import{Hashery as e}from"../../../hashery/dist/node/index.mjs";var r=e=>{let r;if(void 0!==e){if("number"==typeof e)r=e;else{if("string"!=typeof e)return;if(e=e.trim(),Number.isNaN(Number(e))){const t=/^([\d.]+)\s*(ms|s|m|h|hr|d)$/i.exec(e);if(!t)throw new Error(`Unsupported time format: "${e}". Use 'ms', 's', 'm', 'h', 'hr', or 'd'.`);const[,i,s]=t,a=Number.parseFloat(i);switch(s.toLowerCase()){case"ms":r=a;break;case"s":r=1e3*a;break;case"m":r=1e3*a*60;break;case"h":case"hr":r=1e3*a*60*60;break;case"d":r=1e3*a*60*60*24;break;
/* v8 ignore next -- @preserve */default:r=Number(e)}}else r=Number(e)}return r}},t=(e,t)=>{t??=new Date;const i=r(e);return void 0===i?t.getTime():t.getTime()+i},i=(e=>(e.SHA256="SHA-256",e.SHA384="SHA-384",e.SHA512="SHA-512",e.DJB2="djb2",e.FNV1="fnv1",e.MURMER="murmer",e.CRC32="crc32",e))(i||{});function s(r,t={algorithm:"djb2",serialize:JSON.stringify}){const i=t?.algorithm??"djb2",s=(t?.serialize??JSON.stringify)(r);return(new e).toHashSync(s,{algorithm:i})}function a(r,t={min:0,max:10,algorithm:"djb2",serialize:JSON.stringify}){const i=t?.min??0,s=t?.max??10,a=t?.algorithm??"djb2",n=t?.serialize??JSON.stringify,m=t?.hashLength??16;if(i>=s)throw new Error(`Invalid range: min (${i}) must be less than max (${s})`);const o=n(r);return(new e).toNumberSync(o,{algorithm:a,min:i,max:s,hashLength:m})}function n(e,r){const{ttl:t,keyPrefix:i,cache:s,serialize:a}=r;return(...n)=>{let o=m(e,n,{keyPrefix:i,serialize:a});r.createKey&&(o=r.createKey(e,n,r));let c=s.get(o);if(void 0===c)try{c=e(...n),s.set(o,c,t)}catch(e){s.emit("error",e),r.cacheErrors&&s.set(o,e,t)}return c}}function m(e,r,t){const{keyPrefix:i,serialize:a}=t||{};return i?`${i}::${e.name}::${s(r,{serialize:a})}`:`${e.name}::${s(r,{serialize:a})}`}
/* v8 ignore next -- @preserve */export{i as HashAlgorithm,m as createWrapKey,s as hashSync,a as hashToNumberSync,r as shorthandToMilliseconds,t as shorthandToTime,n as wrapSync};