@react-hive/honey-utils 3.24.0 → 3.25.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
@@ -559,6 +559,12 @@ function divide(a: number, b: number): number {
559
559
  - `getWordsInitials(input: string, maxWords?: number): string` - Returns the uppercase initials of the words in a string. The number of processed words can be limited via `maxWords`.
560
560
  - `splitMapJoin(input: string, separator: string, mapFn: (part: string, index: number) => string, joinWith?: string): string` - Splits a string by a separator, applies a transformation function to each trimmed part, and joins the results back together. Useful for processing comma-separated selectors or any delimited string.
561
561
 
562
+ ### Color Utilities
563
+
564
+ ---
565
+
566
+ - `hexWithAlpha(hex: string, alpha: number): HexColor` - Adds an alpha channel to a 3- or 6-digit HEX color and returns a normalized 8-digit HEX color in #RRGGBBAA format.
567
+
562
568
  ### Object Utilities
563
569
 
564
570
  ---
package/dist/README.md CHANGED
@@ -559,6 +559,12 @@ function divide(a: number, b: number): number {
559
559
  - `getWordsInitials(input: string, maxWords?: number): string` - Returns the uppercase initials of the words in a string. The number of processed words can be limited via `maxWords`.
560
560
  - `splitMapJoin(input: string, separator: string, mapFn: (part: string, index: number) => string, joinWith?: string): string` - Splits a string by a separator, applies a transformation function to each trimmed part, and joins the results back together. Useful for processing comma-separated selectors or any delimited string.
561
561
 
562
+ ### Color Utilities
563
+
564
+ ---
565
+
566
+ - `hexWithAlpha(hex: string, alpha: number): HexColor` - Adds an alpha channel to a 3- or 6-digit HEX color and returns a normalized 8-digit HEX color in #RRGGBBAA format.
567
+
562
568
  ### Object Utilities
563
569
 
564
570
  ---
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Represents a hexadecimal CSS color value.
3
+ *
4
+ * This type enforces a leading `#`, but does not validate length
5
+ * at the type level (e.g. `#RGB`, `#RRGGBB`, `#RRGGBBAA`).
6
+ *
7
+ * Valid runtime examples:
8
+ * - `#fff`
9
+ * - `#ffffff`
10
+ * - `#ffffffff`
11
+ */
12
+ export type HexColor = `#${string}`;
13
+ /**
14
+ * Adds an alpha channel to a 3- or 6-digit HEX color.
15
+ *
16
+ * Accepts `#RGB`, `#RRGGBB`, `RGB`, or `RRGGBB` formats
17
+ * and returns a normalized 8-digit HEX color in `#RRGGBBAA` format.
18
+ *
19
+ * The alpha value is converted to a two-digit hexadecimal
20
+ * representation using `Math.round(alpha * 255)`.
21
+ *
22
+ * @param input - Base HEX color (3 or 6 hex digits, with or without `#`).
23
+ * @param alpha - Opacity value between `0` (transparent) and `1` (opaque).
24
+ *
25
+ * @throws {Error}
26
+ * - If `alpha` is outside the `[0, 1]` range.
27
+ * - If `hex` is not a valid 3- or 6-digit hexadecimal color.
28
+ *
29
+ * @returns A normalized 8-digit HEX color in `#RRGGBBAA` format.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * hexWithAlpha('#ff0000', 0.5) // '#FF000080'
34
+ * hexWithAlpha('0f0', 1) // '#00FF00FF'
35
+ * ```
36
+ */
37
+ export declare const hexWithAlpha: (input: string, alpha: number) => HexColor;
@@ -0,0 +1 @@
1
+ export * from './hex-with-alpha';
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={};e.r(t),e.d(t,{FOCUSABLE_HTML_TAGS:()=>a,applyInertiaStep:()=>be,assert:()=>u,blobToFile:()=>me,calculateCenterOffset:()=>oe,calculateEuclideanDistance:()=>Ae,calculateMovingSpeed:()=>Me,calculatePercentage:()=>Ee,camelToDashCase:()=>Te,camelToWords:()=>Fe,centerElementInContainer:()=>se,chunk:()=>_,cloneBlob:()=>n,compact:()=>L,compose:()=>X,definedProps:()=>Oe,delay:()=>K,difference:()=>N,downloadFile:()=>ne,everyAsync:()=>G,fileListToFiles:()=>de,filterParallel:()=>q,filterSequential:()=>$,findAsync:()=>J,findCharIndices:()=>_e,flattenTree:()=>Xe,forEachChar:()=>De,generateEphemeralId:()=>Se,getDOMRectIntersectionRatio:()=>ve,getElementOffsetRect:()=>r,getFocusableHtmlElements:()=>s,getLocalStorageCapabilities:()=>fe,getTreeChildren:()=>je,getWordsInitials:()=>Ne,getXOverflowWidth:()=>ie,getYOverflowHeight:()=>ae,hasXOverflow:()=>re,hasYOverflow:()=>le,hashString:()=>Ce,intersection:()=>D,invokeIfFunction:()=>ye,isAnchorHtmlElement:()=>i,isArray:()=>F,isBlob:()=>S,isBool:()=>g,isContentEditableHtmlElement:()=>l,isDate:()=>b,isDecimal:()=>T,isDefined:()=>d,isEmptyArray:()=>P,isEmptyObject:()=>w,isError:()=>v,isFile:()=>he,isFiniteNumber:()=>O,isFunction:()=>Y,isHtmlElementFocusable:()=>o,isInteger:()=>I,isLocalStorageReadable:()=>ue,isMap:()=>M,isNil:()=>h,isNilOrEmptyString:()=>Le,isNull:()=>f,isNumber:()=>p,isObject:()=>y,isPromise:()=>z,isRegExp:()=>A,isSet:()=>E,isString:()=>te,isSymbol:()=>C,isUndefined:()=>m,isValidDate:()=>x,moveFocusWithinContainer:()=>c,noop:()=>j,not:()=>H,once:()=>W,parse2DMatrix:()=>ce,parseFileName:()=>ke,pipe:()=>R,readFilesFromDataTransfer:()=>ge,reduceAsync:()=>Z,resolveAxisDelta:()=>xe,resolveBoundedDelta:()=>we,retry:()=>ee,runParallel:()=>U,runSequential:()=>B,searchTree:()=>Ye,someAsync:()=>V,splitMapJoin:()=>Re,splitStringIntoWords:()=>Pe,timeout:()=>Q,toKebabCase:()=>Ie,traverseFileSystemDirectory:()=>pe,unique:()=>k});const n=e=>new Blob([e],{type:e.type}),r=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),i=e=>"A"===e.tagName,l=e=>"true"===e.getAttribute("contenteditable"),a=["INPUT","SELECT","TEXTAREA","BUTTON","A"],o=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&&(a.includes(e.tagName)?!i(e)||""!==e.href:!!l(e)||null!==n)},s=e=>Array.from(e.querySelectorAll("*")).filter(o),c=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const i=document.activeElement,l=t??i?.parentElement;if(!i||!l)return;const a=s(l);if(0===a.length)return;const o=a.indexOf(i);if(-1===o)return;let c;r?c=r(o,e,a):"next"===e?(c=o+1,c>=a.length&&(c=n?0:null)):(c=o-1,c<0&&(c=n?a.length-1:null)),null!==c&&a[c]?.focus()};function u(e,t){if(!e)throw new Error(t)}const f=e=>null===e,h=e=>null==e,d=e=>null!=e,m=e=>void 0===e,p=e=>"number"==typeof e,g=e=>"boolean"==typeof e,y=e=>"object"==typeof e,w=e=>y(e)&&!f(e)&&0===Object.keys(e).length,b=e=>e instanceof Date,S=e=>e instanceof Blob,v=e=>e instanceof Error,x=e=>b(e)&&!isNaN(e.getTime()),A=e=>e instanceof RegExp,M=e=>e instanceof Map,E=e=>e instanceof Set,C=e=>"symbol"==typeof e,O=e=>p(e)&&isFinite(e),I=e=>p(e)&&Number.isInteger(e),T=e=>O(e)&&!Number.isInteger(e),F=e=>Array.isArray(e),P=e=>F(e)&&0===e.length,L=e=>e.filter(Boolean),k=e=>[...new Set(e)],_=(e,t)=>(u(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))),D=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return k(t).filter(e=>n.every(t=>t.includes(e)))},N=(e,t)=>e.filter(e=>!t.includes(e)),R=(...e)=>t=>e.reduce((e,t)=>t(e),t),X=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),j=()=>{},Y=e=>"function"==typeof e,H=e=>(...t)=>!e(...t),W=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},z=e=>Y(e?.then),B=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},U=async(e,t)=>Promise.all(e.map(t)),$=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},q=async(e,t)=>{const n=await U(e,async(e,n,r)=>!!await t(e,n,r)&&e);return L(n)},V=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},G=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},J=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},K=e=>new Promise(t=>setTimeout(t,e)),Q=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,K(t).then(()=>Promise.reject(new Error(n)))])}finally{}},ee=(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 K(t)}}throw a},te=e=>"string"==typeof e,ne=(e,{fileName:t,target:n}={})=>{if(m(document))return;const r=document.createElement("a");let i=null;try{const l=te(e)?e:i=URL.createObjectURL(e);r.href=l,t&&(r.download=t),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),i&&setTimeout(()=>{u(i,"Object URL should not be null"),URL.revokeObjectURL(i)},0)}},re=e=>e.scrollWidth>e.clientWidth,ie=e=>Math.max(0,e.scrollWidth-e.clientWidth),le=e=>e.scrollHeight>e.clientHeight,ae=e=>Math.max(0,e.scrollHeight-e.clientHeight),oe=({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))},se=(e,t,{axis:n="both"}={})=>{let r=0,i=0;"x"!==n&&"both"!==n||(r=oe({overflowSize:ie(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),"y"!==n&&"both"!==n||(i=oe({overflowSize:ae(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${i}px)`},ce=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}},ue=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},fe=()=>{if(!ue())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}},he=e=>e instanceof File,de=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},me=(e,t)=>new File([e],t,{type:e.type}),pe=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 U(r,async e=>e.isDirectory?pe(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},ge=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(pe(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()},ye=(e,...t)=>"function"==typeof e?e(...t):e,we=({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},be=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:i,friction:l=.002,minVelocityPxMs:a=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<a)return null;const s=we({delta:r*i,value:e,min:t,max:n});if(null===s)return null;const c=r*Math.exp(-l*i),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<a?null:{value:s,velocityPxMs:u}},Se=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,ve=(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),xe=(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}}},Ae=(e,t,n,r)=>{const i=n-e,l=r-t;return Math.hypot(i,l)},Me=(e,t)=>Math.abs(e/t),Ee=(e,t)=>e*t/100,Ce=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},Oe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Ie=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Te=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Fe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),Pe=e=>0===e.length?[]:e.split(" ").filter(Boolean),Le=e=>""===e||h(e),ke=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},_e=(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},De=(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?"":Pe(e).slice(0,t).map(e=>e[0]).join("").toUpperCase(),Re=(e,t,n,r=t)=>e.split(t).map((e,t)=>n(e.trim(),t)).join(r),Xe=(e,t,n,r=[],i=void 0,l=0)=>(e?.forEach(e=>{const{[n]:a,...o}=e,s=e[n],c=Array.isArray(s);if(r.push({...o,parentId:i,depthLevel:l,childCount:c?s.length:0}),c){const i=e[t];Xe(s,t,n,r,i,l+1)}}),r),je=(e,t,n)=>e.filter(e=>e.parentId===t&&(!n||n(e))),Ye=(e,t,n,r)=>{const i=Pe(r.toLowerCase());if(!i.length)return e;const l=e.reduce((e,n,r)=>(e[n[t]]=r,e),{});return e.reduce((r,a)=>{const o=a[n];if(!o)return r;if(r.some(e=>e[t]===a[t]))return r;const s=Pe(o.toLowerCase());if(i.every(e=>s.some(t=>t.startsWith(e))))if(m(a.parentId)){r.push(a);const n=i=>{i.childCount&&e.forEach(e=>{e.parentId===i[t]&&(r.push(e),n(e))})};n(a)}else{const t=n=>{const i=l[n.parentId],a=e[i];m(a.parentId)||t(a);const o=r.length?r[r.length-1].parentId:null;(f(o)||o!==n.parentId)&&(u(a,"[@react-hive/honey-utils]: Parent node was not found."),r.push(a))};t(a),r.push(a)}return r},[])};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={};e.r(t),e.d(t,{FOCUSABLE_HTML_TAGS:()=>l,applyInertiaStep:()=>be,assert:()=>u,blobToFile:()=>me,calculateCenterOffset:()=>oe,calculateEuclideanDistance:()=>xe,calculateMovingSpeed:()=>Me,calculatePercentage:()=>Ce,camelToDashCase:()=>Fe,camelToWords:()=>Te,centerElementInContainer:()=>se,chunk:()=>_,cloneBlob:()=>n,compact:()=>L,compose:()=>X,definedProps:()=>Oe,delay:()=>K,difference:()=>N,downloadFile:()=>ne,everyAsync:()=>G,fileListToFiles:()=>de,filterParallel:()=>q,filterSequential:()=>B,findAsync:()=>J,findCharIndices:()=>_e,flattenTree:()=>Xe,forEachChar:()=>De,generateEphemeralId:()=>Se,getDOMRectIntersectionRatio:()=>ve,getElementOffsetRect:()=>r,getFocusableHtmlElements:()=>s,getLocalStorageCapabilities:()=>he,getTreeChildren:()=>je,getWordsInitials:()=>Ne,getXOverflowWidth:()=>ae,getYOverflowHeight:()=>le,hasXOverflow:()=>re,hasYOverflow:()=>ie,hashString:()=>Ee,hexWithAlpha:()=>Ye,intersection:()=>D,invokeIfFunction:()=>ye,isAnchorHtmlElement:()=>a,isArray:()=>T,isBlob:()=>S,isBool:()=>g,isContentEditableHtmlElement:()=>i,isDate:()=>b,isDecimal:()=>F,isDefined:()=>d,isEmptyArray:()=>P,isEmptyObject:()=>w,isError:()=>v,isFile:()=>fe,isFiniteNumber:()=>O,isFunction:()=>W,isHtmlElementFocusable:()=>o,isInteger:()=>I,isLocalStorageReadable:()=>ue,isMap:()=>M,isNil:()=>f,isNilOrEmptyString:()=>Le,isNull:()=>h,isNumber:()=>p,isObject:()=>y,isPromise:()=>H,isRegExp:()=>x,isSet:()=>C,isString:()=>te,isSymbol:()=>E,isUndefined:()=>m,isValidDate:()=>A,moveFocusWithinContainer:()=>c,noop:()=>j,not:()=>Y,once:()=>$,parse2DMatrix:()=>ce,parseFileName:()=>ke,pipe:()=>R,readFilesFromDataTransfer:()=>ge,reduceAsync:()=>Z,resolveAxisDelta:()=>Ae,resolveBoundedDelta:()=>we,retry:()=>ee,runParallel:()=>U,runSequential:()=>z,searchTree:()=>We,someAsync:()=>V,splitMapJoin:()=>Re,splitStringIntoWords:()=>Pe,timeout:()=>Q,toKebabCase:()=>Ie,traverseFileSystemDirectory:()=>pe,unique:()=>k});const n=e=>new Blob([e],{type:e.type}),r=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),a=e=>"A"===e.tagName,i=e=>"true"===e.getAttribute("contenteditable"),l=["INPUT","SELECT","TEXTAREA","BUTTON","A"],o=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&&(l.includes(e.tagName)?!a(e)||""!==e.href:!!i(e)||null!==n)},s=e=>Array.from(e.querySelectorAll("*")).filter(o),c=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,i=t??a?.parentElement;if(!a||!i)return;const l=s(i);if(0===l.length)return;const o=l.indexOf(a);if(-1===o)return;let c;r?c=r(o,e,l):"next"===e?(c=o+1,c>=l.length&&(c=n?0:null)):(c=o-1,c<0&&(c=n?l.length-1:null)),null!==c&&l[c]?.focus()};function u(e,t){if(!e)throw new Error(t)}const h=e=>null===e,f=e=>null==e,d=e=>null!=e,m=e=>void 0===e,p=e=>"number"==typeof e,g=e=>"boolean"==typeof e,y=e=>"object"==typeof e,w=e=>y(e)&&!h(e)&&0===Object.keys(e).length,b=e=>e instanceof Date,S=e=>e instanceof Blob,v=e=>e instanceof Error,A=e=>b(e)&&!isNaN(e.getTime()),x=e=>e instanceof RegExp,M=e=>e instanceof Map,C=e=>e instanceof Set,E=e=>"symbol"==typeof e,O=e=>p(e)&&isFinite(e),I=e=>p(e)&&Number.isInteger(e),F=e=>O(e)&&!Number.isInteger(e),T=e=>Array.isArray(e),P=e=>T(e)&&0===e.length,L=e=>e.filter(Boolean),k=e=>[...new Set(e)],_=(e,t)=>(u(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))),D=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return k(t).filter(e=>n.every(t=>t.includes(e)))},N=(e,t)=>e.filter(e=>!t.includes(e)),R=(...e)=>t=>e.reduce((e,t)=>t(e),t),X=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),j=()=>{},W=e=>"function"==typeof e,Y=e=>(...t)=>!e(...t),$=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},H=e=>W(e?.then),z=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},U=async(e,t)=>Promise.all(e.map(t)),B=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++){const a=e[r];await t(a,r,e)&&n.push(a)}return n},q=async(e,t)=>{const n=await U(e,async(e,n,r)=>!!await t(e,n,r)&&e);return L(n)},V=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return!0;return!1},G=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},J=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},K=e=>new Promise(t=>setTimeout(t,e)),Q=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,K(t).then(()=>Promise.reject(new Error(n)))])}finally{}},ee=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...i)=>{let l;for(let o=1;o<=t;o++)try{return await e(...i)}catch(e){if(l=e,o<t){a?.(o,e);const t=r?n*2**(o-1):n;await K(t)}}throw l},te=e=>"string"==typeof e,ne=(e,{fileName:t,target:n}={})=>{if(m(document))return;const r=document.createElement("a");let a=null;try{const i=te(e)?e:a=URL.createObjectURL(e);r.href=i,t&&(r.download=t),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),a&&setTimeout(()=>{u(a,"Object URL should not be null"),URL.revokeObjectURL(a)},0)}},re=e=>e.scrollWidth>e.clientWidth,ae=e=>Math.max(0,e.scrollWidth-e.clientWidth),ie=e=>e.scrollHeight>e.clientHeight,le=e=>Math.max(0,e.scrollHeight-e.clientHeight),oe=({overflowSize:e,containerSize:t,elementOffset:n,elementSize:r})=>{if(e<=0)return 0;const a=n+r/2-t/2;return-Math.max(0,Math.min(a,e))},se=(e,t,{axis:n="both"}={})=>{let r=0,a=0;"x"!==n&&"both"!==n||(r=oe({overflowSize:ae(e),containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth})),"y"!==n&&"both"!==n||(a=oe({overflowSize:le(e),containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight})),e.style.transform=`translate(${r}px, ${a}px)`},ce=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,a,i,l,o]=t[1].split(", ").map(parseFloat);return{translateX:l,translateY:o,scaleX:n,scaleY:i,skewX:a,skewY:r}},ue=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},he=()=>{if(!ue())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}},fe=e=>e instanceof File,de=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},me=(e,t)=>new File([e],t,{type:e.type}),pe=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 U(r,async e=>e.isDirectory?pe(e,{skipFiles:t}):n.has(e.name)?[]:[await new Promise((t,n)=>{e.file(t,n)})])).flat()},ge=async(e,t={})=>{const n=e?.items;if(!n)return[];const r=[];for(let e=0;e<n.length;e++){const a=n[e];if("webkitGetAsEntry"in a){const e=a.webkitGetAsEntry?.();if(e?.isDirectory){r.push(pe(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const i=a.getAsFile();i&&r.push(Promise.resolve([i]))}return(await Promise.all(r)).flat()},ye=(e,...t)=>"function"==typeof e?e(...t):e,we=({delta:e,value:t,min:n,max:r})=>{if(0===e)return null;const a=t+e;return e<0?t<=n?null:Math.max(a,n):e>0?t>=r?null:Math.min(a,r):null},be=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:a,friction:i=.002,minVelocityPxMs:l=.01,emaAlpha:o=.2})=>{if(Math.abs(r)<l)return null;const s=we({delta:r*a,value:e,min:t,max:n});if(null===s)return null;const c=r*Math.exp(-i*a),u=o>0?r*(1-o)+c*o:c;return Math.abs(u)<l?null:{value:s,velocityPxMs:u}},Se=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,ve=(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),Ae=(e,t,{allowFallback:n=!0,invert:r=!0}={})=>{const a=r?-1:1;switch(t){case"x":return{deltaX:a*(0!==e.deltaX?e.deltaX:n?e.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:a*e.deltaY};default:return{deltaX:a*e.deltaX,deltaY:a*e.deltaY}}},xe=(e,t,n,r)=>{const a=n-e,i=r-t;return Math.hypot(a,i)},Me=(e,t)=>Math.abs(e/t),Ce=(e,t)=>e*t/100,Ee=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},Oe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),Ie=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Fe=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},Te=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),Pe=e=>0===e.length?[]:e.split(" ").filter(Boolean),Le=e=>""===e||f(e),ke=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},_e=(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},De=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let a=0;a<r;a++){const i=e[a],l={charIndex:a,prevChar:a>0?e[a-1]:null,nextChar:a<r-1?e[a+1]:null};n?.(i,l)||t(i,l)}},Ne=(e,t=1/0)=>0===e.length?"":Pe(e).slice(0,t).map(e=>e[0]).join("").toUpperCase(),Re=(e,t,n,r=t)=>e.split(t).map((e,t)=>n(e.trim(),t)).join(r),Xe=(e,t,n,r=[],a=void 0,i=0)=>(e?.forEach(e=>{const{[n]:l,...o}=e,s=e[n],c=Array.isArray(s);if(r.push({...o,parentId:a,depthLevel:i,childCount:c?s.length:0}),c){const a=e[t];Xe(s,t,n,r,a,i+1)}}),r),je=(e,t,n)=>e.filter(e=>e.parentId===t&&(!n||n(e))),We=(e,t,n,r)=>{const a=Pe(r.toLowerCase());if(!a.length)return e;const i=e.reduce((e,n,r)=>(e[n[t]]=r,e),{});return e.reduce((r,l)=>{const o=l[n];if(!o)return r;if(r.some(e=>e[t]===l[t]))return r;const s=Pe(o.toLowerCase());if(a.every(e=>s.some(t=>t.startsWith(e))))if(m(l.parentId)){r.push(l);const n=a=>{a.childCount&&e.forEach(e=>{e.parentId===a[t]&&(r.push(e),n(e))})};n(l)}else{const t=n=>{const a=i[n.parentId],l=e[a];m(l.parentId)||t(l);const o=r.length?r[r.length-1].parentId:null;(h(o)||o!==n.parentId)&&(u(l,"[@react-hive/honey-utils]: Parent node was not found."),r.push(l))};t(l),r.push(l)}return r},[])},Ye=(e,t)=>{u(t>=0&&t<=1,`[@react-hive/honey-utils]: Alpha "${t}" must be a number between 0 and 1.`);const n=e.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/);u(n,`[@react-hive/honey-utils]: Invalid hex format: ${e}`);const r=n[1];return`#${(3===r.length?r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r)+Math.round(255*t).toString(16).toUpperCase().padStart(2,"0")}`};module.exports=t})();
2
2
  //# sourceMappingURL=index.cjs.map