@absoluteui/helpers 0.13.1 → 0.13.3
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 +1 -1
- package/SECURITY.md +2 -2
- package/dist/array/compare.js +1 -1
- package/dist/array/index.js +1 -1
- package/dist/array/tree.js +1 -1
- package/dist/async/batch.js +1 -1
- package/dist/async/concurrency.js +1 -1
- package/dist/async/control.js +1 -1
- package/dist/async/index.js +1 -1
- package/dist/async/signal.js +1 -1
- package/dist/boolean/index.js +1 -1
- package/dist/business-calendar/days.js +1 -1
- package/dist/business-calendar/describe.js +1 -1
- package/dist/business-calendar/engine.js +1 -1
- package/dist/business-calendar/hours.js +1 -1
- package/dist/business-calendar/index.js +1 -1
- package/dist/business-calendar/internal.js +1 -1
- package/dist/business-calendar/rules.js +1 -1
- package/dist/color/index.js +1 -1
- package/dist/color/named.js +1 -1
- package/dist/compare/index.js +1 -1
- package/dist/convert/index.js +1 -1
- package/dist/csv/index.js +1 -1
- package/dist/csv/parse.js +1 -1
- package/dist/csv/stringify.js +1 -1
- package/dist/date/calendar.js +1 -1
- package/dist/date/format.js +1 -1
- package/dist/date/index.js +1 -1
- package/dist/date/intervals.js +1 -1
- package/dist/date/intl-cache.js +1 -1
- package/dist/date/locale.js +1 -1
- package/dist/date/plain-date.js +1 -1
- package/dist/date/plain-time.js +1 -1
- package/dist/date/zone.js +1 -1
- package/dist/decimal/index.js +1 -1
- package/dist/ds/avl.js +1 -1
- package/dist/ds/bitset.js +1 -1
- package/dist/ds/bloom.js +1 -1
- package/dist/ds/caches.js +1 -1
- package/dist/ds/disjoint-set.js +1 -1
- package/dist/ds/emitter.js +1 -1
- package/dist/ds/graph.js +1 -1
- package/dist/ds/heap.js +1 -1
- package/dist/ds/index.js +1 -1
- package/dist/ds/internal.js +1 -1
- package/dist/ds/interval-tree.js +1 -1
- package/dist/ds/linked-list.js +1 -1
- package/dist/ds/maps.js +1 -1
- package/dist/ds/ring.js +1 -1
- package/dist/ds/sorted.js +1 -1
- package/dist/ds/stack.js +1 -1
- package/dist/ds/trie.js +1 -1
- package/dist/duration/index.js +1 -1
- package/dist/encoding/index.js +1 -1
- package/dist/error/index.js +1 -1
- package/dist/fn/index.js +1 -1
- package/dist/fn/memo.js +1 -1
- package/dist/fn/timing.js +1 -1
- package/dist/http/headers.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/http/problem.js +1 -1
- package/dist/http/response.js +1 -1
- package/dist/http/status.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/keys.js +1 -1
- package/dist/is/index.js +1 -1
- package/dist/json/index.js +1 -1
- package/dist/json/internal.js +1 -1
- package/dist/json/ndjson.js +1 -1
- package/dist/json/parse.js +1 -1
- package/dist/json/patch.js +1 -1
- package/dist/json/pointer.js +1 -1
- package/dist/json/stringify.js +1 -1
- package/dist/linq/enumerable.js +1 -1
- package/dist/linq/index.js +1 -1
- package/dist/linq/operators.js +1 -1
- package/dist/number/core.js +1 -1
- package/dist/number/format.js +1 -1
- package/dist/number/index.js +1 -1
- package/dist/number/internal.js +1 -1
- package/dist/number/parse.js +1 -1
- package/dist/number/words.js +1 -1
- package/dist/object/basic.js +1 -1
- package/dist/object/deep.js +1 -1
- package/dist/object/diff.js +1 -1
- package/dist/object/index.js +1 -1
- package/dist/object/internal.js +1 -1
- package/dist/object/path.js +1 -1
- package/dist/random/core.js +1 -1
- package/dist/random/index.js +1 -1
- package/dist/random/seeded.js +1 -1
- package/dist/sanitize/index.js +1 -1
- package/dist/sanitize/pii.js +1 -1
- package/dist/sanitize/records.js +1 -1
- package/dist/sanitize/text.js +1 -1
- package/dist/set/index.js +1 -1
- package/dist/stats/index.js +1 -1
- package/dist/string/index.js +1 -1
- package/dist/string/internal.js +1 -1
- package/dist/string/words.js +1 -1
- package/dist/timezone/index.js +1 -1
- package/dist/url/index.js +1 -1
- package/dist/validate/builders.js +1 -1
- package/dist/validate/formats.js +1 -1
- package/dist/validate/index.js +1 -1
- package/dist/validate/schema.js +1 -1
- package/dist/zip/index.js +1 -1
- package/dist/zip/internal.js +1 -1
- package/dist/zip/reader.js +1 -1
- package/dist/zip/writer.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,4 +45,4 @@ Full documentation: [aui.kasadara.com/docs/api/helpers/](https://aui.kasadara.co
|
|
|
45
45
|
|
|
46
46
|
## License
|
|
47
47
|
|
|
48
|
-
Licensed under the [Apache License 2.0](https://aui.kasadara.com/license/). Copyright (c) 2026 Kasadara Technology Solutions Pvt Ltd; see the LICENSE and NOTICE files in this package. AbsoluteUI is open source, Kasadara's contribution to the open-source community; the source is at https://github.com/
|
|
48
|
+
Licensed under the [Apache License 2.0](https://aui.kasadara.com/license/). Copyright (c) 2026 Kasadara Technology Solutions Pvt Ltd; see the LICENSE and NOTICE files in this package. AbsoluteUI is open source, Kasadara's contribution to the open-source community; the source is at https://github.com/kasadara-labs/AbsoluteUI. Report vulnerabilities as described in the [Security Policy](https://aui.kasadara.com/security/).
|
package/SECURITY.md
CHANGED
|
@@ -27,7 +27,7 @@ The current release line is `0.13`. Until `1.0`, security fixes ship as patch re
|
|
|
27
27
|
|
|
28
28
|
Report privately through either channel:
|
|
29
29
|
|
|
30
|
-
- **GitHub (preferred):** open a private vulnerability report at https://github.com/
|
|
30
|
+
- **GitHub (preferred):** open a private vulnerability report at https://github.com/kasadara-labs/AbsoluteUI/security/advisories/new (the **Report a vulnerability** button on the repository's **Security** tab). Only you and the AbsoluteUI maintainers can see it, and we can work on the fix and the advisory with you there.
|
|
31
31
|
- **Email:** security@kasadara.com
|
|
32
32
|
|
|
33
33
|
The email contact is also published in `/.well-known/security.txt` on each AbsoluteUI website.
|
|
@@ -64,7 +64,7 @@ Targets are objectives, not guarantees. See Section 7 (Disclaimer of Warranty) o
|
|
|
64
64
|
|
|
65
65
|
## Security Advisories
|
|
66
66
|
|
|
67
|
-
Advisories are published as GitHub security advisories at https://github.com/
|
|
67
|
+
Advisories are published as GitHub security advisories at https://github.com/kasadara-labs/AbsoluteUI/security/advisories and at https://aui.kasadara.com/advisory/. They include:
|
|
68
68
|
|
|
69
69
|
- affected packages and versions;
|
|
70
70
|
- fixed versions;
|
package/dist/array/compare.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
function s(n){if(n==null)return 0;switch(typeof n){case"boolean":return 1;case"number":return Number.isNaN(n)?0:2;case"bigint":return 2;case"string":return 3;default:return n instanceof Date?Number.isNaN(n.getTime())?0:4:5}}function o(n){return s(n)===0}function c(n,e,a){const r=s(n),i=s(e);if(r!==i)return r-i;switch(r){case 0:case 5:return 0;case 3:return a?a.compare(n,e):n===e?0:n<e?-1:1;case 4:return n.getTime()-e.getTime();default:{const t=n,u=e;return t===u?0:t<u?-1:t>u?1:0}}}export{c as compareNatural,o as isEmptyKey};
|
package/dist/array/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{LimitError as K,ValidationError as N}from"../error/index.js";import{compareNatural as d,isEmptyKey as g}from"./compare.js";import{buildTree as Re,flattenTree as Ke}from"./tree.js";const A=1e7,c=(e,n)=>new N(e,n);function m(e,n,t){if(!Number.isSafeInteger(e)||e<1)throw c(n,t)}function I(e){if(e>A)throw new K("HLP_ARRAY_TOO_LARGE","The requested array length exceeds the limit.",{details:{limit:A}})}function w(e,n){if(!Number.isInteger(n))return;const t=n<0?e+n:n;return t>=0&&t<e?t:void 0}function p(e,n){const t=w(e,n);if(t===void 0)throw c("HLP_ARRAY_INDEX_OUT_OF_RANGE","The index is out of range.");return t}function E(e,n){m(n,"HLP_ARRAY_INVALID_SIZE","Chunk size must be a positive integer.");const t=[];for(let r=0;r<e.length;r+=n)t.push(e.slice(r,r+n));return t}function C(e,n){const t=[],r=[];return e.forEach((o,u)=>(n(o,u)?t:r).push(o)),[t,r]}function S(e,n){const t=Object.groupBy;if(typeof t=="function")return t(e,n);const r=Object.create(null);let o=0;for(const u of e){const a=n(u,o++),i=r[a];i?i.push(u):r[a]=[u]}return r}function D(e,n){const t=Map.groupBy;if(typeof t=="function")return t(e,n);const r=new Map;let o=0;for(const u of e){const a=n(u,o++),i=r.get(a);i?i.push(u):r.set(a,[u])}return r}function O(e,n){const t=Object.create(null);let r=0;for(const o of e)t[n(o,r++)]=o;return t}function M(e,n){const t=Object.create(null);let r=0;for(const o of e){const u=n(o,r++);t[u]=(t[u]??0)+1}return t}function H(...e){if(e.length===0)return[];const n=Math.min(...e.map(r=>r.length)),t=[];for(let r=0;r<n;r++)t.push(e.map(o=>o[r]));return t}function V(e,n,t){const r=Math.min(e.length,n.length),o=[];for(let u=0;u<r;u++)o.push(t(e[u],n[u],u));return o}function Y(e){const n=e.reduce((r,o)=>Math.max(r,o.length),0),t=Array.from({length:n},()=>[]);for(const r of e)for(let o=0;o<n;o++)t[o]?.push(r[o]);return t}function j(e,n){const t=n??1;if(!(t===1/0||Number.isInteger(t)&&t>=0))throw c("HLP_ARRAY_INVALID_DEPTH","Depth must be a non-negative integer.");return e.flat(t)}function G(e){return e.flat(1/0)}function F(e){return e.filter(n=>n!=null&&n!==!1)}function q(e){return[...new Set(e)]}function U(e,n){const t=new Set,r=[];for(const o of e){const u=n(o);t.has(u)||(t.add(u),r.push(o))}return r}const x=new Map;function P(e){const n=typeof e=="string"?e:e.join(",");let t=x.get(n);return t||(x.size>=32&&x.clear(),t=new Intl.Collator(typeof e=="string"?e:[...e]),x.set(n,t)),t}function W(e,n,t={}){const r=Array.isArray(n)?n:[n],o=t.collator??(t.locale===void 0?void 0:P(t.locale)),u=r.map(i=>{const l=typeof i=="function"?{by:i}:i,s=l.order==="desc"?-1:1,T=(l.nulls??t.nulls??"last")==="first",f=l.collator??o,y=l.compare,b=e.map(h=>l.by(h));return{dir:s,nullsFirst:T,collator:f,cmp:y,values:b}}),a=e.map((i,l)=>l);return a.sort((i,l)=>{for(const s of u){const T=s.values[i],f=s.values[l],y=g(T),b=g(f);if(y||b){if(y&&b)continue;return y===s.nullsFirst?-1:1}const h=s.cmp?s.cmp(T,f):d(T,f,s.collator);if(h!==0)return h*s.dir}return i-l}),a.map(i=>e[i])}function Z(e,n,t=d){let r=0,o=e.length-1;for(;r<=o;){const u=r+o>>>1,a=t(e[u],n);if(a===0)return u;a<0?r=u+1:o=u-1}return~r}function X(e,n,t=d){let r=0,o=e.length;for(;r<o;){const u=r+o>>>1;t(e[u],n)<0?r=u+1:o=u}return r}function z(e,n,t=d){let r=0,o=e.length;for(;r<o;){const u=r+o>>>1;t(e[u],n)<=0?r=u+1:o=u}return r}function _(e,n,t){if(!Number.isSafeInteger(n)||n<0)throw c("HLP_ARRAY_INVALID_COUNT","Count must be a non-negative integer.");if(n===0)return[];const r=(i,l)=>{const s=t(e[i],e[l]);return s<0||s===0&&i<l},o=[],u=i=>o[i]??0,a=i=>{for(;;){const l=2*i+1,s=l+1;let T=i;if(l<o.length&&r(u(T),u(l))&&(T=l),s<o.length&&r(u(T),u(s))&&(T=s),T===i)return;const f=u(T);o[T]=u(i),o[i]=f,i=T}};for(let i=0;i<e.length;i++)if(o.length<n){let l=o.push(i)-1;for(;l>0;){const s=l-1>>1;if(!r(u(s),u(l)))break;const T=u(s);o[s]=u(l),o[l]=T,l=s}}else r(i,u(0))&&(o[0]=i,a(0));return o.sort((i,l)=>r(i,l)?-1:1).map(i=>e[i])}function J(e,n,t=d){return _(e,n,(r,o)=>t(o,r))}function Q(e,n,t=d){return _(e,n,t)}function $(e,n,t){const r=p(e.length,n),o=p(e.length,t),u=e.slice(),[a]=u.splice(r,1);return u.splice(o,0,a),u}function ee(e,n,...t){const r=n===e.length?n:p(e.length,n);return[...e.slice(0,r),...t,...e.slice(r)]}function ne(e,n,t=1){const r=p(e.length,n);if(!Number.isSafeInteger(t)||t<0)throw c("HLP_ARRAY_INVALID_COUNT","Count must be a non-negative integer.");return e.toSpliced(r,t)}function te(e,n,t){return e.with(p(e.length,n),t)}function re(e,n,t){const r=p(e.length,n),o=p(e.length,t),u=e.slice();return[u[r],u[o]]=[e[o],e[r]],u}function oe(e,n,t=Object.is){const r=e.filter(o=>!t(o,n));return r.length===e.length?[...e,n]:r}function ue(e,n,t){const r=t(n),o=e.findIndex(u=>Object.is(t(u),r));return o<0?[...e,n]:e.with(o,n)}function ie(e,n){const t=e.length;if(!Number.isInteger(n))throw c("HLP_ARRAY_INVALID_COUNT","Rotation must be an integer.");if(t===0)return[];const r=(-n%t+t)%t;return[...e.slice(r),...e.slice(0,r)]}function le(e,n){return[e.slice(0,n),e.slice(n)]}function ae(e,n){const t=[];return e.forEach((r,o)=>{o>0&&t.push(n),t.push(r)}),t}function se(e,n){const t=e.findIndex((r,o)=>!n(r,o));return t<0?e.slice():e.slice(0,t)}function Te(e,n){const t=e.findIndex((r,o)=>!n(r,o));return t<0?[]:e.slice(t)}function ce(e,n,t){const[r,o]=n===void 0?[0,e]:[e,n],u=t??(o>=r?1:-1);if(!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(u)||u===0)throw c("HLP_ARRAY_INVALID_RANGE","Range bounds and step must be finite and the step non-zero.");const a=Math.max(0,Math.ceil((o-r)/u));return I(a),Array.from({length:a},(i,l)=>r+l*u)}function B(e,n){if(!Number.isSafeInteger(e)||e<0)throw c("HLP_ARRAY_INVALID_COUNT","Count must be a non-negative integer.");return I(e),Array.from({length:e},(t,r)=>n(r))}function fe(e,n){return B(n,()=>e)}function de(e,n,t=1){m(n,"HLP_ARRAY_INVALID_SIZE","Window size must be a positive integer."),m(t,"HLP_ARRAY_INVALID_SIZE","Window step must be a positive integer.");const r=[];for(let o=0;o+n<=e.length;o+=t)r.push(e.slice(o,o+n));return r}function pe(e){const n=[];for(let t=1;t<e.length;t++)n.push([e[t-1],e[t]]);return n}function ye(e,n,t){m(n,"HLP_ARRAY_INVALID_PAGE","Page must be a positive integer."),m(t,"HLP_ARRAY_INVALID_PAGE","Page size must be a positive integer.");const r=e.length,o=Math.ceil(r/t),u=(n-1)*t;return{items:e.slice(u,u+t),total:r,page:n,pageSize:t,pageCount:o,hasNext:n<o,hasPrev:n>1}}function me(e){return e[0]}function be(e){return e[e.length-1]}function he(e,n){const t=w(e.length,n);return t===void 0?void 0:e[t]}function k(e,n){let t=0,r=0;return e.forEach((o,u)=>{const a=n(o,u),i=t+a;r+=Math.abs(t)>=Math.abs(a)?t-i+a:a-i+t,t=i}),t+r}function xe(e,n){return e.length===0?void 0:k(e,n)/e.length}function R(e,n,t){let r,o,u=!1;for(const a of e){const i=n(a);g(i)||(!u||d(i,o)*t<0)&&(r=a,o=i,u=!0)}return r}function ge(e,n){return R(e,n,1)}function Ae(e,n){return R(e,n,-1)}function Ie(e,n,t=Object.is){if(e===n)return!0;if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],n[r]))return!1;return!0}export{A as MAX_GENERATED_LENGTH,Ie as arraysEqual,xe as averageBy,Z as binarySearch,Q as bottomN,Re as buildTree,E as chunk,F as compact,M as countBy,Te as dropWhile,me as first,j as flatten,G as flattenDeep,Ke as flattenTree,S as groupBy,D as groupByToMap,ee as insertAt,ae as intersperse,O as keyBy,be as last,X as lowerBound,Ae as maxBy,ge as minBy,$ as move,he as nth,ye as paginate,pe as pairwise,C as partition,ce as range,ne as removeAt,fe as repeat,te as replaceAt,ie as rotate,W as sortBy,le as splitAt,k as sumBy,re as swap,se as takeWhile,B as times,oe as toggleItem,J as topN,q as uniq,U as uniqBy,Y as unzip,z as upperBound,ue as upsertBy,de as windowed,H as zip,V as zipWith};
|
package/dist/array/tree.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as f}from"../error/index.js";function h(t){return typeof t=="function"?t:r=>r[t]}function w(t,r={}){const u=h(r.id??"id"),l=h(r.parentId??"parentId"),c=new Map,p=t.map(n=>{const o={item:n,children:[]},T=u(n);if(c.has(T))throw new f("HLP_ARRAY_DUPLICATE_ID","Tree items must have unique ids.");return c.set(T,o),o}),d=[],a=[],e=[];for(const n of p){const o=l(n.item);if(o==null){d.push(n),a.push(n);continue}const T=c.get(o);T?T.children.push(n):(e.push(n.item),a.push(n),r.orphans!=="omit"&&d.push(n))}const s=new Set,i=[...a];for(let n=i.pop();n;n=i.pop()){s.add(n);for(const o of n.children)i.push(o)}const y=p.filter(n=>!s.has(n)).map(n=>n.item);return{roots:d,orphans:e,cycles:y}}function N(t){const r=typeof t=="object"&&t!==null?t.children:void 0;return Array.isArray(r)?r:void 0}function k(t,r={}){const u=r.children??N,l=[],c=new Set,p=e=>{if(c.has(e.node))throw new f("HLP_ARRAY_TREE_CYCLE","The tree contains a cycle or a shared node.");return c.add(e.node),l.push(e),[...u(e.node)??[]]},d=[...t].map(e=>({node:e,depth:0,parent:void 0}));if(r.order==="breadth"){for(const e of d)for(const s of p(e))d.push({node:s,depth:e.depth+1,parent:e.node});return l}const a=d.reverse();for(let e=a.pop();e;e=a.pop()){const s=p(e);for(let i=s.length-1;i>=0;i--)a.push({node:s[i],depth:e.depth+1,parent:e.node})}return l}export{w as buildTree,k as flattenTree};
|
package/dist/async/batch.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{AbortError as P,HelperError as x,ValidationError as p,toError as y}from"../error/index.js";import{assertDelay as k,deferred as h,throwIfAborted as g}from"./signal.js";function D(l,s={}){const e=s.maxBatchSize??100;if(!Number.isSafeInteger(e)||e<1)throw new p("HLP_ASYNC_INVALID_BATCH_SIZE","maxBatchSize must be a positive integer.");const a=s.delay??0;k(a,"delay");const r=s.cacheKey??(c=>c);let n,i;const w=()=>{const c=n;if(n=void 0,i!==void 0&&clearTimeout(i),i=void 0,!c||c.size===0)return;const f=[...c.values()],u=o=>{for(const t of f)for(const d of t.waiters)d.reject(y(o))};Promise.resolve().then(()=>l(f.map(o=>o.key))).then(o=>{if(o.length!==f.length){u(new x("HLP_ASYNC_BATCH_LENGTH","The batch loader returned a different number of results than keys.",{details:{expected:f.length,actual:o.length}}));return}f.forEach((t,d)=>{const A=o[d];for(const m of t.waiters)A instanceof Error?m.reject(A):m.resolve(A)})},u)},b=c=>{n??=new Map;const f=r(c);let u=n.get(f);u||(u={key:c,waiters:[]},n.set(f,u));const o=h();if(u.waiters.push(o),n.size>=e)w();else if(i===void 0&&n.size===1&&u.waiters.length===1)if(a===0){const t=n;queueMicrotask(()=>{n===t&&w()})}else i=setTimeout(w,a);return o.promise};return{load:b,loadMany:c=>Promise.all(c.map(b)),flush:w}}function R(l,s=(...e)=>e[0]){const e=new Map;return(...a)=>{const r=s(...a),n=e.get(r);if(n)return n;const i=Promise.resolve().then(()=>l(...a)).finally(()=>{e.get(r)===i&&e.delete(r)});return e.set(r,i),i}}function C(l,s){k(s,"wait");let e,a,r=0,n=[],i=[];const w=new Set;let b;const c=(o,t)=>{for(const d of o)t.ok?d.resolve(t.value):d.reject(y(t.error))},f=()=>{e=void 0;const o=a,t=n;n=[];const d=r;o&&(w.add(t),Promise.resolve().then(()=>l(...o)).then(A=>({ok:!0,value:A}),A=>({ok:!1,error:A})).then(A=>{w.delete(t)&&(d===r?(b={gen:d,outcome:A},c([...t,...i],A),i=[]):b?.gen===r?c(t,b.outcome):i.push(...t))}))},u=(...o)=>{a=o,r++;const t=h();return n.push(t),e!==void 0&&clearTimeout(e),e=setTimeout(f,s),t.promise};return u.cancel=()=>{e!==void 0&&clearTimeout(e),e=void 0,r++;const o=new P,t=[...n,...i,...[...w].flat()];n=[],i=[],w.clear();for(const d of t)d.reject(o)},u}function E(l,...s){return async(...e)=>{let a=await l(...e);for(const r of s)a=await r(a);return a}}async function*v(l){for await(const s of l)yield s}async function I(l,s={}){const{limit:e=1/0,signal:a}=s;if(!(e>=0))throw new p("HLP_ASYNC_INVALID_LIMIT","limit must be a non-negative number.");const r=[];if(g(a),e===0)return r;for await(const n of l)if(g(a),r.push(n),r.length>=e)break;return r}export{E as asyncPipe,I as collectAsync,D as createBatcher,C as debounceAsync,R as singleFlight,v as toAsyncIterable};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{AbortError as k,HelperError as E,ValidationError as x,toError as I}from"../error/index.js";import{LinkedList as y}from"../ds/index.js";import{abortReason as L,throwIfAborted as h}from"./signal.js";function w(n){if(!(Number.isSafeInteger(n)&&n>=1)&&n!==1/0)throw new x("HLP_ASYNC_INVALID_LIMIT","Concurrency limit must be a positive integer.")}const O=()=>new AbortController().signal;function H(n,t,r,e={}){const l=e.stopOnError??!0;return A(n,t,r,e.signal,l).then(a=>{const o=[],u=[];for(const i of a)i.status==="fulfilled"?u.push(i.value):o.push(i.reason);if(o.length>0)throw new E("HLP_ASYNC_MAP_FAILED","One or more operations failed.",{cause:new AggregateError(o),details:{failed:o.length,total:a.length}});return u})}function M(n,t,r,e={}){return A(n,t,r,e.signal,!1)}function A(n,t,r,e,l){return new Promise((a,o)=>{if(w(t),e?.aborted){o(L(e));return}const u=new AbortController,i=[],p=n[Symbol.iterator]();let b=0,s=0,d=!1,f=!1;const v=()=>{f=!0,e?.removeEventListener("abort",P)},g=c=>{f||(v(),u.abort(c),d||p.return?.(),o(I(c)))},P=()=>{e&&g(L(e))};e?.addEventListener("abort",P,{once:!0});const S=()=>{for(;!f&&!d&&s<t;){let c;try{c=p.next()}catch(m){g(m);return}if(c.done){d=!0;break}const T=b++,R=c.value;s++,Promise.resolve().then(()=>r(R,T,u.signal)).then(m=>{i[T]={status:"fulfilled",value:m}},m=>{i[T]={status:"rejected",reason:m},l&&g(m)}).finally(()=>{s--,S()})}!f&&d&&s===0&&(v(),a(i))};S()})}function D(n){const t=[],r=[];for(const e of n)e.status==="fulfilled"?t.push(e.value):r.push(e.reason);return{fulfilled:t,rejected:r}}function _(n){w(n);const t=new y;let r=0,e=[];const l=()=>{if(r===0&&t.size===0&&e.length>0){const o=e;e=[];for(const u of o)u()}},a=()=>{for(;r<n&&t.size>0;)t.shift()?.start();l()};return{schedule(o,u={}){const{signal:i}=u;return new Promise((p,b)=>{h(i);let s;const d=()=>{s&&i&&(t.remove(s),s=void 0,b(L(i)),l())},f={start:()=>{s=void 0,i?.removeEventListener("abort",d),r++,Promise.resolve().then(()=>o(i??O())).then(p,b).finally(()=>{r--,a()})},cancel:v=>{s=void 0,i?.removeEventListener("abort",d),b(v)}};s=t.push(f),i?.addEventListener("abort",d,{once:!0}),a()})},get active(){return r},get pending(){return t.size},concurrency:n,onIdle(){return r===0&&t.size===0?Promise.resolve():new Promise(o=>e.push(o))},clear(){for(let o=t.shift();o;o=t.shift())o.cancel(new k("HLP_ASYNC_QUEUE_CLEARED","The queued task was cleared."));l()}}}function V(){return _(1)}async function Y(n,t,r={}){const{signal:e}=r;let l=0;h(e);for await(const a of n)h(e),await t(a,l++,e)}export{_ as createLimiter,V as createSerialQueue,Y as forEachAsync,H as mapLimit,M as mapLimitSettled,D as partitionSettled};
|
package/dist/async/control.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{TimeoutError as w,ValidationError as T,isAbortError as x,toError as c}from"../error/index.js";import{abortReason as g,assertDelay as y,sleep as p,throwIfAborted as P}from"./signal.js";function A(i,e,m={}){y(e);const l=m.signal;return new Promise((s,n)=>{if(l?.aborted){n(g(l));return}const r=new AbortController;let o=!1;const t=()=>o?!1:(o=!0,clearTimeout(u),l?.removeEventListener("abort",b),!0),b=()=>{if(!l||!t())return;const a=g(l);r.abort(a),n(a)},u=setTimeout(()=>{if(!t())return;const a=new w("HLP_TIMEOUT",m.message??"The operation timed out.");r.abort(a),n(a)},e);l?.addEventListener("abort",b,{once:!0});let f;try{f=typeof i=="function"?i(r.signal):i}catch(a){t(),n(c(a));return}Promise.resolve(f).then(a=>{t()&&s(a)},a=>{t()&&n(c(a))})})}function h(){const i=new Uint32Array(1);return globalThis.crypto.getRandomValues(i),(i[0]??0)/2**32}function v(i,e={}){const{minDelay:m=100,maxDelay:l=3e4,factor:s=2,jitter:n="full",random:r=h}=e,o=Math.min(l,m*s**Math.max(0,i-1));return n==="none"?o:n==="equal"?o/2+r()*(o/2):r()*o}async function O(i,e={}){const{retries:m=3,minDelay:l=100,maxDelay:s=3e4,factor:n=2,signal:r}=e;if(!Number.isSafeInteger(m)||m<0)throw new T("HLP_ASYNC_INVALID_RETRIES","retries must be a non-negative integer.");if(y(l,"minDelay"),y(s,"maxDelay"),!Number.isFinite(n)||n<1)throw new T("HLP_ASYNC_INVALID_FACTOR","factor must be a finite number >= 1.");const o=r??new AbortController().signal;for(let t=1;;t++){P(r);try{return await i(t,o)}catch(b){const u=c(b);if(x(b)||r?.aborted||t>m||e.retryIf&&!await e.retryIf(u,t))throw u;const f=v(t,e),a=e.delayFor?.(u,t,f),d=Math.min(Math.max(0,a??f),s);e.onRetry?.(u,t,d),await p(d,{signal:r})}}}function E(i,e={}){const m=e.interval??1e3;y(m,"interval");const l=e.until??(r=>!!r),s=async r=>{for(let o=1;;o++){P(r);const t=await i(r,o);if(l(t,o))return t;await p(m,{signal:r})}};if(e.timeout!==void 0)return A(s,e.timeout,{signal:e.signal,message:"Polling timed out."});const n=e.signal;return s(n??new AbortController().signal)}export{v as backoffDelay,E as poll,O as retry,A as timeout};
|
package/dist/async/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{MAX_DELAY_MS as o,abortReason as i,throwIfAborted as r,sleep as p,deferred as a,raceSignal as n,anySignal as l,timeoutSignal as c,withCancel as y}from"./signal.js";import{timeout as m,retry as f,backoffDelay as d,poll as A}from"./control.js";import{mapLimit as b,mapLimitSettled as h,partitionSettled as u,createLimiter as O,createSerialQueue as g,forEachAsync as L}from"./concurrency.js";import{createBatcher as D,singleFlight as B,debounceAsync as C,asyncPipe as M,toAsyncIterable as w,collectAsync as E}from"./batch.js";export{o as MAX_DELAY_MS,i as abortReason,l as anySignal,M as asyncPipe,d as backoffDelay,E as collectAsync,D as createBatcher,O as createLimiter,g as createSerialQueue,C as debounceAsync,a as deferred,L as forEachAsync,b as mapLimit,h as mapLimitSettled,u as partitionSettled,A as poll,n as raceSignal,f as retry,B as singleFlight,p as sleep,r as throwIfAborted,m as timeout,c as timeoutSignal,w as toAsyncIterable,y as withCancel};
|
package/dist/async/signal.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{AbortError as s,HelperError as f,TimeoutError as l,ValidationError as c,toError as b}from"../error/index.js";const m=2147483647;function u(n,e="ms"){if(!Number.isFinite(n)||n<0||n>m)throw new c("HLP_ASYNC_INVALID_MS","Delay must be a finite number of milliseconds within the timer range.",{details:{name:e}})}function a(n){const e=n.reason;return e instanceof f?e:typeof e=="object"&&e!==null&&e.name==="TimeoutError"?new l(void 0,void 0,{cause:e}):new s(void 0,void 0,{cause:e})}function A(n){if(n?.aborted)throw a(n)}function w(n,e={}){u(n);const{signal:r}=e;return new Promise((t,i)=>{if(r?.aborted){i(a(r));return}const o=()=>{clearTimeout(d),r&&i(a(r))},d=setTimeout(()=>{r?.removeEventListener("abort",o),t()},n);r?.addEventListener("abort",o,{once:!0})})}function T(){const n=Promise.withResolvers;if(typeof n=="function")return n.call(Promise);let e,r;return{promise:new Promise((i,o)=>{e=i,r=o}),resolve:e,reject:r}}function v(n,e){return e?new Promise((r,t)=>{if(e.aborted){t(a(e));return}const i=()=>{t(a(e))};e.addEventListener("abort",i,{once:!0}),Promise.resolve(n).then(o=>{e.removeEventListener("abort",i),r(o)},o=>{e.removeEventListener("abort",i),t(b(o))})}):Promise.resolve(n)}function g(n){const e=n.filter(o=>o!==void 0);if(typeof AbortSignal.any=="function")return AbortSignal.any(e);const r=new AbortController,t=()=>{for(const o of e)o.removeEventListener("abort",i)},i=function(){t(),r.abort(this.reason)};for(const o of e){if(o.aborted){t(),r.abort(o.reason);break}o.addEventListener("abort",i,{once:!0})}return r.signal}function S(n){if(u(n),typeof AbortSignal.timeout=="function")return AbortSignal.timeout(n);const e=new AbortController;return setTimeout(()=>{e.abort(new l)},n),e.signal}function y(n){const e=new AbortController;return{promise:v(Promise.resolve().then(()=>n(e.signal)),e.signal),signal:e.signal,cancel:t=>{e.abort(t??new s)}}}export{m as MAX_DELAY_MS,a as abortReason,g as anySignal,u as assertDelay,T as deferred,v as raceSignal,w as sleep,A as throwIfAborted,S as timeoutSignal,y as withCancel};
|
package/dist/boolean/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
const a=new Set(["true","yes","y","on","1"]),u=new Set(["false","no","n","off","0"]),f=64;function b(e,n={}){if(typeof e=="boolean")return e;const{strict:o=!1}=n;if(typeof e=="number")return o?void 0:e===1?!0:e===0?!1:void 0;if(typeof e!="string"||e.length>f)return;const r=e.trim().toLowerCase();if(o)return r==="true"?!0:r==="false"?!1:void 0;if(a.has(r)||n.trueValues?.some(t=>t.trim().toLowerCase()===r))return!0;if(u.has(r)||n.falseValues?.some(t=>t.trim().toLowerCase()===r))return!1}function c(e,n){return e!==n}function d(e,n){return e===n}function p(e,n){return!(e&&n)}function x(e,n){return!(e||n)}function y(e,n){return!e||n}function T(e){return!e}const l=e=>typeof e=="function"?e():e;function L(e){for(const n of e)if(!l(n))return!1;return!0}function i(e){for(const n of e)if(l(n))return!0;return!1}function B(e){return!i(e)}function g(e,n=o=>o===!0){let o=0;for(const r of e)n(r)&&o++;return o}function m(e){let n=0,o=0;for(const r of e)r?n++:o++;return n>o}function s(e,n={true:"true",false:"false"}){return e==null?n.null??"":e?n.true:n.false}function k(e,n={true:"Yes",false:"No"}){return s(e,n)}function w(e){return!!e}function I(e){return!e}function S(e){return e?1:0}export{L as all,i as any,S as boolToInt,s as booleanToLabel,k as booleanToYesNo,g as countTrue,y as implies,I as isFalsy,w as isTruthy,m as majority,p as nand,B as none,x as nor,b as parseBoolean,T as toggle,d as xnor,c as xor};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{addMonths as k,fromEpochDay as d,plainDate as N,plainDateFromInstant as q,toEpochDay as b,toPlainDate as A}from"../date/index.js";import{S_FULL as G,S_HALF as W,S_HOL_WEEKDAY as E,S_HOL_WEEKEND as M,S_NONWORKING_WEEKDAY as K,S_PATTERN as U,S_WORKING_WEEKEND as X,businessCount as J,businessValue as H,defaultBusinessCalendar as u,engineOf as l,infoAt as v,patternCount as x,rangesAt as Q,recordAt as $,recordsIn as T,specialCounts as R,statusAt as p,stepBackward as O,stepForward as _}from"./engine.js";import{epochOf as ee,invalid as D,limit as Z,weekdayOfEpoch as z}from"./internal.js";const c=e=>b(A(e)),ne=new Set(["none","start","end","both"]),F=1e3,te=new Set(["following","modifiedFollowing","preceding","modifiedPreceding","none"]);function P(e,n){if(n===void 0)return e.cal.halfDayValue;if(typeof n!="number"||!Number.isFinite(n)||n<0||n>1)throw D("HLP_BIZCAL_INVALID_OPTION","halfDayValue must be between 0 and 1.","halfDayValue");return n}function se(e,n=u()){return l(n).working[z(c(e))]!==!0}function fe(e,n=u()){return!se(e,n)}function re(e,n=u()){const t=l(n);return $(t,c(e))?.holidays??[]}function ce(e,n=u()){const t=re(e,n);return t.find(s=>!s.halfDay&&s.movedTo===void 0)??t.find(s=>!s.halfDay)}function ye(e,n=u()){return p(l(n),c(e))!==0}function me(e,n=u()){return p(l(n),c(e))===2}function De(e,n=u()){return v(l(n),c(e))}function be(e,n=u()){const t=l(n);return v(t,b(q(e,t.zone)))}function pe(e,n,t=u()){const s=l(t),r=c(e),a=c(n),o=Math.min(r,a),i=Math.max(r,a);if(d(i).year-d(o).year>F)throw Z("HLP_BIZCAL_RANGE_LIMIT","The date range spans too many years.",F);const f=[];return T(s,o,i,(I,h)=>{f.push(...h.holidays)}),f}function Ie(e,n,t=u(),s={}){const r=l(t),a=c(e),o=c(n),i=s.limit??Number.POSITIVE_INFINITY;if(typeof i!="number"||Number.isNaN(i)||i<0||Number.isFinite(i)&&!Number.isInteger(i))throw D("HLP_BIZCAL_INVALID_OPTION","limit must be a non-negative integer.","limit");const f=o>=a?1:-1;function*I(){let h=0;for(let g=a;f>0?g<=o:g>=o;g+=f){if(h>=i)return;p(r,g)!==0&&(h++,yield d(g))}}return I()}function L(e,n,t,s){if(typeof e!="number"||!Number.isInteger(e)||e<n||e>t)throw D("HLP_BIZCAL_INVALID_OPTION","Period field is out of range.",s);return e}function ae(e,n=u()){const{cal:t}=l(n);let s,r;if(typeof e=="number")s=N(e,1,1),r=12;else if(typeof e=="object"&&"fiscalYear"in e){const a=L(e.fiscalYear,-27e4,27e4,"fiscalYear"),o=t.fiscalYearStartMonth;s=N(o===1||t.fiscalYearNaming==="start"?a:a-1,o,1),r=12,e.quarter!==void 0&&(s=k(s,3*(L(e.quarter,1,4,"quarter")-1)),r=3)}else if(typeof e=="object"&&"month"in e)s=N(e.year,L(e.month,1,12,"month"),1),r=1;else if(typeof e=="object"&&"quarter"in e)s=N(e.year,(L(e.quarter,1,4,"quarter")-1)*3+1,1),r=3;else throw D("HLP_BIZCAL_INVALID_OPTION","Unknown period.","period");return Object.freeze([s,d(b(k(s,r))-1)])}function he(e,n=u(),t={}){const s=l(n),[r,a]=ae(e,n);return H(s,b(r),b(a),P(s,t.halfDayValue))}function Be(e,n=u(),t={}){const s=l(n),r=c(e);return t.includeSelf===!0&&p(s,r)!==0?d(r):d(_(s,r,1))}function ge(e,n=u(),t={}){const s=l(n),r=c(e);return t.includeSelf===!0&&p(s,r)!==0?d(r):d(O(s,r,1))}const Y=1e7;function Oe(e,n,t=u(),s={}){const r=l(t),a=c(e);if(typeof n!="number"||!Number.isInteger(n))throw D("HLP_BIZCAL_INVALID_OPTION","n must be an integer.","n");if(Math.abs(n)>Y)throw Z("HLP_BIZCAL_RANGE_LIMIT","n exceeds the supported number of business days.",Y);if(n>0)return d(_(r,a,n));if(n<0)return d(O(r,a,-n));const o=s.zero??"following";if(o==="none"||p(r,a)!==0)return d(a);if(o==="following")return d(_(r,a,1));if(o==="preceding")return d(O(r,a,1));throw D("HLP_BIZCAL_INVALID_OPTION","Unknown zero option.","zero")}function _e(e,n,t=u()){const s=l(t),r=A(e),a=b(r);if(!te.has(n))throw D("HLP_BIZCAL_INVALID_OPTION","Unknown business-day convention.","convention");if(n==="none"||p(s,a)!==0)return r;switch(n){case"following":return d(_(s,a,1));case"preceding":return d(O(s,a,1));case"modifiedFollowing":{const o=d(_(s,a,1));return o.month===r.month&&o.year===r.year?o:d(O(s,a,1))}case"modifiedPreceding":{const o=d(O(s,a,1));return o.month===r.month&&o.year===r.year?o:d(_(s,a,1))}default:return r}}function oe(e,n){const t=N(e,n,1);return[b(t),b(k(t,1))-1]}function j(e,n,t,s=u()){const r=l(s);if(typeof t!="number"||!Number.isInteger(t)||t===0||Math.abs(t)>31)throw D("HLP_BIZCAL_INVALID_OPTION","n must be a non-zero integer from -31 to 31.","n");const[a,o]=oe(e,n);let i=Math.abs(t);for(let f=0;f<=o-a;f++){const I=t>0?a+f:o-f;if(p(r,I)!==0&&--i===0)return d(I)}}function Ce(e,n,t=u()){return j(e,n,1,t)}function Ne(e,n,t=u()){return j(e,n,-1,t)}function we(e,n=u()){const t=l(n),s=A(e),r=b(s);if(p(t,r)!==0)return J(t,ee(s.year,s.month,1),r)}function C(e,n,t){const s=c(e),r=c(n),a=t??"start";if(!ne.has(a))throw D("HLP_BIZCAL_INVALID_OPTION","inclusive must be none, start, end, or both.","inclusive");const o=Math.min(s,r),i=Math.max(s,r);return o===i?{sign:1,lo:o,hi:a==="both"?o:o-1}:{sign:r>=s?1:-1,lo:a==="both"||a==="start"?o:o+1,hi:a==="both"||a==="end"?i:i-1}}const y=(e,n)=>n===0?0:e*n;function xe(e,n,t={}){const s=l(t.calendar??u()),{sign:r,lo:a,hi:o}=C(e,n,t.inclusive),i=t.mode??"calendar";if(i==="calendar")return y(r,Math.max(0,o-a+1));if(i==="weekdays")return y(r,x(s,a,o));if(i==="business")return y(r,H(s,a,o,P(s,t.halfDayValue)));throw D("HLP_BIZCAL_INVALID_OPTION","mode must be calendar, weekdays, or business.","mode")}function Pe(e,n,t={}){const s=l(t.calendar??u()),{lo:r,hi:a}=C(e,n,t.inclusive);return Math.max(0,a-r+1)-x(s,r,a)}function Le(e,n,t={}){const s=l(t.calendar??u()),{lo:r,hi:a}=C(e,n,t.inclusive);return x(s,r,a)}function ke(e,n,t={}){const s=l(t.calendar??u()),{lo:r,hi:a}=C(e,n,t.inclusive);return H(s,r,a,P(s,t.halfDayValue))}function Ae(e,n,t={}){const s=l(t.calendar??u()),{lo:r,hi:a}=C(e,n,t.inclusive),o=R(s,r,a),i=o[E]??0,f=o[M]??0;return Object.freeze({total:i+f,onWeekdays:i,onWeekends:f})}function ie(e,n,t){if(n<e)return 0;const s=((t-4)%7+7)%7,r=a=>Math.floor((a-s)/7);return r(n)-r(e-1)}const V=e=>e.reduce((n,[t,s])=>n+s-t,0);function He(e,n,t=u(),s={}){const r=l(t),a=P(r,s.halfDayValue),{sign:o,lo:i,hi:f}=C(e,n,s.inclusive),I=Math.max(0,f-i+1),h=x(r,i,f),g=R(r,i,f);let w=0;for(let m=1;m<=7;m++)r.working[m]===!0&&(w+=ie(i,f,m)*V(r.hours[m]??[]));T(r,i,f,(m,S)=>{S.pattern&&(w-=V(r.hours[z(m)]??[])),w+=V(Q(r,m,S))});const B=m=>g[m]??0;return Object.freeze({calendarDays:y(o,I),weekdays:y(o,h),weekendDays:y(o,I-h),holidays:y(o,B(E)),holidaysOnWeekends:y(o,B(M)),halfDays:y(o,B(W)),nonWorkingWeekdays:y(o,B(K)),workingWeekendDays:y(o,B(X)),businessDays:y(o,h-B(U)+B(G)+a*B(W)),businessHours:y(o,w/60)})}export{Oe as addBusinessDays,_e as adjustBusinessDay,be as businessDayAt,we as businessDayOfMonth,he as businessDaysIn,ke as countBusinessDays,Ae as countHolidays,Le as countWeekdays,Pe as countWeekends,He as diffBreakdown,xe as diffDays,Ce as firstBusinessDayOfMonth,De as getBusinessDay,re as holidaysOn,ye as isBusinessDay,me as isHalfDay,ce as isHoliday,fe as isWeekday,se as isWeekend,Ne as lastBusinessDayOfMonth,Ie as listBusinessDays,pe as listHolidays,Be as nextBusinessDay,j as nthBusinessDayOfMonth,ae as periodRange,ge as previousBusinessDay};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{listFormat as t}from"../date/intl-cache.js";const y=Object.freeze({weekend:"Weekend",holiday:"Holiday: {name}",halfDay:"Half day: {name}",halfDayUnnamed:"Half day",nonWorking:"Non-working day: {name}",nonWorkingUnnamed:"Non-working day",working:"Working day: {name}",workingUnnamed:"Working day"}),r=(n,s)=>n.split("{name}").join(s);function g(n,s={}){const e={...y,...s.labels};switch(n.reasonCode){case"weekend":return e.weekend;case"holiday":{const l=n.holidays.filter(a=>!a.halfDay&&a.movedTo===void 0),i=[...new Set((l.length>0?l:n.holidays.filter(a=>!a.halfDay)).map(a=>a.name))];let o;try{o=t(s.locale,{type:"conjunction",style:"long"}).format(i)}catch{o=i.join(", ")}return r(e.holiday,o)}case"half-day":return n.reason===null?e.halfDayUnnamed:r(e.halfDay,n.reason);case"exception":return n.working?n.halfDay?n.reason===null?e.halfDayUnnamed:r(e.halfDay,n.reason):n.reason===null?e.workingUnnamed:r(e.working,n.reason):n.reason===null?e.nonWorkingUnnamed:r(e.nonWorking,n.reason);default:return""}}export{y as DEFAULT_BUSINESS_DAY_LABELS,g as describeBusinessDay};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{MAX_YEAR as ae,fromEpochDay as T,getWeekInfo as te,toEpochDay as se}from"../date/index.js";import{isValidTimeZone as be}from"../timezone/index.js";import{epochOf as ie,firstHalf as De,invalid as y,isArray as z,isRecord as O,limit as j,lowerBound as Z,normalizeRanges as Y,optionalText as de,rangesToText as W,requiredName as we,upperBound as v,weekdayOfEpoch as H}from"./internal.js";import{normalizeRule as $,normalizeTags as ke}from"./rules.js";const Ie=0,_e=1,Ee=2,Ke=3,Ge=4,qe=5,Je=6,S=7,J=new WeakMap,xe=200,Ae=5e3,le=5e3,Re=1e5,Le=32,ue=1e4,ce=45,U=2e4,fe=366*100;function ye(e){const n=e,o=typeof n=="object"&&n!==null?J.get(n):void 0;if(!o)throw y("HLP_BIZCAL_INVALID_CALENDAR","Expected a calendar created by createBusinessCalendar.");return o}function F(){throw y("HLP_BIZCAL_NO_WORKING_DAYS","The calendar has no business day within the search limit.")}const V=e=>T(e).year;function Q(e,n){return e?n.length===0?e.includeUntagged??!0:n.some(o=>e.tags.includes(o)):!0}function pe(e,n){const o=e.get(n);return o!==void 0&&(e.delete(n),e.set(n,o)),o}function me(e,n,o){if(e.size>=xe){const a=e.keys().next();a.done!==!0&&e.delete(a.value)}return e.set(n,o),o}function Ce(e,n){if(e.providers.length===0||Math.abs(n)>ae)return[];const o=pe(e.provided,n);if(o)return o;const a=[];return e.providers.forEach((i,r)=>{const t=i.holidaysFor(n);if(!z(t))throw y("HLP_BIZCAL_INVALID_PROVIDER","A holiday provider must return an array.",`providers[${String(r)}]`);if(t.length>ue)throw j("HLP_BIZCAL_PROVIDER_LIMIT","A holiday provider returned too many holidays for one year.",ue);t.forEach((d,l)=>a.push($(d,`providers[${String(r)}][${String(l)}]`,{allowProvided:!0})))}),me(e.provided,n,Object.freeze(a))}function He(e,n,o,a){const i=n.occurrences;if(!i)return[];if(o<0)return i(a);const r=`${String(o)}:${String(a)}`,t=e.occurrences.get(r);if(t)return t;const d=i(a);return e.occurrences.size>=Ae&&e.occurrences.clear(),e.occurrences.set(r,d),d}function Se(e,n,o,a){if(o==="none")return;const i=H(n),r=l=>e.working[H(l)]===!0;let t,d;if(typeof o=="string"){if(r(n)||e.workingCount===0)return;if(o==="next-weekday")t=1;else if(o==="previous-weekday")t=-1;else{let l=1;for(;!r(n+l)&&!r(n-l);)l++;t=r(n+l)?1:-1}d=n+t}else{const l=o[i];if(l===void 0||l===0)return;t=l>0?1:-1,d=n+l}for(let l=0;l<366;l++){if(r(d)&&!a.has(d))return d;d+=t}}function Ne(e,n,o,a,i){return Object.freeze({date:T(e),name:n.name,kind:n.kind,...n.id===void 0?{}:{id:n.id},tags:n.tags,halfDay:n.halfDay,observed:o,...a===void 0?{}:{originalDate:T(a)},...i===void 0?{}:{movedTo:T(i)}})}function Oe(e,n){const o=ie(n,1,1),a=ie(n+1,1,1)-1,i=o-ce,r=a+ce,t=[];let d=0;const l=(s,f,D)=>{if(d++,!!Q(e.scope,s.tags)){if(s.span){const g=Math.min(s.span[1],r);for(let h=Math.max(s.span[0],i);h<=g;h++)t.push({e:h,r:s,order:d});return}for(const g of D)if(!(g<s.fromYear||g>s.toYear||Math.abs(g)>=ae))for(const h of He(e,s,f,g))h>=i&&h<=r&&t.push({e:h,r:s,order:d})}},p=[n-1,n,n+1];e.rules.forEach((s,f)=>{l(s,f,p)});for(const s of p)for(const f of Ce(e,s))l(f,-1,[s]);t.sort((s,f)=>s.e-f.e||s.order-f.order);const c=new Set;for(const s of t)s.r.halfDay||c.add(s.e);const m=new Map,I=new Set,x=(s,f,D,g,h)=>{if(s<o||s>a)return;const C=`${String(s)}|${String(D)}|${String(f.halfDay)}|${f.kind}|${f.name}`;if(I.has(C))return;I.add(C);let E=m.get(s);E||(E=[],m.set(s,E)),E.push({h:Ne(s,f,D,g,h),r:f})};for(const s of t){const f=Se(e,s.e,s.r.observed,c);f===void 0?x(s.e,s.r,!1):(x(s.e,s.r,!1,void 0,f),x(f,s.r,!0,s.e),s.r.halfDay||c.add(f))}const w=Z(e.exceptionDays,o),R=v(e.exceptionDays,a),A=new Set(m.keys());for(let s=w;s<R;s++)A.add(e.exceptionDays[s]??0);const B=[...A].sort((s,f)=>s-f),L=new Map,P=new Float64Array((B.length+1)*S);return B.forEach((s,f)=>{const D=m.get(s)??[],g=e.exceptions.get(s),h=e.working[H(s)]===!0,C=D.some(({h:b})=>!b.halfDay&&b.movedTo===void 0),E=D.some(({h:b})=>!b.halfDay),M=D.find(({h:b})=>b.halfDay&&b.movedTo===void 0);let k;g?k=g.ex.working?g.halfDay?2:1:0:C?k=0:M&&h?k=2:k=h?1:0,L.set(s,Object.freeze({holidays:Object.freeze(D.map(b=>b.h)),exception:g,pattern:h,status:k,anyFull:E,halfHours:M?.r.halfHours}));const N=f*S,G=N+S;[h,k===1,k===2,h&&C,!h&&E,h&&k===0,!h&&k>0].forEach((b,u)=>{P[G+u]=(P[N+u]??0)+(b?1:0)})}),Object.freeze({days:B,records:L,cum:P})}function ee(e,n){return pe(e.years,n)??me(e.years,n,Oe(e,n))}function ne(e,n){return ee(e,V(n)).records.get(n)}function Be(e,n,o){if(o<n)return 0;const a=i=>Math.floor(i/7)*e.workingCount+(e.pre[(i%7+7)%7]??0);return a(o+1)-a(n)}function Pe(e,n,o){const a=new Float64Array(S);if(o<n)return a;const i=V(n),r=V(o);if(r-i>U)throw j("HLP_BIZCAL_RANGE_LIMIT","The date range spans too many years.",U);for(let t=i;t<=r;t++){const d=ee(e,t),l=t===i?Z(d.days,n):0,p=t===r?v(d.days,o):d.days.length;if(!(p<=l))for(let c=0;c<S;c++)a[c]=(a[c]??0)+(d.cum[p*S+c]??0)-(d.cum[l*S+c]??0)}return a}function Qe(e,n,o,a){if(o<n)return;const i=V(n),r=V(o);if(r-i>U)throw j("HLP_BIZCAL_RANGE_LIMIT","The date range spans too many years.",U);for(let t=i;t<=r;t++){const d=ee(e,t),l=t===r?v(d.days,o):d.days.length;for(let p=t===i?Z(d.days,n):0;p<l;p++){const c=d.days[p]??0,m=d.records.get(c);m&&a(c,m)}}}function Me(e,n,o,a){if(o<n)return 0;const i=Pe(e,n,o);return Be(e,n,o)-(i[Ie]??0)+(i[_e]??0)+a*(i[Ee]??0)}const X=(e,n,o)=>Me(e,n,o,1);function en(e,n){const o=ne(e,n);return o?o.status:e.working[H(n)]===!0?1:0}function nn(e,n,o){if(e.workingCount===0)return e.workingExceptionDays[v(e.workingExceptionDays,n)+o-1]??F();const a=Math.ceil(o/e.workingCount)*7+7,i=a+fe;let r=a;for(;X(e,n+1,n+r)<o;)r>=i&&F(),r=Math.min(r*2,i);let t=1,d=r;for(;t<d;){const l=t+Math.floor((d-t)/2);X(e,n+1,n+l)>=o?d=l:t=l+1}return n+t}function on(e,n,o){if(e.workingCount===0)return e.workingExceptionDays[Z(e.workingExceptionDays,n)-o]??F();const a=Math.ceil(o/e.workingCount)*7+7,i=a+fe;let r=a;for(;X(e,n-r,n-1)<o;)r>=i&&F(),r=Math.min(r*2,i);let t=1,d=r;for(;t<d;){const l=t+Math.floor((d-t)/2);X(e,n-l,n-1)>=o?d=l:t=l+1}return n-t}function Te(e,n,o=ne(e,n)){const a=H(n),i=o?o.status:e.working[a]===!0?1:0;if(i===0)return[];const r=o?.exception;return r?r.hours??(r.halfDay?e.halfHours[a]??[]:e.hours[a]??[]):i===2?o?.halfHours??e.halfHours[a]??[]:e.hours[a]??[]}function rn(e,n){const o=ne(e,n),a=H(n),i=e.working[a]===!0,r=o?o.status:i?1:0,t=o?.holidays??[],d=o?.exception;let l=null,p=null;if(d)l="exception",p=d.ex.reason??null;else if(r===0){const c=t.find(m=>!m.halfDay&&m.movedTo===void 0)??t.find(m=>!m.halfDay);c?(l="holiday",p=c.name):l="weekend"}else r===2&&(l="half-day",p=t.find(c=>c.halfDay&&c.movedTo===void 0)?.name??null);return Object.freeze({date:T(n),weekday:a,working:r!==0,weekend:!i,holidays:t,exception:d?.ex??null,halfDay:r===2,hours:W(Te(e,n,o)),reasonCode:l,reason:p,businessDayValue:r===0?0:r===2?e.cal.halfDayValue:1})}const oe=Object.freeze([Object.freeze(["09:00","17:00"])]),ze=new Set(["default","1","2","3","4","5","6","7"]);function he(e,n){if(typeof e!="number"||!Number.isInteger(e)||e<1||e>7)throw y("HLP_BIZCAL_INVALID_WEEKDAY","Expected an ISO weekday 1 (Monday) to 7 (Sunday).",n);return e}function We(e){if(!z(e)||e.length>7)throw y("HLP_BIZCAL_INVALID_WEEKEND","Weekend must be an array of distinct ISO weekdays.","weekend");const n=e.map(o=>he(o,"weekend"));if(new Set(n).size!==n.length)throw y("HLP_BIZCAL_INVALID_WEEKEND","Weekend must be an array of distinct ISO weekdays.","weekend");return Object.freeze([...n].sort((o,a)=>o-a))}function Ve(e){if(e===void 0&&(e={default:oe}),!O(e))throw y("HLP_BIZCAL_INVALID_HOURS","workingHours must be an object.","workingHours");const n={},o=new Map;for(const r of Object.keys(e)){if(!ze.has(r))throw y("HLP_BIZCAL_INVALID_HOURS",'workingHours keys must be "default" or ISO weekdays 1-7.',"workingHours");const t=Y(e[r],`workingHours.${r}`);o.set(r,t),n[r]=W(t)}o.has("default")||(o.set("default",Y(oe,"workingHours.default")),n.default=oe);const a=o.get("default")??[],i=[[]];for(let r=1;r<=7;r++)i.push(o.get(String(r))??a);return{text:Object.freeze(n),byDay:Object.freeze(i)}}function je(e,n){if(!O(e))throw y("HLP_BIZCAL_INVALID_EXCEPTION","An exception must be an object.",n);const o=$({kind:"date",name:"exception",date:e.date},n).rule;if(typeof e.working!="boolean")throw y("HLP_BIZCAL_INVALID_EXCEPTION","Exception working must be a boolean.",`${n}.working`);if(e.halfDay!==void 0&&typeof e.halfDay!="boolean")throw y("HLP_BIZCAL_INVALID_EXCEPTION","Exception halfDay must be a boolean.",`${n}.halfDay`);const a=e.halfDay===!0;if(!e.working&&(a||e.hours!==void 0))throw y("HLP_BIZCAL_INVALID_EXCEPTION","Only working exceptions may set hours or halfDay.",n);const i=e.hours===void 0?void 0:Y(e.hours,`${n}.hours`),r=de(e.reason,`${n}.reason`),t=Object.freeze({date:o.date,working:e.working,...i===void 0?{}:{hours:W(i)},...a?{halfDay:a}:{},...r===void 0?{}:{reason:r}});return Object.freeze({e:se(o.date),ex:t,hours:i,halfDay:a})}function K(e,n,o){if(e===void 0)return[];if(!z(e))throw y("HLP_BIZCAL_INVALID_DEFINITION","Expected an array.",n);if(e.length>o)throw j("HLP_BIZCAL_TOO_MANY_ITEMS","Too many items in a calendar definition list.",o);return e}function Ze(e){if(e===void 0)return;if(!O(e))throw y("HLP_BIZCAL_INVALID_TAGS","tagScope must be an object.","tagScope");const n=ke(e.tags,"tagScope.tags");if(e.includeUntagged!==void 0&&typeof e.includeUntagged!="boolean")throw y("HLP_BIZCAL_INVALID_TAGS","includeUntagged must be a boolean.","tagScope.includeUntagged");return Object.freeze({tags:n,...e.includeUntagged===void 0?{}:{includeUntagged:e.includeUntagged}})}function re(e={}){if(!O(e))throw y("HLP_BIZCAL_INVALID_DEFINITION","A business calendar definition must be an object.");const n=e,o=n.name===void 0?"Business calendar":we(n.name,"name"),a=de(n.locale,"locale",128),i=a===void 0?void 0:te(a),r=We(n.weekend??i?.weekend??[6,7]),t=n.firstDayOfWeek===void 0?i?.firstDay??1:he(n.firstDayOfWeek,"firstDayOfWeek"),d=n.timeZone??"UTC";if(typeof d!="string"||!be(d))throw y("HLP_BIZCAL_INVALID_TIME_ZONE","Unsupported time zone identifier.","timeZone");const l=n.fiscalYearStartMonth??1;if(typeof l!="number"||!Number.isInteger(l)||l<1||l>12)throw y("HLP_BIZCAL_INVALID_FISCAL","fiscalYearStartMonth must be 1-12.","fiscalYearStartMonth");const p=n.fiscalYearNaming??"end";if(p!=="end"&&p!=="start")throw y("HLP_BIZCAL_INVALID_FISCAL","fiscalYearNaming must be end or start.","fiscalYearNaming");const c=n.halfDayValue??.5;if(typeof c!="number"||!Number.isFinite(c)||c<0||c>1)throw y("HLP_BIZCAL_INVALID_HALF_DAY","halfDayValue must be between 0 and 1.","halfDayValue");const m=n.halfDayHours===void 0?void 0:Y(n.halfDayHours,"halfDayHours"),I=Ve(n.workingHours),x=K(n.holidays,"holidays",le).map((u,_)=>$(u,`holidays[${String(_)}]`)),w=K(n.halfDays,"halfDays",le).map((u,_)=>$(u,`halfDays[${String(_)}]`,{forceHalf:!0})),R=K(n.exceptions,"exceptions",Re).map((u,_)=>je(u,`exceptions[${String(_)}]`)),A=new Map;R.forEach((u,_)=>{if(A.has(u.e))throw y("HLP_BIZCAL_DUPLICATE_EXCEPTION","Only one exception per date is allowed.",`exceptions[${String(_)}].date`);A.set(u.e,u)});const B=K(n.providers,"providers",Le).map((u,_)=>{if(!O(u)||typeof u.holidaysFor!="function")throw y("HLP_BIZCAL_INVALID_PROVIDER","A holiday provider needs a holidaysFor(year) function.",`providers[${String(_)}]`);return u}),L=Ze(n.tagScope),P=new Set(r),s=[!1];for(let u=1;u<=7;u++)s.push(!P.has(u));const f=Object.freeze([1,2,3,4,5,6,7].filter(u=>s[u]===!0)),D=[0];for(let u=0;u<7;u++)D.push((D[u]??0)+(s[H(u)]===!0?1:0));const g=I.byDay.map(u=>m??De(u)),h=[...A.keys()].sort((u,_)=>u-_),C=h.filter(u=>A.get(u)?.ex.working===!0),E=Object.freeze(x.map(u=>u.rule)),M=Object.freeze(w.map(u=>u.rule)),k=Object.freeze(R.map(u=>u.ex)),N=Object.freeze([...B]),G=Object.freeze({name:o,weekend:r,firstDayOfWeek:t,holidays:E,halfDays:M,halfDayValue:c,...m===void 0?{}:{halfDayHours:W(m)},exceptions:k,workingHours:I.text,timeZone:d,fiscalYearStartMonth:l,fiscalYearNaming:p,providers:N,...L===void 0?{}:{tagScope:L}}),q={};for(let u=1;u<=7;u++)q[String(u)]=W(I.byDay[u]??[]);const b=Object.freeze({kind:"BusinessCalendar",name:o,weekend:r,workingWeekdays:f,firstDayOfWeek:t,timeZone:d,fiscalYearStartMonth:l,fiscalYearNaming:p,halfDayValue:c,workingHours:Object.freeze(q),holidays:E,halfDays:M,exceptions:k,providers:N,tagScope:L,definition:G});return J.set(b,{cal:b,working:Object.freeze(s),workingCount:f.length,pre:Object.freeze(D),hours:I.byDay,halfHours:Object.freeze(g),zone:d,rules:Object.freeze([...x,...w]),providers:N,scope:L,exceptions:A,exceptionDays:h,workingExceptionDays:C,years:new Map,provided:new Map,occurrences:new Map}),b}function an(e){return typeof e=="object"&&e!==null&&J.has(e)}let ge;function tn(){return ge??=re({name:"Default"}),ge}function sn(e){return te(e).weekend}function Ye(e){return!O(e)||!z(e.tags)?[]:e.tags.filter(n=>typeof n=="string")}function ve(e,n){return Object.freeze({holidaysFor:o=>e.holidaysFor(o).filter(a=>Q(n,Ye(a)))})}function dn(e,n={}){if(!z(e)||e.length===0)throw y("HLP_BIZCAL_INVALID_CALENDAR","mergeCalendars needs at least one calendar.","calendars");const o=e.map(c=>ye(c)),[a]=o;if(!a)throw y("HLP_BIZCAL_INVALID_CALENDAR","mergeCalendars needs at least one calendar.","calendars");const i=a.cal,r=[],t=[],d=[],l=[],p=new Set;for(const c of o){const{cal:m,scope:I}=c,x=w=>Q(I,w.tags??[]);r.push(...m.holidays.filter(x)),t.push(...m.halfDays.filter(x));for(const w of m.providers)d.push(I?ve(w,I):w);for(const w of m.exceptions){const R=se(w.date);p.has(R)||(p.add(R),l.push(w))}}return re({...i.definition,tagScope:void 0,name:e.map(c=>c.name).join(" + "),holidays:r,halfDays:t,providers:d,exceptions:l,...n})}function ln(e,n,o={}){const{cal:a}=ye(e);return re({...a.definition,tagScope:{tags:n,...o.includeUntagged===void 0?{}:{includeUntagged:o.includeUntagged}}})}export{_e as S_FULL,Ee as S_HALF,Ke as S_HOL_WEEKDAY,Ge as S_HOL_WEEKEND,qe as S_NONWORKING_WEEKDAY,Ie as S_PATTERN,Je as S_WORKING_WEEKEND,X as businessCount,Me as businessValue,re as createBusinessCalendar,tn as defaultBusinessCalendar,ye as engineOf,rn as infoAt,an as isBusinessCalendar,dn as mergeCalendars,F as noWorkingDays,Be as patternCount,Te as rangesAt,ne as recordAt,Qe as recordsIn,Pe as specialCounts,en as statusAt,on as stepBackward,nn as stepForward,sn as weekendForLocale,ln as withTags};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{endOfDayInstant as v,fromEpochDay as N,plainDateFromInstant as z,plainDateTime as S,timeFromMilliseconds as Z,toEpochDay as B,toPlainDate as V}from"../date/index.js";import{toEpochMs as h}from"../date/zone.js";import{offsetAt as H,zonedToInstant as k}from"../timezone/index.js";import{defaultBusinessCalendar as y,engineOf as _,noWorkingDays as T,rangesAt as F,statusAt as O,stepForward as Y}from"./engine.js";import{DAY_MS as C,MINUTE_MS as x,invalid as D,limit as P}from"./internal.js";const M=36e5,g=366*100,w=3660;function E(s,n,o){const t=n+Math.floor(o/1440);return k(S(N(t),Z(o%1440*x)),s,{disambiguation:"compatible"})}function A(s,n){if(O(s,n)===0)return[];const o=F(s,n);if(o.length===0)return[];const t=n*C,r=H(t-14*M,s.zone),e=H(t+C+14*M,s.zone);if(r===e)return o.map(([u,f])=>[t+u*x-r,t+f*x-r]);const a=[];let i=Number.NEGATIVE_INFINITY;for(const[u,f]of o){const m=Math.max(E(s.zone,n,u),i),c=Math.max(E(s.zone,n,f),m);c>m&&a.push([m,c]),i=c}return a}const L=(s,n)=>B(z(n,s.zone));function q(s,n=y()){const o=_(n);return Object.freeze(A(o,B(V(s))).map(([t,r])=>Object.freeze({start:t,end:r})))}function J(s,n=y()){const o=_(n),t=h(s);return A(o,L(o,t)).some(([r,e])=>t>=r&&t<e)}function K(s,n=y()){const o=_(n),t=h(s),r=L(o,t);for(let e=0;e<=w;e++)for(const[a,i]of A(o,r+e))if(i>t)return Math.max(a,t);return T()}function Q(s,n,o=y(),t={}){const r=_(o),e=h(s),a=h(n),i=t.unit??"hours";if(i!=="hours"&&i!=="milliseconds")throw D("HLP_BIZCAL_INVALID_OPTION","unit must be hours or milliseconds.","unit");const u=Math.min(e,a),f=Math.max(e,a),m=L(r,u),c=L(r,f);if(c-m>g)throw P("HLP_BIZCAL_RANGE_LIMIT","The range spans too many days.",g);let d=0;for(let l=m;l<=c;l++)for(const[b,p]of A(r,l))d+=Math.max(0,Math.min(p,f)-Math.max(b,u));const I=i==="hours"?d/M:d;return I===0?0:a>=e?I:-I}function j(s,n,o=y()){const t=_(o),r=h(s);if(typeof n!="number"||!Number.isFinite(n))throw D("HLP_BIZCAL_INVALID_OPTION","hours must be a finite number.","hours");let e=Math.round(Math.abs(n)*M);if(e===0)return r;const a=n>0,i=L(t,r);let u=0;for(let f=0;f<=g;f++){const m=a?i+f:i-f,c=A(t,m);let d=!1;if(a)for(const[I,l]of c){const b=Math.max(I,r);if(!(l<=b)){if(d=!0,e<=l-b)return b+e;e-=l-b}}else for(let I=c.length-1;I>=0;I--){const[l,b]=c[I]??[0,0],p=Math.min(b,r);if(!(p<=l)){if(d=!0,e<=p-l)return p-e;e-=p-l}}u=d?0:u+1,u>w&&T()}throw P("HLP_BIZCAL_RANGE_LIMIT","The result is too far away.",g)}function $(s,n,o=y()){const t=_(o),r=h(s),e=n;if(typeof e!="object"||e===null)throw D("HLP_BIZCAL_INVALID_OPTION","Expected { businessHours } or { businessDays }.","target");const a="businessHours"in n?n.businessHours:void 0,i="businessDays"in n?n.businessDays:void 0;if(a===void 0==(i===void 0))throw D("HLP_BIZCAL_INVALID_OPTION","Expected exactly one of businessHours or businessDays.","target");if(a!==void 0){if(typeof a!="number"||!(a>=0))throw D("HLP_BIZCAL_INVALID_OPTION","businessHours must be a non-negative number.","businessHours");return j(r,a,o)}if(typeof i!="number"||!Number.isInteger(i)||i<0)throw D("HLP_BIZCAL_INVALID_OPTION","businessDays must be a non-negative integer.","businessDays");const u=L(t,r),f=i===0&&O(t,u)!==0?u:Y(t,u,Math.max(i,1)),m=A(t,f),c=m[m.length-1];return c?c[1]:v(N(f),t.zone)}export{j as addBusinessHours,Q as diffBusinessHours,J as isWorkingTime,K as nextWorkingTime,$ as slaDeadline,q as workingIntervals};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{createBusinessCalendar as i,defaultBusinessCalendar as a,isBusinessCalendar as n,mergeCalendars as o,weekendForLocale as d,withTags as t}from"./engine.js";import{customHoliday as r,defineHolidays as u,easterHoliday as l,easterSunday as f,fixedHoliday as D,holidayRange as B,lastWeekdayHoliday as p,nthWeekdayHoliday as H,oneOffHoliday as O}from"./rules.js";import{addBusinessDays as x,adjustBusinessDay as R,businessDayAt as c,businessDayOfMonth as g,businessDaysIn as k,countBusinessDays as h,countHolidays as C,countWeekdays as v,countWeekends as W,diffBreakdown as b,diffDays as S,firstBusinessDayOfMonth as j,getBusinessDay as I,holidaysOn as T,isBusinessDay as L,isHalfDay as M,isHoliday as w,isWeekday as A,isWeekend as E,lastBusinessDayOfMonth as P,listBusinessDays as F,listHolidays as N,nextBusinessDay as _,nthBusinessDayOfMonth as U,periodRange as Y,previousBusinessDay as K}from"./days.js";import{addBusinessHours as z,diffBusinessHours as G,isWorkingTime as J,nextWorkingTime as Q,slaDeadline as V,workingIntervals as X}from"./hours.js";import{DEFAULT_BUSINESS_DAY_LABELS as $,describeBusinessDay as ss}from"./describe.js";export{$ as DEFAULT_BUSINESS_DAY_LABELS,x as addBusinessDays,z as addBusinessHours,R as adjustBusinessDay,c as businessDayAt,g as businessDayOfMonth,k as businessDaysIn,h as countBusinessDays,C as countHolidays,v as countWeekdays,W as countWeekends,i as createBusinessCalendar,r as customHoliday,a as defaultBusinessCalendar,u as defineHolidays,ss as describeBusinessDay,b as diffBreakdown,G as diffBusinessHours,S as diffDays,l as easterHoliday,f as easterSunday,j as firstBusinessDayOfMonth,D as fixedHoliday,I as getBusinessDay,B as holidayRange,T as holidaysOn,n as isBusinessCalendar,L as isBusinessDay,M as isHalfDay,w as isHoliday,A as isWeekday,E as isWeekend,J as isWorkingTime,P as lastBusinessDayOfMonth,p as lastWeekdayHoliday,F as listBusinessDays,N as listHolidays,o as mergeCalendars,_ as nextBusinessDay,Q as nextWorkingTime,U as nthBusinessDayOfMonth,H as nthWeekdayHoliday,O as oneOffHoliday,Y as periodRange,K as previousBusinessDay,V as slaDeadline,d as weekendForLocale,t as withTags,X as workingIntervals};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{LimitError as g,ValidationError as h}from"../error/index.js";import{toEpochDay as p}from"../date/index.js";const I=864e5,L=6e4;function u(n,t,e){return new h(n,t,e===void 0?{}:{details:{property:e}})}function b(n,t,e){return new g(n,t,{details:{limit:e}})}const f=n=>Array.isArray(n),x=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),k=n=>((n+3)%7+7)%7+1,R=(n,t,e)=>p({kind:"PlainDate",year:n,month:t,day:e}),_=/^(\d{2}):(\d{2})$/;function c(n,t){if(typeof n!="string"||n.length!==5)return;const e=_.exec(n);if(!e)return;const o=Number(e[1]),r=Number(e[2]);if(o===24&&r===0)return t?1440:void 0;if(!(o>23||r>59))return o*60+r}function m(n){const t=e=>String(e).padStart(2,"0");return`${t(Math.floor(n/60))}:${t(n%60)}`}const l=48;function M(n,t){if(!f(n))throw u("HLP_BIZCAL_INVALID_HOURS","Working hours must be an array of [start, end] pairs.",t);if(n.length>l)throw b("HLP_BIZCAL_TOO_MANY_RANGES","Too many working-hour intervals in one day.",l);const e=[];let o=-1;return n.forEach((r,s)=>{const i=`${t}[${String(s)}]`;if(!f(r)||r.length!==2)throw u("HLP_BIZCAL_INVALID_HOURS","Each working-hours entry must be a [start, end] pair.",i);const a=c(r[0],!1),d=c(r[1],!0);if(a===void 0||d===void 0)throw u("HLP_BIZCAL_INVALID_HOURS","Working hours must use HH:mm (24:00 is allowed as an end).",i);if(d<=a)throw u("HLP_BIZCAL_INVALID_HOURS","A working-hours end must be after its start.",i);if(a<o)throw u("HLP_BIZCAL_INVALID_HOURS","Working hours must be sorted and must not overlap.",i);o=d,e.push(Object.freeze([a,d]))}),Object.freeze(e)}function H(n){return Object.freeze(n.map(([t,e])=>Object.freeze([m(t),m(e)])))}function E(n){const t=n.reduce((r,[s,i])=>r+i-s,0);let e=Math.round(t/2);const o=[];for(const[r,s]of n){if(e<=0)break;const i=Math.min(s-r,e);o.push(Object.freeze([r,r+i])),e-=i}return Object.freeze(o)}function N(n,t){let e=0,o=n.length;for(;e<o;){const r=e+o>>>1;(n[r]??0)<t?e=r+1:o=r}return e}function O(n,t){let e=0,o=n.length;for(;e<o;){const r=e+o>>>1;(n[r]??0)<=t?e=r+1:o=r}return e}function y(n,t,e=256){if(n!==void 0){if(typeof n!="string"||n.length>e)throw u("HLP_BIZCAL_INVALID_TEXT","Expected a string of at most 256 characters.",t);return n}}function S(n,t){const e=y(n,t);if(e===void 0||e.trim()==="")throw u("HLP_BIZCAL_INVALID_NAME","A non-empty name is required.",t);return e}export{I as DAY_MS,L as MINUTE_MS,R as epochOf,E as firstHalf,m as formatMinutes,u as invalid,f as isArray,x as isRecord,b as limit,N as lowerBound,M as normalizeRanges,y as optionalText,c as parseTime,H as rangesToText,S as requiredName,O as upperBound,k as weekdayOfEpoch};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{MAX_YEAR as I,daysInMonth as P,fromEpochDay as j,isPlainDate as S,plainDate as W,toEpochDay as D,toPlainDate as U}from"../date/index.js";import{hasOwn as G}from"../internal/keys.js";import{epochOf as x,invalid as i,isArray as E,isRecord as Y,limit as B,normalizeRanges as F,optionalText as K,rangesToText as X,requiredName as q,weekdayOfEpoch as N}from"./internal.js";const p=32,C=3660,$=400,J=new Set(["none","nearest-weekday","next-weekday","previous-weekday"]),Q=/^[1-7]$/;function m(e,n,t,o,l="HLP_BIZCAL_INVALID_RULE"){if(typeof e!="number"||!Number.isInteger(e)||e<n||e>t)throw i(l,"Holiday rule field is out of range.",o);return e}function v(e,n){if(e===void 0)return Object.freeze([]);if(!E(e))throw i("HLP_BIZCAL_INVALID_TAGS","Tags must be an array of strings.",n);if(e.length>p)throw B("HLP_BIZCAL_TOO_MANY_TAGS","Too many tags.",p);const t=e.map(o=>{if(typeof o!="string"||o.length===0||o.length>64)throw i("HLP_BIZCAL_INVALID_TAGS","Tags must be strings of 1 to 64 characters.",n);return o});return Object.freeze([...new Set(t)])}function ee(e,n){if(e===void 0)return"none";if(typeof e=="string"){if(!J.has(e))throw i("HLP_BIZCAL_INVALID_OBSERVED","Unknown observed policy.",n);return e}if(!Y(e))throw i("HLP_BIZCAL_INVALID_OBSERVED","Observed policy must be a name or a weekday map.",n);const t={};for(const o of Object.keys(e)){if(!Q.test(o))throw i("HLP_BIZCAL_INVALID_OBSERVED","Observed map keys must be ISO weekdays 1-7.",n);t[Number(o)]=m(e[o],-7,7,n,"HLP_BIZCAL_INVALID_OBSERVED")}return Object.freeze(t)}function w(e,n){if(typeof e!="string"&&!S(e))throw i("HLP_BIZCAL_INVALID_RULE","Expected a PlainDate or YYYY-MM-DD.",n);try{return U(e)}catch{throw i("HLP_BIZCAL_INVALID_RULE","Expected a PlainDate or YYYY-MM-DD.",n)}}const z=(e,n)=>(e%n+n)%n;function ne(e,n="western"){if(m(e,1,I-1,"year","HLP_BIZCAL_INVALID_YEAR"),n==="orthodox"){const s=e%4,f=e%7,b=(19*(e%19)+15)%30,_=z(2*s+4*f-b+34,7),V=Math.floor((b+_+114)/31),T=(b+_+114)%31+1,Z=Math.floor(e/100)-Math.floor(e/400)-2;return j(x(e,V,T)+Z)}if(n!=="western")throw i("HLP_BIZCAL_INVALID_RULE","Easter method must be western or orthodox.","method");const o=e%19,l=Math.floor(e/100),H=e%100,d=Math.floor(l/4),h=l%4,L=Math.floor((l+8)/25),O=Math.floor((l-L+1)/3),R=(19*o+l-d-O+15)%30,A=Math.floor(H/4),k=H%4,y=z(32+2*h+2*A-R-k,7),c=Math.floor((o+11*R+22*y)/451),r=Math.floor((R+y-7*c+114)/31),a=(R+y-7*c+114)%31+1;return W(e,r,a)}function oe(e,n,t,o){const l=P(e,n);if(o>0){const h=x(e,n,1),L=1+(t-N(h)+7)%7+(o-1)*7;return L<=l?h+L-1:void 0}const H=x(e,n,l),d=l-(N(H)-t+7)%7-(-o-1)*7;return d>=1?H-(l-d):void 0}function M(e,n,t={}){if(!Y(e))throw i("HLP_BIZCAL_INVALID_RULE","A holiday rule must be an object.",n);const o=q(e.name,`${n}.name`),l=K(e.id,`${n}.id`),H=v(e.tags,`${n}.tags`),d=e.kind,h=t.allowProvided===!0&&d!=="range"&&d!=="date"&&G(e,"date"),L=h?"none":ee(e.observed,`${n}.observed`);if(e.halfDay!==void 0&&typeof e.halfDay!="boolean")throw i("HLP_BIZCAL_INVALID_RULE","halfDay must be a boolean.",`${n}.halfDay`);const O=t.forceHalf===!0||e.halfDay===!0,R=e.halfDayHours===void 0?void 0:F(e.halfDayHours,`${n}.halfDayHours`),A=e.fromYear===void 0?-I:m(e.fromYear,-I,I,`${n}.fromYear`),k=e.toYear===void 0?I:m(e.toYear,-I,I,`${n}.toYear`);if(A>k)throw i("HLP_BIZCAL_INVALID_RULE","fromYear must not be after toYear.",`${n}.fromYear`);const y={name:o,id:l,tags:H,observed:L,halfDay:O,halfHours:R,fromYear:A,toYear:k},c={...l===void 0?{}:{id:l},...e.tags===void 0?{}:{tags:H},...e.observed===void 0||h?{}:{observed:L},...O?{halfDay:O}:{},...R===void 0?{}:{halfDayHours:X(R)},...e.fromYear===void 0?{}:{fromYear:A},...e.toYear===void 0?{}:{toYear:k}};if(h){const r=w(e.date,`${n}.date`),a=D(r),s=Object.freeze({date:r,name:o,...c});return Object.freeze({...y,rule:s,kind:"provided",observed:"none",occurrences:void 0,span:Object.freeze([a,a])})}switch(d){case"fixed":{const r=m(e.month,1,12,`${n}.month`),a=m(e.day,1,P(2024,r),`${n}.day`),s=Object.freeze({kind:d,name:o,month:r,day:a,...c});return Object.freeze({...y,rule:s,kind:d,occurrences:u=>a<=P(u,r)?[x(u,r,a)]:[],span:void 0})}case"nth-weekday":{const r=m(e.month,1,12,`${n}.month`),a=m(e.weekday,1,7,`${n}.weekday`),s=m(e.n,-5,5,`${n}.n`);if(s===0)throw i("HLP_BIZCAL_INVALID_RULE","n must be 1..5 or -1..-5.",`${n}.n`);const f=Object.freeze({kind:d,name:o,month:r,weekday:a,n:s,...c});return Object.freeze({...y,rule:f,kind:d,occurrences:b=>{const _=oe(b,r,a,s);return _===void 0?[]:[_]},span:void 0})}case"easter":{const r=e.offsetDays===void 0?0:m(e.offsetDays,-366,366,`${n}.offsetDays`),a=e.method??"western";if(a!=="western"&&a!=="orthodox")throw i("HLP_BIZCAL_INVALID_RULE","Easter method must be western or orthodox.",`${n}.method`);const s=Object.freeze({kind:d,name:o,offsetDays:r,method:a,...c});return Object.freeze({...y,rule:s,kind:d,occurrences:u=>u>=1&&u<I?[D(ne(u,a))+r]:[],span:void 0})}case"date":{const r=w(e.date,`${n}.date`),a=D(r),s=Object.freeze({kind:d,name:o,date:r,...c});return Object.freeze({...y,rule:s,kind:d,occurrences:void 0,span:Object.freeze([a,a])})}case"range":{const r=w(e.start,`${n}.start`),a=w(e.end,`${n}.end`),s=D(r),f=D(a);if(f<s)throw i("HLP_BIZCAL_INVALID_RULE","A holiday range must not end before it starts.",`${n}.end`);if(f-s+1>C)throw B("HLP_BIZCAL_RANGE_TOO_LONG","A holiday range may cover at most 3660 days.",C);const u=Object.freeze({kind:d,name:o,start:r,end:a,...c});return Object.freeze({...y,rule:u,kind:d,occurrences:void 0,span:Object.freeze([s,f])})}case"custom":{const r=e.dates;if(typeof r!="function")throw i("HLP_BIZCAL_INVALID_RULE","A custom rule needs a dates(year) function.",`${n}.dates`);const a=r,s=Object.freeze({kind:d,name:o,dates:a,...c});return Object.freeze({...y,rule:s,kind:d,occurrences:u=>{const b=a(u);if(!E(b))throw i("HLP_BIZCAL_INVALID_RULE","A custom rule must return an array of dates.",`${n}.dates`);if(b.length>$)throw B("HLP_BIZCAL_TOO_MANY_DATES","A custom rule returned too many dates for one year.",$);return b.map(_=>D(w(_,`${n}.dates`)))},span:void 0})}default:throw i("HLP_BIZCAL_INVALID_RULE","Unknown holiday rule kind.",`${n}.kind`)}}function g(e){return M(e,"rule").rule}function se(e,n,t,o={}){return g({...o,kind:"fixed",name:e,month:n,day:t})}function te(e,n,t,o,l={}){return g({...l,kind:"nth-weekday",name:e,month:n,weekday:t,n:o})}function ie(e,n,t,o={}){return te(e,n,t,-1,o)}function le(e,n=0,t={}){return g({...t,kind:"easter",name:e,offsetDays:n})}function ue(e,n,t={}){return g({...t,kind:"date",name:e,date:n})}function ye(e,n,t,o={}){return g({...o,kind:"range",name:e,start:n,end:t})}function ce(e,n,t={}){return g({...t,kind:"custom",name:e,dates:n})}function fe(e){if(!E(e))throw i("HLP_BIZCAL_INVALID_RULE","Expected an array of holiday rules.","rules");return Object.freeze(e.map((n,t)=>M(n,`rules[${String(t)}]`).rule))}export{ce as customHoliday,fe as defineHolidays,le as easterHoliday,ne as easterSunday,se as fixedHoliday,ye as holidayRange,ie as lastWeekdayHoliday,M as normalizeRule,v as normalizeTags,te as nthWeekdayHoliday,ue as oneOffHoliday};
|
package/dist/color/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as $}from"../error/index.js";import{namedColor as P,namedColorNames as G}from"./named.js";const s=(n,t,e)=>n<t?t:n>e?e:n,C=n=>(n%360+360)%360,S=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(%|deg|rad|grad|turn)?$/,q=/^([a-z]+)\(([^()]*)\)$/,z=256;function H(n){if(n==="none")return"none";const t=S.exec(n);if(!t)return;const e=Number(t[1]);return Number.isFinite(e)?{v:e,unit:t[2]??""}:void 0}function _(n){if(n==="none")return 0;switch(n.unit){case"":case"deg":return C(n.v);case"rad":return C(n.v*180/Math.PI);case"grad":return C(n.v*.9);case"turn":return C(n.v*360);default:return}}function V(n){return n===void 0?1:n==="none"?0:n.unit==="%"?s(n.v/100,0,1):n.unit===""?s(n.v,0,1):void 0}function K(n){if(!/^[\da-f]+$/.test(n))return;const t=n.length;if(t===3||t===4){const e=r=>Number.parseInt(n.charAt(r)+n.charAt(r),16);return{r:e(0),g:e(1),b:e(2),alpha:t===4?e(3)/255:1}}if(t===6||t===8){const e=r=>Number.parseInt(n.slice(r,r+2),16);return{r:e(0),g:e(2),b:e(4),alpha:t===8?e(6)/255:1}}}function W(n){if(n.includes(",")){const o=n.split(",").map(a=>a.trim());return o.length!==3&&o.length!==4?void 0:[o.slice(0,3),o[3]]}const t=n.split("/");if(t.length>2)return;const e=(t[0]??"").trim().split(/\s+/);if(e.length!==3)return;const r=t[1]?.trim();if(r!=="")return[e,r]}function J(n){if(n.length>z)return;const t=n.trim().toLowerCase();if(t.startsWith("#"))return K(t.slice(1));if(t==="transparent")return{r:0,g:0,b:0,alpha:0};const e=P(t);if(e!==void 0)return{r:e>>>16,g:e>>>8&255,b:e&255,alpha:1};const r=q.exec(t);if(!r)return;const o=r[1]??"",a=W(r[2]??"");if(!a)return;const i=a[0].map(H),[u,l,f]=i;if(u===void 0||l===void 0||f===void 0)return;const p=a[1]===void 0?void 0:H(a[1]);if(a[1]!==void 0&&p===void 0)return;const m=V(p);if(m!==void 0){if(o==="rgb"||o==="rgba"){const c=g=>g==="none"?0:g.unit==="%"?s(g.v*255/100,0,255):g.unit===""?s(g.v,0,255):void 0,b=c(u),h=c(l),y=c(f);return b===void 0||h===void 0||y===void 0?void 0:{r:b,g:h,b:y,alpha:m}}if(o==="hsl"||o==="hsla"){const c=g=>g==="none"?0:g.unit==="%"||g.unit===""?s(g.v,0,100):void 0,b=_(u),h=c(l),y=c(f);return b===void 0||h===void 0||y===void 0?void 0:j({h:b,s:h,l:y,alpha:m})}if(o==="oklch"){const c=u==="none"?0:u.unit==="%"?u.v/100:u.unit===""?u.v:void 0,b=l==="none"?0:l.unit==="%"?l.v/100*.4:l.unit===""?l.v:void 0,h=_(f);return c===void 0||b===void 0||h===void 0?void 0:v({l:s(c,0,1),c:Math.max(0,b),h,alpha:m})}}}function U(n){const t=J(n);if(!t)throw new $("HLP_COLOR_INVALID","The colour is not valid.");return t}function d(n){if(typeof n=="string")return U(n);const{r:t,g:e,b:r}=n,o=n.alpha??1;if(![t,e,r,o].every(Number.isFinite))throw new $("HLP_COLOR_INVALID","The colour is not valid.");return{r:s(t,0,255),g:s(e,0,255),b:s(r,0,255),alpha:s(o,0,1)}}function on(){return G()}const x=(n,t)=>String(Number(n.toFixed(t))),O=n=>Math.round(s(n,0,255)).toString(16).padStart(2,"0");function an(n,t={}){const e=d(n),r=t.alpha??"auto",o=r==="always"||r==="auto"&&e.alpha<1;return`#${O(e.r)}${O(e.g)}${O(e.b)}${o?O(e.alpha*255):""}`}function un(n,t={}){const e=d(n),[r,o,a]=[e.r,e.g,e.b].map(u=>Math.round(u)),i=x(e.alpha,3);return t.legacy===!0?e.alpha<1?`rgba(${r}, ${o}, ${a}, ${i})`:`rgb(${r}, ${o}, ${a})`:e.alpha<1?`rgb(${r} ${o} ${a} / ${i})`:`rgb(${r} ${o} ${a})`}function ln(n){const t=X(d(n)),e=t.alpha<1?` / ${x(t.alpha,3)}`:"";return`hsl(${x(t.h,2)} ${x(t.s,2)}% ${x(t.l,2)}%${e})`}function sn(n){const t=M(d(n)),e=t.alpha<1?` / ${x(t.alpha,3)}`:"";return`oklch(${x(t.l*100,3)}% ${x(t.c,5)} ${x(t.h,3)}${e})`}function X(n){const t=n.r/255,e=n.g/255,r=n.b/255,o=Math.max(t,e,r),a=Math.min(t,e,r),i=(o+a)/2,u=o-a;let l=0,f=0;return u>1e-12&&(f=i===0||i===1?0:u/(1-Math.abs(2*i-1)),o===t?l=(e-r)/u%6:o===e?l=(r-t)/u+2:l=(t-e)/u+4,l=C(l*60)),{h:l,s:f*100,l:i*100,alpha:n.alpha}}function j(n){const t=s(n.s,0,100)/100,e=s(n.l,0,100)/100,r=C(n.h),o=a=>{const i=(a+r/30)%12,u=t*Math.min(e,1-e);return(e-u*Math.max(-1,Math.min(i-3,9-i,1)))*255};return{r:o(0),g:o(8),b:o(4),alpha:s(n.alpha,0,1)}}const I=n=>n<=.04045?n/12.92:((n+.055)/1.055)**2.4,B=n=>n<=.0031308?n*12.92:1.055*n**(1/2.4)-.055;function T(n){return w(I(n.r/255),I(n.g/255),I(n.b/255))}function w(n,t,e){const r=Math.cbrt(.4122214708*n+.5363325363*t+.0514459929*e),o=Math.cbrt(.2119034982*n+.6806995451*t+.1073969566*e),a=Math.cbrt(.0883024619*n+.2817188376*t+.6299787005*e);return{l:.2104542553*r+.793617785*o-.0040720468*a,a:1.9779984951*r-2.428592205*o+.4505937099*a,b:.0259040371*r+.7827717662*o-.808675766*a}}function k(n,t,e){const r=e*Math.PI/180,o=t*Math.cos(r),a=t*Math.sin(r),i=(n+.3963377774*o+.2158037573*a)**3,u=(n-.1055613458*o-.0638541728*a)**3,l=(n-.0894841775*o-1.291485548*a)**3;return[4.0767416621*i-3.3077115913*u+.2309699292*l,-1.2684380046*i+2.6097574011*u-.3413193965*l,-.0041960863*i-.7034186147*u+1.707614701*l]}const A=1e-4;function M(n){const t=T(n),e=Math.hypot(t.a,t.b),r=e<A?0:C(Math.atan2(t.b,t.a)*180/Math.PI);return{l:t.l,c:e,h:r,alpha:n.alpha}}const R=1e-6,Q=.02;function Y(n,t,e,r){const[o=0,a=0,i=0]=n.map(f=>s(f,0,1)),u=w(o,a,i),l=r*Math.PI/180;return Math.hypot(u.l-t,u.a-e*Math.cos(l),u.b-e*Math.sin(l))<Q}const D=n=>n.every(t=>t>=-R&&t<=1+R);function v(n,t={}){const e=s(n.l,0,1),r=s(n.alpha,0,1);let o=Math.max(0,n.c);const a=C(n.h);if(e>=1-R)return{r:255,g:255,b:255,alpha:r};if(e<=R)return{r:0,g:0,b:0,alpha:r};let i=k(e,o,a);if(!D(i)&&t.gamut!=="clip"&&!Y(i,e,o,a)){let p=0,m=o;for(let c=0;c<24;c++){const b=(p+m)/2;D(k(e,b,a))?p=b:m=b}o=p,i=k(e,o,a)}const[u,l,f]=i.map(p=>s(B(s(p,0,1)),0,1)*255);return{r:u,g:l,b:f,alpha:r}}function L(n){const t=d(n);return .2126*I(t.r/255)+.7152*I(t.g/255)+.0722*I(t.b/255)}function N(n,t){const e=d(n),r=d(t),o=e.alpha+r.alpha*(1-e.alpha);if(o<=0)return{r:0,g:0,b:0,alpha:0};const a=(i,u)=>(i*e.alpha+u*r.alpha*(1-e.alpha))/o;return{r:a(e.r,r.r),g:a(e.g,r.g),b:a(e.b,r.b),alpha:o}}const E={r:255,g:255,b:255,alpha:1};function F(n,t){let e=d(t);e.alpha<1&&(e=N(e,E));let r=d(n);r.alpha<1&&(r=N(r,e));const o=L(r),a=L(e);return(Math.max(o,a)+.05)/(Math.min(o,a)+.05)}function cn(n,t,e={}){const{level:r="AA",size:o="normal"}=e,a=o==="non-text"?3:r==="AAA"?o==="large"?4.5:7:o==="large"?3:4.5;return F(n,t)>=a}function fn(n,t=["#000000","#ffffff"]){let e,r=-1;for(const o of t){const a=F(o,n);a>r&&(r=a,e=o)}if(e===void 0)throw new $("HLP_COLOR_NO_CANDIDATES","At least one candidate colour is required.");return e}const Z=Math.sqrt(1.05*.05)-.05;function nn(n){let t=d(n);return t.alpha<1&&(t=N(t,E)),L(t)<Z}function dn(n){return!nn(n)}function bn(n,t,e=.5,r={}){const o=s(Number.isFinite(e)?e:.5,0,1),a=d(n),i=d(t),u=(b,h)=>b+(h-b)*o;if(r.space==="srgb")return{r:u(a.r,i.r),g:u(a.g,i.g),b:u(a.b,i.b),alpha:u(a.alpha,i.alpha)};const l=M(a),f=M(i);let p=l.h,m=f.h;l.c<A&&(p=m),f.c<A&&(m=p);let c=m-p;return c>180?c-=360:c<-180&&(c+=360),v({l:u(l.l,f.l),c:u(l.c,f.c),h:p+c*o,alpha:u(a.alpha,i.alpha)},r)}function en(n,t=.1,e={}){const r=M(d(n));return v({...r,l:s(r.l+t,0,1)},e)}function pn(n,t=.1,e={}){return en(n,-t,e)}function mn(n,t){return{...d(n),alpha:s(Number.isFinite(t)?t:1,0,1)}}function hn(n,t){const e=T(d(n)),r=T(d(t));return Math.hypot(e.l-r.l,e.a-r.a,e.b-r.b)}export{fn as bestTextColor,hn as colorDistance,N as compositeOver,F as contrastRatio,on as cssColorNames,pn as darken,an as formatHex,ln as formatHsl,sn as formatOklch,un as formatRgb,j as hslToRgb,nn as isDark,dn as isLight,en as lighten,cn as meetsContrast,bn as mix,v as oklchToRgb,J as parseColor,U as parseColorOrThrow,L as relativeLuminance,X as rgbToHsl,M as rgbToOklch,mn as withAlpha};
|
package/dist/color/named.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
const r="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32";let e;function l(d){if(!e){e=new Map;const a=r.split(" ");for(let f=0;f+1<a.length;f+=2)e.set(a[f]??"",Number.parseInt(a[f+1]??"0",16))}return e.get(d)}function i(){return l("black"),[...e?.keys()??[]]}export{l as namedColor,i as namedColorNames};
|
package/dist/compare/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{deepEqual as y}from"../object/index.js";const f=n=>n<0?-1:n>0?1:0;function i(n){if(n==null)return-1;switch(typeof n){case"boolean":return 1;case"number":return Number.isNaN(n)?-1:2;case"bigint":return 2;case"string":return 3;default:return n instanceof Date?Number.isNaN(n.getTime())?-1:4:5}}function T(n,e,r){const o=i(n),t=i(e);return o!==t?o-t:typeof n=="string"&&typeof e=="string"?r?f(r.compare(n,e)):n<e?-1:n>e?1:0:n instanceof Date&&e instanceof Date?f(n.getTime()-e.getTime()):(typeof n=="number"||typeof n=="bigint")&&(typeof e=="number"||typeof e=="bigint")?n<e?-1:n>e?1:0:typeof n=="boolean"&&typeof e=="boolean"?Number(n)-Number(e):0}function m(n,e,r,o){const t=i(n)===-1,u=i(e)===-1;if(t||u){if(t&&u){const a=l=>l===null?0:l===void 0?1:2;return f(a(n)-a(e))}return(t?-1:1)*(r==="first"?1:-1)}return o()}function p(n,e,r={}){const{nulls:o="last",collator:t}=r;return m(n,e,o,()=>T(n,e,t))}function x(n,e={}){const{direction:r="asc",nulls:o="last",collator:t}=e,u=r==="desc"?-1:1;return(a,l)=>{const s=n(a),c=n(l);return m(s,c,o,()=>u*T(s,c,t))}}function R(n,e,r={}){const o=x(e,r);return(t,u)=>n(t,u)||o(t,u)}function O(...n){return(e,r)=>{for(const o of n){const t=o(e,r);if(t!==0)return t}return 0}}function k(n){return(e,r)=>-n(e,r)||0}const d=new Map;function h(n,e){const r=`${Array.isArray(n)?n.join(","):String(n??"")}|${e??""}`;let o=d.get(r);return o||(d.size>=32&&d.clear(),o=new Intl.Collator(n,{numeric:!0,...e?{sensitivity:e}:{}}),d.set(r,o)),o}function N(n,e,r={}){return f(h(r.locale,r.sensitivity).compare(n,e))}function b(n,e,r={}){return r.deep?y(n,e):n===e||Number.isNaN(n)&&Number.isNaN(e)}function v(n,e,r,o={}){const t=o.inclusive??"both",u=t===!0?"both":t===!1?"none":t;if(i(n)===-1||i(e)===-1||i(r)===-1)return!1;const a=T(n,e,o.collator),l=T(n,r,o.collator),s=u==="both"||u==="left"?a>=0:a>0,c=u==="both"||u==="right"?l<=0:l<0;return s&&c}function B(n,e,r){return n>=e&&n<r}function A(...n){for(const e of n)if(e!=null)return e}function I(...n){for(const e of n)if(e!=null&&!(typeof e=="string"&&e.trim()===""))return e}function M(n){let e=!1,r;const o={with(t,u){return e||(typeof t=="function"?t(n):b(t,n))&&(e=!0,r=u(n)),o},otherwise(t){return e?r:t(n)}};return o}function D(n,e){return r=>n(r)?e(r):r}function P(n,e){return r=>n(r)?r:e(r)}function q(n,e){return r=>{for(const[o,t]of n)if(o(r))return t(r);return e?.(r)}}function E(n,e,r){return o=>n(o)?e(o):r(o)}function U(n,e={}){return(r,o)=>b(n(r),n(o),e)}function g(n,e=p){let r,o=!1;for(const t of n)(!o||e(t,r)<0)&&(r=t,o=!0);return r}function $(n,e=p){return g(n,(r,o)=>e(o,r))}function j(n){return e=>n.every(r=>r(e))}function z(n){return e=>n.some(r=>r(e))}function S(n){return e=>!n.some(r=>r(e))}function V(n){return e=>{let r=0;for(const o of n)if(o(e)&&++r>1)return!1;return r===1}}function F(n){return(...e)=>!n(...e)}function w(n,e={}){const{comparer:r=p,strict:o=!1}=e;for(let t=1;t<n.length;t++){const u=r(n[t-1],n[t]);if(u>0||o&&u===0)return!1}return!0}function G(n,e={}){const{comparer:r=p,strict:o=!1}=e;return w(n,{comparer:(t,u)=>r(u,t),strict:o})}export{j as allPass,z as anyPass,v as between,x as by,A as coalesce,I as coalesceBlank,p as compareValues,F as complement,O as composeComparers,q as cond,b as equals,E as ifElse,B as inRange,w as isAscending,G as isDescending,U as isEqualBy,M as match,$ as maxOf,g as minOf,N as naturalCompare,S as nonePass,V as onePass,k as reverseComparer,R as thenBy,P as unless,D as when};
|
package/dist/convert/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as g,err as j,ok as F}from"../error/index.js";import{isPlainObject as x}from"../is/index.js";import{assertSafeKey as V,hasOwn as B,isUnsafeKey as L}from"../internal/keys.js";import{daysInMonth as $}from"../date/plain-date.js";import{parseBoolean as H}from"../boolean/index.js";const C=1e3,U=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,k=/[\u061c\u200e\u200f]/g,b=new Map;function G(n){let e=b.get(n);if(e)return e;const t=new Intl.NumberFormat(n,{useGrouping:!0}).formatToParts(-12345.6),o=(s,u)=>(t.find(d=>d.type===s)?.value??u).replace(k,""),r=new Intl.NumberFormat(n,{useGrouping:!1}),i=new Map;for(let s=0;s<=9;s++)i.set(r.format(s).replace(k,""),String(s));return e={group:o("group",","),decimal:o("decimal","."),minus:o("minusSign","-"),digits:i},b.size>=32&&b.clear(),b.set(n,e),e}const E=new Set([" ","\xA0","\u202F","\u2009"]);function X(n,e){const{group:t,decimal:o,minus:r,digits:i}=G(e),s=E.has(t);let u="";for(const d of n.replace(k,"")){const f=i.get(d);if(f!==void 0)u+=f;else if(d===o)u+=".";else{if(d===t||s&&E.has(d))continue;d===r||d==="\u2212"?u+="-":u+=d}}return u}function S(n,e={}){if(typeof n=="number")return Number.isFinite(n)?n:void 0;if(typeof n=="bigint"){const r=Number(n);return Number.isSafeInteger(r)?r:void 0}if(typeof n!="string"||n.length>C)return;let t=n.trim();if(e.locale!==void 0?t=X(t,e.locale):t.startsWith("\u2212")&&(t=`-${t.slice(1)}`),!U.test(t))return;const o=Number(t);return Number.isFinite(o)?o:void 0}function W(n,e){switch(e){case"none":return Number.isInteger(n)?n:void 0;case"trunc":return Math.trunc(n);case"floor":return Math.floor(n);case"ceil":return Math.ceil(n);case"round":return Math.sign(n)*Math.round(Math.abs(n));case"half-even":{const t=Math.floor(n),o=n-t;return o!==.5?o<.5?t:t+1:t%2===0?t:t+1}}}function N(n,e={}){const t=S(n,e);if(t===void 0)return;const o=W(t,e.rounding??"none");return o===void 0?void 0:o+0}function z(n,e={}){const t=N(n,e);return t!==void 0&&Number.isSafeInteger(t)?t:void 0}const Y=/^[+-]?\d+$/;function Z(n){if(typeof n=="bigint")return n;if(typeof n=="number")return Number.isInteger(n)?BigInt(n):void 0;if(typeof n!="string"||n.length>10001)return;const e=n.trim();return Y.test(e)?BigInt(e):void 0}function q(n,e={}){return H(n,e)}const J=864e13,Q=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:\d{2})?)?$/;function v(n){if(n.length<10||n.length>40)return;const e=Q.exec(n);if(!e)return;const[,t="",o="",r="",i,s="0",u="0",d="",f]=e;if(t==="-000000")return;const c=Number(t),a=Number(o),m=Number(r),y=Number(i??"0"),l=Number(s),w=Number(u),h=Math.floor(+`0.${d||"0"}`*1e3);if(a<1||a>12||m<1||m>$(c,a)||y>23||l>59||w>59)return;const p=new Date(0);if(i!==void 0&&f===void 0)p.setFullYear(c,a-1,m),p.setHours(y,l,w,h);else{let M=0;if(f!==void 0&&f!=="Z"){const O=Number(f.slice(1,3)),R=Number(f.slice(4,6));if(O>23||R>59)return;M=(f.startsWith("-")?-1:1)*(O*60+R)}p.setUTCFullYear(c,a-1,m),p.setUTCHours(y,l-M,w,h)}const I=p.getTime();return Number.isNaN(I)?void 0:I}function K(n){if(n instanceof Date)return Number.isNaN(n.getTime())?void 0:new Date(n.getTime());if(typeof n=="number")return Number.isFinite(n)&&Math.abs(n)<=J?new Date(n):void 0;if(typeof n!="string")return;const e=v(n.trim());return e===void 0?void 0:new Date(e)}function _(n,e,t){e==="__proto__"?Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0}):n[e]=t}function A(n){const e=new Set,t=r=>{if(typeof r=="bigint"||typeof r=="symbol")return r.toString();if(typeof r!="object"||r===null)return r;if(r instanceof Date)return Number.isNaN(r.getTime())?null:r.toISOString();if(e.has(r))return"[Circular]";e.add(r);let i;if(Array.isArray(r))i=r.map(t);else if(r instanceof Map)i=[...r].map(([s,u])=>[t(s),t(u)]);else if(r instanceof Set)i=[...r].map(t);else{const s={};for(const u of Object.keys(r))_(s,u,t(r[u]));i=s}return e.delete(r),i};return JSON.stringify(t(n))??""}function nn(n){switch(typeof n){case"string":return n;case"number":return Object.is(n,-0)?"0":String(n);case"bigint":case"boolean":return String(n);case"symbol":return n.toString();case"undefined":return"";case"function":return n.name?`[Function: ${n.name}]`:"[Function]";default:break}if(n===null)return"";if(n instanceof Date)return Number.isNaN(n.getTime())?"":n.toISOString();if(n instanceof Error)return n.message?`${n.name}: ${n.message}`:n.name;if(n instanceof RegExp)return n.toString();if(Array.isArray(n)||x(n)||n instanceof Map||n instanceof Set)return A(n);const e=n.toString;if(typeof e=="function"&&e!==Object.prototype.toString){const t=e.call(n);if(typeof t=="string")return t}return A(n)}const T=n=>typeof n=="object"&&n!==null&&typeof n[Symbol.iterator]=="function";function D(n){return n==null?[]:Array.isArray(n)?n.slice():T(n)?Array.from(n):[n]}function un(n){return new Set(D(n))}function fn(n){if(n==null)return new Map;if(n instanceof Map)return new Map(n);if(x(n))return new Map(Object.entries(n));if(T(n)&&typeof n!="string"){const e=new Map;for(const t of n){if(!Array.isArray(t)||t.length!==2)return;e.set(t[0],t[1])}return e}}function dn(n){if(typeof n!="object"||n===null)return;const e={};if(n instanceof Map||T(n)){const t=(n instanceof Map,n);for(const o of t){if(!Array.isArray(o)||o.length!==2)return;const[r,i]=o;if(typeof r!="string"&&typeof r!="number")return;const s=String(r);if(L(s))return;e[s]=i}return e}for(const t of Object.keys(n))_(e,t,n[t]);return e}function cn(n,e={}){const t=S(n,e);if(t===void 0)throw new g("HLP_CONVERT_NUMBER","Expected a number.");return t}function an(n,e={}){const t=N(n,e);if(t===void 0)throw new g("HLP_CONVERT_INTEGER","Expected an integer.");return t}function pn(n){const e=K(n);if(e===void 0)throw new g("HLP_CONVERT_DATE","Expected an ISO 8601 date.");return e}function gn(n,e=10){if(!Number.isInteger(e)||e<2||e>36)throw new g("HLP_CONVERT_RADIX","The radix must be an integer from 2 to 36.");if(typeof n!="string"||n.length===0||n.length>C)return;const t=n.startsWith("-")||n.startsWith("+")?1:0;if(t===n.length)return;for(let r=t;r<n.length;r++){const i=n.charCodeAt(r),s=i|32;if((i>=48&&i<=57?i-48:s>=97&&s<=122?s-87:99)>=e)return}const o=Number.parseInt(n,e);return Number.isSafeInteger(o)?o+0:void 0}const P={string:n=>typeof n=="string"?n:typeof n=="number"||typeof n=="bigint"||typeof n=="boolean"||n instanceof Date?nn(n):void 0,number:n=>S(n),integer:n=>N(n),"safe-integer":n=>z(n),bigint:Z,boolean:n=>q(n),date:K,array:n=>D(n)};function mn(n,e){return P[e](n)}function bn(n,e){const t=typeof n=="object"&&n!==null?n:{},o={},r={};for(const[i,s]of Object.entries(e)){V(i);const u=typeof s=="string"?s:s.kind,d=typeof s=="string"?!1:s.optional===!0,f=B(t,i)?t[i]:void 0;if(f==null||typeof f=="string"&&f.trim()===""){d?o[i]=void 0:r[i]="Required.";continue}const c=P[u](f);c===void 0?r[i]=`Expected ${u}.`:o[i]=c}return Object.keys(r).length?j(new g("HLP_CONVERT_FIELDS","One or more fields are invalid.",{fields:r})):F(o)}export{mn as coerce,bn as coerceFields,gn as parseIntStrict,D as toArray,Z as toBigInt,q as toBoolean,K as toDate,pn as toDateOrThrow,N as toInteger,an as toIntegerOrThrow,fn as toMap,S as toNumber,cn as toNumberOrThrow,dn as toPlainObject,z as toSafeInteger,un as toSet,nn as toStringSafe};
|
package/dist/csv/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{parseCsv as t,createCsvParser as r,detectDelimiter as p}from"./parse.js";import{stringifyCsv as i,escapeCsvCell as v,isFormulaLike as o}from"./stringify.js";export{r as createCsvParser,p as detectDelimiter,v as escapeCsvCell,o as isFormulaLike,t as parseCsv,i as stringifyCsv};
|
package/dist/csv/parse.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{LimitError as _,ValidationError as y}from"../error/index.js";import{isUnsafeKey as x}from"../internal/keys.js";const E=[",",";"," ","|"];function S(h,t=E,o='"'){const i=h.length>65536?h.slice(0,65536):h,a=t.map(()=>[]);let s=t.map(()=>0),r=!1,u=0;for(let d=0;d<i.length&&u<10;d++){const c=i.charAt(d);if(c===o)r=!r;else if(!r&&(c===`
|
|
3
3
|
`||c==="\r"))c==="\r"&&i.charAt(d+1)===`
|
|
4
4
|
`&&d++,a.forEach((f,g)=>f.push(s[g]??0)),s=t.map(()=>0),u++;else if(!r){const f=t.indexOf(c);f>=0&&(s[f]=(s[f]??0)+1)}}u<10&&s.some(d=>d>0)&&a.forEach((d,c)=>d.push(s[c]??0));let n=",",e=-1;return t.forEach((d,c)=>{const f=(a[c]??[]).filter((m,p,k)=>m>0||p<k.length-1);if(f.length===0||f.every(m=>m===0))return;const g=new Map;for(const m of f)g.set(m,(g.get(m)??0)+1);let C=0,v=0;for(const[m,p]of g)m>0&&(p>C||p===C&&m>v)&&([v,C]=[m,p]);const L=C/f.length*1e3+Math.min(v,999);v>0&&L>e&&([n,e]=[d,L])}),n}const l={FieldStart:0,Unquoted:1,Quoted:2,QuoteInQuoted:3,AfterQuoted:4,Comment:5};class P{state=l.FieldStart;lastWasCr=!1;recordErrors=[];field="";record=[];anyQuoted=!1;skipLf=!1;line=1;recordLine=1;started=!1;delimiter;quote;trim;comment;limits;onRecord;constructor(t,o,i,a,s,r){this.delimiter=t,this.quote=o,this.trim=i,this.comment=a,this.limits=s,this.onRecord=r}onError(t){this.recordErrors.push(t)}checkField(t){if(this.field.length+t>this.limits.maxFieldLength)throw new _("HLP_CSV_FIELD_TOO_LONG","A CSV field exceeds the length limit.",{details:{maxFieldLength:this.limits.maxFieldLength}})}endField(){if(this.checkField(0),this.record.push(this.state===l.Unquoted&&this.trim?this.field.trimEnd():this.field),this.record.length>this.limits.maxColumns)throw new _("HLP_CSV_TOO_MANY_COLUMNS","A CSV record has too many fields.",{details:{maxColumns:this.limits.maxColumns}});this.field=""}endRecord(){const t=this.record,o=!this.anyQuoted&&t.length===1&&t[0]==="",i=this.recordErrors;this.record=[],this.recordErrors=[],this.anyQuoted=!1,this.onRecord(t,{line:this.recordLine,blank:o,errors:i})}push(t,o){let i=t;!this.started&&i.length>0&&(this.started=!0,i.charCodeAt(0)===65279&&(i=i.slice(1)));const{delimiter:a,quote:s}=this;let r=-1;const u=n=>{r>=0&&(this.checkField(n-r),this.field+=i.slice(r,n),r=-1)};for(let n=0;n<i.length;n++){const e=i.charAt(n);if(!(this.skipLf&&(this.skipLf=!1,e===`
|
package/dist/csv/stringify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as x}from"../error/index.js";const w=new Set([61,43,45,64,9,13,65309,65291,65293,65312]);function T(n){return n.length>0&&w.has(n.charCodeAt(0))}function C(n,t={}){const{delimiter:s=",",quote:a="minimal",injectionProtection:c=!0}=t,r=c&&T(n)?`'${n}`:n;return a==="all"||r.includes(s)||r.includes('"')||r.includes(`
|
|
3
3
|
`)||r.includes("\r")||r.length>0&&(r.charCodeAt(0)===32||r.charCodeAt(r.length-1)===32)?`"${r.replaceAll('"','""')}"`:r}function O(n){if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return String(n);if(n instanceof Date)return Number.isNaN(n.getTime())?"":n.toISOString();if(typeof n=="symbol"||typeof n=="function")return"";try{const t=JSON.stringify(n,(s,a)=>typeof a=="bigint"?a.toString():a);return typeof t=="string"?t:""}catch{return""}}function A(n,t={}){const{delimiter:s=",",quote:a="minimal",injectionProtection:c=!0,eol:r=`\r
|
|
4
4
|
`,bom:y=!1,trailingEol:b=!0}=t;if(s.length!==1||s==='"'||s===`
|
package/dist/date/calendar.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as I}from"../error/index.js";import{comparePlainDates as f,daysBetween as Y,daysInMonth as O,isLeapYear as S,isoWeekday as w,plainDate as p,toEpochDay as c,toPlainDate as o,today as y,addDays as d}from"./plain-date.js";function D(e,t){if(!Number.isSafeInteger(e))throw new I("HLP_DATE_OUT_OF_RANGE","Amount must be a safe integer.",{details:{property:t}})}function T(e,t="firstDayOfWeek"){if(!Number.isInteger(e)||e<1||e>7)throw new I("HLP_DATE_INVALID_WEEKDAY","Weekday must be an integer 1 (Monday) to 7 (Sunday).",{details:{property:t}})}function Q(e,t){if(!Number.isInteger(e)||e<1||e>12)throw new I("HLP_DATE_INVALID_MONTH","Month must be an integer 1 to 12.",{details:{property:t}})}const P=e=>{const t=e.firstDayOfWeek??1;return T(t),t};function H(e,t){return D(t,"weeks"),d(e,t*7)}function l(e,t){D(t,"months");const n=o(e),r=n.year*12+(n.month-1)+t,a=Math.floor(r/12),u=r-a*12+1;return p(a,u,Math.min(n.day,O(a,u)))}function V(e,t){return D(t,"quarters"),l(e,t*3)}function $(e,t){return D(t,"years"),l(e,t*12)}function X(e,t){return D(t,"days"),d(e,0-t)}function Z(e,t){return D(t,"weeks"),H(e,0-t)}function tt(e,t){return D(t,"months"),l(e,0-t)}function et(e,t){return D(t,"quarters"),V(e,0-t)}function nt(e,t){return D(t,"years"),$(e,0-t)}function x(e,t={}){const n=P(t),r=o(e);return d(r,0-(w(r)-n+7)%7)}function rt(e,t={}){return d(x(e,t),6)}function at(e){const t=o(e);return p(t.year,t.month,1)}function B(e){const t=o(e);return p(t.year,t.month,O(t.year,t.month))}function k(e){return Math.floor((o(e).month-1)/3)+1}function v(e){const t=o(e);return p(t.year,(k(t)-1)*3+1,1)}function ot(e){return B(l(v(e),2))}function ut(e){return p(o(e).year,1,1)}function it(e){return p(o(e).year,12,31)}function W(e,t){return e.month>=t?e.year:e.year-1}function h(e){const t=e.startMonth??1;return Q(t,"startMonth"),t}function _(e,t={}){const n=h(t);return p(W(o(e),n),n,1)}function st(e,t={}){return d(l(_(e,t),12),-1)}function R(e,t={}){const n=h(t),r=W(o(e),n);return n===1||t.naming==="start"?r:r+1}function A(e,t={}){const n=h(t);return Math.floor((o(e).month-n+12)%12/3)+1}function j(e,t={}){return l(_(e,t),(A(e,t)-1)*3)}function ft(e,t={}){return d(l(j(e,t),3),-1)}function pt(e,t={}){const n=t.prefix??"FY";if(t.style==="span"){const r=h(t),a=W(o(e),r),u=r===1?a:a+1;return u===a?`${n}${String(a)}`:`${n}${String(a)}-${String((u%100+100)%100).padStart(2,"0")}`}return`${n}${String(R(e,t))}`}function ct(e,t={}){return`Q${String(A(e,t))}`}function F(e,t){return f(e,t)===0}function Dt(e,t,n={}){return F(x(e,n),x(t,n))}function lt(e,t){const n=o(e),r=o(t);return n.year===r.year&&n.month===r.month}function It(e,t){return o(e).year===o(t).year&&k(e)===k(t)}function dt(e,t){return o(e).year===o(t).year}function z(e,t){return f(e,t)<0}function G(e,t){return f(e,t)>0}function mt(e,t,n,r={}){const a=c(o(e)),u=c(o(t)),i=c(o(n));if(i<u)throw new I("HLP_DATE_INVALID_INTERVAL","Interval end is before its start.");const s=r.inclusive??"both",b=s==="both"||s==="start"?a>=u:a>u,N=s==="both"||s==="end"?a<=i:a<i;return b&&N}function bt(e,t){return F(e,y(t))}function yt(e,t){return z(e,y(t))}function xt(e,t){return G(e,y(t))}function ht(e){let t;for(const n of e){const r=o(n);(!t||f(r,t)<0)&&(t=r)}return t}function Ot(e){let t;for(const n of e){const r=o(n);(!t||f(r,t)>0)&&(t=r)}return t}function Pt(e,t){const n=o(t.start),r=o(t.end);if(f(r,n)<0)throw new I("HLP_DATE_INVALID_INTERVAL","Interval end is before its start.");const a=o(e);return f(a,n)<0?n:f(a,r)>0?r:a}function kt(e,t){const n=c(o(e));let r,a=1/0;for(const u of t){const i=o(u),s=Math.abs(c(i)-n);s<a&&(r=i,a=s)}return r}function q(e,t){return Y(t,e)}function Wt(e,t){return Math.trunc(q(e,t)/7)+0}function g(e,t){let n=(t.year-e.year)*12+(t.month-e.month);return Math.min(e.day,O(t.year,t.month))>t.day&&(n-=1),n}function M(e,t){const n=o(e),r=o(t);return f(n,r)>=0?g(r,n):0-g(n,r)}function gt(e,t){return M(e,t)}function Mt(e,t){return Math.trunc(M(e,t)/3)+0}function Yt(e,t){return Math.trunc(M(e,t)/12)+0}function K(e,t){const n=o(e),r=o(t);if(f(r,n)<0){const u=K(r,n);return Object.freeze({years:0-u.years,months:0-u.months,days:0-u.days})}const a=g(n,r);return Object.freeze({years:Math.floor(a/12),months:a%12,days:Y(l(n,a),r)})}function wt(e,t=y(),n={}){const r=o(e),a=o(t);if(f(a,r)<0)throw new I("HLP_DATE_AGE_BEFORE_BIRTH","The reference date is before the birth date.");let u=r.day;r.month===2&&r.day===29&&!S(a.year)&&(n.leapDayBirthday??"feb28")==="feb28"&&(u=28);let i=a.year-r.year;return(a.month<r.month||a.month===r.month&&a.day<u)&&(i-=1),i}function m(e,t,n){return c(x(p(e,1,n),{firstDayOfWeek:t}))}function L(e){const t=P(e),n=e.minimalDays??4;if(!Number.isInteger(n)||n<1||n>7)throw new I("HLP_DATE_INVALID_MINIMAL_DAYS","minimalDays must be an integer 1 to 7.");return[t,n]}function E(e,t={}){const[n,r]=L(t),a=o(e),u=c(a);let i=a.year,s=m(i,n,r);if(u<s)i-=1,s=m(i,n,r);else{const b=m(i+1,n,r);u>=b&&(i+=1,s=b)}return Object.freeze({week:Math.floor((u-s)/7)+1,year:i})}function U(e,t={}){const[n,r]=L(t);return(m(e+1,n,r)-m(e,n,r))/7}function _t(e){return E(e).week}function At(e){return E(e).year}function Ft(e){return U(e)}function Lt(e,t={}){const n=P(t),r=o(e),a=(w(p(r.year,r.month,1))-n+7)%7;return Math.floor((r.day-1+a)/7)+1}function Et(e){const t=o(e);return c(t)-c(p(t.year,1,1))+1}export{l as addMonths,V as addQuarters,H as addWeeks,$ as addYears,wt as age,T as assertIsoWeekday,Pt as clampDate,kt as closestTo,K as dateDiff,Et as dayOfYear,q as differenceInDays,gt as differenceInMonths,Mt as differenceInQuarters,Wt as differenceInWeeks,Yt as differenceInYears,ft as endOfFiscalQuarter,st as endOfFiscalYear,B as endOfMonth,ot as endOfQuarter,rt as endOfWeek,it as endOfYear,ct as fiscalQuarterLabel,A as fiscalQuarterOf,pt as fiscalYearLabel,R as fiscalYearOf,G as isAfter,z as isBefore,mt as isBetween,xt as isFuture,yt as isPast,F as isSameDay,lt as isSameMonth,It as isSameQuarter,Dt as isSameWeek,dt as isSameYear,bt as isToday,_t as isoWeek,At as isoWeekYear,Ft as isoWeeksInYear,Ot as maxDate,ht as minDate,k as quarterOf,j as startOfFiscalQuarter,_ as startOfFiscalYear,at as startOfMonth,v as startOfQuarter,x as startOfWeek,ut as startOfYear,X as subDays,tt as subMonths,et as subQuarters,Z as subWeeks,nt as subYears,Lt as weekOfMonth,E as weekOfYear,U as weeksInWeekYear};
|
package/dist/date/format.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{LimitError as z,ValidationError as w}from"../error/index.js";import{differenceInMonths as C,differenceInYears as q,isoWeek as O,quarterOf as _}from"./calendar.js";import{dateTimeFormat as g,relativeTimeFormat as U}from"./intl-cache.js";import{monthName as M,weekdayName as E}from"./locale.js";import{daysBetween as V,isoWeekday as k,plainDate as $,today as x,toPlainDate as W}from"./plain-date.js";import{isPlainDateTime as S,plainDateTime as v,plainDateTimeToEpochMilliseconds as A,plainTime as Z}from"./plain-time.js";import{toEpochMs as R}from"./zone.js";const j=new Set(["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","ss","SSS","a","Q","w"]),Q=256,X=256,y=new Map,Y=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",B=e=>j.has(e);function T(){return new w("HLP_DATE_INVALID_PATTERN","Unsupported date pattern.")}function F(e){const s=y.get(e);if(s)return s;if(typeof e!="string")throw T();if(e.length>Q)throw new z("HLP_DATE_PATTERN_TOO_LONG","Date pattern exceeds 256 characters.");const i=[];let u="";const r=()=>{u&&i.push({lit:u}),u=""};let o=0;for(;o<e.length;){const t=e.charAt(o);if(t==="'"){if(e.charAt(o+1)==="'"){u+="'",o+=2;continue}o++;let a=!1;for(;o<e.length;){const c=e.charAt(o);if(c==="'"){if(e.charAt(o+1)==="'"){u+="'",o+=2;continue}a=!0,o++;break}u+=c,o++}if(!a)throw T()}else if(Y(t)){let a=o;for(;e.charAt(a)===t;)a++;const c=e.slice(o,a);if(!B(c))throw T();r(),i.push({field:c}),o=a}else u+=t,o++}r();const d=Object.freeze(i);return y.size>=64&&y.clear(),y.set(e,d),d}function G(e){return S(e)?{date:e.date,...e.time}:{date:W(e),hour:0,minute:0,second:0,millisecond:0}}const f=(e,s)=>String(e).padStart(s,"0");function H(e){const s=g(e,{hour:"numeric",hour12:!0,timeZone:"UTC"}),i=(u,r)=>s.formatToParts(Date.UTC(2024,0,1,u)).find(o=>o.type==="dayPeriod")?.value??r;return[i(9,"AM"),i(21,"PM")]}function ce(e,s,i={}){const u=F(s),r=G(e),{locale:o}=i,d=o===void 0?{}:{locale:o};let t="";for(const a of u){if("lit"in a){t+=a.lit;continue}const{year:c,month:l,day:n}=r.date;switch(a.field){case"yyyy":t+=c<0?`-${f(-c,4)}`:f(c,4);break;case"yy":t+=f((c%100+100)%100,2);break;case"M":t+=String(l);break;case"MM":t+=f(l,2);break;case"MMM":t+=M(l,{...d,style:"short",context:"format"});break;case"MMMM":t+=M(l,{...d,style:"long",context:"format"});break;case"d":t+=String(n);break;case"dd":t+=f(n,2);break;case"EEE":t+=E(k(r.date),{...d,style:"short"});break;case"EEEE":t+=E(k(r.date),{...d,style:"long"});break;case"H":t+=String(r.hour);break;case"HH":t+=f(r.hour,2);break;case"h":t+=String(r.hour%12||12);break;case"hh":t+=f(r.hour%12||12,2);break;case"mm":t+=f(r.minute,2);break;case"ss":t+=f(r.second,2);break;case"SSS":t+=f(r.millisecond,3);break;case"a":t+=H(o)[r.hour<12?0:1];break;case"Q":t+=String(_(r.date));break;case"w":t+=String(O(r.date));break}}return t}const b=new Map;function D(e,s,i){const u=`${e??""}|${s}|${i}`,r=b.get(u);if(r)return r;const o=e===void 0?{}:{locale:e},d=[];if(s==="MMM"||s==="MMMM")for(let a=1;a<=12;a++)d.push(M(a,{...o,style:s==="MMM"?"short":"long",context:i}));else for(let a=1;a<=7;a++)d.push(E(a,{...o,style:s==="EEE"?"short":"long"}));const t=Object.freeze(d);return b.size>=128&&b.clear(),b.set(u,t),t}function p(e,s,i,u){let r;for(const o of i)o.forEach((d,t)=>{if(!d||r&&d.length<=r[1])return;const a=e.slice(s,s+d.length);a.length===d.length&&a.toLocaleLowerCase(u)===d.toLocaleLowerCase(u)&&(r=[t,d.length])});return r}const K=e=>e>="0"&&e<="9";function J(e,s,i){if(typeof e!="string"||e.length>X)return;const u=F(s),{locale:r}=i,o={};let d=0;const t=(c,l)=>{const n=o[c];return n!==void 0&&n!==l?!1:(o[c]=l,!0)},a=(c,l)=>{let n=d;for(;n<e.length&&n-d<l&&K(e.charAt(n));)n++;if(n-d<c)return;const m=Number(e.slice(d,n));return d=n,m};for(const c of u){if("lit"in c){if(!e.startsWith(c.lit,d))return;d+=c.lit.length;continue}let l;switch(c.field){case"yyyy":{const n=a(4,4);l=n!==void 0&&t("year",n);break}case"yy":{const n=a(2,2),m=i.referenceYear??2e3;if(n===void 0||!Number.isInteger(m))return;const h=m-50,N=h+((n-h)%100+100)%100;l=t("year",N);break}case"M":case"MM":{const n=c.field==="M"?a(1,2):a(2,2);l=n!==void 0&&t("month",n);break}case"MMM":case"MMMM":{const n=p(e,d,[D(r,c.field,"format"),D(r,c.field,"standalone")],r);if(!n)return;d+=n[1],l=t("month",n[0]+1);break}case"d":case"dd":{const n=c.field==="d"?a(1,2):a(2,2);l=n!==void 0&&t("day",n);break}case"EEE":case"EEEE":{const n=p(e,d,[D(r,c.field,"format")],r);if(!n)return;d+=n[1],l=t("weekday",n[0]+1);break}case"H":case"HH":{const n=c.field==="H"?a(1,2):a(2,2);l=n!==void 0&&t("hour24",n);break}case"h":case"hh":{const n=c.field==="h"?a(1,2):a(2,2);l=n!==void 0&&t("hour12",n);break}case"mm":{const n=a(2,2);l=n!==void 0&&t("minute",n);break}case"ss":{const n=a(2,2);l=n!==void 0&&t("second",n);break}case"SSS":{const n=a(3,3);l=n!==void 0&&t("millisecond",n);break}case"a":{const[n,m]=H(r),h=p(e,d,[[n,m]],r);if(!h)return;d+=h[1],l=t("pm",h[0]===1);break}case"Q":{const n=a(1,1);l=n!==void 0&&t("quarter",n);break}case"w":{const n=a(1,2);l=n!==void 0&&t("week",n);break}}if(!l)return}return d===e.length?o:void 0}function ee(e){if(e.year===void 0)return;let s=e.hour24??0;if(e.hour12!==void 0){if(e.pm===void 0||e.hour12<1||e.hour12>12)return;const u=e.hour12%12+(e.pm?12:0);if(e.hour24!==void 0&&e.hour24!==u)return;s=u}let i;try{i=v($(e.year,e.month??1,e.day??1),Z(s,e.minute??0,e.second??0,e.millisecond??0))}catch{return}if(!(e.weekday!==void 0&&e.weekday!==k(i.date))&&!(e.quarter!==void 0&&e.quarter!==_(i.date))&&!(e.week!==void 0&&e.week!==O(i.date)))return i}function ne(e,s,i={}){const u=J(e,s,i);return u?ee(u):void 0}function le(e,s,i={}){return ne(e,s,i)?.date}function P(e){return S(e)?A(e):A(v(e))}function L(e){const s=Object.keys(e).some(i=>i!=="locale"&&i!=="calendar"&&i!=="numberingSystem"&&i!=="hour12"&&i!=="hourCycle"&&i!=="localeMatcher"&&i!=="formatMatcher");return{...e,...s?{}:{dateStyle:"medium"},timeZone:"UTC"}}function fe(e,s={}){return g(s.locale,L(s)).format(P(e))}function me(e,s,i={}){const u=P(e),r=P(s);if(r<u)throw new w("HLP_DATE_INVALID_INTERVAL","Interval end is before its start.");const o=g(i.locale,L(i)),d=o.formatRange;return d?d.call(o,u,r):`${o.format(u)} to ${o.format(r)}`}const te=[["second",1e3,60],["minute",6e4,60],["hour",36e5,24],["day",864e5,7],["week",6048e5,4],["month",2629746e3,12],["year",31556952e3,1/0]];function I(e){return U(e.locale,{numeric:e.numeric??"auto",style:e.style??"long"})}function he(e,s=Date.now(),i={}){const u=R(e)-R(s),r=Math.abs(u);for(const[o,d,t]of te){const a=Math.round(r/d);if(a<t)return I(i).format(a===0?0:u<0?-a:a,o)}return I(i).format(0,"second")}function ye(e,s=x(),i={}){const u=V(s,e),r=I(i);if(Math.abs(u)<7)return r.format(u,"day");const o=C(e,s);return o===0?r.format(Math.round(u/7),"week"):Math.abs(o)<12?r.format(o,"month"):r.format(q(e,s),"year")}export{ce as formatDate,fe as formatDateIntl,me as formatDateRange,he as formatRelative,ye as formatRelativeDate,le as parseDate,ne as parseDateTime};
|
package/dist/date/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
export*from"./plain-date.js";import{plainTime as t,plainDateTime as m,isPlainTime as o,isPlainDateTime as n,timeToMilliseconds as r,timeFromMilliseconds as s,comparePlainTimes as p,comparePlainDateTimes as l,plainDateTimeToEpochMilliseconds as T,formatPlainTime as f,formatPlainDateTime as D,parsePlainTime as P,parseIsoDateTime as x,parsePlainDateTime as I,parseInstant as c,formatInstant as d}from"./plain-time.js";export*from"./calendar.js";export*from"./locale.js";export*from"./intervals.js";export*from"./format.js";import{toPlainDateTime as u,startOfDayInstant as z,endOfDayInstant as E}from"./zone.js";export{l as comparePlainDateTimes,p as comparePlainTimes,E as endOfDayInstant,d as formatInstant,D as formatPlainDateTime,f as formatPlainTime,n as isPlainDateTime,o as isPlainTime,c as parseInstant,x as parseIsoDateTime,I as parsePlainDateTime,P as parsePlainTime,m as plainDateTime,T as plainDateTimeToEpochMilliseconds,t as plainTime,z as startOfDayInstant,s as timeFromMilliseconds,r as timeToMilliseconds,u as toPlainDateTime};
|
package/dist/date/intervals.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{LimitError as k,ValidationError as m}from"../error/index.js";import{startOfWeek as O}from"./calendar.js";import{comparePlainDates as d,daysInMonth as M,fromEpochDay as c,isoWeekday as _,plainDate as x,toEpochDay as i,toPlainDate as v}from"./plain-date.js";function A(r,n){const t=v(r),e=v(n);if(d(e,t)<0)throw new m("HLP_DATE_INVALID_INTERVAL","Interval end is before its start.");return Object.freeze({start:t,end:e})}const l=r=>A(r.start,r.end);function G(r){const n=l(r);return i(n.end)-i(n.start)+1}function W(r,n){const t=l(r);return d(n,t.start)>=0&&d(n,t.end)<=0}function j(r,n,t={}){const e=l(r),a=l(n);return t.inclusive??!0?d(e.start,a.end)<=0&&d(a.start,e.end)<=0:d(e.start,a.end)<0&&d(a.start,e.end)<0}function N(r,n){const t=l(r),e=l(n),a=d(t.start,e.start)>=0?t.start:e.start,o=d(t.end,e.end)<=0?t.end:e.end;return d(a,o)<=0?Object.freeze({start:a,end:o}):void 0}function L(r,n={}){const t=n.mergeAdjacent??!0?1:0,e=Array.from(r,o=>{const s=l(o);return[i(s.start),i(s.end)]}).sort((o,s)=>o[0]-s[0]||o[1]-s[1]),a=[];for(const o of e){const s=a[a.length-1];s&&o[0]<=s[1]+t?s[1]=Math.max(s[1],o[1]):a.push([o[0],o[1]])}return a.map(([o,s])=>Object.freeze({start:c(o),end:c(s)}))}function z(r,n){const t=l(n),e=i(t.start),a=i(t.end),o=[];let s=e;for(const u of L(r)){const I=i(u.start),f=i(u.end);if(!(f<s)&&(I>a||(I>s&&o.push(Object.freeze({start:c(s),end:c(Math.min(I-1,a))})),s=Math.max(s,f+1),s>a)))break}return s<=a&&o.push(Object.freeze({start:c(s),end:t.end})),o}function D(r,n){const t=n.limit??1e5;if(!Number.isInteger(t)||t<0)throw new m("HLP_DATE_INVALID_LIMIT","limit must be a non-negative integer.");if(r>t)throw new k("HLP_DATE_TOO_MANY_ITEMS","The interval yields more items than the limit allows.",{details:{limit:t}})}function*w(r,n,t){for(let e=0;e<n;e++)yield c(r+e*t)}function C(r,n={}){const t=l(r),e=n.step??1;if(!Number.isSafeInteger(e)||e<1)throw new m("HLP_DATE_INVALID_STEP","step must be a positive integer.");const a=i(t.start),o=Math.floor((i(t.end)-a)/e)+1;return D(o,n),w(a,o,e)}function V(r,n={}){const t=l(r),e=i(O(t.start,n)),a=Math.floor((i(t.end)-e)/7)+1;return D(a,n),w(e,a,7)}function*P(r,n,t,e){const a=r*12+n-1;for(let o=0;o<t;o++){const s=a+o*e,u=Math.floor(s/12);yield x(u,s-u*12+1,1)}}function H(r,n={}){const t=l(r),e=(t.end.year-t.start.year)*12+(t.end.month-t.start.month)+1;return D(e,n),P(t.start.year,t.start.month,e,1)}function S(r,n={}){const t=l(r),e=t.end.year-t.start.year+1;return D(e,n),P(t.start.year,1,e,12)}function Y(r,n,t={}){const e=x(r,n,1),a=i(O(e,t)),o=i(e)+M(r,n)-1,s=t.fixedWeeks??!0?6:Math.floor((o-a)/7)+1,u=t.today===void 0?void 0:i(v(t.today)),I=[];for(let f=0;f<s;f++){const b=[];for(let y=0;y<7;y++){const h=a+f*7+y,p=c(h);b.push(Object.freeze({date:p,inMonth:p.month===n&&p.year===r,isToday:h===u,weekday:_(p)}))}I.push(b)}return I}export{Y as calendarMonthGrid,W as containsDate,A as dateInterval,C as eachDayOfInterval,H as eachMonthOfInterval,V as eachWeekOfInterval,S as eachYearOfInterval,z as intervalGaps,N as intervalIntersection,G as intervalLengthDays,j as intervalsOverlap,L as mergeIntervals};
|
package/dist/date/intl-cache.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as d}from"../error/index.js";const I=128,m=new Map;function r(t,n,s,u){let e=m.get(t);e||(e=new Map,m.set(t,e));const a=`${n??""}|${JSON.stringify(s)}`,o=e.get(a);if(o!==void 0)return o;let i;try{i=u()}catch(f){throw new d("HLP_INTL_INVALID_OPTIONS","Invalid locale or formatting options.",{cause:f})}return e.size>=I&&e.clear(),e.set(a,i),i}function l(t,n){return r("dtf",t,n,()=>new Intl.DateTimeFormat(t,n))}function F(t,n){return r("nf",t,n,()=>new Intl.NumberFormat(t,n))}function T(t,n){return r("lf",t,n,()=>new Intl.ListFormat(t,n))}function g(t,n){return r("rtf",t,n,()=>new Intl.RelativeTimeFormat(t,n))}export{r as cachedIntl,l as dateTimeFormat,T as listFormat,F as numberFormat,g as relativeTimeFormat};
|
package/dist/date/locale.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as I}from"../error/index.js";import{assertIsoWeekday as u}from"./calendar.js";import{dateTimeFormat as y}from"./intl-cache.js";function d(e,n){return Object.fromEntries(e.split(" ").map(t=>[t,n]))}const O=Object.freeze([5,6]),N=Object.freeze([7]),S=Object.freeze({...d("AG AS BD BR BS BT BW BZ CA CO DM DO ET GT GU HK HN ID IL IN IS JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW",7),...d("AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY",6),MV:5}),A=Object.freeze({...d("BH DZ EG IL IQ JO KW LY OM QA SA SD SY YE",O),AF:Object.freeze([4,5]),IR:Object.freeze([5]),IN:N,UG:N}),E=new Set("AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL RE RU SE SJ SK SM VA".split(" ")),w=Object.freeze([6,7]),g=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=7;function L(e){const n=e??new Intl.DateTimeFormat().resolvedOptions().locale;if(typeof n!="string"||n.length>128)throw new I("HLP_INVALID_LOCALE","Invalid locale.");try{return new Intl.Locale(n)}catch(t){throw new I("HLP_INVALID_LOCALE","Invalid locale.",{cause:t})}}const f=new Map;function P(e,n={}){const t=L(e),a=n.useNative??!0,r=`${t.toString()}|${String(a)}`,i=f.get(r);if(i)return i;const s=t.region??t.maximize().region??"001";let c=S[s]??1,m=A[s]??w,k=E.has(s)?4:1;if(a){const l=t;let o;try{o=typeof l.getWeekInfo=="function"?l.getWeekInfo():l.weekInfo}catch{o=void 0}o&&(g(o.firstDay)&&(c=o.firstDay),Array.isArray(o.weekend)&&o.weekend.every(g)&&(m=Object.freeze([...o.weekend].sort((D,p)=>D-p))),typeof o.minimalDays=="number"&&Number.isInteger(o.minimalDays)&&o.minimalDays>=1&&o.minimalDays<=7&&(k=o.minimalDays))}const W=Object.freeze({firstDay:c,weekend:m,minimalDays:k});return f.size>=256&&f.clear(),f.set(r,W),W}const T=e=>Date.UTC(2024,0,e,12);function M(e,n={}){return u(e,"weekday"),y(n.locale,{weekday:n.style??"long",timeZone:"UTC"}).format(T(e))}function H(e,n=1,t="long"){u(n);const a=[];for(let r=0;r<7;r++)a.push(M((n-1+r)%7+1,e===void 0?{style:t}:{locale:e,style:t}));return a}function b(e,n={}){if(!Number.isInteger(e)||e<1||e>12)throw new I("HLP_DATE_INVALID_MONTH","Month must be an integer 1 to 12.");const t=n.style??"long",a=Date.UTC(2024,e-1,15,12);if(n.context==="format"){const i=y(n.locale,{month:t,day:"numeric",timeZone:"UTC"}).formatToParts(a).find(s=>s.type==="month");if(i)return i.value}return y(n.locale,{month:t,timeZone:"UTC"}).format(a)}function U(e,n="long",t="standalone"){const a=[];for(let r=1;r<=12;r++)a.push(b(r,e===void 0?{style:n,context:t}:{locale:e,style:n,context:t}));return a}export{P as getWeekInfo,b as monthName,U as monthNames,M as weekdayName,H as weekdayNames};
|
package/dist/date/plain-date.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as s}from"../error/index.js";const d=275759;function I(e){return e%4===0&&e%100!==0||e%400===0}const P=[31,28,31,30,31,30,31,31,30,31,30,31];function b(e,t){return t===2?I(e)?29:28:P[t-1]??0}function A(e){return I(e)?366:365}function y(e,t,r,n){if(!Number.isInteger(e)||e<t||e>r)throw new s("HLP_DATE_OUT_OF_RANGE","Date field out of range.",{details:{property:n,min:t,max:r}})}function h(e,t,r){return y(e,-d,d,"year"),y(t,1,12,"month"),y(r,1,b(e,t),"day"),Object.freeze({kind:"PlainDate",year:e,month:t,day:r})}function N(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.kind==="PlainDate"&&Number.isInteger(t.year)&&Number.isInteger(t.month)&&Number.isInteger(t.day)&&(t.month??0)>=1&&(t.month??0)<=12&&(t.day??0)>=1&&(t.day??0)<=b(t.year??0,t.month??0)}function f(e){const t=e.month<=2?e.year-1:e.year,r=Math.floor(t/400),n=t-r*400,o=(e.month+9)%12,u=Math.floor((153*o+2)/5)+e.day-1,i=n*365+Math.floor(n/4)-Math.floor(n/100)+u;return r*146097+i-719468}function _(e){if(!Number.isInteger(e))throw new s("HLP_DATE_OUT_OF_RANGE","Epoch day must be an integer.");const t=e+719468,r=Math.floor(t/146097),n=t-r*146097,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/146096))/365),u=n-(365*o+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*u+2)/153),l=u-Math.floor((153*i+2)/5)+1,m=i<10?i+3:i-9,a=o+r*400+(m<=2?1:0);return h(a,m,l)}const M=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/;function E(e){if(typeof e!="string"||e.length>13)return;const t=M.exec(e);if(!t)return;const r=Number(t[1]),n=Number(t[2]),o=Number(t[3]);if(t[1]!=="-000000"&&!(Math.abs(r)>d||n<1||n>12||o<1||o>b(r,n)))return h(r,n,o)}const p=(e,t=2)=>String(Math.abs(e)).padStart(t,"0");function w(e){return`${e.year>=0&&e.year<=9999?p(e.year,4):`${e.year<0?"-":"+"}${p(e.year,6)}`}-${p(e.month)}-${p(e.day)}`}function c(e){if(typeof e=="string"){const t=E(e);if(!t)throw new s("HLP_INVALID_DATE","Expected a date in YYYY-MM-DD format.");return t}if(!N(e))throw new s("HLP_INVALID_DATE","Expected a PlainDate.");return e}function T(e){return((f(c(e))+3)%7+7)%7+1}function L(e,t){return y(t,-Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,"days"),_(f(c(e))+t)}function k(e,t){const r=f(c(e)),n=f(c(t));return r<n?-1:r>n?1:0}function F(e,t){return f(c(t))-f(c(e))}function O(e){return g(Date.now(),e)}const D=new Map;function g(e,t){const r=typeof e=="number"?e:e.getTime();if(!Number.isFinite(r))throw new s("HLP_INVALID_DATE","Invalid instant.");const n=t??"";let o=D.get(n);if(!o){try{o=new Intl.DateTimeFormat("en-US",{timeZone:t,era:"short",year:"numeric",month:"numeric",day:"numeric"})}catch(a){throw new s("HLP_TZ_INVALID_ZONE","Unsupported time zone identifier.",{cause:a})}D.size>=256&&D.clear(),D.set(n,o)}let u=0,i=0,l=0,m=!1;for(const a of o.formatToParts(r))a.type==="year"?u=Number(a.value):a.type==="month"?i=Number(a.value):a.type==="day"?l=Number(a.value):a.type==="era"&&(m=a.value==="BC"||a.value==="B");return h(m?1-u:u,i,l)}export{d as MAX_YEAR,L as addDays,k as comparePlainDates,F as daysBetween,b as daysInMonth,A as daysInYear,w as formatPlainDate,_ as fromEpochDay,I as isLeapYear,N as isPlainDate,T as isoWeekday,E as parsePlainDate,h as plainDate,g as plainDateFromInstant,f as toEpochDay,c as toPlainDate,O as today};
|
package/dist/date/plain-time.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as a}from"../error/index.js";import{formatPlainDate as P,isPlainDate as b,parsePlainDate as D,toEpochDay as _,toPlainDate as g}from"./plain-date.js";const d=864e5;function u(n,e,i){if(!Number.isInteger(n)||n<0||n>e)throw new a("HLP_DATE_OUT_OF_RANGE","Time field out of range.",{details:{property:i,min:0,max:e}})}function m(n,e=0,i=0,t=0){return u(n,23,"hour"),u(e,59,"minute"),u(i,59,"second"),u(t,999,"millisecond"),Object.freeze({kind:"PlainTime",hour:n,minute:e,second:i,millisecond:t})}function y(n,e=m(0)){if(!c(e))throw new a("HLP_INVALID_TIME","Expected a PlainTime.");return Object.freeze({kind:"PlainDateTime",date:g(n),time:e})}function c(n){if(typeof n!="object"||n===null)return!1;const e=n,i=(t,r)=>typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=r;return e.kind==="PlainTime"&&i(e.hour,23)&&i(e.minute,59)&&i(e.second,59)&&i(e.millisecond,999)}function k(n){if(typeof n!="object"||n===null)return!1;const e=n;return e.kind==="PlainDateTime"&&b(e.date)&&c(e.time)}function f(n){return((n.hour*60+n.minute)*60+n.second)*1e3+n.millisecond}function O(n){if(!Number.isInteger(n))throw new a("HLP_DATE_OUT_OF_RANGE","Milliseconds must be an integer.");let e=(n%d+d)%d;const i=Math.floor(e/36e5);e-=i*36e5;const t=Math.floor(e/6e4);e-=t*6e4;const r=Math.floor(e/1e3);return m(i,t,r,e-r*1e3)}function $(n,e){const i=f(n),t=f(e);return i<t?-1:i>t?1:0}function l(n){return _(n.date)*d+f(n.time)}function S(n,e){const i=l(n),t=l(e);return i<t?-1:i>t?1:0}const s=(n,e=2)=>String(n).padStart(e,"0");function h(n){const e=`${s(n.hour)}:${s(n.minute)}:${s(n.second)}`;return n.millisecond?`${e}.${s(n.millisecond,3)}`:e}function F(n){return`${P(n.date)}T${h(n.time)}`}const x=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/,I=/^((?:[+-]\d{2})?\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?)(Z|[+-]\d{2}:\d{2})?$/,N=/^([+-])(\d{2}):(\d{2})(?::(\d{2}))?$/;function E(n){if(typeof n!="string"||n.length>12)return;const e=x.exec(n);if(!e)return;const i=Number(e[1]),t=Number(e[2]),r=Number(e[3]??0),o=Number((e[4]??"0").padEnd(3,"0"));if(!(i>23||t>59||r>59))return m(i,t,r,o)}function M(n){if(typeof n!="string"||n.length>9)return;if(n==="Z")return 0;const e=N.exec(n);if(!e)return;const i=Number(e[2]),t=Number(e[3]),r=Number(e[4]??0);if(i>23||t>59||r>59)return;const o=((i*60+t)*60+r)*1e3;return e[1]==="-"?0-o:o}function T(n){if(typeof n!="string"||n.length>40)return;const e=I.exec(n);if(!e)return;const i=D(e[1]??""),t=E(e[2]??"");if(!i||!t)return;const r=e[3]===void 0?void 0:M(e[3]);if(!(e[3]!==void 0&&r===void 0))return Object.freeze({dateTime:y(i,t),offset:r})}function L(n){const e=T(n);return e&&e.offset===void 0?e.dateTime:void 0}const p=864e13;function j(n){const e=T(n);if(e?.offset===void 0)return;const i=l(e.dateTime)-e.offset;return Math.abs(i)>p?void 0:i}function R(n){const e=typeof n=="number"?n:n.getTime();if(!Number.isFinite(e)||Math.abs(e)>p)throw new a("HLP_INVALID_INSTANT","Expected a finite instant.");return new Date(e).toISOString()}export{S as comparePlainDateTimes,$ as comparePlainTimes,R as formatInstant,F as formatPlainDateTime,h as formatPlainTime,k as isPlainDateTime,c as isPlainTime,j as parseInstant,T as parseIsoDateTime,M as parseOffsetText,L as parsePlainDateTime,E as parsePlainTime,y as plainDateTime,l as plainDateTimeToEpochMilliseconds,m as plainTime,O as timeFromMilliseconds,f as timeToMilliseconds};
|
package/dist/date/zone.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{LimitError as P,ValidationError as h}from"../error/index.js";import{addDays as v,fromEpochDay as E,toEpochDay as M,toPlainDate as k}from"./plain-date.js";import{plainDateTime as L,plainDateTimeToEpochMilliseconds as N,timeFromMilliseconds as O}from"./plain-time.js";const m=864e5,b=864e13;function T(t){const e=typeof t=="number"?t:t instanceof Date?t.getTime():Number.NaN;if(!Number.isFinite(e)||Math.abs(e)>b)throw new h("HLP_INVALID_INSTANT","Expected a finite instant (epoch milliseconds or a valid Date).");return e}const p=t=>Math.max(-b,Math.min(b,t)),I=new Map;function _(t){return new h("HLP_TZ_INVALID_ZONE","Unsupported time zone identifier.",t===void 0?{}:{cause:t})}function g(t){const e=I.get(t);if(e)return e;if(typeof t!="string"||t.length===0||t.length>64)throw _();let n;try{n=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch(r){throw _(r)}return I.size>=512&&I.clear(),I.set(t,n),n}function S(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function d(t){const e=t??S();return g(e),e}function j(t){try{return g(t),!0}catch{return!1}}function s(t,e){const n=Math.floor(t/1e3)*1e3;let r=0,o=1,i=1,a=0,u=0,c=0,f=!1;for(const l of g(e).formatToParts(n))switch(l.type){case"year":r=Number(l.value);break;case"month":o=Number(l.value);break;case"day":i=Number(l.value);break;case"hour":a=Number(l.value)%24;break;case"minute":u=Number(l.value);break;case"second":c=Number(l.value);break;case"era":f=l.value==="BC"||l.value==="B";break;default:break}return f&&(r=1-r),M({kind:"PlainDate",year:r,month:o,day:i})*m+((a*60+u)*60+c)*1e3-n}function B(t,e){return s(T(t),d(e))}function A(t){const e=Math.floor(t/m);return L(E(e),O(t-e*m))}function F(t,e){const n=T(t);return A(n+s(n,d(e)))}function R(t,e){return F(t,e)}function y(t,e){const n=s(p(t-m),e),r=s(p(t+m),e),o=[];for(const i of n===r?[n]:[n,r]){const a=t-i;Math.abs(a)<=b&&s(a,e)===i&&!o.includes(a)&&o.push(a)}return o.sort((i,a)=>i-a)}function Z(t,e){return y(N(t),d(e))}function X(t,e){const n=Z(t,e).length;return n===1?"exact":n>1?"ambiguous":"nonexistent"}function H(t,e,n){const r=y(t,e),[o,i]=r;if(o!==void 0&&i===void 0)return o;if(o!==void 0&&i!==void 0){if(n==="reject")throw new h("HLP_TZ_AMBIGUOUS_TIME","The wall-clock time is ambiguous in the time zone.");return n==="later"?i:o}if(n==="reject")throw new h("HLP_TZ_NONEXISTENT_TIME","The wall-clock time does not exist in the time zone.");const a=s(p(t-m),e),u=s(p(t+m),e);return T(n==="earlier"?t-u:t-a)}function G(t,e,n={}){return H(N(t),d(e),n.disambiguation??"compatible")}function x(t,e,n,r){let o=t,i=e;for(;i-o>1;){const a=o+Math.floor((i-o)/2);s(a*1e3,r)===n?o=a:i=a}return i*1e3}function z(t,e){const n=d(e),r=M(k(t))*m,o=y(r,n);if(o[0]!==void 0)return o[0];const i=s(p(r-m),n),a=s(p(r+m),n),u=Math.floor((r-a)/1e3),c=Math.ceil((r-i)/1e3);return x(u,c,s(u*1e3,n),n)}function W(t,e){return z(v(t,1),e)-1}function w(t){const e=t.searchDays??400;if(!Number.isInteger(e)||e<1)throw new h("HLP_TZ_INVALID_SEARCH","searchDays must be a positive integer.");if(e>36600)throw new P("HLP_TZ_SEARCH_LIMIT","searchDays exceeds the limit of 36600.");return e}function Y(t,e,n={}){const r=T(t),o=d(e),i=w(n);let a=r;const u=s(r,o);for(let c=1;c<=i;c++){const f=p(r+c*m);if(s(f,o)!==u)return x(Math.floor(a/1e3),Math.floor(f/1e3),u,o);if(f===b)break;a=f}}function q(t,e,n={}){const r=T(t)-1,o=d(e),i=w(n),a=s(r,o);let u=r;for(let c=1;c<=i;c++){const f=p(r-c*m),D=s(f,o);if(D!==a)return x(Math.floor(f/1e3),Math.floor(u/1e3),D,o);if(f===-b)break;u=f}}export{W as endOfDayInstant,S as getLocalTimeZone,Z as getPossibleInstants,X as getWallTimeStatus,F as instantToZoned,j as isValidTimeZone,Y as nextTransition,B as offsetAt,s as offsetAtMs,q as previousTransition,d as resolveTimeZone,z as startOfDayInstant,T as toEpochMs,R as toPlainDateTime,G as zonedToInstant};
|
package/dist/decimal/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{HelperError as x,LimitError as D,ValidationError as m}from"../error/index.js";import{formatCurrency as y,formatNumber as C,parseNumberString as P}from"../number/index.js";const I=1e3,S=1e3,R=20,M=10n**BigInt(I),T=/^([+-]?)(\d+)(?:\.(\d+))?(?:e([+-]?\d{1,5}))?$/i,h=t=>10n**BigInt(t);function p(t){if(!Number.isInteger(t)||t<0)throw new m("HLP_DECIMAL_SCALE","The scale must be a non-negative integer.");if(t>S)throw new D("HLP_DECIMAL_TOO_LARGE","The scale exceeds the decimal limit.")}function O(t,e,n){const i=t/e,r=t%e;if(r===0n)return i;const l=t<0n==e<0n,s=l?1n:-1n,c=(r<0n?-r:r)*2n,u=e<0n?-e:e;switch(n){case"down":return i;case"up":return i+s;case"ceiling":return l?i+1n:i;case"floor":return l?i:i-1n;case"half-up":return c>=u?i+s:i;case"half-down":return c>u?i+s:i;case"half-even":return c>u||c===u&&i%2n!==0n?i+s:i}}function b(t,e,n,i){return n>=e?t*h(n-e):O(t,h(e-n),i)}function L(t,e){if(t.length>I*2+20)throw new D("HLP_DECIMAL_TOO_LONG","The decimal text exceeds the length limit.");const n=T.exec(t);if(!n)throw new m("HLP_DECIMAL_PARSE","Invalid decimal string.");const[,i="",r="0",l="",s]=n;if(s!==void 0&&!e)throw new m("HLP_DECIMAL_PARSE","Exponent notation is not allowed.");let c=l.length-(s===void 0?0:Number(s)),u=BigInt(r+l);if(c<0){if(-c>I)throw new D("HLP_DECIMAL_TOO_LARGE","The value exceeds the decimal limit.");u*=h(-c),c=0}return new o(i==="-"?-u:u,c)}function d(t){if(t instanceof o)return t;if(typeof t=="bigint")return new o(t,0);if(typeof t=="number"){if(!Number.isFinite(t))throw new m("HLP_DECIMAL_NOT_FINITE","Expected a finite number.");return L(String(t),!0)}if(typeof t=="string")return L(t,!1);throw new m("HLP_DECIMAL_PARSE","Expected a Decimal, string, number, or bigint.")}const N=(t,e)=>t<e?-1:t>e?1:0;class o{unscaled;scale;constructor(e,n=0){if(typeof e!="bigint")throw new m("HLP_DECIMAL_PARSE","The unscaled value must be a bigint.");if(p(n),e>=M||e<=-M)throw new D("HLP_DECIMAL_TOO_LARGE","The value exceeds the decimal digit limit.");this.unscaled=e,this.scale=n,Object.freeze(this)}add(e){const n=d(e),i=Math.max(this.scale,n.scale);return new o(this.unscaled*h(i-this.scale)+n.unscaled*h(i-n.scale),i)}subtract(e){return this.add(d(e).negate())}multiply(e,n={}){const i=d(e),r=this.unscaled*i.unscaled,l=this.scale+i.scale;return n.scale===void 0?new o(r,l):(p(n.scale),new o(b(r,l,n.scale,n.rounding??"half-up"),n.scale))}divide(e,n={}){const i=d(e);if(i.unscaled===0n)throw new x("HLP_DECIMAL_DIVIDE_BY_ZERO","Division by zero.",{kind:"validation"});const r=n.scale??Math.max(R,this.scale,i.scale);return p(r),new o(O(this.unscaled*h(i.scale+r),i.unscaled*h(this.scale),n.rounding??"half-up"),r)}negate(){return new o(-this.unscaled,this.scale)}abs(){return this.unscaled<0n?this.negate():this}compare(e){const n=d(e),i=Math.max(this.scale,n.scale);return N(this.unscaled*h(i-this.scale),n.unscaled*h(i-n.scale))}equals(e){return this.compare(e)===0}gt(e){return this.compare(e)>0}gte(e){return this.compare(e)>=0}lt(e){return this.compare(e)<0}lte(e){return this.compare(e)<=0}isZero(){return this.unscaled===0n}isNegative(){return this.unscaled<0n}isPositive(){return this.unscaled>0n}round(e,n="half-up"){return p(e),e===this.scale?this:new o(b(this.unscaled,this.scale,e,n),e)}normalize(){let e=this.unscaled,n=this.scale;for(;n>0&&e%10n===0n;)e/=10n,n--;return n===this.scale?this:new o(e,n)}toString(){const e=this.unscaled<0n;let n=(e?-this.unscaled:this.unscaled).toString();return this.scale>0&&(n=n.padStart(this.scale+1,"0"),n=`${n.slice(0,-this.scale)}.${n.slice(-this.scale)}`),e?`-${n}`:n}toFixed(e,n="half-up"){return this.round(e,n).toString()}toNumber(){return Number(this.toString())}toMinorUnits(e=2,n="half-up"){return this.round(e,n).unscaled}allocate(e,n={}){const i=n.scale??this.scale;if(p(i),e.length===0||e.length>1e6)throw new m("HLP_DECIMAL_ALLOCATE","Provide between 1 and 1,000,000 ratios.");const r=b(this.unscaled,this.scale,i,"down");if(b(r,i,this.scale,"down")!==this.unscaled)throw new m("HLP_DECIMAL_ALLOCATE","The amount has more fractional digits than the allocation scale.");const l=e.map(d),s=Math.max(...l.map(a=>a.scale)),c=l.map(a=>a.unscaled*h(s-a.scale));if(c.some(a=>a<0n))throw new m("HLP_DECIMAL_ALLOCATE","Ratios must not be negative.");const u=c.reduce((a,f)=>a+f,0n);if(u===0n)throw new m("HLP_DECIMAL_ALLOCATE","At least one ratio must be positive.");const E=r<0n,w=E?-r:r,g=c.map(a=>w*a/u),A=c.map((a,f)=>({i:f,r:w*a%u}));let _=w-g.reduce((a,f)=>a+f,0n);A.sort((a,f)=>a.r===f.r?a.i-f.i:a.r>f.r?-1:1);for(const{i:a}of A){if(_===0n)break;g[a]=(g[a]??0n)+1n,_--}return g.map(a=>new o(E?-a:a,i))}split(e,n={}){if(!Number.isInteger(e)||e<1||e>1e6)throw new m("HLP_DECIMAL_ALLOCATE","The part count must be an integer between 1 and 1,000,000.");return this.allocate(new Array(e).fill(1),n)}percent(e,n={}){const i=this.multiply(e),r=new o(i.unscaled,i.scale+2);return n.scale===void 0?r:r.round(n.scale,n.rounding??"half-up")}percentageOf(e,n={}){return this.multiply(100).divide(e,n)}toJSON(){return this.toString()}[Symbol.toPrimitive](e){if(e==="number")throw new x("HLP_DECIMAL_COERCION","Use toNumber() to convert a Decimal to a number explicitly.",{kind:"validation"});return this.toString()}}function H(t,e={}){let n;if(typeof t=="string"&&(e.locale!==void 0||e.allowExponent===!0)){let i=t;if(e.locale!==void 0){const r=P(t,{locale:e.locale,strict:!0});if(r===void 0||t.includes("%")||t.includes("\u066A"))throw new m("HLP_DECIMAL_PARSE","Invalid decimal string.");i=r.startsWith(".")?`0${r}`:r}n=L(i,e.allowExponent===!0)}else n=d(t);return e.scale===void 0?n:n.round(e.scale,e.rounding??"half-up")}function k(t,e={}){try{return H(t,e)}catch(n){if(n instanceof m)return;throw n}}function B(t){return t instanceof o}function G(t,e){return d(t).compare(e)}function U(t){let e=new o(0n,0);for(const n of t)e=e.add(n);return e}function $(...t){let e;for(const n of t){const i=d(n);(e===void 0||i.lt(e))&&(e=i)}return e}function z(...t){let e;for(const n of t){const i=d(n);(e===void 0||i.gt(e))&&(e=i)}return e}function V(t,e=2){if(typeof t=="number"&&!Number.isSafeInteger(t))throw new m("HLP_DECIMAL_MINOR_UNITS","Minor units must be a safe integer or bigint.");return new o(BigInt(t),e)}function q(t,e={}){const n=d(t),i=n.toString(),{currency:r,display:l,...s}=e;if(r!==void 0)return y(i,r,l?{...s,display:l}:s);const c=Math.min(n.scale,100),u=s.minimumFractionDigits===void 0&&s.maximumFractionDigits===void 0?{...s,minimumFractionDigits:c,maximumFractionDigits:c}:s;return C(i,u)}export{R as DEFAULT_DIVISION_SCALE,o as Decimal,I as MAX_DECIMAL_DIGITS,S as MAX_DECIMAL_SCALE,G as compareDecimals,H as decimal,q as formatDecimal,V as fromMinorUnits,B as isDecimal,z as maxDecimal,$ as minDecimal,k as parseDecimal,U as sumDecimals};
|
package/dist/ds/avl.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{concurrentModification as d}from"./internal.js";class f{constructor(e,t){this.key=e;this.value=t}key;value;left=void 0;right=void 0;height=1;aug=0}const l=h=>h?h.height:0;class u{root=void 0;size=0;version=0;cmp;#t;#r;constructor(e,t){this.cmp=e,this.#t=t}find(e){let t=this.root;for(;t;){const i=this.cmp(e,t.key);if(i===0)return t;t=i<0?t.left:t.right}}insert(e,t){const i=this.size;return this.root=this.#o(this.root,e,t),this.size!==i&&this.version++,this.size!==i}delete(e){this.root=this.#s(this.root,e);const t=this.#r;return this.#r=void 0,t&&(this.size--,this.version++),t}clear(){this.root=void 0,this.size=0,this.version++}min(){let e=this.root;for(;e?.left;)e=e.left;return e}max(){let e=this.root;for(;e?.right;)e=e.right;return e}below(e,t){let i=this.root,o;for(;i;){const r=this.cmp(i.key,e);if(r<0||t&&r===0){if(o=i,r===0)return i;i=i.right}else i=i.left}return o}above(e,t){let i=this.root,o;for(;i;){const r=this.cmp(i.key,e);if(r>0||t&&r===0){if(o=i,r===0)return i;i=i.left}else i=i.right}return o}*ascending(e){const t=[];let i=this.root;for(;i;){if(e===void 0){t.push(i),i=i.left;continue}const r=this.cmp(i.key,e.key);r>0||r===0&&!e.exclusive?(t.push(i),i=i.left):i=i.right}const o=this.version;for(let r=t.pop();r;r=t.pop()){if(yield r,o!==this.version)throw d();for(let s=r.right;s;s=s.left)t.push(s)}}*descending(e){const t=[];let i=this.root;for(;i;){if(e===void 0){t.push(i),i=i.right;continue}const r=this.cmp(i.key,e.key);r<0||r===0&&!e.exclusive?(t.push(i),i=i.right):i=i.left}const o=this.version;for(let r=t.pop();r;r=t.pop()){if(yield r,o!==this.version)throw d();for(let s=r.left;s;s=s.right)t.push(s)}}#e(e){e.height=1+Math.max(l(e.left),l(e.right)),this.#t?.(e)}#l(e){const t=e.left;return t?(e.left=t.right,t.right=e,this.#e(e),this.#e(t),t):e}#h(e){const t=e.right;return t?(e.right=t.left,t.left=e,this.#e(e),this.#e(t),t):e}#i(e){this.#e(e);const t=l(e.left)-l(e.right);return t>1&&e.left?(l(e.left.left)<l(e.left.right)&&(e.left=this.#h(e.left)),this.#l(e)):t<-1&&e.right?(l(e.right.right)<l(e.right.left)&&(e.right=this.#l(e.right)),this.#h(e)):e}#o(e,t,i){if(!e){this.size++;const r=new f(t,i);return this.#t?.(r),r}const o=this.cmp(t,e.key);if(o<0)e.left=this.#o(e.left,t,i);else if(o>0)e.right=this.#o(e.right,t,i);else return e.value=i,this.#t?.(e),e;return this.#i(e)}#s(e,t){if(!e)return;const i=this.cmp(t,e.key);if(i<0)e.left=this.#s(e.left,t);else if(i>0)e.right=this.#s(e.right,t);else{if(this.#r=e,!e.left)return e.right;if(!e.right)return e.left;let o=e.right;for(;o.left;)o=o.left;const r=this.#d(e.right);return o.left=e.left,o.right=r,this.#i(o)}return this.#i(e)}#d(e){return e.left?(e.left=this.#d(e.left),this.#i(e)):e.right}}export{f as AvlNode,u as AvlTree};
|
package/dist/ds/bitset.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{ValidationError as a}from"../error/index.js";const l=2**31;function m(i){let t=i-(i>>>1&1431655765);return t=(t&858993459)+(t>>>2&858993459),Math.imul(t+(t>>>4)&252645135,16843009)>>>24}function b(i){if(!Number.isInteger(i)||i<0||i>=l)throw new a("HLP_DS_INVALID_INDEX","Bit index must be a non-negative integer below 2^31.")}class u{#t;constructor(t=32){if(!Number.isInteger(t)||t<0||t>l)throw new a("HLP_DS_INVALID_CAPACITY","Capacity must be an integer between 0 and 2^31.");this.#t=new Uint32Array(Math.max(1,Math.ceil(t/32)))}static from(t){const e=new u;for(const r of t)e.set(r);return e}get capacity(){return this.#t.length*32}get size(){return this.count()}set(t){b(t),this.#r(t);const e=t>>>5;return this.#t[e]=((this.#t[e]??0)|1<<(t&31))>>>0,this}clear(t){if(t===void 0)return this.#t.fill(0),this;b(t);const e=t>>>5;return e<this.#t.length&&(this.#t[e]=((this.#t[e]??0)&~(1<<(t&31)))>>>0),this}has(t){if(!Number.isInteger(t)||t<0)return!1;const e=t>>>5;return e<this.#t.length&&((this.#t[e]??0)&1<<(t&31))!==0}toggle(t){return this.has(t)?(this.clear(t),!1):(this.set(t),!0)}count(){let t=0;for(const e of this.#t)t+=m(e);return t}union(t){return this.#e(t,(e,r)=>e|r)}intersect(t){return this.#e(t,(e,r)=>e&r)}difference(t){return this.#e(t,(e,r)=>e&~r)}xor(t){return this.#e(t,(e,r)=>e^r)}equals(t){const e=this.#t,r=t.#t,n=Math.max(e.length,r.length);for(let s=0;s<n;s++)if((e[s]??0)!==(r[s]??0))return!1;return!0}clone(){const t=new u(0);return t.#t=this.#t.slice(),t}toArray(){return[...this]}*[Symbol.iterator](){const t=this.#t;for(let e=0;e<t.length;e++){let r=t[e]??0;for(;r!==0;){const n=r&-r;yield e*32+(31-Math.clz32(n)),r=(r^n)>>>0}}}#r(t){const e=(t>>>5)+1;if(e<=this.#t.length)return;const r=new Uint32Array(Math.min(Math.max(e,this.#t.length*2),l/32));r.set(this.#t),this.#t=r}#e(t,e){const r=this.#t,n=t.#t,s=new u(0),h=new Uint32Array(Math.max(r.length,n.length));for(let o=0;o<h.length;o++)h[o]=e(r[o]??0,n[o]??0)>>>0;return s.#t=h,s}}export{u as BitSet};
|
package/dist/ds/bloom.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{LimitError as c,ValidationError as l}from"../error/index.js";const f=2**31;let u;function m(e){let i=2166136261;for(const t of e)i=Math.imul(i^t,16777619);return i>>>0}function d(e,i){let t=i>>>0;const n=e.length,o=n&-4;for(let a=0;a<o;a+=4){let s=(e[a]??0)|(e[a+1]??0)<<8|(e[a+2]??0)<<16|(e[a+3]??0)<<24;s=Math.imul(s,3432918353),s=s<<15|s>>>17,s=Math.imul(s,461845907),t^=s,t=t<<13|t>>>19,t=Math.imul(t,5)+3864292196|0}let r=0;const h=n&3;return h===3&&(r^=(e[o+2]??0)<<16),h>=2&&(r^=(e[o+1]??0)<<8),h>=1&&(r^=e[o]??0,r=Math.imul(r,3432918353),r=r<<15|r>>>17,r=Math.imul(r,461845907),t^=r),t^=n,t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}function b(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="bigint"||typeof e=="boolean")return String(e);if(e instanceof Uint8Array)return e;throw new l("HLP_DS_BLOOM_UNSUPPORTED","Provide a key function for this item type.")}class x{bits;hashCount;#t;#i;#e=0;constructor(i){const t=i.expectedItems,n=i.falsePositiveRate??.01;if(!Number.isSafeInteger(t)||t<1)throw new l("HLP_DS_BLOOM_INVALID","expectedItems must be a positive integer.");if(!(n>0&&n<1))throw new l("HLP_DS_BLOOM_INVALID","falsePositiveRate must be between 0 and 1.");const o=Math.ceil(-t*Math.log(n)/Math.LN2**2);if(o>f)throw new c("HLP_DS_BLOOM_TOO_LARGE","The requested Bloom filter exceeds the size limit.");this.bits=Math.max(32,o),this.hashCount=Math.max(1,Math.round(this.bits/t*Math.LN2)),this.#t=new Uint32Array(Math.ceil(this.bits/32)),this.#i=i.key??b}get size(){return this.#e}add(i){const[t,n]=this.#n(i);for(let o=0;o<this.hashCount;o++){const r=(t+o*n)%this.bits,h=r>>>5;this.#t[h]=((this.#t[h]??0)|1<<(r&31))>>>0}return this.#e++,this}has(i){const[t,n]=this.#n(i);for(let o=0;o<this.hashCount;o++){const r=(t+o*n)%this.bits;if(((this.#t[r>>>5]??0)&1<<(r&31))===0)return!1}return!0}estimatedFalsePositiveRate(){let i=0;for(const t of this.#t){let n=t;for(;n!==0;)n&=n-1,i++}return(i/this.bits)**this.hashCount}clear(){this.#t.fill(0),this.#e=0}#n(i){const t=this.#i(i);u??=new TextEncoder;const n=typeof t=="string"?u.encode(t):t;return[m(n),(d(n,2538058380)|1)>>>0]}}export{x as BloomFilter};
|
package/dist/ds/caches.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! AbsoluteUI @absoluteui/helpers v0.13.
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.3 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
2
|
import{assertCapacity as a,assertTtl as o}from"./internal.js";class h{maxSize;#e=new Map;#i;#r;#t;constructor(e={}){this.maxSize=e.maxSize??1e3,a(this.maxSize),e.ttlMs!==void 0&&o(e.ttlMs),this.#i=e.ttlMs,this.#r=e.onEvict,this.#t=e.now??Date.now}get size(){return this.#e.size}get(e){const t=this.#n(e);if(t)return this.#e.delete(e),this.#e.set(e,t),t.value}peek(e){return this.#n(e)?.value}has(e){return this.#n(e)!==void 0}set(e,t,n={}){const i=n.ttlMs??this.#i;for(n.ttlMs!==void 0&&o(n.ttlMs),this.#e.delete(e),this.#e.set(e,{value:t,expires:i===void 0?1/0:this.#t()+i});this.#e.size>this.maxSize;){const r=this.#e.entries().next();if(r.done)break;const[s,d]=r.value;this.#e.delete(s),this.#r?.(s,d.value,d.expires<=this.#t()?"expired":"capacity")}return this}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}prune(){const e=this.#t();let t=0;for(const[n,i]of[...this.#e])i.expires<=e&&(this.#e.delete(n),t++,this.#r?.(n,i.value,"expired"));return t}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}toArray(){return[...this]}*[Symbol.iterator](){const e=this.#t();for(const[t,n]of[...this.#e])n.expires>e&&(yield[t,n.value])}#n(e){const t=this.#e.get(e);if(t){if(t.expires<=this.#t()){this.#e.delete(e),this.#r?.(e,t.value,"expired");return}return t}}}class f{maxSize;#e=new Map;#i={freq:0,keys:new Set,prev:void 0,next:void 0};#r;constructor(e){a(e.maxSize),this.maxSize=e.maxSize,this.#r=e.onEvict}get size(){return this.#e.size}get(e){const t=this.#e.get(e);if(t)return this.#t(e,t),t.value}peek(e){return this.#e.get(e)?.value}has(e){return this.#e.has(e)}frequency(e){return this.#e.get(e)?.node.freq??0}set(e,t){const n=this.#e.get(e);if(n)return n.value=t,this.#t(e,n),this;this.#e.size>=this.maxSize&&this.#n();let i=this.#i.next;return i?.freq!==1&&(i=this.#s(this.#i,1)),i.keys.add(e),this.#e.set(e,{value:t,node:i}),this}delete(e){const t=this.#e.get(e);return t?(this.#e.delete(e),t.node.keys.delete(e),t.node.keys.size===0&&this.#o(t.node),!0):!1}clear(){this.#e.clear(),this.#i.next=void 0}toArray(){return[...this]}*[Symbol.iterator](){const e=[];for(let t=this.#i.next;t;t=t.next)for(const n of t.keys){const i=this.#e.get(n);i&&e.push([n,i.value])}yield*e}#t(e,t){const n=t.node;let i=n.next;i?.freq!==n.freq+1&&(i=this.#s(n,n.freq+1)),n.keys.delete(e),i.keys.add(e),t.node=i,n.keys.size===0&&this.#o(n)}#n(){const e=this.#i.next;if(!e)return;const t=e.keys.values().next();if(t.done)return;const n=t.value,i=this.#e.get(n);this.delete(n),i&&this.#r?.(n,i.value)}#s(e,t){const n={freq:t,keys:new Set,prev:e,next:e.next};return e.next&&(e.next.prev=n),e.next=n,n}#o(e){e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.prev=e.next=void 0}}class c{#e=new Map;#i;#r;#t;#n;constructor(e){o(e.ttlMs),e.maxSize!==void 0&&a(e.maxSize),this.#i=e.ttlMs,this.#r=e.maxSize,this.#t=e.onEvict,this.#n=e.now??Date.now}get size(){return this.#e.size}set(e,t,n={}){const i=n.ttlMs??this.#i;if(o(i),this.#e.delete(e),this.#e.set(e,{value:t,expires:this.#n()+i}),this.#r!==void 0)for(;this.#e.size>this.#r;){const r=this.#e.entries().next();if(r.done)break;const[s,d]=r.value;this.#e.delete(s),this.#t?.(s,d.value,"capacity")}return this}get(e){return this.#s(e)?.value}has(e){return this.#s(e)!==void 0}ttlRemaining(e){const t=this.#s(e);return t?t.expires-this.#n():void 0}touch(e,t=this.#i){o(t);const n=this.#s(e);return n?(n.expires=this.#n()+t,!0):!1}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}prune(){const e=this.#n();let t=0;for(const[n,i]of[...this.#e])i.expires<=e&&(this.#e.delete(n),t++,this.#t?.(n,i.value,"expired"));return t}toArray(){return[...this]}*[Symbol.iterator](){const e=this.#n();for(const[t,n]of[...this.#e])n.expires>e&&(yield[t,n.value])}#s(e){const t=this.#e.get(e);if(t){if(t.expires<=this.#n()){this.#e.delete(e),this.#t?.(e,t.value,"expired");return}return t}}}export{f as LFUCache,h as LRUCache,c as TTLCache};
|