nolo-cli 0.8.0-alpha.2 → 0.8.0-alpha.21

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 (188) hide show
  1. package/README.md +1 -1
  2. package/_executeModel-42U3VOVZ.js +205 -0
  3. package/action-TLI3V62L.js +28 -0
  4. package/addContentAction-57RSIIMR.js +26 -0
  5. package/addDialogAgentAction-G3VWEA6E.js +68 -0
  6. package/agentDeleteCommand-5DD2IM3J.js +327 -0
  7. package/agentEmailCommands-6FACJBU4.js +628 -0
  8. package/agentListCommands-I6KZYCIG.js +223 -0
  9. package/agentMachineCommands-VKLIGMZA.js +425 -0
  10. package/agentPullCommand-O2MTUAFR.js +122 -0
  11. package/agentRecordCommands-7TZICYDT.js +96 -0
  12. package/agentRunCommand-L4OM23KV.js +114 -0
  13. package/agentRunControl-K4VKNEHF.js +57 -0
  14. package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
  15. package/agentSlice-BX7GXSNO.js +42 -0
  16. package/authCommand-EB5JSOX5.js +581 -0
  17. package/authCommands-XPEHTKSM.js +35 -0
  18. package/chunk-25LCXTML.js +175 -0
  19. package/chunk-2ECQG4YX.js +22296 -0
  20. package/chunk-2FTTDCD4.js +675 -0
  21. package/chunk-2JCXITPK.js +1078 -0
  22. package/chunk-3ASDTTEI.js +1774 -0
  23. package/chunk-3EUW3WEO.js +8 -0
  24. package/chunk-3LY4F7SV.js +9293 -0
  25. package/chunk-4CQLVGRV.js +50 -0
  26. package/chunk-4IJYA27C.js +342 -0
  27. package/chunk-4O3CARJ4.js +231 -0
  28. package/chunk-4QEWT7KD.js +933 -0
  29. package/chunk-4SN6J65J.js +38 -0
  30. package/chunk-4VNS5WPM.js +42 -0
  31. package/chunk-4XENYTF5.js +222 -0
  32. package/chunk-4ZDM73SD.js +34 -0
  33. package/chunk-5CS33IBL.js +301 -0
  34. package/chunk-5EFXE3O7.js +138 -0
  35. package/chunk-5KLGBAAR.js +386 -0
  36. package/chunk-5MIDPSSK.js +206 -0
  37. package/chunk-5MMAK75Q.js +15 -0
  38. package/chunk-63W5N6P3.js +150 -0
  39. package/chunk-6HYVJV7B.js +102 -0
  40. package/chunk-6KHNO3SK.js +1948 -0
  41. package/chunk-6WD3OOJS.js +20 -0
  42. package/chunk-7DAJ4AI4.js +191 -0
  43. package/chunk-7GNGZRLZ.js +1939 -0
  44. package/chunk-7KCUSYT2.js +354 -0
  45. package/chunk-7U44LYTR.js +238 -0
  46. package/chunk-AFON4QUU.js +112 -0
  47. package/chunk-AGFH73SK.js +239 -0
  48. package/chunk-AL2KDGR2.js +27339 -0
  49. package/chunk-AS4PVWA4.js +221 -0
  50. package/chunk-ATNTHIZI.js +13 -0
  51. package/chunk-AVMKZHBC.js +85 -0
  52. package/chunk-AZPCASRE.js +36 -0
  53. package/chunk-BBYVOSU2.js +792 -0
  54. package/chunk-C3RUNRHT.js +51 -0
  55. package/chunk-C4FTUXVF.js +146 -0
  56. package/chunk-CF2WZF4N.js +134 -0
  57. package/chunk-CF7PE763.js +10 -0
  58. package/chunk-CKOJQDKR.js +198 -0
  59. package/chunk-CMKUBIGW.js +1550 -0
  60. package/chunk-CWMSB67P.js +34 -0
  61. package/chunk-DCOA4QSN.js +105 -0
  62. package/chunk-DFFIZ25G.js +30 -0
  63. package/chunk-DSZUWUYB.js +478 -0
  64. package/chunk-DWLEOOGR.js +8 -0
  65. package/chunk-DZ3XJVET.js +231 -0
  66. package/chunk-EHLHSX7R.js +1433 -0
  67. package/chunk-ENOG22KJ.js +939 -0
  68. package/chunk-FSO5B7GH.js +171 -0
  69. package/chunk-FVYY6MCS.js +1447 -0
  70. package/chunk-G3SUCT4W.js +8 -0
  71. package/chunk-GAKEBQD6.js +30 -0
  72. package/chunk-GBRG75BQ.js +86 -0
  73. package/chunk-GU3PEVGZ.js +4723 -0
  74. package/chunk-H33743XH.js +25 -0
  75. package/chunk-HNMXYYJR.js +12 -0
  76. package/chunk-HNW7IJSK.js +71 -0
  77. package/chunk-I42VC5KR.js +15 -0
  78. package/chunk-I6XMPTMR.js +113 -0
  79. package/chunk-IDZTNRP2.js +85 -0
  80. package/chunk-ISNCLGUZ.js +146 -0
  81. package/chunk-IWX4UW2E.js +548 -0
  82. package/chunk-JBTJAPUF.js +35 -0
  83. package/chunk-JEXVIMYZ.js +55 -0
  84. package/chunk-JRKKFRAV.js +537 -0
  85. package/chunk-JZPBVBIY.js +94 -0
  86. package/chunk-KKY4B2Q2.js +21 -0
  87. package/chunk-KQHGZWSV.js +63 -0
  88. package/chunk-KUG52IAP.js +8 -0
  89. package/chunk-KX6YBIHG.js +8 -0
  90. package/chunk-LCBAMY2M.js +60 -0
  91. package/chunk-LM6IYQ3F.js +16 -0
  92. package/chunk-LTRXGFMS.js +83 -0
  93. package/chunk-M76ECQRD.js +13658 -0
  94. package/chunk-MRC4Q34M.js +188 -0
  95. package/chunk-MTU75CZ2.js +91 -0
  96. package/chunk-N54XAP77.js +19 -0
  97. package/chunk-O2ZNTTET.js +3272 -0
  98. package/chunk-O4BU24WZ.js +3212 -0
  99. package/chunk-OLZBQWZU.js +6 -0
  100. package/chunk-OOSFSFMA.js +271 -0
  101. package/chunk-OPZYGHUC.js +89 -0
  102. package/chunk-OWOHNGCN.js +50 -0
  103. package/chunk-P3PKED2I.js +962 -0
  104. package/chunk-QSJ3HFEF.js +8 -0
  105. package/chunk-RCSJFQPB.js +9036 -0
  106. package/chunk-RL776AGR.js +190 -0
  107. package/chunk-ROWQEJRP.js +139 -0
  108. package/chunk-S7Z2HMCN.js +25 -0
  109. package/chunk-SDJDLO5W.js +628 -0
  110. package/chunk-SOTZ6RDN.js +69 -0
  111. package/chunk-TILFE6LV.js +381 -0
  112. package/chunk-U4TRT5V4.js +246 -0
  113. package/chunk-U6VC4MU4.js +8 -0
  114. package/chunk-UAD2WT54.js +64 -0
  115. package/chunk-UB6SN4NJ.js +421 -0
  116. package/chunk-URUUZLPA.js +807 -0
  117. package/chunk-UTLZINAP.js +3066 -0
  118. package/chunk-VC6OZXO5.js +298 -0
  119. package/chunk-VF4K2QE6.js +21 -0
  120. package/chunk-VHBWHNVT.js +59 -0
  121. package/chunk-VIDPVFP3.js +20 -0
  122. package/chunk-VP4WJWKW.js +8882 -0
  123. package/chunk-VUW5FBDB.js +573 -0
  124. package/chunk-VVX233PH.js +482 -0
  125. package/chunk-VX3SXJ3N.js +2052 -0
  126. package/chunk-W4NVOSFF.js +37 -0
  127. package/chunk-WWC7I6TA.js +8 -0
  128. package/chunk-WZSRQNQG.js +2587 -0
  129. package/chunk-XBUBEFNX.js +34 -0
  130. package/chunk-XENYHRUE.js +104 -0
  131. package/chunk-Y5GCAMGP.js +9 -0
  132. package/chunk-YPRZSPF3.js +148 -0
  133. package/chunk-Z4NR32XR.js +50 -0
  134. package/chunk-ZNFJWEN4.js +56 -0
  135. package/cliExecutor-K3F7DMRO.js +36 -0
  136. package/clipboardy-BVE3LVEH.js +12001 -0
  137. package/createAgentAutomationAction-RJF3N2QY.js +866 -0
  138. package/createDialogAction-DRSPS6CE.js +55 -0
  139. package/createPageAction-6B2WMNO3.js +172 -0
  140. package/db-HCJ5PRB5.js +271 -0
  141. package/dbSlice-Q3TM2FJV.js +60 -0
  142. package/deleteFile-OW53A6BX.js +41 -0
  143. package/dialogCommands-4IX4XIZE.js +63 -0
  144. package/dialogSlice-3M7KX2TX.js +148 -0
  145. package/docCreateCommands-SIL3NPGT.js +220 -0
  146. package/docDeleteCommands-7IOMLUS4.js +181 -0
  147. package/docReadCommands-FNFXUA5L.js +134 -0
  148. package/docStore-SV7E34D4.js +98 -0
  149. package/docUpdateCommands-X2HNDVUC.js +318 -0
  150. package/fetchMessages-KTNM7QAR.js +17 -0
  151. package/getPricing-3E6UNPKL.js +30 -0
  152. package/handleSendMessageAction-JYETO5RZ.js +185 -0
  153. package/index.js +188 -112958
  154. package/lib-FYYBQIXS.js +19839 -0
  155. package/localDialogRead-2VRI24F4.js +26 -0
  156. package/localFirstLog-DHNOY2NA.js +19 -0
  157. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  158. package/localRuntimeDb-LGDF6FQP.js +12 -0
  159. package/machineCommands-RIO3RP5Q.js +781 -0
  160. package/machineInfo-M6KB6HZN.js +10 -0
  161. package/machineWsRunDispatch-W7UYLGB5.js +112 -0
  162. package/memoryCommands-O4MIPIWQ.js +476 -0
  163. package/models-4OPOOLFS.js +9 -0
  164. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  165. package/package.json +4 -24
  166. package/read-GW7ZEI23.js +17 -0
  167. package/readDocTool-HUFU6OCT.js +16 -0
  168. package/readlineWorkspace-27JR7WPW.js +5682 -0
  169. package/removeDialogAgentAction-CXKR4NJI.js +73 -0
  170. package/runAgentClientLoop-HZFAPJHS.js +293 -0
  171. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  172. package/setDialogExtraReferencesAction-6RKUSXHX.js +60 -0
  173. package/setPrimaryDialogAgentAction-T3UTBEFG.js +80 -0
  174. package/settingSlice-IVKXJXMG.js +199 -0
  175. package/skillDiscovery-UGSQGX2U.js +16 -0
  176. package/skillSummaryMarker-42HKSXYY.js +9 -0
  177. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  178. package/slateUtils-2M7MUTWX.js +19 -0
  179. package/spaceCommands-E7VOF4LO.js +450 -0
  180. package/spaceSlice-TSVROA5U.js +149 -0
  181. package/streamAgentChatTurn-3C5RQZJF.js +4510 -0
  182. package/tableCommands-O7O2LBEG.js +1286 -0
  183. package/toolApiClient-QI3YBNWB.js +26 -0
  184. package/tools-EQDEKR6N.js +87 -0
  185. package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
  186. package/understanding-3CUQQ6SV.js +271 -0
  187. package/updateCommands-VOSPKXFF.js +31 -0
  188. package/updateDialogTitleAction-3XV7VWSZ.js +188 -0
@@ -0,0 +1,3212 @@
1
+ import {
2
+ asNonEmptyStringArray
3
+ } from "./chunk-I42VC5KR.js";
4
+ import {
5
+ asOptionalFiniteNumber
6
+ } from "./chunk-WWC7I6TA.js";
7
+ import {
8
+ asTrimmedString
9
+ } from "./chunk-3EUW3WEO.js";
10
+ import {
11
+ asOptionalTrimmedString
12
+ } from "./chunk-G3SUCT4W.js";
13
+ import {
14
+ __commonJS,
15
+ __toESM
16
+ } from "./chunk-4VNS5WPM.js";
17
+
18
+ // node_modules/rambda/dist/rambda.js
19
+ var require_rambda = __commonJS({
20
+ "node_modules/rambda/dist/rambda.js"(exports) {
21
+ "use strict";
22
+ function F() {
23
+ return false;
24
+ }
25
+ function T() {
26
+ return true;
27
+ }
28
+ function add(a, b) {
29
+ if (arguments.length === 1) return (_b) => add(a, _b);
30
+ return Number(a) + Number(b);
31
+ }
32
+ function _concat(set1, set2) {
33
+ set1 = set1 || [];
34
+ set2 = set2 || [];
35
+ let idx;
36
+ const len1 = set1.length;
37
+ const len2 = set2.length;
38
+ const result = [];
39
+ idx = 0;
40
+ while (idx < len1) {
41
+ result[result.length] = set1[idx];
42
+ idx += 1;
43
+ }
44
+ idx = 0;
45
+ while (idx < len2) {
46
+ result[result.length] = set2[idx];
47
+ idx += 1;
48
+ }
49
+ return result;
50
+ }
51
+ function _arity(n, fn) {
52
+ switch (n) {
53
+ case 0:
54
+ return function() {
55
+ return fn.apply(this, arguments);
56
+ };
57
+ case 1:
58
+ return function(_1) {
59
+ return fn.apply(this, arguments);
60
+ };
61
+ case 2:
62
+ return function(_1, _2) {
63
+ return fn.apply(this, arguments);
64
+ };
65
+ case 3:
66
+ return function(_1, _2, _3) {
67
+ return fn.apply(this, arguments);
68
+ };
69
+ case 4:
70
+ return function(_1, _2, _3, _4) {
71
+ return fn.apply(this, arguments);
72
+ };
73
+ case 5:
74
+ return function(_1, _2, _3, _4, _5) {
75
+ return fn.apply(this, arguments);
76
+ };
77
+ case 6:
78
+ return function(_1, _2, _3, _4, _5, _6) {
79
+ return fn.apply(this, arguments);
80
+ };
81
+ case 7:
82
+ return function(_1, _2, _3, _4, _5, _6, _7) {
83
+ return fn.apply(this, arguments);
84
+ };
85
+ case 8:
86
+ return function(_1, _2, _3, _4, _5, _6, _7, _8) {
87
+ return fn.apply(this, arguments);
88
+ };
89
+ case 9:
90
+ return function(_1, _2, _3, _4, _5, _6, _7, _8, _9) {
91
+ return fn.apply(this, arguments);
92
+ };
93
+ default:
94
+ return function(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) {
95
+ return fn.apply(this, arguments);
96
+ };
97
+ }
98
+ }
99
+ function _curryN(n, cache, fn) {
100
+ return function() {
101
+ let ci = 0;
102
+ let ai = 0;
103
+ const cl = cache.length;
104
+ const al = arguments.length;
105
+ const args = new Array(cl + al);
106
+ while (ci < cl) {
107
+ args[ci] = cache[ci];
108
+ ci++;
109
+ }
110
+ while (ai < al) {
111
+ args[cl + ai] = arguments[ai];
112
+ ai++;
113
+ }
114
+ const remaining = n - args.length;
115
+ return args.length >= n ? fn.apply(this, args) : _arity(remaining, _curryN(n, args, fn));
116
+ };
117
+ }
118
+ function curryN(n, fn) {
119
+ if (arguments.length === 1) return (_fn) => curryN(n, _fn);
120
+ if (n > 10) {
121
+ throw new Error("First argument to _arity must be a non-negative integer no greater than ten");
122
+ }
123
+ return _arity(n, _curryN(n, [], fn));
124
+ }
125
+ function addIndex(originalFunction, initialIndexFn = () => 0, loopIndexChange = (x) => x + 1) {
126
+ return curryN(originalFunction.length, function() {
127
+ const origFn = arguments[0];
128
+ const list = arguments[arguments.length - 1];
129
+ let idx = initialIndexFn(list.length);
130
+ const args = Array.prototype.slice.call(arguments, 0);
131
+ args[0] = function() {
132
+ const result = origFn.apply(this, _concat(arguments, [idx, list]));
133
+ idx = loopIndexChange(idx);
134
+ return result;
135
+ };
136
+ return originalFunction.apply(this, args);
137
+ });
138
+ }
139
+ function addIndexRight(originalFunction) {
140
+ return addIndex(originalFunction, (listLength) => listLength - 1, (x) => x - 1);
141
+ }
142
+ var cloneList = (list) => Array.prototype.slice.call(list);
143
+ function curry2(fn, args = []) {
144
+ return (..._args) => ((rest) => rest.length >= fn.length ? fn(...rest) : curry2(fn, rest))([...args, ..._args]);
145
+ }
146
+ function adjustFn(index, replaceFn2, list) {
147
+ const actualIndex = index < 0 ? list.length + index : index;
148
+ if (index >= list.length || actualIndex < 0) return list;
149
+ const clone2 = cloneList(list);
150
+ clone2[actualIndex] = replaceFn2(clone2[actualIndex]);
151
+ return clone2;
152
+ }
153
+ var adjust = curry2(adjustFn);
154
+ function all(predicate, list) {
155
+ if (arguments.length === 1) return (_list) => all(predicate, _list);
156
+ for (let i = 0; i < list.length; i++) {
157
+ if (!predicate(list[i])) return false;
158
+ }
159
+ return true;
160
+ }
161
+ function allPass(predicates) {
162
+ return (...input) => {
163
+ let counter = 0;
164
+ while (counter < predicates.length) {
165
+ if (!predicates[counter](...input)) {
166
+ return false;
167
+ }
168
+ counter++;
169
+ }
170
+ return true;
171
+ };
172
+ }
173
+ function always(x) {
174
+ return (_) => x;
175
+ }
176
+ function and(a, b) {
177
+ if (arguments.length === 1) return (_b) => and(a, _b);
178
+ return a && b;
179
+ }
180
+ function any(predicate, list) {
181
+ if (arguments.length === 1) return (_list) => any(predicate, _list);
182
+ let counter = 0;
183
+ while (counter < list.length) {
184
+ if (predicate(list[counter], counter)) {
185
+ return true;
186
+ }
187
+ counter++;
188
+ }
189
+ return false;
190
+ }
191
+ function anyPass(predicates) {
192
+ return (...input) => {
193
+ let counter = 0;
194
+ while (counter < predicates.length) {
195
+ if (predicates[counter](...input)) {
196
+ return true;
197
+ }
198
+ counter++;
199
+ }
200
+ return false;
201
+ };
202
+ }
203
+ function ap(functions, input) {
204
+ if (arguments.length === 1) {
205
+ return (_inputs) => ap(functions, _inputs);
206
+ }
207
+ return functions.reduce((acc, fn) => [...acc, ...input.map(fn)], []);
208
+ }
209
+ function aperture(step, list) {
210
+ if (arguments.length === 1) {
211
+ return (_list) => aperture(step, _list);
212
+ }
213
+ if (step > list.length) return [];
214
+ let idx = 0;
215
+ const limit = list.length - (step - 1);
216
+ const acc = new Array(limit);
217
+ while (idx < limit) {
218
+ acc[idx] = list.slice(idx, idx + step);
219
+ idx += 1;
220
+ }
221
+ return acc;
222
+ }
223
+ function append(x, input) {
224
+ if (arguments.length === 1) return (_input) => append(x, _input);
225
+ if (typeof input === "string") return input.split("").concat(x);
226
+ const clone2 = cloneList(input);
227
+ clone2.push(x);
228
+ return clone2;
229
+ }
230
+ function apply(fn, args) {
231
+ if (arguments.length === 1) {
232
+ return (_args) => apply(fn, _args);
233
+ }
234
+ return fn.apply(this, args);
235
+ }
236
+ var {
237
+ isArray
238
+ } = Array;
239
+ function __findHighestArity(spec, max2 = 0) {
240
+ for (const key in spec) {
241
+ if (spec.hasOwnProperty(key) === false || key === "constructor") continue;
242
+ if (typeof spec[key] === "object") {
243
+ max2 = Math.max(max2, __findHighestArity(spec[key]));
244
+ }
245
+ if (typeof spec[key] === "function") {
246
+ max2 = Math.max(max2, spec[key].length);
247
+ }
248
+ }
249
+ return max2;
250
+ }
251
+ function __filterUndefined() {
252
+ const defined = [];
253
+ let i = 0;
254
+ const l = arguments.length;
255
+ while (i < l) {
256
+ if (typeof arguments[i] === "undefined") break;
257
+ defined[i] = arguments[i];
258
+ i++;
259
+ }
260
+ return defined;
261
+ }
262
+ function __applySpecWithArity(spec, arity, cache) {
263
+ const remaining = arity - cache.length;
264
+ if (remaining === 1) return (x) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x));
265
+ if (remaining === 2) return (x, y) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y));
266
+ if (remaining === 3) return (x, y, z) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z));
267
+ if (remaining === 4) return (x, y, z, a) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z, a));
268
+ if (remaining > 4) return (...args) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, ...args));
269
+ if (isArray(spec)) {
270
+ const ret2 = [];
271
+ let i = 0;
272
+ const l = spec.length;
273
+ for (; i < l; i++) {
274
+ if (typeof spec[i] === "object" || isArray(spec[i])) {
275
+ ret2[i] = __applySpecWithArity(spec[i], arity, cache);
276
+ }
277
+ if (typeof spec[i] === "function") {
278
+ ret2[i] = spec[i](...cache);
279
+ }
280
+ }
281
+ return ret2;
282
+ }
283
+ const ret = {};
284
+ for (const key in spec) {
285
+ if (spec.hasOwnProperty(key) === false || key === "constructor") continue;
286
+ if (typeof spec[key] === "object") {
287
+ ret[key] = __applySpecWithArity(spec[key], arity, cache);
288
+ continue;
289
+ }
290
+ if (typeof spec[key] === "function") {
291
+ ret[key] = spec[key](...cache);
292
+ }
293
+ }
294
+ return ret;
295
+ }
296
+ function applySpec(spec, ...args) {
297
+ const arity = __findHighestArity(spec);
298
+ if (arity === 0) {
299
+ return () => ({});
300
+ }
301
+ const toReturn = __applySpecWithArity(spec, arity, args);
302
+ return toReturn;
303
+ }
304
+ function applyTo(input, fn) {
305
+ if (arguments.length === 1) {
306
+ return (_fn) => applyTo(input, _fn);
307
+ }
308
+ return fn(input);
309
+ }
310
+ function createCompareFunction(a, b, winner, loser) {
311
+ if (a === b) return 0;
312
+ return a < b ? winner : loser;
313
+ }
314
+ function ascend(getFunction, a, b) {
315
+ if (arguments.length === 1) {
316
+ return (_a, _b) => ascend(getFunction, _a, _b);
317
+ }
318
+ const aValue = getFunction(a);
319
+ const bValue = getFunction(b);
320
+ return createCompareFunction(aValue, bValue, -1, 1);
321
+ }
322
+ function assocFn(prop2, newValue, obj) {
323
+ return Object.assign({}, obj, {
324
+ [prop2]: newValue
325
+ });
326
+ }
327
+ var assoc = curry2(assocFn);
328
+ function _isInteger(n) {
329
+ return n << 0 === n;
330
+ }
331
+ var isInteger = Number.isInteger || _isInteger;
332
+ var isIndexInteger = (index) => Number.isInteger(Number(index));
333
+ function createPath(path2, delimiter = ".") {
334
+ return typeof path2 === "string" ? path2.split(delimiter).map((x) => isInteger(x) ? Number(x) : x) : path2;
335
+ }
336
+ function assocPathFn(path2, newValue, input) {
337
+ const pathArrValue = createPath(path2);
338
+ if (pathArrValue.length === 0) return newValue;
339
+ const index = pathArrValue[0];
340
+ if (pathArrValue.length > 1) {
341
+ const condition = typeof input !== "object" || input === null || !input.hasOwnProperty(index);
342
+ const nextInput = condition ? isIndexInteger(pathArrValue[1]) ? [] : {} : input[index];
343
+ newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue, nextInput);
344
+ }
345
+ if (isIndexInteger(index) && isArray(input)) {
346
+ const arr = cloneList(input);
347
+ arr[index] = newValue;
348
+ return arr;
349
+ }
350
+ return assocFn(index, newValue, input);
351
+ }
352
+ var assocPath = curry2(assocPathFn);
353
+ function binary(fn) {
354
+ if (fn.length <= 2) return fn;
355
+ return (a, b) => fn(a, b);
356
+ }
357
+ function bind(fn, thisObj) {
358
+ if (arguments.length === 1) {
359
+ return (_thisObj) => bind(fn, _thisObj);
360
+ }
361
+ return curryN(fn.length, (...args) => fn.apply(thisObj, args));
362
+ }
363
+ function both(f, g) {
364
+ if (arguments.length === 1) return (_g) => both(f, _g);
365
+ return (...input) => f(...input) && g(...input);
366
+ }
367
+ var call = (fn, ...inputs) => fn(...inputs);
368
+ function chain(fn, list) {
369
+ if (arguments.length === 1) {
370
+ return (_list) => chain(fn, _list);
371
+ }
372
+ return [].concat(...list.map(fn));
373
+ }
374
+ function clampFn(min2, max2, input) {
375
+ if (min2 > max2) {
376
+ throw new Error("min must not be greater than max in clamp(min, max, value)");
377
+ }
378
+ if (input >= min2 && input <= max2) return input;
379
+ if (input > max2) return max2;
380
+ if (input < min2) return min2;
381
+ }
382
+ var clamp = curry2(clampFn);
383
+ function clone(input) {
384
+ const out = isArray(input) ? Array(input.length) : {};
385
+ if (input && input.getTime) return new Date(input.getTime());
386
+ for (const key in input) {
387
+ const v = input[key];
388
+ out[key] = typeof v === "object" && v !== null ? v.getTime ? new Date(v.getTime()) : clone(v) : v;
389
+ }
390
+ return out;
391
+ }
392
+ var ReduceStopper = class {
393
+ constructor(value) {
394
+ this.value = value;
395
+ }
396
+ };
397
+ function reduceFn(reducer, acc, list) {
398
+ if (list == null) {
399
+ return acc;
400
+ }
401
+ if (!isArray(list)) {
402
+ throw new TypeError("reduce: list must be array or iterable");
403
+ }
404
+ let index = 0;
405
+ const len = list.length;
406
+ while (index < len) {
407
+ acc = reducer(acc, list[index], index, list);
408
+ if (acc instanceof ReduceStopper) {
409
+ return acc.value;
410
+ }
411
+ index++;
412
+ }
413
+ return acc;
414
+ }
415
+ var reduce = curry2(reduceFn);
416
+ var reduceStopper = (value) => new ReduceStopper(value);
417
+ function collectBy(fn, list) {
418
+ if (arguments.length === 1) {
419
+ return (_list) => collectBy(fn, _list);
420
+ }
421
+ const group = reduce((o, x) => {
422
+ const tag = fn(x);
423
+ if (o[tag] === void 0) {
424
+ o[tag] = [];
425
+ }
426
+ o[tag].push(x);
427
+ return o;
428
+ }, {}, list);
429
+ const newList = [];
430
+ for (const tag in group) {
431
+ newList.push(group[tag]);
432
+ }
433
+ return newList;
434
+ }
435
+ function comparator(fn) {
436
+ return function(a, b) {
437
+ return fn(a, b) ? -1 : fn(b, a) ? 1 : 0;
438
+ };
439
+ }
440
+ function complement(fn) {
441
+ return (...input) => !fn(...input);
442
+ }
443
+ function _pipe(f, g) {
444
+ return function() {
445
+ return g.call(this, f.apply(this, arguments));
446
+ };
447
+ }
448
+ function pipe() {
449
+ if (arguments.length === 0) {
450
+ throw new Error("pipe requires at least one argument");
451
+ }
452
+ return _arity(arguments[0].length, reduceFn(_pipe, arguments[0], Array.prototype.slice.call(arguments, 1, Infinity)));
453
+ }
454
+ function compose() {
455
+ if (arguments.length === 0) {
456
+ throw new Error("compose requires at least one argument");
457
+ }
458
+ return pipe.apply(this, Array.prototype.slice.call(arguments, 0).reverse());
459
+ }
460
+ function head(listOrString) {
461
+ if (typeof listOrString === "string") return listOrString[0] || "";
462
+ return listOrString[0];
463
+ }
464
+ function identity(x) {
465
+ return x;
466
+ }
467
+ function reverse(listOrString) {
468
+ if (typeof listOrString === "string") {
469
+ return listOrString.split("").reverse().join("");
470
+ }
471
+ const clone2 = listOrString.slice();
472
+ return clone2.reverse();
473
+ }
474
+ function drop(howManyToDrop, listOrString) {
475
+ if (arguments.length === 1) return (_list) => drop(howManyToDrop, _list);
476
+ return listOrString.slice(howManyToDrop > 0 ? howManyToDrop : 0);
477
+ }
478
+ function tail(listOrString) {
479
+ return drop(1, listOrString);
480
+ }
481
+ function pipeWith(xf, list) {
482
+ if (list.length <= 0) {
483
+ return identity;
484
+ }
485
+ const headList = head(list);
486
+ const tailList = tail(list);
487
+ return _arity(headList.length, function() {
488
+ return reduce(function(result, f) {
489
+ return xf.call(this, f, result);
490
+ }, headList.apply(this, arguments), tailList);
491
+ });
492
+ }
493
+ function composeWith(xf, list) {
494
+ if (arguments.length === 1) return (_list) => composeWith(xf, _list);
495
+ return pipeWith.apply(this, [xf, reverse(list)]);
496
+ }
497
+ function concat(x, y) {
498
+ if (arguments.length === 1) return (_y) => concat(x, _y);
499
+ return typeof x === "string" ? `${x}${y}` : [...x, ...y];
500
+ }
501
+ function cond(conditions) {
502
+ return (input) => {
503
+ let done = false;
504
+ let toReturn;
505
+ conditions.forEach(([predicate, resultClosure]) => {
506
+ if (!done && predicate(input)) {
507
+ done = true;
508
+ toReturn = resultClosure(input);
509
+ }
510
+ });
511
+ return toReturn;
512
+ };
513
+ }
514
+ var INCORRECT_ITERABLE_INPUT = "Incorrect iterable input";
515
+ var {
516
+ keys: keys$1
517
+ } = Object;
518
+ function mapArray(fn, list, isIndexed = false) {
519
+ let index = 0;
520
+ const willReturn = Array(list.length);
521
+ while (index < list.length) {
522
+ willReturn[index] = isIndexed ? fn(list[index], index) : fn(list[index]);
523
+ index++;
524
+ }
525
+ return willReturn;
526
+ }
527
+ function mapObject(fn, obj) {
528
+ if (arguments.length === 1) {
529
+ return (_obj) => mapObject(fn, _obj);
530
+ }
531
+ let index = 0;
532
+ const objKeys = keys$1(obj);
533
+ const len = objKeys.length;
534
+ const willReturn = {};
535
+ while (index < len) {
536
+ const key = objKeys[index];
537
+ willReturn[key] = fn(obj[key], key, obj);
538
+ index++;
539
+ }
540
+ return willReturn;
541
+ }
542
+ var mapObjIndexed = mapObject;
543
+ function map(fn, iterable) {
544
+ if (arguments.length === 1) return (_iterable) => map(fn, _iterable);
545
+ if (!iterable) {
546
+ throw new Error(INCORRECT_ITERABLE_INPUT);
547
+ }
548
+ if (isArray(iterable)) return mapArray(fn, iterable);
549
+ return mapObject(fn, iterable);
550
+ }
551
+ function max(x, y) {
552
+ if (arguments.length === 1) return (_y) => max(x, _y);
553
+ return y > x ? y : x;
554
+ }
555
+ function converge(fn, transformers) {
556
+ if (arguments.length === 1) return (_transformers) => converge(fn, _transformers);
557
+ const highestArity = reduce((a, b) => max(a, b.length), 0, transformers);
558
+ return curryN(highestArity, function() {
559
+ return fn.apply(this, map((g) => g.apply(this, arguments), transformers));
560
+ });
561
+ }
562
+ function count(predicate, list) {
563
+ if (arguments.length === 1) {
564
+ return (_list) => count(predicate, _list);
565
+ }
566
+ if (!isArray(list)) return 0;
567
+ return list.filter((x) => predicate(x)).length;
568
+ }
569
+ function countBy(fn, list) {
570
+ if (arguments.length === 1) {
571
+ return (_list) => countBy(fn, _list);
572
+ }
573
+ const willReturn = {};
574
+ list.forEach((item) => {
575
+ const key = fn(item);
576
+ if (!willReturn[key]) {
577
+ willReturn[key] = 1;
578
+ } else {
579
+ willReturn[key]++;
580
+ }
581
+ });
582
+ return willReturn;
583
+ }
584
+ var dec = (x) => x - 1;
585
+ function isFalsy(input) {
586
+ return input === void 0 || input === null || Number.isNaN(input) === true;
587
+ }
588
+ function defaultTo(defaultArgument, input) {
589
+ if (arguments.length === 1) {
590
+ return (_input) => defaultTo(defaultArgument, _input);
591
+ }
592
+ return isFalsy(input) ? defaultArgument : input;
593
+ }
594
+ function descend(getFunction, a, b) {
595
+ if (arguments.length === 1) {
596
+ return (_a, _b) => descend(getFunction, _a, _b);
597
+ }
598
+ const aValue = getFunction(a);
599
+ const bValue = getFunction(b);
600
+ return createCompareFunction(aValue, bValue, 1, -1);
601
+ }
602
+ function type(input) {
603
+ if (input === null) {
604
+ return "Null";
605
+ } else if (input === void 0) {
606
+ return "Undefined";
607
+ } else if (Number.isNaN(input)) {
608
+ return "NaN";
609
+ }
610
+ const typeResult = Object.prototype.toString.call(input).slice(8, -1);
611
+ return typeResult === "AsyncFunction" ? "Promise" : typeResult;
612
+ }
613
+ function _lastIndexOf(valueToFind, list) {
614
+ if (!isArray(list)) throw new Error(`Cannot read property 'indexOf' of ${list}`);
615
+ const typeOfValue = type(valueToFind);
616
+ if (!["Array", "NaN", "Object", "RegExp"].includes(typeOfValue)) return list.lastIndexOf(valueToFind);
617
+ const {
618
+ length: length2
619
+ } = list;
620
+ let index = length2;
621
+ let foundIndex = -1;
622
+ while (--index > -1 && foundIndex === -1) if (equals(list[index], valueToFind)) foundIndex = index;
623
+ return foundIndex;
624
+ }
625
+ function _indexOf(valueToFind, list) {
626
+ if (!isArray(list)) throw new Error(`Cannot read property 'indexOf' of ${list}`);
627
+ const typeOfValue = type(valueToFind);
628
+ if (!["Array", "NaN", "Object", "RegExp"].includes(typeOfValue)) return list.indexOf(valueToFind);
629
+ let index = -1;
630
+ let foundIndex = -1;
631
+ const {
632
+ length: length2
633
+ } = list;
634
+ while (++index < length2 && foundIndex === -1) if (equals(list[index], valueToFind)) foundIndex = index;
635
+ return foundIndex;
636
+ }
637
+ function _arrayFromIterator(iter) {
638
+ const list = [];
639
+ let next;
640
+ while (!(next = iter.next()).done) list.push(next.value);
641
+ return list;
642
+ }
643
+ function _compareSets(a, b) {
644
+ if (a.size !== b.size) return false;
645
+ const aList = _arrayFromIterator(a.values());
646
+ const bList = _arrayFromIterator(b.values());
647
+ const filtered = aList.filter((aInstance) => _indexOf(aInstance, bList) === -1);
648
+ return filtered.length === 0;
649
+ }
650
+ function compareErrors(a, b) {
651
+ if (a.message !== b.message) return false;
652
+ if (a.toString !== b.toString) return false;
653
+ return a.toString() === b.toString();
654
+ }
655
+ function parseDate(maybeDate) {
656
+ if (!maybeDate.toDateString) return [false];
657
+ return [true, maybeDate.getTime()];
658
+ }
659
+ function parseRegex(maybeRegex) {
660
+ if (maybeRegex.constructor !== RegExp) return [false];
661
+ return [true, maybeRegex.toString()];
662
+ }
663
+ function equals(a, b) {
664
+ if (arguments.length === 1) return (_b) => equals(a, _b);
665
+ const aType = type(a);
666
+ if (aType !== type(b)) return false;
667
+ if (aType === "Function") return a.name === void 0 ? false : a.name === b.name;
668
+ if (["NaN", "Null", "Undefined"].includes(aType)) return true;
669
+ if (["BigInt", "Number"].includes(aType)) {
670
+ if (Object.is(-0, a) !== Object.is(-0, b)) return false;
671
+ return a.toString() === b.toString();
672
+ }
673
+ if (["Boolean", "String"].includes(aType)) return a.toString() === b.toString();
674
+ if (aType === "Array") {
675
+ const aClone = Array.from(a);
676
+ const bClone = Array.from(b);
677
+ if (aClone.toString() !== bClone.toString()) return false;
678
+ let loopArrayFlag = true;
679
+ aClone.forEach((aCloneInstance, aCloneIndex) => {
680
+ if (loopArrayFlag) {
681
+ if (aCloneInstance !== bClone[aCloneIndex] && !equals(aCloneInstance, bClone[aCloneIndex])) loopArrayFlag = false;
682
+ }
683
+ });
684
+ return loopArrayFlag;
685
+ }
686
+ const aRegex = parseRegex(a);
687
+ const bRegex = parseRegex(b);
688
+ if (aRegex[0]) return bRegex[0] ? aRegex[1] === bRegex[1] : false;
689
+ else if (bRegex[0]) return false;
690
+ const aDate = parseDate(a);
691
+ const bDate = parseDate(b);
692
+ if (aDate[0]) return bDate[0] ? aDate[1] === bDate[1] : false;
693
+ else if (bDate[0]) return false;
694
+ if (a instanceof Error) {
695
+ if (!(b instanceof Error)) return false;
696
+ return compareErrors(a, b);
697
+ }
698
+ if (aType === "Set") return _compareSets(a, b);
699
+ if (aType === "Object") {
700
+ const aKeys = Object.keys(a);
701
+ if (aKeys.length !== Object.keys(b).length) return false;
702
+ let loopObjectFlag = true;
703
+ aKeys.forEach((aKeyInstance) => {
704
+ if (loopObjectFlag) {
705
+ const aValue = a[aKeyInstance];
706
+ const bValue = b[aKeyInstance];
707
+ if (aValue !== bValue && !equals(aValue, bValue)) loopObjectFlag = false;
708
+ }
709
+ });
710
+ return loopObjectFlag;
711
+ }
712
+ return false;
713
+ }
714
+ function includes$1(valueToFind, iterable) {
715
+ if (arguments.length === 1) return (_iterable) => includes$1(valueToFind, _iterable);
716
+ if (typeof iterable === "string") {
717
+ return iterable.includes(valueToFind);
718
+ }
719
+ if (!iterable) {
720
+ throw new TypeError(`Cannot read property 'indexOf' of ${iterable}`);
721
+ }
722
+ if (!isArray(iterable)) return false;
723
+ return _indexOf(valueToFind, iterable) > -1;
724
+ }
725
+ var _Set = class {
726
+ constructor() {
727
+ this.set = /* @__PURE__ */ new Set();
728
+ this.items = {};
729
+ }
730
+ checkUniqueness(item) {
731
+ const type$1 = type(item);
732
+ if (["Null", "Undefined", "NaN"].includes(type$1)) {
733
+ if (type$1 in this.items) {
734
+ return false;
735
+ }
736
+ this.items[type$1] = true;
737
+ return true;
738
+ }
739
+ if (!["Object", "Array"].includes(type$1)) {
740
+ const prevSize = this.set.size;
741
+ this.set.add(item);
742
+ return this.set.size !== prevSize;
743
+ }
744
+ if (!(type$1 in this.items)) {
745
+ this.items[type$1] = [item];
746
+ return true;
747
+ }
748
+ if (_indexOf(item, this.items[type$1]) === -1) {
749
+ this.items[type$1].push(item);
750
+ return true;
751
+ }
752
+ return false;
753
+ }
754
+ };
755
+ function uniq(list) {
756
+ const set2 = new _Set();
757
+ const willReturn = [];
758
+ list.forEach((item) => {
759
+ if (set2.checkUniqueness(item)) {
760
+ willReturn.push(item);
761
+ }
762
+ });
763
+ return willReturn;
764
+ }
765
+ function difference(a, b) {
766
+ if (arguments.length === 1) return (_b) => difference(a, _b);
767
+ return uniq(a).filter((aInstance) => !includes$1(aInstance, b));
768
+ }
769
+ function differenceWithFn(fn, a, b) {
770
+ const willReturn = [];
771
+ const [first, second] = a.length > b.length ? [a, b] : [b, a];
772
+ first.forEach((item) => {
773
+ const hasItem = second.some((secondItem) => fn(item, secondItem));
774
+ if (!hasItem && _indexOf(item, willReturn) === -1) {
775
+ willReturn.push(item);
776
+ }
777
+ });
778
+ return willReturn;
779
+ }
780
+ var differenceWith = curry2(differenceWithFn);
781
+ function dissoc(prop2, obj) {
782
+ if (arguments.length === 1) return (_obj) => dissoc(prop2, _obj);
783
+ if (obj === null || obj === void 0) return {};
784
+ const willReturn = {};
785
+ for (const p in obj) {
786
+ willReturn[p] = obj[p];
787
+ }
788
+ delete willReturn[prop2];
789
+ return willReturn;
790
+ }
791
+ function ownKeys(e, r) {
792
+ var t = Object.keys(e);
793
+ if (Object.getOwnPropertySymbols) {
794
+ var o = Object.getOwnPropertySymbols(e);
795
+ r && (o = o.filter(function(r2) {
796
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
797
+ })), t.push.apply(t, o);
798
+ }
799
+ return t;
800
+ }
801
+ function _objectSpread2(e) {
802
+ for (var r = 1; r < arguments.length; r++) {
803
+ var t = null != arguments[r] ? arguments[r] : {};
804
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
805
+ _defineProperty(e, r2, t[r2]);
806
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
807
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
808
+ });
809
+ }
810
+ return e;
811
+ }
812
+ function _defineProperty(obj, key, value) {
813
+ key = _toPropertyKey(key);
814
+ if (key in obj) {
815
+ Object.defineProperty(obj, key, {
816
+ value,
817
+ enumerable: true,
818
+ configurable: true,
819
+ writable: true
820
+ });
821
+ } else {
822
+ obj[key] = value;
823
+ }
824
+ return obj;
825
+ }
826
+ function _toPrimitive(input, hint) {
827
+ if (typeof input !== "object" || input === null) return input;
828
+ var prim = input[Symbol.toPrimitive];
829
+ if (prim !== void 0) {
830
+ var res = prim.call(input, hint || "default");
831
+ if (typeof res !== "object") return res;
832
+ throw new TypeError("@@toPrimitive must return a primitive value.");
833
+ }
834
+ return (hint === "string" ? String : Number)(input);
835
+ }
836
+ function _toPropertyKey(arg) {
837
+ var key = _toPrimitive(arg, "string");
838
+ return typeof key === "symbol" ? key : String(key);
839
+ }
840
+ function compare(a, b) {
841
+ return String(a) === String(b);
842
+ }
843
+ function includes(a, list) {
844
+ let index = -1;
845
+ const {
846
+ length: length2
847
+ } = list;
848
+ while (++index < length2) if (compare(list[index], a)) return true;
849
+ return false;
850
+ }
851
+ function omit(propsToOmit, obj) {
852
+ if (arguments.length === 1) return (_obj) => omit(propsToOmit, _obj);
853
+ if (obj === null || obj === void 0) return void 0;
854
+ const propsToOmitValue = createPath(propsToOmit, ",");
855
+ const willReturn = {};
856
+ for (const key in obj) if (!includes(key, propsToOmitValue)) willReturn[key] = obj[key];
857
+ return willReturn;
858
+ }
859
+ function pathFn(pathInput, obj) {
860
+ let willReturn = obj;
861
+ let counter = 0;
862
+ const pathArrValue = createPath(pathInput);
863
+ while (counter < pathArrValue.length) {
864
+ if (willReturn === null || willReturn === void 0) {
865
+ return void 0;
866
+ }
867
+ if (willReturn[pathArrValue[counter]] === null) return void 0;
868
+ willReturn = willReturn[pathArrValue[counter]];
869
+ counter++;
870
+ }
871
+ return willReturn;
872
+ }
873
+ function path(pathInput, obj) {
874
+ if (arguments.length === 1) return (_obj) => path(pathInput, _obj);
875
+ if (obj === null || obj === void 0) {
876
+ return void 0;
877
+ }
878
+ return pathFn(pathInput, obj);
879
+ }
880
+ function removeIndex(index, list) {
881
+ if (arguments.length === 1) return (_list) => removeIndex(index, _list);
882
+ if (index <= 0) return list.slice(1);
883
+ if (index >= list.length - 1) return list.slice(0, list.length - 1);
884
+ return [...list.slice(0, index), ...list.slice(index + 1)];
885
+ }
886
+ function updateFn(index, newValue, list) {
887
+ const clone2 = cloneList(list);
888
+ if (index === -1) return clone2.fill(newValue, index);
889
+ return clone2.fill(newValue, index, index + 1);
890
+ }
891
+ var update = curry2(updateFn);
892
+ function dissocPath(pathInput, input) {
893
+ if (arguments.length === 1) return (_obj) => dissocPath(pathInput, _obj);
894
+ const pathArrValue = createPath(pathInput);
895
+ if (pathArrValue.length === 0) return input;
896
+ const pathResult = path(pathArrValue, input);
897
+ if (pathResult === void 0) return input;
898
+ const index = pathArrValue[0];
899
+ const condition = typeof input !== "object" || input === null || !input.hasOwnProperty(index);
900
+ if (pathArrValue.length > 1) {
901
+ const nextInput = condition ? isIndexInteger(pathArrValue[1]) ? [] : {} : input[index];
902
+ const nextPathInput = Array.prototype.slice.call(pathArrValue, 1);
903
+ const intermediateResult = dissocPath(nextPathInput, nextInput, input);
904
+ if (isArray(input)) return update(index, intermediateResult, input);
905
+ return _objectSpread2(_objectSpread2({}, input), {}, {
906
+ [index]: intermediateResult
907
+ });
908
+ }
909
+ if (isArray(input)) return removeIndex(index, input);
910
+ return omit([index], input);
911
+ }
912
+ function divide(a, b) {
913
+ if (arguments.length === 1) return (_b) => divide(a, _b);
914
+ return a / b;
915
+ }
916
+ function dropLast(howManyToDrop, listOrString) {
917
+ if (arguments.length === 1) {
918
+ return (_listOrString) => dropLast(howManyToDrop, _listOrString);
919
+ }
920
+ return howManyToDrop > 0 ? listOrString.slice(0, -howManyToDrop) : listOrString.slice();
921
+ }
922
+ function dropLastWhile(predicate, iterable) {
923
+ if (arguments.length === 1) {
924
+ return (_iterable) => dropLastWhile(predicate, _iterable);
925
+ }
926
+ if (iterable.length === 0) return iterable;
927
+ const isArray$1 = isArray(iterable);
928
+ if (typeof predicate !== "function") {
929
+ throw new Error(`'predicate' is from wrong type ${typeof predicate}`);
930
+ }
931
+ if (!isArray$1 && typeof iterable !== "string") {
932
+ throw new Error(`'iterable' is from wrong type ${typeof iterable}`);
933
+ }
934
+ const toReturn = [];
935
+ let counter = iterable.length;
936
+ while (counter) {
937
+ const item = iterable[--counter];
938
+ if (!predicate(item)) {
939
+ toReturn.push(item);
940
+ break;
941
+ }
942
+ }
943
+ while (counter) {
944
+ toReturn.push(iterable[--counter]);
945
+ }
946
+ return isArray$1 ? toReturn.reverse() : toReturn.reverse().join("");
947
+ }
948
+ function dropRepeats(list) {
949
+ if (!isArray(list)) {
950
+ throw new Error(`${list} is not a list`);
951
+ }
952
+ const toReturn = [];
953
+ list.reduce((prev, current) => {
954
+ if (!equals(prev, current)) {
955
+ toReturn.push(current);
956
+ }
957
+ return current;
958
+ }, void 0);
959
+ return toReturn;
960
+ }
961
+ function dropRepeatsBy(fn, list) {
962
+ if (arguments.length === 1) return (_list) => dropRepeatsBy(fn, _list);
963
+ let lastEvaluated = null;
964
+ return list.slice().filter((item) => {
965
+ if (lastEvaluated === null) {
966
+ lastEvaluated = fn(item);
967
+ return true;
968
+ }
969
+ const evaluatedResult = fn(item);
970
+ if (equals(lastEvaluated, evaluatedResult)) return false;
971
+ lastEvaluated = evaluatedResult;
972
+ return true;
973
+ });
974
+ }
975
+ function dropRepeatsWith(predicate, list) {
976
+ if (arguments.length === 1) {
977
+ return (_iterable) => dropRepeatsWith(predicate, _iterable);
978
+ }
979
+ if (!isArray(list)) {
980
+ throw new Error(`${list} is not a list`);
981
+ }
982
+ const toReturn = [];
983
+ list.reduce((prev, current) => {
984
+ if (prev === void 0) {
985
+ toReturn.push(current);
986
+ return current;
987
+ }
988
+ if (!predicate(prev, current)) {
989
+ toReturn.push(current);
990
+ }
991
+ return current;
992
+ }, void 0);
993
+ return toReturn;
994
+ }
995
+ function dropWhile(predicate, iterable) {
996
+ if (arguments.length === 1) {
997
+ return (_iterable) => dropWhile(predicate, _iterable);
998
+ }
999
+ const isArray$1 = isArray(iterable);
1000
+ if (!isArray$1 && typeof iterable !== "string") {
1001
+ throw new Error("`iterable` is neither list nor a string");
1002
+ }
1003
+ const toReturn = [];
1004
+ let counter = 0;
1005
+ while (counter < iterable.length) {
1006
+ const item = iterable[counter++];
1007
+ if (!predicate(item)) {
1008
+ toReturn.push(item);
1009
+ break;
1010
+ }
1011
+ }
1012
+ while (counter < iterable.length) {
1013
+ toReturn.push(iterable[counter++]);
1014
+ }
1015
+ return isArray$1 ? toReturn : toReturn.join("");
1016
+ }
1017
+ function either(firstPredicate, secondPredicate) {
1018
+ if (arguments.length === 1) {
1019
+ return (_secondPredicate) => either(firstPredicate, _secondPredicate);
1020
+ }
1021
+ return (...input) => Boolean(firstPredicate(...input) || secondPredicate(...input));
1022
+ }
1023
+ function empty(list) {
1024
+ if (typeof list === "string") return "";
1025
+ if (Array.isArray(list)) {
1026
+ const {
1027
+ name
1028
+ } = list.constructor;
1029
+ if (name === "Uint8Array") return Uint8Array.from("");
1030
+ if (name === "Float32Array") return new Float32Array([]);
1031
+ return [];
1032
+ }
1033
+ if (type(list) === "Object") return {};
1034
+ }
1035
+ function endsWith(target, iterable) {
1036
+ if (arguments.length === 1) return (_iterable) => endsWith(target, _iterable);
1037
+ if (typeof iterable === "string") {
1038
+ return iterable.endsWith(target);
1039
+ }
1040
+ if (!isArray(target)) return false;
1041
+ const diff = iterable.length - target.length;
1042
+ let correct = true;
1043
+ const filtered = target.filter((x, index) => {
1044
+ if (!correct) return false;
1045
+ const result = equals(x, iterable[index + diff]);
1046
+ if (!result) correct = false;
1047
+ return result;
1048
+ });
1049
+ return filtered.length === target.length;
1050
+ }
1051
+ function eqByFn(fn, a, b) {
1052
+ return equals(fn(a), fn(b));
1053
+ }
1054
+ var eqBy = curry2(eqByFn);
1055
+ function prop(propToFind, obj) {
1056
+ if (arguments.length === 1) return (_obj) => prop(propToFind, _obj);
1057
+ if (!obj) return void 0;
1058
+ return obj[propToFind];
1059
+ }
1060
+ function eqPropsFn(property, objA, objB) {
1061
+ return equals(prop(property, objA), prop(property, objB));
1062
+ }
1063
+ var eqProps = curry2(eqPropsFn);
1064
+ function evolveArray(rules, list) {
1065
+ return mapArray((x, i) => {
1066
+ if (type(rules[i]) === "Function") {
1067
+ return rules[i](x);
1068
+ }
1069
+ return x;
1070
+ }, list, true);
1071
+ }
1072
+ function evolveObject(rules, iterable) {
1073
+ return mapObject((x, prop2) => {
1074
+ if (type(x) === "Object") {
1075
+ const typeRule = type(rules[prop2]);
1076
+ if (typeRule === "Function") {
1077
+ return rules[prop2](x);
1078
+ }
1079
+ if (typeRule === "Object") {
1080
+ return evolve(rules[prop2], x);
1081
+ }
1082
+ return x;
1083
+ }
1084
+ if (type(rules[prop2]) === "Function") {
1085
+ return rules[prop2](x);
1086
+ }
1087
+ return x;
1088
+ }, iterable);
1089
+ }
1090
+ function evolve(rules, iterable) {
1091
+ if (arguments.length === 1) {
1092
+ return (_iterable) => evolve(rules, _iterable);
1093
+ }
1094
+ const rulesType = type(rules);
1095
+ const iterableType = type(iterable);
1096
+ if (iterableType !== rulesType) {
1097
+ throw new Error("iterableType !== rulesType");
1098
+ }
1099
+ if (!["Object", "Array"].includes(rulesType)) {
1100
+ throw new Error(`'iterable' and 'rules' are from wrong type ${rulesType}`);
1101
+ }
1102
+ if (iterableType === "Object") {
1103
+ return evolveObject(rules, iterable);
1104
+ }
1105
+ return evolveArray(rules, iterable);
1106
+ }
1107
+ function filterObject(predicate, obj) {
1108
+ const willReturn = {};
1109
+ for (const prop2 in obj) {
1110
+ if (predicate(obj[prop2], prop2, obj)) {
1111
+ willReturn[prop2] = obj[prop2];
1112
+ }
1113
+ }
1114
+ return willReturn;
1115
+ }
1116
+ function filterArray(predicate, list, indexed = false) {
1117
+ let index = 0;
1118
+ const len = list.length;
1119
+ const willReturn = [];
1120
+ while (index < len) {
1121
+ const predicateResult = indexed ? predicate(list[index], index) : predicate(list[index]);
1122
+ if (predicateResult) {
1123
+ willReturn.push(list[index]);
1124
+ }
1125
+ index++;
1126
+ }
1127
+ return willReturn;
1128
+ }
1129
+ function filter(predicate, iterable) {
1130
+ if (arguments.length === 1) return (_iterable) => filter(predicate, _iterable);
1131
+ if (!iterable) {
1132
+ throw new Error("Incorrect iterable input");
1133
+ }
1134
+ if (isArray(iterable)) return filterArray(predicate, iterable, false);
1135
+ return filterObject(predicate, iterable);
1136
+ }
1137
+ function find(predicate, list) {
1138
+ if (arguments.length === 1) return (_list) => find(predicate, _list);
1139
+ let index = 0;
1140
+ const len = list.length;
1141
+ while (index < len) {
1142
+ const x = list[index];
1143
+ if (predicate(x)) {
1144
+ return x;
1145
+ }
1146
+ index++;
1147
+ }
1148
+ }
1149
+ function findIndex(predicate, list) {
1150
+ if (arguments.length === 1) return (_list) => findIndex(predicate, _list);
1151
+ const len = list.length;
1152
+ let index = -1;
1153
+ while (++index < len) {
1154
+ if (predicate(list[index])) {
1155
+ return index;
1156
+ }
1157
+ }
1158
+ return -1;
1159
+ }
1160
+ function findLast(predicate, list) {
1161
+ if (arguments.length === 1) return (_list) => findLast(predicate, _list);
1162
+ let index = list.length;
1163
+ while (--index >= 0) {
1164
+ if (predicate(list[index])) {
1165
+ return list[index];
1166
+ }
1167
+ }
1168
+ return void 0;
1169
+ }
1170
+ function findLastIndex(fn, list) {
1171
+ if (arguments.length === 1) return (_list) => findLastIndex(fn, _list);
1172
+ let index = list.length;
1173
+ while (--index >= 0) {
1174
+ if (fn(list[index])) {
1175
+ return index;
1176
+ }
1177
+ }
1178
+ return -1;
1179
+ }
1180
+ function flatten(list, input) {
1181
+ const willReturn = input === void 0 ? [] : input;
1182
+ for (let i = 0; i < list.length; i++) {
1183
+ if (isArray(list[i])) {
1184
+ flatten(list[i], willReturn);
1185
+ } else {
1186
+ willReturn.push(list[i]);
1187
+ }
1188
+ }
1189
+ return willReturn;
1190
+ }
1191
+ function flipFn(fn) {
1192
+ return (...input) => {
1193
+ if (input.length === 1) {
1194
+ return (holder) => fn(holder, input[0]);
1195
+ } else if (input.length === 2) {
1196
+ return fn(input[1], input[0]);
1197
+ } else if (input.length === 3) {
1198
+ return fn(input[1], input[0], input[2]);
1199
+ } else if (input.length === 4) {
1200
+ return fn(input[1], input[0], input[2], input[3]);
1201
+ }
1202
+ throw new Error("R.flip doesn't work with arity > 4");
1203
+ };
1204
+ }
1205
+ function flip(fn) {
1206
+ return flipFn(fn);
1207
+ }
1208
+ function forEachObjIndexedFn(fn, obj) {
1209
+ let index = 0;
1210
+ const listKeys = keys$1(obj);
1211
+ const len = listKeys.length;
1212
+ while (index < len) {
1213
+ const key = listKeys[index];
1214
+ fn(obj[key], key, obj);
1215
+ index++;
1216
+ }
1217
+ return obj;
1218
+ }
1219
+ function forEachObjIndexed(fn, list) {
1220
+ if (arguments.length === 1) return (_list) => forEachObjIndexed(fn, _list);
1221
+ if (list === void 0) return;
1222
+ return forEachObjIndexedFn(fn, list);
1223
+ }
1224
+ function forEach(fn, iterable) {
1225
+ if (arguments.length === 1) return (_list) => forEach(fn, _list);
1226
+ if (iterable === void 0) return;
1227
+ if (isArray(iterable)) {
1228
+ let index = 0;
1229
+ const len = iterable.length;
1230
+ while (index < len) {
1231
+ fn(iterable[index]);
1232
+ index++;
1233
+ }
1234
+ } else return forEachObjIndexedFn(fn, iterable);
1235
+ return iterable;
1236
+ }
1237
+ function fromPairs(listOfPairs) {
1238
+ const toReturn = {};
1239
+ listOfPairs.forEach(([prop2, value]) => toReturn[prop2] = value);
1240
+ return toReturn;
1241
+ }
1242
+ function groupBy(groupFn, list) {
1243
+ if (arguments.length === 1) return (_list) => groupBy(groupFn, _list);
1244
+ const result = {};
1245
+ for (let i = 0; i < list.length; i++) {
1246
+ const item = list[i];
1247
+ const key = groupFn(item);
1248
+ if (!result[key]) {
1249
+ result[key] = [];
1250
+ }
1251
+ result[key].push(item);
1252
+ }
1253
+ return result;
1254
+ }
1255
+ function groupWith(compareFn, list) {
1256
+ if (!isArray(list)) throw new TypeError("list.reduce is not a function");
1257
+ const clone2 = cloneList(list);
1258
+ if (list.length === 1) return [clone2];
1259
+ const toReturn = [];
1260
+ let holder = [];
1261
+ clone2.reduce((prev, current, i) => {
1262
+ if (i === 0) return current;
1263
+ const okCompare = compareFn(prev, current);
1264
+ const holderIsEmpty = holder.length === 0;
1265
+ const lastCall = i === list.length - 1;
1266
+ if (okCompare) {
1267
+ if (holderIsEmpty) holder.push(prev);
1268
+ holder.push(current);
1269
+ if (lastCall) toReturn.push(holder);
1270
+ return current;
1271
+ }
1272
+ if (holderIsEmpty) {
1273
+ toReturn.push([prev]);
1274
+ if (lastCall) toReturn.push([current]);
1275
+ return current;
1276
+ }
1277
+ toReturn.push(holder);
1278
+ if (lastCall) toReturn.push([current]);
1279
+ holder = [];
1280
+ return current;
1281
+ }, void 0);
1282
+ return toReturn;
1283
+ }
1284
+ function has(prop2, obj) {
1285
+ if (arguments.length === 1) return (_obj) => has(prop2, _obj);
1286
+ if (!obj) return false;
1287
+ return obj.hasOwnProperty(prop2);
1288
+ }
1289
+ function hasPath(pathInput, obj) {
1290
+ if (arguments.length === 1) {
1291
+ return (objHolder) => hasPath(pathInput, objHolder);
1292
+ }
1293
+ return path(pathInput, obj) !== void 0;
1294
+ }
1295
+ function _objectIs(a, b) {
1296
+ if (a === b) {
1297
+ return a !== 0 || 1 / a === 1 / b;
1298
+ }
1299
+ return a !== a && b !== b;
1300
+ }
1301
+ var objectIs = Object.is || _objectIs;
1302
+ function identical(a, b) {
1303
+ if (arguments.length === 1) return (_b) => identical(a, _b);
1304
+ return objectIs(a, b);
1305
+ }
1306
+ function ifElseFn(condition, onTrue, onFalse) {
1307
+ return (...input) => {
1308
+ const conditionResult = typeof condition === "boolean" ? condition : condition(...input);
1309
+ if (conditionResult === true) {
1310
+ return onTrue(...input);
1311
+ }
1312
+ return onFalse(...input);
1313
+ };
1314
+ }
1315
+ var ifElse = curry2(ifElseFn);
1316
+ var inc = (x) => x + 1;
1317
+ function indexByPath(pathInput, list) {
1318
+ const toReturn = {};
1319
+ for (let i = 0; i < list.length; i++) {
1320
+ const item = list[i];
1321
+ toReturn[path(pathInput, item)] = item;
1322
+ }
1323
+ return toReturn;
1324
+ }
1325
+ function indexBy(condition, list) {
1326
+ if (arguments.length === 1) {
1327
+ return (_list) => indexBy(condition, _list);
1328
+ }
1329
+ if (typeof condition === "string") {
1330
+ return indexByPath(condition, list);
1331
+ }
1332
+ const toReturn = {};
1333
+ for (let i = 0; i < list.length; i++) {
1334
+ const item = list[i];
1335
+ toReturn[condition(item)] = item;
1336
+ }
1337
+ return toReturn;
1338
+ }
1339
+ function indexOf(valueToFind, list) {
1340
+ if (arguments.length === 1) {
1341
+ return (_list) => _indexOf(valueToFind, _list);
1342
+ }
1343
+ return _indexOf(valueToFind, list);
1344
+ }
1345
+ function baseSlice(array, start, end) {
1346
+ let index = -1;
1347
+ let {
1348
+ length: length2
1349
+ } = array;
1350
+ end = end > length2 ? length2 : end;
1351
+ if (end < 0) {
1352
+ end += length2;
1353
+ }
1354
+ length2 = start > end ? 0 : end - start >>> 0;
1355
+ start >>>= 0;
1356
+ const result = Array(length2);
1357
+ while (++index < length2) {
1358
+ result[index] = array[index + start];
1359
+ }
1360
+ return result;
1361
+ }
1362
+ function init(listOrString) {
1363
+ if (typeof listOrString === "string") return listOrString.slice(0, -1);
1364
+ return listOrString.length ? baseSlice(listOrString, 0, -1) : [];
1365
+ }
1366
+ function intersection(listA, listB) {
1367
+ if (arguments.length === 1) return (_list) => intersection(listA, _list);
1368
+ return filter((x) => includes$1(x, listA), listB);
1369
+ }
1370
+ function intersperse(separator, list) {
1371
+ if (arguments.length === 1) return (_list) => intersperse(separator, _list);
1372
+ let index = -1;
1373
+ const len = list.length;
1374
+ const willReturn = [];
1375
+ while (++index < len) {
1376
+ if (index === len - 1) {
1377
+ willReturn.push(list[index]);
1378
+ } else {
1379
+ willReturn.push(list[index], separator);
1380
+ }
1381
+ }
1382
+ return willReturn;
1383
+ }
1384
+ function is(targetPrototype, x) {
1385
+ if (arguments.length === 1) return (_x) => is(targetPrototype, _x);
1386
+ return x != null && x.constructor === targetPrototype || x instanceof targetPrototype;
1387
+ }
1388
+ function isEmpty(input) {
1389
+ const inputType = type(input);
1390
+ if (["Undefined", "NaN", "Number", "Null"].includes(inputType)) return false;
1391
+ if (!input) return true;
1392
+ if (inputType === "Object") {
1393
+ return Object.keys(input).length === 0;
1394
+ }
1395
+ if (inputType === "Array") {
1396
+ return input.length === 0;
1397
+ }
1398
+ return false;
1399
+ }
1400
+ function isNil(x) {
1401
+ return x === void 0 || x === null;
1402
+ }
1403
+ function join(glue, list) {
1404
+ if (arguments.length === 1) return (_list) => join(glue, _list);
1405
+ return list.join(glue);
1406
+ }
1407
+ function juxt(listOfFunctions) {
1408
+ return (...args) => listOfFunctions.map((fn) => fn(...args));
1409
+ }
1410
+ function keys(x) {
1411
+ return Object.keys(x);
1412
+ }
1413
+ function last(listOrString) {
1414
+ if (typeof listOrString === "string") {
1415
+ return listOrString[listOrString.length - 1] || "";
1416
+ }
1417
+ return listOrString[listOrString.length - 1];
1418
+ }
1419
+ function lastIndexOf(valueToFind, list) {
1420
+ if (arguments.length === 1) {
1421
+ return (_list) => _lastIndexOf(valueToFind, _list);
1422
+ }
1423
+ return _lastIndexOf(valueToFind, list);
1424
+ }
1425
+ function length(x) {
1426
+ if (isArray(x)) return x.length;
1427
+ if (typeof x === "string") return x.length;
1428
+ return NaN;
1429
+ }
1430
+ function lens(getter, setter) {
1431
+ return function(functor) {
1432
+ return function(target) {
1433
+ return functor(getter(target)).map((focus) => setter(focus, target));
1434
+ };
1435
+ };
1436
+ }
1437
+ function nth(index, input) {
1438
+ if (arguments.length === 1) return (_input) => nth(index, _input);
1439
+ const idx = index < 0 ? input.length + index : index;
1440
+ return Object.prototype.toString.call(input) === "[object String]" ? input.charAt(idx) : input[idx];
1441
+ }
1442
+ function lensIndex(index) {
1443
+ return lens(nth(index), update(index));
1444
+ }
1445
+ function lensPath(key) {
1446
+ return lens(path(key), assocPath(key));
1447
+ }
1448
+ function lensProp(key) {
1449
+ return lens(prop(key), assoc(key));
1450
+ }
1451
+ function match(pattern, input) {
1452
+ if (arguments.length === 1) return (_input) => match(pattern, _input);
1453
+ const willReturn = input.match(pattern);
1454
+ return willReturn === null ? [] : willReturn;
1455
+ }
1456
+ function mathMod(x, y) {
1457
+ if (arguments.length === 1) return (_y) => mathMod(x, _y);
1458
+ if (!isInteger(x) || !isInteger(y) || y < 1) return NaN;
1459
+ return (x % y + y) % y;
1460
+ }
1461
+ function maxByFn(compareFn, x, y) {
1462
+ return compareFn(y) > compareFn(x) ? y : x;
1463
+ }
1464
+ var maxBy = curry2(maxByFn);
1465
+ function sum(list) {
1466
+ return list.reduce((prev, current) => prev + current, 0);
1467
+ }
1468
+ function mean(list) {
1469
+ return sum(list) / list.length;
1470
+ }
1471
+ function median(list) {
1472
+ const len = list.length;
1473
+ if (len === 0) return NaN;
1474
+ const width = 2 - len % 2;
1475
+ const idx = (len - width) / 2;
1476
+ return mean(Array.prototype.slice.call(list, 0).sort((a, b) => {
1477
+ if (a === b) return 0;
1478
+ return a < b ? -1 : 1;
1479
+ }).slice(idx, idx + width));
1480
+ }
1481
+ function mergeRight(target, newProps) {
1482
+ if (arguments.length === 1) return (_newProps) => mergeRight(target, _newProps);
1483
+ return Object.assign({}, target || {}, newProps || {});
1484
+ }
1485
+ function mergeAll(arr) {
1486
+ let willReturn = {};
1487
+ map((val) => {
1488
+ willReturn = mergeRight(willReturn, val);
1489
+ }, arr);
1490
+ return willReturn;
1491
+ }
1492
+ function mergeDeepRight(target, source) {
1493
+ if (arguments.length === 1) {
1494
+ return (sourceHolder) => mergeDeepRight(target, sourceHolder);
1495
+ }
1496
+ const willReturn = clone(target);
1497
+ Object.keys(source).forEach((key) => {
1498
+ if (type(source[key]) === "Object") {
1499
+ if (type(target[key]) === "Object") {
1500
+ willReturn[key] = mergeDeepRight(target[key], source[key]);
1501
+ } else {
1502
+ willReturn[key] = source[key];
1503
+ }
1504
+ } else {
1505
+ willReturn[key] = source[key];
1506
+ }
1507
+ });
1508
+ return willReturn;
1509
+ }
1510
+ function mergeLeft(x, y) {
1511
+ if (arguments.length === 1) return (_y) => mergeLeft(x, _y);
1512
+ return mergeRight(y, x);
1513
+ }
1514
+ function mergeWithFn(mergeFn, aInput, bInput) {
1515
+ const a = aInput !== null && aInput !== void 0 ? aInput : {};
1516
+ const b = bInput !== null && bInput !== void 0 ? bInput : {};
1517
+ const willReturn = {};
1518
+ Object.keys(a).forEach((key) => {
1519
+ if (b[key] === void 0) willReturn[key] = a[key];
1520
+ else willReturn[key] = mergeFn(a[key], b[key]);
1521
+ });
1522
+ Object.keys(b).forEach((key) => {
1523
+ if (willReturn[key] !== void 0) return;
1524
+ if (a[key] === void 0) willReturn[key] = b[key];
1525
+ else willReturn[key] = mergeFn(a[key], b[key]);
1526
+ });
1527
+ return willReturn;
1528
+ }
1529
+ var mergeWith = curry2(mergeWithFn);
1530
+ function min(x, y) {
1531
+ if (arguments.length === 1) return (_y) => min(x, _y);
1532
+ return y < x ? y : x;
1533
+ }
1534
+ function minByFn(compareFn, x, y) {
1535
+ return compareFn(y) < compareFn(x) ? y : x;
1536
+ }
1537
+ var minBy = curry2(minByFn);
1538
+ function isIterable(input) {
1539
+ return Array.isArray(input) || type(input) === "Object";
1540
+ }
1541
+ function modifyFn(property, fn, iterable) {
1542
+ if (!isIterable(iterable)) return iterable;
1543
+ if (iterable[property] === void 0) return iterable;
1544
+ if (isArray(iterable)) {
1545
+ return updateFn(property, fn(iterable[property]), iterable);
1546
+ }
1547
+ return _objectSpread2(_objectSpread2({}, iterable), {}, {
1548
+ [property]: fn(iterable[property])
1549
+ });
1550
+ }
1551
+ var modify = curry2(modifyFn);
1552
+ function modifyPathFn(pathInput, fn, object) {
1553
+ const path$1 = createPath(pathInput);
1554
+ if (path$1.length === 1) {
1555
+ return _objectSpread2(_objectSpread2({}, object), {}, {
1556
+ [path$1[0]]: fn(object[path$1[0]])
1557
+ });
1558
+ }
1559
+ if (path(path$1, object) === void 0) return object;
1560
+ const val = modifyPath(Array.prototype.slice.call(path$1, 1), fn, object[path$1[0]]);
1561
+ if (val === object[path$1[0]]) {
1562
+ return object;
1563
+ }
1564
+ return assoc(path$1[0], val, object);
1565
+ }
1566
+ var modifyPath = curry2(modifyPathFn);
1567
+ function modulo(x, y) {
1568
+ if (arguments.length === 1) return (_y) => modulo(x, _y);
1569
+ return x % y;
1570
+ }
1571
+ function moveFn(fromIndex, toIndex, list) {
1572
+ if (fromIndex < 0 || toIndex < 0) {
1573
+ throw new Error("Rambda.move does not support negative indexes");
1574
+ }
1575
+ if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list;
1576
+ const clone2 = cloneList(list);
1577
+ clone2[fromIndex] = list[toIndex];
1578
+ clone2[toIndex] = list[fromIndex];
1579
+ return clone2;
1580
+ }
1581
+ var move = curry2(moveFn);
1582
+ function multiply(x, y) {
1583
+ if (arguments.length === 1) return (_y) => multiply(x, _y);
1584
+ return x * y;
1585
+ }
1586
+ function negate(x) {
1587
+ return -x;
1588
+ }
1589
+ function none(predicate, list) {
1590
+ if (arguments.length === 1) return (_list) => none(predicate, _list);
1591
+ for (let i = 0; i < list.length; i++) {
1592
+ if (predicate(list[i])) return false;
1593
+ }
1594
+ return true;
1595
+ }
1596
+ function not(input) {
1597
+ return !input;
1598
+ }
1599
+ function objOf(key, value) {
1600
+ if (arguments.length === 1) {
1601
+ return (_value) => objOf(key, _value);
1602
+ }
1603
+ return {
1604
+ [key]: value
1605
+ };
1606
+ }
1607
+ function of(value) {
1608
+ return [value];
1609
+ }
1610
+ function on(binaryFn, unaryFn, a, b) {
1611
+ if (arguments.length === 3) {
1612
+ return (_b) => on(binaryFn, unaryFn, a, _b);
1613
+ }
1614
+ if (arguments.length === 2) {
1615
+ return (_a, _b) => on(binaryFn, unaryFn, _a, _b);
1616
+ }
1617
+ return binaryFn(unaryFn(a), unaryFn(b));
1618
+ }
1619
+ function onceFn(fn, context) {
1620
+ let result;
1621
+ return function() {
1622
+ if (fn) {
1623
+ result = fn.apply(context || this, arguments);
1624
+ fn = null;
1625
+ }
1626
+ return result;
1627
+ };
1628
+ }
1629
+ function once(fn, context) {
1630
+ if (arguments.length === 1) {
1631
+ const wrap = onceFn(fn, context);
1632
+ return curry2(wrap);
1633
+ }
1634
+ return onceFn(fn, context);
1635
+ }
1636
+ function or(a, b) {
1637
+ if (arguments.length === 1) return (_b) => or(a, _b);
1638
+ return a || b;
1639
+ }
1640
+ var Identity = (x) => ({
1641
+ x,
1642
+ map: (fn) => Identity(fn(x))
1643
+ });
1644
+ function overFn(lens2, fn, object) {
1645
+ return lens2((x) => Identity(fn(x)))(object).x;
1646
+ }
1647
+ var over = curry2(overFn);
1648
+ function partial(fn, ...args) {
1649
+ const len = fn.length;
1650
+ const argList = args.length === 1 && isArray(args[0]) ? args[0] : args;
1651
+ return (...rest) => {
1652
+ if (argList.length + rest.length >= len) {
1653
+ return fn(...argList, ...rest);
1654
+ }
1655
+ return partial(fn, ...[...argList, ...rest]);
1656
+ };
1657
+ }
1658
+ function partialObject(fn, input) {
1659
+ return (nextInput) => fn(mergeDeepRight(nextInput, input));
1660
+ }
1661
+ function partitionObject(predicate, iterable) {
1662
+ const yes = {};
1663
+ const no = {};
1664
+ Object.entries(iterable).forEach(([prop2, value]) => {
1665
+ if (predicate(value, prop2)) {
1666
+ yes[prop2] = value;
1667
+ } else {
1668
+ no[prop2] = value;
1669
+ }
1670
+ });
1671
+ return [yes, no];
1672
+ }
1673
+ function partitionArray(predicate, list, indexed = false) {
1674
+ const yes = [];
1675
+ const no = [];
1676
+ let counter = -1;
1677
+ while (counter++ < list.length - 1) {
1678
+ if (indexed ? predicate(list[counter], counter) : predicate(list[counter])) {
1679
+ yes.push(list[counter]);
1680
+ } else {
1681
+ no.push(list[counter]);
1682
+ }
1683
+ }
1684
+ return [yes, no];
1685
+ }
1686
+ function partition(predicate, iterable) {
1687
+ if (arguments.length === 1) {
1688
+ return (listHolder) => partition(predicate, listHolder);
1689
+ }
1690
+ if (!isArray(iterable)) return partitionObject(predicate, iterable);
1691
+ return partitionArray(predicate, iterable);
1692
+ }
1693
+ function pathEqFn(pathToSearch, target, input) {
1694
+ return equals(path(pathToSearch, input), target);
1695
+ }
1696
+ var pathEq = curry2(pathEqFn);
1697
+ function pathOrFn(defaultValue, pathInput, obj) {
1698
+ return defaultTo(defaultValue, path(pathInput, obj));
1699
+ }
1700
+ var pathOr = curry2(pathOrFn);
1701
+ function paths(pathsToSearch, obj) {
1702
+ if (arguments.length === 1) {
1703
+ return (_obj) => paths(pathsToSearch, _obj);
1704
+ }
1705
+ return pathsToSearch.map((singlePath) => path(singlePath, obj));
1706
+ }
1707
+ function pick(propsToPick, input) {
1708
+ if (arguments.length === 1) return (_input) => pick(propsToPick, _input);
1709
+ if (input === null || input === void 0) {
1710
+ return void 0;
1711
+ }
1712
+ const keys2 = createPath(propsToPick, ",");
1713
+ const willReturn = {};
1714
+ let counter = 0;
1715
+ while (counter < keys2.length) {
1716
+ if (keys2[counter] in input) {
1717
+ willReturn[keys2[counter]] = input[keys2[counter]];
1718
+ }
1719
+ counter++;
1720
+ }
1721
+ return willReturn;
1722
+ }
1723
+ function pickAll(propsToPick, obj) {
1724
+ if (arguments.length === 1) return (_obj) => pickAll(propsToPick, _obj);
1725
+ if (obj === null || obj === void 0) {
1726
+ return void 0;
1727
+ }
1728
+ const keysValue = createPath(propsToPick, ",");
1729
+ const willReturn = {};
1730
+ let counter = 0;
1731
+ while (counter < keysValue.length) {
1732
+ if (keysValue[counter] in obj) {
1733
+ willReturn[keysValue[counter]] = obj[keysValue[counter]];
1734
+ } else {
1735
+ willReturn[keysValue[counter]] = void 0;
1736
+ }
1737
+ counter++;
1738
+ }
1739
+ return willReturn;
1740
+ }
1741
+ function pluck(property, list) {
1742
+ if (arguments.length === 1) return (_list) => pluck(property, _list);
1743
+ const willReturn = [];
1744
+ map((x) => {
1745
+ if (x[property] !== void 0) {
1746
+ willReturn.push(x[property]);
1747
+ }
1748
+ }, list);
1749
+ return willReturn;
1750
+ }
1751
+ function prepend(x, input) {
1752
+ if (arguments.length === 1) return (_input) => prepend(x, _input);
1753
+ if (typeof input === "string") return [x].concat(input.split(""));
1754
+ return [x].concat(input);
1755
+ }
1756
+ var product = reduce(multiply, 1);
1757
+ function propEqFn(valueToMatch, propToFind, obj) {
1758
+ if (!obj) return false;
1759
+ return equals(valueToMatch, prop(propToFind, obj));
1760
+ }
1761
+ var propEq = curry2(propEqFn);
1762
+ function propIsFn(targetPrototype, property, obj) {
1763
+ return is(targetPrototype, obj[property]);
1764
+ }
1765
+ var propIs = curry2(propIsFn);
1766
+ function propOrFn(defaultValue, property, obj) {
1767
+ if (!obj) return defaultValue;
1768
+ return defaultTo(defaultValue, obj[property]);
1769
+ }
1770
+ var propOr = curry2(propOrFn);
1771
+ function propSatisfiesFn(predicate, property, obj) {
1772
+ return predicate(prop(property, obj));
1773
+ }
1774
+ var propSatisfies = curry2(propSatisfiesFn);
1775
+ function props(propsToPick, obj) {
1776
+ if (arguments.length === 1) {
1777
+ return (_obj) => props(propsToPick, _obj);
1778
+ }
1779
+ if (!isArray(propsToPick)) {
1780
+ throw new Error("propsToPick is not a list");
1781
+ }
1782
+ return mapArray((prop2) => obj[prop2], propsToPick);
1783
+ }
1784
+ function range(start, end) {
1785
+ if (arguments.length === 1) return (_end) => range(start, _end);
1786
+ if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
1787
+ throw new TypeError("Both arguments to range must be numbers");
1788
+ }
1789
+ if (end < start) return [];
1790
+ const len = end - start;
1791
+ const willReturn = Array(len);
1792
+ for (let i = 0; i < len; i++) {
1793
+ willReturn[i] = start + i;
1794
+ }
1795
+ return willReturn;
1796
+ }
1797
+ function reject(predicate, list) {
1798
+ if (arguments.length === 1) return (_list) => reject(predicate, _list);
1799
+ return filter((x) => !predicate(x), list);
1800
+ }
1801
+ function repeat(x, timesToRepeat) {
1802
+ if (arguments.length === 1) {
1803
+ return (_timesToRepeat) => repeat(x, _timesToRepeat);
1804
+ }
1805
+ return Array(timesToRepeat).fill(x);
1806
+ }
1807
+ function replaceFn(pattern, replacer, str) {
1808
+ return str.replace(pattern, replacer);
1809
+ }
1810
+ var replace = curry2(replaceFn);
1811
+ function setFn(lens2, replacer, x) {
1812
+ return over(lens2, always(replacer), x);
1813
+ }
1814
+ var set = curry2(setFn);
1815
+ function sliceFn(from, to, list) {
1816
+ return list.slice(from, to);
1817
+ }
1818
+ var slice = curry2(sliceFn);
1819
+ function sort(sortFn, list) {
1820
+ if (arguments.length === 1) return (_list) => sort(sortFn, _list);
1821
+ return cloneList(list).sort(sortFn);
1822
+ }
1823
+ function sortBy(sortFn, list) {
1824
+ if (arguments.length === 1) return (_list) => sortBy(sortFn, _list);
1825
+ const clone2 = cloneList(list);
1826
+ return clone2.sort((a, b) => {
1827
+ const aSortResult = sortFn(a);
1828
+ const bSortResult = sortFn(b);
1829
+ if (aSortResult === bSortResult) return 0;
1830
+ return aSortResult < bSortResult ? -1 : 1;
1831
+ });
1832
+ }
1833
+ function split(separator, str) {
1834
+ if (arguments.length === 1) return (_str) => split(separator, _str);
1835
+ return str.split(separator);
1836
+ }
1837
+ function maybe(ifRule, whenIf, whenElse) {
1838
+ const whenIfInput = ifRule && type(whenIf) === "Function" ? whenIf() : whenIf;
1839
+ const whenElseInput = !ifRule && type(whenElse) === "Function" ? whenElse() : whenElse;
1840
+ return ifRule ? whenIfInput : whenElseInput;
1841
+ }
1842
+ function take(howMany, listOrString) {
1843
+ if (arguments.length === 1) return (_listOrString) => take(howMany, _listOrString);
1844
+ if (howMany < 0) return listOrString.slice();
1845
+ if (typeof listOrString === "string") return listOrString.slice(0, howMany);
1846
+ return baseSlice(listOrString, 0, howMany);
1847
+ }
1848
+ function splitAt(index, input) {
1849
+ if (arguments.length === 1) {
1850
+ return (_list) => splitAt(index, _list);
1851
+ }
1852
+ if (!input) throw new TypeError(`Cannot read property 'slice' of ${input}`);
1853
+ if (!isArray(input) && typeof input !== "string") return [[], []];
1854
+ const correctIndex = maybe(index < 0, input.length + index < 0 ? 0 : input.length + index, index);
1855
+ return [take(correctIndex, input), drop(correctIndex, input)];
1856
+ }
1857
+ function splitEvery(sliceLength, listOrString) {
1858
+ if (arguments.length === 1) {
1859
+ return (_listOrString) => splitEvery(sliceLength, _listOrString);
1860
+ }
1861
+ if (sliceLength < 1) {
1862
+ throw new Error("First argument to splitEvery must be a positive integer");
1863
+ }
1864
+ const willReturn = [];
1865
+ let counter = 0;
1866
+ while (counter < listOrString.length) {
1867
+ willReturn.push(listOrString.slice(counter, counter += sliceLength));
1868
+ }
1869
+ return willReturn;
1870
+ }
1871
+ function splitWhen(predicate, input) {
1872
+ if (arguments.length === 1) {
1873
+ return (_input) => splitWhen(predicate, _input);
1874
+ }
1875
+ if (!input) throw new TypeError(`Cannot read property 'length' of ${input}`);
1876
+ const preFound = [];
1877
+ const postFound = [];
1878
+ let found = false;
1879
+ let counter = -1;
1880
+ while (counter++ < input.length - 1) {
1881
+ if (found) {
1882
+ postFound.push(input[counter]);
1883
+ } else if (predicate(input[counter])) {
1884
+ postFound.push(input[counter]);
1885
+ found = true;
1886
+ } else {
1887
+ preFound.push(input[counter]);
1888
+ }
1889
+ }
1890
+ return [preFound, postFound];
1891
+ }
1892
+ function startsWith(question, iterable) {
1893
+ if (arguments.length === 1) return (_iterable) => startsWith(question, _iterable);
1894
+ if (typeof iterable === "string") {
1895
+ return iterable.startsWith(question);
1896
+ }
1897
+ if (!isArray(question)) return false;
1898
+ let correct = true;
1899
+ const filtered = question.filter((x, index) => {
1900
+ if (!correct) return false;
1901
+ const result = equals(x, iterable[index]);
1902
+ if (!result) correct = false;
1903
+ return result;
1904
+ });
1905
+ return filtered.length === question.length;
1906
+ }
1907
+ function subtract(a, b) {
1908
+ if (arguments.length === 1) return (_b) => subtract(a, _b);
1909
+ return a - b;
1910
+ }
1911
+ function symmetricDifference(x, y) {
1912
+ if (arguments.length === 1) {
1913
+ return (_y) => symmetricDifference(x, _y);
1914
+ }
1915
+ return concat(filter((value) => !includes$1(value, y), x), filter((value) => !includes$1(value, x), y));
1916
+ }
1917
+ function takeLast(howMany, listOrString) {
1918
+ if (arguments.length === 1) return (_listOrString) => takeLast(howMany, _listOrString);
1919
+ const len = listOrString.length;
1920
+ if (howMany < 0) return listOrString.slice();
1921
+ let numValue = howMany > len ? len : howMany;
1922
+ if (typeof listOrString === "string") return listOrString.slice(len - numValue);
1923
+ numValue = len - numValue;
1924
+ return baseSlice(listOrString, numValue, len);
1925
+ }
1926
+ function takeLastWhile(predicate, input) {
1927
+ if (arguments.length === 1) {
1928
+ return (_input) => takeLastWhile(predicate, _input);
1929
+ }
1930
+ if (input.length === 0) return input;
1931
+ const toReturn = [];
1932
+ let counter = input.length;
1933
+ while (counter) {
1934
+ const item = input[--counter];
1935
+ if (!predicate(item)) {
1936
+ break;
1937
+ }
1938
+ toReturn.push(item);
1939
+ }
1940
+ return isArray(input) ? toReturn.reverse() : toReturn.reverse().join("");
1941
+ }
1942
+ function takeWhile(predicate, iterable) {
1943
+ if (arguments.length === 1) {
1944
+ return (_iterable) => takeWhile(predicate, _iterable);
1945
+ }
1946
+ const isArray$1 = isArray(iterable);
1947
+ if (!isArray$1 && typeof iterable !== "string") {
1948
+ throw new Error("`iterable` is neither list nor a string");
1949
+ }
1950
+ const toReturn = [];
1951
+ let counter = 0;
1952
+ while (counter < iterable.length) {
1953
+ const item = iterable[counter++];
1954
+ if (!predicate(item)) {
1955
+ break;
1956
+ }
1957
+ toReturn.push(item);
1958
+ }
1959
+ return isArray$1 ? toReturn : toReturn.join("");
1960
+ }
1961
+ function tap(fn, x) {
1962
+ if (arguments.length === 1) return (_x) => tap(fn, _x);
1963
+ fn(x);
1964
+ return x;
1965
+ }
1966
+ function test(pattern, str) {
1967
+ if (arguments.length === 1) return (_str) => test(pattern, _str);
1968
+ if (typeof pattern === "string") {
1969
+ throw new TypeError(`R.test requires a value of type RegExp as its first argument; received "${pattern}"`);
1970
+ }
1971
+ return str.search(pattern) !== -1;
1972
+ }
1973
+ function times(fn, howMany) {
1974
+ if (arguments.length === 1) return (_howMany) => times(fn, _howMany);
1975
+ if (!isInteger(howMany) || howMany < 0) {
1976
+ throw new RangeError("n must be an integer");
1977
+ }
1978
+ return map(fn, range(0, howMany));
1979
+ }
1980
+ function toLower(str) {
1981
+ return str.toLowerCase();
1982
+ }
1983
+ function toPairs(obj) {
1984
+ return Object.entries(obj);
1985
+ }
1986
+ function toString(x) {
1987
+ return x.toString();
1988
+ }
1989
+ function toUpper(str) {
1990
+ return str.toUpperCase();
1991
+ }
1992
+ function transpose(array) {
1993
+ return array.reduce((acc, el) => {
1994
+ el.forEach((nestedEl, i) => isArray(acc[i]) ? acc[i].push(nestedEl) : acc.push([nestedEl]));
1995
+ return acc;
1996
+ }, []);
1997
+ }
1998
+ function trim(str) {
1999
+ return str.trim();
2000
+ }
2001
+ var isFunction = (x) => ["Promise", "Function"].includes(type(x));
2002
+ function tryCatch(fn, fallback) {
2003
+ if (!isFunction(fn)) {
2004
+ throw new Error(`R.tryCatch | fn '${fn}'`);
2005
+ }
2006
+ const passFallback = isFunction(fallback);
2007
+ return (...inputs) => {
2008
+ try {
2009
+ return fn(...inputs);
2010
+ } catch (e) {
2011
+ return passFallback ? fallback(e, ...inputs) : fallback;
2012
+ }
2013
+ };
2014
+ }
2015
+ function unapply(fn) {
2016
+ return function(...args) {
2017
+ return fn.call(this, args);
2018
+ };
2019
+ }
2020
+ function union(x, y) {
2021
+ if (arguments.length === 1) return (_y) => union(x, _y);
2022
+ const toReturn = cloneList(x);
2023
+ y.forEach((yInstance) => {
2024
+ if (!includes$1(yInstance, x)) toReturn.push(yInstance);
2025
+ });
2026
+ return toReturn;
2027
+ }
2028
+ function uniqBy(fn, list) {
2029
+ if (arguments.length === 1) {
2030
+ return (_list) => uniqBy(fn, _list);
2031
+ }
2032
+ const set2 = new _Set();
2033
+ return list.filter((item) => set2.checkUniqueness(fn(item)));
2034
+ }
2035
+ function includesWith(predicate, target, list) {
2036
+ let willReturn = false;
2037
+ let index = -1;
2038
+ while (++index < list.length && !willReturn) {
2039
+ const value = list[index];
2040
+ if (predicate(target, value)) {
2041
+ willReturn = true;
2042
+ }
2043
+ }
2044
+ return willReturn;
2045
+ }
2046
+ function uniqWith(predicate, list) {
2047
+ if (arguments.length === 1) return (_list) => uniqWith(predicate, _list);
2048
+ let index = -1;
2049
+ const willReturn = [];
2050
+ while (++index < list.length) {
2051
+ const value = list[index];
2052
+ if (!includesWith(predicate, value, willReturn)) {
2053
+ willReturn.push(value);
2054
+ }
2055
+ }
2056
+ return willReturn;
2057
+ }
2058
+ function unless(predicate, whenFalse) {
2059
+ if (arguments.length === 1) {
2060
+ return (_whenFalse) => unless(predicate, _whenFalse);
2061
+ }
2062
+ return (input) => predicate(input) ? input : whenFalse(input);
2063
+ }
2064
+ function unnest(list) {
2065
+ return list.reduce((acc, item) => {
2066
+ if (Array.isArray(item)) {
2067
+ return [...acc, ...item];
2068
+ }
2069
+ return [...acc, item];
2070
+ }, []);
2071
+ }
2072
+ function unwind(property, obj) {
2073
+ if (arguments.length === 1) {
2074
+ return (_obj) => unwind(property, _obj);
2075
+ }
2076
+ if (!isArray(obj[property])) return [obj];
2077
+ return mapArray((x) => _objectSpread2(_objectSpread2({}, obj), {}, {
2078
+ [property]: x
2079
+ }), obj[property]);
2080
+ }
2081
+ function values(obj) {
2082
+ if (type(obj) !== "Object") return [];
2083
+ return Object.values(obj);
2084
+ }
2085
+ var Const = (x) => ({
2086
+ x,
2087
+ map: (fn) => Const(x)
2088
+ });
2089
+ function view(lens2, target) {
2090
+ if (arguments.length === 1) return (_target) => view(lens2, _target);
2091
+ return lens2(Const)(target).x;
2092
+ }
2093
+ function whenFn(predicate, whenTrueFn, input) {
2094
+ if (!predicate(input)) return input;
2095
+ return whenTrueFn(input);
2096
+ }
2097
+ var when = curry2(whenFn);
2098
+ function where(conditions, input) {
2099
+ if (input === void 0) {
2100
+ return (_input) => where(conditions, _input);
2101
+ }
2102
+ let flag = true;
2103
+ for (const prop2 in conditions) {
2104
+ if (!flag) continue;
2105
+ const result = conditions[prop2](input[prop2]);
2106
+ if (flag && result === false) {
2107
+ flag = false;
2108
+ }
2109
+ }
2110
+ return flag;
2111
+ }
2112
+ function whereAny(conditions, input) {
2113
+ if (input === void 0) {
2114
+ return (_input) => whereAny(conditions, _input);
2115
+ }
2116
+ for (const prop2 in conditions) {
2117
+ if (conditions[prop2](input[prop2])) {
2118
+ return true;
2119
+ }
2120
+ }
2121
+ return false;
2122
+ }
2123
+ function whereEq(condition, input) {
2124
+ if (arguments.length === 1) {
2125
+ return (_input) => whereEq(condition, _input);
2126
+ }
2127
+ const result = filter((conditionValue, conditionProp) => equals(conditionValue, input[conditionProp]), condition);
2128
+ return Object.keys(result).length === Object.keys(condition).length;
2129
+ }
2130
+ function without(matchAgainst, source) {
2131
+ if (source === void 0) {
2132
+ return (_source) => without(matchAgainst, _source);
2133
+ }
2134
+ return reduce((prev, current) => _indexOf(current, matchAgainst) > -1 ? prev : prev.concat(current), [], source);
2135
+ }
2136
+ function xor(a, b) {
2137
+ if (arguments.length === 1) return (_b) => xor(a, _b);
2138
+ return Boolean(a) && !b || Boolean(b) && !a;
2139
+ }
2140
+ function zip(left, right) {
2141
+ if (arguments.length === 1) return (_right) => zip(left, _right);
2142
+ const result = [];
2143
+ const length2 = Math.min(left.length, right.length);
2144
+ for (let i = 0; i < length2; i++) {
2145
+ result[i] = [left[i], right[i]];
2146
+ }
2147
+ return result;
2148
+ }
2149
+ function zipObj(keys2, values2) {
2150
+ if (arguments.length === 1) return (yHolder) => zipObj(keys2, yHolder);
2151
+ return take(values2.length, keys2).reduce((prev, xInstance, i) => {
2152
+ prev[xInstance] = values2[i];
2153
+ return prev;
2154
+ }, {});
2155
+ }
2156
+ function zipWithFn(fn, x, y) {
2157
+ return take(x.length > y.length ? y.length : x.length, x).map((xInstance, i) => fn(xInstance, y[i]));
2158
+ }
2159
+ var zipWith = curry2(zipWithFn);
2160
+ exports.F = F;
2161
+ exports.T = T;
2162
+ exports.__findHighestArity = __findHighestArity;
2163
+ exports._indexOf = _indexOf;
2164
+ exports._lastIndexOf = _lastIndexOf;
2165
+ exports._pipe = _pipe;
2166
+ exports.add = add;
2167
+ exports.addIndex = addIndex;
2168
+ exports.addIndexRight = addIndexRight;
2169
+ exports.adjust = adjust;
2170
+ exports.all = all;
2171
+ exports.allPass = allPass;
2172
+ exports.always = always;
2173
+ exports.and = and;
2174
+ exports.any = any;
2175
+ exports.anyPass = anyPass;
2176
+ exports.ap = ap;
2177
+ exports.aperture = aperture;
2178
+ exports.append = append;
2179
+ exports.apply = apply;
2180
+ exports.applySpec = applySpec;
2181
+ exports.applyTo = applyTo;
2182
+ exports.ascend = ascend;
2183
+ exports.assoc = assoc;
2184
+ exports.assocFn = assocFn;
2185
+ exports.assocPath = assocPath;
2186
+ exports.assocPathFn = assocPathFn;
2187
+ exports.binary = binary;
2188
+ exports.bind = bind;
2189
+ exports.both = both;
2190
+ exports.call = call;
2191
+ exports.chain = chain;
2192
+ exports.clamp = clamp;
2193
+ exports.clone = clone;
2194
+ exports.collectBy = collectBy;
2195
+ exports.comparator = comparator;
2196
+ exports.complement = complement;
2197
+ exports.compose = compose;
2198
+ exports.composeWith = composeWith;
2199
+ exports.concat = concat;
2200
+ exports.cond = cond;
2201
+ exports.converge = converge;
2202
+ exports.count = count;
2203
+ exports.countBy = countBy;
2204
+ exports.createCompareFunction = createCompareFunction;
2205
+ exports.curry = curry2;
2206
+ exports.curryN = curryN;
2207
+ exports.dec = dec;
2208
+ exports.defaultTo = defaultTo;
2209
+ exports.descend = descend;
2210
+ exports.difference = difference;
2211
+ exports.differenceWith = differenceWith;
2212
+ exports.differenceWithFn = differenceWithFn;
2213
+ exports.dissoc = dissoc;
2214
+ exports.dissocPath = dissocPath;
2215
+ exports.divide = divide;
2216
+ exports.drop = drop;
2217
+ exports.dropLast = dropLast;
2218
+ exports.dropLastWhile = dropLastWhile;
2219
+ exports.dropRepeats = dropRepeats;
2220
+ exports.dropRepeatsBy = dropRepeatsBy;
2221
+ exports.dropRepeatsWith = dropRepeatsWith;
2222
+ exports.dropWhile = dropWhile;
2223
+ exports.either = either;
2224
+ exports.empty = empty;
2225
+ exports.endsWith = endsWith;
2226
+ exports.eqBy = eqBy;
2227
+ exports.eqByFn = eqByFn;
2228
+ exports.eqProps = eqProps;
2229
+ exports.equals = equals;
2230
+ exports.evolve = evolve;
2231
+ exports.evolveArray = evolveArray;
2232
+ exports.evolveObject = evolveObject;
2233
+ exports.filter = filter;
2234
+ exports.filterArray = filterArray;
2235
+ exports.filterObject = filterObject;
2236
+ exports.find = find;
2237
+ exports.findIndex = findIndex;
2238
+ exports.findLast = findLast;
2239
+ exports.findLastIndex = findLastIndex;
2240
+ exports.flatten = flatten;
2241
+ exports.flip = flip;
2242
+ exports.forEach = forEach;
2243
+ exports.forEachObjIndexed = forEachObjIndexed;
2244
+ exports.forEachObjIndexedFn = forEachObjIndexedFn;
2245
+ exports.fromPairs = fromPairs;
2246
+ exports.groupBy = groupBy;
2247
+ exports.groupWith = groupWith;
2248
+ exports.has = has;
2249
+ exports.hasPath = hasPath;
2250
+ exports.head = head;
2251
+ exports.identical = identical;
2252
+ exports.identity = identity;
2253
+ exports.ifElse = ifElse;
2254
+ exports.inc = inc;
2255
+ exports.includes = includes$1;
2256
+ exports.indexBy = indexBy;
2257
+ exports.indexOf = indexOf;
2258
+ exports.init = init;
2259
+ exports.intersection = intersection;
2260
+ exports.intersperse = intersperse;
2261
+ exports.is = is;
2262
+ exports.isEmpty = isEmpty;
2263
+ exports.isNil = isNil;
2264
+ exports.join = join;
2265
+ exports.juxt = juxt;
2266
+ exports.keys = keys;
2267
+ exports.last = last;
2268
+ exports.lastIndexOf = lastIndexOf;
2269
+ exports.length = length;
2270
+ exports.lens = lens;
2271
+ exports.lensIndex = lensIndex;
2272
+ exports.lensPath = lensPath;
2273
+ exports.lensProp = lensProp;
2274
+ exports.map = map;
2275
+ exports.mapArray = mapArray;
2276
+ exports.mapObjIndexed = mapObjIndexed;
2277
+ exports.mapObject = mapObject;
2278
+ exports.match = match;
2279
+ exports.mathMod = mathMod;
2280
+ exports.max = max;
2281
+ exports.maxBy = maxBy;
2282
+ exports.maxByFn = maxByFn;
2283
+ exports.mean = mean;
2284
+ exports.median = median;
2285
+ exports.merge = mergeRight;
2286
+ exports.mergeAll = mergeAll;
2287
+ exports.mergeDeepRight = mergeDeepRight;
2288
+ exports.mergeLeft = mergeLeft;
2289
+ exports.mergeRight = mergeRight;
2290
+ exports.mergeWith = mergeWith;
2291
+ exports.mergeWithFn = mergeWithFn;
2292
+ exports.min = min;
2293
+ exports.minBy = minBy;
2294
+ exports.minByFn = minByFn;
2295
+ exports.modify = modify;
2296
+ exports.modifyPath = modifyPath;
2297
+ exports.modifyPathFn = modifyPathFn;
2298
+ exports.modulo = modulo;
2299
+ exports.move = move;
2300
+ exports.multiply = multiply;
2301
+ exports.negate = negate;
2302
+ exports.none = none;
2303
+ exports.not = not;
2304
+ exports.nth = nth;
2305
+ exports.objOf = objOf;
2306
+ exports.of = of;
2307
+ exports.omit = omit;
2308
+ exports.on = on;
2309
+ exports.once = once;
2310
+ exports.or = or;
2311
+ exports.over = over;
2312
+ exports.partial = partial;
2313
+ exports.partialObject = partialObject;
2314
+ exports.partition = partition;
2315
+ exports.partitionArray = partitionArray;
2316
+ exports.partitionObject = partitionObject;
2317
+ exports.path = path;
2318
+ exports.pathEq = pathEq;
2319
+ exports.pathFn = pathFn;
2320
+ exports.pathOr = pathOr;
2321
+ exports.paths = paths;
2322
+ exports.pick = pick;
2323
+ exports.pickAll = pickAll;
2324
+ exports.pipe = pipe;
2325
+ exports.pipeWith = pipeWith;
2326
+ exports.pluck = pluck;
2327
+ exports.prepend = prepend;
2328
+ exports.product = product;
2329
+ exports.prop = prop;
2330
+ exports.propEq = propEq;
2331
+ exports.propIs = propIs;
2332
+ exports.propOr = propOr;
2333
+ exports.propSatisfies = propSatisfies;
2334
+ exports.props = props;
2335
+ exports.range = range;
2336
+ exports.reduce = reduce;
2337
+ exports.reduceFn = reduceFn;
2338
+ exports.reduceStopper = reduceStopper;
2339
+ exports.reject = reject;
2340
+ exports.removeIndex = removeIndex;
2341
+ exports.repeat = repeat;
2342
+ exports.replace = replace;
2343
+ exports.reverse = reverse;
2344
+ exports.set = set;
2345
+ exports.slice = slice;
2346
+ exports.sort = sort;
2347
+ exports.sortBy = sortBy;
2348
+ exports.split = split;
2349
+ exports.splitAt = splitAt;
2350
+ exports.splitEvery = splitEvery;
2351
+ exports.splitWhen = splitWhen;
2352
+ exports.startsWith = startsWith;
2353
+ exports.subtract = subtract;
2354
+ exports.sum = sum;
2355
+ exports.symmetricDifference = symmetricDifference;
2356
+ exports.tail = tail;
2357
+ exports.take = take;
2358
+ exports.takeLast = takeLast;
2359
+ exports.takeLastWhile = takeLastWhile;
2360
+ exports.takeWhile = takeWhile;
2361
+ exports.tap = tap;
2362
+ exports.test = test;
2363
+ exports.times = times;
2364
+ exports.toLower = toLower;
2365
+ exports.toPairs = toPairs;
2366
+ exports.toString = toString;
2367
+ exports.toUpper = toUpper;
2368
+ exports.transpose = transpose;
2369
+ exports.trim = trim;
2370
+ exports.tryCatch = tryCatch;
2371
+ exports.type = type;
2372
+ exports.unapply = unapply;
2373
+ exports.union = union;
2374
+ exports.uniq = uniq;
2375
+ exports.uniqBy = uniqBy;
2376
+ exports.uniqWith = uniqWith;
2377
+ exports.unless = unless;
2378
+ exports.unnest = unnest;
2379
+ exports.unwind = unwind;
2380
+ exports.update = update;
2381
+ exports.updateFn = updateFn;
2382
+ exports.values = values;
2383
+ exports.view = view;
2384
+ exports.when = when;
2385
+ exports.where = where;
2386
+ exports.whereAny = whereAny;
2387
+ exports.whereEq = whereEq;
2388
+ exports.without = without;
2389
+ exports.xor = xor;
2390
+ exports.zip = zip;
2391
+ exports.zipObj = zipObj;
2392
+ exports.zipWith = zipWith;
2393
+ }
2394
+ });
2395
+
2396
+ // packages/core/toTrimmedString.ts
2397
+ function toTrimmedString(value) {
2398
+ return typeof value === "string" ? value.trim() : value == null ? "" : String(value).trim();
2399
+ }
2400
+
2401
+ // packages/database/utils/ulid.ts
2402
+ import { monotonicFactory } from "ulid";
2403
+ var prng = () => Math.random();
2404
+ var ulid = monotonicFactory(prng);
2405
+
2406
+ // packages/database/keys.ts
2407
+ var import_rambda = __toESM(require_rambda(), 1);
2408
+
2409
+ // packages/core/userId.ts
2410
+ function normalizeUserId(value) {
2411
+ const text = asTrimmedString(value);
2412
+ return text.startsWith("user:") ? text.slice("user:".length) : text;
2413
+ }
2414
+
2415
+ // packages/share/keys.ts
2416
+ var SHARE_PREFIX = "share";
2417
+ var SHARE_INDEX_PREFIX = "shareidx";
2418
+ var TIMESTAMP_MAX = 9999999999999;
2419
+ var normalizeToken = (value) => toTrimmedString(value);
2420
+ var normalizeCreatedAt = (value) => {
2421
+ const parsed = Math.floor(Number(value));
2422
+ if (!Number.isFinite(parsed) || parsed < 0) return 0;
2423
+ return Math.min(parsed, TIMESTAMP_MAX);
2424
+ };
2425
+ var toInvertedTimestamp = (value) => String(TIMESTAMP_MAX - normalizeCreatedAt(value)).padStart(13, "0");
2426
+ var normalizeDimensionValue = (dim, raw) => dim === "creator" ? normalizeUserId(raw) : toSafeAgentKey(raw);
2427
+ var createCommunityIndex = (dim, rawValue, createdAt, token) => {
2428
+ const value = normalizeDimensionValue(dim, rawValue);
2429
+ const normalizedToken = normalizeToken(token);
2430
+ if (!value || !normalizedToken) return "";
2431
+ return createKey(SHARE_INDEX_PREFIX, "community", dim, value, toInvertedTimestamp(createdAt), normalizedToken);
2432
+ };
2433
+ var createCommunityRange = (dim, rawValue) => {
2434
+ const value = normalizeDimensionValue(dim, rawValue);
2435
+ if (!value) return { start: "", end: "" };
2436
+ const start = createKey(SHARE_INDEX_PREFIX, "community", dim, value, "");
2437
+ return { start, end: start + "\uFFFF" };
2438
+ };
2439
+ var createCommunityAllIndex = (createdAt, token) => {
2440
+ const normalizedToken = normalizeToken(token);
2441
+ if (!normalizedToken) return "";
2442
+ return createKey(SHARE_INDEX_PREFIX, "community", "all", toInvertedTimestamp(createdAt), normalizedToken);
2443
+ };
2444
+ var createCommunityAllRange = () => {
2445
+ const start = createKey(SHARE_INDEX_PREFIX, "community", "all", "");
2446
+ return { start, end: start + "\uFFFF" };
2447
+ };
2448
+ var createOwnerIndex = (rawUserId, createdAt, token) => {
2449
+ const userId = normalizeUserId(rawUserId);
2450
+ const normalizedToken = normalizeToken(token);
2451
+ if (!userId || !normalizedToken) return "";
2452
+ return createKey(SHARE_INDEX_PREFIX, "owner", userId, toInvertedTimestamp(createdAt), normalizedToken);
2453
+ };
2454
+ var createOwnerRange = (rawUserId) => {
2455
+ const userId = normalizeUserId(rawUserId);
2456
+ if (!userId) return { start: "", end: "" };
2457
+ const start = createKey(SHARE_INDEX_PREFIX, "owner", userId, "");
2458
+ return { start, end: start + "\uFFFF" };
2459
+ };
2460
+ var findAgentKeyInArray = (arr) => {
2461
+ for (const item of arr) {
2462
+ const key = toSafeAgentKey(item);
2463
+ if (key) return key;
2464
+ }
2465
+ return "";
2466
+ };
2467
+ var findAgentKeyInMessages = (messages) => {
2468
+ for (const raw of messages) {
2469
+ if (!raw || typeof raw !== "object") continue;
2470
+ const key = toSafeAgentKey(raw.cybotKey);
2471
+ if (key) return key;
2472
+ }
2473
+ return "";
2474
+ };
2475
+ var resolveAgentKeyFromPayload = (data) => {
2476
+ if (!data || typeof data !== "object") return "";
2477
+ const meta = data?.meta;
2478
+ const payload = data?.data;
2479
+ const directCandidates = [
2480
+ meta?.sourceAgentKey,
2481
+ meta?.agentKey,
2482
+ data?.sourceAgentKey,
2483
+ data?.agentKey,
2484
+ data?.cybotKey,
2485
+ data?.type === "cybot" ? data?.dbKey ?? data?.id : ""
2486
+ ];
2487
+ for (const c of directCandidates) {
2488
+ const key = toSafeAgentKey(c);
2489
+ if (key) return key;
2490
+ }
2491
+ if (payload && typeof payload === "object") {
2492
+ const payloadCandidates = [
2493
+ payload?.sourceAgentKey,
2494
+ payload?.agentKey,
2495
+ payload?.cybotKey,
2496
+ payload?.meta?.sourceAgentKey,
2497
+ payload?.meta?.agentKey,
2498
+ data?.type === "cybot" ? payload?.dbKey ?? payload?.id : ""
2499
+ ];
2500
+ for (const c of payloadCandidates) {
2501
+ const key = toSafeAgentKey(c);
2502
+ if (key) return key;
2503
+ }
2504
+ if (Array.isArray(payload?.cybots)) {
2505
+ const key = findAgentKeyInArray(payload.cybots);
2506
+ if (key) return key;
2507
+ }
2508
+ if (Array.isArray(payload?.messages)) {
2509
+ const key = findAgentKeyInMessages(payload.messages);
2510
+ if (key) return key;
2511
+ }
2512
+ if (Array.isArray(payload?.history)) {
2513
+ const key = findAgentKeyInMessages(payload.history);
2514
+ if (key) return key;
2515
+ }
2516
+ }
2517
+ return "";
2518
+ };
2519
+ var shareKey = {
2520
+ create: (token) => createKey(SHARE_PREFIX, token),
2521
+ range: () => {
2522
+ const start = createKey(SHARE_PREFIX, "");
2523
+ return { start, end: start + "\uFFFF" };
2524
+ },
2525
+ isShareKey: (key) => {
2526
+ const parts = splitKey(key);
2527
+ return parts.length >= 2 && parts[0] === SHARE_PREFIX;
2528
+ },
2529
+ tokenFromKey: (key) => {
2530
+ if (!shareKey.isShareKey(key)) return "";
2531
+ return key.slice(`${SHARE_PREFIX}-`.length).trim();
2532
+ },
2533
+ // Creator dimension
2534
+ communityCreatorIndex: (authorId, createdAt, token) => createCommunityIndex("creator", authorId, createdAt, token),
2535
+ communityCreatorRange: (authorId) => createCommunityRange("creator", authorId),
2536
+ // Agent dimension
2537
+ communityAgentIndex: (agentKey, createdAt, token) => createCommunityIndex("agent", agentKey, createdAt, token),
2538
+ communityAgentRange: (agentKey) => createCommunityRange("agent", agentKey),
2539
+ // Owner dimension (all shares, for "My Shares")
2540
+ ownerIndex: (userId, createdAt, token) => createOwnerIndex(userId, createdAt, token),
2541
+ ownerRange: (userId) => createOwnerRange(userId),
2542
+ // Global community feed (all community shares, time-ordered)
2543
+ communityAllIndex: (createdAt, token) => createCommunityAllIndex(createdAt, token),
2544
+ communityAllRange: () => createCommunityAllRange(),
2545
+ // From existing share data → index keys
2546
+ communityCreatorIndexFromShare: (dbKey, data) => {
2547
+ if (!shareKey.isShareKey(dbKey)) return "";
2548
+ if (data?.meta?.visibility !== "community") return "";
2549
+ const token = shareKey.tokenFromKey(dbKey);
2550
+ return shareKey.communityCreatorIndex(data?.meta?.authorId, data?.meta?.createdAt, token);
2551
+ },
2552
+ communityAgentIndexFromShare: (dbKey, data) => {
2553
+ if (!shareKey.isShareKey(dbKey)) return "";
2554
+ if (data?.meta?.visibility !== "community") return "";
2555
+ const token = shareKey.tokenFromKey(dbKey);
2556
+ const agentKey = resolveAgentKeyFromPayload(data);
2557
+ return shareKey.communityAgentIndex(agentKey, data?.meta?.createdAt, token);
2558
+ },
2559
+ ownerIndexFromShare: (dbKey, data) => {
2560
+ if (!shareKey.isShareKey(dbKey)) return "";
2561
+ const token = shareKey.tokenFromKey(dbKey);
2562
+ return shareKey.ownerIndex(data?.meta?.authorId, data?.meta?.createdAt, token);
2563
+ },
2564
+ communityAllIndexFromShare: (dbKey, data) => {
2565
+ if (!shareKey.isShareKey(dbKey)) return "";
2566
+ if (data?.meta?.visibility !== "community") return "";
2567
+ const token = shareKey.tokenFromKey(dbKey);
2568
+ return shareKey.communityAllIndex(data?.meta?.createdAt, token);
2569
+ },
2570
+ communityIndexKeysFromShare: (dbKey, data) => {
2571
+ const all = shareKey.communityAllIndexFromShare(dbKey, data);
2572
+ const creator = shareKey.communityCreatorIndexFromShare(dbKey, data);
2573
+ const agent = shareKey.communityAgentIndexFromShare(dbKey, data);
2574
+ return Array.from(new Set([all, creator, agent].filter(Boolean)));
2575
+ },
2576
+ allIndexKeysFromShare: (dbKey, data) => {
2577
+ const owner = shareKey.ownerIndexFromShare(dbKey, data);
2578
+ const community = shareKey.communityIndexKeysFromShare(dbKey, data);
2579
+ return Array.from(new Set([owner, ...community].filter(Boolean)));
2580
+ }
2581
+ };
2582
+
2583
+ // packages/database/dialogKey.ts
2584
+ var SEPARATOR = "-";
2585
+ var createKey2 = (...parts) => parts.join(SEPARATOR);
2586
+ var splitKey2 = (key) => key.split(SEPARATOR);
2587
+ var isDialogKey = (key) => {
2588
+ const parts = splitKey2(key);
2589
+ return parts.length >= 3 && parts[0] === "dialog" /* DIALOG */;
2590
+ };
2591
+ var isDialogRecordKey = (key) => {
2592
+ if (typeof key !== "string" || !key.startsWith(`${"dialog" /* DIALOG */}-`)) return false;
2593
+ if (key.includes("-msg-")) return false;
2594
+ const parts = splitKey2(key);
2595
+ return parts.length >= 3 && parts[0] === "dialog" /* DIALOG */;
2596
+ };
2597
+ var createDialogKey = Object.assign(
2598
+ (userId) => createKey2("dialog" /* DIALOG */, userId, ulid()),
2599
+ {
2600
+ single: (userId, dialogId) => createKey2("dialog" /* DIALOG */, userId, dialogId),
2601
+ rangeOfUser: (userId) => ({
2602
+ start: createKey2("dialog" /* DIALOG */, userId, ""),
2603
+ end: createKey2("dialog" /* DIALOG */, userId, "\uFFFF")
2604
+ })
2605
+ }
2606
+ );
2607
+ var dialogMessageKey = (dialogId, messageId) => createKey2("dialog" /* DIALOG */, dialogId, "msg", messageId);
2608
+ var createDialogMessageKeyAndId = (dialogId, ulidFn = ulid) => {
2609
+ const messageId = ulidFn();
2610
+ return { key: dialogMessageKey(dialogId, messageId), messageId };
2611
+ };
2612
+ var dialogMessageRange = (dialogId) => ({
2613
+ start: createKey2("dialog" /* DIALOG */, dialogId, "msg", ""),
2614
+ end: createKey2("dialog" /* DIALOG */, dialogId, "msg", "\uFFFF")
2615
+ });
2616
+
2617
+ // packages/database/keys.ts
2618
+ var SEPARATOR2 = "-";
2619
+ var createKey = (...parts) => parts.join(SEPARATOR2);
2620
+ var splitKey = (key) => key.split(SEPARATOR2);
2621
+ var TYPE_STORAGE_PREFIXES = {
2622
+ ["app" /* APP */]: ["app"],
2623
+ ["page" /* DOC */]: ["page"],
2624
+ ["dialog" /* DIALOG */]: ["dialog"],
2625
+ ["image" /* IMAGE */]: ["image"],
2626
+ ["file" /* FILE */]: ["file"],
2627
+ ["table" /* TABLE */]: ["meta", "table"],
2628
+ ["agent" /* AGENT */]: ["agent"]
2629
+ };
2630
+ var _PREFIX_TO_TYPE = (() => {
2631
+ const map = /* @__PURE__ */ new Map();
2632
+ for (const [type, prefixes] of Object.entries(TYPE_STORAGE_PREFIXES)) {
2633
+ for (const prefix of prefixes) {
2634
+ if (!map.has(prefix)) map.set(prefix, type);
2635
+ }
2636
+ }
2637
+ return map;
2638
+ })();
2639
+ var isTableMetaKey = (key) => {
2640
+ const parts = splitKey(key);
2641
+ return parts.length >= 3 && parts[0] === "meta";
2642
+ };
2643
+ var isPageKey = (key) => {
2644
+ const parts = splitKey(key);
2645
+ return parts.length >= 3 && parts[0] === "page" /* DOC */;
2646
+ };
2647
+ var isTaskKey = (key) => {
2648
+ const parts = splitKey(key);
2649
+ return parts.length >= 3 && parts[0] === "task" /* TASK */;
2650
+ };
2651
+ var isFileKey = (key) => {
2652
+ const parts = splitKey(key);
2653
+ return parts.length >= 3 && (parts[0] === "file" /* FILE */ || parts[0] === "image" /* IMAGE */);
2654
+ };
2655
+ var isAgentKey2 = (key) => {
2656
+ const parts = splitKey(key);
2657
+ return parts.length >= 3 && parts[0] === "agent" /* AGENT */;
2658
+ };
2659
+ var isAppKey = (key) => {
2660
+ const parts = splitKey(key);
2661
+ return parts.length >= 2 && parts[0] === "app" /* APP */;
2662
+ };
2663
+ var rowKey = {
2664
+ /** 生成新行主键 + rowId */
2665
+ create: (tenantId, tableId) => {
2666
+ const rowId = ulid();
2667
+ return { dbKey: createKey("row", tenantId, tableId, rowId), rowId };
2668
+ },
2669
+ /** 单行键 */
2670
+ single: (tenantId, tableId, rowId) => createKey("row", tenantId, tableId, rowId),
2671
+ /** 整张表的范围(gte / lte)—— 供批量操作使用 */
2672
+ range: (tenantId, tableId) => {
2673
+ const start = createKey("row", tenantId, tableId, "");
2674
+ return {
2675
+ gte: start,
2676
+ lte: start + "\uFFFF"
2677
+ };
2678
+ },
2679
+ /** 旧接口(start / end)—— 与早期代码兼容 */
2680
+ rangeOfTable: (tenantId, tableId) => {
2681
+ const start = createKey("row", tenantId, tableId, "");
2682
+ return {
2683
+ start,
2684
+ end: start + "\uFFFF"
2685
+ };
2686
+ },
2687
+ /** 某个租户的所有行范围 */
2688
+ rangeOfTenant: (tenantId) => {
2689
+ const start = createKey("row", tenantId, "");
2690
+ return {
2691
+ start,
2692
+ end: start + "\uFFFF"
2693
+ };
2694
+ }
2695
+ };
2696
+ var metaKey = Object.assign(
2697
+ (tenantId, tableId) => createKey("meta", tenantId, tableId),
2698
+ {
2699
+ /** 某个租户的所有表定义范围 */
2700
+ rangeOfTenant: (tenantId) => {
2701
+ const start = createKey("meta", tenantId, "");
2702
+ return {
2703
+ start,
2704
+ end: start + "\uFFFF"
2705
+ };
2706
+ }
2707
+ }
2708
+ );
2709
+ var DB_PREFIX = {
2710
+ USER: "user:"
2711
+ };
2712
+ var createUserKey = {
2713
+ settings: (userId) => createKey(userId, "settings"),
2714
+ profile: (userId) => createKey(userId, "profile")
2715
+ };
2716
+ var createUserPreferenceKey = {
2717
+ single: (userId, preferenceName) => createKey("user", "pref", userId, preferenceName),
2718
+ authorityHome: (userId) => createKey("user", "pref", userId, "authority_home"),
2719
+ defaultAgent: (userId) => createKey("user", "pref", userId, "agent_default"),
2720
+ rangeOfUser: (userId) => ({
2721
+ start: createKey("user", "pref", userId, ""),
2722
+ end: createKey("user", "pref", userId, "\uFFFF")
2723
+ })
2724
+ };
2725
+ var createMemoryKey = (ownerType, ownerId, memoryId) => createKey("mem", ownerType, ownerId, memoryId);
2726
+ var createMemoryOwnerIndexKey = (ownerType, ownerId, createdAt, memoryId) => createKey("memidx", "owner", ownerType, ownerId, createdAt, memoryId);
2727
+ var createMemorySubjectKindIndexKey = (subjectType, subjectId, kind, createdAt, memoryId) => createKey(
2728
+ "memidx",
2729
+ "subject",
2730
+ subjectType,
2731
+ subjectId,
2732
+ kind,
2733
+ createdAt,
2734
+ memoryId
2735
+ );
2736
+ var memoryOwnerRange = (ownerType, ownerId) => ({
2737
+ start: createKey("memidx", "owner", ownerType, ownerId, ""),
2738
+ end: createKey("memidx", "owner", ownerType, ownerId, "\uFFFF")
2739
+ });
2740
+ var memorySubjectKindRange = (subjectType, subjectId, kind) => ({
2741
+ start: createKey("memidx", "subject", subjectType, subjectId, kind, ""),
2742
+ end: createKey("memidx", "subject", subjectType, subjectId, kind, "\uFFFF")
2743
+ });
2744
+ var createTransactionKey = {
2745
+ record: (0, import_rambda.curry)(
2746
+ (userId, txId) => createKey("tx", userId, txId)
2747
+ ),
2748
+ index: (txId) => createKey("tx", "index", txId),
2749
+ range: (userId) => ({
2750
+ start: createKey("tx", userId, ""),
2751
+ end: createKey("tx", userId, "\uFFFF")
2752
+ })
2753
+ };
2754
+ var createTokenKey = {
2755
+ record: (0, import_rambda.curry)(
2756
+ (userId, timestamp) => createKey("token", userId, timestamp.toString())
2757
+ ),
2758
+ range: (userId, timestamp) => ({
2759
+ start: createKey("token", userId, timestamp.toString()),
2760
+ end: createKey("token", userId, (timestamp + 864e5).toString())
2761
+ }),
2762
+ /** 某个用户的所有 Token 记录范围 */
2763
+ rangeOfUser: (userId) => ({
2764
+ start: createKey("token", userId, ""),
2765
+ end: createKey("token", userId, "\uFFFF")
2766
+ })
2767
+ };
2768
+ var createTokenStatsKey = Object.assign(
2769
+ (userId, dateKey) => createKey("token", "stats", "day", "user", userId, dateKey),
2770
+ {
2771
+ /** 某个用户的所有统计记录范围 */
2772
+ rangeOfUser: (userId) => ({
2773
+ start: createKey("token", "stats", "day", "user", userId, ""),
2774
+ end: createKey("token", "stats", "day", "user", userId, "\uFFFF")
2775
+ })
2776
+ }
2777
+ );
2778
+ var DIALOG_AGENT_LIST_INDEX_PREFIX = "dialogidx";
2779
+ var DIALOG_LIST_TIMESTAMP_MAX = 9999999999999;
2780
+ function parseDialogUpdatedAtMs(value) {
2781
+ const finite = asOptionalFiniteNumber(value);
2782
+ if (finite !== void 0) {
2783
+ return Math.max(0, Math.floor(finite));
2784
+ }
2785
+ if (typeof value === "string" && value) {
2786
+ const asNumber = Number(value);
2787
+ if (Number.isFinite(asNumber) && /^\d+(\.\d+)?$/.test(value.trim())) {
2788
+ return Math.max(0, Math.floor(asNumber));
2789
+ }
2790
+ const parsed = Date.parse(value);
2791
+ return Number.isFinite(parsed) ? Math.max(0, Math.floor(parsed)) : 0;
2792
+ }
2793
+ return 0;
2794
+ }
2795
+ function toDialogListInvertedTimestamp(updatedAt) {
2796
+ const ms = Math.min(
2797
+ DIALOG_LIST_TIMESTAMP_MAX,
2798
+ parseDialogUpdatedAtMs(updatedAt)
2799
+ );
2800
+ return String(DIALOG_LIST_TIMESTAMP_MAX - ms).padStart(13, "0");
2801
+ }
2802
+ function createDialogAgentListIndexKey(args) {
2803
+ const userId = args.userId.trim();
2804
+ const agentKey = args.agentKey.trim();
2805
+ const dialogId = args.dialogId.trim();
2806
+ if (!userId || !agentKey || !dialogId) return "";
2807
+ return createKey(
2808
+ DIALOG_AGENT_LIST_INDEX_PREFIX,
2809
+ "agent",
2810
+ userId,
2811
+ agentKey,
2812
+ toDialogListInvertedTimestamp(args.updatedAt),
2813
+ dialogId
2814
+ );
2815
+ }
2816
+ function expandDialogAgentListIndexAliases(agentKey) {
2817
+ const key = agentKey.trim();
2818
+ if (!key) return [];
2819
+ return [key];
2820
+ }
2821
+ function collectDialogAgentListIndexAgentKeys(record) {
2822
+ const keys = /* @__PURE__ */ new Set();
2823
+ const add = (raw) => {
2824
+ if (typeof raw !== "string") return;
2825
+ const trimmed = raw.trim();
2826
+ if (!trimmed) return;
2827
+ for (const alias of expandDialogAgentListIndexAliases(trimmed)) {
2828
+ keys.add(alias);
2829
+ }
2830
+ };
2831
+ add(record.primaryAgentKey);
2832
+ if (Array.isArray(record.cybots)) {
2833
+ for (const item of record.cybots) add(item);
2834
+ }
2835
+ return Array.from(keys);
2836
+ }
2837
+ function isDialogAgentListIndexable(record) {
2838
+ if (!record || typeof record !== "object") return false;
2839
+ if (record.triggerType === "automation_run" || record.triggerType === "scheduled_run") {
2840
+ return false;
2841
+ }
2842
+ if (record.parentAutomationKey) return false;
2843
+ if (record.parentTaskKey) return false;
2844
+ return true;
2845
+ }
2846
+ function resolveDialogIdForIndex(dialogKey, dialogId, record) {
2847
+ const fromDialogId = asOptionalTrimmedString(dialogId);
2848
+ if (fromDialogId) return fromDialogId;
2849
+ const fromRecordId = asOptionalTrimmedString(record?.id);
2850
+ if (fromRecordId) return fromRecordId;
2851
+ const parts = splitKey(dialogKey);
2852
+ if (parts.length >= 3 && parts[0] === "dialog" /* DIALOG */ && !dialogKey.includes("-msg-")) {
2853
+ return parts[parts.length - 1] ?? "";
2854
+ }
2855
+ return "";
2856
+ }
2857
+ function buildDialogAgentListIndexKeySet(args) {
2858
+ const map = /* @__PURE__ */ new Map();
2859
+ if (!args.userId.trim() || !args.dialogKey.trim() || !args.dialogId.trim()) {
2860
+ return map;
2861
+ }
2862
+ if (!isDialogAgentListIndexable(args.record)) return map;
2863
+ const updatedAtMs = parseDialogUpdatedAtMs(args.record.updatedAt);
2864
+ const value = {
2865
+ dialogKey: args.dialogKey,
2866
+ dialogId: args.dialogId,
2867
+ updatedAtMs
2868
+ };
2869
+ for (const agentKey of collectDialogAgentListIndexAgentKeys(args.record)) {
2870
+ const key = createDialogAgentListIndexKey({
2871
+ userId: args.userId,
2872
+ agentKey,
2873
+ updatedAt: updatedAtMs,
2874
+ dialogId: args.dialogId
2875
+ });
2876
+ if (key) map.set(key, value);
2877
+ }
2878
+ return map;
2879
+ }
2880
+ function buildDialogAgentListIndexDeleteOps(args) {
2881
+ return buildDialogAgentListIndexOps({
2882
+ userId: args.userId,
2883
+ dialogKey: args.dialogKey,
2884
+ dialogId: args.dialogId,
2885
+ nextRecord: null,
2886
+ previousRecord: args.previousRecord
2887
+ }).filter((op) => op.type === "del");
2888
+ }
2889
+ function buildDialogAgentListIndexOps(args) {
2890
+ const userId = asTrimmedString(args.userId);
2891
+ const dialogKey = args.dialogKey.trim();
2892
+ if (!userId || !dialogKey) return [];
2893
+ const dialogId = resolveDialogIdForIndex(
2894
+ dialogKey,
2895
+ args.dialogId,
2896
+ args.nextRecord ?? args.previousRecord ?? null
2897
+ );
2898
+ if (!dialogId) return [];
2899
+ const previousMap = args.previousRecord && typeof args.previousRecord === "object" ? buildDialogAgentListIndexKeySet({
2900
+ userId,
2901
+ dialogKey,
2902
+ dialogId: resolveDialogIdForIndex(
2903
+ dialogKey,
2904
+ args.dialogId,
2905
+ args.previousRecord
2906
+ ) || dialogId,
2907
+ record: args.previousRecord
2908
+ }) : /* @__PURE__ */ new Map();
2909
+ const nextMap = args.nextRecord && typeof args.nextRecord === "object" ? buildDialogAgentListIndexKeySet({
2910
+ userId,
2911
+ dialogKey,
2912
+ dialogId,
2913
+ record: args.nextRecord
2914
+ }) : /* @__PURE__ */ new Map();
2915
+ const ops = [];
2916
+ for (const key of previousMap.keys()) {
2917
+ if (!nextMap.has(key)) {
2918
+ ops.push({ type: "del", key });
2919
+ }
2920
+ }
2921
+ for (const [key, value] of nextMap) {
2922
+ ops.push({ type: "put", key, value });
2923
+ }
2924
+ return ops;
2925
+ }
2926
+ var createTaskKey = Object.assign(
2927
+ (userId) => createKey("task" /* TASK */, userId, ulid()),
2928
+ {
2929
+ rangeOfUser: (userId) => ({
2930
+ start: createKey("task" /* TASK */, userId, ""),
2931
+ end: createKey("task" /* TASK */, userId, "\uFFFF")
2932
+ })
2933
+ }
2934
+ );
2935
+ var createAgentAutomationKey = Object.assign(
2936
+ (userId) => createKey("agent-automation" /* AGENT_AUTOMATION */, userId, ulid()),
2937
+ {
2938
+ rangeOfUser: (userId) => ({
2939
+ start: createKey("agent-automation" /* AGENT_AUTOMATION */, userId, ""),
2940
+ end: createKey("agent-automation" /* AGENT_AUTOMATION */, userId, "\uFFFF")
2941
+ })
2942
+ }
2943
+ );
2944
+ var AGENT_AUTOMATION_OWNER_INDEX_PREFIX = "agent-automation-owner-idx";
2945
+ var createAgentAutomationOwnerIndexKey = Object.assign(
2946
+ (userId, ownerAgentKey, automationId) => createKey(
2947
+ AGENT_AUTOMATION_OWNER_INDEX_PREFIX,
2948
+ userId,
2949
+ ownerAgentKey,
2950
+ automationId
2951
+ ),
2952
+ {
2953
+ rangeOfAgent: (userId, ownerAgentKey) => {
2954
+ const start = createKey(
2955
+ AGENT_AUTOMATION_OWNER_INDEX_PREFIX,
2956
+ userId,
2957
+ ownerAgentKey,
2958
+ ""
2959
+ );
2960
+ return { start, end: `${start}\uFFFF` };
2961
+ }
2962
+ }
2963
+ );
2964
+ function buildAgentAutomationOwnerIndexValue(args) {
2965
+ return {
2966
+ automationKey: args.automationKey,
2967
+ automationId: args.automationId,
2968
+ userId: args.userId,
2969
+ ownerAgentKey: args.ownerAgentKey
2970
+ };
2971
+ }
2972
+ var createPageKey = {
2973
+ create: (userId) => {
2974
+ const id = ulid();
2975
+ return { dbKey: createKey("page" /* DOC */, userId, id), id };
2976
+ },
2977
+ rangeOfUser: (userId) => ({
2978
+ start: createKey("page" /* DOC */, userId, ""),
2979
+ end: createKey("page" /* DOC */, userId, "\uFFFF")
2980
+ })
2981
+ };
2982
+ var createAgentKey = {
2983
+ private: (0, import_rambda.curry)(
2984
+ (userId, agentId) => createKey("agent" /* AGENT */, userId, agentId)
2985
+ ),
2986
+ public: (agentId) => createKey("agent" /* AGENT */, "pub", agentId),
2987
+ rangeOfUser: (userId) => ({
2988
+ start: createKey("agent" /* AGENT */, userId, ""),
2989
+ end: createKey("agent" /* AGENT */, userId, "\uFFFF")
2990
+ })
2991
+ };
2992
+ var fileKey = {
2993
+ single: (tenantId, fileId) => createKey("file", tenantId, fileId),
2994
+ rangeOfTenant: (tenantId) => {
2995
+ const start = createKey("file", tenantId, "");
2996
+ return {
2997
+ start,
2998
+ end: start + "\uFFFF"
2999
+ };
3000
+ }
3001
+ };
3002
+ var getFileIdFromKey = (key) => {
3003
+ const parts = key.split(SEPARATOR2);
3004
+ return parts[2];
3005
+ };
3006
+
3007
+ // packages/share/helpers.ts
3008
+ var toSafeString = (value) => asTrimmedString(value);
3009
+ var toNonEmptyString = (value) => {
3010
+ const text = toSafeString(value);
3011
+ return text || void 0;
3012
+ };
3013
+ var toSafeAgentKey = (value) => {
3014
+ const text = toSafeString(value);
3015
+ return text && isAgentKey2(text) ? text : "";
3016
+ };
3017
+ var SHARE_TIME_FORMATTER = new Intl.DateTimeFormat("zh-CN", {
3018
+ timeZone: "Asia/Shanghai",
3019
+ year: "numeric",
3020
+ month: "2-digit",
3021
+ day: "2-digit",
3022
+ hour: "2-digit",
3023
+ minute: "2-digit",
3024
+ second: "2-digit",
3025
+ hour12: false
3026
+ });
3027
+ var findAgentKeyInMessages2 = (messages) => {
3028
+ for (const raw of messages) {
3029
+ if (!raw || typeof raw !== "object") continue;
3030
+ const key = toSafeAgentKey(raw.cybotKey);
3031
+ if (key) return key;
3032
+ }
3033
+ return "";
3034
+ };
3035
+ var findAgentKeyInArray2 = (items) => {
3036
+ for (const raw of items) {
3037
+ const direct = toSafeAgentKey(raw);
3038
+ if (direct) return direct;
3039
+ if (!raw || typeof raw !== "object") continue;
3040
+ const item = raw;
3041
+ const key = toSafeAgentKey(item.dbKey) || toSafeAgentKey(item.id);
3042
+ if (key) return key;
3043
+ }
3044
+ return "";
3045
+ };
3046
+ var findAgentNameInMessages = (messages) => {
3047
+ for (const raw of messages) {
3048
+ if (!raw || typeof raw !== "object") continue;
3049
+ const msg = raw;
3050
+ const name = toSafeString(msg.agentName) || toSafeString(msg.cybotName) || toSafeString(msg.sourceAgentName);
3051
+ if (name) return name;
3052
+ }
3053
+ return "";
3054
+ };
3055
+ var findAgentNameInArray = (items) => {
3056
+ for (const raw of items) {
3057
+ if (!raw || typeof raw !== "object") continue;
3058
+ const item = raw;
3059
+ const name = toSafeString(item.name) || toSafeString(item.agentName) || toSafeString(item.cybotName) || toSafeString(item.sourceAgentName);
3060
+ if (name) return name;
3061
+ }
3062
+ return "";
3063
+ };
3064
+ var extractAgentInfo = (type, data) => {
3065
+ const meta = data.meta;
3066
+ const keyCandidates = [
3067
+ meta?.sourceAgentKey,
3068
+ meta?.agentKey,
3069
+ data.sourceAgentKey,
3070
+ data.agentKey,
3071
+ data.cybotKey,
3072
+ type === "cybot" ? data.dbKey ?? data.id : void 0
3073
+ ];
3074
+ let agentKey = "";
3075
+ for (const candidate of keyCandidates) {
3076
+ agentKey = toSafeAgentKey(candidate);
3077
+ if (agentKey) break;
3078
+ }
3079
+ if (!agentKey && Array.isArray(data.cybots)) {
3080
+ agentKey = findAgentKeyInArray2(data.cybots);
3081
+ }
3082
+ if (!agentKey && Array.isArray(data.messages)) {
3083
+ agentKey = findAgentKeyInMessages2(data.messages);
3084
+ }
3085
+ if (!agentKey && Array.isArray(data.history)) {
3086
+ agentKey = findAgentKeyInMessages2(data.history);
3087
+ }
3088
+ const nameCandidates = [
3089
+ meta?.sourceAgentName,
3090
+ meta?.agentName,
3091
+ meta?.cybotName,
3092
+ data.sourceAgentName,
3093
+ data.agentName,
3094
+ data.cybotName,
3095
+ type === "cybot" ? data.name : void 0
3096
+ ];
3097
+ let agentName = "";
3098
+ for (const candidate of nameCandidates) {
3099
+ agentName = toSafeString(candidate);
3100
+ if (agentName) break;
3101
+ }
3102
+ if (!agentName && Array.isArray(data.cybots)) {
3103
+ agentName = findAgentNameInArray(data.cybots);
3104
+ }
3105
+ if (!agentName && Array.isArray(data.messages)) {
3106
+ agentName = findAgentNameInMessages(data.messages);
3107
+ }
3108
+ if (!agentName && Array.isArray(data.history)) {
3109
+ agentName = findAgentNameInMessages(data.history);
3110
+ }
3111
+ return {
3112
+ ...agentKey ? { sourceAgentKey: agentKey } : {},
3113
+ ...agentName ? { sourceAgentName: agentName } : {}
3114
+ };
3115
+ };
3116
+ var extractImageFromContent = (content) => {
3117
+ if (Array.isArray(content)) {
3118
+ const part = content.find(
3119
+ (p) => p?.type === "image_url" && typeof p?.image_url?.url === "string"
3120
+ );
3121
+ if (part?.image_url?.url) return part.image_url.url;
3122
+ }
3123
+ if (typeof content === "string") {
3124
+ const match = content.match(/!\[.*?\]\((.*?)\)/);
3125
+ if (match?.[1]) return match[1];
3126
+ }
3127
+ return void 0;
3128
+ };
3129
+ var extractCoverImage = (type, data) => {
3130
+ if (type === "image" /* IMAGE */) {
3131
+ return toNonEmptyString(data.url);
3132
+ }
3133
+ if (type === "app" /* APP */) {
3134
+ return toNonEmptyString(data.coverImage);
3135
+ }
3136
+ if (type !== "dialog" /* DIALOG */) return void 0;
3137
+ const messages = Array.isArray(data.messages) ? data.messages : Array.isArray(data.history) ? data.history : [];
3138
+ for (const msg of messages) {
3139
+ const fromContent = extractImageFromContent(msg.content);
3140
+ if (fromContent) return fromContent;
3141
+ const image = toNonEmptyString(msg.image);
3142
+ if (image) return image;
3143
+ if (Array.isArray(msg.images)) {
3144
+ const first = asNonEmptyStringArray(msg.images)[0];
3145
+ if (first) return first;
3146
+ }
3147
+ }
3148
+ return void 0;
3149
+ };
3150
+ var resolveShareAuthorIdentity = (args) => {
3151
+ const authorName = toNonEmptyString(args.profile?.nickname) ?? toNonEmptyString(args.user?.name) ?? toNonEmptyString(args.user?.nickname) ?? toNonEmptyString(args.user?.username) ?? toNonEmptyString(args.fallbackName);
3152
+ const authorAvatar = toNonEmptyString(args.profile?.avatar) ?? toNonEmptyString(args.user?.avatar) ?? toNonEmptyString(args.fallbackAvatar);
3153
+ return {
3154
+ ...authorName ? { authorName } : {},
3155
+ ...authorAvatar ? { authorAvatar } : {}
3156
+ };
3157
+ };
3158
+ var SENSITIVE_FIELDS = ["apiKey", "secret", "password"];
3159
+ var sanitizeShareData = (data) => {
3160
+ const snapshot = { ...data };
3161
+ for (const field of SENSITIVE_FIELDS) {
3162
+ delete snapshot[field];
3163
+ }
3164
+ return snapshot;
3165
+ };
3166
+
3167
+ export {
3168
+ ulid,
3169
+ toTrimmedString,
3170
+ toNonEmptyString,
3171
+ extractAgentInfo,
3172
+ extractCoverImage,
3173
+ resolveShareAuthorIdentity,
3174
+ sanitizeShareData,
3175
+ shareKey,
3176
+ isDialogKey,
3177
+ isDialogRecordKey,
3178
+ createDialogKey,
3179
+ dialogMessageKey,
3180
+ createDialogMessageKeyAndId,
3181
+ dialogMessageRange,
3182
+ SEPARATOR2 as SEPARATOR,
3183
+ createKey,
3184
+ splitKey,
3185
+ TYPE_STORAGE_PREFIXES,
3186
+ isTableMetaKey,
3187
+ isPageKey,
3188
+ isTaskKey,
3189
+ isFileKey,
3190
+ isAgentKey2 as isAgentKey,
3191
+ isAppKey,
3192
+ rowKey,
3193
+ metaKey,
3194
+ DB_PREFIX,
3195
+ createUserKey,
3196
+ createUserPreferenceKey,
3197
+ createMemoryKey,
3198
+ createMemoryOwnerIndexKey,
3199
+ createMemorySubjectKindIndexKey,
3200
+ memoryOwnerRange,
3201
+ memorySubjectKindRange,
3202
+ createTokenKey,
3203
+ createTokenStatsKey,
3204
+ buildDialogAgentListIndexDeleteOps,
3205
+ createAgentAutomationKey,
3206
+ createAgentAutomationOwnerIndexKey,
3207
+ buildAgentAutomationOwnerIndexValue,
3208
+ createPageKey,
3209
+ createAgentKey,
3210
+ fileKey,
3211
+ getFileIdFromKey
3212
+ };