@react-hive/honey-utils 4.2.0 → 4.3.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 +32 -0
- package/dist/README.md +32 -0
- package/dist/env/storage/index.d.ts +1 -0
- package/dist/env/storage/local-storage-json.d.ts +29 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +72 -3
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=e=>new Blob([e],{type:e.type}),t=e=>new DOMRect(e.offsetLeft,e.offsetTop,e.clientWidth,e.clientHeight),n=e=>"A"===e.tagName,r=e=>"true"===e.getAttribute("contenteditable"),a=["INPUT","SELECT","TEXTAREA","BUTTON","A"],l=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 l=e.getAttribute("tabindex");return"-1"!==l&&(a.includes(e.tagName)?!n(e)||""!==e.href:!!r(e)||null!==l)},o=e=>Array.from(e.querySelectorAll("*")).filter(l),i=(e,t=null,{wrap:n=!0,getNextIndex:r}={})=>{const a=document.activeElement,l=t??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,e,i):"next"===e?(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=(...e)=>t=>e.reduce((e,t)=>t(e),t),c=(...e)=>t=>e.reduceRight((e,t)=>t(e),t),u=(e,t)=>e.filter(e=>!t.includes(e)),f=e=>[...new Set(e)],h=(...e)=>{if(0===e.length)return[];if(1===e.length)return[...e[0]];const[t,...n]=e;return f(t).filter(e=>n.every(t=>t.includes(e)))};function d(e,t){if(!e)throw new Error(t)}const m=e=>null===e,p=e=>null==e,y=e=>null!=e,g=e=>void 0===e,w=e=>"number"==typeof e,b=e=>"boolean"==typeof e,x=e=>"object"==typeof e,A=e=>x(e)&&!m(e)&&0===Object.keys(e).length,S=e=>e instanceof Date,M=e=>e instanceof Blob,v=e=>e instanceof Error,I=e=>S(e)&&!isNaN(e.getTime()),C=e=>e instanceof RegExp,O=e=>e instanceof Map,$=e=>e instanceof Set,E=e=>"symbol"==typeof e,k=e=>w(e)&&isFinite(e),L=e=>w(e)&&Number.isInteger(e),T=e=>k(e)&&!Number.isInteger(e),P=(e,t)=>Object.values(e).includes(t),B=(e,t)=>(d(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))),X=e=>e.filter(Boolean),_=e=>Array.isArray(e),N=e=>_(e)&&0===e.length,z=(e,t,n)=>{if(!e?.length||!t)return{previousItem:null,currentItem:null,nextItem:null};const r=e.findIndex(e=>n(e,t));return-1===r?{previousItem:null,currentItem:null,nextItem:null}:{previousItem:r>0?e[r-1]:null,currentItem:e[r],nextItem:r<e.length-1?e[r+1]:null}},U=(e,t,n)=>{const r=e.includes(t);return r===(n??!r)?e:r?u(e,[t]):[...e,t]},Y=()=>{},j=e=>"function"==typeof e,F=e=>(...t)=>!e(...t),R=e=>{let t,n=!1;return function(...r){return n||(n=!0,t=e.apply(this,r)),t}},D=e=>j(e?.then),W=async(e,t)=>{const n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r,e));return n},H=async(e,t)=>Promise.all(e.map(t)),Z=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},J=async(e,t)=>{const n=await H(e,async(e,n,r)=>!!await t(e,n,r)&&e);return X(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},q=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},K=async(e,t)=>{for(let n=0;n<e.length;n++)if(await t(e[n],n,e))return e[n];return null},Q=e=>new Promise(t=>setTimeout(t,e)),ee=async(e,t,n="Operation timed out")=>{try{return await Promise.race([e,Q(t).then(()=>Promise.reject(new Error(n)))])}finally{}},te=(e,{maxAttempts:t=3,delayMs:n=300,backoff:r=!0,onRetry:a}={})=>async(...l)=>{let o;for(let i=1;i<=t;i++)try{return await e(...l)}catch(e){if(o=e,i<t){a?.(i,e);const t=r?n*2**(i-1):n;await Q(t)}}throw o},ne=e=>{try{return JSON.parse(e)}catch{return null}},re="application/json",ae=(e,t)=>{e.setData(re,JSON.stringify(t))},le=e=>{const t=e.getData(re);return t?ne(t):null},oe=e=>"string"==typeof e,ie=(e,{fileName:t,target:n}={})=>{if(g(document))return;const r=document.createElement("a");let a=null;try{const l=oe(e)?e:a=URL.createObjectURL(e);r.href=l,t&&(r.download=t),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)}},se=e=>{const t=e.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${t?`?${t}`:""}${window.location.hash}`)},ce=e=>e.scrollWidth>e.clientWidth,ue=e=>Math.max(0,e.scrollWidth-e.clientWidth),fe=e=>e.scrollHeight>e.clientHeight,he=e=>Math.max(0,e.scrollHeight-e.clientHeight),de=({containerSize:e,elementOffset:t,elementSize:n})=>-(t+n/2-e/2),me=(e,t)=>t<=0?0:Math.max(-t,Math.min(e,0)),pe=(e,t,{axis:n="both",shouldClamp:r=!0}={})=>{let a=0,l=0;if("x"===n||"both"===n){const n=de({containerSize:e.clientWidth,elementOffset:t.offsetLeft,elementSize:t.clientWidth});a=r?me(n,ue(e)):n}if("y"===n||"both"===n){const n=de({containerSize:e.clientHeight,elementOffset:t.offsetTop,elementSize:t.clientHeight});l=r?me(n,he(e)):n}e.style.transform=`translate(${a}px, ${l}px)`},ye=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,l,o,i]=t[1].split(", ").map(parseFloat);return{translateX:o,translateY:i,scaleX:n,scaleY:l,skewX:a,skewY:r}},ge=()=>{if("undefined"==typeof window||!window.localStorage)return!1;try{return window.localStorage.getItem("__non_existing_key__"),!0}catch{return!1}},we=()=>{if(!ge())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}},be=e=>e instanceof File,xe=e=>{if(!e)return[];const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t},Ae=(e,t)=>new File([e],t,{type:e.type}),Se=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 H(r,async e=>e.isDirectory?Se(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 a=n[e];if("webkitGetAsEntry"in a){const e=a.webkitGetAsEntry?.();if(e?.isDirectory){r.push(Se(e,t));continue}if(e?.isFile){r.push(new Promise((t,n)=>e.file(e=>t([e]),n)));continue}}const l=a.getAsFile();l&&r.push(Promise.resolve([l]))}return(await Promise.all(r)).flat()},ve=(e,...t)=>"function"==typeof e?e(...t):e,Ie=({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},Ce=({value:e,min:t,max:n,velocityPxMs:r,deltaTimeMs:a,friction:l=.002,minVelocityPxMs:o=.01,emaAlpha:i=.2})=>{if(Math.abs(r)<o)return null;const s=Ie({delta:r*a,value:e,min:t,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}},Oe=()=>`${Math.floor(1e3*performance.now()).toString(36)}${Math.random().toString(36).slice(2,10)}`,$e=(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),Ee=(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}}},ke=(e,t,n,r)=>{const a=n-e,l=r-t;return Math.hypot(a,l)},Le=(e,t)=>Math.abs(e/t),Te=(e,t)=>e*t/100,Pe=e=>{let t=5381;for(let n=0;n<e.length;n++)t=33*t^e.charCodeAt(n);return(t>>>0).toString(36)},Be=(e,t,n)=>Math.min(Math.max(e,t),n),Xe=e=>Object.entries(e).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),_e=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ne=e=>{const t=e.charAt(0),n=e.slice(1);return t.toLowerCase()+n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)},ze=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),Ue=e=>0===e.length?[]:e.split(" ").filter(Boolean),Ye=e=>""===e||p(e),je=e=>{const t=e.lastIndexOf(".");return t<=0||t===e.length-1?[e,""]:[e.slice(0,t),e.slice(t+1).toLowerCase()]},Fe=(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},Re=(e,t,n)=>{if(0===e.length)return;const r=e.length;for(let a=0;a<r;a++){const l=e[a],o={charIndex:a,prevChar:a>0?e[a-1]:null,nextChar:a<r-1?e[a+1]:null};n?.(l,o)||t(l,o)}},De=(e,t=1/0)=>0===e.length?"":Ue(e).slice(0,t).map(e=>e[0]).join("").toUpperCase(),We=(e,t,n,r=t)=>e.split(t).map((e,t)=>n(e.trim(),t)).join(r),He=(e,t,n,r=[],a=void 0,l=0)=>(e?.forEach(e=>{const{[n]:o,...i}=e,s=e[n],c=Array.isArray(s);if(r.push({...i,parentId:a,depthLevel:l,childCount:c?s.length:0}),c){const a=e[t];He(s,t,n,r,a,l+1)}}),r),Ze=(e,t,n)=>e.filter(e=>e.parentId===t&&(!n||n(e))),Je=(e,t,n,r)=>{const a=Ue(r.toLowerCase());if(!a.length)return e;const l=e.reduce((e,n,r)=>(e[n[t]]=r,e),{});return e.reduce((r,o)=>{const i=o[n];if(!i)return r;if(r.some(e=>e[t]===o[t]))return r;const s=Ue(i.toLowerCase());if(a.every(e=>s.some(t=>t.startsWith(e))))if(g(o.parentId)){r.push(o);const n=a=>{a.childCount&&e.forEach(e=>{e.parentId===a[t]&&(r.push(e),n(e))})};n(o)}else{const t=n=>{const a=l[n.parentId],o=e[a];g(o.parentId)||t(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))};t(o),r.push(o)}return r},[])},Ve=(e,t)=>{d(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})$/);d(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")}`},Ge=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,qe=e=>{if(!Ge.test(e))return null;try{return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode((e=>{if("function"==typeof Uint8Array.fromBase64)return Uint8Array.fromBase64(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64");const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n})(e))}catch{return null}},Ke=e=>{const t=qe(e);return null===t?null:ne(t)},Qe=e=>(e=>{if("function"==typeof e.toBase64)return e.toBase64();if("undefined"!=typeof Buffer)return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64");let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)})((new TextEncoder).encode(e)),et=e=>Qe(JSON.stringify(e));export{re as DATA_TRANSFER_JSON_MIME,a as FOCUSABLE_HTML_TAGS,Ce as applyInertiaStep,d as assert,Ae as blobToFile,de as calculateCenterOffset,ke as calculateEuclideanDistance,Le as calculateMovingSpeed,Te as calculatePercentage,Ne as camelToDashCase,ze as camelToWords,pe as centerElementInContainer,B as chunk,Be as clamp,me as clampOffsetToOverflow,e as cloneBlob,X as compact,c as compose,qe as decodeBase64,Ke as decodeBase64Json,Xe as definedProps,Q as delay,u as difference,ie as downloadFile,Qe as encodeBase64,et as encodeBase64Json,G as everyAsync,xe as fileListToFiles,J as filterParallel,Z as filterSequential,K as findAsync,Fe as findCharIndices,He as flattenTree,Re as forEachChar,Oe as generateEphemeralId,z as getAdjacentItems,$e as getDOMRectIntersectionRatio,le as getDataTransferJson,t as getElementOffsetRect,o as getFocusableHtmlElements,we as getLocalStorageCapabilities,Ze as getTreeChildren,De as getWordsInitials,ue as getXOverflowWidth,he as getYOverflowHeight,ce as hasXOverflow,fe as hasYOverflow,Pe as hashString,Ve as hexWithAlpha,h as intersection,ve as invokeIfFunction,n as isAnchorHtmlElement,_ as isArray,M as isBlob,b as isBool,r as isContentEditableHtmlElement,S as isDate,T as isDecimal,y as isDefined,N as isEmptyArray,A as isEmptyObject,P as isEnumValue,v as isError,be as isFile,k as isFiniteNumber,j as isFunction,l as isHtmlElementFocusable,L as isInteger,ge as isLocalStorageReadable,O as isMap,p as isNil,Ye as isNilOrEmptyString,m as isNull,w as isNumber,x as isObject,D as isPromise,C as isRegExp,$ as isSet,oe as isString,E as isSymbol,g as isUndefined,I as isValidDate,i as moveFocusWithinContainer,Y as noop,F as not,R as once,ye as parse2DMatrix,je as parseFileName,ne as parseJson,s as pipe,Me as readFilesFromDataTransfer,q as reduceAsync,se as replaceHistorySearchParams,Ee as resolveAxisDelta,Ie as resolveBoundedDelta,te as retry,H as runParallel,W as runSequential,Je as searchTree,ae as setDataTransferJson,V as someAsync,We as splitMapJoin,Ue as splitStringIntoWords,ee as timeout,_e as toKebabCase,U as toggleArrayItem,Se as traverseFileSystemDirectory,f as unique};
|
|
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};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|