@absoluteui/helpers 0.0.0-stage → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +47 -2
  4. package/SECURITY.md +102 -0
  5. package/dist/array/compare.d.ts +8 -0
  6. package/dist/array/compare.js +2 -0
  7. package/dist/array/index.d.ts +328 -0
  8. package/dist/array/index.js +2 -0
  9. package/dist/array/tree.d.ts +48 -0
  10. package/dist/array/tree.js +2 -0
  11. package/dist/async/batch.d.ts +103 -0
  12. package/dist/async/batch.js +2 -0
  13. package/dist/async/concurrency.d.ts +92 -0
  14. package/dist/async/concurrency.js +2 -0
  15. package/dist/async/control.d.ts +77 -0
  16. package/dist/async/control.js +2 -0
  17. package/dist/async/index.d.ts +8 -0
  18. package/dist/async/index.js +2 -0
  19. package/dist/async/signal.d.ts +95 -0
  20. package/dist/async/signal.js +2 -0
  21. package/dist/boolean/index.d.ts +83 -0
  22. package/dist/boolean/index.js +2 -0
  23. package/dist/business-calendar/days.d.ts +397 -0
  24. package/dist/business-calendar/days.js +2 -0
  25. package/dist/business-calendar/describe.d.ts +45 -0
  26. package/dist/business-calendar/describe.js +2 -0
  27. package/dist/business-calendar/engine.d.ts +305 -0
  28. package/dist/business-calendar/engine.js +2 -0
  29. package/dist/business-calendar/hours.d.ts +96 -0
  30. package/dist/business-calendar/hours.js +2 -0
  31. package/dist/business-calendar/index.d.ts +29 -0
  32. package/dist/business-calendar/index.js +2 -0
  33. package/dist/business-calendar/internal.d.ts +44 -0
  34. package/dist/business-calendar/internal.js +2 -0
  35. package/dist/business-calendar/rules.d.ts +260 -0
  36. package/dist/business-calendar/rules.js +2 -0
  37. package/dist/color/index.d.ts +200 -0
  38. package/dist/color/index.js +2 -0
  39. package/dist/color/named.d.ts +4 -0
  40. package/dist/color/named.js +2 -0
  41. package/dist/compare/index.d.ts +186 -0
  42. package/dist/compare/index.js +2 -0
  43. package/dist/convert/index.d.ts +152 -0
  44. package/dist/convert/index.js +2 -0
  45. package/dist/csv/index.d.ts +6 -0
  46. package/dist/csv/index.js +2 -0
  47. package/dist/csv/parse.d.ts +85 -0
  48. package/dist/csv/parse.js +12 -0
  49. package/dist/csv/stringify.d.ts +48 -0
  50. package/dist/csv/stringify.js +5 -0
  51. package/dist/date/calendar.d.ts +339 -0
  52. package/dist/date/calendar.js +2 -0
  53. package/dist/date/format.d.ts +66 -0
  54. package/dist/date/format.js +2 -0
  55. package/dist/date/index.d.ts +26 -0
  56. package/dist/date/index.js +2 -0
  57. package/dist/date/intervals.d.ts +110 -0
  58. package/dist/date/intervals.js +2 -0
  59. package/dist/date/intl-cache.d.ts +10 -0
  60. package/dist/date/intl-cache.js +2 -0
  61. package/dist/date/locale.d.ts +58 -0
  62. package/dist/date/locale.js +2 -0
  63. package/dist/date/plain-date.d.ts +105 -0
  64. package/dist/date/plain-date.js +2 -0
  65. package/dist/date/plain-time.d.ts +121 -0
  66. package/dist/date/plain-time.js +2 -0
  67. package/dist/date/zone.d.ts +121 -0
  68. package/dist/date/zone.js +2 -0
  69. package/dist/decimal/index.d.ts +149 -0
  70. package/dist/decimal/index.js +2 -0
  71. package/dist/ds/avl.d.ts +50 -0
  72. package/dist/ds/avl.js +2 -0
  73. package/dist/ds/bitset.d.ts +46 -0
  74. package/dist/ds/bitset.js +2 -0
  75. package/dist/ds/bloom.d.ts +41 -0
  76. package/dist/ds/bloom.js +2 -0
  77. package/dist/ds/caches.d.ts +141 -0
  78. package/dist/ds/caches.js +2 -0
  79. package/dist/ds/disjoint-set.d.ts +38 -0
  80. package/dist/ds/disjoint-set.js +2 -0
  81. package/dist/ds/emitter.d.ts +53 -0
  82. package/dist/ds/emitter.js +2 -0
  83. package/dist/ds/graph.d.ts +84 -0
  84. package/dist/ds/graph.js +2 -0
  85. package/dist/ds/heap.d.ts +49 -0
  86. package/dist/ds/heap.js +2 -0
  87. package/dist/ds/index.d.ts +20 -0
  88. package/dist/ds/index.js +2 -0
  89. package/dist/ds/internal.d.ts +19 -0
  90. package/dist/ds/internal.js +2 -0
  91. package/dist/ds/interval-tree.d.ts +49 -0
  92. package/dist/ds/interval-tree.js +2 -0
  93. package/dist/ds/linked-list.d.ts +54 -0
  94. package/dist/ds/linked-list.js +2 -0
  95. package/dist/ds/maps.d.ts +89 -0
  96. package/dist/ds/maps.js +2 -0
  97. package/dist/ds/ring.d.ts +99 -0
  98. package/dist/ds/ring.js +2 -0
  99. package/dist/ds/sorted.d.ts +104 -0
  100. package/dist/ds/sorted.js +2 -0
  101. package/dist/ds/stack.d.ts +28 -0
  102. package/dist/ds/stack.js +2 -0
  103. package/dist/ds/trie.d.ts +84 -0
  104. package/dist/ds/trie.js +2 -0
  105. package/dist/duration/index.d.ts +146 -0
  106. package/dist/duration/index.js +2 -0
  107. package/dist/encoding/index.d.ts +144 -0
  108. package/dist/encoding/index.js +2 -0
  109. package/dist/error/index.d.ts +316 -0
  110. package/dist/error/index.js +2 -0
  111. package/dist/fn/index.d.ts +129 -0
  112. package/dist/fn/index.js +2 -0
  113. package/dist/fn/memo.d.ts +46 -0
  114. package/dist/fn/memo.js +2 -0
  115. package/dist/fn/timing.d.ts +64 -0
  116. package/dist/fn/timing.js +2 -0
  117. package/dist/http/headers.d.ts +160 -0
  118. package/dist/http/headers.js +2 -0
  119. package/dist/http/index.d.ts +10 -0
  120. package/dist/http/index.js +2 -0
  121. package/dist/http/problem.d.ts +37 -0
  122. package/dist/http/problem.js +2 -0
  123. package/dist/http/response.d.ts +43 -0
  124. package/dist/http/response.js +2 -0
  125. package/dist/http/status.d.ts +169 -0
  126. package/dist/http/status.js +2 -0
  127. package/dist/index.d.ts +34 -0
  128. package/dist/index.js +2 -0
  129. package/dist/internal/keys.d.ts +6 -0
  130. package/dist/internal/keys.js +2 -0
  131. package/dist/is/index.d.ts +219 -0
  132. package/dist/is/index.js +2 -0
  133. package/dist/json/index.d.ts +9 -0
  134. package/dist/json/index.js +2 -0
  135. package/dist/json/internal.d.ts +12 -0
  136. package/dist/json/internal.js +2 -0
  137. package/dist/json/ndjson.d.ts +28 -0
  138. package/dist/json/ndjson.js +4 -0
  139. package/dist/json/parse.d.ts +45 -0
  140. package/dist/json/parse.js +2 -0
  141. package/dist/json/patch.d.ts +62 -0
  142. package/dist/json/patch.js +2 -0
  143. package/dist/json/pointer.d.ts +43 -0
  144. package/dist/json/pointer.js +2 -0
  145. package/dist/json/stringify.d.ts +42 -0
  146. package/dist/json/stringify.js +2 -0
  147. package/dist/linq/enumerable.d.ts +208 -0
  148. package/dist/linq/enumerable.js +2 -0
  149. package/dist/linq/index.d.ts +6 -0
  150. package/dist/linq/index.js +2 -0
  151. package/dist/linq/operators.d.ts +503 -0
  152. package/dist/linq/operators.js +2 -0
  153. package/dist/number/core.d.ts +164 -0
  154. package/dist/number/core.js +2 -0
  155. package/dist/number/format.d.ts +80 -0
  156. package/dist/number/format.js +2 -0
  157. package/dist/number/index.d.ts +12 -0
  158. package/dist/number/index.js +2 -0
  159. package/dist/number/internal.d.ts +18 -0
  160. package/dist/number/internal.js +2 -0
  161. package/dist/number/parse.d.ts +45 -0
  162. package/dist/number/parse.js +2 -0
  163. package/dist/number/words.d.ts +19 -0
  164. package/dist/number/words.js +2 -0
  165. package/dist/object/basic.d.ts +130 -0
  166. package/dist/object/basic.js +2 -0
  167. package/dist/object/deep.d.ts +90 -0
  168. package/dist/object/deep.js +2 -0
  169. package/dist/object/diff.d.ts +57 -0
  170. package/dist/object/diff.js +2 -0
  171. package/dist/object/index.d.ts +8 -0
  172. package/dist/object/index.js +2 -0
  173. package/dist/object/internal.d.ts +21 -0
  174. package/dist/object/internal.js +2 -0
  175. package/dist/object/path.d.ts +17 -0
  176. package/dist/object/path.js +2 -0
  177. package/dist/random/core.d.ts +14 -0
  178. package/dist/random/core.js +2 -0
  179. package/dist/random/index.d.ts +167 -0
  180. package/dist/random/index.js +2 -0
  181. package/dist/random/seeded.d.ts +27 -0
  182. package/dist/random/seeded.js +2 -0
  183. package/dist/sanitize/index.d.ts +8 -0
  184. package/dist/sanitize/index.js +2 -0
  185. package/dist/sanitize/pii.d.ts +48 -0
  186. package/dist/sanitize/pii.js +2 -0
  187. package/dist/sanitize/records.d.ts +100 -0
  188. package/dist/sanitize/records.js +2 -0
  189. package/dist/sanitize/text.d.ts +101 -0
  190. package/dist/sanitize/text.js +2 -0
  191. package/dist/set/index.d.ts +162 -0
  192. package/dist/set/index.js +2 -0
  193. package/dist/stats/index.d.ts +190 -0
  194. package/dist/stats/index.js +2 -0
  195. package/dist/string/index.d.ts +494 -0
  196. package/dist/string/index.js +8 -0
  197. package/dist/string/internal.d.ts +33 -0
  198. package/dist/string/internal.js +2 -0
  199. package/dist/string/words.d.ts +14 -0
  200. package/dist/string/words.js +2 -0
  201. package/dist/timezone/index.d.ts +76 -0
  202. package/dist/timezone/index.js +2 -0
  203. package/dist/url/index.d.ts +178 -0
  204. package/dist/url/index.js +2 -0
  205. package/dist/validate/builders.d.ts +6 -0
  206. package/dist/validate/builders.js +2 -0
  207. package/dist/validate/formats.d.ts +237 -0
  208. package/dist/validate/formats.js +2 -0
  209. package/dist/validate/index.d.ts +13 -0
  210. package/dist/validate/index.js +2 -0
  211. package/dist/validate/schema.d.ts +220 -0
  212. package/dist/validate/schema.js +2 -0
  213. package/dist/zip/index.d.ts +8 -0
  214. package/dist/zip/index.js +2 -0
  215. package/dist/zip/internal.d.ts +69 -0
  216. package/dist/zip/internal.js +2 -0
  217. package/dist/zip/reader.d.ts +56 -0
  218. package/dist/zip/reader.js +2 -0
  219. package/dist/zip/writer.d.ts +65 -0
  220. package/dist/zip/writer.js +2 -0
  221. package/package.json +150 -4
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ class i extends Error{name="HelperError";code;kind;details;fields;constructor(e,n,t={}){super(n,t.cause===void 0?void 0:{cause:t.cause}),this.code=e,this.kind=t.kind??"internal",this.details=Object.freeze({...t.details}),this.fields=Object.freeze({...t.fields})}}class x extends i{name="ValidationError";constructor(e,n,t={}){super(e,n,{...t,kind:"validation"})}}class T extends i{name="NotFoundError";constructor(e,n,t={}){super(e,n,{...t,kind:"not-found"})}}class w extends i{name="ConflictError";constructor(e,n,t={}){super(e,n,{...t,kind:"conflict"})}}class H extends i{name="TimeoutError";constructor(e="HLP_TIMEOUT",n="The operation timed out.",t={}){super(e,n,{...t,kind:"timeout"})}}class O extends i{name="AbortError";constructor(e="HLP_ABORTED",n="The operation was aborted.",t={}){super(e,n,{...t,kind:"aborted"})}}class v extends i{name="LimitError";constructor(e,n,t={}){super(e,n,{...t,kind:"limit"})}}const E=new Map([[0,"network"],[400,"validation"],[401,"unauthorized"],[403,"forbidden"],[404,"not-found"],[408,"timeout"],[409,"conflict"],[410,"not-found"],[412,"conflict"],[413,"too-large"],[422,"validation"],[429,"rate-limited"],[502,"unavailable"],[503,"unavailable"],[504,"timeout"]]);function g(r){const e=E.get(r);return e!==void 0?e:r>=500&&r<=599?"server":"client"}const m=new Set(["network","offline","timeout","rate-limited","unavailable"]);class y extends i{name="HttpError";status;statusText;problem;method;url;category;retryable;retryAfterMs;requestId;body;constructor(e,n,t){const s=t.category??g(t.status),a=s==="cancelled"?"aborted":s==="timeout"&&t.status===0?"timeout":t.status===401?"unauthorized":t.status===403?"forbidden":t.status===404?"not-found":t.status===409?"conflict":"http";super(e,n,{...t,kind:a}),this.status=t.status,this.statusText=t.statusText??"",this.problem=t.problem,this.method=t.method,this.url=t.url,this.category=s,this.retryable=t.retryable??(m.has(s)||t.status===425||t.status===500),this.retryAfterMs=t.retryAfterMs,this.requestId=t.requestId,this.body=t.body}toJSON(){const e=this.problem?.type;return{name:this.name,code:this.code,message:this.message,status:this.status,category:this.category,retryable:this.retryable,method:this.method,url:this.url,requestId:this.requestId,retryAfterMs:this.retryAfterMs,fields:this.fields,problemType:typeof e=="string"?e:void 0}}}function A(r,e){return r instanceof i&&(e===void 0||r.code===e)}function S(r){return r instanceof i&&r.kind==="aborted"?!0:typeof r=="object"&&r!==null&&r.name==="AbortError"}function l(r){return r instanceof Error?r:new i("HLP_NON_ERROR_THROWN","A non-error value was thrown.",{cause:r})}function z(r,e={}){const{includeStack:n=!1,maxDepth:t=5}=e,s=(a,f)=>{const o=l(a),d={name:o.name,message:o.message};return o instanceof i&&(d.code=o.code,d.kind=o.kind,Object.keys(o.details).length&&(d.details=o.details),Object.keys(o.fields).length&&(d.fields=o.fields)),o instanceof y&&(d.status=o.status),n&&o.stack!==void 0&&(d.stack=o.stack),o.cause!==void 0&&f<t&&!(o instanceof i&&o.code==="HLP_NON_ERROR_THROWN")&&(d.cause=s(o.cause,f+1)),d};return s(r,0)}function k(r){if(typeof r!="object"||r===null)return new i("HLP_INVALID_SERIALIZED_ERROR","Invalid serialized error.");const e=r,n=typeof e.message=="string"?e.message:"Unknown error.",t=typeof e.code=="string"?e.code:"HLP_DESERIALIZED",s={...p(e.details)?{details:e.details}:{},...h(e.fields)?{fields:e.fields}:{},...e.cause!==void 0?{cause:k(e.cause)}:{}},a=typeof e.status=="number"?new y(t,n,{...s,status:e.status}):new i(t,n,{...s,kind:R(e.kind)?e.kind:"internal"});return typeof e.name=="string"&&(a.name=e.name),a}const b=["validation","not-found","conflict","http","timeout","aborted","unauthorized","forbidden","unsupported","limit","internal"],R=r=>typeof r=="string"&&b.includes(r),p=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),h=r=>p(r)&&Object.values(r).every(e=>typeof e=="string");function u(r){return{ok:!0,value:r}}function c(r){return{ok:!1,error:r}}function I(r){try{return u(r())}catch(e){return c(l(e))}}async function _(r){try{return u(await r())}catch(e){return c(l(e))}}function C(r){if(r.ok)return r.value;throw r.error instanceof Error?r.error:l(r.error)}function L(r,e){return r.ok?r.value:e}function F(r,e){return r.ok?u(e(r.value)):r}function N(r,e){return r.ok?r:c(e(r.error))}function P(r){const e=[];for(const n of r){if(!n.ok)return n;e.push(n.value)}return u(e)}function j(r,e="_form"){const n={};for(const t of r)if(t instanceof i&&Object.keys(t.fields).length)for(const[s,a]of Object.entries(t.fields))s in n||(n[s]=a);else e in n||(n[e]=l(t).message);return n}function K(r,e="Invariant failed.",n="HLP_ASSERT"){if(!r)throw new i(n,e)}function M(r,e="Unexpected value."){throw new i("HLP_UNREACHABLE",e,{cause:r})}export{O as AbortError,w as ConflictError,i as HelperError,y as HttpError,v as LimitError,T as NotFoundError,H as TimeoutError,x as ValidationError,M as assertNever,P as combineResults,k as deserializeError,c as err,j as fieldErrors,g as httpFailureCategory,K as invariant,S as isAbortError,A as isHelperError,N as mapError,F as mapResult,u as ok,z as serializeError,l as toError,I as tryCatch,_ as tryCatchAsync,C as unwrap,L as unwrapOr};
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Function helpers (docs/PLAN-HELPERS.md section 2 `fn`). Timers never use string callbacks; nothing touches
3
+ * globals at import time.
4
+ */
5
+ import { type Result } from '../error/index.js';
6
+ export { debounce, throttle, rafThrottle, type Debounced, type DebounceOptions, type ThrottleOptions, type FrameThrottled } from './timing.js';
7
+ export { memoize, memoizeOne, type Memoized, type MemoizeOptions } from './memo.js';
8
+ /**
9
+ * Does nothing and returns `undefined`.
10
+ * @example
11
+ * const options: { onChange?: (value: string) => void } = {};
12
+ * const onChange = options.onChange ?? noop;
13
+ * onChange('Ada'); // => undefined
14
+ */
15
+ export declare const noop: (...args: unknown[]) => void;
16
+ /**
17
+ * Returns its argument.
18
+ * @example
19
+ * [1, 0, 2].filter(identity); // => [1, 2]
20
+ */
21
+ export declare function identity<T>(value: T): T;
22
+ /**
23
+ * Returns a function that always returns `value`.
24
+ * @example
25
+ * const alwaysTrue = constant(true);
26
+ * alwaysTrue(); // => true
27
+ */
28
+ export declare function constant<T>(value: T): () => T;
29
+ /**
30
+ * Inverts a predicate.
31
+ * @example
32
+ * [1, 2, 3].filter(negate((n: number) => n % 2 === 0)); // => [1, 3]
33
+ */
34
+ export declare function negate<A extends unknown[]>(predicate: (...args: A) => unknown): (...args: A) => boolean;
35
+ /**
36
+ * Calls `fn` only on the first call; later calls return the first result (or rethrow the first error).
37
+ * @example
38
+ * let setups = 0;
39
+ * const init = once(() => ++setups);
40
+ * init();
41
+ * init(); // => 1 // returns the first result
42
+ * setups; // => 1
43
+ */
44
+ export declare function once<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R;
45
+ /**
46
+ * Calls `fn` for the first `n - 1` calls; afterwards returns the last result without calling it.
47
+ * @example
48
+ * let attempts = 0;
49
+ * const tryLogin = before(3, () => ++attempts); // runs on calls 1 and 2 only
50
+ * [tryLogin(), tryLogin(), tryLogin()]; // => [1, 2, 2]
51
+ */
52
+ export declare function before<A extends unknown[], R>(n: number, fn: (...args: A) => R): (...args: A) => R | undefined;
53
+ /**
54
+ * Calls `fn` only from the `n`th call onwards; earlier calls return `undefined`.
55
+ * @example
56
+ * const uploads = ['contract.pdf', 'id-card.png'];
57
+ * const done = after(uploads.length, () => 'All files uploaded.');
58
+ * [done(), done()]; // => [undefined, 'All files uploaded.']
59
+ */
60
+ export declare function after<A extends unknown[], R>(n: number, fn: (...args: A) => R): (...args: A) => R | undefined;
61
+ /**
62
+ * Left-to-right composition: `pipe(f, g)(x) === g(f(x))`. The first function may take several arguments.
63
+ * @example
64
+ * const slug = pipe((s: string) => s.trim(), (s) => s.toLowerCase(), (s) => s.replaceAll(' ', '-'));
65
+ * slug(' Hello World '); // => 'hello-world'
66
+ */
67
+ export declare function pipe<A extends unknown[], B>(ab: (...a: A) => B): (...a: A) => B;
68
+ export declare function pipe<A extends unknown[], B, C>(ab: (...a: A) => B, bc: (b: B) => C): (...a: A) => C;
69
+ export declare function pipe<A extends unknown[], B, C, D>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...a: A) => D;
70
+ export declare function pipe<A extends unknown[], B, C, D, E>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): (...a: A) => E;
71
+ export declare function pipe<A extends unknown[], B, C, D, E, F>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): (...a: A) => F;
72
+ export declare function pipe<A extends unknown[], B, C, D, E, F, G>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): (...a: A) => G;
73
+ export declare function pipe<A extends unknown[], B, C, D, E, F, G, H>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H): (...a: A) => H;
74
+ export declare function pipe<A extends unknown[], B, C, D, E, F, G, H, I>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I): (...a: A) => I;
75
+ export declare function pipe<A extends unknown[], B, C, D, E, F, G, H, I, J>(ab: (...a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H, hi: (h: H) => I, ij: (i: I) => J): (...a: A) => J;
76
+ /**
77
+ * Right-to-left composition: `compose(g, f)(x) === g(f(x))`. The last function may take several arguments.
78
+ * @example
79
+ * const shout = compose((s: string) => `${s}!`, (s: string) => s.toUpperCase());
80
+ * shout('hi'); // => 'HI!'
81
+ */
82
+ export declare function compose<A extends unknown[], B>(ab: (...a: A) => B): (...a: A) => B;
83
+ export declare function compose<A extends unknown[], B, C>(bc: (b: B) => C, ab: (...a: A) => B): (...a: A) => C;
84
+ export declare function compose<A extends unknown[], B, C, D>(cd: (c: C) => D, bc: (b: B) => C, ab: (...a: A) => B): (...a: A) => D;
85
+ export declare function compose<A extends unknown[], B, C, D, E>(de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...a: A) => B): (...a: A) => E;
86
+ export declare function compose<A extends unknown[], B, C, D, E, F>(ef: (e: E) => F, de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...a: A) => B): (...a: A) => F;
87
+ export declare function compose<A extends unknown[], B, C, D, E, F, G>(fg: (f: F) => G, ef: (e: E) => F, de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...a: A) => B): (...a: A) => G;
88
+ export declare function compose<A extends unknown[], B, C, D, E, F, G, H>(gh: (g: G) => H, fg: (f: F) => G, ef: (e: E) => F, de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...a: A) => B): (...a: A) => H;
89
+ export declare function compose<A extends unknown[], B, C, D, E, F, G, H, I>(hi: (h: H) => I, gh: (g: G) => H, fg: (f: F) => G, ef: (e: E) => F, de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...a: A) => B): (...a: A) => I;
90
+ export declare function compose<A extends unknown[], B, C, D, E, F, G, H, I, J>(ij: (i: I) => J, hi: (h: H) => I, gh: (g: G) => H, fg: (f: F) => G, ef: (e: E) => F, de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...a: A) => B): (...a: A) => J;
91
+ /**
92
+ * Wraps `fn` to run it for side effects and pass the value through.
93
+ * @example
94
+ * const seen: number[] = [];
95
+ * const double = pipe((s: string) => Number(s), tap((n: number) => { seen.push(n); }), (n) => n * 2);
96
+ * double('21'); // => 42
97
+ * seen; // => [21]
98
+ */
99
+ export declare function tap<T>(fn: (value: T) => void): (value: T) => T;
100
+ /**
101
+ * Runs `fn`, returning a `Result` instead of throwing.
102
+ * @example
103
+ * const r = attempt(() => JSON.parse('{"active":true}') as unknown); // => { ok: true, value: { active: true } }
104
+ * attempt(() => JSON.parse('{')).ok; // => false
105
+ */
106
+ export declare function attempt<R>(fn: () => R): Result<R>;
107
+ /**
108
+ * Calls `fn(...args)` when `condition` is truthy; otherwise returns `undefined`.
109
+ * @example
110
+ * const add = (a: number, b: number): number => a + b;
111
+ * callIf(true, add, 2, 3); // => 5
112
+ * callIf(false, add, 2, 3); // => undefined
113
+ */
114
+ export declare function callIf<A extends unknown[], R>(condition: unknown, fn: (...args: A) => R, ...args: A): R | undefined;
115
+ /**
116
+ * Runs `fn`, swallowing any throw: returns `undefined` and reports the error to `onError` (if given).
117
+ * Use for optional user callbacks that must not break the caller.
118
+ * @example
119
+ * const errors: string[] = [];
120
+ * safeCall(() => { throw new Error('onChange failed.'); }, (e) => { errors.push(e.message); }); // => undefined
121
+ * errors; // => ['onChange failed.']
122
+ */
123
+ export declare function safeCall<R>(fn: () => R, onError?: (error: Error) => void): R | undefined;
124
+ /**
125
+ * Limits `fn` to its first argument (for `map(parseInt)`-style pitfalls).
126
+ * @example
127
+ * ['1', '2', '3'].map(unary(parseInt)); // => [1, 2, 3]
128
+ */
129
+ export declare function unary<T, R>(fn: (value: T, ...rest: never[]) => R): (value: T) => R;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as c,toError as u,tryCatch as d}from"../error/index.js";import{debounce as m,throttle as h,rafThrottle as G}from"./timing.js";import{memoize as T,memoizeOne as I}from"./memo.js";const i=()=>{};function p(n){return n}function A(n){return()=>n}function s(n){return(...e)=>!n(...e)}function b(n){let e;return(...o)=>{if(!e)try{e={ok:!0,value:n(...o)}}catch(t){e={ok:!1,error:t}}if(e.ok)return e.value;throw u(e.error)}}function a(n){if(!Number.isSafeInteger(n)||n<0)throw new c("HLP_FN_INVALID_COUNT","Count must be a non-negative integer.")}function x(n,e){a(n);let o=0,t;return(...r)=>(o++,o<n&&(t=e(...r)),t)}function B(n,e){a(n);let o=0;return(...t)=>(o++,o>=n?e(...t):void 0)}function C(n,...e){return(...o)=>{let t=n(...o);for(const r of e)t=r(t);return t}}function D(...n){return(...e)=>{let o=n.length-1;const t=n[o];if(!t)return e[0];let r=t(...e);for(o--;o>=0;o--)r=n[o](r);return r}}function k(n){return e=>(n(e),e)}function w(n){return d(n)}function g(n,e,...o){return n?e(...o):void 0}function E(n,e){try{return n()}catch(o){e?.(u(o));return}}function l(n){return e=>n(e)}export{B as after,w as attempt,x as before,g as callIf,D as compose,A as constant,m as debounce,p as identity,T as memoize,I as memoizeOne,s as negate,i as noop,b as once,C as pipe,G as rafThrottle,E as safeCall,k as tap,h as throttle,l as unary};
@@ -0,0 +1,46 @@
1
+ export interface MemoizeOptions<A extends unknown[]> {
2
+ /** Cache key from the arguments. Default: the first argument (compared with SameValueZero). */
3
+ readonly key?: (...args: A) => unknown;
4
+ /** Maximum cached results; least recently used are evicted. Default 1000. */
5
+ readonly maxSize?: number;
6
+ /** Time to live per result in ms. Default: no expiry. */
7
+ readonly ttlMs?: number;
8
+ /** Clock in ms, injectable for tests. Default `Date.now`. */
9
+ readonly now?: () => number;
10
+ }
11
+ /** A memoized function with cache controls. */
12
+ export interface Memoized<A extends unknown[], R> {
13
+ (...args: A): R;
14
+ /** Drops every cached result. */
15
+ clear(): void;
16
+ /** Drops the result cached for these arguments. */
17
+ delete(...args: A): boolean;
18
+ /** Number of cached results. */
19
+ readonly size: number;
20
+ }
21
+ /**
22
+ * Caches results of `fn` in a bounded LRU map (default 1000 entries), optionally with a TTL.
23
+ * Throws are not cached; returned promises are (including ones that later reject - clear on failure if needed).
24
+ * @example
25
+ * const fib = memoize((n: number): number => (n < 2 ? n : fib(n - 1) + fib(n - 2)));
26
+ * fib(50); // => 12586269025
27
+ * let loads = 0;
28
+ * const label = memoize((id: string, lang: string) => { loads++; return `${id}:${lang}`; }, { key: (id, lang) => `${id}|${lang}`, ttlMs: 60_000 });
29
+ * label('EMP-1', 'de');
30
+ * label('EMP-1', 'de'); // => 'EMP-1:de'
31
+ * loads; // => 1
32
+ */
33
+ export declare function memoize<A extends unknown[], R>(fn: (...args: A) => R, options?: MemoizeOptions<A>): Memoized<A, R>;
34
+ /**
35
+ * Remembers only the latest call: returns the cached result while the arguments are equal
36
+ * (same length, each `Object.is`, or a custom `isEqual`).
37
+ * @example
38
+ * interface Row { name: string }
39
+ * let runs = 0;
40
+ * const visible = memoizeOne((rows: Row[], filter: string) => { runs++; return rows.filter((r) => r.name.includes(filter)); });
41
+ * const rows: Row[] = [{ name: 'Ada' }, { name: 'Grace' }];
42
+ * visible(rows, 'Ad'); // => [{ name: 'Ada' }]
43
+ * visible(rows, 'Ad'); // same arguments: cached
44
+ * runs; // => 1
45
+ */
46
+ export declare function memoizeOne<A extends unknown[], R>(fn: (...args: A) => R, isEqual?: (next: A, prev: A) => boolean): (...args: A) => R;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as c}from"../error/index.js";function x(o,t={}){const e=t.maxSize??1e3;if(!Number.isSafeInteger(e)||e<1)throw new c("HLP_FN_INVALID_SIZE","maxSize must be a positive integer.");const r=t.ttlMs;if(r!==void 0&&(!Number.isFinite(r)||r<=0))throw new c("HLP_FN_INVALID_TTL","ttlMs must be a finite number greater than zero.");const a=t.key??((...i)=>i[0]),d=t.now??Date.now,n=new Map,s=(...i)=>{const u=a(...i),l=n.get(u);if(l&&(n.delete(u),l.expires>d()))return n.set(u,l),l.value;const m=o(...i);if(n.set(u,{value:m,expires:r===void 0?1/0:d()+r}),n.size>e){const f=n.keys().next();f.done||n.delete(f.value)}return m};return s.clear=()=>{n.clear()},s.delete=(...i)=>n.delete(a(...i)),Object.defineProperty(s,"size",{get:()=>n.size,enumerable:!0}),s}function z(o,t=A){let e;return(...r)=>{if(e&&t(r,e.args))return e.value;const a=o(...r);return e={args:r,value:a},a}}function A(o,t){if(o.length!==t.length)return!1;for(let e=0;e<o.length;e++)if(!Object.is(o[e],t[e]))return!1;return!0}export{x as memoize,z as memoizeOne};
@@ -0,0 +1,64 @@
1
+ export interface DebounceOptions {
2
+ /** Invoke on the leading edge. Default false. */
3
+ readonly leading?: boolean;
4
+ /** Invoke on the trailing edge. Default true. */
5
+ readonly trailing?: boolean;
6
+ /** Maximum ms `fn` may be delayed; guarantees periodic calls under constant input. */
7
+ readonly maxWait?: number;
8
+ }
9
+ /** A debounced function with control methods. Returns the result of the last invocation. */
10
+ export interface Debounced<A extends unknown[], R> {
11
+ (...args: A): R | undefined;
12
+ /** Drops any pending invocation. */
13
+ cancel(): void;
14
+ /** Runs a pending invocation now and returns its result (or the last result). */
15
+ flush(): R | undefined;
16
+ /** True while an invocation is scheduled. */
17
+ pending(): boolean;
18
+ }
19
+ /**
20
+ * Delays calling `fn` until `wait` ms have passed since the last call (lodash-compatible edges and
21
+ * `maxWait`). `this` is not forwarded; wrap methods in an arrow function.
22
+ * @example
23
+ * const saved: string[] = [];
24
+ * const save = debounce((text: string) => { saved.push(text); }, 300);
25
+ * save('D');
26
+ * save('Dr');
27
+ * save('Draft');
28
+ * save.flush(); // runs the pending call now (e.g. on beforeunload)
29
+ * saved; // => ['Draft']
30
+ */
31
+ export declare function debounce<A extends unknown[], R>(fn: (...args: A) => R, wait: number, options?: DebounceOptions): Debounced<A, R>;
32
+ export interface ThrottleOptions {
33
+ /** Invoke on the leading edge. Default true. */
34
+ readonly leading?: boolean;
35
+ /** Invoke on the trailing edge with the latest arguments. Default true. */
36
+ readonly trailing?: boolean;
37
+ }
38
+ /**
39
+ * Calls `fn` at most once per `wait` ms (leading and trailing by default).
40
+ * @example
41
+ * let calls = 0;
42
+ * const onScroll = throttle(() => { calls++; }, 100);
43
+ * onScroll();
44
+ * onScroll();
45
+ * onScroll();
46
+ * calls; // => 1 // leading call; the others merge into one trailing call
47
+ * onScroll.cancel();
48
+ */
49
+ export declare function throttle<A extends unknown[], R>(fn: (...args: A) => R, wait: number, options?: ThrottleOptions): Debounced<A, R>;
50
+ /** A frame-throttled function. */
51
+ export interface FrameThrottled<A extends unknown[]> {
52
+ (...args: A): void;
53
+ /** Drops the scheduled call. */
54
+ cancel(): void;
55
+ }
56
+ /**
57
+ * Calls `fn` at most once per animation frame with the latest arguments. Uses `requestAnimationFrame`
58
+ * when available at call time, otherwise a 16 ms timer (SSR/Node/workers). No global access at import.
59
+ * @example
60
+ * declare const handle: HTMLElement;
61
+ * const onMove = rafThrottle((e: PointerEvent) => { handle.style.translate = `${e.clientX}px ${e.clientY}px`; });
62
+ * handle.addEventListener('pointermove', onMove); // at most one update per frame
63
+ */
64
+ export declare function rafThrottle<A extends unknown[]>(fn: (...args: A) => void): FrameThrottled<A>;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{ValidationError as p}from"../error/index.js";function h(a,n){if(!Number.isFinite(a)||a<0)throw new p("HLP_FN_INVALID_WAIT","Wait must be a finite number of milliseconds >= 0.",{details:{name:n}})}function W(a,n,t={}){h(n,"wait");const f=t.leading??!1,c=t.trailing??!0;let d;t.maxWait!==void 0&&(h(t.maxWait,"maxWait"),d=Math.max(t.maxWait,n));let u,o,i,l,s=0;const A=e=>{const r=u;return u=void 0,s=e,r&&(o=a(...r)),o},R=e=>{const r=e-(l??0),g=n-r;return d===void 0?g:Math.min(g,d-(e-s))},T=e=>{if(l===void 0)return!0;const r=e-l;return r>=n||r<0||d!==void 0&&e-s>=d},x=e=>(i=void 0,c&&u?A(e):(u=void 0,o)),m=()=>{const e=Date.now();if(T(e)){x(e);return}i=setTimeout(m,R(e))},v=e=>(s=e,i=setTimeout(m,n),f?A(e):o),b=(...e)=>{const r=Date.now(),g=T(r);if(u=e,l=r,g){if(i===void 0)return v(r);if(d!==void 0)return clearTimeout(i),i=setTimeout(m,n),A(r)}return i??=setTimeout(m,n),o};return b.cancel=()=>{i!==void 0&&clearTimeout(i),s=0,u=l=i=void 0},b.flush=()=>i===void 0?o:(clearTimeout(i),x(Date.now())),b.pending=()=>i!==void 0,b}function y(a,n,t={}){return W(a,n,{leading:t.leading??!0,trailing:t.trailing??!0,maxWait:n})}function D(a){let n,t;const f=()=>{t=void 0;const d=n;n=void 0,d&&a(...d)},c=(...d)=>{if(n=d,t)return;const u=typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame.bind(globalThis):void 0;if(u){const o=u(f);t=()=>{globalThis.cancelAnimationFrame(o)}}else{const o=setTimeout(f,16);t=()=>{clearTimeout(o)}}};return c.cancel=()=>{t?.(),t=void 0,n=void 0},c}export{W as debounce,D as rafThrottle,y as throttle};
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Decodes an RFC 8187 / RFC 5987 `ext-value` such as `UTF-8''na%C3%AFve.txt`. Supports UTF-8
3
+ * and ISO-8859-1; returns `undefined` for other charsets or malformed encoding.
4
+ * @example decodeExtValue("UTF-8''%E2%82%AC%20rates") // => '€ rates'
5
+ */
6
+ export declare function decodeExtValue(value: string): string | undefined;
7
+ export interface ContentType {
8
+ /** Lowercased top-level type, e.g. `application`. */
9
+ readonly type: string;
10
+ /** Lowercased subtype, e.g. `problem+json`. */
11
+ readonly subtype: string;
12
+ /** Structured syntax suffix including `+`, e.g. `+json`; `''` when absent. */
13
+ readonly suffix: string;
14
+ /** `type/subtype`. */
15
+ readonly mediaType: string;
16
+ /** Parameters with lowercased names (`charset` value lowercased too). */
17
+ readonly params: Readonly<Record<string, string>>;
18
+ }
19
+ /**
20
+ * Parses a `Content-Type` value.
21
+ * @example parseContentType('application/json; charset=UTF-8') // => { type: 'application', subtype: 'json', suffix: '', mediaType: 'application/json', params: { charset: 'utf-8' } }
22
+ */
23
+ export declare function parseContentType(value: string | null | undefined): ContentType | undefined;
24
+ /**
25
+ * True for `application/json` and any `+json` media type (`application/problem+json`).
26
+ * @example isJsonContentType('application/vnd.api+json') // => true
27
+ */
28
+ export declare function isJsonContentType(value: string | null | undefined): boolean;
29
+ export interface ContentDisposition {
30
+ /** Lowercased disposition type: `attachment`, `inline`, `form-data`... */
31
+ readonly type: string;
32
+ /** Decoded file name as sent (`filename*` preferred over `filename`); may be unsafe. */
33
+ readonly filename: string | undefined;
34
+ /** File name reduced to a base name and passed through `safeFileName`. */
35
+ readonly safeFilename: string | undefined;
36
+ readonly params: Readonly<Record<string, string>>;
37
+ }
38
+ /**
39
+ * Parses `Content-Disposition` (RFC 6266), decoding `filename*` (RFC 8187) and producing a
40
+ * sanitized file name candidate for saving.
41
+ * @example parseContentDisposition(`attachment; filename="plain.txt"; filename*=UTF-8''%E2%82%AC.txt`)?.filename // => '€.txt'
42
+ */
43
+ export declare function parseContentDisposition(value: string | null | undefined): ContentDisposition | undefined;
44
+ export interface CacheControl {
45
+ readonly maxAge?: number;
46
+ readonly sMaxAge?: number;
47
+ readonly staleWhileRevalidate?: number;
48
+ readonly staleIfError?: number;
49
+ /** `max-stale` without a value is `Infinity`. */
50
+ readonly maxStale?: number;
51
+ readonly minFresh?: number;
52
+ readonly noCache: boolean;
53
+ readonly noStore: boolean;
54
+ readonly noTransform: boolean;
55
+ readonly mustRevalidate: boolean;
56
+ readonly proxyRevalidate: boolean;
57
+ readonly mustUnderstand: boolean;
58
+ readonly private: boolean;
59
+ readonly public: boolean;
60
+ readonly immutable: boolean;
61
+ readonly onlyIfCached: boolean;
62
+ /** Every directive (lowercased) with its value, or `true` when it has none. */
63
+ readonly directives: Readonly<Record<string, string | true>>;
64
+ }
65
+ /**
66
+ * Parses `Cache-Control` (RFC 9111). Invalid delta-seconds are ignored; values over 2^31 are capped.
67
+ * @example parseCacheControl('public, max-age=3600, stale-while-revalidate=60').maxAge // => 3600
68
+ */
69
+ export declare function parseCacheControl(value: string | null | undefined): CacheControl;
70
+ export interface ETag {
71
+ readonly weak: boolean;
72
+ /** The opaque tag without quotes. */
73
+ readonly tag: string;
74
+ }
75
+ /**
76
+ * Parses one entity tag (`"abc"` or `W/"abc"`), RFC 9110 section 8.8.3.
77
+ * @example parseETag('W/"v1"') // => { weak: true, tag: 'v1' }
78
+ */
79
+ export declare function parseETag(value: string | null | undefined): ETag | undefined;
80
+ /**
81
+ * Parses an `If-Match` / `If-None-Match` list: `'*'` or entity tags (invalid members skipped).
82
+ * @example parseETagList('"a", W/"b"') // => [{ weak: false, tag: 'a' }, { weak: true, tag: 'b' }]
83
+ */
84
+ export declare function parseETagList(value: string | null | undefined): '*' | ETag[];
85
+ /**
86
+ * Compares entity tags (RFC 9110 section 8.8.3.2). Weak comparison (default) ignores the `W/` flag;
87
+ * strong comparison requires both to be strong. Unparseable tags never match.
88
+ * @example etagMatches('W/"1"', '"1"') // => true
89
+ * @example etagMatches('W/"1"', '"1"', { weak: false }) // => false
90
+ */
91
+ export declare function etagMatches(a: string | ETag | null | undefined, b: string | ETag | null | undefined, options?: {
92
+ readonly weak?: boolean;
93
+ }): boolean;
94
+ /**
95
+ * True when `etag` matches an `If-None-Match` (weak) or `If-Match` (`weak: false`) header.
96
+ * @example etagMatchesAny('"a", "b"', '"b"') // => true
97
+ */
98
+ export declare function etagMatchesAny(header: string | null | undefined, etag: string | ETag | null | undefined, options?: {
99
+ readonly weak?: boolean;
100
+ }): boolean;
101
+ export interface LanguageRange {
102
+ /** Language range as sent (`en-GB`, `*`). */
103
+ readonly tag: string;
104
+ /** Quality 0.001-1. */
105
+ readonly q: number;
106
+ }
107
+ /**
108
+ * Parses `Accept-Language`, drops `q=0` and malformed entries, and sorts by quality
109
+ * (stable for ties). At most `max` entries (default 50) are read.
110
+ * @example parseAcceptLanguage('fr-CH, fr;q=0.9, en;q=0.8, *;q=0.5') // => [{ tag: 'fr-CH', q: 1 }, { tag: 'fr', q: 0.9 }, { tag: 'en', q: 0.8 }, { tag: '*', q: 0.5 }]
111
+ */
112
+ export declare function parseAcceptLanguage(value: string | null | undefined, max?: number): LanguageRange[];
113
+ export interface Link {
114
+ /** Target URI (resolved against `baseUrl` when given). */
115
+ readonly uri: string;
116
+ /** Relation types, lowercased (`rel="next last"` -> `['next', 'last']`). */
117
+ readonly rel: readonly string[];
118
+ /** Other parameters (lowercased names; `title*` decoded into `title*`). */
119
+ readonly params: Readonly<Record<string, string>>;
120
+ }
121
+ export interface LinkHeaderOptions {
122
+ /** Resolve relative targets against this URL. */
123
+ readonly baseUrl?: string;
124
+ /** Maximum links; more throws `HLP_HTTP_TOO_MANY_LINKS`. Default 100. */
125
+ readonly maxLinks?: number;
126
+ /** Maximum header length; longer throws `HLP_HTTP_HEADER_TOO_LONG`. Default 16 384. */
127
+ readonly maxLength?: number;
128
+ }
129
+ /**
130
+ * Parses a `Link` header (RFC 8288): multiple links, quoted parameters (commas and semicolons
131
+ * inside quotes), multiple relation types, and RFC 8187 `title*`. Malformed links are skipped.
132
+ * @example parseLinkHeader('<https://api.example.com/items?page=2>; rel="next"')[0]?.rel // => ['next']
133
+ */
134
+ export declare function parseLinkHeader(value: string | null | undefined, options?: LinkHeaderOptions): Link[];
135
+ export interface PaginationLinks {
136
+ readonly next?: string;
137
+ readonly prev?: string;
138
+ readonly first?: string;
139
+ readonly last?: string;
140
+ }
141
+ /**
142
+ * Extracts `next`, `prev` (or `previous`), `first` and `last` targets from a `Link` header.
143
+ * @example getPaginationLinks('<?page=3>; rel="next", <?page=1>; rel="prev"', 'https://api.example.com/items') // => { next: 'https://api.example.com/items?page=3', prev: 'https://api.example.com/items?page=1' }
144
+ */
145
+ export declare function getPaginationLinks(header: string | readonly Link[] | null | undefined, baseUrl?: string): PaginationLinks;
146
+ /**
147
+ * Parses an HTTP-date (RFC 9110 section 5.6.7): IMF-fixdate, obsolete RFC 850 and asctime formats.
148
+ * Returns epoch milliseconds or `undefined`.
149
+ * @example parseHttpDate('Sun, 06 Nov 1994 08:49:37 GMT') // => 784111777000
150
+ */
151
+ export declare function parseHttpDate(value: string | null | undefined, now?: number | Date): number | undefined;
152
+ /**
153
+ * Converts `Retry-After` (delta-seconds or HTTP-date) to a delay in milliseconds, clamped to
154
+ * `0...maxMs` (default one hour). Returns `undefined` when absent or invalid.
155
+ * @example parseRetryAfter('120') // => 120000
156
+ * @example parseRetryAfter('Wed, 21 Oct 2015 07:28:00 GMT', Date.UTC(2015, 9, 21, 7, 27, 0)) // => 60000
157
+ */
158
+ export declare function parseRetryAfter(value: string | null | undefined, now?: number | Date, options?: {
159
+ readonly maxMs?: number;
160
+ }): number | undefined;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{LimitError as w}from"../error/index.js";import{isUnsafeKey as T}from"../internal/keys.js";import{safeFileName as L}from"../sanitize/index.js";const c=16384,A="!#$%&'*+-.^_`|~",M=e=>{const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||e.length===1&&A.includes(e)},R=e=>e===" "||e===" ";function l(e,t){if(e.length>t)throw new w("HLP_HTTP_HEADER_TOO_LONG","The header value exceeds the length limit.",{details:{max:t}})}class g{constructor(t){this.s=t}s;i=0;get done(){return this.i>=this.s.length}peek(){return this.s.charAt(this.i)}ows(){for(;this.i<this.s.length&&R(this.s.charAt(this.i));)this.i++}eat(t){return this.s.charAt(this.i)===t?(this.i++,!0):!1}token(){const t=this.i;for(;this.i<this.s.length&&M(this.s.charAt(this.i));)this.i++;return this.s.slice(t,this.i)}quoted(){if(!this.eat('"'))return;let t="";for(;this.i<this.s.length;){const r=this.s.charAt(this.i++);if(r==='"')return t;r==="\\"&&this.i<this.s.length?t+=this.s.charAt(this.i++):t+=r}}value(){return this.peek()==='"'?this.quoted():this.token()}skipPast(t){for(;this.i<this.s.length;){const r=this.s.charAt(this.i);if(r==='"'){if(this.quoted()===void 0)return;continue}if(this.i++,r===t)return}}}function p(e,t){const r=[];for(;;){if(e.ows(),e.done||t&&e.peek()===",")return r;if(!e.eat(";")){e.i++;continue}e.ows();const n=e.token().toLowerCase();e.ows();let o="";e.eat("=")&&(e.ows(),o=e.value()??""),n!==""&&r.push([n,o])}}function y(e){const t={};for(const[r,n]of e)!T(r)&&!Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=n);return t}function k(e){const t=e.indexOf("'"),r=t<0?-1:e.indexOf("'",t+1);if(r<0)return;const n=e.slice(0,t).toLowerCase(),o=e.slice(r+1),i=[];for(let s=0;s<o.length;s++){const a=o.charAt(s);if(a==="%"){const d=o.slice(s+1,s+3);if(!/^[\da-f]{2}$/i.test(d))return;i.push(parseInt(d,16)),s+=2}else{const d=a.charCodeAt(0);if(d>126||d<=32)return;i.push(d)}}if(n==="utf-8")try{return new TextDecoder("utf-8",{fatal:!0}).decode(Uint8Array.from(i))}catch{return}if(n==="iso-8859-1")return String.fromCharCode(...i)}function O(e){if(typeof e!="string"||e.length>1024)return;const t=new g(e.trim()),r=t.token().toLowerCase();if(r===""||!t.eat("/"))return;const n=t.token().toLowerCase();if(n==="")return;const o=y(p(t,!1));o.charset!==void 0&&(o.charset=o.charset.toLowerCase());const i=n.lastIndexOf("+");return{type:r,subtype:n,suffix:i>0?n.slice(i):"",mediaType:`${r}/${n}`,params:o}}function z(e){const t=O(e);return t!==void 0&&(t.mediaType==="application/json"||t.suffix==="+json")}function K(e){if(typeof e!="string")return;l(e,c);const t=new g(e.trim()),r=t.token().toLowerCase();if(r==="")return;const n=y(p(t,!1)),i=(n["filename*"]===void 0?void 0:k(n["filename*"]))??n.filename;let s;if(i!==void 0){const a=i.slice(Math.max(i.lastIndexOf("/"),i.lastIndexOf("\\"))+1);s=L(a)}return{type:r,filename:i,safeFilename:s,params:n}}const N=2147483648,E=e=>{if(!(typeof e!="string"||!/^\d{1,19}$/.test(e)))return Math.min(Number(e),N)};function v(e){const t={};if(typeof e=="string"){l(e,c);const i=new g(e);for(;!i.done;){i.ows();const s=i.token().toLowerCase();i.ows();let a=!0;i.eat("=")&&(i.ows(),a=i.value()??""),s!==""&&!T(s)&&!Object.prototype.hasOwnProperty.call(t,s)&&(t[s]=a),i.skipPast(",")}}const r=i=>Object.prototype.hasOwnProperty.call(t,i),n={noCache:r("no-cache"),noStore:r("no-store"),noTransform:r("no-transform"),mustRevalidate:r("must-revalidate"),proxyRevalidate:r("proxy-revalidate"),mustUnderstand:r("must-understand"),private:r("private"),public:r("public"),immutable:r("immutable"),onlyIfCached:r("only-if-cached"),directives:t},o=(i,s)=>{const a=E(t[s]);a!==void 0&&(n[i]=a)};return o("maxAge","max-age"),o("sMaxAge","s-maxage"),o("staleWhileRevalidate","stale-while-revalidate"),o("staleIfError","stale-if-error"),o("minFresh","min-fresh"),t["max-stale"]===!0?n.maxStale=1/0:o("maxStale","max-stale"),n}const S=e=>e===33||e>=35&&e<=126||e>=128&&e<=255;function b(e){if(typeof e!="string"||e.length>1024)return;const t=e.trim(),r=t.startsWith("W/"),n=r?t.slice(2):t;if(n.length<2||!n.startsWith('"')||!n.endsWith('"'))return;const o=n.slice(1,-1);for(let i=0;i<o.length;i++)if(!S(o.charCodeAt(i)))return;return{weak:r,tag:o}}function D(e){if(typeof e!="string")return[];if(l(e,c),e.trim()==="*")return"*";const t=[];let r=0;for(;r<e.length&&t.length<1e3;){const n=e.indexOf('"',r);if(n<0)break;const o=e.indexOf('"',n+1);if(o<0)break;const i=e.slice(Math.max(0,n-2),n)==="W/",s=b((i?"W/":"")+e.slice(n,o+1));s&&t.push(s),r=o+1}return t}function _(e,t,r={}){const n=typeof e=="string"||e===null||e===void 0?b(e):e,o=typeof t=="string"||t===null||t===void 0?b(t):t;return!n||n.tag!==o?.tag?!1:r.weak!==!1||!n.weak&&!o.weak}function J(e,t,r={}){const n=D(e);return n==="*"?t!=null:n.some(o=>_(o,t,r))}function G(e,t=50){if(typeof e!="string")return[];l(e,4096);const r=[];for(const n of e.split(",").slice(0,t)){const[o="",...i]=n.split(";"),s=o.trim();if(!/^(?:\*|[a-z]{1,8}(?:-[\da-z]{1,8})*)$/i.test(s))continue;let a=1,d=!0;for(const h of i){const[u="",f=""]=h.split("=").map(m=>m.trim());u.toLowerCase()==="q"&&(/^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/.test(f)?a=Number(f):d=!1)}d&&a>0&&r.push({tag:s,q:a})}return r.map((n,o)=>({e:n,i:o})).sort((n,o)=>o.e.q-n.e.q||n.i-o.i).map(({e:n})=>n)}function P(e,t={}){const{baseUrl:r,maxLinks:n=100,maxLength:o=c}=t;if(typeof e!="string")return[];l(e,o);const i=new g(e),s=[];for(;!i.done;){if(i.ows(),i.eat(","))continue;if(!i.eat("<")){i.skipPast(",");continue}const a=e.indexOf(">",i.i);if(a<0)break;let d=e.slice(i.i,a).trim();i.i=a+1;const h=p(i,!0),u=y(h),f=u["title*"]===void 0?void 0:k(u["title*"]);f!==void 0&&(u["title*"]=f);const m=(u.rel??"").toLowerCase().split(/[\t ]+/).filter(C=>C!=="");if(r!==void 0)try{d=new URL(d,r).href}catch{continue}if(s.length>=n)throw new w("HLP_HTTP_TOO_MANY_LINKS","The Link header has too many links.",{details:{maxLinks:n}});s.push({uri:d,rel:m,params:u})}return s}function X(e,t){const r=typeof e=="string"||e===null||e===void 0?P(e,t===void 0?{}:{baseUrl:t}):e,n={};for(const o of r)for(const i of o.rel){const s=i==="previous"?"prev":i;(s==="next"||s==="prev"||s==="first"||s==="last")&&n[s]===void 0&&(n[s]=o.uri)}return n}const F=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],I=/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d{2}) ([A-Z][a-z]{2}) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT$/,H=/^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d{2})-([A-Z][a-z]{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}) GMT$/,W=/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) ([A-Z][a-z]{2}) ([\d ]\d) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/;function x(e,t,r,n,o,i){const s=F.indexOf(t);if(s<0||n>23||o>59||i>60)return;const a=Date.UTC(e,s,r,n,o,Math.min(i,59)),d=new Date(a);return d.getUTCDate()===r&&d.getUTCMonth()===s?a:void 0}function $(e,t=Date.now()){if(typeof e!="string"||e.length>64)return;const r=e.trim();let n=I.exec(r);if(n)return x(Number(n[3]),n[2]??"",Number(n[1]),Number(n[4]),Number(n[5]),Number(n[6]));if(n=H.exec(r),n){const o=new Date(t).getUTCFullYear();let i=Math.floor(o/100)*100+Number(n[3]);return i>o+50&&(i-=100),x(i,n[2]??"",Number(n[1]),Number(n[4]),Number(n[5]),Number(n[6]))}if(n=W.exec(r),n)return x(Number(n[6]),n[1]??"",Number((n[2]??"").trim()),Number(n[3]),Number(n[4]),Number(n[5]))}function Y(e,t=Date.now(),r={}){const{maxMs:n=36e5}=r;if(typeof e!="string")return;const o=e.trim();if(/^\d{1,12}$/.test(o))return Math.min(Number(o)*1e3,n);const i=$(o,t);if(i===void 0)return;const s=typeof t=="number"?t:t.getTime();return Math.min(Math.max(0,i-s),n)}export{k as decodeExtValue,_ as etagMatches,J as etagMatchesAny,X as getPaginationLinks,z as isJsonContentType,G as parseAcceptLanguage,v as parseCacheControl,K as parseContentDisposition,O as parseContentType,b as parseETag,D as parseETagList,$ as parseHttpDate,P as parseLinkHeader,Y as parseRetryAfter};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Pure HTTP helpers: status classification and retryability, Retry-After, RFC 9457 Problem
3
+ * Details, RFC 8288 Link, content type and disposition, cache control, ETags, Accept-Language,
4
+ * response assertions and user-facing messages (docs/PLAN-HELPERS.md section 2). No fetch.
5
+ */
6
+ export { httpStatus, statusText, isInformational, isSuccess, isRedirect, isClientError, isServerError, isRetryableStatus, DEFAULT_RETRYABLE_STATUSES, isIdempotentMethod, isSafeMethod, userMessageForStatus, DEFAULT_STATUS_MESSAGES, statusClass, statusMessageCatalog, localizedStatusMessages, composeStatusMessages, describeStatus, type HttpStatusName, type StatusMessageCatalog, type StatusMessages, type StatusClass, type StatusDescription, } from './status.js';
7
+ export { parseContentType, isJsonContentType, parseContentDisposition, decodeExtValue, parseCacheControl, parseETag, parseETagList, etagMatches, etagMatchesAny, parseAcceptLanguage, parseLinkHeader, getPaginationLinks, parseHttpDate, parseRetryAfter, type ContentType, type ContentDisposition, type CacheControl, type ETag, type LanguageRange, type Link, type LinkHeaderOptions, type PaginationLinks, } from './headers.js';
8
+ export { parseProblemDetails, problemToFieldErrors, isProblemDetails, type ProblemDetails } from './problem.js';
9
+ export { assertResponse, classifyHttpError, safeUrlForLog, type ResponseLike, type AssertResponseOptions, type HttpErrorCategory } from './response.js';
10
+ export { httpFailureCategory, type HttpFailureCategory } from '../error/index.js';
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{httpStatus as s,statusText as a,isInformational as r,isSuccess as o,isRedirect as p,isClientError as i,isServerError as n,isRetryableStatus as y,DEFAULT_RETRYABLE_STATUSES as g,isIdempotentMethod as l,isSafeMethod as S,userMessageForStatus as u,DEFAULT_STATUS_MESSAGES as C,statusClass as E,statusMessageCatalog as c,localizedStatusMessages as T,composeStatusMessages as m,describeStatus as L}from"./status.js";import{parseContentType as M,isJsonContentType as f,parseContentDisposition as A,decodeExtValue as D,parseCacheControl as R,parseETag as h,parseETagList as x,etagMatches as F,etagMatchesAny as H,parseAcceptLanguage as b,parseLinkHeader as k,getPaginationLinks as P,parseHttpDate as U,parseRetryAfter as _}from"./headers.js";import{parseProblemDetails as O,problemToFieldErrors as v,isProblemDetails as z}from"./problem.js";import{assertResponse as G,classifyHttpError as J,safeUrlForLog as N}from"./response.js";import{httpFailureCategory as Y}from"../error/index.js";export{g as DEFAULT_RETRYABLE_STATUSES,C as DEFAULT_STATUS_MESSAGES,G as assertResponse,J as classifyHttpError,m as composeStatusMessages,D as decodeExtValue,L as describeStatus,F as etagMatches,H as etagMatchesAny,P as getPaginationLinks,Y as httpFailureCategory,s as httpStatus,i as isClientError,l as isIdempotentMethod,r as isInformational,f as isJsonContentType,z as isProblemDetails,p as isRedirect,y as isRetryableStatus,S as isSafeMethod,n as isServerError,o as isSuccess,T as localizedStatusMessages,b as parseAcceptLanguage,R as parseCacheControl,A as parseContentDisposition,M as parseContentType,h as parseETag,x as parseETagList,U as parseHttpDate,k as parseLinkHeader,O as parseProblemDetails,_ as parseRetryAfter,v as problemToFieldErrors,N as safeUrlForLog,E as statusClass,c as statusMessageCatalog,a as statusText,u as userMessageForStatus};
@@ -0,0 +1,37 @@
1
+ /** Normalized problem details. Members with the wrong JSON type are ignored (RFC 9457 section 3.1). */
2
+ export interface ProblemDetails {
3
+ /** Problem type URI; `'about:blank'` when absent. */
4
+ readonly type: string;
5
+ readonly title?: string;
6
+ readonly status?: number;
7
+ readonly detail?: string;
8
+ readonly instance?: string;
9
+ /** Every other member (unsafe keys dropped). */
10
+ readonly extensions: Readonly<Record<string, unknown>>;
11
+ /** Field errors extracted with {@link problemToFieldErrors}. */
12
+ readonly fieldErrors: Readonly<Record<string, string>>;
13
+ }
14
+ /**
15
+ * True for an object that looks like RFC 9457 problem details: at least one of `type`,
16
+ * `title` or `status`, and every standard member present has the right type.
17
+ * @example isProblemDetails({ title: 'Out of credit', status: 403 }) // => true
18
+ */
19
+ export declare function isProblemDetails(value: unknown): value is Record<string, unknown>;
20
+ /**
21
+ * Extracts field errors from common problem-details extensions: `invalid-params`
22
+ * (`[{ name, reason }]`, RFC 7807), `errors` as `[{ detail, pointer }]` (RFC 9457 example),
23
+ * `[{ field, message }]`, or `{ field: string | string[] }` (ASP.NET), and `violations`
24
+ * (`[{ field, message }]`). Pointers become paths like `items[2].qty`; first message per field.
25
+ * @example problemToFieldErrors({ errors: [{ detail: 'must be positive', pointer: '#/age' }] }) // => { age: 'must be positive' }
26
+ */
27
+ export declare function problemToFieldErrors(problem: unknown, maxFields?: number): Record<string, string>;
28
+ /**
29
+ * Parses RFC 9457 problem details from a JSON string or an already-parsed value. Returns
30
+ * `undefined` when the input is not a problem-details object. JSON text over `maxLength`
31
+ * (default 1 000 000) throws `HLP_HTTP_PROBLEM_TOO_LARGE`.
32
+ * @example parseProblemDetails('{"type":"https://example.com/probs/out-of-credit","title":"You do not have enough credit.","status":403,"balance":30}')
33
+ * // { type: 'https://example.com/probs/out-of-credit', title: '…', status: 403, extensions: { balance: 30 }, fieldErrors: {} }
34
+ */
35
+ export declare function parseProblemDetails(input: unknown, options?: {
36
+ readonly maxLength?: number;
37
+ }): ProblemDetails | undefined;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{LimitError as y}from"../error/index.js";import{isUnsafeKey as l}from"../internal/keys.js";import{isPlainObject as d}from"../is/index.js";const g=new Set(["type","title","status","detail","instance"]);function P(n){if(!d(n))return!1;const{type:t,title:i,status:s,detail:e,instance:r}=n;return t!==void 0&&typeof t!="string"||i!==void 0&&typeof i!="string"||s!==void 0&&!(Number.isInteger(s)&&s>=100&&s<=599)||e!==void 0&&typeof e!="string"||r!==void 0&&typeof r!="string"?!1:t!==void 0||i!==void 0||s!==void 0}function p(n){let t=n.startsWith("#")?n.slice(1):n;if(!t.startsWith("/"))return t.startsWith("$.")?t.slice(2):t;t=t.slice(1);let i="";for(const s of t.split("/")){let e=s.replaceAll("~1","/").replaceAll("~0","~");try{e=decodeURIComponent(e)}catch{}i+=/^\d+$/.test(e)?`[${e}]`:i===""?e:`.${e}`}return i}const m=n=>{if(typeof n=="string")return n;if(Array.isArray(n))return n.find(t=>typeof t=="string")};function b(n,t=200){const i={};if(!d(n))return i;const s=d(n.extensions)?{...n.extensions,...n}:n,e=(o,a)=>{const u=typeof o=="string"?p(o.trim()):void 0,c=m(a);u===void 0||c===void 0||l(u)||Object.keys(i).length>=t||Object.prototype.hasOwnProperty.call(i,u)||(i[u]=c)},r=o=>{if(Array.isArray(o))for(const a of o.slice(0,t))d(a)&&e(a.pointer??a.field??a.name??a.path??a.propertyPath??a.parameter,a.detail??a.reason??a.message??a.title)};r(s["invalid-params"]),r(s.violations);const f=s.errors;if(Array.isArray(f))r(f);else if(d(f))for(const o of Object.keys(f).slice(0,t))e(o,f[o]);return i}function R(n,t={}){const{maxLength:i=1e6}=t;let s=n;if(typeof n=="string"){if(n.length>i)throw new y("HLP_HTTP_PROBLEM_TOO_LARGE","The problem details document is too large.",{details:{maxLength:i}});try{s=JSON.parse(n,(o,a)=>l(o)?void 0:a)}catch{return}}if(!d(s))return;const e=s,r={type:typeof e.type=="string"&&e.type!==""?e.type:"about:blank",extensions:{},fieldErrors:{}};typeof e.title=="string"&&(r.title=e.title),Number.isInteger(e.status)&&e.status>=100&&e.status<=599&&(r.status=e.status),typeof e.detail=="string"&&(r.detail=e.detail),typeof e.instance=="string"&&(r.instance=e.instance);const f={};for(const o of Object.keys(e))!g.has(o)&&!l(o)&&(f[o]=e[o]);if(r.extensions=f,r.fieldErrors=b(e),!(r.title===void 0&&r.status===void 0&&r.detail===void 0&&e.type===void 0))return r}export{P as isProblemDetails,R as parseProblemDetails,b as problemToFieldErrors};
@@ -0,0 +1,43 @@
1
+ /** Minimal response shape (satisfied by the Fetch API `Response`). */
2
+ export interface ResponseLike {
3
+ readonly status: number;
4
+ readonly statusText?: string;
5
+ readonly url?: string;
6
+ readonly headers: {
7
+ get(name: string): string | null;
8
+ };
9
+ }
10
+ export interface AssertResponseOptions {
11
+ /** Accepted status(es) or predicate. Default: any 2xx. */
12
+ readonly expectStatus?: number | readonly number[] | ((status: number) => boolean);
13
+ /** `'json'` (`application/json` or `+json`), a media type, or a list of media types. */
14
+ readonly expectContentType?: 'json' | (string & {}) | readonly string[];
15
+ /** Request method, recorded on the error. */
16
+ readonly method?: string;
17
+ }
18
+ /**
19
+ * Strips credentials, query and fragment from a URL so it is safe to log.
20
+ * @example safeUrlForLog('https://u:p@api.example.com/a?token=x#f') // => 'https://api.example.com/a'
21
+ */
22
+ export declare function safeUrlForLog(url: string): string;
23
+ /**
24
+ * Throws `HttpError` unless the response has an expected status (`HLP_HTTP_STATUS`) and content
25
+ * type (`HLP_HTTP_CONTENT_TYPE`). Messages never contain the URL query or body. 204, 205 and
26
+ * 304 responses skip the content-type check.
27
+ * @example
28
+ * const res = new Response('{"id":7}', { headers: { 'content-type': 'application/json' } });
29
+ * assertResponse(res, { expectContentType: 'json' });
30
+ * const data: unknown = await res.json(); // => { id: 7 }
31
+ * assertResponse(new Response(null, { status: 404 })); // => throws HttpError
32
+ */
33
+ export declare function assertResponse(response: ResponseLike, options?: AssertResponseOptions): void;
34
+ /** Coarse error category for choosing a message, retry or sign-in flow. */
35
+ export type HttpErrorCategory = 'network' | 'timeout' | 'aborted' | 'client' | 'server' | 'auth' | 'unknown';
36
+ /**
37
+ * Classifies anything thrown by a fetch-based call.
38
+ * @example classifyHttpError(new TypeError('Failed to fetch')) // => 'network'
39
+ * @example
40
+ * import { HttpError } from '@absoluteui/helpers/error';
41
+ * classifyHttpError(new HttpError('X', 'Failed.', { status: 401 })); // => 'auth'
42
+ */
43
+ export declare function classifyHttpError(error: unknown): HttpErrorCategory;
@@ -0,0 +1,2 @@
1
+ /*! AbsoluteUI @absoluteui/helpers v0.13.1 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
2
+ import{HelperError as p,HttpError as c,isAbortError as m}from"../error/index.js";import{isJsonContentType as y,parseContentType as T}from"./headers.js";import{isSuccess as h,statusText as w}from"./status.js";function x(t){try{const n=new URL(t);return`${n.origin==="null"?n.protocol:n.origin}${n.pathname}`}catch{const n=t.search(/[?#]/);return n<0?t:t.slice(0,n)}}function C(t,n={}){const{expectStatus:e=h,expectContentType:r,method:i}=n,o=t.status,f=typeof e=="function"?e(o):typeof e=="number"?o===e:e.includes(o),u={status:o,statusText:t.statusText!==void 0&&t.statusText!==""?t.statusText:w(o),...i===void 0?{}:{method:i.toUpperCase()},...t.url===void 0||t.url===""?{}:{url:x(t.url)}};if(!f)throw new c("HLP_HTTP_STATUS",`The server responded with an unexpected status (${o}).`,u);if(r===void 0||o===204||o===205||o===304)return;const a=t.headers.get("content-type");let s;if(r==="json")s=y(a);else{const d=T(a)?.mediaType;s=d!==void 0&&(typeof r=="string"?[r]:r).some(l=>l.toLowerCase()===d)}if(!s)throw new c("HLP_HTTP_CONTENT_TYPE","The server responded with an unexpected content type.",{...u,details:{expected:r}})}function H(t){if(typeof t!="object"||t===null)return"unknown";if(t.name==="TimeoutError"||t instanceof p&&t.kind==="timeout")return"timeout";if(m(t))return"aborted";const e=t.status;if(typeof e=="number"&&Number.isInteger(e)){if(e===0)return"network";if(e===401||e===403||e===407)return"auth";if(e===408||e===504)return"timeout";if(e>=400&&e<500)return"client";if(e>=500&&e<600)return"server"}return t instanceof p&&(t.kind==="unauthorized"||t.kind==="forbidden")?"auth":t instanceof TypeError?"network":"unknown"}export{C as assertResponse,H as classifyHttpError,x as safeUrlForLog};