UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

1 lines 87.7 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)._={})}(this,(function(e){"use strict";function difference$1(e,t){const n=new Set(t);return e.filter((e=>!n.has(e)))}function differenceWith$1(e,t,n){return e.filter((e=>t.every((t=>!n(e,t)))))}function dropRightWhile$1(e,t){for(let n=e.length-1;n>=0;n--)if(!t(e[n],n,e))return e.slice(0,n+1);return[]}function dropWhile$1(e,t){const n=e.findIndex(((e,n,r)=>!t(e,n,r)));return-1===n?[]:e.slice(n)}class Semaphore{capacity;available;deferredTasks=[];constructor(e){this.capacity=e;this.available=e}async acquire(){if(!(this.available>0))return new Promise((e=>{this.deferredTasks.push(e)}));this.available--}release(){const e=this.deferredTasks.shift();null==e?this.available<this.capacity&&this.available++:e()}}function limitAsync(e,t){const n=new Semaphore(t);return async function(...t){try{await n.acquire();return await e.apply(this,t)}finally{n.release()}}}function flatten$1(e,t=1){const n=[],r=Math.floor(t),recursive=(e,t)=>{for(let i=0;i<e.length;i++){const o=e[i];Array.isArray(o)&&t<r?recursive(o,t+1):n.push(o)}};recursive(e,0);return n}function intersection$1(e,t){const n=new Set(t);return e.filter((e=>n.has(e)))}function intersectionBy$1(e,t,n){const r=[],i=new Set(t.map(n));for(let t=0;t<e.length;t++){const o=e[t],s=n(o);if(i.has(s)){r.push(o);i.delete(s)}}return r}function intersectionWith$1(e,t,n){return e.filter((e=>t.some((t=>n(e,t)))))}function last$1(e){return e[e.length-1]}function pull$1(e,t){const n=new Set(t);let r=0;for(let t=0;t<e.length;t++)n.has(e[t])||(Object.hasOwn(e,t)?e[r++]=e[t]:delete e[r++]);e.length=r;return e}function sample$1(e){return e[Math.floor(Math.random()*e.length)]}function random$1(e,t){if(null==t){t=e;e=0}if(e>=t)throw new Error("Invalid input: The maximum value must be greater than the minimum value.");return Math.random()*(t-e)+e}function randomInt(e,t){return Math.floor(random$1(e,t))}function shuffle$1(e){const t=e.slice();for(let e=t.length-1;e>=1;e--){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}function isSymbol$1(e){return"symbol"==typeof e||e instanceof Symbol}function toNumber(e){return isSymbol$1(e)?NaN:Number(e)}function toFinite(e){if(!e)return 0===e?e:0;if((e=toNumber(e))===1/0||e===-1/0){return(e<0?-1:1)*Number.MAX_VALUE}return e==e?e:0}function toInteger(e){const t=toFinite(e),n=t%1;return n?t-n:t}function uniq$1(e){return[...new Set(e)]}function uniqBy$1(e,t){const n=new Map;for(let r=0;r<e.length;r++){const i=e[r],o=t(i,r,e);n.has(o)||n.set(o,i)}return Array.from(n.values())}function uniqWith$1(e,t){const n=[];for(let r=0;r<e.length;r++){const i=e[r];n.every((e=>!t(e,i)))&&n.push(i)}return n}function unzip$1(e){let t=0;for(let n=0;n<e.length;n++)e[n].length>t&&(t=e[n].length);const n=new Array(t);for(let r=0;r<t;r++){n[r]=new Array(e.length);for(let t=0;t<e.length;t++)n[r][t]=e[t][r]}return n}function windowed(e,t,n=1,{partialWindows:r=!1}={}){if(t<=0||!Number.isInteger(t))throw new Error("Size must be a positive integer.");if(n<=0||!Number.isInteger(n))throw new Error("Step must be a positive integer.");const i=[],o=r?e.length:e.length-t+1;for(let r=0;r<o;r+=n)i.push(e.slice(r,r+t));return i}function zip$1(...e){let t=0;for(let n=0;n<e.length;n++)e[n].length>t&&(t=e[n].length);const n=e.length,r=Array(t);for(let i=0;i<t;++i){const t=Array(n);for(let r=0;r<n;++r)t[r]=e[r][i];r[i]=t}return r}const t="object"==typeof globalThis&&globalThis||"object"==typeof window&&window||"object"==typeof self&&self||"object"==typeof global&&global||function(){return this}()||Function("return this")(),n=void 0!==t.DOMException?t.DOMException:Error;class AbortError extends n{constructor(e="The operation was aborted"){super(e)}}class TimeoutError extends n{constructor(e="The operation was timed out"){super(e)}}function after$1(e,t){if(!Number.isInteger(e)||e<0)throw new Error("n must be a non-negative integer.");let n=0;return(...r)=>{if(++n>=e)return t(...r)}}function ary$1(e,t){return function(...n){return e.apply(this,n.slice(0,t))}}function debounce$1(e,t,{signal:n,edges:r}={}){let i,o=null;const s=null!=r&&r.includes("leading"),u=null==r||r.includes("trailing"),invoke=()=>{if(null!==o){e.apply(i,o);i=void 0;o=null}};let c=null;const schedule=()=>{null!=c&&clearTimeout(c);c=setTimeout((()=>{c=null;(()=>{u&&invoke();cancel()})()}),t)},cancel=()=>{(()=>{if(null!==c){clearTimeout(c);c=null}})();i=void 0;o=null},debounced=function(...e){if(n?.aborted)return;i=this;o=e;const t=null==c;schedule();s&&t&&invoke()};debounced.schedule=schedule;debounced.cancel=cancel;debounced.flush=()=>{invoke()};n?.addEventListener("abort",cancel,{once:!0});return debounced}function flow$1(...e){return function(...t){let n=e.length?e[0].apply(this,t):t[0];for(let t=1;t<e.length;t++)n=e[t].call(this,n);return n}}function identity$1(e){return e}function noop$1(){}function delay$1(e,{signal:t}={}){return new Promise(((n,r)=>{const abortError=()=>{r(new AbortError)},abortHandler=()=>{clearTimeout(i);abortError()};if(t?.aborted)return abortError();const i=setTimeout((()=>{t?.removeEventListener("abort",abortHandler);n()}),e);t?.addEventListener("abort",abortHandler,{once:!0})}))}const r=Number.POSITIVE_INFINITY,DEFAULT_SHOULD_RETRY=()=>!0;function median(e){if(0===e.length)return NaN;const t=e.slice().sort(((e,t)=>e-t)),n=Math.floor(t.length/2);return t.length%2==0?(t[n-1]+t[n])/2:t[n]}function range$1(e,t,n=1){if(null==t){t=e;e=0}if(!Number.isInteger(n)||0===n)throw new Error("The step value must be a non-zero integer.");const r=Math.max(Math.ceil((t-e)/n),0),i=new Array(r);for(let t=0;t<r;t++)i[t]=e+t*n;return i}function isPrimitive(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function isTypedArray$1(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function clone$1(e){if(isPrimitive(e))return e;if(Array.isArray(e)||isTypedArray$1(e)||e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e);if(null==t)return Object.assign(Object.create(t),e);const n=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new n(e);if(e instanceof RegExp){const t=new n(e);t.lastIndex=e.lastIndex;return t}if(e instanceof DataView)return new n(e.buffer.slice(0));if(e instanceof Error){let t;t=e instanceof AggregateError?new n(e.errors,e.message,{cause:e.cause}):new n(e.message,{cause:e.cause});t.stack=e.stack;Object.assign(t,e);return t}if("undefined"!=typeof File&&e instanceof File){return new n([e],e.name,{type:e.type,lastModified:e.lastModified})}if("object"==typeof e){const n=Object.create(t);return Object.assign(n,e)}return e}function getSymbols(e){return Object.getOwnPropertySymbols(e).filter((t=>Object.prototype.propertyIsEnumerable.call(e,t)))}function getTag(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const i="[object RegExp]",o="[object String]",s="[object Number]",u="[object Boolean]",c="[object Arguments]",a="[object Symbol]",l="[object Date]",f="[object Map]",y="[object Set]",p="[object Array]",h="[object Function]",g="[object ArrayBuffer]",m="[object Object]",d="[object Error]",b="[object DataView]",A="[object Uint8Array]",$="[object Uint8ClampedArray]",j="[object Uint16Array]",O="[object Uint32Array]",w="[object BigUint64Array]",k="[object Int8Array]",S="[object Int16Array]",v="[object Int32Array]",I="[object BigInt64Array]",N="[object Float32Array]",E="[object Float64Array]";function isBuffer$1(e){return void 0!==t.Buffer&&t.Buffer.isBuffer(e)}function cloneDeepWithImpl(e,t,n,r=new Map,h=void 0){const d=h?.(e,t,n,r);if(void 0!==d)return d;if(isPrimitive(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){const t=new Array(e.length);r.set(e,t);for(let i=0;i<e.length;i++)t[i]=cloneDeepWithImpl(e[i],i,n,r,h);Object.hasOwn(e,"index")&&(t.index=e.index);Object.hasOwn(e,"input")&&(t.input=e.input);return t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);t.lastIndex=e.lastIndex;return t}if(e instanceof Map){const t=new Map;r.set(e,t);for(const[i,o]of e)t.set(i,cloneDeepWithImpl(o,i,n,r,h));return t}if(e instanceof Set){const t=new Set;r.set(e,t);for(const i of e)t.add(cloneDeepWithImpl(i,void 0,n,r,h));return t}if(isBuffer$1(e))return e.subarray();if(isTypedArray$1(e)){const t=new(Object.getPrototypeOf(e).constructor)(e.length);r.set(e,t);for(let i=0;i<e.length;i++)t[i]=cloneDeepWithImpl(e[i],i,n,r,h);return t}if(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);r.set(e,t);copyProperties(t,e,n,r,h);return t}if("undefined"!=typeof File&&e instanceof File){const t=new File([e],e.name,{type:e.type});r.set(e,t);copyProperties(t,e,n,r,h);return t}if("undefined"!=typeof Blob&&e instanceof Blob){const t=new Blob([e],{type:e.type});r.set(e,t);copyProperties(t,e,n,r,h);return t}if(e instanceof Error){const t=structuredClone(e);r.set(e,t);t.message=e.message;t.name=e.name;t.stack=e.stack;t.cause=e.cause;t.constructor=e.constructor;copyProperties(t,e,n,r,h);return t}if(e instanceof Boolean){const t=new Boolean(e.valueOf());r.set(e,t);copyProperties(t,e,n,r,h);return t}if(e instanceof Number){const t=new Number(e.valueOf());r.set(e,t);copyProperties(t,e,n,r,h);return t}if(e instanceof String){const t=new String(e.valueOf());r.set(e,t);copyProperties(t,e,n,r,h);return t}if("object"==typeof e&&function isCloneableObject$1(e){switch(getTag(e)){case c:case p:case g:case b:case u:case l:case N:case E:case k:case S:case v:case f:case s:case m:case i:case y:case o:case a:case A:case $:case j:case O:return!0;default:return!1}}(e)){const t=Object.create(Object.getPrototypeOf(e));r.set(e,t);copyProperties(t,e,n,r,h);return t}return e}function copyProperties(e,t,n=e,r,i){const o=[...Object.keys(t),...getSymbols(t)];for(let s=0;s<o.length;s++){const u=o[s],c=Object.getOwnPropertyDescriptor(e,u);(null==c||c.writable)&&(e[u]=cloneDeepWithImpl(t[u],u,n,r,i))}}function cloneDeep$1(e){return cloneDeepWithImpl(e,void 0,e,new Map,void 0)}function isPlainObject$1(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function flattenObjectImpl(e,t,n){const r={},i=Object.keys(e);for(let o=0;o<i.length;o++){const s=i[o],u=e[s],c=t?`${t}${n}${s}`:s;isPlainObject$1(u)&&Object.keys(u).length>0?Object.assign(r,flattenObjectImpl(u,c,n)):Array.isArray(u)&&u.length>0?Object.assign(r,flattenObjectImpl(u,c,n)):r[c]=u}return r}function isUnsafeProperty(e){return"__proto__"===e}function mergeWith$1(e,t,n){const r=Object.keys(t);for(let i=0;i<r.length;i++){const o=r[i];if(isUnsafeProperty(o))continue;const s=t[o],u=e[o],c=n(u,s,o,e,t);void 0!==c?e[o]=c:Array.isArray(s)?Array.isArray(u)?e[o]=mergeWith$1(u,s,n):e[o]=mergeWith$1([],s,n):isPlainObject$1(s)?isPlainObject$1(u)?e[o]=mergeWith$1(u,s,n):e[o]=mergeWith$1({},s,n):void 0!==u&&void 0===s||(e[o]=s)}return e}function isArray(e){return Array.isArray(e)}function capitalize$1(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}const L=/\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;function words$1(e){return Array.from(e.match(L)??[])}function camelCase$1(e){const t=words$1(e);if(0===t.length)return"";const[n,...r]=t;return`${n.toLowerCase()}${r.map((e=>capitalize$1(e))).join("")}`}function isPlainObject(e){if("object"!=typeof e)return!1;if(null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];if(null==t)return!1;return!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function snakeCase$1(e){return words$1(e).map((e=>e.toLowerCase())).join("_")}function isBlob(e){return"undefined"!=typeof Blob&&e instanceof Blob}function isEqualsSameValueZero(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function isEqualWith$1(e,t,n){return isEqualWithImpl(e,t,void 0,void 0,void 0,void 0,n)}function isEqualWithImpl(e,t,n,r,i,o,s){const u=s(e,t,n,r,i,o);if(void 0!==u)return u;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return areObjectsEqual(e,t,o,s)}return areObjectsEqual(e,t,o,s)}function areObjectsEqual(e,t,n,r){if(Object.is(e,t))return!0;let L=getTag(e),x=getTag(t);L===c&&(L=m);x===c&&(x=m);if(L!==x)return!1;switch(L){case o:return e.toString()===t.toString();case s:return isEqualsSameValueZero(e.valueOf(),t.valueOf());case u:case l:case a:return Object.is(e.valueOf(),t.valueOf());case i:return e.source===t.source&&e.flags===t.flags;case h:return e===t}const M=(n=n??new Map).get(e),W=n.get(t);if(null!=M&&null!=W)return M===t;n.set(e,t);n.set(t,e);try{switch(L){case f:if(e.size!==t.size)return!1;for(const[i,o]of e.entries())if(!t.has(i)||!isEqualWithImpl(o,t.get(i),i,e,t,n,r))return!1;return!0;case y:{if(e.size!==t.size)return!1;const i=Array.from(e.values()),o=Array.from(t.values());for(let s=0;s<i.length;s++){const u=i[s],c=o.findIndex((i=>isEqualWithImpl(u,i,void 0,e,t,n,r)));if(-1===c)return!1;o.splice(c,1)}return!0}case p:case A:case $:case j:case O:case w:case k:case S:case v:case I:case N:case E:if(isBuffer$1(e)!==isBuffer$1(t))return!1;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!isEqualWithImpl(e[i],t[i],i,e,t,n,r))return!1;return!0;case g:return e.byteLength===t.byteLength&&areObjectsEqual(new Uint8Array(e),new Uint8Array(t),n,r);case b:return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&areObjectsEqual(new Uint8Array(e),new Uint8Array(t),n,r);case d:return e.name===t.name&&e.message===t.message;case m:{if(!(areObjectsEqual(e.constructor,t.constructor,n,r)||isPlainObject$1(e)&&isPlainObject$1(t)))return!1;const i=[...Object.keys(e),...getSymbols(e)],o=[...Object.keys(t),...getSymbols(t)];if(i.length!==o.length)return!1;for(let o=0;o<i.length;o++){const s=i[o],u=e[s];if(!Object.hasOwn(t,s))return!1;if(!isEqualWithImpl(u,t[s],s,e,t,n,r))return!1}return!0}default:return!1}}finally{n.delete(e);n.delete(t)}}function isFunction$1(e){return"function"==typeof e}function isJSONValue(e){switch(typeof e){case"object":return null===e||isJSONArray(e)||isJSONObject(e);case"string":case"number":case"boolean":return!0;default:return!1}}function isJSONArray(e){return!!Array.isArray(e)&&e.every((e=>isJSONValue(e)))}function isJSONObject(e){if(!isPlainObject$1(e))return!1;const t=Reflect.ownKeys(e);for(let n=0;n<t.length;n++){const r=t[n],i=e[r];if("string"!=typeof r)return!1;if(!isJSONValue(i))return!1}return!0}function isNil$1(e){return null==e}function isNull$1(e){return null===e}function isSymbol(e){return"symbol"==typeof e}function isUndefined$1(e){return void 0===e}async function timeout(e){await delay$1(e);throw new TimeoutError}const x=new Map([["Æ","Ae"],["Ð","D"],["Ø","O"],["Þ","Th"],["ß","ss"],["æ","ae"],["ð","d"],["ø","o"],["þ","th"],["Đ","D"],["đ","d"],["Ħ","H"],["ħ","h"],["ı","i"],["IJ","IJ"],["ij","ij"],["ĸ","k"],["Ŀ","L"],["ŀ","l"],["Ł","L"],["ł","l"],["ʼn","'n"],["Ŋ","N"],["ŋ","n"],["Œ","Oe"],["œ","oe"],["Ŧ","T"],["ŧ","t"],["ſ","s"]]);const M={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function trimEnd$1(e,t){if(void 0===t)return e.trimEnd();let n=e.length;switch(typeof t){case"string":if(1!==t.length)throw new Error("The 'chars' parameter should be a single character string.");for(;n>0&&e[n-1]===t;)n--;break;case"object":for(;n>0&&t.includes(e[n-1]);)n--}return e.substring(0,n)}function trimStart$1(e,t){if(void 0===t)return e.trimStart();let n=0;switch(typeof t){case"string":for(;n<e.length&&e[n]===t;)n++;break;case"object":for(;n<e.length&&t.includes(e[n]);)n++}return e.substring(n)}function trim$1(e,t){return void 0===t?e.trim():trimStart$1(trimEnd$1(e,t),t)}const W={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"};function invariant(e,t){if(!e){if("string"==typeof t)throw new Error(t);throw t}}function toArray$1(e){return Array.isArray(e)?e:Array.from(e)}function isArrayLike(e){return null!=e&&"function"!=typeof e&&function isLength$1(e){return Number.isSafeInteger(e)&&e>=0}(e.length)}function isDeepKey(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function toKey(e){return"string"==typeof e||"symbol"==typeof e?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function toString(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return e.map(toString).join(",");const t=String(e);return"0"===t&&Object.is(Number(e),-0)?"-0":t}function toPath(e){if(Array.isArray(e))return e.map(toKey);if("symbol"==typeof e)return[e];const t=[],n=(e=toString(e)).length;if(0===n)return t;let r=0,i="",o="",s=!1;if(46===e.charCodeAt(0)){t.push("");r++}for(;r<n;){const u=e[r];if(o)if("\\"===u&&r+1<n){r++;i+=e[r]}else u===o?o="":i+=u;else if(s)if('"'===u||"'"===u)o=u;else if("]"===u){s=!1;t.push(i);i=""}else i+=u;else if("["===u){s=!0;if(i){t.push(i);i=""}}else if("."===u){if(i){t.push(i);i=""}}else i+=u;r++}i&&t.push(i);return t}function get(e,t,n){if(null==e)return n;switch(typeof t){case"string":{if(isUnsafeProperty(t))return n;const r=e[t];return void 0===r?isDeepKey(t)?get(e,toPath(t),n):n:r}case"number":case"symbol":{"number"==typeof t&&(t=toKey(t));const r=e[t];return void 0===r?n:r}default:{if(Array.isArray(t))return function getWithPath(e,t,n){if(0===t.length)return n;let r=e;for(let e=0;e<t.length;e++){if(null==r)return n;if(isUnsafeProperty(t[e]))return n;r=r[t[e]]}if(void 0===r)return n;return r}(e,t,n);if(isUnsafeProperty(t=Object.is(t?.valueOf(),-0)?"-0":String(t)))return n;const r=e[t];return void 0===r?n:r}}}function property(e){return function(t){return get(t,e)}}function isObject(e){return null!==e&&("object"==typeof e||"function"==typeof e)}function isMatchWith(e,t,n){return"function"!=typeof n?isMatchWith(e,t,(()=>{})):isMatchWithInternal(e,t,(function doesMatch(e,t,r,i,o,s){const u=n(e,t,r,i,o,s);return void 0!==u?Boolean(u):isMatchWithInternal(e,t,doesMatch,s)}),new Map)}function isMatchWithInternal(e,t,n,r){if(t===e)return!0;switch(typeof t){case"object":return function isObjectMatch(e,t,n,r){if(null==t)return!0;if(Array.isArray(t))return isArrayMatch(e,t,n,r);if(t instanceof Map)return function isMapMatch(e,t,n,r){if(0===t.size)return!0;if(!(e instanceof Map))return!1;for(const[i,o]of t.entries()){if(!1===n(e.get(i),o,i,e,t,r))return!1}return!0}(e,t,n,r);if(t instanceof Set)return function isSetMatch(e,t,n,r){if(0===t.size)return!0;if(!(e instanceof Set))return!1;return isArrayMatch([...e],[...t],n,r)}(e,t,n,r);const i=Object.keys(t);if(null==e||isPrimitive(e))return 0===i.length;if(0===i.length)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let o=0;o<i.length;o++){const s=i[o];if(!isPrimitive(e)&&!(s in e))return!1;if(void 0===t[s]&&void 0!==e[s])return!1;if(null===t[s]&&null!==e[s])return!1;if(!n(e[s],t[s],s,e,t,r))return!1}return!0}finally{r?.delete(t)}}(e,t,n,r);case"function":return Object.keys(t).length>0?isMatchWithInternal(e,{...t},n,r):isEqualsSameValueZero(e,t);default:return isObject(e)?"string"!=typeof t||""===t:isEqualsSameValueZero(e,t)}}function isArrayMatch(e,t,n,r){if(0===t.length)return!0;if(!Array.isArray(e))return!1;const i=new Set;for(let o=0;o<t.length;o++){const s=t[o];let u=!1;for(let c=0;c<e.length;c++){if(i.has(c))continue;let a=!1;n(e[c],s,o,e,t,r)&&(a=!0);if(a){i.add(c);u=!0;break}}if(!u)return!1}return!0}function isMatch(e,t){return isMatchWith(e,t,(()=>{}))}function matches(e){e=cloneDeep$1(e);return t=>isMatch(t,e)}function cloneDeepWith(e,t){return function cloneDeepWith$1(e,t){return cloneDeepWithImpl(e,void 0,e,new Map,t)}(e,((n,r,i,a)=>{const l=t?.(n,r,i,a);if(void 0!==l)return l;if("object"==typeof e){if(getTag(e)===m&&"function"!=typeof e.constructor){const t={};a.set(e,t);copyProperties(t,e,i,a);return t}switch(Object.prototype.toString.call(e)){case s:case o:case u:{const t=new e.constructor(e?.valueOf());copyProperties(t,e);return t}case c:{const t={};copyProperties(t,e);t.length=e.length;t[Symbol.iterator]=e[Symbol.iterator];return t}default:return}}}))}function cloneDeep(e){return cloneDeepWith(e)}const P=/^(?:0|[1-9]\d*)$/;function isIndex(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return P.test(e)}}function isArguments(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===getTag(e)}function has(e,t){let n;n=Array.isArray(t)?t:"string"==typeof t&&isDeepKey(t)&&null==e?.[t]?toPath(t):[t];if(0===n.length)return!1;let r=e;for(let e=0;e<n.length;e++){const t=n[e];if(null==r||!Object.hasOwn(r,t)){if(!((Array.isArray(r)||isArguments(r))&&isIndex(t)&&t<r.length))return!1}r=r[t]}return!0}function matchesProperty(e,t){switch(typeof e){case"object":Object.is(e?.valueOf(),-0)&&(e="-0");break;case"number":e=toKey(e)}t=cloneDeep(t);return function(n){const r=get(n,e);return void 0===r?has(n,e):void 0===t?void 0===r:isMatch(r,t)}}function iteratee(e){if(null==e)return identity$1;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&2===e.length?matchesProperty(e[0],e[1]):matches(e);case"string":case"symbol":case"number":return property(e)}}function isObjectLike(e){return"object"==typeof e&&null!==e}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}function last(e){if(isArrayLike(e))return last$1(toArray$1(e))}function flattenArrayLike(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];if(isArrayLikeObject(r))for(let e=0;e<r.length;e++)t.push(r[e])}return t}function differenceBy(e,...t){if(!isArrayLikeObject(e))return[];const n=last(t),r=flattenArrayLike(t);return isArrayLikeObject(n)?difference$1(Array.from(e),r):function differenceBy$1(e,t,n){const r=new Set(t.map((e=>n(e))));return e.filter((e=>!r.has(n(e))))}(Array.from(e),r,iteratee(n))}function differenceWith(e,...t){if(!isArrayLikeObject(e))return[];const n=last(t),r=flattenArrayLike(t);return"function"==typeof n?differenceWith$1(Array.from(e),r,n):difference$1(Array.from(e),r)}function forEach(e,t=identity$1){if(!e)return e;const n=isArrayLike(e)||Array.isArray(e)?range$1(0,e.length):Object.keys(e);for(let r=0;r<n.length;r++){const i=n[r];if(!1===t(e[i],i,e))break}return e}function forEachRight(e,t=identity$1){if(!e)return e;const n=isArrayLike(e)?range$1(0,e.length):Object.keys(e);for(let r=n.length-1;r>=0;r--){const i=n[r];if(!1===t(e[i],i,e))break}return e}function isIterateeCall(e,t,n){return!!isObject(n)&&(!!("number"==typeof t&&isArrayLike(n)&&isIndex(t)&&t<n.length||"string"==typeof t&&t in n)&&isEqualsSameValueZero(n[t],e))}function isString(e){return"string"==typeof e||e instanceof String}function filter(e,t=identity$1){if(!e)return[];t=iteratee(t);if(!Array.isArray(e)){const n=[],r=Object.keys(e),i=isArrayLike(e)?e.length:r.length;for(let o=0;o<i;o++){const i=r[o],s=e[i];t(s,i,e)&&n.push(s)}return n}const n=[],r=e.length;for(let i=0;i<r;i++){const r=e[i];t(r,i,e)&&n.push(r)}return n}function identity(e){return e}function head(e){if(isArrayLike(e))return function head$1(e){return e[0]}(toArray$1(e))}function flatten(e,t=1){const n=[],r=Math.floor(t);if(!isArrayLike(e))return n;const recursive=(e,t)=>{for(let i=0;i<e.length;i++){const o=e[i];t<r&&(Array.isArray(o)||Boolean(o?.[Symbol.isConcatSpreadable])||null!==o&&"object"==typeof o&&"[object Arguments]"===Object.prototype.toString.call(o))?Array.isArray(o)?recursive(o,t+1):recursive(Array.from(o),t+1):n.push(o)}};recursive(Array.from(e),0);return n}function flattenDepth(e,t=1){return flatten(e,t)}function map(e,t){if(!e)return[];const n=isArrayLike(e)||Array.isArray(e)?range$1(0,e.length):Object.keys(e),r=iteratee(t??identity$1),i=new Array(n.length);for(let t=0;t<n.length;t++){const o=n[t],s=e[o];i[t]=r(s,o,e)}return i}function flatMapDepth(e,t=identity$1,n=1){if(null==e)return[];return flatten(map(e,iteratee(t)),n)}function intersectionBy(e,...t){if(!isArrayLikeObject(e))return[];const n=last$1(t);if(void 0===n)return Array.from(e);let r=uniq$1(Array.from(e));const i=isArrayLikeObject(n)?t.length:t.length-1;for(let e=0;e<i;++e){const i=t[e];if(!isArrayLikeObject(i))return[];isArrayLikeObject(n)?r=intersectionBy$1(r,Array.from(i),identity$1):"function"==typeof n?r=intersectionBy$1(r,Array.from(i),(e=>n(e))):"string"==typeof n&&(r=intersectionBy$1(r,Array.from(i),property(n)))}return r}function uniq(e){return isArrayLike(e)?uniq$1(Array.from(e)):[]}function intersectionWith(e,...t){if(null==e)return[];const n=last(t);let r=isEqualsSameValueZero,i=uniq;if("function"==typeof n){r=n;i=uniqPreserve0;t.pop()}let o=i(Array.from(e));for(let e=0;e<t.length;++e){const n=t[e];if(null==n)return[];o=intersectionWith$1(o,Array.from(n),r)}return o}function uniqPreserve0(e){const t=[],n=new Set;for(let r=0;r<e.length;r++){const i=e[r];if(!n.has(i)){t.push(i);n.add(i)}}return t}function reduce(e,t=identity$1,n){if(!e)return n;let r,i=0;if(isArrayLike(e)){r=range$1(0,e.length);if(null==n&&e.length>0){n=e[0];i+=1}}else{r=Object.keys(e);if(null==n){n=e[r[0]];i+=1}}for(let o=i;o<r.length;o++){const i=r[o];n=t(n,e[i],i,e)}return n}function getPriority(e){return"symbol"==typeof e?1:null===e?2:void 0===e?3:e!=e?4:0}const compareValues=(e,t,n)=>{if(e!==t){const r=getPriority(e),i=getPriority(t);if(r===i&&0===r){if(e<t)return"desc"===n?1:-1;if(e>t)return"desc"===n?-1:1}return"desc"===n?i-r:r-i}return 0},B=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,R=/^\w*$/;function isKey(e,t){return!Array.isArray(e)&&(!("number"!=typeof e&&"boolean"!=typeof e&&null!=e&&!isSymbol$1(e))||("string"==typeof e&&(R.test(e)||!B.test(e))||null!=t&&Object.hasOwn(t,e)))}function orderBy(e,t,n,r){if(null==e)return[];n=r?void 0:n;Array.isArray(e)||(e=Object.values(e));Array.isArray(t)||(t=null==t?[null]:[t]);0===t.length&&(t=[null]);Array.isArray(n)||(n=null==n?[]:[n]);n=n.map((e=>String(e)));const getValueByNestedPath=(e,t)=>{let n=e;for(let e=0;e<t.length&&null!=n;++e)n=n[t[e]];return n},i=t.map((e=>{Array.isArray(e)&&1===e.length&&(e=e[0]);return null==e||"function"==typeof e||Array.isArray(e)||isKey(e)?e:{key:e,path:toPath(e)}}));return e.map((e=>({original:e,criteria:i.map((t=>((e,t)=>null==t||null==e?t:"object"==typeof e&&"key"in e?Object.hasOwn(t,e.key)?t[e.key]:getValueByNestedPath(t,e.path):"function"==typeof e?e(t):Array.isArray(e)?getValueByNestedPath(t,e):"object"==typeof t?t[e]:t)(t,e)))}))).slice().sort(((e,t)=>{for(let r=0;r<i.length;r++){const i=compareValues(e.criteria[r],t.criteria[r],n[r]);if(0!==i)return i}return 0})).map((e=>e.original))}function at(e,...t){if(0===t.length)return[];const n=[];for(let e=0;e<t.length;e++){const r=t[e];if(isArrayLike(r)&&!isString(r))for(let e=0;e<r.length;e++)n.push(r[e]);else n.push(r)}const r=[];for(let t=0;t<n.length;t++)r.push(get(e,n[t]));return r}function unset(e,t){if(null==e)return!0;switch(typeof t){case"symbol":case"number":case"object":if(Array.isArray(t))return unsetWithPath(e,t);"number"==typeof t?t=toKey(t):"object"==typeof t&&(t=Object.is(t?.valueOf(),-0)?"-0":String(t));if(isUnsafeProperty(t))return!1;if(void 0===e?.[t])return!0;try{delete e[t];return!0}catch{return!1}case"string":if(void 0===e?.[t]&&isDeepKey(t))return unsetWithPath(e,toPath(t));if(isUnsafeProperty(t))return!1;try{delete e[t];return!0}catch{return!1}}}function unsetWithPath(e,t){const n=1===t.length?e:get(e,t.slice(0,-1)),r=t[t.length-1];if(void 0===n?.[r])return!0;if(isUnsafeProperty(r))return!1;try{delete n[r];return!0}catch{return!1}}function negate(e){if("function"!=typeof e)throw new TypeError("Expected a function");return function(...t){return!e.apply(this,t)}}function clamp(e,t,n){if(void 0===n){n=t;t=void 0}if(void 0!==n){n=toNumber(n);e=Math.min(e,Number.isNaN(n)?0:n)}if(void 0!==t){t=toNumber(t);e=Math.max(e,Number.isNaN(t)?0:t)}return e}function isMap(e){return function isMap$1(e){return e instanceof Map}(e)}function toArray(e){return null==e?[]:isArrayLike(e)||isMap(e)?Array.from(e):"object"==typeof e?Object.values(e):[]}function values(e){return null==e?[]:Object.values(e)}function isNil(e){return null==e}function isNaN(e){return Number.isNaN(e)}const T=4294967294;function sortedIndexBy(e,t,n=identity,r){if(isNil(e)||0===e.length)return 0;let i=0,o=e.length;const s=iteratee(n),u=s(t),c=isNaN(u),a=isNull$1(u),l=isSymbol$1(u),f=isUndefined$1(u);for(;i<o;){let t;const n=Math.floor((i+o)/2),y=s(e[n]),p=!isUndefined$1(y),h=isNull$1(y),g=!isNaN(y),m=isSymbol$1(y);t=c?r||g:f?g&&(r||p):a?g&&p&&(r||!h):l?g&&p&&!h&&(r||!m):!h&&!m&&(r?y<=u:y<u);t?i=n+1:o=n}return Math.min(o,T)}function isNumber(e){return"number"==typeof e||e instanceof Number}const D=2147483647;function sortedIndex(e,t){if(isNil$1(e))return 0;let n=0,r=e.length;if(isNumber(t)&&t==t&&r<=D){for(;n<r;){const i=n+r>>>1,o=e[i];!isNull$1(o)&&!isSymbol(o)&&o<t?n=i+1:r=i}return r}return sortedIndexBy(e,t,(e=>e))}function sortedLastIndexBy(e,t,n){return sortedIndexBy(e,t,n,!0)}const C=2147483647;function sortedLastIndex(e,t){if(isNil$1(e))return 0;let n=e.length;if(!isNumber(t)||Number.isNaN(t)||n>C)return sortedLastIndexBy(e,t,(e=>e));let r=0;for(;r<n;){const i=r+n>>>1,o=e[i];!isNull$1(o)&&!isSymbol(o)&&o<=t?r=i+1:n=i}return n}function unionBy(...e){const t=last$1(e),n=flattenArrayLike(e);return isArrayLikeObject(t)||null==t?uniq$1(n):uniqBy$1(n,ary$1(iteratee(t),1))}function unionWith(...e){const t=last$1(e),n=flattenArrayLike(e);return isArrayLikeObject(t)||null==t?uniq$1(n):uniqWith$1(n,t)}function unzip(e){return isArrayLikeObject(e)&&e.length?unzip$1(e=(e=isArray(e)?e:Array.from(e)).filter((e=>isArrayLikeObject(e)))):[]}const assignValue=(e,t,n)=>{const r=e[t];Object.hasOwn(e,t)&&isEqualsSameValueZero(r,n)&&(void 0!==n||t in e)||(e[t]=n)};function updateWith(e,t,n,r){if(null==e&&!isObject(e))return e;let i;i=isKey(t,e)?[t]:Array.isArray(t)?t:toPath(t);const o=n(get(e,i));let s=e;for(let t=0;t<i.length&&null!=s;t++){const n=toKey(i[t]);if(isUnsafeProperty(n))continue;let u;if(t===i.length-1)u=o;else{const o=s[n],c=r?.(o,n,e);u=void 0!==c?c:isObject(o)?o:isIndex(i[t+1])?[]:{}}assignValue(s,n,u);s=s[n]}return e}function set(e,t,n){return updateWith(e,t,(()=>n),(()=>{}))}function ary(e,t=e.length,n){n&&(t=e.length);(Number.isNaN(t)||t<0)&&(t=0);return ary$1(e,t)}function attempt(e,...t){try{return e(...t)}catch(e){return e instanceof Error?e:new Error(e)}}function bind(e,t,...n){const bound=function(...r){const i=[];let o=0;for(let e=0;e<n.length;e++){const t=n[e];t===bind.placeholder?i.push(r[o++]):i.push(t)}for(let e=o;e<r.length;e++)i.push(r[e]);return this instanceof bound?new e(...i):e.apply(t,i)};return bound}const q=Symbol("bind.placeholder");bind.placeholder=q;function bindKey(e,t,...n){const bound=function(...r){const i=[];let o=0;for(let e=0;e<n.length;e++){const t=n[e];t===bindKey.placeholder?i.push(r[o++]):i.push(t)}for(let e=o;e<r.length;e++)i.push(r[e]);return this instanceof bound?new e[t](...i):e[t].apply(e,i)};return bound}const F=Symbol("bindKey.placeholder");bindKey.placeholder=F;function curry(e,t=e.length,n){t=n?e.length:t;t=Number.parseInt(t,10);(Number.isNaN(t)||t<1)&&(t=0);const wrapper=function(...n){const r=n.filter((e=>e===curry.placeholder)),i=n.length-r.length;return i<t?makeCurry(e,t-i,n):this instanceof wrapper?new e(...n):e.apply(this,n)};wrapper.placeholder=z;return wrapper}function makeCurry(e,t,n){function wrapper(...r){const i=r.filter((e=>e===curry.placeholder)),o=r.length-i.length;r=function composeArgs$1(e,t){const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o===curry.placeholder&&r<e.length?n.push(e[r++]):n.push(o)}for(let t=r;t<e.length;t++)n.push(e[t]);return n}(r,n);return o<t?makeCurry(e,t-o,r):this instanceof wrapper?new e(...r):e.apply(this,r)}wrapper.placeholder=z;return wrapper}const z=Symbol("curry.placeholder");curry.placeholder=z;function curryRight(e,t=e.length,n){t=n?e.length:t;t=Number.parseInt(t,10);(Number.isNaN(t)||t<1)&&(t=0);const wrapper=function(...n){const r=n.filter((e=>e===curryRight.placeholder)),i=n.length-r.length;return i<t?makeCurryRight(e,t-i,n):this instanceof wrapper?new e(...n):e.apply(this,n)};wrapper.placeholder=_;return wrapper}function makeCurryRight(e,t,n){function wrapper(...r){const i=r.filter((e=>e===curryRight.placeholder)),o=r.length-i.length;r=function composeArgs(e,t){const n=t.filter((e=>e===curryRight.placeholder)).length,r=Math.max(e.length-n,0),i=[];let o=0;for(let t=0;t<r;t++)i.push(e[o++]);for(let n=0;n<t.length;n++){const r=t[n];r===curryRight.placeholder&&o<e.length?i.push(e[o++]):i.push(r)}return i}(r,n);return o<t?makeCurryRight(e,t-o,r):this instanceof wrapper?new e(...r):e.apply(this,r)}wrapper.placeholder=_;return wrapper}const _=Symbol("curryRight.placeholder");curryRight.placeholder=_;function debounce(e,t=0,n={}){"object"!=typeof n&&(n={});const{leading:r=!1,trailing:i=!0,maxWait:o}=n,s=Array(2);r&&(s[0]="leading");i&&(s[1]="trailing");let u,c=null;const a=debounce$1((function(...t){u=e.apply(this,t);c=null}),t,{edges:s}),debounced=function(...t){if(null!=o){null===c&&(c=Date.now());if(Date.now()-c>=o){u=e.apply(this,t);c=Date.now();a.cancel();a.schedule();return u}}a.apply(this,t);return u};debounced.cancel=a.cancel;debounced.flush=()=>{a.flush();return u};return debounced}function memoize(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");const memoized=function(...n){const r=t?t.apply(this,n):n[0],i=memoized.cache;if(i.has(r))return i.get(r);const o=e.apply(this,n);memoized.cache=i.set(r,o)||i;return o},n=memoize.Cache||Map;memoized.cache=new n;return memoized}memoize.Cache=Map;function partial(e,...t){return function partialImpl(e,t,...n){const partialed=function(...r){let i=0;const o=n.slice().map((e=>e===t?r[i++]:e)),s=r.slice(i);return e.apply(this,o.concat(s))};e.prototype&&(partialed.prototype=Object.create(e.prototype));return partialed}(e,partial.placeholder,...t)}partial.placeholder=Symbol("compat.partial.placeholder");function partialRight(e,...t){return function partialRightImpl(e,t,...n){const partialedRight=function(...r){const i=n.filter((e=>e===t)).length,o=Math.max(r.length-i,0),s=r.slice(0,o);let u=o;const c=n.slice().map((e=>e===t?r[u++]:e));return e.apply(this,s.concat(c))};e.prototype&&(partialedRight.prototype=Object.create(e.prototype));return partialedRight}(e,partialRight.placeholder,...t)}partialRight.placeholder=Symbol("compat.partialRight.placeholder");function decimalAdjust(e,t,n=0){t=Number(t);Object.is(t,-0)&&(t="-0");if(n=Math.min(Number.parseInt(n,10),292)){const[r,i=0]=t.toString().split("e");let o=Math[e](Number(`${r}e${Number(i)+n}`));Object.is(o,-0)&&(o="-0");const[s,u=0]=o.toString().split("e");return Number(`${s}e${Number(u)-n}`)}return Math[e](Number(t))}function sumBy(e,t){if(!e||!e.length)return 0;null!=t&&(t=iteratee(t));let n;for(let r=0;r<e.length;r++){const i=t?t(e[r]):e[r];void 0!==i&&(void 0===n?n=i:n+=i)}return n}function sum(e){return sumBy(e)}function isPrototype(e){const t=e?.constructor;return e===("function"==typeof t?t.prototype:Object.prototype)}function isTypedArray(e){return isTypedArray$1(e)}function times(e,t){if((e=toInteger(e))<1||!Number.isSafeInteger(e))return[];const n=new Array(e);for(let r=0;r<e;r++)n[r]="function"==typeof t?t(r):r;return n}function keys(e){if(isArrayLike(e))return function arrayLikeKeys(e){const t=times(e.length,(e=>`${e}`)),n=new Set(t);if(isBuffer$1(e)){n.add("offset");n.add("parent")}if(isTypedArray(e)){n.add("buffer");n.add("byteLength");n.add("byteOffset")}const r=Object.keys(e).filter((e=>!n.has(e)));if(Array.isArray(e))return[...t,...r];return[...t.filter((t=>Object.hasOwn(e,t))),...r]}(e);const t=Object.keys(Object(e));return isPrototype(e)?t.filter((e=>"constructor"!==e)):t}function assignImpl(e,t){const n=keys(t);for(let r=0;r<n.length;r++){const i=n[r];i in e&&isEqualsSameValueZero(e[i],t[i])||(e[i]=t[i])}}function keysIn(e){if(null==e)return[];switch(typeof e){case"object":case"function":return isArrayLike(e)?function arrayLikeKeysIn(e){const t=times(e.length,(e=>`${e}`)),n=new Set(t);if(isBuffer$1(e)){n.add("offset");n.add("parent")}if(isTypedArray(e)){n.add("buffer");n.add("byteLength");n.add("byteOffset")}const r=keysInImpl(e).filter((e=>!n.has(e)));if(Array.isArray(e))return[...t,...r];return[...t.filter((t=>Object.hasOwn(e,t))),...r]}(e):isPrototype(e)?function prototypeKeysIn(e){const t=keysInImpl(e);return t.filter((e=>"constructor"!==e))}(e):keysInImpl(e);default:return keysInImpl(Object(e))}}function keysInImpl(e){const t=[];for(const n in e)t.push(n);return t}function assignIn(e,...t){for(let n=0;n<t.length;n++)assignInImpl(e,t[n]);return e}function assignInImpl(e,t){const n=keysIn(t);for(let r=0;r<n.length;r++){const i=n[r];i in e&&isEqualsSameValueZero(e[i],t[i])||(e[i]=t[i])}}function assignInWith(e,...t){let n=t[t.length-1];"function"==typeof n?t.pop():n=void 0;for(let r=0;r<t.length;r++)assignInWithImpl(e,t[r],n);return e}function assignInWithImpl(e,t,n){const r=keysIn(t);for(let i=0;i<r.length;i++){const o=r[i],s=e[o],u=t[o],c=n?.(s,u,o,e,t)??u;o in e&&isEqualsSameValueZero(s,c)||(e[o]=c)}}function assignWithImpl(e,t,n){const r=keys(t);for(let i=0;i<r.length;i++){const o=r[i],s=e[o],u=t[o],c=n?.(s,u,o,e,t)??u;o in e&&isEqualsSameValueZero(s,c)||(e[o]=c)}}function clone(e){if(isPrimitive(e))return e;const t=getTag(e);if(!function isCloneableObject(e){switch(getTag(e)){case c:case p:case g:case b:case u:case l:case N:case E:case k:case S:case v:case f:case s:case m:case i:case y:case o:case a:case A:case $:case j:case O:return!0;default:return!1}}(e))return{};if(isArray(e)){const t=Array.from(e);if(e.length>0&&"string"==typeof e[0]&&Object.hasOwn(e,"index")){t.index=e.index;t.input=e.input}return t}if(isTypedArray(e)){const t=e;return new(0,t.constructor)(t.buffer,t.byteOffset,t.length)}if(t===g)return new ArrayBuffer(e.byteLength);if(t===b){const t=e,n=t.buffer,r=t.byteOffset,i=t.byteLength,o=new ArrayBuffer(i),s=new Uint8Array(n,r,i);new Uint8Array(o).set(s);return new DataView(o)}if(t===u||t===s||t===o){const n=new(0,e.constructor)(e.valueOf());t===o?function cloneStringObjectProperties(e,t){const n=t.valueOf().length;for(const r in t)Object.hasOwn(t,r)&&(Number.isNaN(Number(r))||Number(r)>=n)&&(e[r]=t[r])}(n,e):copyOwnProperties(n,e);return n}if(t===l)return new Date(Number(e));if(t===i){const t=e,n=new RegExp(t.source,t.flags);n.lastIndex=t.lastIndex;return n}if(t===a)return Object(Symbol.prototype.valueOf.call(e));if(t===f){const t=e,n=new Map;t.forEach(((e,t)=>{n.set(t,e)}));return n}if(t===y){const t=e,n=new Set;t.forEach((e=>{n.add(e)}));return n}if(t===c){const t=e,n={};copyOwnProperties(n,t);n.length=t.length;n[Symbol.iterator]=t[Symbol.iterator];return n}const n={};!function copyPrototype(e,t){const n=Object.getPrototypeOf(t);if(null!==n){"function"==typeof t.constructor&&Object.setPrototypeOf(e,n)}}(n,e);copyOwnProperties(n,e);!function copySymbolProperties(e,t){const n=Object.getOwnPropertySymbols(t);for(let r=0;r<n.length;r++){const i=n[r];Object.prototype.propertyIsEnumerable.call(t,i)&&(e[i]=t[i])}}(n,e);return n}function copyOwnProperties(e,t){for(const n in t)Object.hasOwn(t,n)&&(e[n]=t[n])}function defaults(e,...t){e=Object(e);const n=Object.prototype;let r=t.length;const i=r>2?t[2]:void 0;i&&isIterateeCall(t[0],t[1],i)&&(r=1);for(let i=0;i<r;i++){if(isNil$1(t[i]))continue;const r=t[i],o=Object.keys(r);for(let t=0;t<o.length;t++){const i=o[t],s=e[i];(void 0===s||!Object.hasOwn(e,i)&&isEqualsSameValueZero(s,n[i]))&&(e[i]=r[i])}}return e}function defaultsDeepRecursive(e,t,n){for(const r in t){const i=t[r],o=e[r];void 0!==o&&Object.hasOwn(e,r)?n.get(i)!==o&&handleExistingProperty(o,i,n):e[r]=handleMissingProperty(i,n)}}function handleMissingProperty(e,t){if(t.has(e))return t.get(e);if(isPlainObject(e)){const n={};t.set(e,n);defaultsDeepRecursive(n,e,t);return n}return e}function handleExistingProperty(e,t,n){if(isPlainObject(e)&&isPlainObject(t)){n.set(t,e);defaultsDeepRecursive(e,t,n)}else if(Array.isArray(e)&&Array.isArray(t)){n.set(t,e);!function mergeArrays(e,t,n){const r=Math.min(t.length,e.length);for(let i=0;i<r;i++)isPlainObject(e[i])&&isPlainObject(t[i])&&defaultsDeepRecursive(e[i],t[i],n);for(let n=r;n<t.length;n++)e.push(t[n])}(e,t,n)}}function mergeWith(e,...t){const n=t.slice(0,-1),r=t[t.length-1];let i=e;for(let e=0;e<n.length;e++){i=mergeWithDeep(i,n[e],r,new Map)}return i}function mergeWithDeep(e,t,n,r){isPrimitive(e)&&(e=Object(e));if(null==t||"object"!=typeof t)return e;if(r.has(t))return clone$1(r.get(t));r.set(t,e);if(Array.isArray(t)){t=t.slice();for(let e=0;e<t.length;e++)t[e]=t[e]??void 0}const i=[...Object.keys(t),...getSymbols(t)];for(let o=0;o<i.length;o++){const s=i[o];if(isUnsafeProperty(s))continue;let u=t[s],c=e[s];isArguments(u)&&(u={...u});isArguments(c)&&(c={...c});isBuffer$1(u)&&(u=cloneDeep(u));if(Array.isArray(u))if(Array.isArray(c)){const e=[],t=Reflect.ownKeys(c);for(let n=0;n<t.length;n++){const r=t[n];e[r]=c[r]}c=e}else if(isArrayLikeObject(c)){const e=[];for(let t=0;t<c.length;t++)e[t]=c[t];c=e}else c=[];const a=n(c,u,s,e,t,r);void 0!==a?e[s]=a:Array.isArray(u)||isObjectLike(c)&&isObjectLike(u)&&(isPlainObject(c)||isPlainObject(u)||isTypedArray(c)||isTypedArray(u))?e[s]=mergeWithDeep(c,u,n,r):null==c&&isPlainObject(u)?e[s]=mergeWithDeep({},u,n,r):null==c&&isTypedArray(u)?e[s]=cloneDeep(u):void 0!==c&&void 0===u||(e[s]=u)}return e}function getSymbolsIn(e){const t=[];for(;e;){t.push(...getSymbols(e));e=Object.getPrototypeOf(e)}return t}function mapToEntries(e){const t=new Array(e.size),n=e.keys(),r=e.values();for(let e=0;e<t.length;e++)t[e]=[n.next().value,r.next().value];return t}function setToEntries(e){const t=new Array(e.size),n=e.values();for(let e=0;e<t.length;e++){const r=n.next().value;t[e]=[r,r]}return t}function isBuffer(e){return isBuffer$1(e)}const K=Function.prototype.toString,U=RegExp(`^${K.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")}$`);function conformsTo(e,t){if(null==t)return!0;if(null==e)return 0===Object.keys(t).length;const n=Object.keys(t);for(let r=0;r<n.length;r++){const i=n[r],o=t[i],s=e[i];if(void 0===s&&!(i in e))return!1;if("function"==typeof o&&!o(s))return!1}return!0}function deburr(e){return function deburr$1(e){e=e.normalize("NFD");let t="";for(let n=0;n<e.length;n++){const r=e[n];r>="̀"&&r<="ͯ"||r>="︠"&&r<="︣"||(t+=x.get(r)??r)}return t}(toString(e))}function normalizeForCase(e){"string"!=typeof e&&(e=toString(e));return e.replace(/['\u2019]/g,"")}function escape(e){return function escape$1(e){return e.replace(/[&<>"']/g,(e=>M[e]))}(toString(e))}const V=Number.MAX_SAFE_INTEGER;const Z=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,J=/['\n\r\u2028\u2029\\]/g,X=/($^)/,G=new Map([["\\","\\"],["'","'"],["\n","n"],["\r","r"],["\u2028","u2028"],["\u2029","u2029"]]);function escapeString(e){return`\\${G.get(e)}`}const H=/<%=([\s\S]+?)%>/g,Y={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:H,variable:"",imports:{_:{escape,template}}};function template(e,t,n){e=toString(e);n&&(t=Y);t=defaults({...t},Y);const r=new RegExp([t.escape?.source??X.source,t.interpolate?.source??X.source,t.interpolate===H?Z.source:X.source,t.evaluate?.source??X.source,"$"].join("|"),"g");let i=0,o=!1,s="__p += ''";for(const t of e.matchAll(r)){const[n,r,u,c,a]=t,{index:l}=t;s+=` + '${e.slice(i,l).replace(J,escapeString)}'`;r&&(s+=` + _.escape(${r})`);u?s+=` + ((${u}) == null ? '' : ${u})`:c&&(s+=` + ((${c}) == null ? '' : ${c})`);if(a){s+=`;\n${a};\n __p += ''`;o=!0}i=l+n.length}const u=defaults({...t.imports},Y.imports),c=Object.keys(u),a=Object.values(u),l=`//# sourceURL=${t.sourceURL?String(t.sourceURL).replace(/[\r\n]/g," "):`es-toolkit.templateSource[${Date.now()}]`}\n`,f=`function(${t.variable||"obj"}) {\n let __p = '';\n ${t.variable?"":"if (obj == null) { obj = {}; }"}\n ${o?"function print() { __p += Array.prototype.join.call(arguments, ''); }":""}\n ${t.variable?s:`with(obj) {\n${s}\n}`}\n return __p;\n }`,y=attempt((()=>new Function(...c,`${l}return ${f}`)(...a)));y.source=f;if(y instanceof Error)throw y;return y}const Q=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;const ee="\\p{Lu}",te="\\p{Ll}",ne="(?:[\\p{Lm}\\p{Lo}]\\p{M}*)",re="\\d",ie="(?:['’](?:d|ll|m|re|s|t|ve))?",oe="(?:['’](?:D|LL|M|RE|S|T|VE))?",se="[\\p{Z}\\p{P}\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\xd7\\xf7]",ue=`(?:${te}|${ne})`,ce=RegExp([`${ee}?${te}+${ie}(?=${se}|${ee}|$)`,`${`(?:${ee}|${ne})`}+${oe}(?=${se}|${ee}${ue}|$)`,`${ee}?${ue}+${ie}`,`${ee}+${oe}`,`${re}*(?:1ST|2ND|3RD|(?![123])${re}TH)(?=\\b|[a-z_])`,`${re}*(?:1st|2nd|3rd|(?![123])${re}th)(?=\\b|[A-Z_])`,`${re}+`,"\\p{Emoji_Presentation}","\\p{Extended_Pictographic}"].join("|"),"gu");function invoke(e,t,...n){n=n.flat(1);if(null!=e)switch(typeof t){case"string":return"object"==typeof e&&Object.hasOwn(e,t)?invokeImpl(e,[t],n):invokeImpl(e,toPath(t),n);case"number":case"symbol":return invokeImpl(e,[t],n);default:return Array.isArray(t)?invokeImpl(e,t,n):invokeImpl(e,[t],n)}}function invokeImpl(e,t,n){const r=get(e,t.slice(0,-1),e);if(null==r)return;let i=last(t);const o=i?.valueOf();i="number"==typeof o?toKey(o):String(i);const s=get(r,i);return s?.apply(r,n)}let ae=0;e.AbortError=AbortError;e.Mutex=class Mutex{semaphore=new Semaphore(1);get isLocked(){return 0===this.semaphore.available}async acquire(){return this.semaphore.acquire()}release(){this.semaphore.release()}};e.Semaphore=Semaphore;e.TimeoutError=TimeoutError;e.add=function add(e,t){if(void 0===e&&void 0===t)return 0;if(void 0===e||void 0===t)return e??t;if("string"==typeof e||"string"==typeof t){e=toString(e);t=toString(t)}else{e=toNumber(e);t=toNumber(t)}return e+t};e.after=function after(e,t){if("function"!=typeof t)throw new TypeError("Expected a function");e=toInteger(e);return function(...n){if(--e<1)return t.apply(this,n)}};e.ary=ary;e.assert=invariant;e.assign=function assign(e,...t){for(let n=0;n<t.length;n++)assignImpl(e,t[n]);return e};e.assignIn=assignIn;e.assignInWith=assignInWith;e.assignWith=function assignWith(e,...t){let n=t[t.length-1];"function"==typeof n?t.pop():n=void 0;for(let r=0;r<t.length;r++)assignWithImpl(e,t[r],n);return e};e.asyncNoop=async function asyncNoop(){};e.at=at;e.attempt=attempt;e.attemptAsync=async function attemptAsync(e){try{return[null,await e()]}catch(e){return[e,null]}};e.before=function before(e,t){if("function"!=typeof t)throw new TypeError("Expected a function");let n;e=toInteger(e);return function(...r){--e>0&&(n=t.apply(this,r));e<=1&&t&&(t=void 0);return n}};e.bind=bind;e.bindAll=function bindAll(e,...t){if(null==e)return e;if(!isObject(e))return e;if(isArray(e)&&0===t.length)return e;const n=[];for(let e=0;e<t.length;e++){const r=t[e];isArray(r)?n.push(...r):r&&"object"==typeof r&&"length"in r?n.push(...Array.from(r)):n.push(r)}if(0===n.length)return e;for(let t=0;t<n.length;t++){const r=toString(n[t]),i=e[r];isFunction$1(i)&&(e[r]=i.bind(e))}return e};e.bindKey=bindKey;e.camelCase=function camelCase(e){return camelCase$1(normalizeForCase(deburr(e)))};e.capitalize=function capitalize(e){return capitalize$1(toString(e))};e.castArray=function castArray(e){return 0===arguments.length?[]:Array.isArray(e)?e:[e]};e.ceil=function ceil(e,t=0){return decimalAdjust("ceil",e,t)};e.chunk=function chunk(e,t=1){return 0!==(t=Math.max(Math.floor(t),0))&&isArrayLike(e)?function chunk$1(e,t){if(!Number.isInteger(t)||t<=0)throw new Error("Size must be an integer greater than zero.");const n=Math.ceil(e.length/t),r=Array(n);for(let i=0;i<n;i++){const n=i*t,o=n+t;r[i]=e.slice(n,o)}return r}(toArray$1(e),t):[]};e.clamp=clamp;e.clone=clone;e.cloneDeep=cloneDeep;e.cloneDeepWith=cloneDeepWith;e.cloneWith=function cloneWith(e,t){if(!t)return clone(e);const n=t(e);return void 0!==n?n:clone(e)};e.compact=function compact(e){return isArrayLike(e)?function compact$1(e){const t=[];for(let n=0;n<e.length;n++){const r=e[n];r&&t.push(r)}return t}(Array.from(e)):[]};e.concat=function concat(...e){return flatten$1(e)};e.cond=function cond(e){const t=e.length,n=e.map((e=>{const t=e[0],n=e[1];if(!isFunction$1(n))throw new TypeError("Expected a function");return[iteratee(t),n]}));return function(...e){for(let r=0;r<t;r++){const t=n[r],i=t[0],o=t[1];if(i.apply(this,e))return o.apply(this,e)}}};e.conforms=function conforms(e){e=cloneDeep$1(e);return function(t){return conformsTo(t,e)}};e.conformsTo=conformsTo;e.constant=function constant(e){return()=>e};e.constantCase=function constantCase(e){return words$1(e).map((e=>e.toUpperCase())).join("_")};e.countBy=function countBy(e,t){if(null==e)return{};const n=isArrayLike(e)?Array.from(e):Object.values(e),r=iteratee(t??void 0),i=Object.create(null);for(let e=0;e<n.length;e++){const t=r(n[e]);i[t]=(i[t]??0)+1}return i};e.create=function create(e,t){const n=isObject(e)?Object.create(e):{};if(null!=t){const e=keys(t);for(let r=0;r<e.length;r++){const i=e[r],o=t[i];assignValue(n,i,o)}}return n};e.curry=curry;e.curryRight=curryRight;e.debounce=debounce;e.deburr=deburr;e.defaultTo=function defaultTo(e,t){return null==e||Number.isNaN(e)?t:e};e.defaults=defaults;e.defaultsDeep=function defaultsDeep(e,...t){e=Object(e);for(let n=0;n<t.length;n++){const r=t[n];null!=r&&defaultsDeepRecursive(e,r,new WeakMap)}return e};e.defer=function defer(e,...t){if("function"!=typeof e)throw new TypeError("Expected a function");return setTimeout(e,1,...t)};e.delay=function delay(e,t,.