@sv443-network/coreutils 3.4.0 → 3.5.1

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.
@@ -16,11 +16,12 @@
16
16
 
17
17
 
18
18
 
19
- "use strict";var Y=Object.create;var N=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var ne=(r,e)=>{for(var t in e)N(r,t,{get:e[t],enumerable:!0})},K=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of te(e))!ie.call(r,n)&&n!==t&&N(r,n,{get:()=>e[n],enumerable:!(i=ee(e,n))||i.enumerable});return r};var A=(r,e,t)=>(t=r!=null?Y(re(r)):{},K(e||!r||!r.__esModule?N(t,"default",{value:r,enumerable:!0}):t,r)),ae=r=>K(N({},"__esModule",{value:!0}),r);var $e={};ne($e,{BrowserStorageEngine:()=>j,ChecksumMismatchError:()=>w,CustomError:()=>S,DataStore:()=>U,DataStoreEngine:()=>P,DataStoreSerializer:()=>L,DatedError:()=>p,Debouncer:()=>F,FileStorageEngine:()=>B,MigrationError:()=>x,NanoEmitter:()=>T,NetworkError:()=>E,ScriptContextError:()=>b,ValidationError:()=>R,abtoa:()=>W,atoab:()=>Q,autoPlural:()=>Oe,bitSetHas:()=>oe,capitalize:()=>Ne,clamp:()=>D,compress:()=>$,computeHash:()=>z,consumeGen:()=>ge,consumeStringGen:()=>be,createProgressBar:()=>Ve,createRecurringTask:()=>Pe,darkenColor:()=>q,debounce:()=>Ie,decompress:()=>C,defaultPbChars:()=>G,digitCount:()=>se,fetchAdvanced:()=>ye,formatNumber:()=>ue,getCallStack:()=>Ee,getListLength:()=>De,hexToRgb:()=>_,insertValues:()=>Fe,joinArrayReadable:()=>ke,lightenColor:()=>fe,mapRange:()=>V,overflowVal:()=>ce,pauseFor:()=>Te,pureObj:()=>Se,randRange:()=>v,randomId:()=>he,randomItem:()=>de,randomItemIndex:()=>I,randomizeArray:()=>me,rgbToHex:()=>H,roundFixed:()=>M,scheduleExit:()=>xe,secsToTimeStr:()=>Ae,setImmediateInterval:()=>ve,setImmediateTimeoutLoop:()=>we,takeRandomItem:()=>pe,takeRandomItemIndex:()=>J,truncStr:()=>Me,valsWithin:()=>le});module.exports=ae($e);function oe(r,e){return(r&e)===e}function D(r,e,t){return typeof t!="number"&&(t=e,e=0),Math.max(Math.min(r,t),e)}function se(r,e=!0){if(r=Number(["string","number"].includes(typeof r)?r:String(r)),typeof r=="number"&&isNaN(r))return NaN;let[t,i]=r.toString().split("."),n=t==="0"?1:Math.floor(Math.log10(Math.abs(Number(t)))+1),o=e&&i?i.length:0;return n+o}function ue(r,e,t){return r.toLocaleString(e,t==="short"?{notation:"compact",compactDisplay:"short",maximumFractionDigits:1}:{style:"decimal",maximumFractionDigits:0})}function V(r,e,t,i,n){return(typeof i>"u"||typeof n>"u")&&(n=t,t=e,i=e=0),Number(e)===0&&Number(i)===0?r*(n/t):(r-e)*((n-i)/(t-e))+i}function ce(r,e,t){let i=typeof t=="number"?e:0;if(t=typeof t=="number"?t:e,i>t)throw new RangeError(`Parameter "min" can't be bigger than "max"`);if(isNaN(r)||isNaN(i)||isNaN(t)||!isFinite(r)||!isFinite(i)||!isFinite(t))return NaN;if(r>=i&&r<=t)return r;let n=t-i+1;return((r-i)%n+n)%n+i}function v(...r){let e,t,i=!1;if(typeof r[0]=="number"&&typeof r[1]=="number")[e,t]=r;else if(typeof r[0]=="number"&&typeof r[1]!="number")e=0,[t]=r;else throw new TypeError(`Wrong parameter(s) provided - expected (number, boolean|undefined) or (number, number, boolean|undefined) but got (${r.map(n=>typeof n).join(", ")}) instead`);if(typeof r[2]=="boolean"?i=r[2]:typeof r[1]=="boolean"&&(i=r[1]),e=Number(e),t=Number(t),isNaN(e)||isNaN(t))return NaN;if(e>t)throw new TypeError(`Parameter "min" can't be bigger than "max"`);if(i){let n=new Uint8Array(1);return crypto.getRandomValues(n),Number(Array.from(n,o=>Math.round(V(o,0,255,e,t)).toString(10)).join(""))}else return Math.floor(Math.random()*(t-e+1))+e}function M(r,e){let t=10**e;return Math.round(r*t)/t}function le(r,e,t=1,i=.5){return Math.abs(M(r,t)-M(e,t))<=i}function de(r){return I(r)[0]}function I(r){if(r.length===0)return[void 0,void 0];let e=v(r.length-1);return[r[e],e]}function me(r){let e=[...r];if(r.length===0)return e;for(let t=e.length-1;t>0;t--){let i=Math.floor(Math.random()*(t+1));[e[t],e[i]]=[e[i],e[t]]}return e}function pe(r){var e;return(e=J(r))==null?void 0:e[0]}function J(r){let[e,t]=I(r);return t===void 0?[void 0,void 0]:(r.splice(t,1),[e,t])}function q(r,e,t=!1){var c;r=r.trim();let i=(l,d,m,f)=>(l=Math.max(0,Math.min(255,l-l*f/100)),d=Math.max(0,Math.min(255,d-d*f/100)),m=Math.max(0,Math.min(255,m-m*f/100)),[l,d,m]),n,o,a,s,u=r.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/);if(u)[n,o,a,s]=_(r);else if(r.startsWith("rgb")){let l=(c=r.match(/\d+(\.\d+)?/g))==null?void 0:c.map(Number);if(!l)throw new TypeError("Invalid RGB/RGBA color format");[n,o,a,s]=l}else throw new TypeError("Unsupported color format");return[n,o,a]=i(n,o,a,e),u?H(n,o,a,s,r.startsWith("#"),t):r.startsWith("rgba")?`rgba(${n}, ${o}, ${a}, ${s??NaN})`:`rgb(${n}, ${o}, ${a})`}function _(r){r=(r.startsWith("#")?r.slice(1):r).trim();let e=r.length===8||r.length===4?parseInt(r.slice(-(r.length/4)),16)/(r.length===8?255:15):void 0;isNaN(Number(e))||(r=r.slice(0,-(r.length/4))),(r.length===3||r.length===4)&&(r=r.split("").map(a=>a+a).join(""));let t=parseInt(r,16),i=t>>16&255,n=t>>8&255,o=t&255;return[D(i,0,255),D(n,0,255),D(o,0,255),typeof e=="number"?D(e,0,1):void 0]}function fe(r,e,t=!1){return q(r,e*-1,t)}function H(r,e,t,i,n=!0,o=!1){let a=s=>D(Math.round(s),0,255).toString(16).padStart(2,"0")[o?"toUpperCase":"toLowerCase"]();return`${n?"#":""}${a(r)}${a(e)}${a(t)}${i?a(i*255):""}`}function W(r){return btoa(new Uint8Array(r).reduce((e,t)=>e+String.fromCharCode(t),""))}function Q(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0))}async function $(r,e,t="string"){let i=r instanceof Uint8Array?r:new TextEncoder().encode((r==null?void 0:r.toString())??String(r)),n=new CompressionStream(e),o=n.writable.getWriter();o.write(i),o.close();let a=new Uint8Array(await new Response(n.readable).arrayBuffer());return t==="arrayBuffer"?a:W(a)}async function C(r,e,t="string"){let i=r instanceof Uint8Array?r:Q((r==null?void 0:r.toString())??String(r)),n=new DecompressionStream(e),o=n.writable.getWriter();o.write(i),o.close();let a=new Uint8Array(await new Response(n.readable).arrayBuffer());return t==="arrayBuffer"?a:new TextDecoder().decode(a)}async function z(r,e="SHA-256"){let t;typeof r=="string"?t=new TextEncoder().encode(r):t=r;let i=await crypto.subtle.digest(e,t);return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("")}function he(r=16,e=16,t=!1,i=!0){if(r<1)throw new RangeError("The length argument must be at least 1");if(e<2||e>36)throw new RangeError("The radix argument must be between 2 and 36");let n=[],o=i?[0,1]:[0];if(t){let a=new Uint8Array(r);crypto.getRandomValues(a),n=Array.from(a,s=>V(s,0,255,0,e).toString(e).substring(0,1))}else n=Array.from({length:r},()=>Math.floor(Math.random()*e).toString(e));return n.some(a=>/[a-zA-Z]/.test(a))?n.map(a=>o[v(0,o.length-1,t)]===1?a.toUpperCase():a).join(""):n.join("")}var p=class extends Error{date;constructor(e,t){super(e,t),this.name=this.constructor.name,this.date=new Date}},w=class extends p{constructor(e,t){super(e,t),this.name="ChecksumMismatchError"}},S=class extends p{constructor(e,t,i){super(t,i),this.name=e}},x=class extends p{constructor(e,t){super(e,t),this.name="MigrationError"}},R=class extends p{constructor(e,t){super(e,t),this.name="ValidationError"}},b=class extends p{constructor(e,t){super(e,t),this.name="ScriptContextError"}},E=class extends p{constructor(e,t){super(e,t),this.name="NetworkError"}};async function ge(r){return await(typeof r=="function"?r():r)}async function be(r){return typeof r=="string"?r:String(typeof r=="function"?await r():r)}async function ye(r,e={}){let{timeout:t=1e4,signal:i,...n}=e,o=new AbortController;i==null||i.addEventListener("abort",()=>o.abort());let a={},s;t>=0&&(s=setTimeout(()=>o.abort(),t),a={signal:o.signal});try{let u=await fetch(r,{...n,...a});return typeof s<"u"&&clearTimeout(s),u}catch(u){throw typeof s<"u"&&clearTimeout(s),new E("Error while calling fetch",{cause:u})}}function De(r,e=!0){return"length"in r?r.length:"size"in r?r.size:"count"in r?r.count:e?0:NaN}function Te(r,e,t=!1){return new Promise((i,n)=>{let o=setTimeout(()=>i(),r);e==null||e.addEventListener("abort",()=>{clearTimeout(o),t?n(new S("AbortError","The pause was aborted")):i()})})}function Se(r){return Object.assign(Object.create(null),r??{})}function ve(r,e,t){let i,n=()=>clearInterval(i),o=()=>{if(t!=null&&t.aborted)return n();r()};t==null||t.addEventListener("abort",n),o(),i=setInterval(o,e)}function we(r,e,t){let i,n=()=>clearTimeout(i),o=async()=>{if(t!=null&&t.aborted)return n();await r(),i=setTimeout(o,e)};t==null||t.addEventListener("abort",n),o()}function xe(r=0,e=0){if(e<0)throw new TypeError("Timeout must be a non-negative number");let t;if(typeof process<"u"&&"exit"in process&&typeof process.exit=="function")t=()=>process.exit(r);else if(typeof Deno<"u"&&"exit"in Deno&&typeof Deno.exit=="function")t=()=>Deno.exit(r);else throw new b("Cannot exit the process, no exit method available");setTimeout(t,e)}function Ee(r,e=1/0){if(typeof e!="number"||isNaN(e)||e<0)throw new TypeError("lines parameter must be a non-negative number");try{throw new S("GetCallStack","Capturing a stack trace with CoreUtils.getCallStack(). If you see this anywhere, you can safely ignore it.")}catch(t){let i=(t.stack??"").split(`
19
+ "use strict";var le=Object.create;var I=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var fe=(r,e)=>{for(var t in e)I(r,t,{get:e[t],enumerable:!0})},G=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of de(e))!pe.call(r,n)&&n!==t&&I(r,n,{get:()=>e[n],enumerable:!(i=ce(e,n))||i.enumerable});return r};var U=(r,e,t)=>(t=r!=null?le(me(r)):{},G(e||!r||!r.__esModule?I(t,"default",{value:r,enumerable:!0}):t,r)),he=r=>G(I({},"__esModule",{value:!0}),r);var _e={};fe(_e,{BrowserStorageEngine:()=>W,ChecksumMismatchError:()=>F,CustomError:()=>O,DataStore:()=>_,DataStoreEngine:()=>$,DataStoreSerializer:()=>Q,DatedError:()=>b,Debouncer:()=>z,FileStorageEngine:()=>H,MigrationError:()=>M,NanoEmitter:()=>E,NetworkError:()=>C,ScriptContextError:()=>x,ValidationError:()=>J,abtoa:()=>te,atoab:()=>re,autoPlural:()=>Re,bitSetHas:()=>ge,capitalize:()=>ze,clamp:()=>P,compress:()=>B,computeHash:()=>q,consumeGen:()=>Ee,consumeStringGen:()=>Oe,createProgressBar:()=>Ue,createRecurringTask:()=>Ie,createTable:()=>qe,darkenColor:()=>X,debounce:()=>Je,decompress:()=>K,defaultPbChars:()=>ie,defaultTableLineCharset:()=>ne,digitCount:()=>be,fetchAdvanced:()=>Ae,formatNumber:()=>ye,getCallStack:()=>$e,getListLength:()=>Ne,hexToRgb:()=>Y,insertValues:()=>Le,joinArrayReadable:()=>je,lightenColor:()=>xe,mapRange:()=>R,overflowVal:()=>Te,pauseFor:()=>Ve,pureObj:()=>ke,randRange:()=>k,randomId:()=>Pe,randomItem:()=>Se,randomItemIndex:()=>j,randomizeArray:()=>ve,rgbToHex:()=>ee,roundFixed:()=>L,scheduleExit:()=>Ce,secsToTimeStr:()=>Be,setImmediateInterval:()=>Fe,setImmediateTimeoutLoop:()=>Me,takeRandomItem:()=>we,takeRandomItemIndex:()=>Z,truncStr:()=>Ke,valsWithin:()=>De});module.exports=he(_e);function ge(r,e){return(r&e)===e}function P(r,e,t){return typeof t!="number"&&(t=e,e=0),Math.max(Math.min(r,t),e)}function be(r,e=!0){if(r=Number(["string","number"].includes(typeof r)?r:String(r)),typeof r=="number"&&isNaN(r))return NaN;let[t,i]=r.toString().split("."),n=t==="0"?1:Math.floor(Math.log10(Math.abs(Number(t)))+1),o=e&&i?i.length:0;return n+o}function ye(r,e,t){return r.toLocaleString(e,t==="short"?{notation:"compact",compactDisplay:"short",maximumFractionDigits:1}:{style:"decimal",maximumFractionDigits:0})}function R(r,e,t,i,n){return(typeof i>"u"||typeof n>"u")&&(n=t,t=e,i=e=0),Number(e)===0&&Number(i)===0?r*(n/t):(r-e)*((n-i)/(t-e))+i}function Te(r,e,t){let i=typeof t=="number"?e:0;if(t=typeof t=="number"?t:e,i>t)throw new RangeError(`Parameter "min" can't be bigger than "max"`);if(isNaN(r)||isNaN(i)||isNaN(t)||!isFinite(r)||!isFinite(i)||!isFinite(t))return NaN;if(r>=i&&r<=t)return r;let n=t-i+1;return((r-i)%n+n)%n+i}function k(...r){let e,t,i=!1;if(typeof r[0]=="number"&&typeof r[1]=="number")[e,t]=r;else if(typeof r[0]=="number"&&typeof r[1]!="number")e=0,[t]=r;else throw new TypeError(`Wrong parameter(s) provided - expected (number, boolean|undefined) or (number, number, boolean|undefined) but got (${r.map(n=>typeof n).join(", ")}) instead`);if(typeof r[2]=="boolean"?i=r[2]:typeof r[1]=="boolean"&&(i=r[1]),e=Number(e),t=Number(t),isNaN(e)||isNaN(t))return NaN;if(e>t)throw new TypeError(`Parameter "min" can't be bigger than "max"`);if(i){let n=new Uint8Array(1);return crypto.getRandomValues(n),Number(Array.from(n,o=>Math.round(R(o,0,255,e,t)).toString(10)).join(""))}else return Math.floor(Math.random()*(t-e+1))+e}function L(r,e){let t=10**e;return Math.round(r*t)/t}function De(r,e,t=1,i=.5){return Math.abs(L(r,t)-L(e,t))<=i}function Se(r){return j(r)[0]}function j(r){if(r.length===0)return[void 0,void 0];let e=k(r.length-1);return[r[e],e]}function ve(r){let e=[...r];if(r.length===0)return e;for(let t=e.length-1;t>0;t--){let i=Math.floor(Math.random()*(t+1));[e[t],e[i]]=[e[i],e[t]]}return e}function we(r){var e;return(e=Z(r))==null?void 0:e[0]}function Z(r){let[e,t]=j(r);return t===void 0?[void 0,void 0]:(r.splice(t,1),[e,t])}function X(r,e,t=!1){var c;r=r.trim();let i=(m,p,h,l)=>(m=Math.max(0,Math.min(255,m-m*l/100)),p=Math.max(0,Math.min(255,p-p*l/100)),h=Math.max(0,Math.min(255,h-h*l/100)),[m,p,h]),n,o,a,s,u=r.match(/^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/);if(u)[n,o,a,s]=Y(r);else if(r.startsWith("rgb")){let m=(c=r.match(/\d+(\.\d+)?/g))==null?void 0:c.map(Number);if(!m)throw new TypeError("Invalid RGB/RGBA color format");[n,o,a,s]=m}else throw new TypeError("Unsupported color format");return[n,o,a]=i(n,o,a,e),u?ee(n,o,a,s,r.startsWith("#"),t):r.startsWith("rgba")?`rgba(${n}, ${o}, ${a}, ${s??NaN})`:`rgb(${n}, ${o}, ${a})`}function Y(r){r=(r.startsWith("#")?r.slice(1):r).trim();let e=r.length===8||r.length===4?parseInt(r.slice(-(r.length/4)),16)/(r.length===8?255:15):void 0;isNaN(Number(e))||(r=r.slice(0,-(r.length/4))),(r.length===3||r.length===4)&&(r=r.split("").map(a=>a+a).join(""));let t=parseInt(r,16),i=t>>16&255,n=t>>8&255,o=t&255;return[P(i,0,255),P(n,0,255),P(o,0,255),typeof e=="number"?P(e,0,1):void 0]}function xe(r,e,t=!1){return X(r,e*-1,t)}function ee(r,e,t,i,n=!0,o=!1){let a=s=>P(Math.round(s),0,255).toString(16).padStart(2,"0")[o?"toUpperCase":"toLowerCase"]();return`${n?"#":""}${a(r)}${a(e)}${a(t)}${i?a(i*255):""}`}function te(r){return btoa(new Uint8Array(r).reduce((e,t)=>e+String.fromCharCode(t),""))}function re(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0))}async function B(r,e,t="string"){let i=r instanceof Uint8Array?r:new TextEncoder().encode((r==null?void 0:r.toString())??String(r)),n=new CompressionStream(e),o=n.writable.getWriter();o.write(i),o.close();let a=new Uint8Array(await new Response(n.readable).arrayBuffer());return t==="arrayBuffer"?a:te(a)}async function K(r,e,t="string"){let i=r instanceof Uint8Array?r:re((r==null?void 0:r.toString())??String(r)),n=new DecompressionStream(e),o=n.writable.getWriter();o.write(i),o.close();let a=new Uint8Array(await new Response(n.readable).arrayBuffer());return t==="arrayBuffer"?a:new TextDecoder().decode(a)}async function q(r,e="SHA-256"){let t;typeof r=="string"?t=new TextEncoder().encode(r):t=r;let i=await crypto.subtle.digest(e,t);return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("")}function Pe(r=16,e=16,t=!1,i=!0){if(r<1)throw new RangeError("The length argument must be at least 1");if(e<2||e>36)throw new RangeError("The radix argument must be between 2 and 36");let n=[],o=i?[0,1]:[0];if(t){let a=new Uint8Array(r);crypto.getRandomValues(a),n=Array.from(a,s=>R(s,0,255,0,e).toString(e).substring(0,1))}else n=Array.from({length:r},()=>Math.floor(Math.random()*e).toString(e));return n.some(a=>/[a-zA-Z]/.test(a))?n.map(a=>o[k(0,o.length-1,t)]===1?a.toUpperCase():a).join(""):n.join("")}var b=class extends Error{date;constructor(e,t){super(e,t),this.name=this.constructor.name,this.date=new Date}},F=class extends b{constructor(e,t){super(e,t),this.name="ChecksumMismatchError"}},O=class extends b{constructor(e,t,i){super(t,i),this.name=e}},M=class extends b{constructor(e,t){super(e,t),this.name="MigrationError"}},J=class extends b{constructor(e,t){super(e,t),this.name="ValidationError"}},x=class extends b{constructor(e,t){super(e,t),this.name="ScriptContextError"}},C=class extends b{constructor(e,t){super(e,t),this.name="NetworkError"}};async function Ee(r){return await(typeof r=="function"?r():r)}async function Oe(r){return typeof r=="string"?r:String(typeof r=="function"?await r():r)}async function Ae(r,e={}){let{timeout:t=1e4,signal:i,...n}=e,o=new AbortController;i==null||i.addEventListener("abort",()=>o.abort());let a={},s;t>=0&&(s=setTimeout(()=>o.abort(),t),a={signal:o.signal});try{let u=await fetch(r,{...n,...a});return typeof s<"u"&&clearTimeout(s),u}catch(u){throw typeof s<"u"&&clearTimeout(s),new C("Error while calling fetch",{cause:u})}}function Ne(r,e=!0){return"length"in r?r.length:"size"in r?r.size:"count"in r?r.count:e?0:NaN}function Ve(r,e,t=!1){return new Promise((i,n)=>{let o=setTimeout(()=>i(),r);e==null||e.addEventListener("abort",()=>{clearTimeout(o),t?n(new O("AbortError","The pause was aborted")):i()})})}function ke(r){return Object.assign(Object.create(null),r??{})}function Fe(r,e,t){let i,n=()=>clearInterval(i),o=()=>{if(t!=null&&t.aborted)return n();r()};t==null||t.addEventListener("abort",n),o(),i=setInterval(o,e)}function Me(r,e,t){let i,n=()=>clearTimeout(i),o=async()=>{if(t!=null&&t.aborted)return n();await r(),i=setTimeout(o,e)};t==null||t.addEventListener("abort",n),o()}function Ce(r=0,e=0){if(e<0)throw new TypeError("Timeout must be a non-negative number");let t;if(typeof process<"u"&&"exit"in process&&typeof process.exit=="function")t=()=>process.exit(r);else if(typeof Deno<"u"&&"exit"in Deno&&typeof Deno.exit=="function")t=()=>Deno.exit(r);else throw new x("Cannot exit the process, no exit method available");setTimeout(t,e)}function $e(r,e=1/0){if(typeof e!="number"||isNaN(e)||e<0)throw new TypeError("lines parameter must be a non-negative number");try{throw new O("GetCallStack","Capturing a stack trace with CoreUtils.getCallStack(). If you see this anywhere, you can safely ignore it.")}catch(t){let i=(t.stack??"").split(`
20
20
  `).map(n=>n.trim()).slice(2,e+2);return r!==!1?i:i.join(`
21
- `)}}function Pe(r){var n;let e=0,t=!1;(n=r.signal)==null||n.addEventListener("abort",()=>{t=!0},{once:!0});let i=async(o=!1)=>{var a;if(!t){try{if(((r.immediate??!0)||!o)&&(e++,await((a=r.condition)==null?void 0:a.call(r,e-1))??!0)){let s=await r.task(e-1);r.onSuccess&&await r.onSuccess(s,e-1)}}catch(s){if(r.onError&&await r.onError(s,e-1),r.abortOnError&&(t=!0),!r.onError&&!r.abortOnError)throw s}!t&&(typeof r.maxIterations!="number"||e<r.maxIterations)&&setTimeout(i,r.timeout)}};return i(!0)}function Oe(r,e,t="auto"){switch(typeof e!="number"&&("length"in e?e=e.length:"size"in e?e=e.size:"count"in e&&(e=e.count)),["-s","-ies"].includes(t)||(t="auto"),isNaN(e)&&(e=2),t==="auto"?String(r).endsWith("y")?"-ies":"-s":t){case"-s":return`${r}${e===1?"":"s"}`;case"-ies":return`${String(r).slice(0,-1)}${e===1?"y":"ies"}`}}function Ne(r){return r.charAt(0).toUpperCase()+r.slice(1)}var G={100:"\u2588",75:"\u2593",50:"\u2592",25:"\u2591",0:"\u2500"};function Ve(r,e,t=G){if(r===100)return t[100].repeat(e);let i=Math.floor(r/100*e),n=r/10*e-i,o="";n>=.75?o=t[75]:n>=.5?o=t[50]:n>=.25&&(o=t[25]);let a=t[100].repeat(i),s=t[0].repeat(e-i-(o?1:0));return`${a}${o}${s}`}function Fe(r,...e){return r.replace(/%\d/gm,t=>{var n;let i=Number(t.substring(1))-1;return(n=e[i]??t)==null?void 0:n.toString()})}function ke(r,e=", ",t=" and "){let i=[...r];if(i.length===0)return"";if(i.length===1)return String(i[0]);if(i.length===2)return i.join(t);let n=t+i[i.length-1];return i.pop(),i.join(e)+n}function Ae(r){let e=r<0,t=Math.abs(r);if(isNaN(t)||!isFinite(t))throw new TypeError("The seconds argument must be a valid number");let i=Math.floor(t/3600),n=Math.floor(t%3600/60),o=Math.floor(t%60);return(e?"-":"")+[i?i+":":"",String(n).padStart(n>0||i>0?2:1,"0"),":",String(o).padStart(o>0||n>0||i>0||r===0?2:1,"0")].join("")}function Me(r,e,t="..."){let i=(r==null?void 0:r.toString())??String(r),n=i.length>e?i.substring(0,e-t.length)+t:i;return n.length>e?n.substring(0,e):n}var Z=()=>({emit(r,...e){for(let t=this.events[r]||[],i=0,n=t.length;i<n;i++)t[i](...e)},events:{},on(r,e){return(this.events[r]||=[]).push(e),()=>{var t;this.events[r]=(t=this.events[r])==null?void 0:t.filter(i=>e!==i)}}});var T=class{events=Z();eventUnsubscribes=[];emitterOptions;constructor(e={}){this.emitterOptions={publicEmit:!1,...e}}on(e,t){let i,n=()=>{i&&(i(),this.eventUnsubscribes=this.eventUnsubscribes.filter(o=>o!==i))};return i=this.events.on(e,t),this.eventUnsubscribes.push(i),n}once(e,t){return new Promise(i=>{let n,o=((...a)=>{t==null||t(...a),n==null||n(),i(a)});n=this.events.on(e,o),this.eventUnsubscribes.push(n)})}onMulti(e){let t=[],i=()=>{for(let n of t)n();t.splice(0,t.length),this.eventUnsubscribes=this.eventUnsubscribes.filter(n=>!t.includes(n))};for(let n of Array.isArray(e)?e:[e]){let o={allOf:[],oneOf:[],once:!1,...n},{oneOf:a,allOf:s,once:u,signal:c,callback:l}=o;if(c!=null&&c.aborted)return i;if(a.length===0&&s.length===0)throw new TypeError("NanoEmitter.onMulti(): Either `oneOf` or `allOf` or both must be provided in the options");let d=[],m=(g=!1)=>{if(!(!(c!=null&&c.aborted)&&!g)){for(let y of d)y();d.splice(0,d.length),this.eventUnsubscribes=this.eventUnsubscribes.filter(y=>!d.includes(y))}},f=new Set,O=()=>s.length===0||f.size===s.length;for(let g of a){let y=this.events.on(g,((...k)=>{m(),O()&&(l(g,...k),u&&m(!0))}));d.push(y)}for(let g of s){let y=this.events.on(g,((...k)=>{m(),f.add(g),O()&&(a.length===0||a.includes(g))&&(l(g,...k),u&&m(!0))}));d.push(y)}t.push(()=>m(!0))}return i}emit(e,...t){return this.emitterOptions.publicEmit?(this.events.emit(e,...t),!0):!1}unsubscribeAll(){for(let e of this.eventUnsubscribes)e();this.eventUnsubscribes=[]}};var X=1,U=class extends T{id;formatVersion;defaultData;encodeData;decodeData;compressionFormat="deflate-raw";memoryCache;engine;keyPrefix;options;firstInit=!0;cachedData;migrations;migrateIds=[];constructor(e){if(super(e.nanoEmitterOptions),this.id=e.id,this.formatVersion=e.formatVersion,this.defaultData=e.defaultData,this.memoryCache=e.memoryCache??!0,this.cachedData=this.memoryCache?e.defaultData:{},this.migrations=e.migrations,e.migrateIds&&(this.migrateIds=Array.isArray(e.migrateIds)?e.migrateIds:[e.migrateIds]),this.engine=typeof e.engine=="function"?e.engine():e.engine,this.keyPrefix=e.keyPrefix??"__ds-",this.options=e,"encodeData"in e&&"decodeData"in e&&Array.isArray(e.encodeData)&&Array.isArray(e.decodeData))this.encodeData=[e.encodeData[0],e.encodeData[1]],this.decodeData=[e.decodeData[0],e.decodeData[1]],this.compressionFormat=e.encodeData[0]??null;else if(e.compressionFormat===null)this.encodeData=void 0,this.decodeData=void 0,this.compressionFormat=null;else{let t=typeof e.compressionFormat=="string"?e.compressionFormat:"deflate-raw";this.compressionFormat=t,this.encodeData=[t,async i=>await $(i,t,"string")],this.decodeData=[t,async i=>await C(i,t,"string")]}this.engine.setDataStoreOptions({id:this.id,encodeData:this.encodeData,decodeData:this.decodeData})}async loadData(){try{if(this.firstInit){this.firstInit=!1;let u=Number(await this.engine.getValue("__ds_fmt_ver",0)),c=await this.engine.getValue(`_uucfg-${this.id}`,null);if(c){let l=Number(await this.engine.getValue(`_uucfgver-${this.id}`,NaN)),d=await this.engine.getValue(`_uucfgenc-${this.id}`,null),m=[],f=(O,g,y)=>{m.push(this.engine.setValue(g,y)),m.push(this.engine.deleteValue(O))};f(`_uucfg-${this.id}`,`${this.keyPrefix}${this.id}-dat`,c),isNaN(l)||f(`_uucfgver-${this.id}`,`${this.keyPrefix}${this.id}-ver`,l),typeof d=="boolean"||d==="true"||d==="false"||typeof d=="number"||d==="0"||d==="1"?f(`_uucfgenc-${this.id}`,`${this.keyPrefix}${this.id}-enf`,[0,"0",!0,"true"].includes(d)?this.compressionFormat??null:null):(m.push(this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat)),m.push(this.engine.deleteValue(`_uucfgenc-${this.id}`))),await Promise.allSettled(m)}(isNaN(u)||u<X)&&await this.engine.setValue("__ds_fmt_ver",X)}this.migrateIds.length>0&&(await this.migrateId(this.migrateIds),this.migrateIds=[]);let e=await this.engine.getValue(`${this.keyPrefix}${this.id}-dat`,null),t=Number(await this.engine.getValue(`${this.keyPrefix}${this.id}-ver`,NaN));if(typeof e!="string"&&typeof e!="object"||e===null||isNaN(t)){await this.saveDefaultData(!1);let u=this.engine.deepCopy(this.defaultData);return this.events.emit("loadData",u),u}let i=e??JSON.stringify(this.defaultData),n=String(await this.engine.getValue(`${this.keyPrefix}${this.id}-enf`,null)),o=n!=="null"&&n!=="false"&&n!=="0"&&n!==""&&n!==null,a=typeof i=="string"?await this.engine.deserializeData(i,o):i;t<this.formatVersion&&this.migrations&&(a=await this.runMigrations(a,t));let s=this.memoryCache?this.cachedData=this.engine.deepCopy(a):this.engine.deepCopy(a);return this.events.emit("loadData",s),s}catch(e){let t=e instanceof Error?e:new Error(String(e));return console.warn("Error while parsing JSON data, resetting it to the default value.",e),this.events.emit("error",t),await this.saveDefaultData(),this.defaultData}}getData(){if(!this.memoryCache)throw new p("In-memory cache is disabled for this DataStore instance, so getData() can't be used. Please use loadData() instead.");return this.engine.deepCopy(this.cachedData)}setData(e){let t=this.engine.deepCopy(e);return this.memoryCache&&(this.cachedData=e,this.events.emit("updateDataSync",t)),new Promise(async i=>{let n=await Promise.allSettled([this.engine.setValue(`${this.keyPrefix}${this.id}-dat`,await this.engine.serializeData(e,this.encodingEnabled())),this.engine.setValue(`${this.keyPrefix}${this.id}-ver`,this.formatVersion),this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat)]);if(n.every(o=>o.status==="fulfilled"))this.events.emit("updateData",t);else{let o=new Error("Error while saving data to persistent storage: "+n.map(a=>a.status==="rejected"?a.reason:null).filter(Boolean).join("; "));console.error(o),this.events.emit("error",o)}i()})}async saveDefaultData(e=!0){this.memoryCache&&(this.cachedData=this.defaultData);let t=await Promise.allSettled([this.engine.setValue(`${this.keyPrefix}${this.id}-dat`,await this.engine.serializeData(this.defaultData,this.encodingEnabled())),this.engine.setValue(`${this.keyPrefix}${this.id}-ver`,this.formatVersion),this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat)]);if(t.every(i=>i.status==="fulfilled"))e&&this.events.emit("setDefaultData",this.defaultData);else{let i=new Error("Error while saving default data to persistent storage: "+t.map(n=>n.status==="rejected"?n.reason:null).filter(Boolean).join("; "));console.error(i),this.events.emit("error",i)}}async deleteData(){var e,t;await Promise.allSettled([this.engine.deleteValue(`${this.keyPrefix}${this.id}-dat`),this.engine.deleteValue(`${this.keyPrefix}${this.id}-ver`),this.engine.deleteValue(`${this.keyPrefix}${this.id}-enf`)]),await((t=(e=this.engine).deleteStorage)==null?void 0:t.call(e)),this.events.emit("deleteData")}encodingEnabled(){return!!(this.encodeData&&this.decodeData)&&this.compressionFormat!==null||!!this.compressionFormat}async runMigrations(e,t,i=!0){if(!this.migrations)return e;let n=e,o=Object.entries(this.migrations).sort(([u],[c])=>Number(u)-Number(c)),a=t;for(let u=0;u<o.length;u++){let[c,l]=o[u],d=Number(c);if(t<this.formatVersion&&t<d)try{let m=l(n);n=m instanceof Promise?await m:m,a=t=d;let f=d>=this.formatVersion||u===o.length-1;this.events.emit("migrateData",d,n,f)}catch(m){let f=new x(`Error while running migration function for format version '${c}'`,{cause:m});if(this.events.emit("migrationError",d,f),this.events.emit("error",f),!i)throw f;return await this.saveDefaultData(),this.engine.deepCopy(this.defaultData)}}await Promise.allSettled([this.engine.setValue(`${this.keyPrefix}${this.id}-dat`,await this.engine.serializeData(n,this.encodingEnabled())),this.engine.setValue(`${this.keyPrefix}${this.id}-ver`,a),this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat)]);let s=this.memoryCache?this.cachedData=this.engine.deepCopy(n):this.engine.deepCopy(n);return this.events.emit("updateData",s),s}async migrateId(e){let t=Array.isArray(e)?e:[e];await Promise.all(t.map(async i=>{let[n,o,a]=await(async()=>{let[u,c,l]=await Promise.all([this.engine.getValue(`${this.keyPrefix}${i}-dat`,JSON.stringify(this.defaultData)),this.engine.getValue(`${this.keyPrefix}${i}-ver`,NaN),this.engine.getValue(`${this.keyPrefix}${i}-enf`,null)]);return[u,Number(c),!!l&&String(l)!=="null"]})();if(n===void 0||isNaN(o))return;let s=await this.engine.deserializeData(n,a);await Promise.allSettled([this.engine.setValue(`${this.keyPrefix}${this.id}-dat`,await this.engine.serializeData(s,this.encodingEnabled())),this.engine.setValue(`${this.keyPrefix}${this.id}-ver`,o),this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat),this.engine.deleteValue(`${this.keyPrefix}${i}-dat`),this.engine.deleteValue(`${this.keyPrefix}${i}-ver`),this.engine.deleteValue(`${this.keyPrefix}${i}-enf`)]),this.events.emit("migrateId",i,this.id)}))}};var P=class{dataStoreOptions;constructor(e){e&&(this.dataStoreOptions=e)}setDataStoreOptions(e){this.dataStoreOptions=e}async serializeData(e,t){var o,a,s,u,c;this.ensureDataStoreOptions();let i=JSON.stringify(e);if(!t||!((o=this.dataStoreOptions)!=null&&o.encodeData)||!((a=this.dataStoreOptions)!=null&&a.decodeData))return i;let n=(c=(u=(s=this.dataStoreOptions)==null?void 0:s.encodeData)==null?void 0:u[1])==null?void 0:c.call(u,i);return n instanceof Promise?await n:n}async deserializeData(e,t){var n,o,a;this.ensureDataStoreOptions();let i=(n=this.dataStoreOptions)!=null&&n.decodeData&&t?(a=(o=this.dataStoreOptions.decodeData)==null?void 0:o[1])==null?void 0:a.call(o,e):void 0;return i instanceof Promise&&(i=await i),JSON.parse(i??e)}ensureDataStoreOptions(){if(!this.dataStoreOptions)throw new p("DataStoreEngine must be initialized with DataStore options before use. If you are using this instance standalone, set them in the constructor or call `setDataStoreOptions()` with the DataStore options.");if(!this.dataStoreOptions.id)throw new p("DataStoreEngine must be initialized with a valid DataStore ID")}deepCopy(e){try{if("structuredClone"in globalThis)return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))}},j=class extends P{options;constructor(e){super(e==null?void 0:e.dataStoreOptions),this.options={type:"localStorage",...e}}async getValue(e,t){let i=this.options.type==="localStorage"?globalThis.localStorage.getItem(e):globalThis.sessionStorage.getItem(e);return typeof i>"u"?t:i}async setValue(e,t){this.options.type==="localStorage"?globalThis.localStorage.setItem(e,String(t)):globalThis.sessionStorage.setItem(e,String(t))}async deleteValue(e){this.options.type==="localStorage"?globalThis.localStorage.removeItem(e):globalThis.sessionStorage.removeItem(e)}},h,B=class extends P{options;fileAccessQueue=Promise.resolve();constructor(e){super(e==null?void 0:e.dataStoreOptions),this.options={filePath:t=>`.ds-${t}`,...e}}async readFile(){var e,t,i,n;this.ensureDataStoreOptions();try{if(h||(h=(e=await import("fs/promises"))==null?void 0:e.default),!h)throw new b("FileStorageEngine requires Node.js or Deno with Node compatibility (v1.31+)",{cause:new p("'node:fs/promises' module not available")});let o=typeof this.options.filePath=="string"?this.options.filePath:this.options.filePath(this.dataStoreOptions.id,this.dataStoreOptions),a=await h.readFile(o,"utf-8");return a?JSON.parse(await((n=(i=(t=this.dataStoreOptions)==null?void 0:t.decodeData)==null?void 0:i[1])==null?void 0:n.call(i,a))??a):void 0}catch{return}}async writeFile(e){var t,i,n,o;this.ensureDataStoreOptions();try{if(h||(h=(t=await import("fs/promises"))==null?void 0:t.default),!h)throw new b("FileStorageEngine requires Node.js or Deno with Node compatibility (v1.31+)",{cause:new p("'node:fs/promises' module not available")});let a=typeof this.options.filePath=="string"?this.options.filePath:this.options.filePath(this.dataStoreOptions.id,this.dataStoreOptions);await h.mkdir(a.slice(0,a.lastIndexOf(a.includes("/")?"/":"\\")),{recursive:!0}),await h.writeFile(a,await((o=(n=(i=this.dataStoreOptions)==null?void 0:i.encodeData)==null?void 0:n[1])==null?void 0:o.call(n,JSON.stringify(e)))??JSON.stringify(e,void 0,2),"utf-8")}catch(a){console.error("Error writing file:",a)}}async getValue(e,t){let i=await this.readFile();if(!i)return t;let n=i==null?void 0:i[e];if(typeof n>"u")return t;if(typeof t=="string")return typeof n=="object"&&n!==null?JSON.stringify(n):typeof n=="string"?n:String(n);if(typeof n=="string")try{return JSON.parse(n)}catch{return t}return n}async setValue(e,t){this.fileAccessQueue=this.fileAccessQueue.then(async()=>{let i=await this.readFile();i||(i={});let n=t;if(typeof t=="string")try{if(t.startsWith("{")||t.startsWith("[")){let o=JSON.parse(t);typeof o=="object"&&o!==null&&(n=o)}}catch{}i[e]=n,await this.writeFile(i)}).catch(i=>{throw console.error("Error in setValue:",i),i}),await this.fileAccessQueue.catch(()=>{})}async deleteValue(e){this.fileAccessQueue=this.fileAccessQueue.then(async()=>{let t=await this.readFile();t&&(delete t[e],await this.writeFile(t))}).catch(t=>{throw console.error("Error in deleteValue:",t),t}),await this.fileAccessQueue.catch(()=>{})}async deleteStorage(){var e;this.ensureDataStoreOptions();try{if(h||(h=(e=await import("fs/promises"))==null?void 0:e.default),!h)throw new b("FileStorageEngine requires Node.js or Deno with Node compatibility (v1.31+)",{cause:new p("'node:fs/promises' module not available")});let t=typeof this.options.filePath=="string"?this.options.filePath:this.options.filePath(this.dataStoreOptions.id,this.dataStoreOptions);return await h.unlink(t)}catch(t){console.error("Error deleting file:",t)}}};var L=class r{stores;options;constructor(e,t={}){if(!crypto||!crypto.subtle)throw new b("DataStoreSerializer has to run in a secure context (HTTPS) or in another environment that implements the subtleCrypto API!");this.stores=e,this.options={addChecksum:!0,ensureIntegrity:!0,remapIds:{},...t}}async calcChecksum(e){return z(e,"SHA-256")}async serializePartial(e,t=!0,i=!0){var a;let n=[],o=this.stores.filter(s=>typeof e=="function"?e(s.id):e.includes(s.id));for(let s of o){let u=!!(t&&s.encodingEnabled()&&((a=s.encodeData)!=null&&a[1])),c=s.memoryCache?s.getData():await s.loadData(),l=u?await s.encodeData[1](JSON.stringify(c)):JSON.stringify(c);n.push({id:s.id,data:l,formatVersion:s.formatVersion,encoded:u,checksum:this.options.addChecksum?await this.calcChecksum(l):void 0})}return i?JSON.stringify(n):n}async serialize(e=!0,t=!0){return this.serializePartial(this.stores.map(i=>i.id),e,t)}async deserializePartial(e,t){let i=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(i)||!i.every(r.isSerializedDataStoreObj))throw new TypeError("Invalid serialized data format! Expected an array of SerializedDataStore objects.");let n=a=>{var s;return((s=Object.entries(this.options.remapIds).find(([,u])=>u.includes(a)))==null?void 0:s[0])??a},o=a=>typeof e=="function"?e(a):e.includes(a);for(let a of i){let s=n(a.id);if(!o(s))continue;let u=this.stores.find(l=>l.id===s);if(!u)throw new p(`Can't deserialize data because no DataStore instance with the ID "${s}" was found! Make sure to provide it in the DataStoreSerializer constructor.`);if(this.options.ensureIntegrity&&typeof a.checksum=="string"){let l=await this.calcChecksum(a.data);if(l!==a.checksum)throw new w(`Checksum mismatch for DataStore with ID "${a.id}"!
21
+ `)}}function Ie(r){var n;let e=0,t=!1;(n=r.signal)==null||n.addEventListener("abort",()=>{t=!0},{once:!0});let i=async(o=!1)=>{var a;if(!t){try{if(((r.immediate??!0)||!o)&&(e++,await((a=r.condition)==null?void 0:a.call(r,e-1))??!0)){let s=await r.task(e-1);r.onSuccess&&await r.onSuccess(s,e-1)}}catch(s){if(r.onError&&await r.onError(s,e-1),r.abortOnError&&(t=!0),!r.onError&&!r.abortOnError)throw s}!t&&(typeof r.maxIterations!="number"||e<r.maxIterations)&&setTimeout(i,r.timeout)}};return i(!0)}function Re(r,e,t="auto"){switch(typeof e!="number"&&("length"in e?e=e.length:"size"in e?e=e.size:"count"in e&&(e=e.count)),["-s","-ies"].includes(t)||(t="auto"),isNaN(e)&&(e=2),t==="auto"?String(r).endsWith("y")?"-ies":"-s":t){case"-s":return`${r}${e===1?"":"s"}`;case"-ies":return`${String(r).slice(0,-1)}${e===1?"y":"ies"}`}}function ze(r){return r.charAt(0).toUpperCase()+r.slice(1)}var ie={100:"\u2588",75:"\u2593",50:"\u2592",25:"\u2591",0:"\u2500"};function Ue(r,e,t=ie){if(r===100)return t[100].repeat(e);let i=Math.floor(r/100*e),n=r/10*e-i,o="";n>=.75?o=t[75]:n>=.5?o=t[50]:n>=.25&&(o=t[25]);let a=t[100].repeat(i),s=t[0].repeat(e-i-(o?1:0));return`${a}${o}${s}`}function Le(r,...e){return r.replace(/%\d/gm,t=>{var n;let i=Number(t.substring(1))-1;return(n=e[i]??t)==null?void 0:n.toString()})}function je(r,e=", ",t=" and "){let i=[...r];if(i.length===0)return"";if(i.length===1)return String(i[0]);if(i.length===2)return i.join(t);let n=t+i[i.length-1];return i.pop(),i.join(e)+n}function Be(r){let e=r<0,t=Math.abs(r);if(isNaN(t)||!isFinite(t))throw new TypeError("The seconds argument must be a valid number");let i=Math.floor(t/3600),n=Math.floor(t%3600/60),o=Math.floor(t%60);return(e?"-":"")+[i?i+":":"",String(n).padStart(n>0||i>0?2:1,"0"),":",String(o).padStart(o>0||n>0||i>0||r===0?2:1,"0")].join("")}function Ke(r,e,t="..."){let i=(r==null?void 0:r.toString())??String(r),n=i.length>e?i.substring(0,e-t.length)+t:i;return n.length>e?n.substring(0,e):n}var ne={single:{horizontal:"\u2500",vertical:"\u2502",topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"},double:{horizontal:"\u2550",vertical:"\u2551",topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",leftT:"\u2560",rightT:"\u2563",topT:"\u2566",bottomT:"\u2569",cross:"\u256C"},none:{horizontal:" ",vertical:" ",topLeft:" ",topRight:" ",bottomLeft:" ",bottomRight:" ",leftT:" ",rightT:" ",topT:" ",bottomT:" ",cross:" "}};function qe(r,e){var h;let t={columnAlign:"left",truncateAbove:1/0,truncEndStr:"\u2026",minPadding:1,lineStyle:"single",applyCellStyle:()=>{},applyLineStyle:()=>{},lineCharset:ne,...e??{}},i=(l,f,d)=>P(typeof l!="number"||isNaN(Number(l))?f:l,f,d);t.truncateAbove=i(t.truncateAbove,0,1/0),t.minPadding=i(t.minPadding,0,1/0);let n=t.lineCharset[t.lineStyle],o=l=>l.replace(/\u001b\[[0-9;]*m/g,""),a=r.map(l=>l.map(f=>String(f))),s=((h=r[0])==null?void 0:h.length)??0;if(s===0||a.length===0)return"";if(isFinite(t.truncateAbove)){let l=(f,d,g)=>{let y=d-g.length;if(y<=0)return g.slice(0,d);let T=0,D="",v=0,w=!1;for(;v<f.length;){if(f[v]==="\x1B"&&f[v+1]==="["){let A=f.indexOf("m",v+2);if(A!==-1){D+=f.slice(v,A+1),w=!0,v=A+1;continue}}if(T===y)return D+=g,w&&(D+="\x1B[0m"),D;D+=f[v],T++,v++}return D};for(let f of a)for(let d=0;d<f.length;d++)o(f[d]??"").length>t.truncateAbove&&(f[d]=l(f[d]??"",t.truncateAbove,t.truncEndStr))}let u=Array.from({length:s},(l,f)=>Math.max(0,...a.map(d=>o(d[f]??"").length))),c=(l,f,d)=>{let[g="",y=""]=t.applyLineStyle(l,f)??[];return`${g}${d}${y}`},m=(l,f,d,g)=>{let y="",T=0;y+=c(l,T++,f);for(let D=0;D<s;D++){let v=(u[D]??0)+t.minPadding*2;for(let w=0;w<v;w++)y+=c(l,T++,n.horizontal);D<s-1&&(y+=c(l,T++,d))}return y+=c(l,T++,g),y},p=[];for(let l=0;l<a.length;l++){let f=a[l]??[],d=l*3;t.lineStyle!=="none"&&p.push(l===0?m(d,n.topLeft,n.topT,n.topRight):m(d,n.leftT,n.cross,n.rightT));let g="",y=0;g+=c(d+1,y++,n.vertical);for(let T=0;T<s;T++){let D=f[T]??"",v=o(D).length,w=(u[T]??0)-v,A=(Array.isArray(t.columnAlign)?t.columnAlign[T]:t.columnAlign)??"left",N,V;switch(A){case"right":N=t.minPadding+w,V=t.minPadding;break;case"centerLeft":N=t.minPadding+Math.floor(w/2),V=t.minPadding+Math.ceil(w/2);break;case"centerRight":N=t.minPadding+Math.ceil(w/2),V=t.minPadding+Math.floor(w/2);break;default:N=t.minPadding,V=t.minPadding+w}let[se="",ue=""]=t.applyCellStyle(l,T)??[];g+=" ".repeat(N)+se+D+ue+" ".repeat(V),g+=c(d+1,y++,n.vertical)}p.push(g),t.lineStyle!=="none"&&l===a.length-1&&p.push(m(d+2,n.bottomLeft,n.bottomT,n.bottomRight))}return p.join(`
22
+ `)}var ae=()=>({emit(r,...e){for(let t=this.events[r]||[],i=0,n=t.length;i<n;i++)t[i](...e)},events:{},on(r,e){return(this.events[r]||=[]).push(e),()=>{var t;this.events[r]=(t=this.events[r])==null?void 0:t.filter(i=>e!==i)}}});var E=class{events=ae();eventUnsubscribes=[];emitterOptions;constructor(e={}){this.emitterOptions={publicEmit:!1,...e}}on(e,t){let i,n=()=>{i&&(i(),this.eventUnsubscribes=this.eventUnsubscribes.filter(o=>o!==i))};return i=this.events.on(e,t),this.eventUnsubscribes.push(i),n}once(e,t){return new Promise(i=>{let n,o=((...a)=>{t==null||t(...a),n==null||n(),i(a)});n=this.events.on(e,o),this.eventUnsubscribes.push(n)})}onMulti(e){let t=[],i=()=>{for(let n of t)n();t.splice(0,t.length),this.eventUnsubscribes=this.eventUnsubscribes.filter(n=>!t.includes(n))};for(let n of Array.isArray(e)?e:[e]){let o={allOf:[],oneOf:[],once:!1,...n},{oneOf:a,allOf:s,once:u,signal:c,callback:m}=o;if(c!=null&&c.aborted)return i;if(a.length===0&&s.length===0)throw new TypeError("NanoEmitter.onMulti(): Either `oneOf` or `allOf` or both must be provided in the options");let p=[],h=(d=!1)=>{if(!(!(c!=null&&c.aborted)&&!d)){for(let g of p)g();p.splice(0,p.length),this.eventUnsubscribes=this.eventUnsubscribes.filter(g=>!p.includes(g))}},l=new Set,f=()=>s.length===0||l.size===s.length;for(let d of a){let g=this.events.on(d,((...y)=>{h(),f()&&(m(d,...y),u&&h(!0))}));p.push(g)}for(let d of s){let g=this.events.on(d,((...y)=>{h(),l.add(d),f()&&(a.length===0||a.includes(d))&&(m(d,...y),u&&h(!0))}));p.push(g)}t.push(()=>h(!0))}return i}emit(e,...t){return this.emitterOptions.publicEmit?(this.events.emit(e,...t),!0):!1}unsubscribeAll(){for(let e of this.eventUnsubscribes)e();this.eventUnsubscribes=[]}};var oe=1,_=class extends E{id;formatVersion;defaultData;encodeData;decodeData;compressionFormat="deflate-raw";memoryCache;engine;keyPrefix;options;firstInit=!0;cachedData;migrations;migrateIds=[];constructor(e){if(super(e.nanoEmitterOptions),this.id=e.id,this.formatVersion=e.formatVersion,this.defaultData=e.defaultData,this.memoryCache=e.memoryCache??!0,this.cachedData=this.memoryCache?e.defaultData:{},this.migrations=e.migrations,e.migrateIds&&(this.migrateIds=Array.isArray(e.migrateIds)?e.migrateIds:[e.migrateIds]),this.engine=typeof e.engine=="function"?e.engine():e.engine,this.keyPrefix=e.keyPrefix??"__ds-",this.options=e,"encodeData"in e&&"decodeData"in e&&Array.isArray(e.encodeData)&&Array.isArray(e.decodeData))this.encodeData=[e.encodeData[0],e.encodeData[1]],this.decodeData=[e.decodeData[0],e.decodeData[1]],this.compressionFormat=e.encodeData[0]??null;else if(e.compressionFormat===null)this.encodeData=void 0,this.decodeData=void 0,this.compressionFormat=null;else{let t=typeof e.compressionFormat=="string"?e.compressionFormat:"deflate-raw";this.compressionFormat=t,this.encodeData=[t,async i=>await B(i,t,"string")],this.decodeData=[t,async i=>await K(i,t,"string")]}this.engine.setDataStoreOptions({id:this.id,encodeData:this.encodeData,decodeData:this.decodeData})}async loadData(){try{if(this.firstInit){this.firstInit=!1;let u=Number(await this.engine.getValue("__ds_fmt_ver",0)),c=await this.engine.getValue(`_uucfg-${this.id}`,null);if(c){let m=Number(await this.engine.getValue(`_uucfgver-${this.id}`,NaN)),p=await this.engine.getValue(`_uucfgenc-${this.id}`,null),h=[],l=(f,d,g)=>{h.push(this.engine.setValue(d,g)),h.push(this.engine.deleteValue(f))};l(`_uucfg-${this.id}`,`${this.keyPrefix}${this.id}-dat`,c),isNaN(m)||l(`_uucfgver-${this.id}`,`${this.keyPrefix}${this.id}-ver`,m),typeof p=="boolean"||p==="true"||p==="false"||typeof p=="number"||p==="0"||p==="1"?l(`_uucfgenc-${this.id}`,`${this.keyPrefix}${this.id}-enf`,[0,"0",!0,"true"].includes(p)?this.compressionFormat??null:null):(h.push(this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat)),h.push(this.engine.deleteValue(`_uucfgenc-${this.id}`))),await Promise.allSettled(h)}(isNaN(u)||u<oe)&&await this.engine.setValue("__ds_fmt_ver",oe)}this.migrateIds.length>0&&(await this.migrateId(this.migrateIds),this.migrateIds=[]);let e=await this.engine.getValue(`${this.keyPrefix}${this.id}-dat`,null),t=Number(await this.engine.getValue(`${this.keyPrefix}${this.id}-ver`,NaN));if(typeof e!="string"&&typeof e!="object"||e===null||isNaN(t)){await this.saveDefaultData(!1);let u=this.engine.deepCopy(this.defaultData);return this.events.emit("loadData",u),u}let i=e??JSON.stringify(this.defaultData),n=String(await this.engine.getValue(`${this.keyPrefix}${this.id}-enf`,null)),o=n!=="null"&&n!=="false"&&n!=="0"&&n!==""&&n!==null,a=typeof i=="string"?await this.engine.deserializeData(i,o):i;t<this.formatVersion&&this.migrations&&(a=await this.runMigrations(a,t));let s=this.memoryCache?this.cachedData=this.engine.deepCopy(a):this.engine.deepCopy(a);return this.events.emit("loadData",s),s}catch(e){let t=e instanceof Error?e:new Error(String(e));return console.warn("Error while parsing JSON data, resetting it to the default value.",e),this.events.emit("error",t),await this.saveDefaultData(),this.defaultData}}getData(){if(!this.memoryCache)throw new b("In-memory cache is disabled for this DataStore instance, so getData() can't be used. Please use loadData() instead.");return this.engine.deepCopy(this.cachedData)}setData(e){let t=this.engine.deepCopy(e);return this.memoryCache&&(this.cachedData=e,this.events.emit("updateDataSync",t)),new Promise(async i=>{let n=await Promise.allSettled([this.engine.setValue(`${this.keyPrefix}${this.id}-dat`,await this.engine.serializeData(e,this.encodingEnabled())),this.engine.setValue(`${this.keyPrefix}${this.id}-ver`,this.formatVersion),this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat)]);if(n.every(o=>o.status==="fulfilled"))this.events.emit("updateData",t);else{let o=new Error("Error while saving data to persistent storage: "+n.map(a=>a.status==="rejected"?a.reason:null).filter(Boolean).join("; "));console.error(o),this.events.emit("error",o)}i()})}async saveDefaultData(e=!0){this.memoryCache&&(this.cachedData=this.defaultData);let t=await Promise.allSettled([this.engine.setValue(`${this.keyPrefix}${this.id}-dat`,await this.engine.serializeData(this.defaultData,this.encodingEnabled())),this.engine.setValue(`${this.keyPrefix}${this.id}-ver`,this.formatVersion),this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat)]);if(t.every(i=>i.status==="fulfilled"))e&&this.events.emit("setDefaultData",this.defaultData);else{let i=new Error("Error while saving default data to persistent storage: "+t.map(n=>n.status==="rejected"?n.reason:null).filter(Boolean).join("; "));console.error(i),this.events.emit("error",i)}}async deleteData(){var e,t;await Promise.allSettled([this.engine.deleteValue(`${this.keyPrefix}${this.id}-dat`),this.engine.deleteValue(`${this.keyPrefix}${this.id}-ver`),this.engine.deleteValue(`${this.keyPrefix}${this.id}-enf`)]),await((t=(e=this.engine).deleteStorage)==null?void 0:t.call(e)),this.events.emit("deleteData")}encodingEnabled(){return!!(this.encodeData&&this.decodeData)&&this.compressionFormat!==null||!!this.compressionFormat}async runMigrations(e,t,i=!0){if(!this.migrations)return e;let n=e,o=Object.entries(this.migrations).sort(([u],[c])=>Number(u)-Number(c)),a=t;for(let u=0;u<o.length;u++){let[c,m]=o[u],p=Number(c);if(t<this.formatVersion&&t<p)try{let h=m(n);n=h instanceof Promise?await h:h,a=t=p;let l=p>=this.formatVersion||u===o.length-1;this.events.emit("migrateData",p,n,l)}catch(h){let l=new M(`Error while running migration function for format version '${c}'`,{cause:h});if(this.events.emit("migrationError",p,l),this.events.emit("error",l),!i)throw l;return await this.saveDefaultData(),this.engine.deepCopy(this.defaultData)}}await Promise.allSettled([this.engine.setValue(`${this.keyPrefix}${this.id}-dat`,await this.engine.serializeData(n,this.encodingEnabled())),this.engine.setValue(`${this.keyPrefix}${this.id}-ver`,a),this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat)]);let s=this.memoryCache?this.cachedData=this.engine.deepCopy(n):this.engine.deepCopy(n);return this.events.emit("updateData",s),s}async migrateId(e){let t=Array.isArray(e)?e:[e];await Promise.all(t.map(async i=>{let[n,o,a]=await(async()=>{let[u,c,m]=await Promise.all([this.engine.getValue(`${this.keyPrefix}${i}-dat`,JSON.stringify(this.defaultData)),this.engine.getValue(`${this.keyPrefix}${i}-ver`,NaN),this.engine.getValue(`${this.keyPrefix}${i}-enf`,null)]);return[u,Number(c),!!m&&String(m)!=="null"]})();if(n===void 0||isNaN(o))return;let s=await this.engine.deserializeData(n,a);await Promise.allSettled([this.engine.setValue(`${this.keyPrefix}${this.id}-dat`,await this.engine.serializeData(s,this.encodingEnabled())),this.engine.setValue(`${this.keyPrefix}${this.id}-ver`,o),this.engine.setValue(`${this.keyPrefix}${this.id}-enf`,this.compressionFormat),this.engine.deleteValue(`${this.keyPrefix}${i}-dat`),this.engine.deleteValue(`${this.keyPrefix}${i}-ver`),this.engine.deleteValue(`${this.keyPrefix}${i}-enf`)]),this.events.emit("migrateId",i,this.id)}))}};var $=class{dataStoreOptions;constructor(e){e&&(this.dataStoreOptions=e)}setDataStoreOptions(e){this.dataStoreOptions=e}async serializeData(e,t){var o,a,s,u,c;this.ensureDataStoreOptions();let i=JSON.stringify(e);if(!t||!((o=this.dataStoreOptions)!=null&&o.encodeData)||!((a=this.dataStoreOptions)!=null&&a.decodeData))return i;let n=(c=(u=(s=this.dataStoreOptions)==null?void 0:s.encodeData)==null?void 0:u[1])==null?void 0:c.call(u,i);return n instanceof Promise?await n:n}async deserializeData(e,t){var n,o,a;this.ensureDataStoreOptions();let i=(n=this.dataStoreOptions)!=null&&n.decodeData&&t?(a=(o=this.dataStoreOptions.decodeData)==null?void 0:o[1])==null?void 0:a.call(o,e):void 0;return i instanceof Promise&&(i=await i),JSON.parse(i??e)}ensureDataStoreOptions(){if(!this.dataStoreOptions)throw new b("DataStoreEngine must be initialized with DataStore options before use. If you are using this instance standalone, set them in the constructor or call `setDataStoreOptions()` with the DataStore options.");if(!this.dataStoreOptions.id)throw new b("DataStoreEngine must be initialized with a valid DataStore ID")}deepCopy(e){try{if("structuredClone"in globalThis)return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))}},W=class extends ${options;constructor(e){super(e==null?void 0:e.dataStoreOptions),this.options={type:"localStorage",...e}}async getValue(e,t){let i=this.options.type==="localStorage"?globalThis.localStorage.getItem(e):globalThis.sessionStorage.getItem(e);return typeof i>"u"?t:i}async setValue(e,t){this.options.type==="localStorage"?globalThis.localStorage.setItem(e,String(t)):globalThis.sessionStorage.setItem(e,String(t))}async deleteValue(e){this.options.type==="localStorage"?globalThis.localStorage.removeItem(e):globalThis.sessionStorage.removeItem(e)}},S,H=class extends ${options;fileAccessQueue=Promise.resolve();constructor(e){super(e==null?void 0:e.dataStoreOptions),this.options={filePath:t=>`.ds-${t}`,...e}}async readFile(){var e,t,i,n;this.ensureDataStoreOptions();try{if(S||(S=(e=await import("fs/promises"))==null?void 0:e.default),!S)throw new x("FileStorageEngine requires Node.js or Deno with Node compatibility (v1.31+)",{cause:new b("'node:fs/promises' module not available")});let o=typeof this.options.filePath=="string"?this.options.filePath:this.options.filePath(this.dataStoreOptions.id,this.dataStoreOptions),a=await S.readFile(o,"utf-8");return a?JSON.parse(await((n=(i=(t=this.dataStoreOptions)==null?void 0:t.decodeData)==null?void 0:i[1])==null?void 0:n.call(i,a))??a):void 0}catch{return}}async writeFile(e){var t,i,n,o;this.ensureDataStoreOptions();try{if(S||(S=(t=await import("fs/promises"))==null?void 0:t.default),!S)throw new x("FileStorageEngine requires Node.js or Deno with Node compatibility (v1.31+)",{cause:new b("'node:fs/promises' module not available")});let a=typeof this.options.filePath=="string"?this.options.filePath:this.options.filePath(this.dataStoreOptions.id,this.dataStoreOptions);await S.mkdir(a.slice(0,a.lastIndexOf(a.includes("/")?"/":"\\")),{recursive:!0}),await S.writeFile(a,await((o=(n=(i=this.dataStoreOptions)==null?void 0:i.encodeData)==null?void 0:n[1])==null?void 0:o.call(n,JSON.stringify(e)))??JSON.stringify(e,void 0,2),"utf-8")}catch(a){console.error("Error writing file:",a)}}async getValue(e,t){let i=await this.readFile();if(!i)return t;let n=i==null?void 0:i[e];if(typeof n>"u")return t;if(typeof t=="string")return typeof n=="object"&&n!==null?JSON.stringify(n):typeof n=="string"?n:String(n);if(typeof n=="string")try{return JSON.parse(n)}catch{return t}return n}async setValue(e,t){this.fileAccessQueue=this.fileAccessQueue.then(async()=>{let i=await this.readFile();i||(i={});let n=t;if(typeof t=="string")try{if(t.startsWith("{")||t.startsWith("[")){let o=JSON.parse(t);typeof o=="object"&&o!==null&&(n=o)}}catch{}i[e]=n,await this.writeFile(i)}).catch(i=>{throw console.error("Error in setValue:",i),i}),await this.fileAccessQueue.catch(()=>{})}async deleteValue(e){this.fileAccessQueue=this.fileAccessQueue.then(async()=>{let t=await this.readFile();t&&(delete t[e],await this.writeFile(t))}).catch(t=>{throw console.error("Error in deleteValue:",t),t}),await this.fileAccessQueue.catch(()=>{})}async deleteStorage(){var e;this.ensureDataStoreOptions();try{if(S||(S=(e=await import("fs/promises"))==null?void 0:e.default),!S)throw new x("FileStorageEngine requires Node.js or Deno with Node compatibility (v1.31+)",{cause:new b("'node:fs/promises' module not available")});let t=typeof this.options.filePath=="string"?this.options.filePath:this.options.filePath(this.dataStoreOptions.id,this.dataStoreOptions);return await S.unlink(t)}catch(t){console.error("Error deleting file:",t)}}};var Q=class r{stores;options;constructor(e,t={}){if(!crypto||!crypto.subtle)throw new x("DataStoreSerializer has to run in a secure context (HTTPS) or in another environment that implements the subtleCrypto API!");this.stores=e,this.options={addChecksum:!0,ensureIntegrity:!0,remapIds:{},...t}}async calcChecksum(e){return q(e,"SHA-256")}async serializePartial(e,t=!0,i=!0){var a;let n=[],o=this.stores.filter(s=>typeof e=="function"?e(s.id):e.includes(s.id));for(let s of o){let u=!!(t&&s.encodingEnabled()&&((a=s.encodeData)!=null&&a[1])),c=s.memoryCache?s.getData():await s.loadData(),m=u?await s.encodeData[1](JSON.stringify(c)):JSON.stringify(c);n.push({id:s.id,data:m,formatVersion:s.formatVersion,encoded:u,checksum:this.options.addChecksum?await this.calcChecksum(m):void 0})}return i?JSON.stringify(n):n}async serialize(e=!0,t=!0){return this.serializePartial(this.stores.map(i=>i.id),e,t)}async deserializePartial(e,t){let i=typeof t=="string"?JSON.parse(t):t;if(!Array.isArray(i)||!i.every(r.isSerializedDataStoreObj))throw new TypeError("Invalid serialized data format! Expected an array of SerializedDataStore objects.");let n=a=>{var s;return((s=Object.entries(this.options.remapIds).find(([,u])=>u.includes(a)))==null?void 0:s[0])??a},o=a=>typeof e=="function"?e(a):e.includes(a);for(let a of i){let s=n(a.id);if(!o(s))continue;let u=this.stores.find(m=>m.id===s);if(!u)throw new b(`Can't deserialize data because no DataStore instance with the ID "${s}" was found! Make sure to provide it in the DataStoreSerializer constructor.`);if(this.options.ensureIntegrity&&typeof a.checksum=="string"){let m=await this.calcChecksum(a.data);if(m!==a.checksum)throw new F(`Checksum mismatch for DataStore with ID "${a.id}"!
22
23
  Expected: ${a.checksum}
23
- Has: ${l}`)}let c=a.encoded&&u.encodingEnabled()?await u.decodeData[1](a.data):a.data;a.formatVersion&&!isNaN(Number(a.formatVersion))&&Number(a.formatVersion)<u.formatVersion?await u.runMigrations(JSON.parse(c),Number(a.formatVersion),!1):await u.setData(JSON.parse(c))}}async deserialize(e){return this.deserializePartial(this.stores.map(t=>t.id),e)}async loadStoresData(e){return Promise.allSettled(this.getStoresFiltered(e).map(async t=>({id:t.id,data:await t.loadData()})))}async resetStoresData(e){return Promise.allSettled(this.getStoresFiltered(e).map(t=>t.saveDefaultData()))}async deleteStoresData(e){return Promise.allSettled(this.getStoresFiltered(e).map(t=>t.deleteData()))}static isSerializedDataStoreObjArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="object"&&t!==null&&"id"in t&&"data"in t&&"formatVersion"in t&&"encoded"in t)}static isSerializedDataStoreObj(e){return typeof e=="object"&&e!==null&&"id"in e&&"data"in e&&"formatVersion"in e&&"encoded"in e}getStoresFiltered(e){return this.stores.filter(t=>typeof e>"u"?!0:Array.isArray(e)?e.includes(t.id):e(t.id))}};var F=class extends T{constructor(t=200,i="immediate",n){super(n);this.timeout=t;this.type=i}listeners=[];activeTimeout;queuedCall;addListener(t){this.listeners.push(t)}removeListener(t){let i=this.listeners.findIndex(n=>n===t);i!==-1&&this.listeners.splice(i,1)}removeAllListeners(){this.listeners=[]}getListeners(){return this.listeners}setTimeout(t){this.events.emit("change",this.timeout=t,this.type)}getTimeout(){return this.timeout}isTimeoutActive(){return typeof this.activeTimeout<"u"}setType(t){this.events.emit("change",this.timeout,this.type=t)}getType(){return this.type}call(...t){let i=(...o)=>{this.queuedCall=void 0,this.events.emit("call",...o),this.listeners.forEach(a=>a.call(this,...o))},n=()=>{this.activeTimeout=setTimeout(()=>{this.queuedCall?(this.queuedCall(),n()):this.activeTimeout=void 0},this.timeout)};switch(this.type){case"immediate":typeof this.activeTimeout>"u"?(i(...t),n()):this.queuedCall=()=>i(...t);break;case"idle":this.activeTimeout&&clearTimeout(this.activeTimeout),this.activeTimeout=setTimeout(()=>{i(...t),this.activeTimeout=void 0},this.timeout);break;default:throw new TypeError(`Invalid debouncer type: ${this.type}`)}}};function Ie(r,e=200,t="immediate",i){let n=new F(e,t,i);n.addListener(r);let o=((...a)=>n.call(...a));return o.debouncer=n,o}
24
+ Has: ${m}`)}let c=a.encoded&&u.encodingEnabled()?await u.decodeData[1](a.data):a.data;a.formatVersion&&!isNaN(Number(a.formatVersion))&&Number(a.formatVersion)<u.formatVersion?await u.runMigrations(JSON.parse(c),Number(a.formatVersion),!1):await u.setData(JSON.parse(c))}}async deserialize(e){return this.deserializePartial(this.stores.map(t=>t.id),e)}async loadStoresData(e){return Promise.allSettled(this.getStoresFiltered(e).map(async t=>({id:t.id,data:await t.loadData()})))}async resetStoresData(e){return Promise.allSettled(this.getStoresFiltered(e).map(t=>t.saveDefaultData()))}async deleteStoresData(e){return Promise.allSettled(this.getStoresFiltered(e).map(t=>t.deleteData()))}static isSerializedDataStoreObjArray(e){return Array.isArray(e)&&e.every(t=>typeof t=="object"&&t!==null&&"id"in t&&"data"in t&&"formatVersion"in t&&"encoded"in t)}static isSerializedDataStoreObj(e){return typeof e=="object"&&e!==null&&"id"in e&&"data"in e&&"formatVersion"in e&&"encoded"in e}getStoresFiltered(e){return this.stores.filter(t=>typeof e>"u"?!0:Array.isArray(e)?e.includes(t.id):e(t.id))}};var z=class extends E{constructor(t=200,i="immediate",n){super(n);this.timeout=t;this.type=i}listeners=[];activeTimeout;queuedCall;addListener(t){this.listeners.push(t)}removeListener(t){let i=this.listeners.findIndex(n=>n===t);i!==-1&&this.listeners.splice(i,1)}removeAllListeners(){this.listeners=[]}getListeners(){return this.listeners}setTimeout(t){this.events.emit("change",this.timeout=t,this.type)}getTimeout(){return this.timeout}isTimeoutActive(){return typeof this.activeTimeout<"u"}setType(t){this.events.emit("change",this.timeout,this.type=t)}getType(){return this.type}call(...t){let i=(...o)=>{this.queuedCall=void 0,this.events.emit("call",...o),this.listeners.forEach(a=>a.call(this,...o))},n=()=>{this.activeTimeout=setTimeout(()=>{this.queuedCall?(this.queuedCall(),n()):this.activeTimeout=void 0},this.timeout)};switch(this.type){case"immediate":typeof this.activeTimeout>"u"?(i(...t),n()):this.queuedCall=()=>i(...t);break;case"idle":this.activeTimeout&&clearTimeout(this.activeTimeout),this.activeTimeout=setTimeout(()=>{i(...t),this.activeTimeout=void 0},this.timeout);break;default:throw new TypeError(`Invalid debouncer type: ${this.type}`)}}};function Je(r,e=200,t="immediate",i){let n=new z(e,t,i);n.addListener(r);let o=((...a)=>n.call(...a));return o.debouncer=n,o}
24
25
 
25
26
 
26
27
 
@@ -495,6 +495,173 @@ function truncStr(input, length, endStr = "...") {
495
495
  const finalStr = str.length > length ? str.substring(0, length - endStr.length) + endStr : str;
496
496
  return finalStr.length > length ? finalStr.substring(0, length) : finalStr;
497
497
  }
498
+ var defaultTableLineCharset = {
499
+ single: {
500
+ horizontal: "\u2500",
501
+ vertical: "\u2502",
502
+ topLeft: "\u250C",
503
+ topRight: "\u2510",
504
+ bottomLeft: "\u2514",
505
+ bottomRight: "\u2518",
506
+ leftT: "\u251C",
507
+ rightT: "\u2524",
508
+ topT: "\u252C",
509
+ bottomT: "\u2534",
510
+ cross: "\u253C"
511
+ },
512
+ double: {
513
+ horizontal: "\u2550",
514
+ vertical: "\u2551",
515
+ topLeft: "\u2554",
516
+ topRight: "\u2557",
517
+ bottomLeft: "\u255A",
518
+ bottomRight: "\u255D",
519
+ leftT: "\u2560",
520
+ rightT: "\u2563",
521
+ topT: "\u2566",
522
+ bottomT: "\u2569",
523
+ cross: "\u256C"
524
+ },
525
+ none: {
526
+ horizontal: " ",
527
+ vertical: " ",
528
+ topLeft: " ",
529
+ topRight: " ",
530
+ bottomLeft: " ",
531
+ bottomRight: " ",
532
+ leftT: " ",
533
+ rightT: " ",
534
+ topT: " ",
535
+ bottomT: " ",
536
+ cross: " "
537
+ }
538
+ };
539
+ function createTable(rows, options) {
540
+ var _a;
541
+ const opts = {
542
+ columnAlign: "left",
543
+ truncateAbove: Infinity,
544
+ truncEndStr: "\u2026",
545
+ minPadding: 1,
546
+ lineStyle: "single",
547
+ applyCellStyle: () => void 0,
548
+ applyLineStyle: () => void 0,
549
+ lineCharset: defaultTableLineCharset,
550
+ ...options ?? {}
551
+ };
552
+ const defRange = (val, min, max) => clamp(typeof val !== "number" || isNaN(Number(val)) ? min : val, min, max);
553
+ opts.truncateAbove = defRange(opts.truncateAbove, 0, Infinity);
554
+ opts.minPadding = defRange(opts.minPadding, 0, Infinity);
555
+ const lnCh = opts.lineCharset[opts.lineStyle];
556
+ const stripAnsi = (str) => str.replace(/\u001b\[[0-9;]*m/g, "");
557
+ const stringRows = rows.map((row) => row.map((cell) => String(cell)));
558
+ const colCount = ((_a = rows[0]) == null ? void 0 : _a.length) ?? 0;
559
+ if (colCount === 0 || stringRows.length === 0)
560
+ return "";
561
+ if (isFinite(opts.truncateAbove)) {
562
+ const truncAnsi = (str, maxVisible, endStr) => {
563
+ const limit = maxVisible - endStr.length;
564
+ if (limit <= 0)
565
+ return endStr.slice(0, maxVisible);
566
+ let visible = 0;
567
+ let result = "";
568
+ let i = 0;
569
+ let hasAnsi = false;
570
+ while (i < str.length) {
571
+ if (str[i] === "\x1B" && str[i + 1] === "[") {
572
+ const seqEnd = str.indexOf("m", i + 2);
573
+ if (seqEnd !== -1) {
574
+ result += str.slice(i, seqEnd + 1);
575
+ hasAnsi = true;
576
+ i = seqEnd + 1;
577
+ continue;
578
+ }
579
+ }
580
+ if (visible === limit) {
581
+ result += endStr;
582
+ if (hasAnsi)
583
+ result += "\x1B[0m";
584
+ return result;
585
+ }
586
+ result += str[i];
587
+ visible++;
588
+ i++;
589
+ }
590
+ return result;
591
+ };
592
+ for (const row of stringRows)
593
+ for (let j = 0; j < row.length; j++)
594
+ if (stripAnsi(row[j] ?? "").length > opts.truncateAbove)
595
+ row[j] = truncAnsi(row[j] ?? "", opts.truncateAbove, opts.truncEndStr);
596
+ }
597
+ const colWidths = Array.from(
598
+ { length: colCount },
599
+ (_, j) => Math.max(0, ...stringRows.map((row) => stripAnsi(row[j] ?? "").length))
600
+ );
601
+ const applyLn = (i, j, ch) => {
602
+ const [before = "", after = ""] = opts.applyLineStyle(i, j) ?? [];
603
+ return `${before}${ch}${after}`;
604
+ };
605
+ const buildBorderRow = (lineIdx, leftCh, midCh, rightCh) => {
606
+ let result = "";
607
+ let j = 0;
608
+ result += applyLn(lineIdx, j++, leftCh);
609
+ for (let col = 0; col < colCount; col++) {
610
+ const cellWidth = (colWidths[col] ?? 0) + opts.minPadding * 2;
611
+ for (let ci = 0; ci < cellWidth; ci++)
612
+ result += applyLn(lineIdx, j++, lnCh.horizontal);
613
+ if (col < colCount - 1)
614
+ result += applyLn(lineIdx, j++, midCh);
615
+ }
616
+ result += applyLn(lineIdx, j++, rightCh);
617
+ return result;
618
+ };
619
+ const lines = [];
620
+ for (let rowIdx = 0; rowIdx < stringRows.length; rowIdx++) {
621
+ const row = stringRows[rowIdx] ?? [];
622
+ const lineIdxBase = rowIdx * 3;
623
+ if (opts.lineStyle !== "none") {
624
+ lines.push(
625
+ rowIdx === 0 ? buildBorderRow(lineIdxBase, lnCh.topLeft, lnCh.topT, lnCh.topRight) : buildBorderRow(lineIdxBase, lnCh.leftT, lnCh.cross, lnCh.rightT)
626
+ );
627
+ }
628
+ let contentLine = "";
629
+ let j = 0;
630
+ contentLine += applyLn(lineIdxBase + 1, j++, lnCh.vertical);
631
+ for (let colIdx = 0; colIdx < colCount; colIdx++) {
632
+ const cell = row[colIdx] ?? "";
633
+ const visLen = stripAnsi(cell).length;
634
+ const extra = (colWidths[colIdx] ?? 0) - visLen;
635
+ const align = (Array.isArray(opts.columnAlign) ? opts.columnAlign[colIdx] : opts.columnAlign) ?? "left";
636
+ let leftPad;
637
+ let rightPad;
638
+ switch (align) {
639
+ case "right":
640
+ leftPad = opts.minPadding + extra;
641
+ rightPad = opts.minPadding;
642
+ break;
643
+ case "centerLeft":
644
+ leftPad = opts.minPadding + Math.floor(extra / 2);
645
+ rightPad = opts.minPadding + Math.ceil(extra / 2);
646
+ break;
647
+ case "centerRight":
648
+ leftPad = opts.minPadding + Math.ceil(extra / 2);
649
+ rightPad = opts.minPadding + Math.floor(extra / 2);
650
+ break;
651
+ default:
652
+ leftPad = opts.minPadding;
653
+ rightPad = opts.minPadding + extra;
654
+ }
655
+ const [cellBefore = "", cellAfter = ""] = opts.applyCellStyle(rowIdx, colIdx) ?? [];
656
+ contentLine += " ".repeat(leftPad) + cellBefore + cell + cellAfter + " ".repeat(rightPad);
657
+ contentLine += applyLn(lineIdxBase + 1, j++, lnCh.vertical);
658
+ }
659
+ lines.push(contentLine);
660
+ if (opts.lineStyle !== "none" && rowIdx === stringRows.length - 1)
661
+ lines.push(buildBorderRow(lineIdxBase + 2, lnCh.bottomLeft, lnCh.bottomT, lnCh.bottomRight));
662
+ }
663
+ return lines.join("\n");
664
+ }
498
665
 
499
666
  // node_modules/.pnpm/nanoevents@9.1.0/node_modules/nanoevents/index.js
500
667
  var createNanoEvents = () => ({
@@ -1205,6 +1372,7 @@ var FileStorageEngine = class extends DataStoreEngine {
1205
1372
  // lib/DataStoreSerializer.ts
1206
1373
  var DataStoreSerializer = class _DataStoreSerializer {
1207
1374
  stores;
1375
+ // eslint-disable-line @typescript-eslint/no-explicit-any
1208
1376
  options;
1209
1377
  constructor(stores, options = {}) {
1210
1378
  if (!crypto || !crypto.subtle)
@@ -1474,10 +1642,12 @@ export {
1474
1642
  consumeStringGen,
1475
1643
  createProgressBar,
1476
1644
  createRecurringTask,
1645
+ createTable,
1477
1646
  darkenColor,
1478
1647
  debounce,
1479
1648
  decompress,
1480
1649
  defaultPbChars,
1650
+ defaultTableLineCharset,
1481
1651
  digitCount,
1482
1652
  fetchAdvanced,
1483
1653
  formatNumber,