@elaraai/east-py-datascience 0.0.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +18 -0
- package/README.md +104 -0
- package/dist/gp/gp.d.ts +398 -0
- package/dist/gp/gp.d.ts.map +1 -0
- package/dist/gp/gp.js +170 -0
- package/dist/gp/gp.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/lightgbm/lightgbm.d.ts +494 -0
- package/dist/lightgbm/lightgbm.d.ts.map +1 -0
- package/dist/lightgbm/lightgbm.js +155 -0
- package/dist/lightgbm/lightgbm.js.map +1 -0
- package/dist/mads/mads.d.ts +413 -0
- package/dist/mads/mads.d.ts.map +1 -0
- package/dist/mads/mads.js +221 -0
- package/dist/mads/mads.js.map +1 -0
- package/dist/ngboost/ngboost.d.ts +433 -0
- package/dist/ngboost/ngboost.d.ts.map +1 -0
- package/dist/ngboost/ngboost.js +178 -0
- package/dist/ngboost/ngboost.js.map +1 -0
- package/dist/optuna/optuna.d.ts +797 -0
- package/dist/optuna/optuna.d.ts.map +1 -0
- package/dist/optuna/optuna.js +268 -0
- package/dist/optuna/optuna.js.map +1 -0
- package/dist/scipy/scipy.d.ts +954 -0
- package/dist/scipy/scipy.d.ts.map +1 -0
- package/dist/scipy/scipy.js +287 -0
- package/dist/scipy/scipy.js.map +1 -0
- package/dist/shap/shap.d.ts +657 -0
- package/dist/shap/shap.d.ts.map +1 -0
- package/dist/shap/shap.js +241 -0
- package/dist/shap/shap.js.map +1 -0
- package/dist/simanneal/simanneal.d.ts +531 -0
- package/dist/simanneal/simanneal.d.ts.map +1 -0
- package/dist/simanneal/simanneal.js +231 -0
- package/dist/simanneal/simanneal.js.map +1 -0
- package/dist/sklearn/sklearn.d.ts +1272 -0
- package/dist/sklearn/sklearn.d.ts.map +1 -0
- package/dist/sklearn/sklearn.js +307 -0
- package/dist/sklearn/sklearn.js.map +1 -0
- package/dist/torch/torch.d.ts +658 -0
- package/dist/torch/torch.d.ts.map +1 -0
- package/dist/torch/torch.js +233 -0
- package/dist/torch/torch.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +81 -0
- package/dist/types.js.map +1 -0
- package/dist/xgboost/xgboost.d.ts +504 -0
- package/dist/xgboost/xgboost.d.ts.map +1 -0
- package/dist/xgboost/xgboost.js +177 -0
- package/dist/xgboost/xgboost.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sklearn.d.ts","sourceRoot":"","sources":["../../src/sklearn/sklearn.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAEH,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,UAAU,EACb,MAAM,eAAe,CAAC;AAQvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C;;GAEG;AACH,eAAO,MAAM,eAAe;IACxB,gEAAgE;;IAEhE,sCAAsC;;IAEtC,8DAA8D;;EAEhE,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,eAAe;IACxB,wBAAwB;;IAExB,oBAAoB;;IAEpB,sBAAsB;;IAEtB,kBAAkB;;EAEpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAC9B,yBAAyB;;IAEzB,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,qBAAqB;;YAErB,mCAAmC;;YAEnC,gCAAgC;;YAEhC,kCAAkC;;;QAmOlC,yCAAyC;;YArNzC,2BAA2B;;gBAEvB,uBAAuB;;gBAEvB,+BAA+B;;;YAGnC,yBAAyB;;gBAErB,uBAAuB;;gBAEvB,+BAA+B;;;YAGnC,2BAA2B;;gBAEvB,mCAAmC;;gBAEnC,+BAA+B;;gBAE/B,+BAA+B;;gBAE/B,+BAA+B;;;;QAiMnC,+BAA+B;;QAE/B,gDAAgD;;YArLhD,wBAAwB;;;;;;;;;;;;;YAExB,yBAAyB;;;;;;;;;;;;;;YAEzB,wBAAwB;;;;;;;;;;;;YAExB,iCAAiC;;;;;;;;;;;;;;;;QAiLjC,iCAAiC;;YAzKjC,4CAA4C;;gBAd5C,wBAAwB;;;;;;;;;;;;;gBAExB,yBAAyB;;;;;;;;;;;;;;gBAEzB,wBAAwB;;;;;;;;;;;;gBAExB,iCAAiC;;;;;;;;;;;;;;;;YAUjC,yEAAyE;;YAEzE,sCAAsC;;;;CAoNhC,CAAC"}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Scikit-learn platform functions for East.
|
|
7
|
+
*
|
|
8
|
+
* Provides core machine learning utilities: preprocessing, model selection, and metrics.
|
|
9
|
+
* Uses ONNX for model serialization to enable portable inference.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { East, StructType, VariantType, OptionType, IntegerType, BooleanType, FloatType, BlobType, ArrayType, StringType, } from "@elaraai/east";
|
|
14
|
+
import { VectorType, MatrixType, LabelVectorType } from "../types.js";
|
|
15
|
+
import { XGBoostConfigType } from "../xgboost/xgboost.js";
|
|
16
|
+
import { LightGBMConfigType } from "../lightgbm/lightgbm.js";
|
|
17
|
+
import { NGBoostConfigType } from "../ngboost/ngboost.js";
|
|
18
|
+
import { GPConfigType } from "../gp/gp.js";
|
|
19
|
+
// Re-export shared types for convenience
|
|
20
|
+
export { VectorType, MatrixType, LabelVectorType } from "../types.js";
|
|
21
|
+
// Re-export config types used in RegressorChain
|
|
22
|
+
export { XGBoostConfigType } from "../xgboost/xgboost.js";
|
|
23
|
+
export { LightGBMConfigType } from "../lightgbm/lightgbm.js";
|
|
24
|
+
export { NGBoostConfigType } from "../ngboost/ngboost.js";
|
|
25
|
+
export { GPConfigType } from "../gp/gp.js";
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Config Types
|
|
28
|
+
// ============================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for train/test split.
|
|
31
|
+
*/
|
|
32
|
+
export const SplitConfigType = StructType({
|
|
33
|
+
/** Proportion of data to include in test split (default 0.2) */
|
|
34
|
+
test_size: OptionType(FloatType),
|
|
35
|
+
/** Random seed for reproducibility */
|
|
36
|
+
random_state: OptionType(IntegerType),
|
|
37
|
+
/** Whether to shuffle data before splitting (default true) */
|
|
38
|
+
shuffle: OptionType(BooleanType),
|
|
39
|
+
});
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// Result Types
|
|
42
|
+
// ============================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Result of train/test split.
|
|
45
|
+
*/
|
|
46
|
+
export const SplitResultType = StructType({
|
|
47
|
+
/** Training features */
|
|
48
|
+
X_train: MatrixType,
|
|
49
|
+
/** Test features */
|
|
50
|
+
X_test: MatrixType,
|
|
51
|
+
/** Training labels */
|
|
52
|
+
y_train: VectorType,
|
|
53
|
+
/** Test labels */
|
|
54
|
+
y_test: VectorType,
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Regression metrics result.
|
|
58
|
+
*/
|
|
59
|
+
export const RegressionMetricsType = StructType({
|
|
60
|
+
/** Mean Squared Error */
|
|
61
|
+
mse: FloatType,
|
|
62
|
+
/** Root Mean Squared Error */
|
|
63
|
+
rmse: FloatType,
|
|
64
|
+
/** Mean Absolute Error */
|
|
65
|
+
mae: FloatType,
|
|
66
|
+
/** R-squared (coefficient of determination) */
|
|
67
|
+
r2: FloatType,
|
|
68
|
+
/** Mean Absolute Percentage Error */
|
|
69
|
+
mape: FloatType,
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* Classification metrics result.
|
|
73
|
+
*/
|
|
74
|
+
export const ClassificationMetricsType = StructType({
|
|
75
|
+
/** Accuracy score */
|
|
76
|
+
accuracy: FloatType,
|
|
77
|
+
/** Precision (weighted average) */
|
|
78
|
+
precision: FloatType,
|
|
79
|
+
/** Recall (weighted average) */
|
|
80
|
+
recall: FloatType,
|
|
81
|
+
/** F1 score (weighted average) */
|
|
82
|
+
f1: FloatType,
|
|
83
|
+
});
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Model Blob Types
|
|
86
|
+
// ============================================================================
|
|
87
|
+
/**
|
|
88
|
+
* Model blob type for serialized sklearn models.
|
|
89
|
+
*
|
|
90
|
+
* Each model type has its own variant case containing ONNX bytes and metadata.
|
|
91
|
+
*/
|
|
92
|
+
export const SklearnModelBlobType = VariantType({
|
|
93
|
+
/** StandardScaler model */
|
|
94
|
+
standard_scaler: StructType({
|
|
95
|
+
/** ONNX model bytes */
|
|
96
|
+
onnx: BlobType,
|
|
97
|
+
/** Number of input features */
|
|
98
|
+
n_features: IntegerType,
|
|
99
|
+
}),
|
|
100
|
+
/** MinMaxScaler model */
|
|
101
|
+
min_max_scaler: StructType({
|
|
102
|
+
/** ONNX model bytes */
|
|
103
|
+
onnx: BlobType,
|
|
104
|
+
/** Number of input features */
|
|
105
|
+
n_features: IntegerType,
|
|
106
|
+
}),
|
|
107
|
+
/** RegressorChain model */
|
|
108
|
+
regressor_chain: StructType({
|
|
109
|
+
/** Cloudpickle serialized chain */
|
|
110
|
+
data: BlobType,
|
|
111
|
+
/** Number of input features */
|
|
112
|
+
n_features: IntegerType,
|
|
113
|
+
/** Number of target outputs */
|
|
114
|
+
n_targets: IntegerType,
|
|
115
|
+
/** Base estimator type name */
|
|
116
|
+
base_estimator_type: StringType,
|
|
117
|
+
}),
|
|
118
|
+
});
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// RegressorChain Types
|
|
121
|
+
// ============================================================================
|
|
122
|
+
/**
|
|
123
|
+
* Base estimator configuration for RegressorChain.
|
|
124
|
+
* Variant carries both the estimator type AND its configuration.
|
|
125
|
+
*/
|
|
126
|
+
export const RegressorChainBaseConfigType = VariantType({
|
|
127
|
+
/** XGBoost regressor */
|
|
128
|
+
xgboost: XGBoostConfigType,
|
|
129
|
+
/** LightGBM regressor */
|
|
130
|
+
lightgbm: LightGBMConfigType,
|
|
131
|
+
/** NGBoost regressor */
|
|
132
|
+
ngboost: NGBoostConfigType,
|
|
133
|
+
/** Gaussian Process regressor */
|
|
134
|
+
gp: GPConfigType,
|
|
135
|
+
});
|
|
136
|
+
/**
|
|
137
|
+
* Configuration for RegressorChain.
|
|
138
|
+
*/
|
|
139
|
+
export const RegressorChainConfigType = StructType({
|
|
140
|
+
/** Base estimator with its configuration */
|
|
141
|
+
base_estimator: RegressorChainBaseConfigType,
|
|
142
|
+
/** Chain order (indices of targets). None = natural order [0,1,2,...] */
|
|
143
|
+
order: OptionType(ArrayType(IntegerType)),
|
|
144
|
+
/** Random seed for reproducibility */
|
|
145
|
+
random_state: OptionType(IntegerType),
|
|
146
|
+
});
|
|
147
|
+
// ============================================================================
|
|
148
|
+
// Platform Functions
|
|
149
|
+
// ============================================================================
|
|
150
|
+
/**
|
|
151
|
+
* Split arrays into train and test subsets.
|
|
152
|
+
*
|
|
153
|
+
* @param X - Feature matrix
|
|
154
|
+
* @param y - Target vector
|
|
155
|
+
* @param config - Split configuration
|
|
156
|
+
* @returns Split result with X_train, X_test, y_train, y_test
|
|
157
|
+
*/
|
|
158
|
+
export const sklearn_train_test_split = East.platform("sklearn_train_test_split", [MatrixType, VectorType, SplitConfigType], SplitResultType);
|
|
159
|
+
/**
|
|
160
|
+
* Fit a StandardScaler to training data.
|
|
161
|
+
*
|
|
162
|
+
* Standardizes features by removing the mean and scaling to unit variance.
|
|
163
|
+
*
|
|
164
|
+
* @param X - Training feature matrix
|
|
165
|
+
* @returns Model blob containing fitted scaler
|
|
166
|
+
*/
|
|
167
|
+
export const sklearn_standard_scaler_fit = East.platform("sklearn_standard_scaler_fit", [MatrixType], SklearnModelBlobType);
|
|
168
|
+
/**
|
|
169
|
+
* Transform data using a fitted StandardScaler.
|
|
170
|
+
*
|
|
171
|
+
* @param model - Fitted scaler model blob
|
|
172
|
+
* @param X - Feature matrix to transform
|
|
173
|
+
* @returns Transformed feature matrix
|
|
174
|
+
*/
|
|
175
|
+
export const sklearn_standard_scaler_transform = East.platform("sklearn_standard_scaler_transform", [SklearnModelBlobType, MatrixType], MatrixType);
|
|
176
|
+
/**
|
|
177
|
+
* Fit a MinMaxScaler to training data.
|
|
178
|
+
*
|
|
179
|
+
* Scales features to a given range (default [0, 1]).
|
|
180
|
+
*
|
|
181
|
+
* @param X - Training feature matrix
|
|
182
|
+
* @returns Model blob containing fitted scaler
|
|
183
|
+
*/
|
|
184
|
+
export const sklearn_min_max_scaler_fit = East.platform("sklearn_min_max_scaler_fit", [MatrixType], SklearnModelBlobType);
|
|
185
|
+
/**
|
|
186
|
+
* Transform data using a fitted MinMaxScaler.
|
|
187
|
+
*
|
|
188
|
+
* @param model - Fitted scaler model blob
|
|
189
|
+
* @param X - Feature matrix to transform
|
|
190
|
+
* @returns Transformed feature matrix
|
|
191
|
+
*/
|
|
192
|
+
export const sklearn_min_max_scaler_transform = East.platform("sklearn_min_max_scaler_transform", [SklearnModelBlobType, MatrixType], MatrixType);
|
|
193
|
+
/**
|
|
194
|
+
* Compute regression metrics.
|
|
195
|
+
*
|
|
196
|
+
* @param y_true - True target values
|
|
197
|
+
* @param y_pred - Predicted target values
|
|
198
|
+
* @returns Regression metrics (MSE, RMSE, MAE, R2, MAPE)
|
|
199
|
+
*/
|
|
200
|
+
export const sklearn_metrics_regression = East.platform("sklearn_metrics_regression", [VectorType, VectorType], RegressionMetricsType);
|
|
201
|
+
/**
|
|
202
|
+
* Compute classification metrics.
|
|
203
|
+
*
|
|
204
|
+
* @param y_true - True class labels
|
|
205
|
+
* @param y_pred - Predicted class labels
|
|
206
|
+
* @returns Classification metrics (accuracy, precision, recall, F1)
|
|
207
|
+
*/
|
|
208
|
+
export const sklearn_metrics_classification = East.platform("sklearn_metrics_classification", [LabelVectorType, LabelVectorType], ClassificationMetricsType);
|
|
209
|
+
/**
|
|
210
|
+
* Multi-target output type for RegressorChain.
|
|
211
|
+
*/
|
|
212
|
+
export const MultiTargetType = ArrayType(ArrayType(FloatType));
|
|
213
|
+
/**
|
|
214
|
+
* Train a RegressorChain for multi-target regression.
|
|
215
|
+
*
|
|
216
|
+
* Each model in the chain uses previous targets as additional features,
|
|
217
|
+
* enabling modeling of dependencies between targets.
|
|
218
|
+
*
|
|
219
|
+
* @param X - Feature matrix
|
|
220
|
+
* @param Y - Target matrix (rows=samples, cols=targets)
|
|
221
|
+
* @param config - Chain configuration
|
|
222
|
+
* @returns Model blob containing fitted chain
|
|
223
|
+
*/
|
|
224
|
+
export const sklearn_regressor_chain_train = East.platform("sklearn_regressor_chain_train", [MatrixType, MultiTargetType, RegressorChainConfigType], SklearnModelBlobType);
|
|
225
|
+
/**
|
|
226
|
+
* Predict using a fitted RegressorChain.
|
|
227
|
+
*
|
|
228
|
+
* @param model - Fitted chain model blob
|
|
229
|
+
* @param X - Feature matrix to predict
|
|
230
|
+
* @returns Predicted target matrix
|
|
231
|
+
*/
|
|
232
|
+
export const sklearn_regressor_chain_predict = East.platform("sklearn_regressor_chain_predict", [SklearnModelBlobType, MatrixType], MultiTargetType);
|
|
233
|
+
// ============================================================================
|
|
234
|
+
// Grouped Export
|
|
235
|
+
// ============================================================================
|
|
236
|
+
/**
|
|
237
|
+
* Type definitions for sklearn functions.
|
|
238
|
+
*/
|
|
239
|
+
export const SklearnTypes = {
|
|
240
|
+
/** Vector type (array of floats) */
|
|
241
|
+
VectorType,
|
|
242
|
+
/** Matrix type (2D array of floats) */
|
|
243
|
+
MatrixType,
|
|
244
|
+
/** Label vector type (array of integers) */
|
|
245
|
+
LabelVectorType,
|
|
246
|
+
/** Split configuration type */
|
|
247
|
+
SplitConfigType,
|
|
248
|
+
/** Split result type */
|
|
249
|
+
SplitResultType,
|
|
250
|
+
/** Regression metrics type */
|
|
251
|
+
RegressionMetricsType,
|
|
252
|
+
/** Classification metrics type */
|
|
253
|
+
ClassificationMetricsType,
|
|
254
|
+
/** Model blob type for sklearn models */
|
|
255
|
+
ModelBlobType: SklearnModelBlobType,
|
|
256
|
+
/** Multi-target output type */
|
|
257
|
+
MultiTargetType,
|
|
258
|
+
/** RegressorChain base estimator config type */
|
|
259
|
+
RegressorChainBaseConfigType,
|
|
260
|
+
/** RegressorChain config type */
|
|
261
|
+
RegressorChainConfigType,
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Scikit-learn machine learning utilities.
|
|
265
|
+
*
|
|
266
|
+
* Provides preprocessing, model selection, and metrics for ML workflows.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* import { East, variant } from "@elaraai/east";
|
|
271
|
+
* import { Sklearn } from "@elaraai/east-py-datascience";
|
|
272
|
+
*
|
|
273
|
+
* const pipeline = East.function([], Sklearn.Types.SplitResultType, $ => {
|
|
274
|
+
* const X = $.let([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0], [7.0, 8.0]]);
|
|
275
|
+
* const y = $.let([1.0, 2.0, 3.0, 4.0]);
|
|
276
|
+
* const config = $.let({
|
|
277
|
+
* test_size: variant('some', 0.25),
|
|
278
|
+
* random_state: variant('some', 42n),
|
|
279
|
+
* shuffle: variant('some', true),
|
|
280
|
+
* });
|
|
281
|
+
* return $.return(Sklearn.trainTestSplit(X, y, config));
|
|
282
|
+
* });
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
export const Sklearn = {
|
|
286
|
+
/** Split arrays into train and test subsets */
|
|
287
|
+
trainTestSplit: sklearn_train_test_split,
|
|
288
|
+
/** Fit a StandardScaler to data */
|
|
289
|
+
standardScalerFit: sklearn_standard_scaler_fit,
|
|
290
|
+
/** Transform data using fitted StandardScaler */
|
|
291
|
+
standardScalerTransform: sklearn_standard_scaler_transform,
|
|
292
|
+
/** Fit a MinMaxScaler to data */
|
|
293
|
+
minMaxScalerFit: sklearn_min_max_scaler_fit,
|
|
294
|
+
/** Transform data using fitted MinMaxScaler */
|
|
295
|
+
minMaxScalerTransform: sklearn_min_max_scaler_transform,
|
|
296
|
+
/** Compute regression metrics */
|
|
297
|
+
metricsRegression: sklearn_metrics_regression,
|
|
298
|
+
/** Compute classification metrics */
|
|
299
|
+
metricsClassification: sklearn_metrics_classification,
|
|
300
|
+
/** Train a RegressorChain for multi-target regression */
|
|
301
|
+
regressorChainTrain: sklearn_regressor_chain_train,
|
|
302
|
+
/** Predict using a fitted RegressorChain */
|
|
303
|
+
regressorChainPredict: sklearn_regressor_chain_predict,
|
|
304
|
+
/** Type definitions */
|
|
305
|
+
Types: SklearnTypes,
|
|
306
|
+
};
|
|
307
|
+
//# sourceMappingURL=sklearn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sklearn.js","sourceRoot":"","sources":["../../src/sklearn/sklearn.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,UAAU,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EA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