ts-data-forge 1.0.0 → 1.0.2

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 (292) hide show
  1. package/README.md +1 -1
  2. package/dist/array/array-utils.d.mts +2617 -0
  3. package/dist/array/array-utils.d.mts.map +1 -0
  4. package/dist/array/array-utils.mjs +2915 -0
  5. package/dist/array/array-utils.mjs.map +1 -0
  6. package/dist/array/index.d.mts +3 -0
  7. package/dist/array/index.d.mts.map +1 -0
  8. package/dist/array/index.mjs +3 -0
  9. package/dist/array/index.mjs.map +1 -0
  10. package/dist/array/tuple-utils.d.mts +421 -0
  11. package/dist/array/tuple-utils.d.mts.map +1 -0
  12. package/dist/array/tuple-utils.mjs +391 -0
  13. package/dist/array/tuple-utils.mjs.map +1 -0
  14. package/dist/collections/imap-mapped.d.mts +445 -0
  15. package/dist/collections/imap-mapped.d.mts.map +1 -0
  16. package/dist/collections/imap-mapped.mjs +424 -0
  17. package/dist/collections/imap-mapped.mjs.map +1 -0
  18. package/dist/collections/imap.d.mts +359 -0
  19. package/dist/collections/imap.d.mts.map +1 -0
  20. package/dist/collections/imap.mjs +338 -0
  21. package/dist/collections/imap.mjs.map +1 -0
  22. package/dist/collections/index.d.mts +7 -0
  23. package/dist/collections/index.d.mts.map +1 -0
  24. package/dist/collections/index.mjs +7 -0
  25. package/dist/collections/index.mjs.map +1 -0
  26. package/dist/collections/iset-mapped.d.mts +576 -0
  27. package/dist/collections/iset-mapped.d.mts.map +1 -0
  28. package/dist/collections/iset-mapped.mjs +522 -0
  29. package/dist/collections/iset-mapped.mjs.map +1 -0
  30. package/dist/collections/iset.d.mts +426 -0
  31. package/dist/collections/iset.d.mts.map +1 -0
  32. package/dist/collections/iset.mjs +437 -0
  33. package/dist/collections/iset.mjs.map +1 -0
  34. package/dist/collections/queue.d.mts +190 -0
  35. package/dist/collections/queue.d.mts.map +1 -0
  36. package/dist/collections/queue.mjs +317 -0
  37. package/dist/collections/queue.mjs.map +1 -0
  38. package/dist/collections/stack.d.mts +210 -0
  39. package/dist/collections/stack.d.mts.map +1 -0
  40. package/dist/collections/stack.mjs +353 -0
  41. package/dist/collections/stack.mjs.map +1 -0
  42. package/dist/expect-type.d.mts +199 -0
  43. package/dist/expect-type.d.mts.map +1 -0
  44. package/dist/expect-type.mjs +201 -0
  45. package/dist/expect-type.mjs.map +1 -0
  46. package/dist/functional/index.d.mts +5 -0
  47. package/dist/functional/index.d.mts.map +1 -0
  48. package/dist/functional/index.mjs +5 -0
  49. package/dist/functional/index.mjs.map +1 -0
  50. package/dist/functional/match.d.mts +215 -0
  51. package/dist/functional/match.d.mts.map +1 -0
  52. package/dist/functional/match.mjs +139 -0
  53. package/dist/functional/match.mjs.map +1 -0
  54. package/dist/functional/optional.d.mts +517 -0
  55. package/dist/functional/optional.d.mts.map +1 -0
  56. package/dist/functional/optional.mjs +532 -0
  57. package/dist/functional/optional.mjs.map +1 -0
  58. package/dist/functional/pipe.d.mts +185 -0
  59. package/dist/functional/pipe.d.mts.map +1 -0
  60. package/dist/functional/pipe.mjs +129 -0
  61. package/dist/functional/pipe.mjs.map +1 -0
  62. package/dist/functional/result.d.mts +796 -0
  63. package/dist/functional/result.d.mts.map +1 -0
  64. package/dist/functional/result.mjs +844 -0
  65. package/dist/functional/result.mjs.map +1 -0
  66. package/dist/globals.d.mts +38 -0
  67. package/dist/guard/has-key.d.mts +100 -0
  68. package/dist/guard/has-key.d.mts.map +1 -0
  69. package/dist/guard/has-key.mjs +94 -0
  70. package/dist/guard/has-key.mjs.map +1 -0
  71. package/dist/guard/index.d.mts +8 -0
  72. package/dist/guard/index.d.mts.map +1 -0
  73. package/dist/guard/index.mjs +8 -0
  74. package/dist/guard/index.mjs.map +1 -0
  75. package/dist/guard/is-non-empty-string.d.mts +106 -0
  76. package/dist/guard/is-non-empty-string.d.mts.map +1 -0
  77. package/dist/guard/is-non-empty-string.mjs +108 -0
  78. package/dist/guard/is-non-empty-string.mjs.map +1 -0
  79. package/dist/guard/is-non-null-object.d.mts +105 -0
  80. package/dist/guard/is-non-null-object.d.mts.map +1 -0
  81. package/dist/guard/is-non-null-object.mjs +108 -0
  82. package/dist/guard/is-non-null-object.mjs.map +1 -0
  83. package/dist/guard/is-primitive.d.mts +146 -0
  84. package/dist/guard/is-primitive.d.mts.map +1 -0
  85. package/dist/guard/is-primitive.mjs +161 -0
  86. package/dist/guard/is-primitive.mjs.map +1 -0
  87. package/dist/guard/is-record.d.mts +151 -0
  88. package/dist/guard/is-record.d.mts.map +1 -0
  89. package/dist/guard/is-record.mjs +155 -0
  90. package/dist/guard/is-record.mjs.map +1 -0
  91. package/dist/guard/is-type.d.mts +430 -0
  92. package/dist/guard/is-type.d.mts.map +1 -0
  93. package/dist/guard/is-type.mjs +432 -0
  94. package/dist/guard/is-type.mjs.map +1 -0
  95. package/dist/guard/key-is-in.d.mts +158 -0
  96. package/dist/guard/key-is-in.d.mts.map +1 -0
  97. package/dist/guard/key-is-in.mjs +160 -0
  98. package/dist/guard/key-is-in.mjs.map +1 -0
  99. package/dist/index.d.mts +11 -0
  100. package/dist/index.d.mts.map +1 -0
  101. package/dist/index.mjs +61 -0
  102. package/dist/index.mjs.map +1 -0
  103. package/dist/iterator/index.d.mts +2 -0
  104. package/dist/iterator/index.d.mts.map +1 -0
  105. package/dist/iterator/index.mjs +2 -0
  106. package/dist/iterator/index.mjs.map +1 -0
  107. package/dist/iterator/range.d.mts +97 -0
  108. package/dist/iterator/range.d.mts.map +1 -0
  109. package/dist/iterator/range.mjs +130 -0
  110. package/dist/iterator/range.mjs.map +1 -0
  111. package/dist/json/index.d.mts +2 -0
  112. package/dist/json/index.d.mts.map +1 -0
  113. package/dist/json/index.mjs +2 -0
  114. package/dist/json/index.mjs.map +1 -0
  115. package/dist/json/json.d.mts +597 -0
  116. package/dist/json/json.d.mts.map +1 -0
  117. package/dist/json/json.mjs +687 -0
  118. package/dist/json/json.mjs.map +1 -0
  119. package/dist/number/branded-types/finite-number.d.mts +291 -0
  120. package/dist/number/branded-types/finite-number.d.mts.map +1 -0
  121. package/dist/number/branded-types/finite-number.mjs +296 -0
  122. package/dist/number/branded-types/finite-number.mjs.map +1 -0
  123. package/dist/number/branded-types/index.d.mts +27 -0
  124. package/dist/number/branded-types/index.d.mts.map +1 -0
  125. package/dist/number/branded-types/index.mjs +27 -0
  126. package/dist/number/branded-types/index.mjs.map +1 -0
  127. package/dist/number/branded-types/int.d.mts +242 -0
  128. package/dist/number/branded-types/int.d.mts.map +1 -0
  129. package/dist/number/branded-types/int.mjs +239 -0
  130. package/dist/number/branded-types/int.mjs.map +1 -0
  131. package/dist/number/branded-types/int16.d.mts +162 -0
  132. package/dist/number/branded-types/int16.d.mts.map +1 -0
  133. package/dist/number/branded-types/int16.mjs +141 -0
  134. package/dist/number/branded-types/int16.mjs.map +1 -0
  135. package/dist/number/branded-types/int32.d.mts +155 -0
  136. package/dist/number/branded-types/int32.d.mts.map +1 -0
  137. package/dist/number/branded-types/int32.mjs +142 -0
  138. package/dist/number/branded-types/int32.mjs.map +1 -0
  139. package/dist/number/branded-types/non-negative-finite-number.d.mts +165 -0
  140. package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -0
  141. package/dist/number/branded-types/non-negative-finite-number.mjs +160 -0
  142. package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -0
  143. package/dist/number/branded-types/non-negative-int16.d.mts +160 -0
  144. package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -0
  145. package/dist/number/branded-types/non-negative-int16.mjs +138 -0
  146. package/dist/number/branded-types/non-negative-int16.mjs.map +1 -0
  147. package/dist/number/branded-types/non-negative-int32.d.mts +156 -0
  148. package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -0
  149. package/dist/number/branded-types/non-negative-int32.mjs +138 -0
  150. package/dist/number/branded-types/non-negative-int32.mjs.map +1 -0
  151. package/dist/number/branded-types/non-zero-finite-number.d.mts +154 -0
  152. package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -0
  153. package/dist/number/branded-types/non-zero-finite-number.mjs +160 -0
  154. package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -0
  155. package/dist/number/branded-types/non-zero-int.d.mts +131 -0
  156. package/dist/number/branded-types/non-zero-int.d.mts.map +1 -0
  157. package/dist/number/branded-types/non-zero-int.mjs +128 -0
  158. package/dist/number/branded-types/non-zero-int.mjs.map +1 -0
  159. package/dist/number/branded-types/non-zero-int16.d.mts +166 -0
  160. package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -0
  161. package/dist/number/branded-types/non-zero-int16.mjs +145 -0
  162. package/dist/number/branded-types/non-zero-int16.mjs.map +1 -0
  163. package/dist/number/branded-types/non-zero-int32.d.mts +158 -0
  164. package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -0
  165. package/dist/number/branded-types/non-zero-int32.mjs +145 -0
  166. package/dist/number/branded-types/non-zero-int32.mjs.map +1 -0
  167. package/dist/number/branded-types/non-zero-safe-int.d.mts +148 -0
  168. package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -0
  169. package/dist/number/branded-types/non-zero-safe-int.mjs +145 -0
  170. package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -0
  171. package/dist/number/branded-types/non-zero-uint16.d.mts +160 -0
  172. package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -0
  173. package/dist/number/branded-types/non-zero-uint16.mjs +140 -0
  174. package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -0
  175. package/dist/number/branded-types/non-zero-uint32.d.mts +156 -0
  176. package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -0
  177. package/dist/number/branded-types/non-zero-uint32.mjs +140 -0
  178. package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -0
  179. package/dist/number/branded-types/positive-finite-number.d.mts +171 -0
  180. package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -0
  181. package/dist/number/branded-types/positive-finite-number.mjs +165 -0
  182. package/dist/number/branded-types/positive-finite-number.mjs.map +1 -0
  183. package/dist/number/branded-types/positive-int.d.mts +270 -0
  184. package/dist/number/branded-types/positive-int.d.mts.map +1 -0
  185. package/dist/number/branded-types/positive-int.mjs +257 -0
  186. package/dist/number/branded-types/positive-int.mjs.map +1 -0
  187. package/dist/number/branded-types/positive-int16.d.mts +162 -0
  188. package/dist/number/branded-types/positive-int16.d.mts.map +1 -0
  189. package/dist/number/branded-types/positive-int16.mjs +139 -0
  190. package/dist/number/branded-types/positive-int16.mjs.map +1 -0
  191. package/dist/number/branded-types/positive-int32.d.mts +158 -0
  192. package/dist/number/branded-types/positive-int32.d.mts.map +1 -0
  193. package/dist/number/branded-types/positive-int32.mjs +139 -0
  194. package/dist/number/branded-types/positive-int32.mjs.map +1 -0
  195. package/dist/number/branded-types/positive-safe-int.d.mts +152 -0
  196. package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -0
  197. package/dist/number/branded-types/positive-safe-int.mjs +138 -0
  198. package/dist/number/branded-types/positive-safe-int.mjs.map +1 -0
  199. package/dist/number/branded-types/positive-uint16.d.mts +160 -0
  200. package/dist/number/branded-types/positive-uint16.d.mts.map +1 -0
  201. package/dist/number/branded-types/positive-uint16.mjs +139 -0
  202. package/dist/number/branded-types/positive-uint16.mjs.map +1 -0
  203. package/dist/number/branded-types/positive-uint32.d.mts +156 -0
  204. package/dist/number/branded-types/positive-uint32.d.mts.map +1 -0
  205. package/dist/number/branded-types/positive-uint32.mjs +139 -0
  206. package/dist/number/branded-types/positive-uint32.mjs.map +1 -0
  207. package/dist/number/branded-types/safe-int.d.mts +243 -0
  208. package/dist/number/branded-types/safe-int.d.mts.map +1 -0
  209. package/dist/number/branded-types/safe-int.mjs +240 -0
  210. package/dist/number/branded-types/safe-int.mjs.map +1 -0
  211. package/dist/number/branded-types/safe-uint.d.mts +151 -0
  212. package/dist/number/branded-types/safe-uint.d.mts.map +1 -0
  213. package/dist/number/branded-types/safe-uint.mjs +138 -0
  214. package/dist/number/branded-types/safe-uint.mjs.map +1 -0
  215. package/dist/number/branded-types/uint.d.mts +144 -0
  216. package/dist/number/branded-types/uint.d.mts.map +1 -0
  217. package/dist/number/branded-types/uint.mjs +132 -0
  218. package/dist/number/branded-types/uint.mjs.map +1 -0
  219. package/dist/number/branded-types/uint16.d.mts +157 -0
  220. package/dist/number/branded-types/uint16.d.mts.map +1 -0
  221. package/dist/number/branded-types/uint16.mjs +137 -0
  222. package/dist/number/branded-types/uint16.mjs.map +1 -0
  223. package/dist/number/branded-types/uint32.d.mts +185 -0
  224. package/dist/number/branded-types/uint32.d.mts.map +1 -0
  225. package/dist/number/branded-types/uint32.mjs +169 -0
  226. package/dist/number/branded-types/uint32.mjs.map +1 -0
  227. package/dist/number/enum/index.d.mts +3 -0
  228. package/dist/number/enum/index.d.mts.map +1 -0
  229. package/dist/number/enum/index.mjs +3 -0
  230. package/dist/number/enum/index.mjs.map +1 -0
  231. package/dist/number/enum/int8.d.mts +202 -0
  232. package/dist/number/enum/int8.d.mts.map +1 -0
  233. package/dist/number/enum/int8.mjs +296 -0
  234. package/dist/number/enum/int8.mjs.map +1 -0
  235. package/dist/number/enum/uint8.d.mts +128 -0
  236. package/dist/number/enum/uint8.d.mts.map +1 -0
  237. package/dist/number/enum/uint8.mjs +251 -0
  238. package/dist/number/enum/uint8.mjs.map +1 -0
  239. package/dist/number/index.d.mts +5 -0
  240. package/dist/number/index.d.mts.map +1 -0
  241. package/dist/number/index.mjs +31 -0
  242. package/dist/number/index.mjs.map +1 -0
  243. package/dist/number/num.d.mts +515 -0
  244. package/dist/number/num.d.mts.map +1 -0
  245. package/dist/number/num.mjs +513 -0
  246. package/dist/number/num.mjs.map +1 -0
  247. package/dist/number/refined-number-utils.d.mts +191 -0
  248. package/dist/number/refined-number-utils.d.mts.map +1 -0
  249. package/dist/number/refined-number-utils.mjs +179 -0
  250. package/dist/number/refined-number-utils.mjs.map +1 -0
  251. package/dist/object/index.d.mts +2 -0
  252. package/dist/object/index.d.mts.map +1 -0
  253. package/dist/object/index.mjs +2 -0
  254. package/dist/object/index.mjs.map +1 -0
  255. package/dist/object/object.d.mts +296 -0
  256. package/dist/object/object.d.mts.map +1 -0
  257. package/dist/object/object.mjs +295 -0
  258. package/dist/object/object.mjs.map +1 -0
  259. package/dist/others/cast-mutable.d.mts +110 -0
  260. package/dist/others/cast-mutable.d.mts.map +1 -0
  261. package/dist/others/cast-mutable.mjs +114 -0
  262. package/dist/others/cast-mutable.mjs.map +1 -0
  263. package/dist/others/cast-readonly.d.mts +189 -0
  264. package/dist/others/cast-readonly.d.mts.map +1 -0
  265. package/dist/others/cast-readonly.mjs +193 -0
  266. package/dist/others/cast-readonly.mjs.map +1 -0
  267. package/dist/others/if-then.d.mts +98 -0
  268. package/dist/others/if-then.d.mts.map +1 -0
  269. package/dist/others/if-then.mjs +100 -0
  270. package/dist/others/if-then.mjs.map +1 -0
  271. package/dist/others/index.d.mts +8 -0
  272. package/dist/others/index.d.mts.map +1 -0
  273. package/dist/others/index.mjs +8 -0
  274. package/dist/others/index.mjs.map +1 -0
  275. package/dist/others/map-nullable.d.mts +151 -0
  276. package/dist/others/map-nullable.d.mts.map +1 -0
  277. package/dist/others/map-nullable.mjs +159 -0
  278. package/dist/others/map-nullable.mjs.map +1 -0
  279. package/dist/others/memoize-function.d.mts +173 -0
  280. package/dist/others/memoize-function.d.mts.map +1 -0
  281. package/dist/others/memoize-function.mjs +189 -0
  282. package/dist/others/memoize-function.mjs.map +1 -0
  283. package/dist/others/tuple.d.mts +159 -0
  284. package/dist/others/tuple.d.mts.map +1 -0
  285. package/dist/others/tuple.mjs +161 -0
  286. package/dist/others/tuple.mjs.map +1 -0
  287. package/dist/others/unknown-to-string.d.mts +180 -0
  288. package/dist/others/unknown-to-string.d.mts.map +1 -0
  289. package/dist/others/unknown-to-string.mjs +211 -0
  290. package/dist/others/unknown-to-string.mjs.map +1 -0
  291. package/dist/tsconfig.json +1 -0
  292. package/package.json +18 -16
@@ -0,0 +1,687 @@
1
+ import { Arr } from '../array/array-utils.mjs';
2
+ import '../array/tuple-utils.mjs';
3
+ import { isRecord } from '../guard/is-record.mjs';
4
+ import '../functional/optional.mjs';
5
+ import { pipe } from '../functional/pipe.mjs';
6
+ import { Result } from '../functional/result.mjs';
7
+ import { castMutable } from '../others/cast-mutable.mjs';
8
+ import { unknownToString } from '../others/unknown-to-string.mjs';
9
+
10
+ /**
11
+ * A collection of type-safe JSON utility functions that provide safe parsing,
12
+ * stringification, and manipulation of JSON data. All functions return `Result`
13
+ * types to handle errors without throwing exceptions.
14
+ *
15
+ * @example Basic usage
16
+ * ```typescript
17
+ * import { Json, Result } from 'ts-data-forge';
18
+ *
19
+ * // Parse JSON safely
20
+ * const parseResult = Json.parse('{"name": "Alice", "age": 30}');
21
+ * if (Result.isOk(parseResult)) {
22
+ * console.log(parseResult.value); // { name: 'Alice', age: 30 }
23
+ * }
24
+ *
25
+ * // Stringify with error handling
26
+ * const stringifyResult = Json.stringify({ name: 'Bob', age: 25 });
27
+ * if (Result.isOk(stringifyResult)) {
28
+ * console.log(stringifyResult.value); // '{"name":"Bob","age":25}'
29
+ * }
30
+ * ```
31
+ */
32
+ var Json;
33
+ (function (Json) {
34
+ /**
35
+ * Safely converts a JSON string into a JavaScript value without throwing exceptions.
36
+ *
37
+ * This function provides type-safe JSON parsing by wrapping the native `JSON.parse`
38
+ * in a `Result` type, allowing you to handle parsing errors gracefully without
39
+ * try-catch blocks.
40
+ *
41
+ * @param text - A valid JSON string to parse. Can contain any valid JSON data type:
42
+ * primitives (string, number, boolean, null), arrays, or objects.
43
+ * @param reviver - Optional function that transforms parsed values. Called for each
44
+ * key-value pair in the JSON. The function receives the key name and parsed value,
45
+ * and should return the transformed value. For nested objects, inner objects are
46
+ * processed before outer objects.
47
+ * @returns A `Result<JsonValue, string>` containing:
48
+ * - On success: `Result.ok(parsedValue)` where `parsedValue` is the parsed JSON
49
+ * - On failure: `Result.err(errorMessage)` where `errorMessage` describes the parsing error
50
+ *
51
+ * @example Basic parsing
52
+ * ```typescript
53
+ * // Parse simple values
54
+ * const str = Json.parse('"hello"');
55
+ * // Result.ok('hello')
56
+ *
57
+ * const num = Json.parse('42');
58
+ * // Result.ok(42)
59
+ *
60
+ * const bool = Json.parse('true');
61
+ * // Result.ok(true)
62
+ *
63
+ * const nul = Json.parse('null');
64
+ * // Result.ok(null)
65
+ * ```
66
+ *
67
+ * @example Parsing objects and arrays
68
+ * ```typescript
69
+ * const obj = Json.parse('{"name": "John", "age": 30, "active": true}');
70
+ * if (Result.isOk(obj)) {
71
+ * console.log(obj.value.name); // 'John'
72
+ * console.log(obj.value.age); // 30
73
+ * }
74
+ *
75
+ * const arr = Json.parse('[1, "two", true, null]');
76
+ * if (Result.isOk(arr)) {
77
+ * console.log(arr.value); // [1, 'two', true, null]
78
+ * }
79
+ * ```
80
+ *
81
+ * @example Error handling
82
+ * ```typescript
83
+ * const invalid = Json.parse('invalid json');
84
+ * if (Result.isErr(invalid)) {
85
+ * console.log('Parse failed:', invalid.value);
86
+ * // Parse failed: Unexpected token i in JSON at position 0
87
+ * }
88
+ *
89
+ * const malformed = Json.parse('{"missing": quote}');
90
+ * if (Result.isErr(malformed)) {
91
+ * console.log('Parse failed:', malformed.value);
92
+ * // Parse failed: Unexpected token q in JSON at position 12
93
+ * }
94
+ * ```
95
+ *
96
+ * @example Using reviver for data transformation
97
+ * ```typescript
98
+ * // Convert ISO date strings to Date objects
99
+ * const dateReviver = (key: string, value: unknown): unknown => {
100
+ * if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}T/.test(value)) {
101
+ * return new Date(value);
102
+ * }
103
+ * return value;
104
+ * };
105
+ *
106
+ * const result = Json.parse(
107
+ * '{"event": "Meeting", "date": "2023-12-25T10:00:00Z"}',
108
+ * dateReviver
109
+ * );
110
+ * if (Result.isOk(result)) {
111
+ * console.log(result.value.date instanceof Date); // true
112
+ * }
113
+ * ```
114
+ *
115
+ * @example API response validation
116
+ * ```typescript
117
+ * import { isRecord, hasKey } from 'ts-data-forge';
118
+ *
119
+ * const validateApiResponse = (jsonString: string) => {
120
+ * const parseResult = Json.parse(jsonString);
121
+ *
122
+ * if (Result.isErr(parseResult)) {
123
+ * return Result.err(`Invalid JSON: ${parseResult.value}`);
124
+ * }
125
+ *
126
+ * const data = parseResult.value;
127
+ * if (!isRecord(data) || !hasKey(data, 'status')) {
128
+ * return Result.err('Missing required "status" field');
129
+ * }
130
+ *
131
+ * return Result.ok(data);
132
+ * };
133
+ * ```
134
+ */
135
+ Json.parse = (text, reviver) => {
136
+ try {
137
+ return Result.ok(JSON.parse(text,
138
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
139
+ reviver));
140
+ }
141
+ catch (error) {
142
+ const errStr = unknownToString(error);
143
+ return Result.err(Result.isOk(errStr) ? errStr.value : 'Failed to parse JSON');
144
+ }
145
+ };
146
+ /**
147
+ * Safely converts a JavaScript value to a JSON string without throwing exceptions.
148
+ *
149
+ * This function provides type-safe JSON stringification by wrapping the native
150
+ * `JSON.stringify` in a `Result` type, allowing you to handle serialization errors
151
+ * gracefully (such as circular references or BigInt values).
152
+ *
153
+ * @param value - The JavaScript value to serialize. Can be any value that JSON.stringify
154
+ * accepts: primitives, objects, arrays. Non-serializable values (functions, undefined,
155
+ * symbols) will be omitted or converted to null according to JSON.stringify behavior.
156
+ * @param replacer - Optional function that transforms values during serialization.
157
+ * Called for each key-value pair. Should return the value to be serialized, or
158
+ * undefined to omit the property from the result.
159
+ * @param space - Optional parameter for formatting the output JSON:
160
+ * - Number (1-10): Number of spaces to indent each level
161
+ * - String: String to use for indentation (first 10 characters)
162
+ * - undefined/null: No formatting (compact output)
163
+ * @returns A `Result<string, string>` containing:
164
+ * - On success: `Result.ok(jsonString)` where `jsonString` is the serialized JSON
165
+ * - On failure: `Result.err(errorMessage)` where `errorMessage` describes the error
166
+ *
167
+ * @example Basic stringification
168
+ * ```typescript
169
+ * // Primitives
170
+ * const str = Json.stringify('hello');
171
+ * // Result.ok('"hello"')
172
+ *
173
+ * const num = Json.stringify(42);
174
+ * // Result.ok('42')
175
+ *
176
+ * const bool = Json.stringify(true);
177
+ * // Result.ok('true')
178
+ *
179
+ * const nul = Json.stringify(null);
180
+ * // Result.ok('null')
181
+ * ```
182
+ *
183
+ * @example Objects and arrays
184
+ * ```typescript
185
+ * const obj = { name: 'John', age: 30, active: true };
186
+ * const result = Json.stringify(obj);
187
+ * if (Result.isOk(result)) {
188
+ * console.log(result.value); // '{"name":"John","age":30,"active":true}'
189
+ * }
190
+ *
191
+ * const arr = [1, 'two', true, null];
192
+ * const arrResult = Json.stringify(arr);
193
+ * if (Result.isOk(arrResult)) {
194
+ * console.log(arrResult.value); // '[1,"two",true,null]'
195
+ * }
196
+ * ```
197
+ *
198
+ * @example Formatted output
199
+ * ```typescript
200
+ * const data = { users: [{ name: 'Alice', id: 1 }, { name: 'Bob', id: 2 }] };
201
+ *
202
+ * // Pretty-print with 2 spaces
203
+ * const formatted = Json.stringify(data, undefined, 2);
204
+ * if (Result.isOk(formatted)) {
205
+ * console.log(formatted.value);
206
+ * // {
207
+ * // "users": [
208
+ * // {
209
+ * // "name": "Alice",
210
+ * // "id": 1
211
+ * // },
212
+ * // {
213
+ * // "name": "Bob",
214
+ * // "id": 2
215
+ * // }
216
+ * // ]
217
+ * // }
218
+ * }
219
+ *
220
+ * // Custom indentation string
221
+ * const tabbed = Json.stringify(data, undefined, '\t');
222
+ * ```
223
+ *
224
+ * @example Error handling for problematic values
225
+ * ```typescript
226
+ * // Circular reference error
227
+ * const circular: any = { name: 'test' };
228
+ * circular.self = circular;
229
+ * const error = Json.stringify(circular);
230
+ * if (Result.isErr(error)) {
231
+ * console.log('Stringify failed:', error.value);
232
+ * // Stringify failed: Converting circular structure to JSON
233
+ * }
234
+ *
235
+ * // BigInt error
236
+ * const bigIntError = Json.stringify({ big: BigInt(123) });
237
+ * if (Result.isErr(bigIntError)) {
238
+ * console.log('Stringify failed:', bigIntError.value);
239
+ * // Stringify failed: Do not know how to serialize a BigInt
240
+ * }
241
+ * ```
242
+ *
243
+ * @example Using replacer for value transformation
244
+ * ```typescript
245
+ * // Filter out sensitive data
246
+ * const sensitiveData = { name: 'John', password: 'secret123', email: 'john@example.com' };
247
+ *
248
+ * const secureReplacer = (key: string, value: unknown) => {
249
+ * if (key === 'password') return '[REDACTED]';
250
+ * return value;
251
+ * };
252
+ *
253
+ * const safe = Json.stringify(sensitiveData, secureReplacer);
254
+ * if (Result.isOk(safe)) {
255
+ * console.log(safe.value);
256
+ * // '{"name":"John","password":"[REDACTED]","email":"john@example.com"}'
257
+ * }
258
+ *
259
+ * // Convert Dates to custom format
260
+ * const data = { event: 'Meeting', date: new Date('2023-12-25T10:00:00Z') };
261
+ * const dateReplacer = (key: string, value: unknown) => {
262
+ * if (value instanceof Date) return value.toISOString().split('T')[0]; // YYYY-MM-DD
263
+ * return value;
264
+ * };
265
+ *
266
+ * const result = Json.stringify(data, dateReplacer);
267
+ * if (Result.isOk(result)) {
268
+ * console.log(result.value); // '{"event":"Meeting","date":"2023-12-25"}'
269
+ * }
270
+ * ```
271
+ *
272
+ * @example Special value handling
273
+ * ```typescript
274
+ * // Functions, undefined, and symbols are omitted in objects
275
+ * const obj = {
276
+ * name: 'test',
277
+ * fn: () => {}, // omitted
278
+ * undef: undefined, // omitted
279
+ * sym: Symbol('test'), // omitted
280
+ * num: 42
281
+ * };
282
+ * const result = Json.stringify(obj);
283
+ * // Result.ok('{"name":"test","num":42}')
284
+ *
285
+ * // In arrays, they become null
286
+ * const arr = ['string', () => {}, undefined, Symbol('test'), 42];
287
+ * const arrResult = Json.stringify(arr);
288
+ * // Result.ok('["string",null,null,null,42]')
289
+ * ```
290
+ */
291
+ Json.stringify = (value, replacer, space) => {
292
+ try {
293
+ return Result.ok(JSON.stringify(value, replacer, space));
294
+ }
295
+ catch (error) {
296
+ const errStr = unknownToString(error);
297
+ return Result.err(Result.isOk(errStr) ? errStr.value : 'Failed to stringify JSON');
298
+ }
299
+ };
300
+ /**
301
+ * Safely converts a JavaScript value to a JSON string, including only the specified properties.
302
+ *
303
+ * This function provides selective serialization by allowing you to specify exactly which
304
+ * object properties should be included in the resulting JSON. It's useful for creating
305
+ * filtered or minimal representations of objects, such as for API responses or logging.
306
+ *
307
+ * @param value - The JavaScript value to serialize. While any value is accepted,
308
+ * the property filtering only applies to objects and nested objects.
309
+ * @param propertiesToBeSelected - Optional array of property names (strings) and array
310
+ * indices (numbers) to include in the serialization. If provided, only these properties
311
+ * will appear in the output JSON. If undefined, all properties are included.
312
+ * @param space - Optional formatting parameter:
313
+ * - Number (1-10): Number of spaces to indent each level
314
+ * - String: String to use for indentation (first 10 characters)
315
+ * - undefined/null: No formatting (compact output)
316
+ * @returns A `Result<string, string>` containing:
317
+ * - On success: `Result.ok(jsonString)` with only selected properties
318
+ * - On failure: `Result.err(errorMessage)` describing the serialization error
319
+ *
320
+ * @example Basic property selection
321
+ * ```typescript
322
+ * const user = {
323
+ * id: 1,
324
+ * name: 'Alice',
325
+ * email: 'alice@example.com',
326
+ * password: 'secret123',
327
+ * lastLogin: '2023-12-01'
328
+ * };
329
+ *
330
+ * // Include only public fields
331
+ * const publicFields = Json.stringifySelected(user, ['id', 'name', 'email']);
332
+ * if (Result.isOk(publicFields)) {
333
+ * console.log(publicFields.value);
334
+ * // '{"id":1,"name":"Alice","email":"alice@example.com"}'
335
+ * }
336
+ * ```
337
+ *
338
+ * @example Array property selection
339
+ * ```typescript
340
+ * const data = {
341
+ * users: [
342
+ * { id: 1, name: 'Alice', secret: 'hidden1' },
343
+ * { id: 2, name: 'Bob', secret: 'hidden2' }
344
+ * ],
345
+ * metadata: { total: 2, page: 1 }
346
+ * };
347
+ *
348
+ * // Select specific properties across nested structures
349
+ * const selected = Json.stringifySelected(data, ['users', 'id', 'name', 'total']);
350
+ * if (Result.isOk(selected)) {
351
+ * console.log(selected.value);
352
+ * // '{"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}],"metadata":{"total":2}}'
353
+ * }
354
+ * ```
355
+ *
356
+ * @example Formatted output with selection
357
+ * ```typescript
358
+ * const config = {
359
+ * database: { host: 'localhost', password: 'secret' },
360
+ * api: { endpoint: '/api/v1', key: 'secret-key' },
361
+ * features: { debug: true, logging: true }
362
+ * };
363
+ *
364
+ * // Create a safe config for logging (exclude sensitive fields)
365
+ * const safeConfig = Json.stringifySelected(
366
+ * config,
367
+ * ['database', 'host', 'api', 'endpoint', 'features'],
368
+ * 2
369
+ * );
370
+ * if (Result.isOk(safeConfig)) {
371
+ * console.log(safeConfig.value);
372
+ * // {
373
+ * // "database": {
374
+ * // "host": "localhost"
375
+ * // },
376
+ * // "api": {
377
+ * // "endpoint": "/api/v1"
378
+ * // },
379
+ * // "features": {
380
+ * // "debug": true,
381
+ * // "logging": true
382
+ * // }
383
+ * // }
384
+ * }
385
+ * ```
386
+ *
387
+ * @example Working with arrays and indices
388
+ * ```typescript
389
+ * const matrix = [
390
+ * [1, 2, 3, 4],
391
+ * [5, 6, 7, 8],
392
+ * [9, 10, 11, 12]
393
+ * ];
394
+ *
395
+ * // Select only first two columns (indices 0 and 1)
396
+ * const columns = Json.stringifySelected(matrix, [0, 1]);
397
+ * if (Result.isOk(columns)) {
398
+ * console.log(columns.value);
399
+ * // '[[1,2],[5,6],[9,10]]'
400
+ * }
401
+ * ```
402
+ *
403
+ * @example API response filtering
404
+ * ```typescript
405
+ * // Simulate filtering an API response
406
+ * const fullResponse = {
407
+ * data: {
408
+ * users: [
409
+ * { id: 1, name: 'Alice', email: 'alice@example.com', internalId: 'usr_123' },
410
+ * { id: 2, name: 'Bob', email: 'bob@example.com', internalId: 'usr_456' }
411
+ * ]
412
+ * },
413
+ * metadata: {
414
+ * total: 2,
415
+ * internalVersion: '1.2.3',
416
+ * serverTime: Date.now()
417
+ * }
418
+ * };
419
+ *
420
+ * // Create public API response
421
+ * const publicResponse = Json.stringifySelected(
422
+ * fullResponse,
423
+ * ['data', 'users', 'id', 'name', 'email', 'metadata', 'total']
424
+ * );
425
+ *
426
+ * if (Result.isOk(publicResponse)) {
427
+ * console.log('Public API response:', publicResponse.value);
428
+ * // Only includes id, name, email for users and total in metadata
429
+ * }
430
+ * ```
431
+ *
432
+ * @example Error handling
433
+ * ```typescript
434
+ * const circular: any = { name: 'test' };
435
+ * circular.self = circular;
436
+ *
437
+ * const result = Json.stringifySelected(circular, ['name', 'self']);
438
+ * if (Result.isErr(result)) {
439
+ * console.log('Serialization failed:', result.value);
440
+ * // Even with property selection, circular references still cause errors
441
+ * }
442
+ * ```
443
+ */
444
+ Json.stringifySelected = (value, propertiesToBeSelected, space) => {
445
+ try {
446
+ return Result.ok(JSON.stringify(value, castMutable(propertiesToBeSelected), space));
447
+ }
448
+ catch (error) {
449
+ const errStr = unknownToString(error);
450
+ return Result.err(Result.isOk(errStr) ? errStr.value : 'Failed to stringify JSON');
451
+ }
452
+ };
453
+ /**
454
+ * Safely converts a JavaScript record to a JSON string with keys sorted alphabetically at all levels.
455
+ *
456
+ * This function creates deterministic JSON output by ensuring that object keys appear in
457
+ * alphabetical order at every level of nesting. This is particularly useful for creating
458
+ * consistent output for comparison, hashing, caching, or when you need reproducible JSON
459
+ * representations across different JavaScript engines or runs.
460
+ *
461
+ * @param value - An object (`UnknownRecord`) to serialize. Must be a plain object
462
+ * (not an array, primitive, or null). Nested objects and arrays within the object
463
+ * will also have their keys sorted alphabetically.
464
+ * @param space - Optional formatting parameter:
465
+ * - Number (1-10): Number of spaces to indent each level
466
+ * - String: String to use for indentation (first 10 characters)
467
+ * - undefined/null: No formatting (compact output)
468
+ * @returns A `Result<string, string>` containing:
469
+ * - On success: `Result.ok(jsonString)` with all object keys sorted alphabetically
470
+ * - On failure: `Result.err(errorMessage)` describing the serialization error
471
+ *
472
+ * @example Basic key sorting
473
+ * ```typescript
474
+ * const unsortedObj = {
475
+ * zebra: 'animal',
476
+ * apple: 'fruit',
477
+ * banana: 'fruit',
478
+ * aardvark: 'animal'
479
+ * };
480
+ *
481
+ * const sorted = Json.stringifySortedKey(unsortedObj);
482
+ * if (Result.isOk(sorted)) {
483
+ * console.log(sorted.value);
484
+ * // '{"aardvark":"animal","apple":"fruit","banana":"fruit","zebra":"animal"}'
485
+ * }
486
+ *
487
+ * // Compare with regular stringify (order not guaranteed)
488
+ * const regular = Json.stringify(unsortedObj);
489
+ * // Keys might appear in insertion order or engine-dependent order
490
+ * ```
491
+ *
492
+ * @example Nested object key sorting
493
+ * ```typescript
494
+ * const nestedObj = {
495
+ * user: {
496
+ * name: 'Alice',
497
+ * age: 30,
498
+ * address: {
499
+ * zip: '12345',
500
+ * city: 'New York',
501
+ * country: 'USA'
502
+ * }
503
+ * },
504
+ * settings: {
505
+ * theme: 'dark',
506
+ * language: 'en',
507
+ * notifications: {
508
+ * email: true,
509
+ * sms: false,
510
+ * push: true
511
+ * }
512
+ * }
513
+ * };
514
+ *
515
+ * const sorted = Json.stringifySortedKey(nestedObj, 2);
516
+ * if (Result.isOk(sorted)) {
517
+ * console.log(sorted.value);
518
+ * // {
519
+ * // "settings": {
520
+ * // "language": "en",
521
+ * // "notifications": {
522
+ * // "email": true,
523
+ * // "push": true,
524
+ * // "sms": false
525
+ * // },
526
+ * // "theme": "dark"
527
+ * // },
528
+ * // "user": {
529
+ * // "address": {
530
+ * // "city": "New York",
531
+ * // "country": "USA",
532
+ * // "zip": "12345"
533
+ * // },
534
+ * // "age": 30,
535
+ * // "name": "Alice"
536
+ * // }
537
+ * // }
538
+ * }
539
+ * ```
540
+ *
541
+ * @example Arrays with nested objects
542
+ * ```typescript
543
+ * const dataWithArrays = {
544
+ * users: [
545
+ * { name: 'Bob', id: 2, active: true },
546
+ * { name: 'Alice', id: 1, active: false }
547
+ * ],
548
+ * metadata: {
549
+ * version: '1.0',
550
+ * created: '2023-12-01',
551
+ * author: 'system'
552
+ * }
553
+ * };
554
+ *
555
+ * const sorted = Json.stringifySortedKey(dataWithArrays);
556
+ * if (Result.isOk(sorted)) {
557
+ * console.log(sorted.value);
558
+ * // Keys in objects within arrays are also sorted:
559
+ * // '{"metadata":{"author":"system","created":"2023-12-01","version":"1.0"},"users":[{"active":true,"id":2,"name":"Bob"},{"active":false,"id":1,"name":"Alice"}]}'
560
+ * }
561
+ * ```
562
+ *
563
+ * @example Configuration files and consistent output
564
+ * ```typescript
565
+ * // Useful for configuration files that need consistent ordering
566
+ * const config = {
567
+ * database: {
568
+ * port: 5432,
569
+ * host: 'localhost',
570
+ * name: 'myapp',
571
+ * username: 'admin'
572
+ * },
573
+ * server: {
574
+ * port: 3000,
575
+ * middleware: ['cors', 'helmet', 'compression'],
576
+ * routes: {
577
+ * api: '/api/v1',
578
+ * health: '/health',
579
+ * docs: '/docs'
580
+ * }
581
+ * }
582
+ * };
583
+ *
584
+ * const consistentConfig = Json.stringifySortedKey(config, 2);
585
+ * if (Result.isOk(consistentConfig)) {
586
+ * // Always produces the same key order regardless of object creation order
587
+ * console.log('Consistent config:', consistentConfig.value);
588
+ * }
589
+ * ```
590
+ *
591
+ * @example Deterministic hashing and comparison
592
+ * ```typescript
593
+ * // Useful when you need consistent JSON for hashing or comparison
594
+ * const createHash = async (obj: Record<string, unknown>) => {
595
+ * const sortedJson = Json.stringifySortedKey(obj);
596
+ * if (Result.isErr(sortedJson)) {
597
+ * throw new Error(`Failed to serialize: ${sortedJson.value}`);
598
+ * }
599
+ *
600
+ * // Now you can safely hash the JSON string
601
+ * const encoder = new TextEncoder();
602
+ * const data = encoder.encode(sortedJson.value);
603
+ * const hashBuffer = await crypto.subtle.digest('SHA-256', data);
604
+ * return Array.from(new Uint8Array(hashBuffer))
605
+ * .map(b => b.toString(16).padStart(2, '0'))
606
+ * .join('');
607
+ * };
608
+ *
609
+ * // These will produce the same hash regardless of property order:
610
+ * const obj1 = { b: 2, a: 1, c: 3 };
611
+ * const obj2 = { a: 1, c: 3, b: 2 };
612
+ * // createHash(obj1) === createHash(obj2) // true
613
+ * ```
614
+ *
615
+ * @example Error handling
616
+ * ```typescript
617
+ * const problematicObj = {
618
+ * normal: 'value',
619
+ * circular: {} as any
620
+ * };
621
+ * problematicObj.circular.self = problematicObj;
622
+ *
623
+ * const result = Json.stringifySortedKey(problematicObj);
624
+ * if (Result.isErr(result)) {
625
+ * console.log('Serialization failed:', result.value);
626
+ * // Even with key sorting, circular references still cause errors
627
+ * }
628
+ * ```
629
+ */
630
+ Json.stringifySortedKey = (value, space) => {
631
+ const allKeys = pipe(keysDeep(value))
632
+ .map((keys) => Arr.uniq(keys))
633
+ .map((ks) => ks.toSorted()).value;
634
+ return Json.stringifySelected(value, allKeys, space);
635
+ };
636
+ })(Json || (Json = {}));
637
+ /**
638
+ * @internal
639
+ * Recursively collects all property keys from a nested object structure.
640
+ *
641
+ * This helper function traverses an object and its nested objects and arrays,
642
+ * collecting all string keys found at any level of nesting. The function mutates
643
+ * the provided keys array for performance reasons.
644
+ *
645
+ * @param obj - The record to extract keys from. Must be a plain object.
646
+ * @param mut_keys - A mutable array to accumulate the collected keys. This array
647
+ * will be modified in-place by the function for performance reasons.
648
+ */
649
+ const keysDeepImpl = (obj,
650
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
651
+ mut_keys) => {
652
+ for (const k of Object.keys(obj)) {
653
+ mut_keys.push(k);
654
+ const o = obj[k];
655
+ if (isRecord(o)) {
656
+ keysDeepImpl(o, mut_keys);
657
+ }
658
+ if (Array.isArray(o)) {
659
+ for (const li of o) {
660
+ if (isRecord(li)) {
661
+ keysDeepImpl(li, mut_keys);
662
+ }
663
+ }
664
+ }
665
+ }
666
+ };
667
+ /**
668
+ * @internal
669
+ * Extracts all property keys from a nested object structure into a flat array.
670
+ *
671
+ * This function serves as a safe wrapper around `keysDeepImpl`, creating a new
672
+ * mutable array and passing it to the recursive implementation. The result
673
+ * contains all keys found at any level of nesting within the input object.
674
+ *
675
+ * @param obj - The record to extract keys from. Must be a plain object.
676
+ * @returns A readonly array of all string keys found in the object and its
677
+ * nested objects/arrays. May contain duplicates if the same key appears
678
+ * at multiple levels.
679
+ */
680
+ const keysDeep = (obj) => {
681
+ const mut_keys = [];
682
+ keysDeepImpl(obj, mut_keys);
683
+ return mut_keys;
684
+ };
685
+
686
+ export { Json };
687
+ //# sourceMappingURL=json.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.mjs","sources":["../../src/json/json.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACG,IAAW;AAAjB,CAAA,UAAiB,IAAI,EAAA;AACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGG;AACU,IAAA,IAAA,CAAA,KAAK,GAAG,CACnB,IAAY,EACZ,OAAmE,KACtC;AAC7B,QAAA,IAAI;YACF,OAAO,MAAM,CAAC,EAAE,CACd,IAAI,CAAC,KAAK,CACR,IAAI;;YAEJ,OAAkE,CACnE,CACF;;QACD,OAAO,KAAc,EAAE;AACvB,YAAA,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC;YACrC,OAAO,MAAM,CAAC,GAAG,CACf,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,sBAAsB,CAC5D;;AAEL,KAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgJG;IACU,IAAA,CAAA,SAAS,GAAG,CACvB,KAAc,EACd,QAAgE,EAChE,KAA0C,KAChB;AAC1B,QAAA,IAAI;AACF,YAAA,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;;QACxD,OAAO,KAAK,EAAE;AACd,YAAA,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC;YACrC,OAAO,MAAM,CAAC,GAAG,CACf,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,0BAA0B,CAChE;;AAEL,KAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+IG;IACU,IAAA,CAAA,iBAAiB,GAAG,CAC/B,KAAc,EACd,sBAAqD,EACrD,KAA0C,KAChB;AAC1B,QAAA,IAAI;AACF,YAAA,OAAO,MAAM,CAAC,EAAE,CACd,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,sBAAsB,CAAC,EAAE,KAAK,CAAC,CAClE;;QACD,OAAO,KAAK,EAAE;AACd,YAAA,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC;YACrC,OAAO,MAAM,CAAC,GAAG,CACf,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,0BAA0B,CAChE;;AAEL,KAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgLG;AACU,IAAA,IAAA,CAAA,kBAAkB,GAAG,CAChC,KAAoB,EACpB,KAA0C,KAChB;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AACjC,aAAA,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5B,aAAA,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK;QAEnC,OAAO,IAAA,CAAA,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC;AACjD,KAAC;AACH,CAAC,EAtnBgB,IAAI,KAAJ,IAAI,GAAA,EAAA,CAAA,CAAA;AAwnBrB;;;;;;;;;;;AAWG;AACH,MAAM,YAAY,GAAG,CACnB,GAAkB;AAClB;AACA,QAAkB,KACV;IACR,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAChC,QAAA,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAChB,QAAA,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;AAChB,QAAA,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;AACf,YAAA,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC;;AAE3B,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;AACpB,YAAA,KAAK,MAAM,EAAE,IAAI,CAAC,EAAE;AAClB,gBAAA,IAAI,QAAQ,CAAC,EAAE,CAAC,EAAE;AAChB,oBAAA,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC;;;;;AAKpC,CAAC;AAED;;;;;;;;;;;;AAYG;AACH,MAAM,QAAQ,GAAG,CAAC,GAAkB,KAAuB;IACzD,MAAM,QAAQ,GAAa,EAAE;AAC7B,IAAA,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC;AAC3B,IAAA,OAAO,QAAQ;AACjB,CAAC;;;;"}