@react-hive/honey-utils 3.18.0 → 3.19.0

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/README.md CHANGED
@@ -636,7 +636,7 @@ function divide(a: number, b: number): number {
636
636
  ---
637
637
 
638
638
  - `resolveBoundedDelta(options: ResolveBoundedDeltaOptions): Nullable<number>` – Resolves the next numeric value by consuming a delta within fixed bounds. Prevents overshoot, partially consumes deltas at boundaries, and returns `null` when movement in the given direction is no longer possible. Useful for drag constraints, sliders, synthetic scrolling, and inertia systems.
639
- - `applyInertiaStep(options: ApplyInertiaStepOptions): Nullable<InertiaStepResult>` - Advances a value by **one momentum (inertia) step** using velocity integration, exponential friction, and hard bounds. Designed to be called repeatedly from an animation loop (e.g. `requestAnimationFrame`) to implement native-feeling inertial motion such as momentum scrolling, carousels, sliders, and timelines. Returns the updated value and velocity while inertia is active, or `null` when inertia has completed or further movement is no longer possible.
639
+ - `applyInertiaStep(options: ApplyInertiaStepOptions): Nullable<InertiaStepResult>` - Advances a value by **a single momentum (inertia) step** using velocity integration, exponential friction, optional velocity smoothing, and hard bounds. This function models momentum-driven motion and is intended to be called repeatedly from an animation loop (e.g. `requestAnimationFrame`). Returns the updated value and velocity while inertia remains active, or `null` when inertia has naturally completed or further movement is blocked by bounds. Common use cases include momentum scrolling, drag-to-scroll interactions, carousels, sliders, and timelines.
640
640
 
641
641
  #### Layout
642
642
 
package/dist/README.md CHANGED
@@ -636,7 +636,7 @@ function divide(a: number, b: number): number {
636
636
  ---
637
637
 
638
638
  - `resolveBoundedDelta(options: ResolveBoundedDeltaOptions): Nullable<number>` – Resolves the next numeric value by consuming a delta within fixed bounds. Prevents overshoot, partially consumes deltas at boundaries, and returns `null` when movement in the given direction is no longer possible. Useful for drag constraints, sliders, synthetic scrolling, and inertia systems.
639
- - `applyInertiaStep(options: ApplyInertiaStepOptions): Nullable<InertiaStepResult>` - Advances a value by **one momentum (inertia) step** using velocity integration, exponential friction, and hard bounds. Designed to be called repeatedly from an animation loop (e.g. `requestAnimationFrame`) to implement native-feeling inertial motion such as momentum scrolling, carousels, sliders, and timelines. Returns the updated value and velocity while inertia is active, or `null` when inertia has completed or further movement is no longer possible.
639
+ - `applyInertiaStep(options: ApplyInertiaStepOptions): Nullable<InertiaStepResult>` - Advances a value by **a single momentum (inertia) step** using velocity integration, exponential friction, optional velocity smoothing, and hard bounds. This function models momentum-driven motion and is intended to be called repeatedly from an animation loop (e.g. `requestAnimationFrame`). Returns the updated value and velocity while inertia remains active, or `null` when inertia has naturally completed or further movement is blocked by bounds. Common use cases include momentum scrolling, drag-to-scroll interactions, carousels, sliders, and timelines.
640
640
 
641
641
  #### Layout
642
642
 
@@ -12,19 +12,17 @@ export interface InertiaOptions {
12
12
  velocityPxMs: number;
13
13
  /**
14
14
  * Time elapsed since the previous inertia step, in milliseconds.
15
- *
16
- * This value is typically derived from a high-resolution timestamp
17
- * (e.g. `performance.now()`), ensuring frame-rate-independent behavior.
18
15
  */
19
16
  deltaTimeMs: number;
20
17
  /**
21
- * Exponential friction coefficient controlling how quickly velocity decays.
18
+ * Exponential friction coefficient controlling velocity decay.
22
19
  *
23
- * The decay is applied per millisecond using an exponential model:
20
+ * Friction is applied per millisecond using an exponential model:
24
21
  *
25
22
  * `velocityPxMs *= exp(-friction * deltaTimeMs)`
26
23
  *
27
- * Smaller values produce longer, floatier motion; larger values result in a quicker stop.
24
+ * Smaller values result in longer, floatier inertia;
25
+ * larger values cause quicker deceleration.
28
26
  *
29
27
  * Typical values:
30
28
  * - `0.001` — very long, floaty inertia
@@ -44,6 +42,24 @@ export interface InertiaOptions {
44
42
  * @default 0.01
45
43
  */
46
44
  minVelocityPxMs?: number;
45
+ /**
46
+ * Exponential Moving Average (EMA) factor used to smooth velocity changes.
47
+ *
48
+ * This is applied **after friction**, blending the previous velocity
49
+ * with the newly decayed velocity to reduce jitter and sudden spikes.
50
+ *
51
+ * Value range: `0..1`
52
+ *
53
+ * - `0` → EMA disabled (raw exponential decay only)
54
+ * - `0.2` → light smoothing (recommended for scroll / drag inertia)
55
+ * - `0.5` → heavy smoothing (very soft, less responsive)
56
+ *
57
+ * Formula:
58
+ * `vNext = vPrev * (1 - emaAlpha) + vDecayed * emaAlpha`
59
+ *
60
+ * @default 0.2
61
+ */
62
+ emaAlpha?: number;
47
63
  }
48
64
  interface ApplyInertiaStepOptions extends InertiaOptions {
49
65
  /**
@@ -66,43 +82,48 @@ interface ApplyInertiaStepOptions extends InertiaOptions {
66
82
  /**
67
83
  * Result of a single inertia simulation step.
68
84
  *
69
- * Returned when inertia is still active and further movement
70
- * in the current direction is possible.
85
+ * Returned when inertia is still active and further movement in the current direction is possible.
71
86
  */
72
87
  export interface InertiaStepResult {
73
88
  /**
74
- * Updated value after applying the inertial step.
89
+ * Updated value after applying this inertia step.
90
+ *
91
+ * Guaranteed to be within `[min, max]`.
75
92
  */
76
93
  value: number;
77
94
  /**
78
- * Updated velocity after applying exponential decay.
95
+ * Updated velocity after friction decay and optional EMA smoothing.
79
96
  *
80
97
  * Expressed in pixels per millisecond (`px/ms`).
81
98
  */
82
99
  velocityPxMs: number;
83
100
  }
84
101
  /**
85
- * Advances a value by a single inertial step using velocity,
86
- * elapsed time, exponential friction, and hard bounds.
102
+ * Applies a **single step** of bounded, velocity-based inertia.
103
+ *
104
+ * This function models **momentum-driven motion** by:
105
+ * - integrating velocity over elapsed time
106
+ * - applying exponential friction
107
+ * - optionally smoothing velocity using EMA
108
+ * - enforcing hard bounds via {@link resolveBoundedDelta}
87
109
  *
88
- * This function models **momentum-driven motion** and delegates
89
- * boundary enforcement to {@link resolveBoundedDelta}, which guarantees:
110
+ * Boundary handling guarantees:
90
111
  * - no overshoot
91
- * - no jitter at bounds
112
+ * - no oscillation at limits
92
113
  * - deterministic stopping behavior
93
114
  *
94
115
  * ---
95
116
  *
96
117
  * ### Termination conditions
97
- * Inertia stops immediately when:
118
+ * Inertia ends immediately when:
98
119
  * - the absolute velocity falls below `minVelocityPxMs`, or
99
120
  * - movement in the current direction is blocked by a bound
100
121
  *
101
122
  * ---
102
123
  *
103
124
  * ⚠️ **Single-step function**
104
- * This function performs **one inertia step only**.
105
- * It must be called repeatedly from an animation loop
125
+ * This function advances inertia **once only**.
126
+ * It must be invoked repeatedly from an animation loop
106
127
  * (e.g. `requestAnimationFrame`) to produce continuous motion.
107
128
  *
108
129
  * ---
@@ -113,9 +134,8 @@ export interface InertiaStepResult {
113
134
  * - Carousels and sliders
114
135
  * - Timelines and scrubbers
115
136
  *
116
- * @returns An {@link InertiaStepResult} when inertia is still active,
117
- * or `null` when inertia has completed or further movement
118
- * is not possible.
137
+ * @returns An {@link InertiaStepResult} while inertia remains active,
138
+ * or `null` when inertia has completed or cannot proceed.
119
139
  */
120
- export declare const applyInertiaStep: ({ value, min, max, velocityPxMs, deltaTimeMs, friction, minVelocityPxMs, }: ApplyInertiaStepOptions) => Nullable<InertiaStepResult>;
140
+ export declare const applyInertiaStep: ({ value, min, max, velocityPxMs, deltaTimeMs, friction, minVelocityPxMs, emaAlpha, }: ApplyInertiaStepOptions) => Nullable<InertiaStepResult>;
121
141
  export {};
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- (()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){if(!e)throw new Error(t)}e.r(t),e.d(t,{FOCUSABLE_HTML_TAGS:()=>Te,applyInertiaStep:()=>Ce,assert:()=>n,blobToFile:()=>xe,calculateCenterOffset:()=>pe,calculateEuclideanDistance:()=>ie,calculateMovingSpeed:()=>le,calculatePercentage:()=>ae,camelToDashCase:()=>G,camelToWords:()=>Z,centerElementInContainer:()=>we,chunk:()=>E,cloneBlob:()=>se,compact:()=>M,compose:()=>T,definedProps:()=>Oe,delay:()=>B,difference:()=>F,downloadFile:()=>he,everyAsync:()=>H,fileListToFiles:()=>ve,filterParallel:()=>j,filterSequential:()=>X,findAsync:()=>W,findCharIndices:()=>ee,forEachChar:()=>te,getDOMRectIntersectionRatio:()=>Fe,getElementOffsetRect:()=>ce,getFocusableHtmlElements:()=>_e,getLocalStorageCapabilities:()=>Le,getWordsInitials:()=>ne,getXOverflowWidth:()=>me,getYOverflowHeight:()=>ge,hasXOverflow:()=>de,hasYOverflow:()=>ye,hashString:()=>oe,intersection:()=>C,invokeIfFunction:()=>re,isAnchorHtmlElement:()=>ue,isArray:()=>x,isBlob:()=>h,isBool:()=>s,isContentEditableHtmlElement:()=>fe,isDate:()=>f,isDecimal:()=>v,isDefined:()=>l,isEmptyArray:()=>A,isEmptyObject:()=>u,isError:()=>d,isFile:()=>Se,isFiniteNumber:()=>b,isFunction:()=>_,isHtmlElementFocusable:()=>ke,isInteger:()=>S,isLocalStorageReadable:()=>Ie,isMap:()=>g,isNil:()=>i,isNilOrEmptyString:()=>J,isNull:()=>r,isNumber:()=>o,isObject:()=>c,isPromise:()=>L,isRegExp:()=>y,isSet:()=>p,isString:()=>q,isSymbol:()=>w,isUndefined:()=>a,isValidDate:()=>m,moveFocusWithinContainer:()=>De,noop:()=>k,not:()=>D,once:()=>I,parse2DMatrix:()=>be,parseFileName:()=>Q,pipe:()=>P,readFilesFromDataTransfer:()=>Me,reduceAsync:()=>z,resolveAxisDelta:()=>Pe,resolveBoundedDelta:()=>Ee,retry:()=>$,runParallel:()=>R,runSequential:()=>N,someAsync:()=>Y,splitStringIntoWords:()=>K,timeout:()=>U,toKebabCase:()=>V,traverseFileSystemDirectory:()=>Ae,unique:()=>O});const r=e=>null===e,i=e=>null==e,l=e=>null!=e,a=e=>void 0===e,o=e=>"number"==typeof e,s=e=>"boolean"==typeof e,c=e=>"object"==typeof e,u=e=>c(e)&&!r(e)&&0===Object.keys(e).length,f=e=>e instanceof Date,h=e=>e instanceof Blob,d=e=>e instanceof Error,m=e=>f(e)&&!isNaN(e.getTime()),y=e=>e instanceof RegExp,g=e=>e instanceof Map,p=e=>e instanceof Set,w=e=>"symbol"==typeof e,b=e=>o(e)&&isFinite(e),S=e=>o(e)&&Number.isInteger(e),v=e=>b(e)&&!Number.isInteger(e),x=e=>Array.isArray(e),A=e=>x(e)&&0===e.length,M=e=>e.filter(Boolean),O=e=>[...new Set(e)],E=(e,t)=>(n(t>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))),C=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return O(t).filter(e=>n.every(t=>t.includes(e)))},F=(e,t)=>e.filter(e=>!t.includes(e)),P=(...e)=>t=>e.reduce((e,t)=>t(e),t),T=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),k=()=>{},_=e=>"function"==typeof e,D=e=>(...t)=>!e(...t),I=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},L=e=>_(e?.then),N=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},R=async(e,t)=>Promise.all(e.map(t)),X=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const i=e[r];await t(i,r,e)&&n.push(i)}return n},j=async(e,t)=>{const n=await R(e,async(e,n,r)=>!!await t(e,n,r)&&e);return M(n)},Y=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},H=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},z=async(e,t,n)=>{let r=n;for(let n=0;n<e.length;n++)r=await t(r,e[n],n,e);return r},W=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},B=e=>new Promise(t=>setTimeout(t,e)),U=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,B(t).then(()=>Promise.reject(new Error(n)))])}finally{}},$=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:i}={})=>async(...l)=>{let a;for(let o=1;o<=t;o++)try{return await e(...l)}catch(e){if(a=e,o<t){i?.(o,e);const t=r?n*2**(o-1):n;await B(t)}}throw a},q=e=>"string"==typeof e,V=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),G=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Z=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),K=e=>0===e.length?[]:e.split(" ").filter(Boolean),J=e=>""===e||i(e),Q=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},ee=(e,t)=>{if(0===e.length)return[];const n=t.charCodeAt(0),r=[];for(let t=0;t<e.length;t++)e.charCodeAt(t)===n&&r.push(t);return r},te=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let i=0;i<r;i++){const l=e[i],a={charIndex:i,prevChar:i>0?e[i-1]:null,nextChar:i<r-1?e[i+1]:null};n?.(l,a)||t(l,a)}},ne=(e,t=1/0)=>0===e.length?"":K(e).slice(0,t).map(e=>e[0]).join("").toUpperCase(),re=(e,...t)=>"function"==typeof e?e(...t):e,ie=(e,t,n,r)=>{const i=n-e,l=r-t;return Math.hypot(i,l)},le=(e,t)=>Math.abs(e/t),ae=(e,t)=>e*t/100,oe=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},se=e=>new Blob([e],{type:e.type}),ce=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),ue=e=>"A"===e.tagName,fe=e=>"true"===e.getAttribute("contenteditable"),he=(e,{fileName:t,target:r}={})=>{if(a(document))return;const i=document.createElement("a");let l=null;try{const n=q(e)?e:l=URL.createObjectURL(e);i.href=n,t&&(i.download=t),r&&(i.target=r),document.body.appendChild(i),i.click()}finally{i.remove(),l&&setTimeout(()=>{n(l,"Object URL should not be null"),URL.revokeObjectURL(l)},0)}},de=e=>e.scrollWidth>e.clientWidth,me=e=>Math.max(0,e.scrollWidth-e.clientWidth),ye=e=>e.scrollHeight>e.clientHeight,ge=e=>Math.max(0,e.scrollHeight-e.clientHeight),pe=({overflowSize:e,containerSize:t,elementOffset:n,elementSize:r})=>{if(e<=0)return 0;const i=n+r/2-t/2;return-Math.max(0,Math.min(i,e))},we=(e,t,{axis:n="both"}={})=>{let r=0,i=0;"x"!==n&&"both"!==n||(r=pe({overflowSize:me(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),"y"!==n&&"both"!==n||(i=pe({overflowSize:ge(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${i}px)`},be=e=>{const t=window.getComputedStyle(e).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!t)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,i,l,a,o]=t[1].split(", ").map(parseFloat);return{translateX:a,translateY:o,scaleX:n,scaleY:l,skewX:i,skewY:r}},Se=e=>e instanceof File,ve=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},xe=(e,t)=>new File([e],t,{type:e.type}),Ae=async(e,{skipFiles:t=[".DS_Store","Thumbs.db","desktop.ini","ehthumbs.db",".Spotlight-V100",".Trashes",".fseventsd","__MACOSX"]}={})=>{const n=new Set(t),r=await(async e=>{const t=e.createReader(),n=async()=>new Promise((e,r)=>{t.readEntries(async t=>{if(t.length)try{const r=await n();e([...t,...r])}catch(e){r(e)}else e([])},r)});return n()})(e);return(await R(r,async e=>e.isDirectory?Ae(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},Me=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const i=n[e];if("webkitGetAsEntry"in i){const e=i.webkitGetAsEntry?.();if(e?.isDirectory){r.push(Ae(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const l=i.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},Oe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Ee=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const i=t+e;return e<0?t<=n?null:Math.max(i,n):e>0?t>=r?null:Math.min(i,r):null},Ce=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:i,friction:l=.002,minVelocityPxMs:a=.01})=>{if(Math.abs(r)<a)return null;const o=Ee({delta:r*i,value:e,min:t,max:n});return null===o?null:{value:o,velocityPxMs:r*Math.exp(-l*i)}},Fe=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top))/(t.width*t.height),Pe=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const i=r?-1:1;switch(t){case"x":return{deltaX:i*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:i*e.deltaY};default:return{deltaX:i*e.deltaX,deltaY:i*e.deltaY}}},Te=["INPUT","SELECT","TEXTAREA","BUTTON","A"],ke=e=>{if(!e)return!1;const t=window.getComputedStyle(e);if("hidden"===t.visibility||"none"===t.display)return!1;if("disabled"in e&&e.disabled)return!1;const n=e.getAttribute("tabindex");return"-1"!==n&&(Te.includes(e.tagName)?!ue(e)||""!==e.href:!!fe(e)||null!==n)},_e=e=>Array.from(e.querySelectorAll("*")).filter(ke),De=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const i=document.activeElement,l=t??i?.parentElement;if(!i||!l)return;const a=_e(l);if(0===a.length)return;const o=a.indexOf(i);if(-1===o)return;let s;r?s=r(o,e,a):"next"===e?(s=o+1,s>=a.length&&(s=n?0:null)):(s=o-1,s<0&&(s=n?a.length-1:null)),null!==s&&a[s]?.focus()},Ie=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},Le=()=>{if(!Ie())return{readable:!1,writable:!1};try{const e="__test_write__";return window.localStorage.setItem(e,"1"),window.localStorage.removeItem(e),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}};module.exports=t})();
1
+ (()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e,t){if(!e)throw new Error(t)}e.r(t),e.d(t,{FOCUSABLE_HTML_TAGS:()=>Te,applyInertiaStep:()=>Ce,assert:()=>n,blobToFile:()=>xe,calculateCenterOffset:()=>pe,calculateEuclideanDistance:()=>le,calculateMovingSpeed:()=>ie,calculatePercentage:()=>ae,camelToDashCase:()=>G,camelToWords:()=>Z,centerElementInContainer:()=>we,chunk:()=>E,cloneBlob:()=>se,compact:()=>M,compose:()=>T,definedProps:()=>Oe,delay:()=>B,difference:()=>F,downloadFile:()=>he,everyAsync:()=>H,fileListToFiles:()=>ve,filterParallel:()=>j,filterSequential:()=>X,findAsync:()=>W,findCharIndices:()=>ee,forEachChar:()=>te,getDOMRectIntersectionRatio:()=>Fe,getElementOffsetRect:()=>ce,getFocusableHtmlElements:()=>_e,getLocalStorageCapabilities:()=>Le,getWordsInitials:()=>ne,getXOverflowWidth:()=>me,getYOverflowHeight:()=>ge,hasXOverflow:()=>de,hasYOverflow:()=>ye,hashString:()=>oe,intersection:()=>C,invokeIfFunction:()=>re,isAnchorHtmlElement:()=>ue,isArray:()=>x,isBlob:()=>h,isBool:()=>s,isContentEditableHtmlElement:()=>fe,isDate:()=>f,isDecimal:()=>v,isDefined:()=>i,isEmptyArray:()=>A,isEmptyObject:()=>u,isError:()=>d,isFile:()=>Se,isFiniteNumber:()=>b,isFunction:()=>_,isHtmlElementFocusable:()=>ke,isInteger:()=>S,isLocalStorageReadable:()=>Ie,isMap:()=>g,isNil:()=>l,isNilOrEmptyString:()=>J,isNull:()=>r,isNumber:()=>o,isObject:()=>c,isPromise:()=>L,isRegExp:()=>y,isSet:()=>p,isString:()=>q,isSymbol:()=>w,isUndefined:()=>a,isValidDate:()=>m,moveFocusWithinContainer:()=>De,noop:()=>k,not:()=>D,once:()=>I,parse2DMatrix:()=>be,parseFileName:()=>Q,pipe:()=>P,readFilesFromDataTransfer:()=>Me,reduceAsync:()=>z,resolveAxisDelta:()=>Pe,resolveBoundedDelta:()=>Ee,retry:()=>$,runParallel:()=>R,runSequential:()=>N,someAsync:()=>Y,splitStringIntoWords:()=>K,timeout:()=>U,toKebabCase:()=>V,traverseFileSystemDirectory:()=>Ae,unique:()=>O});const r=e=>null===e,l=e=>null==e,i=e=>null!=e,a=e=>void 0===e,o=e=>"number"==typeof e,s=e=>"boolean"==typeof e,c=e=>"object"==typeof e,u=e=>c(e)&&!r(e)&&0===Object.keys(e).length,f=e=>e instanceof Date,h=e=>e instanceof Blob,d=e=>e instanceof Error,m=e=>f(e)&&!isNaN(e.getTime()),y=e=>e instanceof RegExp,g=e=>e instanceof Map,p=e=>e instanceof Set,w=e=>"symbol"==typeof e,b=e=>o(e)&&isFinite(e),S=e=>o(e)&&Number.isInteger(e),v=e=>b(e)&&!Number.isInteger(e),x=e=>Array.isArray(e),A=e=>x(e)&&0===e.length,M=e=>e.filter(Boolean),O=e=>[...new Set(e)],E=(e,t)=>(n(t>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,(r+1)*t))),C=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return O(t).filter(e=>n.every(t=>t.includes(e)))},F=(e,t)=>e.filter(e=>!t.includes(e)),P=(...e)=>t=>e.reduce((e,t)=>t(e),t),T=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),k=()=>{},_=e=>"function"==typeof e,D=e=>(...t)=>!e(...t),I=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},L=e=>_(e?.then),N=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},R=async(e,t)=>Promise.all(e.map(t)),X=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const l=e[r];await t(l,r,e)&&n.push(l)}return n},j=async(e,t)=>{const n=await R(e,async(e,n,r)=>!!await t(e,n,r)&&e);return M(n)},Y=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},H=async(e,t)=>{for(let n=0;n<e.length;n++)if(!await t(e[n],n,e))return!1;return!0},z=async(e,t,n)=>{let r=n;for(let n=0;n<e.length;n++)r=await t(r,e[n],n,e);return r},W=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},B=e=>new Promise(t=>setTimeout(t,e)),U=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,B(t).then(()=>Promise.reject(new Error(n)))])}finally{}},$=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:l}={})=>async(...i)=>{let a;for(let o=1;o<=t;o++)try{return await e(...i)}catch(e){if(a=e,o<t){l?.(o,e);const t=r?n*2**(o-1):n;await B(t)}}throw a},q=e=>"string"==typeof e,V=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),G=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Z=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),K=e=>0===e.length?[]:e.split(" ").filter(Boolean),J=e=>""===e||l(e),Q=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},ee=(e,t)=>{if(0===e.length)return[];const n=t.charCodeAt(0),r=[];for(let t=0;t<e.length;t++)e.charCodeAt(t)===n&&r.push(t);return r},te=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let l=0;l<r;l++){const i=e[l],a={charIndex:l,prevChar:l>0?e[l-1]:null,nextChar:l<r-1?e[l+1]:null};n?.(i,a)||t(i,a)}},ne=(e,t=1/0)=>0===e.length?"":K(e).slice(0,t).map(e=>e[0]).join("").toUpperCase(),re=(e,...t)=>"function"==typeof e?e(...t):e,le=(e,t,n,r)=>{const l=n-e,i=r-t;return Math.hypot(l,i)},ie=(e,t)=>Math.abs(e/t),ae=(e,t)=>e*t/100,oe=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},se=e=>new Blob([e],{type:e.type}),ce=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),ue=e=>"A"===e.tagName,fe=e=>"true"===e.getAttribute("contenteditable"),he=(e,{fileName:t,target:r}={})=>{if(a(document))return;const l=document.createElement("a");let i=null;try{const n=q(e)?e:i=URL.createObjectURL(e);l.href=n,t&&(l.download=t),r&&(l.target=r),document.body.appendChild(l),l.click()}finally{l.remove(),i&&setTimeout(()=>{n(i,"Object URL should not be null"),URL.revokeObjectURL(i)},0)}},de=e=>e.scrollWidth>e.clientWidth,me=e=>Math.max(0,e.scrollWidth-e.clientWidth),ye=e=>e.scrollHeight>e.clientHeight,ge=e=>Math.max(0,e.scrollHeight-e.clientHeight),pe=({overflowSize:e,containerSize:t,elementOffset:n,elementSize:r})=>{if(e<=0)return 0;const l=n+r/2-t/2;return-Math.max(0,Math.min(l,e))},we=(e,t,{axis:n="both"}={})=>{let r=0,l=0;"x"!==n&&"both"!==n||(r=pe({overflowSize:me(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),"y"!==n&&"both"!==n||(l=pe({overflowSize:ge(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${l}px)`},be=e=>{const t=window.getComputedStyle(e).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!t)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,l,i,a,o]=t[1].split(", ").map(parseFloat);return{translateX:a,translateY:o,scaleX:n,scaleY:i,skewX:l,skewY:r}},Se=e=>e instanceof File,ve=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},xe=(e,t)=>new File([e],t,{type:e.type}),Ae=async(e,{skipFiles:t=[".DS_Store","Thumbs.db","desktop.ini","ehthumbs.db",".Spotlight-V100",".Trashes",".fseventsd","__MACOSX"]}={})=>{const n=new Set(t),r=await(async e=>{const t=e.createReader(),n=async()=>new Promise((e,r)=>{t.readEntries(async t=>{if(t.length)try{const r=await n();e([...t,...r])}catch(e){r(e)}else e([])},r)});return n()})(e);return(await R(r,async e=>e.isDirectory?Ae(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},Me=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const l=n[e];if("webkitGetAsEntry"in l){const e=l.webkitGetAsEntry?.();if(e?.isDirectory){r.push(Ae(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const i=l.getAsFile();i&&r.push(Promise.resolve([i]))}return(await Promise.all(r)).flat()},Oe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Ee=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const l=t+e;return e<0?t<=n?null:Math.max(l,n):e>0?t>=r?null:Math.min(l,r):null},Ce=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:l,friction:i=.002,minVelocityPxMs:a=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<a)return null;const s=Ee({delta:r*l,value:e,min:t,max:n});if(null===s)return null;const c=r*Math.exp(-i*l),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<a?null:{value:s,velocityPxMs:u}},Fe=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top))/(t.width*t.height),Pe=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const l=r?-1:1;switch(t){case"x":return{deltaX:l*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:l*e.deltaY};default:return{deltaX:l*e.deltaX,deltaY:l*e.deltaY}}},Te=["INPUT","SELECT","TEXTAREA","BUTTON","A"],ke=e=>{if(!e)return!1;const t=window.getComputedStyle(e);if("hidden"===t.visibility||"none"===t.display)return!1;if("disabled"in e&&e.disabled)return!1;const n=e.getAttribute("tabindex");return"-1"!==n&&(Te.includes(e.tagName)?!ue(e)||""!==e.href:!!fe(e)||null!==n)},_e=e=>Array.from(e.querySelectorAll("*")).filter(ke),De=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const l=document.activeElement,i=t??l?.parentElement;if(!l||!i)return;const a=_e(i);if(0===a.length)return;const o=a.indexOf(l);if(-1===o)return;let s;r?s=r(o,e,a):"next"===e?(s=o+1,s>=a.length&&(s=n?0:null)):(s=o-1,s<0&&(s=n?a.length-1:null)),null!==s&&a[s]?.focus()},Ie=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},Le=()=>{if(!Ie())return{readable:!1,writable:!1};try{const e="__test_write__";return window.localStorage.setItem(e,"1"),window.localStorage.removeItem(e),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}};module.exports=t})();
2
2
  //# sourceMappingURL=index.cjs.map