langgraph-ui-components 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es100.js +25 -157
- package/dist/index.es100.js.map +1 -1
- package/dist/index.es101.js +3130 -176
- package/dist/index.es101.js.map +1 -1
- package/dist/index.es102.js +36 -13
- package/dist/index.es102.js.map +1 -1
- package/dist/index.es103.js +5 -30
- package/dist/index.es103.js.map +1 -1
- package/dist/index.es104.js +69 -30
- package/dist/index.es104.js.map +1 -1
- package/dist/index.es105.js +28 -3148
- package/dist/index.es105.js.map +1 -1
- package/dist/index.es106.js +5 -16
- package/dist/index.es106.js.map +1 -1
- package/dist/index.es107.js +2 -7
- package/dist/index.es107.js.map +1 -1
- package/dist/index.es108.js +13 -2
- package/dist/index.es108.js.map +1 -1
- package/dist/index.es109.js +499 -9
- package/dist/index.es109.js.map +1 -1
- package/dist/index.es11.js +2 -2
- package/dist/index.es11.js.map +1 -1
- package/dist/index.es110.js +5 -501
- package/dist/index.es110.js.map +1 -1
- package/dist/index.es111.js +2 -7
- package/dist/index.es111.js.map +1 -1
- package/dist/index.es112.js +148 -2
- package/dist/index.es112.js.map +1 -1
- package/dist/index.es113.js +878 -118
- package/dist/index.es113.js.map +1 -1
- package/dist/index.es114.js +251 -877
- package/dist/index.es114.js.map +1 -1
- package/dist/index.es115.js +3 -281
- package/dist/index.es115.js.map +1 -1
- package/dist/index.es116.js +445 -3
- package/dist/index.es116.js.map +1 -1
- package/dist/index.es117.js +39 -437
- package/dist/index.es117.js.map +1 -1
- package/dist/index.es118.js +22 -46
- package/dist/index.es118.js.map +1 -1
- package/dist/index.es119.js +78 -21
- package/dist/index.es119.js.map +1 -1
- package/dist/index.es120.js +126 -76
- package/dist/index.es120.js.map +1 -1
- package/dist/index.es121.js +45 -125
- package/dist/index.es121.js.map +1 -1
- package/dist/index.es122.js +9 -48
- package/dist/index.es122.js.map +1 -1
- package/dist/index.es123.js +45 -10
- package/dist/index.es123.js.map +1 -1
- package/dist/index.es124.js +97 -43
- package/dist/index.es124.js.map +1 -1
- package/dist/index.es125.js +48 -94
- package/dist/index.es125.js.map +1 -1
- package/dist/index.es126.js +14 -51
- package/dist/index.es126.js.map +1 -1
- package/dist/index.es127.js +13 -162
- package/dist/index.es127.js.map +1 -1
- package/dist/index.es128.js +89 -2
- package/dist/index.es128.js.map +1 -1
- package/dist/index.es129.js +2 -15
- package/dist/index.es129.js.map +1 -1
- package/dist/index.es130.js +54 -87
- package/dist/index.es130.js.map +1 -1
- package/dist/index.es131.js +100 -2
- package/dist/index.es131.js.map +1 -1
- package/dist/index.es132.js +186 -51
- package/dist/index.es132.js.map +1 -1
- package/dist/index.es133.js +97 -87
- package/dist/index.es133.js.map +1 -1
- package/dist/index.es134.js +31 -187
- package/dist/index.es134.js.map +1 -1
- package/dist/index.es135.js +10 -110
- package/dist/index.es135.js.map +1 -1
- package/dist/index.es136.js +11 -35
- package/dist/index.es136.js.map +1 -1
- package/dist/index.es137.js +12 -10
- package/dist/index.es137.js.map +1 -1
- package/dist/index.es138.js +90 -10
- package/dist/index.es138.js.map +1 -1
- package/dist/index.es139.js +274 -11
- package/dist/index.es139.js.map +1 -1
- package/dist/index.es140.js +2 -91
- package/dist/index.es140.js.map +1 -1
- package/dist/index.es141.js +150 -261
- package/dist/index.es141.js.map +1 -1
- package/dist/index.es142.js +51 -2
- package/dist/index.es142.js.map +1 -1
- package/dist/index.es143.js +34 -158
- package/dist/index.es143.js.map +1 -1
- package/dist/index.es144.js +34 -50
- package/dist/index.es144.js.map +1 -1
- package/dist/index.es145.js +32 -32
- package/dist/index.es145.js.map +1 -1
- package/dist/index.es146.js +23 -34
- package/dist/index.es146.js.map +1 -1
- package/dist/index.es147.js +583 -32
- package/dist/index.es147.js.map +1 -1
- package/dist/index.es148.js +121 -20
- package/dist/index.es148.js.map +1 -1
- package/dist/index.es149.js +158 -585
- package/dist/index.es149.js.map +1 -1
- package/dist/index.es15.js +15 -15
- package/dist/index.es150.js +2 -125
- package/dist/index.es150.js.map +1 -1
- package/dist/index.es157.js +2 -2
- package/dist/index.es159.js +2 -2
- package/dist/index.es161.js +64 -25
- package/dist/index.es161.js.map +1 -1
- package/dist/index.es162.js +22 -12
- package/dist/index.es162.js.map +1 -1
- package/dist/index.es163.js +5 -53
- package/dist/index.es163.js.map +1 -1
- package/dist/index.es164.js +337 -52
- package/dist/index.es164.js.map +1 -1
- package/dist/index.es165.js +24 -21
- package/dist/index.es165.js.map +1 -1
- package/dist/index.es166.js +12 -6
- package/dist/index.es166.js.map +1 -1
- package/dist/index.es167.js +49 -344
- package/dist/index.es167.js.map +1 -1
- package/dist/index.es175.js +1 -1
- package/dist/index.es178.js +1 -1
- package/dist/index.es183.js +1 -1
- package/dist/index.es195.js +2 -2
- package/dist/index.es197.js +2 -2
- package/dist/index.es200.js +1 -1
- package/dist/index.es201.js +1 -1
- package/dist/index.es203.js +1 -1
- package/dist/index.es204.js +2 -2
- package/dist/index.es206.js +1 -1
- package/dist/index.es209.js +3 -3
- package/dist/index.es21.js +1 -1
- package/dist/index.es210.js +2 -2
- package/dist/index.es212.js +1 -1
- package/dist/index.es214.js +1 -1
- package/dist/index.es215.js +1 -1
- package/dist/index.es217.js +1 -1
- package/dist/index.es218.js +2 -2
- package/dist/index.es219.js +1 -1
- package/dist/index.es220.js +1 -1
- package/dist/index.es221.js +1 -1
- package/dist/index.es222.js +1 -1
- package/dist/index.es223.js +1 -1
- package/dist/index.es224.js +1 -1
- package/dist/index.es225.js +1 -1
- package/dist/index.es229.js +2 -2
- package/dist/index.es28.js +7 -7
- package/dist/index.es29.js +1 -1
- package/dist/index.es32.js +4 -4
- package/dist/index.es33.js +15 -1191
- package/dist/index.es33.js.map +1 -1
- package/dist/index.es34.js +117 -6
- package/dist/index.es34.js.map +1 -1
- package/dist/index.es35.js +70 -8
- package/dist/index.es35.js.map +1 -1
- package/dist/index.es36.js +19 -148
- package/dist/index.es36.js.map +1 -1
- package/dist/index.es37.js +255 -112
- package/dist/index.es37.js.map +1 -1
- package/dist/index.es38.js +40 -68
- package/dist/index.es38.js.map +1 -1
- package/dist/index.es39.js +214 -17
- package/dist/index.es39.js.map +1 -1
- package/dist/index.es40.js +53 -247
- package/dist/index.es40.js.map +1 -1
- package/dist/index.es41.js +123 -24
- package/dist/index.es41.js.map +1 -1
- package/dist/index.es42.js +14 -205
- package/dist/index.es42.js.map +1 -1
- package/dist/index.es43.js +221 -58
- package/dist/index.es43.js.map +1 -1
- package/dist/index.es44.js +7 -140
- package/dist/index.es44.js.map +1 -1
- package/dist/index.es45.js +1185 -17
- package/dist/index.es45.js.map +1 -1
- package/dist/index.es46.js +6 -229
- package/dist/index.es46.js.map +1 -1
- package/dist/index.es47.js +146 -15
- package/dist/index.es47.js.map +1 -1
- package/dist/index.es49.js +7 -90
- package/dist/index.es49.js.map +1 -1
- package/dist/index.es50.js +92 -6
- package/dist/index.es50.js.map +1 -1
- package/dist/index.es51.js +3 -14
- package/dist/index.es51.js.map +1 -1
- package/dist/index.es52.js +36 -8
- package/dist/index.es52.js.map +1 -1
- package/dist/index.es53.js +61 -83
- package/dist/index.es53.js.map +1 -1
- package/dist/index.es54.js +37 -3
- package/dist/index.es54.js.map +1 -1
- package/dist/index.es55.js +304 -34
- package/dist/index.es55.js.map +1 -1
- package/dist/index.es56.js +9 -72
- package/dist/index.es56.js.map +1 -1
- package/dist/index.es57.js +85 -32
- package/dist/index.es57.js.map +1 -1
- package/dist/index.es58.js +6 -304
- package/dist/index.es58.js.map +1 -1
- package/dist/index.es59.js +15 -9
- package/dist/index.es59.js.map +1 -1
- package/dist/index.es60.js +142 -5
- package/dist/index.es60.js.map +1 -1
- package/dist/index.es61.js +285 -148
- package/dist/index.es61.js.map +1 -1
- package/dist/index.es62.js +62 -668
- package/dist/index.es62.js.map +1 -1
- package/dist/index.es63.js +201 -131
- package/dist/index.es63.js.map +1 -1
- package/dist/index.es64.js +29 -295
- package/dist/index.es64.js.map +1 -1
- package/dist/index.es65.js +8 -65
- package/dist/index.es65.js.map +1 -1
- package/dist/index.es66.js +9 -210
- package/dist/index.es66.js.map +1 -1
- package/dist/index.es67.js +181 -28
- package/dist/index.es67.js.map +1 -1
- package/dist/index.es68.js +23 -8
- package/dist/index.es68.js.map +1 -1
- package/dist/index.es69.js +1397 -9
- package/dist/index.es69.js.map +1 -1
- package/dist/index.es70.js +9 -187
- package/dist/index.es70.js.map +1 -1
- package/dist/index.es71.js +8 -24
- package/dist/index.es71.js.map +1 -1
- package/dist/index.es72.js +5 -1399
- package/dist/index.es72.js.map +1 -1
- package/dist/index.es73.js +163 -9
- package/dist/index.es73.js.map +1 -1
- package/dist/index.es74.js +672 -8
- package/dist/index.es74.js.map +1 -1
- package/dist/index.es75.js +11 -36
- package/dist/index.es75.js.map +1 -1
- package/dist/index.es76.js +40 -5
- package/dist/index.es76.js.map +1 -1
- package/dist/index.es77.js +32 -71
- package/dist/index.es77.js.map +1 -1
- package/dist/index.es78.js +225 -30
- package/dist/index.es78.js.map +1 -1
- package/dist/index.es79.js +29 -11
- package/dist/index.es79.js.map +1 -1
- package/dist/index.es80.js +72 -37
- package/dist/index.es80.js.map +1 -1
- package/dist/index.es81.js +74 -32
- package/dist/index.es81.js.map +1 -1
- package/dist/index.es82.js +46 -226
- package/dist/index.es82.js.map +1 -1
- package/dist/index.es83.js +6 -6
- package/dist/index.es83.js.map +1 -1
- package/dist/index.es84.js +39 -71
- package/dist/index.es84.js.map +1 -1
- package/dist/index.es85.js +54 -73
- package/dist/index.es85.js.map +1 -1
- package/dist/index.es86.js +13 -52
- package/dist/index.es86.js.map +1 -1
- package/dist/index.es87.js +135 -28
- package/dist/index.es87.js.map +1 -1
- package/dist/index.es88.js +20 -42
- package/dist/index.es88.js.map +1 -1
- package/dist/index.es89.js +175 -50
- package/dist/index.es89.js.map +1 -1
- package/dist/index.es90.js +240 -12
- package/dist/index.es90.js.map +1 -1
- package/dist/index.es91.js +348 -130
- package/dist/index.es91.js.map +1 -1
- package/dist/index.es92.js +134 -18
- package/dist/index.es92.js.map +1 -1
- package/dist/index.es93.js +62 -174
- package/dist/index.es93.js.map +1 -1
- package/dist/index.es94.js +30 -234
- package/dist/index.es94.js.map +1 -1
- package/dist/index.es95.js +26 -344
- package/dist/index.es95.js.map +1 -1
- package/dist/index.es96.js +156 -127
- package/dist/index.es96.js.map +1 -1
- package/dist/index.es97.js +196 -63
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +14 -37
- package/dist/index.es98.js.map +1 -1
- package/dist/index.es99.js +27 -34
- package/dist/index.es99.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es92.js
CHANGED
|
@@ -1,24 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { isNetworkError } from "./index.es118.js";
|
|
2
|
+
function validateRetries(retries) {
|
|
3
|
+
if (typeof retries === "number") {
|
|
4
|
+
if (retries < 0) throw new TypeError("Expected `retries` to be a non-negative number.");
|
|
5
|
+
if (Number.isNaN(retries)) throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
|
|
6
|
+
} else if (retries !== void 0) throw new TypeError("Expected `retries` to be a number or Infinity.");
|
|
7
|
+
}
|
|
8
|
+
function validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) {
|
|
9
|
+
if (value === void 0) return;
|
|
10
|
+
if (typeof value !== "number" || Number.isNaN(value)) throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
|
|
11
|
+
if (!allowInfinity && !Number.isFinite(value)) throw new TypeError(`Expected \`${name}\` to be a finite number.`);
|
|
12
|
+
if (value < min) throw new TypeError(`Expected \`${name}\` to be ≥ ${min}.`);
|
|
13
|
+
}
|
|
14
|
+
var AbortError = class extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super();
|
|
17
|
+
if (message instanceof Error) {
|
|
18
|
+
this.originalError = message;
|
|
19
|
+
({ message } = message);
|
|
20
|
+
} else {
|
|
21
|
+
this.originalError = new Error(message);
|
|
22
|
+
this.originalError.stack = this.stack;
|
|
23
|
+
}
|
|
24
|
+
this.name = "AbortError";
|
|
25
|
+
this.message = message;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function calculateDelay(retriesConsumed, options) {
|
|
29
|
+
const attempt = Math.max(1, retriesConsumed + 1);
|
|
30
|
+
const random = options.randomize ? Math.random() + 1 : 1;
|
|
31
|
+
let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
|
|
32
|
+
timeout = Math.min(timeout, options.maxTimeout);
|
|
33
|
+
return timeout;
|
|
34
|
+
}
|
|
35
|
+
function calculateRemainingTime(start, max) {
|
|
36
|
+
if (!Number.isFinite(max)) return max;
|
|
37
|
+
return max - (performance.now() - start);
|
|
38
|
+
}
|
|
39
|
+
async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {
|
|
40
|
+
const normalizedError = error instanceof Error ? error : /* @__PURE__ */ new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
|
|
41
|
+
if (normalizedError instanceof AbortError) throw normalizedError.originalError;
|
|
42
|
+
const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
|
|
43
|
+
const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
|
|
44
|
+
const context = Object.freeze({
|
|
45
|
+
error: normalizedError,
|
|
46
|
+
attemptNumber,
|
|
47
|
+
retriesLeft,
|
|
48
|
+
retriesConsumed
|
|
49
|
+
});
|
|
50
|
+
await options.onFailedAttempt(context);
|
|
51
|
+
if (calculateRemainingTime(startTime, maxRetryTime) <= 0) throw normalizedError;
|
|
52
|
+
const consumeRetry = await options.shouldConsumeRetry(context);
|
|
53
|
+
const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
|
|
54
|
+
if (remainingTime <= 0 || retriesLeft <= 0) throw normalizedError;
|
|
55
|
+
if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
|
|
56
|
+
if (consumeRetry) throw normalizedError;
|
|
57
|
+
options.signal?.throwIfAborted();
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (!await options.shouldRetry(context)) throw normalizedError;
|
|
61
|
+
if (!consumeRetry) {
|
|
62
|
+
options.signal?.throwIfAborted();
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const delayTime = calculateDelay(retriesConsumed, options);
|
|
66
|
+
const finalDelay = Math.min(delayTime, remainingTime);
|
|
67
|
+
if (finalDelay > 0) await new Promise((resolve, reject) => {
|
|
68
|
+
const onAbort = () => {
|
|
69
|
+
clearTimeout(timeoutToken);
|
|
70
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
71
|
+
reject(options.signal.reason);
|
|
10
72
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
73
|
+
const timeoutToken = setTimeout(() => {
|
|
74
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
75
|
+
resolve();
|
|
76
|
+
}, finalDelay);
|
|
77
|
+
if (options.unref) timeoutToken.unref?.();
|
|
78
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
79
|
+
});
|
|
80
|
+
options.signal?.throwIfAborted();
|
|
81
|
+
return true;
|
|
14
82
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
83
|
+
async function pRetry(input, options = {}) {
|
|
84
|
+
options = { ...options };
|
|
85
|
+
validateRetries(options.retries);
|
|
86
|
+
if (Object.hasOwn(options, "forever")) throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
|
|
87
|
+
options.retries ??= 10;
|
|
88
|
+
options.factor ??= 2;
|
|
89
|
+
options.minTimeout ??= 1e3;
|
|
90
|
+
options.maxTimeout ??= Number.POSITIVE_INFINITY;
|
|
91
|
+
options.maxRetryTime ??= Number.POSITIVE_INFINITY;
|
|
92
|
+
options.randomize ??= false;
|
|
93
|
+
options.onFailedAttempt ??= () => {
|
|
94
|
+
};
|
|
95
|
+
options.shouldRetry ??= () => true;
|
|
96
|
+
options.shouldConsumeRetry ??= () => true;
|
|
97
|
+
validateNumberOption("factor", options.factor, {
|
|
98
|
+
min: 0,
|
|
99
|
+
allowInfinity: false
|
|
100
|
+
});
|
|
101
|
+
validateNumberOption("minTimeout", options.minTimeout, {
|
|
102
|
+
min: 0,
|
|
103
|
+
allowInfinity: false
|
|
104
|
+
});
|
|
105
|
+
validateNumberOption("maxTimeout", options.maxTimeout, {
|
|
106
|
+
min: 0,
|
|
107
|
+
allowInfinity: true
|
|
108
|
+
});
|
|
109
|
+
validateNumberOption("maxRetryTime", options.maxRetryTime, {
|
|
110
|
+
min: 0,
|
|
111
|
+
allowInfinity: true
|
|
112
|
+
});
|
|
113
|
+
if (!(options.factor > 0)) options.factor = 1;
|
|
114
|
+
options.signal?.throwIfAborted();
|
|
115
|
+
let attemptNumber = 0;
|
|
116
|
+
let retriesConsumed = 0;
|
|
117
|
+
const startTime = performance.now();
|
|
118
|
+
while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
|
|
119
|
+
attemptNumber++;
|
|
120
|
+
try {
|
|
121
|
+
options.signal?.throwIfAborted();
|
|
122
|
+
const result = await input(attemptNumber);
|
|
123
|
+
options.signal?.throwIfAborted();
|
|
124
|
+
return result;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (await onAttemptFailure({
|
|
127
|
+
error,
|
|
128
|
+
attemptNumber,
|
|
129
|
+
retriesConsumed,
|
|
130
|
+
startTime,
|
|
131
|
+
options
|
|
132
|
+
})) retriesConsumed++;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
throw new Error("Retry attempts exhausted without throwing an error.");
|
|
19
136
|
}
|
|
20
137
|
export {
|
|
21
|
-
|
|
22
|
-
raceWithSignal
|
|
138
|
+
pRetry
|
|
23
139
|
};
|
|
24
140
|
//# sourceMappingURL=index.es92.js.map
|
package/dist/index.es92.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es92.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/
|
|
1
|
+
{"version":3,"file":"index.es92.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/p-retry/index.js"],"sourcesContent":["import { isNetworkError } from \"../is-network-error/index.js\";\n\n//#region src/utils/p-retry/index.js\nfunction validateRetries(retries) {\n\tif (typeof retries === \"number\") {\n\t\tif (retries < 0) throw new TypeError(\"Expected `retries` to be a non-negative number.\");\n\t\tif (Number.isNaN(retries)) throw new TypeError(\"Expected `retries` to be a valid number or Infinity, got NaN.\");\n\t} else if (retries !== void 0) throw new TypeError(\"Expected `retries` to be a number or Infinity.\");\n}\nfunction validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) {\n\tif (value === void 0) return;\n\tif (typeof value !== \"number\" || Number.isNaN(value)) throw new TypeError(`Expected \\`${name}\\` to be a number${allowInfinity ? \" or Infinity\" : \"\"}.`);\n\tif (!allowInfinity && !Number.isFinite(value)) throw new TypeError(`Expected \\`${name}\\` to be a finite number.`);\n\tif (value < min) throw new TypeError(`Expected \\`${name}\\` to be \\u2265 ${min}.`);\n}\nvar AbortError = class extends Error {\n\tconstructor(message) {\n\t\tsuper();\n\t\tif (message instanceof Error) {\n\t\t\tthis.originalError = message;\n\t\t\t({message} = message);\n\t\t} else {\n\t\t\tthis.originalError = new Error(message);\n\t\t\tthis.originalError.stack = this.stack;\n\t\t}\n\t\tthis.name = \"AbortError\";\n\t\tthis.message = message;\n\t}\n};\nfunction calculateDelay(retriesConsumed, options) {\n\tconst attempt = Math.max(1, retriesConsumed + 1);\n\tconst random = options.randomize ? Math.random() + 1 : 1;\n\tlet timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));\n\ttimeout = Math.min(timeout, options.maxTimeout);\n\treturn timeout;\n}\nfunction calculateRemainingTime(start, max) {\n\tif (!Number.isFinite(max)) return max;\n\treturn max - (performance.now() - start);\n}\nasync function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {\n\tconst normalizedError = error instanceof Error ? error : /* @__PURE__ */ new TypeError(`Non-error was thrown: \"${error}\". You should only throw errors.`);\n\tif (normalizedError instanceof AbortError) throw normalizedError.originalError;\n\tconst retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;\n\tconst maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;\n\tconst context = Object.freeze({\n\t\terror: normalizedError,\n\t\tattemptNumber,\n\t\tretriesLeft,\n\t\tretriesConsumed\n\t});\n\tawait options.onFailedAttempt(context);\n\tif (calculateRemainingTime(startTime, maxRetryTime) <= 0) throw normalizedError;\n\tconst consumeRetry = await options.shouldConsumeRetry(context);\n\tconst remainingTime = calculateRemainingTime(startTime, maxRetryTime);\n\tif (remainingTime <= 0 || retriesLeft <= 0) throw normalizedError;\n\tif (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {\n\t\tif (consumeRetry) throw normalizedError;\n\t\toptions.signal?.throwIfAborted();\n\t\treturn false;\n\t}\n\tif (!await options.shouldRetry(context)) throw normalizedError;\n\tif (!consumeRetry) {\n\t\toptions.signal?.throwIfAborted();\n\t\treturn false;\n\t}\n\tconst delayTime = calculateDelay(retriesConsumed, options);\n\tconst finalDelay = Math.min(delayTime, remainingTime);\n\tif (finalDelay > 0) await new Promise((resolve, reject) => {\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeoutToken);\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\treject(options.signal.reason);\n\t\t};\n\t\tconst timeoutToken = setTimeout(() => {\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, finalDelay);\n\t\tif (options.unref) timeoutToken.unref?.();\n\t\toptions.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\toptions.signal?.throwIfAborted();\n\treturn true;\n}\nasync function pRetry(input, options = {}) {\n\toptions = { ...options };\n\tvalidateRetries(options.retries);\n\tif (Object.hasOwn(options, \"forever\")) throw new Error(\"The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.\");\n\toptions.retries ??= 10;\n\toptions.factor ??= 2;\n\toptions.minTimeout ??= 1e3;\n\toptions.maxTimeout ??= Number.POSITIVE_INFINITY;\n\toptions.maxRetryTime ??= Number.POSITIVE_INFINITY;\n\toptions.randomize ??= false;\n\toptions.onFailedAttempt ??= () => {};\n\toptions.shouldRetry ??= () => true;\n\toptions.shouldConsumeRetry ??= () => true;\n\tvalidateNumberOption(\"factor\", options.factor, {\n\t\tmin: 0,\n\t\tallowInfinity: false\n\t});\n\tvalidateNumberOption(\"minTimeout\", options.minTimeout, {\n\t\tmin: 0,\n\t\tallowInfinity: false\n\t});\n\tvalidateNumberOption(\"maxTimeout\", options.maxTimeout, {\n\t\tmin: 0,\n\t\tallowInfinity: true\n\t});\n\tvalidateNumberOption(\"maxRetryTime\", options.maxRetryTime, {\n\t\tmin: 0,\n\t\tallowInfinity: true\n\t});\n\tif (!(options.factor > 0)) options.factor = 1;\n\toptions.signal?.throwIfAborted();\n\tlet attemptNumber = 0;\n\tlet retriesConsumed = 0;\n\tconst startTime = performance.now();\n\twhile (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {\n\t\tattemptNumber++;\n\t\ttry {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tconst result = await input(attemptNumber);\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (await onAttemptFailure({\n\t\t\t\terror,\n\t\t\t\tattemptNumber,\n\t\t\t\tretriesConsumed,\n\t\t\t\tstartTime,\n\t\t\t\toptions\n\t\t\t})) retriesConsumed++;\n\t\t}\n\t}\n\tthrow new Error(\"Retry attempts exhausted without throwing an error.\");\n}\n\n//#endregion\nexport { pRetry };\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";AAGA,SAAS,gBAAgB,SAAS;AACjC,MAAI,OAAO,YAAY,UAAU;AAChC,QAAI,UAAU,EAAG,OAAM,IAAI,UAAU,iDAAiD;AACtF,QAAI,OAAO,MAAM,OAAO,EAAG,OAAM,IAAI,UAAU,+DAA+D;AAAA,EAC/G,WAAW,YAAY,OAAQ,OAAM,IAAI,UAAU,gDAAgD;AACpG;AACA,SAAS,qBAAqB,MAAM,OAAO,EAAE,MAAM,GAAG,gBAAgB,MAAK,IAAK,IAAI;AACnF,MAAI,UAAU,OAAQ;AACtB,MAAI,OAAO,UAAU,YAAY,OAAO,MAAM,KAAK,EAAG,OAAM,IAAI,UAAU,cAAc,IAAI,oBAAoB,gBAAgB,iBAAiB,EAAE,GAAG;AACtJ,MAAI,CAAC,iBAAiB,CAAC,OAAO,SAAS,KAAK,EAAG,OAAM,IAAI,UAAU,cAAc,IAAI,2BAA2B;AAChH,MAAI,QAAQ,IAAK,OAAM,IAAI,UAAU,cAAc,IAAI,cAAmB,GAAG,GAAG;AACjF;AACA,IAAI,aAAa,cAAc,MAAM;AAAA,EACpC,YAAY,SAAS;AACpB,UAAK;AACL,QAAI,mBAAmB,OAAO;AAC7B,WAAK,gBAAgB;AACrB,OAAC,EAAC,QAAO,IAAI;AAAA,IACd,OAAO;AACN,WAAK,gBAAgB,IAAI,MAAM,OAAO;AACtC,WAAK,cAAc,QAAQ,KAAK;AAAA,IACjC;AACA,SAAK,OAAO;AACZ,SAAK,UAAU;AAAA,EAChB;AACD;AACA,SAAS,eAAe,iBAAiB,SAAS;AACjD,QAAM,UAAU,KAAK,IAAI,GAAG,kBAAkB,CAAC;AAC/C,QAAM,SAAS,QAAQ,YAAY,KAAK,OAAM,IAAK,IAAI;AACvD,MAAI,UAAU,KAAK,MAAM,SAAS,QAAQ,aAAa,QAAQ,WAAW,UAAU,EA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AkB;AACtB,QAAM,YAAY,YAAY,IAAG;AACjC,SAAO,OAAO,SAAS,QAAQ,OAAO,IAAI,mBAAmB,QAAQ,UAAU,MAAM;AACpF;AACA,QAAI;AACH,cAAQ,QAAQ,eAAc;AAC9B,YAAM,SAAS,MAAM,MAAM,aAAa;AACxC,cAAQ,QAAQ,eAAc;AAC9B,aAAO;AAAA,IACR,SAAS,OAAO;AACf,UAAI,MAAM,iBAAiB;AAAA,QAC1B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACJ,CAAI,EAAG;AAAA,IACL;AAAA,EACD;AACA,QAAM,IAAI,MAAM,qDAAqD;AACtE;","x_google_ignoreList":[0]}
|
package/dist/index.es93.js
CHANGED
|
@@ -1,185 +1,73 @@
|
|
|
1
|
-
import { __export } from "./index.
|
|
2
|
-
import {
|
|
3
|
-
import "./index.
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
value: void 0
|
|
28
|
-
};
|
|
29
|
-
} else return {
|
|
30
|
-
done: false,
|
|
31
|
-
value: result.value
|
|
32
|
-
};
|
|
33
|
-
} catch (e) {
|
|
34
|
-
this.reader.releaseLock();
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async return() {
|
|
39
|
-
this.ensureReader();
|
|
40
|
-
if (this.locked) {
|
|
41
|
-
const cancelPromise = this.reader.cancel();
|
|
42
|
-
this.reader.releaseLock();
|
|
43
|
-
await cancelPromise;
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
done: true,
|
|
47
|
-
value: void 0
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
async throw(e) {
|
|
51
|
-
this.ensureReader();
|
|
52
|
-
if (this.locked) {
|
|
53
|
-
const cancelPromise = this.reader.cancel();
|
|
54
|
-
this.reader.releaseLock();
|
|
55
|
-
await cancelPromise;
|
|
56
|
-
}
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
|
-
[Symbol.asyncIterator]() {
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
async [Symbol.asyncDispose]() {
|
|
63
|
-
await this.return();
|
|
64
|
-
}
|
|
65
|
-
static fromReadableStream(stream) {
|
|
66
|
-
const reader = stream.getReader();
|
|
67
|
-
return new IterableReadableStream2({
|
|
68
|
-
start(controller) {
|
|
69
|
-
return pump();
|
|
70
|
-
function pump() {
|
|
71
|
-
return reader.read().then(({ done, value }) => {
|
|
72
|
-
if (done) {
|
|
73
|
-
controller.close();
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
controller.enqueue(value);
|
|
77
|
-
return pump();
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
cancel() {
|
|
82
|
-
reader.releaseLock();
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
static fromAsyncGenerator(generator) {
|
|
87
|
-
return new IterableReadableStream2({
|
|
88
|
-
async pull(controller) {
|
|
89
|
-
const { value, done } = await generator.next();
|
|
90
|
-
if (done) controller.close();
|
|
91
|
-
controller.enqueue(value);
|
|
92
|
-
},
|
|
93
|
-
async cancel(reason) {
|
|
94
|
-
await generator.return(reason);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
1
|
+
import { __export } from "./index.es49.js";
|
|
2
|
+
import { getAbortSignalError } from "./index.es88.js";
|
|
3
|
+
import { pRetry } from "./index.es92.js";
|
|
4
|
+
import PQueueMod from "./index.es110.js";
|
|
5
|
+
var async_caller_exports = {};
|
|
6
|
+
__export(async_caller_exports, { AsyncCaller: () => AsyncCaller });
|
|
7
|
+
const STATUS_NO_RETRY = [
|
|
8
|
+
400,
|
|
9
|
+
401,
|
|
10
|
+
402,
|
|
11
|
+
403,
|
|
12
|
+
404,
|
|
13
|
+
405,
|
|
14
|
+
406,
|
|
15
|
+
407,
|
|
16
|
+
409
|
|
17
|
+
];
|
|
18
|
+
const defaultFailedAttemptHandler = (error) => {
|
|
19
|
+
if (error.message.startsWith("Cancel") || error.message.startsWith("AbortError") || error.name === "AbortError") throw error;
|
|
20
|
+
if (error?.code === "ECONNABORTED") throw error;
|
|
21
|
+
const status = error?.response?.status ?? error?.status;
|
|
22
|
+
if (status && STATUS_NO_RETRY.includes(+status)) throw error;
|
|
23
|
+
if (error?.error?.code === "insufficient_quota") {
|
|
24
|
+
const err = new Error(error?.message);
|
|
25
|
+
err.name = "InsufficientQuotaError";
|
|
26
|
+
throw err;
|
|
97
27
|
}
|
|
98
28
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
for (const buffer$1 of buffers) buffer$1.push(result);
|
|
105
|
-
} else if (buffer[0].done) return;
|
|
106
|
-
else yield buffer.shift().value;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function concat(first, second) {
|
|
110
|
-
if (Array.isArray(first) && Array.isArray(second)) return first.concat(second);
|
|
111
|
-
else if (typeof first === "string" && typeof second === "string") return first + second;
|
|
112
|
-
else if (typeof first === "number" && typeof second === "number") return first + second;
|
|
113
|
-
else if ("concat" in first && typeof first.concat === "function") return first.concat(second);
|
|
114
|
-
else if (typeof first === "object" && typeof second === "object") {
|
|
115
|
-
const chunk = { ...first };
|
|
116
|
-
for (const [key, value] of Object.entries(second)) if (key in chunk && !Array.isArray(chunk[key])) chunk[key] = concat(chunk[key], value);
|
|
117
|
-
else chunk[key] = value;
|
|
118
|
-
return chunk;
|
|
119
|
-
} else throw new Error(`Cannot concat ${typeof first} and ${typeof second}`);
|
|
120
|
-
}
|
|
121
|
-
var AsyncGeneratorWithSetup = class {
|
|
122
|
-
generator;
|
|
123
|
-
setup;
|
|
124
|
-
config;
|
|
125
|
-
signal;
|
|
126
|
-
firstResult;
|
|
127
|
-
firstResultUsed = false;
|
|
29
|
+
var AsyncCaller = class {
|
|
30
|
+
maxConcurrency;
|
|
31
|
+
maxRetries;
|
|
32
|
+
onFailedAttempt;
|
|
33
|
+
queue;
|
|
128
34
|
constructor(params) {
|
|
129
|
-
this.
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.firstResult = params.generator.next();
|
|
135
|
-
if (params.startSetup) this.firstResult.then(params.startSetup).then(resolve, reject);
|
|
136
|
-
else this.firstResult.then((_result) => resolve(void 0), reject);
|
|
137
|
-
}, true);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
async next(...args) {
|
|
141
|
-
this.signal?.throwIfAborted();
|
|
142
|
-
if (!this.firstResultUsed) {
|
|
143
|
-
this.firstResultUsed = true;
|
|
144
|
-
return this.firstResult;
|
|
145
|
-
}
|
|
146
|
-
return AsyncLocalStorageProviderSingleton.runWithConfig(pickRunnableConfigKeys(this.config), this.signal ? async () => {
|
|
147
|
-
return raceWithSignal(this.generator.next(...args), this.signal);
|
|
148
|
-
} : async () => {
|
|
149
|
-
return this.generator.next(...args);
|
|
150
|
-
}, true);
|
|
151
|
-
}
|
|
152
|
-
async return(value) {
|
|
153
|
-
return this.generator.return(value);
|
|
35
|
+
this.maxConcurrency = params.maxConcurrency ?? Infinity;
|
|
36
|
+
this.maxRetries = params.maxRetries ?? 6;
|
|
37
|
+
this.onFailedAttempt = params.onFailedAttempt ?? defaultFailedAttemptHandler;
|
|
38
|
+
const PQueue = "default" in PQueueMod ? PQueueMod.default : PQueueMod;
|
|
39
|
+
this.queue = new PQueue({ concurrency: this.maxConcurrency });
|
|
154
40
|
}
|
|
155
|
-
async
|
|
156
|
-
return this.
|
|
41
|
+
async call(callable, ...args) {
|
|
42
|
+
return this.queue.add(() => pRetry(() => callable(...args).catch((error) => {
|
|
43
|
+
if (error instanceof Error) throw error;
|
|
44
|
+
else throw new Error(error);
|
|
45
|
+
}), {
|
|
46
|
+
onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),
|
|
47
|
+
retries: this.maxRetries,
|
|
48
|
+
randomize: true
|
|
49
|
+
}), { throwOnTimeout: true });
|
|
157
50
|
}
|
|
158
|
-
|
|
159
|
-
|
|
51
|
+
callWithOptions(options, callable, ...args) {
|
|
52
|
+
if (options.signal) {
|
|
53
|
+
let listener;
|
|
54
|
+
return Promise.race([this.call(callable, ...args), new Promise((_, reject) => {
|
|
55
|
+
listener = () => {
|
|
56
|
+
reject(getAbortSignalError(options.signal));
|
|
57
|
+
};
|
|
58
|
+
options.signal?.addEventListener("abort", listener);
|
|
59
|
+
})]).finally(() => {
|
|
60
|
+
if (options.signal && listener) options.signal.removeEventListener("abort", listener);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return this.call(callable, ...args);
|
|
160
64
|
}
|
|
161
|
-
|
|
162
|
-
|
|
65
|
+
fetch(...args) {
|
|
66
|
+
return this.call(() => fetch(...args).then((res) => res.ok ? res : Promise.reject(res)));
|
|
163
67
|
}
|
|
164
68
|
};
|
|
165
|
-
async function pipeGeneratorWithSetup(to, generator, startSetup, signal, ...args) {
|
|
166
|
-
const gen = new AsyncGeneratorWithSetup({
|
|
167
|
-
generator,
|
|
168
|
-
startSetup,
|
|
169
|
-
signal
|
|
170
|
-
});
|
|
171
|
-
const setup = await gen.setup;
|
|
172
|
-
return {
|
|
173
|
-
output: to(gen, setup, ...args),
|
|
174
|
-
setup
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
69
|
export {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
atee,
|
|
181
|
-
concat,
|
|
182
|
-
pipeGeneratorWithSetup,
|
|
183
|
-
stream_exports
|
|
70
|
+
AsyncCaller,
|
|
71
|
+
async_caller_exports
|
|
184
72
|
};
|
|
185
73
|
//# sourceMappingURL=index.es93.js.map
|
package/dist/index.es93.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es93.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/
|
|
1
|
+
{"version":3,"file":"index.es93.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/async_caller.js"],"sourcesContent":["import { __export } from \"../_virtual/rolldown_runtime.js\";\nimport { getAbortSignalError } from \"./signal.js\";\nimport { pRetry } from \"./p-retry/index.js\";\nimport PQueueMod from \"p-queue\";\n\n//#region src/utils/async_caller.ts\nvar async_caller_exports = {};\n__export(async_caller_exports, { AsyncCaller: () => AsyncCaller });\nconst STATUS_NO_RETRY = [\n\t400,\n\t401,\n\t402,\n\t403,\n\t404,\n\t405,\n\t406,\n\t407,\n\t409\n];\nconst defaultFailedAttemptHandler = (error) => {\n\tif (error.message.startsWith(\"Cancel\") || error.message.startsWith(\"AbortError\") || error.name === \"AbortError\") throw error;\n\tif (error?.code === \"ECONNABORTED\") throw error;\n\tconst status = error?.response?.status ?? error?.status;\n\tif (status && STATUS_NO_RETRY.includes(+status)) throw error;\n\tif (error?.error?.code === \"insufficient_quota\") {\n\t\tconst err = new Error(error?.message);\n\t\terr.name = \"InsufficientQuotaError\";\n\t\tthrow err;\n\t}\n};\n/**\n* A class that can be used to make async calls with concurrency and retry logic.\n*\n* This is useful for making calls to any kind of \"expensive\" external resource,\n* be it because it's rate-limited, subject to network issues, etc.\n*\n* Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n* to `Infinity`. This means that by default, all calls will be made in parallel.\n*\n* Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n* means that by default, each call will be retried up to 6 times, with an\n* exponential backoff between each attempt.\n*/\nvar AsyncCaller = class {\n\tmaxConcurrency;\n\tmaxRetries;\n\tonFailedAttempt;\n\tqueue;\n\tconstructor(params) {\n\t\tthis.maxConcurrency = params.maxConcurrency ?? Infinity;\n\t\tthis.maxRetries = params.maxRetries ?? 6;\n\t\tthis.onFailedAttempt = params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\t\tconst PQueue = \"default\" in PQueueMod ? PQueueMod.default : PQueueMod;\n\t\tthis.queue = new PQueue({ concurrency: this.maxConcurrency });\n\t}\n\tasync call(callable, ...args) {\n\t\treturn this.queue.add(() => pRetry(() => callable(...args).catch((error) => {\n\t\t\tif (error instanceof Error) throw error;\n\t\t\telse throw new Error(error);\n\t\t}), {\n\t\t\tonFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n\t\t\tretries: this.maxRetries,\n\t\t\trandomize: true\n\t\t}), { throwOnTimeout: true });\n\t}\n\tcallWithOptions(options, callable, ...args) {\n\t\tif (options.signal) {\n\t\t\tlet listener;\n\t\t\treturn Promise.race([this.call(callable, ...args), new Promise((_, reject) => {\n\t\t\t\tlistener = () => {\n\t\t\t\t\treject(getAbortSignalError(options.signal));\n\t\t\t\t};\n\t\t\t\toptions.signal?.addEventListener(\"abort\", listener);\n\t\t\t})]).finally(() => {\n\t\t\t\tif (options.signal && listener) options.signal.removeEventListener(\"abort\", listener);\n\t\t\t});\n\t\t}\n\t\treturn this.call(callable, ...args);\n\t}\n\tfetch(...args) {\n\t\treturn this.call(() => fetch(...args).then((res) => res.ok ? res : Promise.reject(res)));\n\t}\n};\n\n//#endregion\nexport { AsyncCaller, async_caller_exports };\n//# sourceMappingURL=async_caller.js.map"],"names":[],"mappings":";;;;AAMG,IAAC,uBAAuB,CAAA;AAC3B,SAAS,sBAAsB,EAAE,aAAa,MAAM,YAAW,CAAE;AACjE,MAAM,kBAAkB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AACA,MAAM,8BAA8B,CAAC,UAAU;AAC9C,MAAI,MAAM,QAAQ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