@react-hive/honey-utils 4.3.0 → 5.0.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.
Files changed (54) hide show
  1. package/README.md +24 -12
  2. package/dist/README.md +24 -12
  3. package/dist/a11y/focus/is-html-element-focusable.d.ts +8 -6
  4. package/dist/a11y/focus/move-focus-within-container.d.ts +1 -1
  5. package/dist/array/chunk.d.ts +4 -1
  6. package/dist/array/compose.d.ts +7 -3
  7. package/dist/array/get-adjacent-items.d.ts +1 -1
  8. package/dist/array/index.d.ts +1 -0
  9. package/dist/array/intersection.d.ts +2 -1
  10. package/dist/array/is-array.d.ts +6 -0
  11. package/dist/array/is-empty-array.d.ts +7 -0
  12. package/dist/array/pipe.d.ts +5 -2
  13. package/dist/array/to-map-by.d.ts +48 -0
  14. package/dist/async/async.d.ts +10 -1
  15. package/dist/async/retry.d.ts +4 -3
  16. package/dist/dom/data-transfer.d.ts +22 -4
  17. package/dist/dom/dom.d.ts +7 -5
  18. package/dist/dom/transform/parse-2d-matrix.d.ts +5 -0
  19. package/dist/encoding/decode-base64-json.d.ts +22 -1
  20. package/dist/encoding/decode-base64.d.ts +23 -1
  21. package/dist/encoding/encode-base64-json.d.ts +16 -0
  22. package/dist/encoding/encode-base64.d.ts +20 -0
  23. package/dist/env/storage/local-storage-json.d.ts +1 -1
  24. package/dist/env/storage/local-storage.d.ts +1 -6
  25. package/dist/file.d.ts +3 -2
  26. package/dist/function/function.d.ts +12 -0
  27. package/dist/geometry/apply-inertia-step.d.ts +1 -1
  28. package/dist/geometry/layout/calculate-center-offset.d.ts +11 -1
  29. package/dist/geometry/layout/clamp-offset-to-overflow.d.ts +6 -0
  30. package/dist/geometry/resolve-bounded-delta.d.ts +1 -1
  31. package/dist/guards.d.ts +24 -3
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.dev.cjs +402 -97
  35. package/dist/index.dev.cjs.map +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/intersection/get-dom-rect-intersection-ratio.d.ts +8 -1
  39. package/dist/intersection/resolve-axis-delta.d.ts +7 -0
  40. package/dist/json/parse-json.d.ts +22 -1
  41. package/dist/math/hash-string.d.ts +1 -1
  42. package/dist/math/math.d.ts +17 -1
  43. package/dist/object.d.ts +7 -1
  44. package/dist/string/for-each-char.d.ts +1 -1
  45. package/dist/string/is-nil-or-empty-string.d.ts +1 -1
  46. package/dist/string/parse-file-name.d.ts +1 -1
  47. package/dist/tree/flatten-tree.d.ts +2 -2
  48. package/dist/tree/get-tree-children.d.ts +2 -2
  49. package/dist/tree/search-tree.d.ts +2 -2
  50. package/dist/tree/tree.types.d.ts +1 -1
  51. package/package.json +8 -7
  52. package/dist/geometry/apply-inertia-step.spec.d.ts +0 -1
  53. package/dist/geometry/resolve-bounded-delta.spec.d.ts +0 -1
  54. package/dist/id/generate-ephemeral-id.spec.d.ts +0 -1
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- const t=t=>new Blob([t],{type:t.type}),e=t=>new DOMRect(t.offsetLeft,t.offsetTop,t.clientWidth,t.clientHeight),n=t=>"A"===t.tagName,r=t=>"true"===t.getAttribute("contenteditable"),a=["INPUT","SELECT","TEXTAREA","BUTTON","A"],l=t=>{if(!t)return!1;const e=window.getComputedStyle(t);if("hidden"===e.visibility||"none"===e.display)return!1;if("disabled"in t&&t.disabled)return!1;const l=t.getAttribute("tabindex");return"-1"!==l&&(a.includes(t.tagName)?!n(t)||""!==t.href:!!r(t)||null!==l)},o=t=>Array.from(t.querySelectorAll("*")).filter(l),i=(t,e=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,l=e??a?.parentElement;if(!a||!l)return;const i=o(l);if(0===i.length)return;const s=i.indexOf(a);if(-1===s)return;let c;r?c=r(s,t,i):"next"===t?(c=s+1,c>=i.length&&(c=n?0:null)):(c=s-1,c<0&&(c=n?i.length-1:null)),null!==c&&i[c]?.focus()},s=(...t)=>e=>t.reduce((t,e)=>e(t),e),c=(...t)=>e=>t.reduceRight((t,e)=>e(t),e),u=(t,e)=>t.filter(t=>!e.includes(t)),f=t=>[...new Set(t)],h=(...t)=>{if(0===t.length)return[];if(1===t.length)return[...t[0]];const[e,...n]=t;return f(e).filter(t=>n.every(e=>e.includes(t)))};function d(t,e){if(!t)throw new Error(e)}const m=t=>null===t,p=t=>null==t,g=t=>null!=t,y=t=>void 0===t,w=t=>"number"==typeof t,b=t=>"boolean"==typeof t,x=t=>"object"==typeof t,A=t=>x(t)&&!m(t)&&0===Object.keys(t).length,S=t=>t instanceof Date,M=t=>t instanceof Blob,I=t=>t instanceof Error,v=t=>S(t)&&!isNaN(t.getTime()),C=t=>t instanceof RegExp,O=t=>t instanceof Map,$=t=>t instanceof Set,E=t=>"symbol"==typeof t,k=t=>w(t)&&isFinite(t),L=t=>w(t)&&Number.isInteger(t),T=t=>k(t)&&!Number.isInteger(t),P=(t,e)=>Object.values(t).includes(e),B=(t,e)=>(d(e>0,"Chunk size must be greater than 0"),Array.from({length:Math.ceil(t.length/e)},(n,r)=>t.slice(r*e,(r+1)*e))),N=t=>t.filter(Boolean),X=t=>Array.isArray(t),_=t=>X(t)&&0===t.length,z=(t,e,n)=>{if(!t?.length||!e)return{previousItem:null,currentItem:null,nextItem:null};const r=t.findIndex(t=>n(t,e));return-1===r?{previousItem:null,currentItem:null,nextItem:null}:{previousItem:r>0?t[r-1]:null,currentItem:t[r],nextItem:r<t.length-1?t[r+1]:null}},U=(t,e,n)=>{const r=t.includes(e);return r===(n??!r)?t:r?u(t,[e]):[...t,e]},Y=()=>{},j=t=>"function"==typeof t,F=t=>(...e)=>!t(...e),R=t=>{let e,n=!1;return function(...r){return n||(n=!0,e=t.apply(this,r)),e}},D=t=>j(t?.then),W=async(t,e)=>{const n=[];for(let r=0;r<t.length;r++)n.push(await e(t[r],r,t));return n},H=async(t,e)=>Promise.all(t.map(e)),Z=async(t,e)=>{const n=[];for(let r=0;r<t.length;r++){const a=t[r];await e(a,r,t)&&n.push(a)}return n},J=async(t,e)=>{const n=await H(t,async(t,n,r)=>!!await e(t,n,r)&&t);return N(n)},V=async(t,e)=>{for(let n=0;n<t.length;n++)if(await e(t[n],n,t))return!0;return!1},G=async(t,e)=>{for(let n=0;n<t.length;n++)if(!await e(t[n],n,t))return!1;return!0},q=async(t,e,n)=>{let r=n;for(let n=0;n<t.length;n++)r=await e(r,t[n],n,t);return r},K=async(t,e)=>{for(let n=0;n<t.length;n++)if(await e(t[n],n,t))return t[n];return null},Q=t=>new Promise(e=>setTimeout(e,t)),tt=async(t,e,n="Operation timed out")=>{try{return await Promise.race([t,Q(e).then(()=>Promise.reject(new Error(n)))])}finally{}},et=(t,{maxAttempts:e=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...l)=>{let o;for(let i=1;i<=e;i++)try{return await t(...l)}catch(t){if(o=t,i<e){a?.(i,t);const e=r?n*2**(i-1):n;await Q(e)}}throw o},nt=t=>{try{return JSON.parse(t)}catch{return null}},rt="application/json",at=(t,e)=>{t.setData(rt,JSON.stringify(e))},lt=t=>{const e=t.getData(rt);return e?nt(e):null},ot=t=>"string"==typeof t,it=(t,{fileName:e,target:n}={})=>{if(y(document))return;const r=document.createElement("a");let a=null;try{const l=ot(t)?t:a=URL.createObjectURL(t);r.href=l,e&&(r.download=e),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),a&&setTimeout(()=>{d(a,"Object URL should not be null"),URL.revokeObjectURL(a)},0)}},st=t=>{const e=t.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${e?`?${e}`:""}${window.location.hash}`)},ct=t=>t.scrollWidth>t.clientWidth,ut=t=>Math.max(0,t.scrollWidth-t.clientWidth),ft=t=>t.scrollHeight>t.clientHeight,ht=t=>Math.max(0,t.scrollHeight-t.clientHeight),dt=({containerSize:t,elementOffset:e,elementSize:n})=>-(e+n/2-t/2),mt=(t,e)=>e<=0?0:Math.max(-e,Math.min(t,0)),pt=(t,e,{axis:n="both",shouldClamp:r=!0}={})=>{let a=0,l=0;if("x"===n||"both"===n){const n=dt({containerSize:t.clientWidth,elementOffset:e.offsetLeft,elementSize:e.clientWidth});a=r?mt(n,ut(t)):n}if("y"===n||"both"===n){const n=dt({containerSize:t.clientHeight,elementOffset:e.offsetTop,elementSize:e.clientHeight});l=r?mt(n,ht(t)):n}t.style.transform=`translate(${a}px, ${l}px)`},gt=t=>{const e=window.getComputedStyle(t).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!e)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,a,l,o,i]=e[1].split(", ").map(parseFloat);return{translateX:o,translateY:i,scaleX:n,scaleY:l,skewX:a,skewY:r}},yt=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},wt=()=>{if(!yt())return{readable:!1,writable:!1};try{const t="__test_write__";return window.localStorage.setItem(t,"1"),window.localStorage.removeItem(t),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}},bt=t=>{try{const e=window.localStorage.getItem(t);return null===e?null:nt(e)}catch{return null}},xt=(t,e)=>{try{return window.localStorage.setItem(t,JSON.stringify(e)),!0}catch{return!1}},At=t=>t instanceof File,St=t=>{if(!t)return[];const e=[];for(let n=0;n<t.length;n++)e.push(t[n]);return e},Mt=(t,e)=>new File([t],e,{type:t.type}),It=async(t,{skipFiles:e=[".DS_Store","Thumbs.db","desktop.ini","ehthumbs.db",".Spotlight-V100",".Trashes",".fseventsd","__MACOSX"]}={})=>{const n=new Set(e),r=await(async t=>{const e=t.createReader(),n=async()=>new Promise((t,r)=>{e.readEntries(async e=>{if(e.length)try{const r=await n();t([...e,...r])}catch(t){r(t)}else t([])},r)});return n()})(t);return(await H(r,async t=>t.isDirectory?It(t,{skipFiles:e}):n.has(t.name)?[]:[await new Promise((e,n)=>{t.file(e,n)})])).flat()},vt=async(t,e={})=>{const n=t?.items;if(!n)return[];const r=[];for(let t=0;t<n.length;t++){const a=n[t];if("webkitGetAsEntry"in a){const t=a.webkitGetAsEntry?.();if(t?.isDirectory){r.push(It(t,e));continue}if(t?.isFile){r.push(new Promise((e,n)=>t.file(t=>e([t]),n)));continue}}const l=a.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},Ct=(t,...e)=>"function"==typeof t?t(...e):t,Ot=({delta:t,value:e,min:n,max:r})=>{if(0===t)return null;const a=e+t;return t<0?e<=n?null:Math.max(a,n):t>0?e>=r?null:Math.min(a,r):null},$t=({value:t,min:e,max:n,velocityPxMs:r,deltaTimeMs:a,friction:l=.002,minVelocityPxMs:o=.01,emaAlpha:i=.2})=>{if(Math.abs(r)<o)return null;const s=Ot({delta:r*a,value:t,min:e,max:n});if(null===s)return null;const c=r*Math.exp(-l*a),u=i>0?r*(1-i)+c*i:c;return Math.abs(u)<o?null:{value:s,velocityPxMs:u}},Et=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,kt=(t,e)=>Math.max(0,Math.min(t.right,e.right)-Math.max(t.left,e.left))*Math.max(0,Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top))/(e.width*e.height),Lt=(t,e,{allowFallback:n=!0,invert:r=!0}={})=>{const a=r?-1:1;switch(e){case"x":return{deltaX:a*(0!==t.deltaX?t.deltaX:n?t.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:a*t.deltaY};default:return{deltaX:a*t.deltaX,deltaY:a*t.deltaY}}},Tt=(t,e,n,r)=>{const a=n-t,l=r-e;return Math.hypot(a,l)},Pt=(t,e)=>Math.abs(t/e),Bt=(t,e)=>t*e/100,Nt=t=>{let e=5381;for(let n=0;n<t.length;n++)e=33*e^t.charCodeAt(n);return(e>>>0).toString(36)},Xt=(t,e,n)=>Math.min(Math.max(t,e),n),_t=t=>Object.entries(t).reduce((t,[e,n])=>(void 0!==n&&(t[e]=n),t),{}),zt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ut=t=>{const e=t.charAt(0),n=t.slice(1);return e.toLowerCase()+n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)},Yt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),jt=t=>0===t.length?[]:t.split(" ").filter(Boolean),Ft=t=>""===t||p(t),Rt=t=>{const e=t.lastIndexOf(".");return e<=0||e===t.length-1?[t,""]:[t.slice(0,e),t.slice(e+1).toLowerCase()]},Dt=(t,e)=>{if(0===t.length)return[];const n=e.charCodeAt(0),r=[];for(let e=0;e<t.length;e++)t.charCodeAt(e)===n&&r.push(e);return r},Wt=(t,e,n)=>{if(0===t.length)return;const r=t.length;for(let a=0;a<r;a++){const l=t[a],o={charIndex:a,prevChar:a>0?t[a-1]:null,nextChar:a<r-1?t[a+1]:null};n?.(l,o)||e(l,o)}},Ht=(t,e=1/0)=>0===t.length?"":jt(t).slice(0,e).map(t=>t[0]).join("").toUpperCase(),Zt=(t,e,n,r=e)=>t.split(e).map((t,e)=>n(t.trim(),e)).join(r),Jt=(t,e,n,r=[],a=void 0,l=0)=>(t?.forEach(t=>{const{[n]:o,...i}=t,s=t[n],c=Array.isArray(s);if(r.push({...i,parentId:a,depthLevel:l,childCount:c?s.length:0}),c){const a=t[e];Jt(s,e,n,r,a,l+1)}}),r),Vt=(t,e,n)=>t.filter(t=>t.parentId===e&&(!n||n(t))),Gt=(t,e,n,r)=>{const a=jt(r.toLowerCase());if(!a.length)return t;const l=t.reduce((t,n,r)=>(t[n[e]]=r,t),{});return t.reduce((r,o)=>{const i=o[n];if(!i)return r;if(r.some(t=>t[e]===o[e]))return r;const s=jt(i.toLowerCase());if(a.every(t=>s.some(e=>e.startsWith(t))))if(y(o.parentId)){r.push(o);const n=a=>{a.childCount&&t.forEach(t=>{t.parentId===a[e]&&(r.push(t),n(t))})};n(o)}else{const e=n=>{const a=l[n.parentId],o=t[a];y(o.parentId)||e(o);const i=r.length?r[r.length-1].parentId:null;(m(i)||i!==n.parentId)&&(d(o,"[@react-hive/honey-utils]: Parent node was not found."),r.push(o))};e(o),r.push(o)}return r},[])},qt=(t,e)=>{d(e>=0&&e<=1,`[@react-hive/honey-utils]: Alpha "${e}" must be a number between 0 and 1.`);const n=t.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/);d(n,`[@react-hive/honey-utils]: Invalid hex format: ${t}`);const r=n[1];return`#${(3===r.length?r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r)+Math.round(255*e).toString(16).toUpperCase().padStart(2,"0")}`},Kt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Qt=t=>{if(!Kt.test(t))return null;try{return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode((t=>{if("function"==typeof Uint8Array.fromBase64)return Uint8Array.fromBase64(t);if("undefined"!=typeof Buffer)return Buffer.from(t,"base64");const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n})(t))}catch{return null}},te=t=>{const e=Qt(t);return null===e?null:nt(e)},ee=t=>(t=>{if("function"==typeof t.toBase64)return t.toBase64();if("undefined"!=typeof Buffer)return Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)})((new TextEncoder).encode(t)),ne=t=>ee(JSON.stringify(t));export{rt as DATA_TRANSFER_JSON_MIME,a as FOCUSABLE_HTML_TAGS,$t as applyInertiaStep,d as assert,Mt as blobToFile,dt as calculateCenterOffset,Tt as calculateEuclideanDistance,Pt as calculateMovingSpeed,Bt as calculatePercentage,Ut as camelToDashCase,Yt as camelToWords,pt as centerElementInContainer,B as chunk,Xt as clamp,mt as clampOffsetToOverflow,t as cloneBlob,N as compact,c as compose,Qt as decodeBase64,te as decodeBase64Json,_t as definedProps,Q as delay,u as difference,it as downloadFile,ee as encodeBase64,ne as encodeBase64Json,G as everyAsync,St as fileListToFiles,J as filterParallel,Z as filterSequential,K as findAsync,Dt as findCharIndices,Jt as flattenTree,Wt as forEachChar,Et as generateEphemeralId,z as getAdjacentItems,kt as getDOMRectIntersectionRatio,lt as getDataTransferJson,e as getElementOffsetRect,o as getFocusableHtmlElements,wt as getLocalStorageCapabilities,Vt as getTreeChildren,Ht as getWordsInitials,ut as getXOverflowWidth,ht as getYOverflowHeight,ct as hasXOverflow,ft as hasYOverflow,Nt as hashString,qt as hexWithAlpha,h as intersection,Ct as invokeIfFunction,n as isAnchorHtmlElement,X as isArray,M as isBlob,b as isBool,r as isContentEditableHtmlElement,S as isDate,T as isDecimal,g as isDefined,_ as isEmptyArray,A as isEmptyObject,P as isEnumValue,I as isError,At as isFile,k as isFiniteNumber,j as isFunction,l as isHtmlElementFocusable,L as isInteger,yt as isLocalStorageReadable,O as isMap,p as isNil,Ft as isNilOrEmptyString,m as isNull,w as isNumber,x as isObject,D as isPromise,C as isRegExp,$ as isSet,ot as isString,E as isSymbol,y as isUndefined,v as isValidDate,i as moveFocusWithinContainer,Y as noop,F as not,R as once,gt as parse2DMatrix,Rt as parseFileName,nt as parseJson,s as pipe,vt as readFilesFromDataTransfer,bt as readLocalStorageJson,q as reduceAsync,st as replaceHistorySearchParams,Lt as resolveAxisDelta,Ot as resolveBoundedDelta,et as retry,H as runParallel,W as runSequential,Gt as searchTree,at as setDataTransferJson,V as someAsync,Zt as splitMapJoin,jt as splitStringIntoWords,tt as timeout,zt as toKebabCase,U as toggleArrayItem,It as traverseFileSystemDirectory,f as unique,xt as writeLocalStorageJson};
1
+ const t=t=>new Blob([t],{type:t.type}),e=t=>new DOMRect(t.offsetLeft,t.offsetTop,t.clientWidth,t.clientHeight),n=t=>"A"===t.tagName,r=t=>{const e=t.getAttribute("contenteditable");return null!==e&&["","true","plaintext-only"].includes(e.toLowerCase())},l=["INPUT","SELECT","TEXTAREA","BUTTON","A"],a=t=>{if(!t)return!1;if("hidden"===window.getComputedStyle(t).visibility)return!1;for(let e=t;e;e=e.parentElement)if("none"===window.getComputedStyle(e).display)return!1;if(t.matches(":disabled"))return!1;const e=(t=>{const e=null===t?null:/^\s*([+-]?\d+)/.exec(t);return e?parseInt(e[1],10):null})(t.getAttribute("tabindex"));return null!==e?e>=0:l.includes(t.tagName)?!n(t)||""!==t.href:r(t)},o=t=>Array.from(t.querySelectorAll("*")).filter(a),i=(t,e=null,{wrap:n=!0,getNextIndex:r}={})=>{const l=document.activeElement,a=e??l?.parentElement;if(!l||!a)return;const i=o(a);if(0===i.length)return;const s=i.indexOf(l);if(-1===s)return;let u;r?u=r(s,t,i):"next"===t?(u=s+1,u>=i.length&&(u=n?0:null)):(u=s-1,u<0&&(u=n?i.length-1:null)),null!==u&&i[u]?.focus()},s=(...t)=>e=>t.reduce((t,e)=>e(t),e),u=(...t)=>e=>t.reduceRight((t,e)=>e(t),e),c=(t,e)=>t.filter(t=>!e.includes(t)),f=t=>[...new Set(t)],h=(...t)=>{if(0===t.length)return[];const[e,...n]=t;return f(e).filter(t=>n.every(e=>e.includes(t)))};function d(t,e){if(!t)throw new Error(e)}const m=t=>null===t,p=t=>null==t,y=t=>null!=t,g=t=>void 0===t,w=t=>"number"==typeof t,b=t=>"boolean"==typeof t,x=t=>"object"==typeof t&&null!==t,S=t=>x(t)&&Reflect.ownKeys(t).every(e=>!Object.prototype.propertyIsEnumerable.call(t,e)),A=t=>t instanceof Date,I=t=>t instanceof Blob,M=t=>t instanceof Error,v=t=>A(t)&&!isNaN(t.getTime()),C=t=>t instanceof RegExp,L=t=>t instanceof Map,E=t=>t instanceof Set,O=t=>"symbol"==typeof t,$=t=>w(t)&&isFinite(t),T=t=>w(t)&&Number.isInteger(t),N=t=>$(t)&&!Number.isInteger(t),P=(t,e)=>Object.values(t).includes(e),k=(t,e)=>(d(Number.isInteger(e)&&e>0,"Chunk size must be a positive whole number"),Array.from({length:Math.ceil(t.length/e)},(n,r)=>t.slice(r*e,(r+1)*e))),B=t=>t.filter(Boolean),X=t=>Array.isArray(t),_=t=>X(t)&&0===t.length,R=(t,e,n)=>{if(!t?.length||!e)return{previousItem:null,currentItem:null,nextItem:null};const r=t.findIndex(t=>n(t,e));return-1===r?{previousItem:null,currentItem:null,nextItem:null}:{previousItem:r>0?t[r-1]:null,currentItem:t[r],nextItem:r<t.length-1?t[r+1]:null}},U=(t,e,n)=>{const r=t.includes(e);return r===(n??!r)?t:r?c(t,[e]):[...t,e]};function Y(t,e,n){const r=new Map;return t.forEach((t,l)=>{r.set(e(t,l),n?n(t,l):t)}),r}const F=()=>{},j=t=>"function"==typeof t,z=t=>(...e)=>!t(...e),D=t=>{let e,n,r=!1,l=!1;return function(...a){if(!r){r=!0;try{e=t.apply(this,a)}catch(t){l=!0,n=t}}if(l)throw n;return e}},W=t=>j(t?.then),H=async(t,e)=>{const n=[];for(let r=0;r<t.length;r++)n.push(await e(t[r],r,t));return n},J=async(t,e)=>Promise.all(t.map(e)),V=async(t,e)=>{const n=[];for(let r=0;r<t.length;r++){const l=t[r];await e(l,r,t)&&n.push(l)}return n},Z=async(t,e)=>{const n=await J(t,e);return t.filter((t,e)=>n[e])},G=async(t,e)=>{for(let n=0;n<t.length;n++)if(await e(t[n],n,t))return!0;return!1},K=async(t,e)=>{for(let n=0;n<t.length;n++)if(!await e(t[n],n,t))return!1;return!0},q=async(t,e,n)=>{let r=n;for(let n=0;n<t.length;n++)r=await e(r,t[n],n,t);return r},Q=async(t,e)=>{for(let n=0;n<t.length;n++)if(await e(t[n],n,t))return t[n];return null},tt=t=>new Promise(e=>setTimeout(e,t)),et=async(t,e,n="Operation timed out")=>{let r=null;try{return await Promise.race([t,new Promise((t,l)=>{r=setTimeout(()=>l(new Error(n)),e)})])}finally{null!==r&&clearTimeout(r)}},nt=(t,{maxAttempts:e=3,delayMs:n=300,backoff:r=!0,onRetry:l}={})=>{const a=Math.max(1,e);return async(...e)=>{let o;for(let i=1;i<=a;i++)try{return await t(...e)}catch(t){if(o=t,i<a){l?.(i,t);const e=r?n*2**(i-1):n;await tt(e)}}throw o}},rt=t=>{try{return JSON.parse(t)}catch{return null}},lt="application/json",at=(t,e)=>{t.setData(lt,JSON.stringify(e))},ot=t=>{const e=t.getData(lt);return e?rt(e):null},it=t=>"string"==typeof t,st=(t,{fileName:e,target:n}={})=>{if("undefined"==typeof document)return;const r=document.createElement("a");let l=null;try{const a=it(t)?t:l=URL.createObjectURL(t);r.href=a,e&&(r.download=e),n&&(r.target=n),document.body.appendChild(r),r.click()}finally{r.remove(),l&&setTimeout(()=>{d(l,"Object URL should not be null"),URL.revokeObjectURL(l)},0)}},ut=t=>{const e=t.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${e?`?${e}`:""}${window.location.hash}`)},ct=t=>t.scrollWidth>t.clientWidth,ft=t=>Math.max(0,t.scrollWidth-t.clientWidth),ht=t=>t.scrollHeight>t.clientHeight,dt=t=>Math.max(0,t.scrollHeight-t.clientHeight),mt=({containerSize:t,elementOffset:e,elementSize:n})=>-(e+n/2-t/2)||0,pt=(t,e)=>e<=0?0:Math.max(-e,Math.min(t,0)),yt=(t,e,{axis:n="both",shouldClamp:r=!0}={})=>{let l=0,a=0;if("x"===n||"both"===n){const n=mt({containerSize:t.clientWidth,elementOffset:e.offsetLeft,elementSize:e.clientWidth});l=r?pt(n,ft(t)):n}if("y"===n||"both"===n){const n=mt({containerSize:t.clientHeight,elementOffset:e.offsetTop,elementSize:e.clientHeight});a=r?pt(n,dt(t)):n}t.style.transform=`translate(${l}px, ${a}px)`},gt=t=>{const e=window.getComputedStyle(t).getPropertyValue("transform").match(/^matrix\((.+)\)$/);if(!e)return{translateX:0,translateY:0,scaleX:1,scaleY:1,skewX:0,skewY:0};const[n,r,l,a,o,i]=e[1].split(", ").map(parseFloat);return{translateX:o,translateY:i,scaleX:n,scaleY:a,skewX:l,skewY:r}},wt=()=>{if("undefined"==typeof window)return!1;try{return!!window.localStorage&&(window.localStorage.getItem("__non_existing_key__"),!0)}catch{return!1}},bt=()=>{if(!wt())return{readable:!1,writable:!1};try{const t="__test_write__";return window.localStorage.setItem(t,"1"),window.localStorage.removeItem(t),{readable:!0,writable:!0}}catch{}return{readable:!0,writable:!1}},xt=t=>{try{const e=window.localStorage.getItem(t);return null===e?null:rt(e)}catch{return null}},St=(t,e)=>{try{return window.localStorage.setItem(t,JSON.stringify(e)),!0}catch{return!1}},At=t=>t instanceof File,It=t=>{if(!t)return[];const e=[];for(let n=0;n<t.length;n++)e.push(t[n]);return e},Mt=(t,e)=>new File([t],e,{type:t.type}),vt=async(t,{skipFiles:e=[".DS_Store","Thumbs.db","desktop.ini","ehthumbs.db",".Spotlight-V100",".Trashes",".fseventsd","__MACOSX"]}={})=>{const n=new Set(e),r=await(async t=>{const e=t.createReader(),n=async()=>new Promise((t,r)=>{e.readEntries(async e=>{if(e.length)try{const r=await n();t([...e,...r])}catch(t){r(t)}else t([])},r)});return n()})(t);return(await J(r,async t=>n.has(t.name)?[]:t.isDirectory?vt(t,{skipFiles:e}):[await new Promise((e,n)=>{t.file(e,n)})])).flat()},Ct=async(t,e={})=>{const n=t?.items;if(!n)return[];const r=[];for(let t=0;t<n.length;t++){const l=n[t];if("webkitGetAsEntry"in l){const t=l.webkitGetAsEntry?.();if(t?.isDirectory){r.push(vt(t,e));continue}if(t?.isFile){r.push(new Promise((e,n)=>t.file(t=>e([t]),n)));continue}}const a=l.getAsFile();a&&r.push(Promise.resolve([a]))}return(await Promise.all(r)).flat()},Lt=(t,...e)=>"function"==typeof t?t(...e):t,Et=({delta:t,value:e,min:n,max:r})=>{if(0===t)return null;const l=e+t;return t<0?e<=n?null:Math.max(l,n):t>0?e>=r?null:Math.min(l,r):null},Ot=({value:t,min:e,max:n,velocityPxMs:r,deltaTimeMs:l,friction:a=.002,minVelocityPxMs:o=.01,emaAlpha:i=.2})=>{if(Math.abs(r)<o)return null;const s=Et({delta:r*l,value:t,min:e,max:n});if(null===s)return null;const u=r*Math.exp(-a*l),c=i>0?r*(1-i)+u*i:u;return Math.abs(c)<o?null:{value:s,velocityPxMs:c}},$t=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,Tt=(t,e)=>{const n=Math.max(0,Math.min(t.right,e.right)-Math.max(t.left,e.left))*Math.max(0,Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top)),r=e.width*e.height;return r<=0?0:n/r},Nt=(t,e,{allowFallback:n=!0,invert:r=!0}={})=>{const l=r?-1:1,a=t=>l*t||0;switch(e){case"x":return{deltaX:a(0!==t.deltaX?t.deltaX:n?t.deltaY:0),deltaY:0};case"y":return{deltaX:0,deltaY:a(t.deltaY)};default:return{deltaX:a(t.deltaX),deltaY:a(t.deltaY)}}},Pt=(t,e,n,r)=>{const l=n-t,a=r-e;return Math.hypot(l,a)},kt=(t,e)=>Math.abs(t/e),Bt=(t,e)=>t*e/100,Xt=t=>{let e=5381;for(let n=0;n<t.length;n++)e=33*e^t.charCodeAt(n);return(e>>>0).toString(36)},_t=(t,e,n)=>Math.min(Math.max(t,e),n),Rt=t=>{const e={};return Reflect.ownKeys(t).forEach(n=>{if(!Object.prototype.propertyIsEnumerable.call(t,n))return;const r=t[n];void 0!==r&&(e[n]=r)}),e},Ut=t=>t.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu,"$1-$2").toLowerCase(),Yt=t=>{const e=t.charAt(0),n=t.slice(1);return e.toLowerCase()+n.replace(/\p{Lu}/gu,t=>`-${t.toLowerCase()}`)},Ft=t=>t.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu,"$1 $2").replace(/(\p{Lu})(\p{Lu}\p{Ll})/gu,"$1 $2"),jt=t=>0===t.length?[]:t.split(" ").filter(Boolean),zt=t=>""===t||p(t),Dt=t=>{const e=t.lastIndexOf(".");return e<=0||e===t.length-1?[t,""]:[t.slice(0,e),t.slice(e+1).toLowerCase()]},Wt=(t,e)=>{if(0===t.length)return[];const n=e.charCodeAt(0),r=[];for(let e=0;e<t.length;e++)t.charCodeAt(e)===n&&r.push(e);return r},Ht=(t,e,n)=>{if(0===t.length)return;const r=t.length;for(let l=0;l<r;l++){const a=t[l],o={charIndex:l,prevChar:l>0?t[l-1]:null,nextChar:l<r-1?t[l+1]:null};n?.(a,o)||e(a,o)}},Jt=(t,e=1/0)=>0===t.length?"":jt(t).slice(0,e).map(t=>String.fromCodePoint(t.codePointAt(0))).join("").toUpperCase(),Vt=(t,e,n,r=e)=>t.split(e).map((t,e)=>n(t.trim(),e)).join(r),Zt=(t,e,n,r=[],l=void 0,a=0)=>(t?.forEach(t=>{const{[n]:o,...i}=t,s=t[n],u=Array.isArray(s);if(r.push({...i,parentId:l,depthLevel:a,childCount:u?s.length:0}),u){const l=t[e];Zt(s,e,n,r,l,a+1)}}),r),Gt=(t,e,n)=>t.filter(t=>t.parentId===e&&(!n||n(t))),Kt=(t,e,n,r)=>{const l=jt(r.toLowerCase());if(!l.length)return t;const a=t.reduce((t,n,r)=>(t[n[e]]=r,t),{});return t.reduce((r,o)=>{const i=o[n];if(!i)return r;if(r.some(t=>t[e]===o[e]))return r;const s=jt(i.toLowerCase());if(l.every(t=>s.some(e=>e.startsWith(t))))if(g(o.parentId)){r.push(o);const n=l=>{l.childCount&&t.forEach(t=>{t.parentId===l[e]&&(r.push(t),n(t))})};n(o)}else{const e=n=>{const l=a[n.parentId],o=t[l];g(o.parentId)||e(o);const i=r.length?r[r.length-1].parentId:null;(m(i)||i!==n.parentId)&&(d(o,"[@react-hive/honey-utils]: Parent node was not found."),r.push(o))};e(o),r.push(o)}return r},[])},qt=(t,e)=>{d(e>=0&&e<=1,`[@react-hive/honey-utils]: Alpha "${e}" must be a number between 0 and 1.`);const n=t.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/);d(n,`[@react-hive/honey-utils]: Invalid hex format: ${t}`);const r=n[1];return`#${(3===r.length?r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r)+Math.round(255*e).toString(16).toUpperCase().padStart(2,"0")}`},Qt=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,te=t=>{if(!Qt.test(t))return null;try{return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode((t=>{if("function"==typeof Uint8Array.fromBase64)return Uint8Array.fromBase64(t);if("undefined"!=typeof Buffer)return Buffer.from(t,"base64");const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n})(t))}catch{return null}},ee=t=>{const e=te(t);return null===e?null:rt(e)},ne=t=>(t=>{if("function"==typeof t.toBase64)return t.toBase64();if("undefined"!=typeof Buffer)return Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)})((new TextEncoder).encode(t)),re=t=>ne(JSON.stringify(t));export{lt as DATA_TRANSFER_JSON_MIME,l as FOCUSABLE_HTML_TAGS,Ot as applyInertiaStep,d as assert,Mt as blobToFile,mt as calculateCenterOffset,Pt as calculateEuclideanDistance,kt as calculateMovingSpeed,Bt as calculatePercentage,Yt as camelToDashCase,Ft as camelToWords,yt as centerElementInContainer,k as chunk,_t as clamp,pt as clampOffsetToOverflow,t as cloneBlob,B as compact,u as compose,te as decodeBase64,ee as decodeBase64Json,Rt as definedProps,tt as delay,c as difference,st as downloadFile,ne as encodeBase64,re as encodeBase64Json,K as everyAsync,It as fileListToFiles,Z as filterParallel,V as filterSequential,Q as findAsync,Wt as findCharIndices,Zt as flattenTree,Ht as forEachChar,$t as generateEphemeralId,R as getAdjacentItems,Tt as getDOMRectIntersectionRatio,ot as getDataTransferJson,e as getElementOffsetRect,o as getFocusableHtmlElements,bt as getLocalStorageCapabilities,Gt as getTreeChildren,Jt as getWordsInitials,ft as getXOverflowWidth,dt as getYOverflowHeight,ct as hasXOverflow,ht as hasYOverflow,Xt as hashString,qt as hexWithAlpha,h as intersection,Lt as invokeIfFunction,n as isAnchorHtmlElement,X as isArray,I as isBlob,b as isBool,r as isContentEditableHtmlElement,A as isDate,N as isDecimal,y as isDefined,_ as isEmptyArray,S as isEmptyObject,P as isEnumValue,M as isError,At as isFile,$ as isFiniteNumber,j as isFunction,a as isHtmlElementFocusable,T as isInteger,wt as isLocalStorageReadable,L as isMap,p as isNil,zt as isNilOrEmptyString,m as isNull,w as isNumber,x as isObject,W as isPromise,C as isRegExp,E as isSet,it as isString,O as isSymbol,g as isUndefined,v as isValidDate,i as moveFocusWithinContainer,F as noop,z as not,D as once,gt as parse2DMatrix,Dt as parseFileName,rt as parseJson,s as pipe,Ct as readFilesFromDataTransfer,xt as readLocalStorageJson,q as reduceAsync,ut as replaceHistorySearchParams,Nt as resolveAxisDelta,Et as resolveBoundedDelta,nt as retry,J as runParallel,H as runSequential,Kt as searchTree,at as setDataTransferJson,G as someAsync,Vt as splitMapJoin,jt as splitStringIntoWords,et as timeout,Ut as toKebabCase,Y as toMapBy,U as toggleArrayItem,vt as traverseFileSystemDirectory,f as unique,St as writeLocalStorageJson};
2
2
  //# sourceMappingURL=index.mjs.map