@player-tools/fluent-generator 0.13.0--canary.221.5819

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.
@@ -0,0 +1,510 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/generators/fluent/src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ containsArrayType: () => containsArrayType,
24
+ extractGenericUsage: () => extractGenericUsage,
25
+ generateFluentBuilder: () => generateFluentBuilder,
26
+ getAssetTypeFromExtends: () => getAssetTypeFromExtends,
27
+ getPropertiesInfo: () => getPropertiesInfo,
28
+ isAndType: () => import_xlr_utils.isAndType,
29
+ isArrayType: () => import_xlr_utils.isArrayType,
30
+ isAssetWrapperRef: () => isAssetWrapperRef,
31
+ isBindingRef: () => isBindingRef,
32
+ isBooleanType: () => import_xlr_utils.isBooleanType,
33
+ isComplexObjectType: () => isComplexObjectType,
34
+ isExpressionRef: () => isExpressionRef,
35
+ isNamedType: () => import_xlr_utils.isNamedType,
36
+ isNumberType: () => import_xlr_utils.isNumberType,
37
+ isObjectType: () => import_xlr_utils.isObjectType,
38
+ isOrType: () => import_xlr_utils.isOrType,
39
+ isPrimitiveConst: () => isPrimitiveConst,
40
+ isRecordType: () => import_xlr_utils.isRecordType,
41
+ isRefType: () => import_xlr_utils.isRefType,
42
+ isStringType: () => import_xlr_utils.isStringType,
43
+ toBuilderClassName: () => toBuilderClassName,
44
+ toFactoryName: () => toFactoryName,
45
+ toPascalCase: () => toPascalCase
46
+ });
47
+ module.exports = __toCommonJS(src_exports);
48
+
49
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/generators/fluent/src/generator.ts
50
+ var import_xlr_utils2 = require("@player-tools/xlr-utils");
51
+
52
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/generators/fluent/src/utils.ts
53
+ var import_xlr_utils = require("@player-tools/xlr-utils");
54
+ function isPrimitiveConst(node) {
55
+ return ((0, import_xlr_utils.isStringType)(node) || (0, import_xlr_utils.isNumberType)(node) || (0, import_xlr_utils.isBooleanType)(node)) && "const" in node && node.const !== void 0;
56
+ }
57
+ function isAssetWrapperRef(node) {
58
+ return (0, import_xlr_utils.isRefType)(node) && node.ref.startsWith("AssetWrapper");
59
+ }
60
+ function isExpressionRef(node) {
61
+ return (0, import_xlr_utils.isRefType)(node) && node.ref === "Expression";
62
+ }
63
+ function isBindingRef(node) {
64
+ return (0, import_xlr_utils.isRefType)(node) && node.ref === "Binding";
65
+ }
66
+ function toPascalCase(str) {
67
+ return str.split(/[-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
68
+ }
69
+ function toFactoryName(typeName) {
70
+ const name = typeName.replace(/Asset$/, "");
71
+ return name.charAt(0).toLowerCase() + name.slice(1);
72
+ }
73
+ function toBuilderClassName(typeName) {
74
+ return `${typeName}Builder`;
75
+ }
76
+ function isComplexObjectType(obj) {
77
+ const props = Object.values(obj.properties);
78
+ const hasSlots = props.some((p) => isAssetWrapperRef(p.node));
79
+ if (hasSlots) return true;
80
+ if (props.length > 3) return true;
81
+ const hasNestedObjects = props.some(
82
+ (p) => (0, import_xlr_utils.isObjectType)(p.node) && !isPrimitiveConst(p.node)
83
+ );
84
+ if (hasNestedObjects) return true;
85
+ return false;
86
+ }
87
+ function getAssetTypeFromExtends(obj) {
88
+ if (!obj.extends) return void 0;
89
+ const ref = obj.extends;
90
+ if (ref.genericArguments && ref.genericArguments.length > 0) {
91
+ const typeArg = ref.genericArguments[0];
92
+ if ((0, import_xlr_utils.isStringType)(typeArg) && typeArg.const) {
93
+ return typeArg.const;
94
+ }
95
+ }
96
+ return void 0;
97
+ }
98
+ function getPropertiesInfo(obj) {
99
+ return Object.entries(obj.properties).map(([name, prop]) => {
100
+ const isSlot = isAssetWrapperRef(prop.node);
101
+ const isArray = (0, import_xlr_utils.isArrayType)(prop.node);
102
+ const isArraySlot = isArray && isAssetWrapperRef(prop.node.elementType);
103
+ return {
104
+ name,
105
+ node: prop.node,
106
+ required: prop.required,
107
+ isSlot,
108
+ isArraySlot,
109
+ isArray
110
+ };
111
+ });
112
+ }
113
+ function containsArrayType(node) {
114
+ if ((0, import_xlr_utils.isArrayType)(node)) {
115
+ return true;
116
+ }
117
+ if ((0, import_xlr_utils.isOrType)(node)) {
118
+ return node.or.some(containsArrayType);
119
+ }
120
+ if ((0, import_xlr_utils.isAndType)(node)) {
121
+ return node.and.some(containsArrayType);
122
+ }
123
+ return false;
124
+ }
125
+ function extractGenericUsage(genericParams) {
126
+ if (!genericParams) {
127
+ return "";
128
+ }
129
+ const params = genericParams.split(",").map((p) => p.trim().split(" ")[0]).join(", ");
130
+ return `<${params}>`;
131
+ }
132
+
133
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/generators/fluent/src/generator.ts
134
+ function extractBaseName(ref) {
135
+ const bracketIndex = ref.indexOf("<");
136
+ return bracketIndex === -1 ? ref : ref.substring(0, bracketIndex);
137
+ }
138
+ var FluentBuilderGenerator = class {
139
+ namedType;
140
+ config;
141
+ /** Track nested types that need their own builders */
142
+ nestedBuilders = /* @__PURE__ */ new Map();
143
+ /** Track array properties for __arrayProperties__ */
144
+ arrayProperties = /* @__PURE__ */ new Set();
145
+ /** Track all type references that need to be imported from the source type file */
146
+ referencedTypes = /* @__PURE__ */ new Set();
147
+ /** Track whether Asset type is needed for imports */
148
+ needsAssetImport = false;
149
+ constructor(namedType, config = {}) {
150
+ this.namedType = namedType;
151
+ this.config = config;
152
+ }
153
+ /**
154
+ * Generate the builder code
155
+ */
156
+ generate() {
157
+ const mainBuilder = this.createBuilderInfo(this.namedType);
158
+ this.collectNestedTypes(this.namedType);
159
+ const nestedBuilderCode = Array.from(this.nestedBuilders.entries()).map(([name, objType]) => {
160
+ const info = {
161
+ name,
162
+ className: toBuilderClassName(name),
163
+ factoryName: toFactoryName(name),
164
+ objectType: objType,
165
+ isAsset: false
166
+ };
167
+ return this.generateBuilderClass(info);
168
+ }).join("\n\n");
169
+ const mainBuilderCode = this.generateBuilderClass(mainBuilder);
170
+ const imports = this.generateImports(mainBuilder);
171
+ return [imports, nestedBuilderCode, mainBuilderCode].filter(Boolean).join("\n\n");
172
+ }
173
+ createBuilderInfo(namedType) {
174
+ const assetType = getAssetTypeFromExtends(namedType);
175
+ const isAsset = !!assetType;
176
+ let genericParams;
177
+ if ((0, import_xlr_utils2.isGenericNamedType)(namedType)) {
178
+ genericParams = namedType.genericTokens.map((t) => {
179
+ let param = t.symbol;
180
+ if (t.constraints) {
181
+ param += ` extends ${this.transformType(t.constraints)}`;
182
+ }
183
+ if (t.default) {
184
+ param += ` = ${this.transformType(t.default)}`;
185
+ }
186
+ return param;
187
+ }).join(", ");
188
+ }
189
+ return {
190
+ name: namedType.name,
191
+ className: toBuilderClassName(namedType.name),
192
+ factoryName: toFactoryName(namedType.name),
193
+ objectType: namedType,
194
+ assetType,
195
+ genericParams,
196
+ isAsset
197
+ };
198
+ }
199
+ generateImports(mainBuilder) {
200
+ const typeImportPath = this.config.typeImportPathGenerator ? this.config.typeImportPathGenerator(mainBuilder.name) : `../types/${this.getTypeFileName(mainBuilder.name)}`;
201
+ const typesToImport = /* @__PURE__ */ new Set([mainBuilder.name]);
202
+ Array.from(this.nestedBuilders.keys()).forEach((name) => {
203
+ typesToImport.add(name);
204
+ });
205
+ Array.from(this.referencedTypes).forEach((name) => {
206
+ typesToImport.add(name);
207
+ });
208
+ const typeImportStatement = `import type { ${Array.from(typesToImport).join(", ")} } from "${typeImportPath}";`;
209
+ const typesImportPath = this.config.typesImportPath ?? "@player-ui/types";
210
+ const fluentImportPath = this.config.fluentImportPath ?? "@player-tools/fluent";
211
+ const lines = [typeImportStatement];
212
+ if (this.needsAssetImport) {
213
+ lines.push(`import type { Asset } from "${typesImportPath}";`);
214
+ }
215
+ lines.push(
216
+ `import { type FluentBuilder, type BaseBuildContext, FluentBuilderBase, createInspectMethod, type TaggedTemplateValue } from "${fluentImportPath}";`
217
+ );
218
+ return lines.join("\n");
219
+ }
220
+ getTypeFileName(typeName) {
221
+ return typeName.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "").replace(/asset$/, "");
222
+ }
223
+ collectNestedTypes(objType) {
224
+ for (const [propName, prop] of Object.entries(objType.properties)) {
225
+ this.collectNestedTypesFromNode(prop.node, propName);
226
+ }
227
+ }
228
+ collectNestedTypesFromNode(node, parentName) {
229
+ if ((0, import_xlr_utils.isObjectType)(node)) {
230
+ if ((0, import_xlr_utils.isNamedType)(node) && isComplexObjectType(node)) {
231
+ this.nestedBuilders.set(node.name, node);
232
+ this.collectNestedTypes(node);
233
+ } else if (!(0, import_xlr_utils.isNamedType)(node) && isComplexObjectType(node)) {
234
+ const name = toPascalCase(parentName);
235
+ this.nestedBuilders.set(name, node);
236
+ this.collectNestedTypes(node);
237
+ } else if ((0, import_xlr_utils.isNamedType)(node)) {
238
+ this.referencedTypes.add(node.name);
239
+ }
240
+ } else if ((0, import_xlr_utils.isArrayType)(node)) {
241
+ this.collectNestedTypesFromNode(node.elementType, parentName);
242
+ } else if ((0, import_xlr_utils.isOrType)(node)) {
243
+ for (const variant of node.or) {
244
+ this.collectNestedTypesFromNode(variant, parentName);
245
+ }
246
+ } else if ((0, import_xlr_utils.isAndType)(node)) {
247
+ for (const part of node.and) {
248
+ this.collectNestedTypesFromNode(part, parentName);
249
+ }
250
+ } else if ((0, import_xlr_utils.isRefType)(node)) {
251
+ const baseName = extractBaseName(node.ref);
252
+ const builtInTypes = [
253
+ "Asset",
254
+ "AssetWrapper",
255
+ "Binding",
256
+ "Expression",
257
+ "Array",
258
+ "Record"
259
+ ];
260
+ if (!builtInTypes.includes(baseName)) {
261
+ this.referencedTypes.add(baseName);
262
+ }
263
+ }
264
+ }
265
+ generateBuilderClass(info) {
266
+ const {
267
+ name,
268
+ className,
269
+ factoryName,
270
+ objectType,
271
+ assetType,
272
+ genericParams
273
+ } = info;
274
+ this.arrayProperties.clear();
275
+ const genericPart = genericParams ? `<${genericParams}>` : "";
276
+ const genericUsage = extractGenericUsage(genericParams);
277
+ const interfaceCode = this.generateInterfaceMethods(info);
278
+ const classMethods = this.generateClassMethods(info);
279
+ const defaults = this.generateDefaults(objectType, assetType);
280
+ const arrayPropsCode = this.arrayProperties.size > 0 ? ` private static readonly __arrayProperties__: ReadonlySet<string> = new Set([${Array.from(
281
+ this.arrayProperties
282
+ ).map((p) => `"${p}"`).join(", ")}]);
283
+ ` : "";
284
+ const classCode = `
285
+ ${interfaceCode}
286
+
287
+ /**
288
+ * A builder for ${name}
289
+ */
290
+ export class ${className}${genericPart} extends FluentBuilderBase<${name}${genericUsage}> implements ${className}Methods${genericUsage}, FluentBuilder<${name}${genericUsage}, BaseBuildContext> {
291
+ private static readonly defaults: Record<string, unknown> = ${defaults};
292
+ ${arrayPropsCode}
293
+ ${classMethods}
294
+
295
+ /**
296
+ * Builds the final ${name} object
297
+ * @param context - Optional build context for nested builders
298
+ */
299
+ build(context?: BaseBuildContext): ${name}${genericUsage} {
300
+ return this.buildWithDefaults(${className}.defaults, context);
301
+ }
302
+
303
+ [Symbol.for("nodejs.util.inspect.custom")](): string {
304
+ return createInspectMethod("${className}", this.values);
305
+ }
306
+ }
307
+
308
+ /**
309
+ * Creates a new ${name} builder
310
+ * @param initial Optional initial values
311
+ * @returns A fluent builder for ${name}
312
+ */
313
+ export function ${factoryName}${genericPart}(initial?: Partial<${name}${genericUsage}>): ${className}${genericUsage} {
314
+ return new ${className}${genericUsage}(initial);
315
+ }`;
316
+ return classCode.trim();
317
+ }
318
+ generateInterfaceMethods(info) {
319
+ const { className, objectType, genericParams, isAsset } = info;
320
+ const genericUsage = extractGenericUsage(genericParams);
321
+ const properties = this.collectPropertiesForMethods(objectType, isAsset);
322
+ const methods = properties.map(({ propName, propType, description }) => {
323
+ const methodName = `with${toPascalCase(propName)}`;
324
+ const paramType = this.transformType(propType, true);
325
+ return ` /** ${description} */
326
+ ${methodName}(value: ${paramType}): ${className}${genericUsage};`;
327
+ }).join("\n");
328
+ return `export interface ${className}Methods${genericParams ? `<${genericParams}>` : ""} {
329
+ ${methods}
330
+ }`;
331
+ }
332
+ collectPropertiesForMethods(objectType, isAsset) {
333
+ const properties = [];
334
+ if (isAsset) {
335
+ properties.push({
336
+ propName: "id",
337
+ propType: { type: "string" },
338
+ description: "A unique identifier for this asset"
339
+ });
340
+ }
341
+ for (const [propName, prop] of Object.entries(objectType.properties)) {
342
+ properties.push({
343
+ propName,
344
+ propType: prop.node,
345
+ description: prop.node.description || `Sets the ${propName} property`
346
+ });
347
+ }
348
+ return properties;
349
+ }
350
+ generateClassMethods(info) {
351
+ const { className, objectType, genericParams, isAsset } = info;
352
+ const genericUsage = extractGenericUsage(genericParams);
353
+ const properties = this.collectPropertiesForMethods(objectType, isAsset);
354
+ return properties.map(({ propName, propType, description }) => {
355
+ const methodName = `with${toPascalCase(propName)}`;
356
+ const paramType = this.transformType(propType, true);
357
+ if (containsArrayType(propType)) {
358
+ this.arrayProperties.add(propName);
359
+ }
360
+ return ` /** ${description} */
361
+ ${methodName}(value: ${paramType}): ${className}${genericUsage} {
362
+ return this.set("${propName}", value);
363
+ }`;
364
+ }).join("\n\n");
365
+ }
366
+ generateDefaults(objectType, assetType) {
367
+ const defaults = {};
368
+ if (assetType) {
369
+ defaults["type"] = assetType;
370
+ }
371
+ if (objectType.extends?.ref.startsWith("Asset")) {
372
+ defaults["id"] = "";
373
+ } else if ("id" in objectType.properties) {
374
+ defaults["id"] = "";
375
+ }
376
+ for (const [propName, prop] of Object.entries(objectType.properties)) {
377
+ if (isPrimitiveConst(prop.node)) {
378
+ defaults[propName] = prop.node.const;
379
+ }
380
+ }
381
+ return JSON.stringify(defaults);
382
+ }
383
+ /**
384
+ * Transform an XLR type to a TypeScript type string
385
+ * This is the core recursive transformation that adds TaggedTemplateValue support
386
+ */
387
+ transformType(node, forParameter = false) {
388
+ if ((0, import_xlr_utils.isStringType)(node)) {
389
+ if (isPrimitiveConst(node)) {
390
+ return `"${node.const}"`;
391
+ }
392
+ return forParameter ? "string | TaggedTemplateValue<string>" : "string";
393
+ }
394
+ if ((0, import_xlr_utils.isNumberType)(node)) {
395
+ if (isPrimitiveConst(node)) {
396
+ return `${node.const}`;
397
+ }
398
+ return forParameter ? "number | TaggedTemplateValue<number>" : "number";
399
+ }
400
+ if ((0, import_xlr_utils.isBooleanType)(node)) {
401
+ if (isPrimitiveConst(node)) {
402
+ return `${node.const}`;
403
+ }
404
+ return forParameter ? "boolean | TaggedTemplateValue<boolean>" : "boolean";
405
+ }
406
+ if ((0, import_xlr_utils.isRefType)(node)) {
407
+ return this.transformRefType(node, forParameter);
408
+ }
409
+ if ((0, import_xlr_utils.isArrayType)(node)) {
410
+ const elementType = this.transformType(node.elementType, forParameter);
411
+ return `Array<${elementType}>`;
412
+ }
413
+ if ((0, import_xlr_utils.isOrType)(node)) {
414
+ const variants = node.or.map((v) => this.transformType(v, forParameter));
415
+ return variants.join(" | ");
416
+ }
417
+ if ((0, import_xlr_utils.isAndType)(node)) {
418
+ const parts = node.and.map((p) => this.transformType(p, forParameter));
419
+ return parts.join(" & ");
420
+ }
421
+ if ((0, import_xlr_utils.isRecordType)(node)) {
422
+ const keyType = this.transformType(node.keyType, false);
423
+ const valueType = this.transformType(node.valueType, forParameter);
424
+ return `Record<${keyType}, ${valueType}>`;
425
+ }
426
+ if ((0, import_xlr_utils.isObjectType)(node)) {
427
+ if ((0, import_xlr_utils.isNamedType)(node)) {
428
+ if (isComplexObjectType(node)) {
429
+ return `${node.name} | FluentBuilder<${node.name}, BaseBuildContext>`;
430
+ }
431
+ return node.name;
432
+ }
433
+ return this.generateInlineObjectType(node, forParameter);
434
+ }
435
+ if (node.type === "null") return "null";
436
+ if (node.type === "undefined") return "undefined";
437
+ if (node.type === "any") return "any";
438
+ if (node.type === "unknown") return "unknown";
439
+ if (node.type === "never") return "never";
440
+ if (node.type === "void") return "void";
441
+ return "unknown";
442
+ }
443
+ transformRefType(node, forParameter) {
444
+ const ref = node.ref;
445
+ if (ref.startsWith("AssetWrapper")) {
446
+ this.needsAssetImport = true;
447
+ return "Asset | FluentBuilder<Asset, BaseBuildContext>";
448
+ }
449
+ if (ref === "Expression") {
450
+ return forParameter ? "string | TaggedTemplateValue<string>" : "string";
451
+ }
452
+ if (ref === "Binding") {
453
+ return forParameter ? "string | TaggedTemplateValue<string>" : "string";
454
+ }
455
+ if (ref === "Asset" || ref.startsWith("Asset<")) {
456
+ this.needsAssetImport = true;
457
+ return "Asset";
458
+ }
459
+ const baseName = extractBaseName(ref);
460
+ if (this.nestedBuilders.has(baseName)) {
461
+ return `${baseName} | FluentBuilder<${baseName}, BaseBuildContext>`;
462
+ }
463
+ if (node.genericArguments && node.genericArguments.length > 0) {
464
+ const args = node.genericArguments.map(
465
+ (a) => this.transformType(a, forParameter)
466
+ );
467
+ return `${baseName}<${args.join(", ")}>`;
468
+ }
469
+ return baseName;
470
+ }
471
+ generateInlineObjectType(node, forParameter) {
472
+ const props = Object.entries(node.properties).map(([propName, prop]) => {
473
+ const propType = this.transformType(prop.node, forParameter);
474
+ const optional = prop.required ? "" : "?";
475
+ return `${propName}${optional}: ${propType}`;
476
+ }).join("; ");
477
+ return `{ ${props} }`;
478
+ }
479
+ };
480
+ function generateFluentBuilder(namedType, config = {}) {
481
+ const generator = new FluentBuilderGenerator(namedType, config);
482
+ return generator.generate();
483
+ }
484
+ // Annotate the CommonJS export names for ESM import in node:
485
+ 0 && (module.exports = {
486
+ containsArrayType,
487
+ extractGenericUsage,
488
+ generateFluentBuilder,
489
+ getAssetTypeFromExtends,
490
+ getPropertiesInfo,
491
+ isAndType,
492
+ isArrayType,
493
+ isAssetWrapperRef,
494
+ isBindingRef,
495
+ isBooleanType,
496
+ isComplexObjectType,
497
+ isExpressionRef,
498
+ isNamedType,
499
+ isNumberType,
500
+ isObjectType,
501
+ isOrType,
502
+ isPrimitiveConst,
503
+ isRecordType,
504
+ isRefType,
505
+ isStringType,
506
+ toBuilderClassName,
507
+ toFactoryName,
508
+ toPascalCase
509
+ });
510
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/generators/fluent/src/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/generators/fluent/src/generator.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/generators/fluent/src/utils.ts"],"sourcesContent":["/**\n * @player-tools/fluent-generator\n *\n * Generates fluent builders from XLR types for Player-UI assets.\n */\n\nexport {\n generateFluentBuilder,\n type GeneratorConfig,\n type BuilderInfo,\n} from \"./generator\";\nexport * from \"./utils\";\n","import type {\n NodeType,\n ObjectType,\n RefType,\n NamedType,\n} from \"@player-tools/xlr\";\nimport { isGenericNamedType } from \"@player-tools/xlr-utils\";\nimport {\n isStringType,\n isNumberType,\n isBooleanType,\n isObjectType,\n isArrayType,\n isRefType,\n isOrType,\n isAndType,\n isRecordType,\n isNamedType,\n isPrimitiveConst,\n toPascalCase,\n toFactoryName,\n toBuilderClassName,\n isComplexObjectType,\n getAssetTypeFromExtends,\n containsArrayType,\n extractGenericUsage,\n} from \"./utils\";\n\n/**\n * Configuration for the generator\n */\nexport interface GeneratorConfig {\n /** Import path for fluent utilities (default: \"@player-tools/fluent\") */\n fluentImportPath?: string;\n /** Import path for player-ui types (default: \"@player-ui/types\") */\n typesImportPath?: string;\n /** Function to generate the type import path */\n typeImportPathGenerator?: (typeName: string) => string;\n}\n\n/**\n * Information about a builder class to generate.\n * Exported for consumers who need to extend or introspect the generator.\n */\nexport interface BuilderInfo {\n /** Original type name from XLR */\n name: string;\n /** Generated class name (e.g., \"TextAssetBuilder\") */\n className: string;\n /** Factory function name (e.g., \"text\") */\n factoryName: string;\n /** The XLR ObjectType being generated */\n objectType: ObjectType;\n /** Asset type string if this is an Asset (e.g., \"text\") */\n assetType?: string;\n /** Generic parameters declaration if type is generic */\n genericParams?: string;\n /** Whether this type extends Asset */\n isAsset: boolean;\n}\n\n/**\n * Extracts the base type name from a ref string, handling nested generics.\n * @example\n * extractBaseName(\"MyType\") // \"MyType\"\n * extractBaseName(\"MyType<T>\") // \"MyType\"\n * extractBaseName(\"Map<string, Array<T>>\") // \"Map\"\n */\nfunction extractBaseName(ref: string): string {\n const bracketIndex = ref.indexOf(\"<\");\n return bracketIndex === -1 ? ref : ref.substring(0, bracketIndex);\n}\n\n/**\n * Generates fluent builder TypeScript code from XLR types\n */\nexport class FluentBuilderGenerator {\n private readonly namedType: NamedType<ObjectType>;\n private readonly config: GeneratorConfig;\n\n /** Track nested types that need their own builders */\n private nestedBuilders = new Map<string, ObjectType>();\n\n /** Track array properties for __arrayProperties__ */\n private arrayProperties = new Set<string>();\n\n /** Track all type references that need to be imported from the source type file */\n private referencedTypes = new Set<string>();\n\n /** Track whether Asset type is needed for imports */\n private needsAssetImport = false;\n\n constructor(namedType: NamedType<ObjectType>, config: GeneratorConfig = {}) {\n this.namedType = namedType;\n this.config = config;\n }\n\n /**\n * Generate the builder code\n */\n generate(): string {\n const mainBuilder = this.createBuilderInfo(this.namedType);\n\n // Collect all nested types that need builders\n this.collectNestedTypes(this.namedType);\n\n // Generate nested builder classes first (this sets needsAssetImport flag)\n const nestedBuilderCode = Array.from(this.nestedBuilders.entries())\n .map(([name, objType]) => {\n const info: BuilderInfo = {\n name,\n className: toBuilderClassName(name),\n factoryName: toFactoryName(name),\n objectType: objType,\n isAsset: false,\n };\n return this.generateBuilderClass(info);\n })\n .join(\"\\n\\n\");\n\n // Generate main builder class (this also sets needsAssetImport flag)\n const mainBuilderCode = this.generateBuilderClass(mainBuilder);\n\n // Generate imports after builder code so we know what imports are needed\n const imports = this.generateImports(mainBuilder);\n\n return [imports, nestedBuilderCode, mainBuilderCode]\n .filter(Boolean)\n .join(\"\\n\\n\");\n }\n\n private createBuilderInfo(namedType: NamedType<ObjectType>): BuilderInfo {\n const assetType = getAssetTypeFromExtends(namedType);\n const isAsset = !!assetType;\n\n let genericParams: string | undefined;\n if (isGenericNamedType(namedType)) {\n genericParams = namedType.genericTokens\n .map((t) => {\n let param = t.symbol;\n if (t.constraints) {\n param += ` extends ${this.transformType(t.constraints)}`;\n }\n if (t.default) {\n param += ` = ${this.transformType(t.default)}`;\n }\n return param;\n })\n .join(\", \");\n }\n\n return {\n name: namedType.name,\n className: toBuilderClassName(namedType.name),\n factoryName: toFactoryName(namedType.name),\n objectType: namedType,\n assetType,\n genericParams,\n isAsset,\n };\n }\n\n private generateImports(mainBuilder: BuilderInfo): string {\n // Import the main type - use custom generator if provided\n const typeImportPath = this.config.typeImportPathGenerator\n ? this.config.typeImportPathGenerator(mainBuilder.name)\n : `../types/${this.getTypeFileName(mainBuilder.name)}`;\n\n // Collect all types to import from the same source file\n // This includes: main type, nested builder types, and other referenced types\n const typesToImport = new Set<string>([mainBuilder.name]);\n\n // Add all nested builder types\n Array.from(this.nestedBuilders.keys()).forEach((name) => {\n typesToImport.add(name);\n });\n\n // Add all referenced types\n Array.from(this.referencedTypes).forEach((name) => {\n typesToImport.add(name);\n });\n\n const typeImportStatement = `import type { ${Array.from(typesToImport).join(\", \")} } from \"${typeImportPath}\";`;\n\n // Get import paths from config or use defaults\n const typesImportPath = this.config.typesImportPath ?? \"@player-ui/types\";\n const fluentImportPath =\n this.config.fluentImportPath ?? \"@player-tools/fluent\";\n\n // Build import lines\n const lines = [typeImportStatement];\n\n // Only import Asset if it's used\n if (this.needsAssetImport) {\n lines.push(`import type { Asset } from \"${typesImportPath}\";`);\n }\n\n lines.push(\n `import { type FluentBuilder, type BaseBuildContext, FluentBuilderBase, createInspectMethod, type TaggedTemplateValue } from \"${fluentImportPath}\";`,\n );\n\n return lines.join(\"\\n\");\n }\n\n private getTypeFileName(typeName: string): string {\n // Convert PascalCase to kebab-case for file name\n return typeName\n .replace(/([A-Z])/g, \"-$1\")\n .toLowerCase()\n .replace(/^-/, \"\")\n .replace(/asset$/, \"\");\n }\n\n private collectNestedTypes(objType: ObjectType): void {\n for (const [propName, prop] of Object.entries(objType.properties)) {\n this.collectNestedTypesFromNode(prop.node, propName);\n }\n }\n\n private collectNestedTypesFromNode(node: NodeType, parentName: string): void {\n if (isObjectType(node)) {\n if (isNamedType(node) && isComplexObjectType(node)) {\n this.nestedBuilders.set(node.name, node);\n this.collectNestedTypes(node);\n } else if (!isNamedType(node) && isComplexObjectType(node)) {\n // Anonymous complex object - generate a builder for it\n const name = toPascalCase(parentName);\n this.nestedBuilders.set(name, node);\n this.collectNestedTypes(node);\n } else if (isNamedType(node)) {\n // Simple named type - just track for import\n this.referencedTypes.add(node.name);\n }\n } else if (isArrayType(node)) {\n this.collectNestedTypesFromNode(node.elementType, parentName);\n } else if (isOrType(node)) {\n for (const variant of node.or) {\n this.collectNestedTypesFromNode(variant, parentName);\n }\n } else if (isAndType(node)) {\n for (const part of node.and) {\n this.collectNestedTypesFromNode(part, parentName);\n }\n } else if (isRefType(node)) {\n // Track reference types that aren't built-in Player types\n const baseName = extractBaseName(node.ref);\n const builtInTypes = [\n \"Asset\",\n \"AssetWrapper\",\n \"Binding\",\n \"Expression\",\n \"Array\",\n \"Record\",\n ];\n if (!builtInTypes.includes(baseName)) {\n this.referencedTypes.add(baseName);\n }\n }\n }\n\n private generateBuilderClass(info: BuilderInfo): string {\n const {\n name,\n className,\n factoryName,\n objectType,\n assetType,\n genericParams,\n } = info;\n\n // Reset array properties for this builder\n this.arrayProperties.clear();\n\n const genericPart = genericParams ? `<${genericParams}>` : \"\";\n const genericUsage = extractGenericUsage(genericParams);\n\n // Generate interface methods\n const interfaceCode = this.generateInterfaceMethods(info);\n\n // Generate class methods\n const classMethods = this.generateClassMethods(info);\n\n // Generate defaults\n const defaults = this.generateDefaults(objectType, assetType);\n\n // Generate array properties metadata\n const arrayPropsCode =\n this.arrayProperties.size > 0\n ? ` private static readonly __arrayProperties__: ReadonlySet<string> = new Set([${Array.from(\n this.arrayProperties,\n )\n .map((p) => `\"${p}\"`)\n .join(\", \")}]);\\n`\n : \"\";\n\n // Build the class\n const classCode = `\n${interfaceCode}\n\n/**\n * A builder for ${name}\n */\nexport class ${className}${genericPart} extends FluentBuilderBase<${name}${genericUsage}> implements ${className}Methods${genericUsage}, FluentBuilder<${name}${genericUsage}, BaseBuildContext> {\n private static readonly defaults: Record<string, unknown> = ${defaults};\n${arrayPropsCode}\n${classMethods}\n\n /**\n * Builds the final ${name} object\n * @param context - Optional build context for nested builders\n */\n build(context?: BaseBuildContext): ${name}${genericUsage} {\n return this.buildWithDefaults(${className}.defaults, context);\n }\n\n [Symbol.for(\"nodejs.util.inspect.custom\")](): string {\n return createInspectMethod(\"${className}\", this.values);\n }\n}\n\n/**\n * Creates a new ${name} builder\n * @param initial Optional initial values\n * @returns A fluent builder for ${name}\n */\nexport function ${factoryName}${genericPart}(initial?: Partial<${name}${genericUsage}>): ${className}${genericUsage} {\n return new ${className}${genericUsage}(initial);\n}`;\n\n return classCode.trim();\n }\n\n private generateInterfaceMethods(info: BuilderInfo): string {\n const { className, objectType, genericParams, isAsset } = info;\n const genericUsage = extractGenericUsage(genericParams);\n\n // Collect all properties to generate methods for\n const properties = this.collectPropertiesForMethods(objectType, isAsset);\n\n const methods = properties\n .map(({ propName, propType, description }) => {\n const methodName = `with${toPascalCase(propName)}`;\n const paramType = this.transformType(propType, true);\n\n return ` /** ${description} */\n ${methodName}(value: ${paramType}): ${className}${genericUsage};`;\n })\n .join(\"\\n\");\n\n return `export interface ${className}Methods${genericParams ? `<${genericParams}>` : \"\"} {\n${methods}\n}`;\n }\n\n private collectPropertiesForMethods(\n objectType: ObjectType,\n isAsset: boolean,\n ): Array<{ propName: string; propType: NodeType; description: string }> {\n const properties: Array<{\n propName: string;\n propType: NodeType;\n description: string;\n }> = [];\n\n // Add inherited Asset properties for asset types\n if (isAsset) {\n // Add id property - all assets have an id\n properties.push({\n propName: \"id\",\n propType: { type: \"string\" },\n description: \"A unique identifier for this asset\",\n });\n }\n\n // Add properties from the object type\n for (const [propName, prop] of Object.entries(objectType.properties)) {\n properties.push({\n propName,\n propType: prop.node,\n description: prop.node.description || `Sets the ${propName} property`,\n });\n }\n\n return properties;\n }\n\n private generateClassMethods(info: BuilderInfo): string {\n const { className, objectType, genericParams, isAsset } = info;\n const genericUsage = extractGenericUsage(genericParams);\n\n // Collect all properties to generate methods for\n const properties = this.collectPropertiesForMethods(objectType, isAsset);\n\n return properties\n .map(({ propName, propType, description }) => {\n const methodName = `with${toPascalCase(propName)}`;\n const paramType = this.transformType(propType, true);\n\n // Track array properties (including union types that contain arrays)\n if (containsArrayType(propType)) {\n this.arrayProperties.add(propName);\n }\n\n return ` /** ${description} */\n ${methodName}(value: ${paramType}): ${className}${genericUsage} {\n return this.set(\"${propName}\", value);\n }`;\n })\n .join(\"\\n\\n\");\n }\n\n private generateDefaults(objectType: ObjectType, assetType?: string): string {\n const defaults: Record<string, unknown> = {};\n\n // Add asset type default if this is an asset\n if (assetType) {\n defaults[\"type\"] = assetType;\n }\n\n // Add default ID for assets (types that extend Asset)\n if (objectType.extends?.ref.startsWith(\"Asset\")) {\n defaults[\"id\"] = \"\";\n }\n // Also add default ID for non-Asset types that have an 'id' property\n // This enables ID auto-generation for nested object types\n else if (\"id\" in objectType.properties) {\n defaults[\"id\"] = \"\";\n }\n\n // Add const defaults from properties\n for (const [propName, prop] of Object.entries(objectType.properties)) {\n if (isPrimitiveConst(prop.node)) {\n defaults[propName] = prop.node.const;\n }\n }\n\n return JSON.stringify(defaults);\n }\n\n /**\n * Transform an XLR type to a TypeScript type string\n * This is the core recursive transformation that adds TaggedTemplateValue support\n */\n private transformType(node: NodeType, forParameter = false): string {\n // Primitive types get TaggedTemplateValue support\n if (isStringType(node)) {\n if (isPrimitiveConst(node)) {\n return `\"${node.const}\"`;\n }\n return forParameter ? \"string | TaggedTemplateValue<string>\" : \"string\";\n }\n\n if (isNumberType(node)) {\n if (isPrimitiveConst(node)) {\n return `${node.const}`;\n }\n return forParameter ? \"number | TaggedTemplateValue<number>\" : \"number\";\n }\n\n if (isBooleanType(node)) {\n if (isPrimitiveConst(node)) {\n return `${node.const}`;\n }\n return forParameter\n ? \"boolean | TaggedTemplateValue<boolean>\"\n : \"boolean\";\n }\n\n // Reference types\n if (isRefType(node)) {\n return this.transformRefType(node, forParameter);\n }\n\n // Array types\n if (isArrayType(node)) {\n const elementType = this.transformType(node.elementType, forParameter);\n return `Array<${elementType}>`;\n }\n\n // Union types\n if (isOrType(node)) {\n const variants = node.or.map((v) => this.transformType(v, forParameter));\n return variants.join(\" | \");\n }\n\n // Intersection types\n if (isAndType(node)) {\n const parts = node.and.map((p) => this.transformType(p, forParameter));\n return parts.join(\" & \");\n }\n\n // Record types - key type should NOT have TaggedTemplateValue since\n // TypeScript Record keys can only be string | number | symbol\n if (isRecordType(node)) {\n const keyType = this.transformType(node.keyType, false);\n const valueType = this.transformType(node.valueType, forParameter);\n return `Record<${keyType}, ${valueType}>`;\n }\n\n // Object types - transform properties recursively\n if (isObjectType(node)) {\n if (isNamedType(node)) {\n // Named type - reference it or its builder\n if (isComplexObjectType(node)) {\n return `${node.name} | FluentBuilder<${node.name}, BaseBuildContext>`;\n }\n return node.name;\n }\n\n // Anonymous object - generate inline type with transformed properties\n return this.generateInlineObjectType(node, forParameter);\n }\n\n // Handle other primitive types\n if (node.type === \"null\") return \"null\";\n if (node.type === \"undefined\") return \"undefined\";\n if (node.type === \"any\") return \"any\";\n if (node.type === \"unknown\") return \"unknown\";\n if (node.type === \"never\") return \"never\";\n if (node.type === \"void\") return \"void\";\n\n // Default fallback\n return \"unknown\";\n }\n\n private transformRefType(node: RefType, forParameter: boolean): string {\n const ref = node.ref;\n\n // AssetWrapper - transform to accept Asset or FluentBuilder\n if (ref.startsWith(\"AssetWrapper\")) {\n this.needsAssetImport = true;\n return \"Asset | FluentBuilder<Asset, BaseBuildContext>\";\n }\n\n // Expression - allow TaggedTemplateValue\n if (ref === \"Expression\") {\n return forParameter ? \"string | TaggedTemplateValue<string>\" : \"string\";\n }\n\n // Binding - allow TaggedTemplateValue\n if (ref === \"Binding\") {\n return forParameter ? \"string | TaggedTemplateValue<string>\" : \"string\";\n }\n\n // Asset reference\n if (ref === \"Asset\" || ref.startsWith(\"Asset<\")) {\n this.needsAssetImport = true;\n return \"Asset\";\n }\n\n // Other references - check if we have a builder for them\n const baseName = extractBaseName(ref);\n if (this.nestedBuilders.has(baseName)) {\n return `${baseName} | FluentBuilder<${baseName}, BaseBuildContext>`;\n }\n\n // Handle generic arguments\n if (node.genericArguments && node.genericArguments.length > 0) {\n const args = node.genericArguments.map((a) =>\n this.transformType(a, forParameter),\n );\n return `${baseName}<${args.join(\", \")}>`;\n }\n\n return baseName;\n }\n\n private generateInlineObjectType(\n node: ObjectType,\n forParameter: boolean,\n ): string {\n const props = Object.entries(node.properties)\n .map(([propName, prop]) => {\n const propType = this.transformType(prop.node, forParameter);\n const optional = prop.required ? \"\" : \"?\";\n return `${propName}${optional}: ${propType}`;\n })\n .join(\"; \");\n\n return `{ ${props} }`;\n }\n}\n\n/**\n * Generate fluent builder code from a NamedType<ObjectType>\n * @param namedType - The XLR NamedType to generate a builder for\n * @param config - Optional generator configuration\n * @returns Generated TypeScript code for the fluent builder\n */\nexport function generateFluentBuilder(\n namedType: NamedType<ObjectType>,\n config: GeneratorConfig = {},\n): string {\n const generator = new FluentBuilderGenerator(namedType, config);\n return generator.generate();\n}\n","import type {\n NodeType,\n ObjectType,\n ArrayType,\n StringType,\n NumberType,\n BooleanType,\n} from \"@player-tools/xlr\";\n\nimport {\n isStringType,\n isNumberType,\n isBooleanType,\n isObjectType,\n isArrayType,\n isRefType,\n isOrType,\n isAndType,\n isRecordType,\n isNamedType,\n} from \"@player-tools/xlr-utils\";\n\n// Re-export type guards from xlr-utils for consumers\nexport {\n isStringType,\n isNumberType,\n isBooleanType,\n isObjectType,\n isArrayType,\n isRefType,\n isOrType,\n isAndType,\n isRecordType,\n isNamedType,\n};\n\n/**\n * Check if a primitive type has a const value (literal type)\n */\nexport function isPrimitiveConst(\n node: NodeType,\n): node is (StringType | NumberType | BooleanType) & { const: unknown } {\n return (\n (isStringType(node) || isNumberType(node) || isBooleanType(node)) &&\n \"const\" in node &&\n node.const !== undefined\n );\n}\n\n/**\n * Check if a ref type is an AssetWrapper\n */\nexport function isAssetWrapperRef(node: NodeType): boolean {\n return isRefType(node) && node.ref.startsWith(\"AssetWrapper\");\n}\n\n/**\n * Check if a ref type is an Expression\n */\nexport function isExpressionRef(node: NodeType): boolean {\n return isRefType(node) && node.ref === \"Expression\";\n}\n\n/**\n * Check if a ref type is a Binding\n */\nexport function isBindingRef(node: NodeType): boolean {\n return isRefType(node) && node.ref === \"Binding\";\n}\n\n/**\n * Convert a property name to PascalCase for method names.\n * Handles camelCase, kebab-case, and snake_case inputs.\n *\n * @example\n * toPascalCase(\"myProperty\") // \"MyProperty\"\n * toPascalCase(\"my-property\") // \"MyProperty\"\n * toPascalCase(\"my_property\") // \"MyProperty\"\n */\nexport function toPascalCase(str: string): string {\n return str\n .split(/[-_]/)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n}\n\n/**\n * Convert a type name to a factory function name (camelCase)\n */\nexport function toFactoryName(typeName: string): string {\n // Remove \"Asset\" suffix if present\n const name = typeName.replace(/Asset$/, \"\");\n return name.charAt(0).toLowerCase() + name.slice(1);\n}\n\n/**\n * Convert a type name to a builder class name\n */\nexport function toBuilderClassName(typeName: string): string {\n return `${typeName}Builder`;\n}\n\n/**\n * Check if an object type is complex enough to warrant its own builder class\n */\nexport function isComplexObjectType(obj: ObjectType): boolean {\n const props = Object.values(obj.properties);\n\n // Has AssetWrapper properties\n const hasSlots = props.some((p) => isAssetWrapperRef(p.node));\n if (hasSlots) return true;\n\n // Has many properties\n if (props.length > 3) return true;\n\n // Has nested objects\n const hasNestedObjects = props.some(\n (p) => isObjectType(p.node) && !isPrimitiveConst(p.node),\n );\n if (hasNestedObjects) return true;\n\n return false;\n}\n\n/**\n * Get the asset type string from extends ref\n */\nexport function getAssetTypeFromExtends(obj: ObjectType): string | undefined {\n if (!obj.extends) return undefined;\n\n const ref = obj.extends;\n if (ref.genericArguments && ref.genericArguments.length > 0) {\n const typeArg = ref.genericArguments[0];\n if (isStringType(typeArg) && typeArg.const) {\n return typeArg.const;\n }\n }\n return undefined;\n}\n\n/**\n * Information about a property for code generation\n */\nexport interface PropertyInfo {\n name: string;\n node: NodeType;\n required: boolean;\n isSlot: boolean;\n isArraySlot: boolean;\n isArray: boolean;\n}\n\n/**\n * Extract property information from an ObjectType\n */\nexport function getPropertiesInfo(obj: ObjectType): PropertyInfo[] {\n return Object.entries(obj.properties).map(([name, prop]) => {\n const isSlot = isAssetWrapperRef(prop.node);\n const isArray = isArrayType(prop.node);\n const isArraySlot =\n isArray && isAssetWrapperRef((prop.node as ArrayType).elementType);\n\n return {\n name,\n node: prop.node,\n required: prop.required,\n isSlot,\n isArraySlot,\n isArray,\n };\n });\n}\n\n/**\n * Check if a type contains an array type (directly or within a union/intersection)\n * This handles cases like `Array<T> | T` where the property can be either\n */\nexport function containsArrayType(node: NodeType): boolean {\n if (isArrayType(node)) {\n return true;\n }\n\n if (isOrType(node)) {\n return node.or.some(containsArrayType);\n }\n\n if (isAndType(node)) {\n return node.and.some(containsArrayType);\n }\n\n return false;\n}\n\n/**\n * Extract generic usage string from generic params declaration\n * Converts \"T extends Foo, U = Bar\" to \"<T, U>\"\n */\nexport function extractGenericUsage(genericParams: string | undefined): string {\n if (!genericParams) {\n return \"\";\n }\n\n const params = genericParams\n .split(\",\")\n .map((p) => p.trim().split(\" \")[0])\n .join(\", \");\n\n return `<${params}>`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAAA,oBAAmC;;;ACGnC,uBAWO;AAmBA,SAAS,iBACd,MACsE;AACtE,cACG,+BAAa,IAAI,SAAK,+BAAa,IAAI,SAAK,gCAAc,IAAI,MAC/D,WAAW,QACX,KAAK,UAAU;AAEnB;AAKO,SAAS,kBAAkB,MAAyB;AACzD,aAAO,4BAAU,IAAI,KAAK,KAAK,IAAI,WAAW,cAAc;AAC9D;AAKO,SAAS,gBAAgB,MAAyB;AACvD,aAAO,4BAAU,IAAI,KAAK,KAAK,QAAQ;AACzC;AAKO,SAAS,aAAa,MAAyB;AACpD,aAAO,4BAAU,IAAI,KAAK,KAAK,QAAQ;AACzC;AAWO,SAAS,aAAa,KAAqB;AAChD,SAAO,IACJ,MAAM,MAAM,EACZ,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC,EAC1D,KAAK,EAAE;AACZ;AAKO,SAAS,cAAc,UAA0B;AAEtD,QAAM,OAAO,SAAS,QAAQ,UAAU,EAAE;AAC1C,SAAO,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC;AACpD;AAKO,SAAS,mBAAmB,UAA0B;AAC3D,SAAO,GAAG,QA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