@player-tools/fluent 0.12.1--canary.241.6077

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/cjs/index.cjs +2396 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/index.legacy-esm.js +2276 -0
  4. package/dist/index.mjs +2276 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +38 -0
  7. package/src/core/base-builder/__tests__/fluent-builder-base.test.ts +2423 -0
  8. package/src/core/base-builder/__tests__/fluent-partial.test.ts +179 -0
  9. package/src/core/base-builder/__tests__/id-generator.test.ts +658 -0
  10. package/src/core/base-builder/__tests__/registry.test.ts +534 -0
  11. package/src/core/base-builder/__tests__/resolution-mixed-arrays.test.ts +319 -0
  12. package/src/core/base-builder/__tests__/resolution-pipeline.test.ts +416 -0
  13. package/src/core/base-builder/__tests__/resolution-switches.test.ts +468 -0
  14. package/src/core/base-builder/__tests__/resolution-templates.test.ts +255 -0
  15. package/src/core/base-builder/__tests__/switch.test.ts +815 -0
  16. package/src/core/base-builder/__tests__/template.test.ts +596 -0
  17. package/src/core/base-builder/__tests__/value-extraction.test.ts +200 -0
  18. package/src/core/base-builder/__tests__/value-storage.test.ts +459 -0
  19. package/src/core/base-builder/conditional/index.ts +64 -0
  20. package/src/core/base-builder/context.ts +152 -0
  21. package/src/core/base-builder/errors.ts +69 -0
  22. package/src/core/base-builder/fluent-builder-base.ts +308 -0
  23. package/src/core/base-builder/guards.ts +137 -0
  24. package/src/core/base-builder/id/generator.ts +290 -0
  25. package/src/core/base-builder/id/registry.ts +152 -0
  26. package/src/core/base-builder/index.ts +72 -0
  27. package/src/core/base-builder/resolution/path-resolver.ts +116 -0
  28. package/src/core/base-builder/resolution/pipeline.ts +103 -0
  29. package/src/core/base-builder/resolution/steps/__tests__/nested-asset-wrappers.test.ts +206 -0
  30. package/src/core/base-builder/resolution/steps/asset-id.ts +77 -0
  31. package/src/core/base-builder/resolution/steps/asset-wrappers.ts +64 -0
  32. package/src/core/base-builder/resolution/steps/builders.ts +84 -0
  33. package/src/core/base-builder/resolution/steps/mixed-arrays.ts +95 -0
  34. package/src/core/base-builder/resolution/steps/nested-asset-wrappers.ts +124 -0
  35. package/src/core/base-builder/resolution/steps/static-values.ts +35 -0
  36. package/src/core/base-builder/resolution/steps/switches.ts +71 -0
  37. package/src/core/base-builder/resolution/steps/templates.ts +40 -0
  38. package/src/core/base-builder/resolution/value-resolver.ts +333 -0
  39. package/src/core/base-builder/storage/auxiliary-storage.ts +82 -0
  40. package/src/core/base-builder/storage/value-storage.ts +282 -0
  41. package/src/core/base-builder/types.ts +266 -0
  42. package/src/core/base-builder/utils.ts +10 -0
  43. package/src/core/flow/__tests__/index.test.ts +292 -0
  44. package/src/core/flow/index.ts +118 -0
  45. package/src/core/index.ts +8 -0
  46. package/src/core/mocks/generated/action.builder.ts +92 -0
  47. package/src/core/mocks/generated/choice-item.builder.ts +120 -0
  48. package/src/core/mocks/generated/choice.builder.ts +134 -0
  49. package/src/core/mocks/generated/collection.builder.ts +93 -0
  50. package/src/core/mocks/generated/field-collection.builder.ts +86 -0
  51. package/src/core/mocks/generated/index.ts +10 -0
  52. package/src/core/mocks/generated/info.builder.ts +64 -0
  53. package/src/core/mocks/generated/input.builder.ts +63 -0
  54. package/src/core/mocks/generated/overview-collection.builder.ts +65 -0
  55. package/src/core/mocks/generated/splash-collection.builder.ts +93 -0
  56. package/src/core/mocks/generated/text.builder.ts +47 -0
  57. package/src/core/mocks/index.ts +1 -0
  58. package/src/core/mocks/types/action.ts +92 -0
  59. package/src/core/mocks/types/choice.ts +129 -0
  60. package/src/core/mocks/types/collection.ts +140 -0
  61. package/src/core/mocks/types/info.ts +7 -0
  62. package/src/core/mocks/types/input.ts +7 -0
  63. package/src/core/mocks/types/text.ts +5 -0
  64. package/src/core/schema/__tests__/index.test.ts +127 -0
  65. package/src/core/schema/index.ts +195 -0
  66. package/src/core/schema/types.ts +7 -0
  67. package/src/core/switch/__tests__/index.test.ts +156 -0
  68. package/src/core/switch/index.ts +81 -0
  69. package/src/core/tagged-template/README.md +448 -0
  70. package/src/core/tagged-template/__tests__/extract-bindings-from-schema.test.ts +207 -0
  71. package/src/core/tagged-template/__tests__/index.test.ts +190 -0
  72. package/src/core/tagged-template/__tests__/schema-std-integration.test.ts +580 -0
  73. package/src/core/tagged-template/binding.ts +95 -0
  74. package/src/core/tagged-template/expression.ts +92 -0
  75. package/src/core/tagged-template/extract-bindings-from-schema.ts +120 -0
  76. package/src/core/tagged-template/index.ts +5 -0
  77. package/src/core/tagged-template/std.ts +472 -0
  78. package/src/core/tagged-template/types.ts +123 -0
  79. package/src/core/template/__tests__/index.test.ts +380 -0
  80. package/src/core/template/index.ts +196 -0
  81. package/src/core/utils/index.ts +160 -0
  82. package/src/fp/README.md +411 -0
  83. package/src/fp/__tests__/index.test.ts +1178 -0
  84. package/src/fp/index.ts +386 -0
  85. package/src/gen/common.ts +15 -0
  86. package/src/index.ts +5 -0
  87. package/src/types.ts +203 -0
  88. package/types/core/base-builder/conditional/index.d.ts +21 -0
  89. package/types/core/base-builder/context.d.ts +39 -0
  90. package/types/core/base-builder/errors.d.ts +45 -0
  91. package/types/core/base-builder/fluent-builder-base.d.ts +147 -0
  92. package/types/core/base-builder/guards.d.ts +58 -0
  93. package/types/core/base-builder/id/generator.d.ts +69 -0
  94. package/types/core/base-builder/id/registry.d.ts +93 -0
  95. package/types/core/base-builder/index.d.ts +9 -0
  96. package/types/core/base-builder/resolution/path-resolver.d.ts +15 -0
  97. package/types/core/base-builder/resolution/pipeline.d.ts +27 -0
  98. package/types/core/base-builder/resolution/steps/asset-id.d.ts +14 -0
  99. package/types/core/base-builder/resolution/steps/asset-wrappers.d.ts +14 -0
  100. package/types/core/base-builder/resolution/steps/builders.d.ts +14 -0
  101. package/types/core/base-builder/resolution/steps/mixed-arrays.d.ts +14 -0
  102. package/types/core/base-builder/resolution/steps/nested-asset-wrappers.d.ts +14 -0
  103. package/types/core/base-builder/resolution/steps/static-values.d.ts +14 -0
  104. package/types/core/base-builder/resolution/steps/switches.d.ts +15 -0
  105. package/types/core/base-builder/resolution/steps/templates.d.ts +14 -0
  106. package/types/core/base-builder/resolution/value-resolver.d.ts +62 -0
  107. package/types/core/base-builder/storage/auxiliary-storage.d.ts +50 -0
  108. package/types/core/base-builder/storage/value-storage.d.ts +82 -0
  109. package/types/core/base-builder/types.d.ts +183 -0
  110. package/types/core/base-builder/utils.d.ts +2 -0
  111. package/types/core/flow/index.d.ts +23 -0
  112. package/types/core/index.d.ts +8 -0
  113. package/types/core/mocks/index.d.ts +2 -0
  114. package/types/core/mocks/types/action.d.ts +58 -0
  115. package/types/core/mocks/types/choice.d.ts +95 -0
  116. package/types/core/mocks/types/collection.d.ts +102 -0
  117. package/types/core/mocks/types/info.d.ts +7 -0
  118. package/types/core/mocks/types/input.d.ts +7 -0
  119. package/types/core/mocks/types/text.d.ts +5 -0
  120. package/types/core/schema/index.d.ts +34 -0
  121. package/types/core/schema/types.d.ts +5 -0
  122. package/types/core/switch/index.d.ts +21 -0
  123. package/types/core/tagged-template/binding.d.ts +19 -0
  124. package/types/core/tagged-template/expression.d.ts +11 -0
  125. package/types/core/tagged-template/extract-bindings-from-schema.d.ts +7 -0
  126. package/types/core/tagged-template/index.d.ts +6 -0
  127. package/types/core/tagged-template/std.d.ts +174 -0
  128. package/types/core/tagged-template/types.d.ts +69 -0
  129. package/types/core/template/index.d.ts +97 -0
  130. package/types/core/utils/index.d.ts +47 -0
  131. package/types/fp/index.d.ts +149 -0
  132. package/types/gen/common.d.ts +6 -0
  133. package/types/index.d.ts +3 -0
  134. package/types/types.d.ts +163 -0
@@ -0,0 +1,2396 @@
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/dsl/fluent/src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ AND: () => and,
24
+ BranchTypes: () => BranchTypes,
25
+ ErrorCodes: () => ErrorCodes,
26
+ FLUENT_BUILDER_SYMBOL: () => FLUENT_BUILDER_SYMBOL,
27
+ FluentBuilderBase: () => FluentBuilderBase,
28
+ FluentError: () => FluentError,
29
+ IDRegistry: () => IDRegistry,
30
+ NAND: () => nand,
31
+ NOR: () => nor,
32
+ NOT: () => not,
33
+ OR: () => or,
34
+ PropertyKeys: () => PropertyKeys,
35
+ SchemaGenerator: () => SchemaGenerator,
36
+ SchemaTypeName: () => SchemaTypeName,
37
+ StorageKeys: () => StorageKeys,
38
+ TEMPLATE_MARKER: () => TEMPLATE_MARKER,
39
+ TaggedTemplateValueSymbol: () => TaggedTemplateValueSymbol,
40
+ XOR: () => xor,
41
+ add: () => add,
42
+ and: () => and,
43
+ binding: () => binding,
44
+ call: () => call,
45
+ conditional: () => conditional,
46
+ createFluentError: () => createFluentError,
47
+ createIdRegistry: () => createIdRegistry,
48
+ createInspectMethod: () => createInspectMethod,
49
+ createNestedContext: () => createNestedContext,
50
+ createSwitchContext: () => createSwitchContext,
51
+ createTemplateContext: () => createTemplateContext,
52
+ determineSlotName: () => determineSlotName,
53
+ div: () => divide,
54
+ divide: () => divide,
55
+ eq: () => equal,
56
+ equal: () => equal,
57
+ expression: () => expression,
58
+ extractBindingsFromSchema: () => extractBindingsFromSchema,
59
+ extractValue: () => extractValue,
60
+ flow: () => flow,
61
+ genId: () => genId,
62
+ generateAssetId: () => generateAssetId,
63
+ globalIdRegistry: () => globalIdRegistry,
64
+ greaterThan: () => greaterThan,
65
+ greaterThanOrEqual: () => greaterThanOrEqual,
66
+ gt: () => greaterThan,
67
+ gte: () => greaterThanOrEqual,
68
+ ifElse: () => conditional,
69
+ isAsset: () => isAsset,
70
+ isAssetWrapper: () => isAssetWrapper,
71
+ isAssetWrapperValue: () => isAssetWrapperValue,
72
+ isAssetWrapperWithAsset: () => isAssetWrapperWithAsset,
73
+ isBuilderArray: () => isBuilderArray,
74
+ isFluentBuilder: () => isFluentBuilder,
75
+ isPlainObject: () => isPlainObject,
76
+ isStringOrUndefined: () => isStringOrUndefined,
77
+ isSwitchResult: () => isSwitchResult,
78
+ isTaggedTemplateValue: () => isTaggedTemplateValue,
79
+ isTemplate: () => isTemplate,
80
+ lessThan: () => lessThan,
81
+ lessThanOrEqual: () => lessThanOrEqual,
82
+ literal: () => literal,
83
+ lt: () => lessThan,
84
+ lte: () => lessThanOrEqual,
85
+ minus: () => subtract,
86
+ mod: () => modulo,
87
+ modulo: () => modulo,
88
+ multiply: () => multiply,
89
+ nand: () => nand,
90
+ needsAssetWrapper: () => needsAssetWrapper,
91
+ neq: () => notEqual,
92
+ nor: () => nor,
93
+ not: () => not,
94
+ notEqual: () => notEqual,
95
+ or: () => or,
96
+ peekId: () => peekId,
97
+ plus: () => add,
98
+ resetGlobalIdSet: () => resetGlobalIdSet,
99
+ resolveAndWrapAsset: () => resolveAndWrapAsset,
100
+ resolveValue: () => resolveValue,
101
+ safeFromMixedType: () => safeFromMixedType,
102
+ safeToArray: () => safeToArray,
103
+ safeToBoolean: () => safeToBoolean,
104
+ safeToNumber: () => safeToNumber,
105
+ safeToObject: () => safeToObject,
106
+ safeToString: () => safeToString,
107
+ strictEq: () => strictEqual,
108
+ strictEqual: () => strictEqual,
109
+ strictNeq: () => strictNotEqual,
110
+ strictNotEqual: () => strictNotEqual,
111
+ subtract: () => subtract,
112
+ switch_: () => switch_,
113
+ template: () => template,
114
+ ternary: () => conditional,
115
+ times: () => multiply,
116
+ xor: () => xor
117
+ });
118
+ module.exports = __toCommonJS(src_exports);
119
+
120
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/types.ts
121
+ var FLUENT_BUILDER_SYMBOL = Symbol.for("fluent-builder");
122
+ var BranchTypes = {
123
+ SLOT: "slot",
124
+ ARRAY_ITEM: "array-item",
125
+ TEMPLATE: "template",
126
+ SWITCH: "switch",
127
+ CUSTOM: "custom"
128
+ };
129
+ var StorageKeys = {
130
+ TEMPLATES: "__templates__",
131
+ SWITCHES: "__switches__"
132
+ };
133
+ var PropertyKeys = {
134
+ ID: "id",
135
+ TYPE: "type",
136
+ VALUE: "value",
137
+ BINDING: "binding"
138
+ };
139
+
140
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/guards.ts
141
+ function isFluentBuilder(value) {
142
+ if (value === null || typeof value !== "object") {
143
+ return false;
144
+ }
145
+ if (!(FLUENT_BUILDER_SYMBOL in value)) {
146
+ return false;
147
+ }
148
+ const obj = value;
149
+ return obj[FLUENT_BUILDER_SYMBOL] === true && typeof obj.build === "function";
150
+ }
151
+ function isBuilderArray(value) {
152
+ return Array.isArray(value) && value.every(isFluentBuilder);
153
+ }
154
+ function isPlainObject(value) {
155
+ if (!value || typeof value !== "object") return false;
156
+ const proto = Object.getPrototypeOf(value);
157
+ return proto === Object.prototype || proto === null;
158
+ }
159
+ function isAsset(value) {
160
+ if (!value || typeof value !== "object") return false;
161
+ const obj = value;
162
+ return "type" in obj && typeof obj.type === "string";
163
+ }
164
+ function isAssetWrapper(value) {
165
+ if (!value || typeof value !== "object") return false;
166
+ const obj = value;
167
+ return "asset" in obj && typeof obj.asset === "object" && obj.asset !== null;
168
+ }
169
+ function isAssetWrapperWithAsset(value) {
170
+ return isAssetWrapper(value) && isAsset(value.asset);
171
+ }
172
+ function isAssetWrapperValue(value) {
173
+ return typeof value === "object" && value !== null && "asset" in value && Object.keys(value).length === 1;
174
+ }
175
+ function needsAssetWrapper(value) {
176
+ if (isAssetWrapper(value)) return false;
177
+ if (isFluentBuilder(value)) return false;
178
+ return isAsset(value);
179
+ }
180
+ function isSwitchResult(value) {
181
+ if (typeof value !== "object" || value === null) {
182
+ return false;
183
+ }
184
+ const obj = value;
185
+ return "staticSwitch" in obj || "dynamicSwitch" in obj;
186
+ }
187
+ function isStringOrUndefined(value) {
188
+ return value === void 0 || typeof value === "string";
189
+ }
190
+
191
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/id/registry.ts
192
+ var IDRegistry = class {
193
+ usedIds;
194
+ isEnabled;
195
+ constructor(enabled = true) {
196
+ this.usedIds = /* @__PURE__ */ new Set();
197
+ this.isEnabled = enabled;
198
+ }
199
+ /**
200
+ * Ensures the given ID is unique, modifying it if necessary.
201
+ * If the ID already exists, appends a numeric suffix (-1, -2, etc.)
202
+ * until a unique ID is found.
203
+ *
204
+ * Special handling for template placeholders:
205
+ * - IDs ending with `_index_`, `_row_`, etc. are allowed as duplicates
206
+ * - IDs with placeholders followed by segments (e.g., `_index_.field`) enforce uniqueness
207
+ *
208
+ * @param baseId - The desired ID
209
+ * @returns A unique ID (either the original or modified with suffix)
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const registry = new IDRegistry();
214
+ * registry.ensureUnique("my-id"); // "my-id"
215
+ * registry.ensureUnique("my-id"); // "my-id-1"
216
+ * registry.ensureUnique("list-_index_"); // "list-_index_" (allowed duplicate)
217
+ * registry.ensureUnique("list-_index_"); // "list-_index_" (allowed duplicate)
218
+ * ```
219
+ */
220
+ ensureUnique(baseId) {
221
+ if (!this.isEnabled) {
222
+ return baseId;
223
+ }
224
+ if (this.isTemplatePlaceholderID(baseId)) {
225
+ return baseId;
226
+ }
227
+ if (!this.usedIds.has(baseId)) {
228
+ this.usedIds.add(baseId);
229
+ return baseId;
230
+ }
231
+ let counter = 1;
232
+ let uniqueId = `${baseId}-${counter}`;
233
+ while (this.usedIds.has(uniqueId)) {
234
+ counter++;
235
+ uniqueId = `${baseId}-${counter}`;
236
+ }
237
+ this.usedIds.add(uniqueId);
238
+ return uniqueId;
239
+ }
240
+ /**
241
+ * Checks if an ID has already been used.
242
+ *
243
+ * @param id - The ID to check
244
+ * @returns true if the ID has been used, false otherwise
245
+ */
246
+ has(id) {
247
+ return this.usedIds.has(id);
248
+ }
249
+ /**
250
+ * Clears all registered IDs from the registry.
251
+ * Useful for resetting state between test runs or separate flows.
252
+ */
253
+ reset() {
254
+ this.usedIds.clear();
255
+ }
256
+ /**
257
+ * Enables or disables the uniqueness checking.
258
+ * When disabled, all IDs pass through unchanged.
259
+ *
260
+ * @param enabled - Whether to enable uniqueness checking
261
+ */
262
+ setEnabled(enabled) {
263
+ this.isEnabled = enabled;
264
+ }
265
+ /**
266
+ * Returns the number of unique IDs currently registered.
267
+ *
268
+ * @returns The count of registered IDs
269
+ */
270
+ size() {
271
+ return this.usedIds.size;
272
+ }
273
+ /**
274
+ * Returns a snapshot of all registered IDs.
275
+ * Useful for debugging and testing.
276
+ *
277
+ * @returns An array of all registered IDs
278
+ */
279
+ getRegisteredIds() {
280
+ return Array.from(this.usedIds);
281
+ }
282
+ /**
283
+ * Checks if an ID contains template placeholders that should be exempt from uniqueness checks.
284
+ * Template placeholders are patterns like `_index_`, `_index1_`, `_row_` that are replaced at runtime.
285
+ *
286
+ * IDs ending with just a placeholder (e.g., "parent-_index_") are allowed as duplicates.
287
+ * IDs with placeholders followed by additional segments (e.g., "parent-_index_-field") are not.
288
+ *
289
+ * @param id - The ID to check
290
+ * @returns true if the ID should be exempt from uniqueness checks
291
+ */
292
+ isTemplatePlaceholderID(id) {
293
+ const templatePlaceholderPattern = /_(?:index|row|item)\d*_$/;
294
+ return templatePlaceholderPattern.test(id);
295
+ }
296
+ };
297
+ var globalIdRegistry = new IDRegistry();
298
+ function createIdRegistry(enabled = true) {
299
+ return new IDRegistry(enabled);
300
+ }
301
+
302
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/id/generator.ts
303
+ var resetGlobalIdSet = () => {
304
+ globalIdRegistry.reset();
305
+ };
306
+ var _generateBaseId = (context, functionName) => {
307
+ if (!context) {
308
+ throw new Error(
309
+ `${functionName}: Context is undefined. Please provide a valid BaseBuildContext object.`
310
+ );
311
+ }
312
+ const { parentId, branch } = context;
313
+ let baseId;
314
+ if (!branch) {
315
+ baseId = parentId || "";
316
+ } else {
317
+ switch (branch.type) {
318
+ case "custom":
319
+ baseId = parentId || "";
320
+ break;
321
+ case "slot":
322
+ if (!branch.name) {
323
+ throw new Error(
324
+ `${functionName}: Slot branch requires a 'name' property. Context: ${JSON.stringify(context)}`
325
+ );
326
+ }
327
+ baseId = `${parentId ? `${parentId}-` : ""}${branch.name}`;
328
+ break;
329
+ case "array-item":
330
+ if (typeof branch.index !== "number") {
331
+ throw new Error(
332
+ `${functionName}: Array-item branch requires a numeric 'index' property. Got: ${typeof branch.index}. Context: ${JSON.stringify(context)}`
333
+ );
334
+ }
335
+ if (branch.index < 0) {
336
+ throw new Error(
337
+ `${functionName}: Array-item index must be non-negative. Got: ${branch.index}. Context: ${JSON.stringify(context)}`
338
+ );
339
+ }
340
+ baseId = `${parentId}-${branch.index}`;
341
+ break;
342
+ case "template":
343
+ if (branch.depth !== void 0 && branch.depth < 0) {
344
+ throw new Error(
345
+ `${functionName}: Template depth must be non-negative. Got: ${branch.depth}. Context: ${JSON.stringify(context)}`
346
+ );
347
+ }
348
+ baseId = `${parentId}-_index${branch.depth || ""}_`;
349
+ break;
350
+ case "switch":
351
+ if (typeof branch.index !== "number") {
352
+ throw new Error(
353
+ `${functionName}: Switch branch requires a numeric 'index' property. Got: ${typeof branch.index}. Context: ${JSON.stringify(context)}`
354
+ );
355
+ }
356
+ if (branch.index < 0) {
357
+ throw new Error(
358
+ `${functionName}: Switch index must be non-negative. Got: ${branch.index}. Context: ${JSON.stringify(context)}`
359
+ );
360
+ }
361
+ if (!branch.kind || !["static", "dynamic"].includes(branch.kind)) {
362
+ throw new Error(
363
+ `${functionName}: Switch branch requires 'kind' to be 'static' or 'dynamic'. Got: ${branch.kind}. Context: ${JSON.stringify(context)}`
364
+ );
365
+ }
366
+ baseId = `${parentId}-${branch.kind}Switch-${branch.index}`;
367
+ break;
368
+ default: {
369
+ const exhaustiveCheck = branch;
370
+ throw new Error(
371
+ `${functionName}: Unhandled branch type: ${JSON.stringify(exhaustiveCheck)}`
372
+ );
373
+ }
374
+ }
375
+ }
376
+ return baseId;
377
+ };
378
+ var peekId = (context) => {
379
+ return _generateBaseId(context, "peekId");
380
+ };
381
+ var genId = (context) => {
382
+ const baseId = _generateBaseId(context, "genId");
383
+ const { parentId, branch } = context;
384
+ if (process.env.NODE_ENV !== "production" && !parentId && !branch) {
385
+ console.warn(
386
+ "genId: Context appears incomplete (no parentId or branch). This may result in an empty or invalid ID. Consider using context helper functions from 'fluent/utils/context'."
387
+ );
388
+ }
389
+ if (process.env.NODE_ENV !== "production" && parentId === "") {
390
+ console.warn(
391
+ "genId: parentId is an empty string. This may indicate a missing or improperly initialized context."
392
+ );
393
+ }
394
+ const uniqueId = globalIdRegistry.ensureUnique(baseId);
395
+ if (process.env.NODE_ENV !== "production" && uniqueId !== baseId) {
396
+ console.warn(
397
+ `genId: ID collision detected. Original: "${baseId}", Modified to: "${uniqueId}". Consider providing more specific IDs to avoid collisions.`
398
+ );
399
+ }
400
+ return uniqueId;
401
+ };
402
+ function determineSlotName(parameterName, assetMetadata) {
403
+ if (!assetMetadata) {
404
+ return parameterName;
405
+ }
406
+ const { type, binding: binding2, value } = assetMetadata;
407
+ if (type === "action" && value) {
408
+ const cleanValue = value.replace(/^\{\{|\}\}$/g, "");
409
+ const segments = cleanValue.split(".");
410
+ const lastSegment = segments[segments.length - 1];
411
+ return lastSegment ? `${type}-${lastSegment}` : type;
412
+ }
413
+ if (type !== "action" && binding2) {
414
+ const cleanBinding = binding2.replace(/^\{\{|\}\}$/g, "");
415
+ const segments = cleanBinding.split(".");
416
+ const lastSegment = segments[segments.length - 1];
417
+ if (lastSegment) {
418
+ return `${type || parameterName}-${lastSegment}`;
419
+ }
420
+ }
421
+ return type || parameterName;
422
+ }
423
+ function generateAssetId(params) {
424
+ const {
425
+ context,
426
+ parameterName = "asset",
427
+ assetMetadata,
428
+ explicitId
429
+ } = params;
430
+ if (explicitId) {
431
+ return explicitId;
432
+ }
433
+ if (context && "parentId" in context) {
434
+ const slotName2 = determineSlotName(parameterName, assetMetadata);
435
+ if (context.branch) {
436
+ const baseId = genId(context);
437
+ return genId({
438
+ ...context,
439
+ parentId: baseId,
440
+ branch: { type: BranchTypes.SLOT, name: slotName2 }
441
+ });
442
+ }
443
+ if (context.parentId) {
444
+ return genId({
445
+ ...context,
446
+ branch: { type: BranchTypes.SLOT, name: slotName2 }
447
+ });
448
+ }
449
+ }
450
+ const slotName = determineSlotName(parameterName, assetMetadata);
451
+ return slotName;
452
+ }
453
+
454
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/context.ts
455
+ function buildContextParams(parentContext, parameterName, index) {
456
+ const params = {
457
+ parentContext,
458
+ parameterName
459
+ };
460
+ if (index !== void 0) {
461
+ return { ...params, index };
462
+ }
463
+ return params;
464
+ }
465
+ function createNestedContext({
466
+ parentContext,
467
+ parameterName,
468
+ index,
469
+ assetMetadata
470
+ }) {
471
+ if (parentContext.nestedContextGenerator) {
472
+ const contextParams = buildContextParams(
473
+ parentContext,
474
+ parameterName,
475
+ index
476
+ );
477
+ const generated = parentContext.nestedContextGenerator(contextParams);
478
+ return generated;
479
+ }
480
+ const slotName = determineSlotName(parameterName, assetMetadata);
481
+ let generatedId;
482
+ let branch;
483
+ if (parentContext && "parentId" in parentContext) {
484
+ if (index !== void 0) {
485
+ generatedId = peekId({
486
+ parentId: parentContext.parentId,
487
+ branch: { type: BranchTypes.SLOT, name: slotName }
488
+ });
489
+ branch = { type: BranchTypes.ARRAY_ITEM, index };
490
+ } else {
491
+ generatedId = genId({
492
+ parentId: parentContext.parentId,
493
+ branch: { type: BranchTypes.SLOT, name: slotName }
494
+ });
495
+ }
496
+ }
497
+ const newContext = index !== void 0 ? {
498
+ ...parentContext,
499
+ parameterName,
500
+ index,
501
+ ...generatedId ? { parentId: generatedId } : {},
502
+ ...assetMetadata ? { assetMetadata } : {},
503
+ ...branch ? { branch } : {}
504
+ } : {
505
+ ...parentContext,
506
+ parameterName,
507
+ ...generatedId ? { parentId: generatedId } : {},
508
+ ...assetMetadata ? { assetMetadata } : {}
509
+ };
510
+ return newContext;
511
+ }
512
+ function createTemplateContext({
513
+ parentContext,
514
+ depth = 0
515
+ }) {
516
+ const parentId = genId(parentContext);
517
+ const templateContext = {
518
+ ...parentContext,
519
+ parentId,
520
+ branch: {
521
+ type: BranchTypes.TEMPLATE,
522
+ depth
523
+ }
524
+ };
525
+ return templateContext;
526
+ }
527
+ function createSwitchContext({
528
+ parentContext,
529
+ index,
530
+ kind
531
+ }) {
532
+ const switchContext = {
533
+ ...parentContext,
534
+ branch: {
535
+ type: BranchTypes.SWITCH,
536
+ index,
537
+ kind
538
+ }
539
+ };
540
+ return switchContext;
541
+ }
542
+
543
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/types.ts
544
+ var TaggedTemplateValueSymbol = Symbol(
545
+ "TaggedTemplateValue"
546
+ );
547
+ function isTaggedTemplateValue(value) {
548
+ return typeof value === "object" && value !== null && TaggedTemplateValueSymbol in value;
549
+ }
550
+
551
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/binding.ts
552
+ function binding(strings, ...expressions) {
553
+ let indexCounter = 0;
554
+ const processValue = (val) => {
555
+ if (!val.includes("_index_")) return val;
556
+ return val.replace(/_index_/g, () => {
557
+ const suffix = indexCounter > 0 ? indexCounter : "";
558
+ indexCounter++;
559
+ return `_index${suffix}_`;
560
+ });
561
+ };
562
+ let result = "";
563
+ const len = strings.length;
564
+ for (let i = 0; i < len; i++) {
565
+ result += processValue(strings[i]);
566
+ if (i < expressions.length) {
567
+ const expr = expressions[i];
568
+ if (isTaggedTemplateValue(expr)) {
569
+ const refStr = expr.toRefString();
570
+ if (refStr.startsWith("@[")) {
571
+ result += expr.toRefString({ nestedContext: "binding" });
572
+ } else {
573
+ result += expr.toString();
574
+ }
575
+ } else if (typeof expr === "string") {
576
+ result += processValue(expr);
577
+ } else {
578
+ result += String(expr);
579
+ }
580
+ }
581
+ }
582
+ const templateValue = {
583
+ [TaggedTemplateValueSymbol]: true,
584
+ _phantomType: void 0,
585
+ toValue() {
586
+ return result;
587
+ },
588
+ toRefString(options) {
589
+ if (options?.nestedContext === "binding") {
590
+ return result;
591
+ }
592
+ return `{{${result}}}`;
593
+ },
594
+ toString() {
595
+ return `{{${result}}}`;
596
+ }
597
+ };
598
+ return templateValue;
599
+ }
600
+
601
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/expression.ts
602
+ function expression(strings, ...expressions) {
603
+ const validateSyntax = (expr) => {
604
+ let openParens = 0;
605
+ let position = 0;
606
+ for (const char of expr) {
607
+ if (char === "(") openParens++;
608
+ if (char === ")") openParens--;
609
+ position++;
610
+ if (openParens < 0) {
611
+ throw new Error(
612
+ `Error: Unexpected ) at character ${position} in expression:
613
+ ${expr.slice(
614
+ 0,
615
+ position
616
+ )}\u2588${expr.slice(position)}`
617
+ );
618
+ }
619
+ }
620
+ if (openParens > 0) {
621
+ throw new Error(
622
+ `Error: Expected ) at character ${position} in expression:
623
+ ${expr}\u2588`
624
+ );
625
+ }
626
+ };
627
+ let result = "";
628
+ const len = strings.length;
629
+ for (let i = 0; i < len; i++) {
630
+ result += strings[i];
631
+ if (i < expressions.length) {
632
+ const expr = expressions[i];
633
+ if (isTaggedTemplateValue(expr)) {
634
+ result += expr.toRefString({ nestedContext: "expression" });
635
+ } else {
636
+ result += String(expr);
637
+ }
638
+ }
639
+ }
640
+ validateSyntax(result);
641
+ return {
642
+ [TaggedTemplateValueSymbol]: true,
643
+ toValue() {
644
+ return result;
645
+ },
646
+ toRefString(options) {
647
+ if (options?.nestedContext === "binding") {
648
+ return `\`${result}\``;
649
+ } else if (options?.nestedContext === "expression") {
650
+ return result;
651
+ }
652
+ return `@[${result}]@`;
653
+ },
654
+ toString() {
655
+ return `@[${result}]@`;
656
+ }
657
+ };
658
+ }
659
+
660
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/extract-bindings-from-schema.ts
661
+ function extractBindingsFromSchema(schema) {
662
+ const primitiveTypes = /* @__PURE__ */ new Set(["StringType", "NumberType", "BooleanType"]);
663
+ const isPrimitive = (typeName) => {
664
+ return primitiveTypes.has(typeName);
665
+ };
666
+ const createBinding = (typeName, path) => {
667
+ if (typeName === "StringType") {
668
+ return binding`${path}`;
669
+ }
670
+ if (typeName === "NumberType") {
671
+ return binding`${path}`;
672
+ }
673
+ if (typeName === "BooleanType") {
674
+ return binding`${path}`;
675
+ }
676
+ return binding`${path}`;
677
+ };
678
+ const processDataType = (dataType, schema2, path, visited = /* @__PURE__ */ new Set()) => {
679
+ const typeName = dataType.type;
680
+ if (visited.has(typeName)) {
681
+ return createBinding("StringType", path);
682
+ }
683
+ if ("isArray" in dataType && dataType.isArray) {
684
+ const arrayPath = path ? `${path}._current_` : "_current_";
685
+ if (isPrimitive(typeName)) {
686
+ if (typeName === "StringType") {
687
+ return { name: createBinding(typeName, arrayPath) };
688
+ } else {
689
+ return { value: createBinding(typeName, arrayPath) };
690
+ }
691
+ } else {
692
+ const typeNode2 = schema2[typeName];
693
+ if (typeNode2) {
694
+ const newVisited = new Set(visited);
695
+ newVisited.add(typeName);
696
+ return processNode(
697
+ typeNode2,
698
+ schema2,
699
+ arrayPath,
700
+ newVisited
701
+ );
702
+ }
703
+ return createBinding("StringType", arrayPath);
704
+ }
705
+ }
706
+ if ("isRecord" in dataType && dataType.isRecord) {
707
+ const typeNode2 = schema2[typeName];
708
+ if (typeNode2) {
709
+ const newVisited = new Set(visited);
710
+ newVisited.add(typeName);
711
+ return processNode(typeNode2, schema2, path, newVisited);
712
+ }
713
+ return createBinding("StringType", path);
714
+ }
715
+ if (isPrimitive(typeName)) {
716
+ return createBinding(typeName, path);
717
+ }
718
+ const typeNode = schema2[typeName];
719
+ if (typeNode) {
720
+ const newVisited = new Set(visited);
721
+ newVisited.add(typeName);
722
+ return processNode(typeNode, schema2, path, newVisited);
723
+ }
724
+ return createBinding("StringType", path);
725
+ };
726
+ const processNode = (node, schema2, basePath, visited = /* @__PURE__ */ new Set()) => {
727
+ const result = {};
728
+ Object.entries(node).forEach(([key, dataType]) => {
729
+ const path = basePath ? `${basePath}.${key}` : key;
730
+ result[key] = processDataType(dataType, schema2, path, visited);
731
+ });
732
+ return result;
733
+ };
734
+ return processNode(schema.ROOT, schema, "");
735
+ }
736
+
737
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/std.ts
738
+ function and(...args) {
739
+ const expressions = args.map((arg) => {
740
+ if (isTaggedTemplateValue(arg)) {
741
+ const expr = arg.toRefString({ nestedContext: "expression" });
742
+ if (expr.includes(" || ") && !expr.startsWith("(")) {
743
+ return `(${expr})`;
744
+ }
745
+ return expr;
746
+ }
747
+ return String(arg);
748
+ });
749
+ return expression`${expressions.join(" && ")}`;
750
+ }
751
+ function or(...args) {
752
+ const expressions = args.map((arg) => {
753
+ if (isTaggedTemplateValue(arg)) {
754
+ return arg.toRefString({ nestedContext: "expression" });
755
+ }
756
+ return String(arg);
757
+ });
758
+ return expression`${expressions.join(" || ")}`;
759
+ }
760
+ function not(value) {
761
+ const expr = isTaggedTemplateValue(value) ? value.toRefString({ nestedContext: "expression" }) : String(value);
762
+ return expression`!${expr}`;
763
+ }
764
+ function nor(...args) {
765
+ return not(or(...args));
766
+ }
767
+ function nand(...args) {
768
+ return not(and(...args));
769
+ }
770
+ function xor(left, right) {
771
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : String(left);
772
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : String(right);
773
+ return expression`(${leftExpr} && !${rightExpr}) || (!${leftExpr} && ${rightExpr})`;
774
+ }
775
+ function equal(left, right) {
776
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : JSON.stringify(left);
777
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : JSON.stringify(right);
778
+ return expression`${leftExpr} == ${rightExpr}`;
779
+ }
780
+ function strictEqual(left, right) {
781
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : JSON.stringify(left);
782
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : JSON.stringify(right);
783
+ return expression`${leftExpr} === ${rightExpr}`;
784
+ }
785
+ function notEqual(left, right) {
786
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : JSON.stringify(left);
787
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : JSON.stringify(right);
788
+ return expression`${leftExpr} != ${rightExpr}`;
789
+ }
790
+ function strictNotEqual(left, right) {
791
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : JSON.stringify(left);
792
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : JSON.stringify(right);
793
+ return expression`${leftExpr} !== ${rightExpr}`;
794
+ }
795
+ function greaterThan(left, right) {
796
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : JSON.stringify(left);
797
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : JSON.stringify(right);
798
+ return expression`${leftExpr} > ${rightExpr}`;
799
+ }
800
+ function greaterThanOrEqual(left, right) {
801
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : JSON.stringify(left);
802
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : JSON.stringify(right);
803
+ return expression`${leftExpr} >= ${rightExpr}`;
804
+ }
805
+ function lessThan(left, right) {
806
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : JSON.stringify(left);
807
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : JSON.stringify(right);
808
+ return expression`${leftExpr} < ${rightExpr}`;
809
+ }
810
+ function lessThanOrEqual(left, right) {
811
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : JSON.stringify(left);
812
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : JSON.stringify(right);
813
+ return expression`${leftExpr} <= ${rightExpr}`;
814
+ }
815
+ function add(...args) {
816
+ const expressions = args.map((arg) => {
817
+ if (isTaggedTemplateValue(arg)) {
818
+ return arg.toRefString({ nestedContext: "expression" });
819
+ }
820
+ return String(arg);
821
+ });
822
+ return expression`${expressions.join(" + ")}`;
823
+ }
824
+ function subtract(left, right) {
825
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : String(left);
826
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : String(right);
827
+ return expression`${leftExpr} - ${rightExpr}`;
828
+ }
829
+ function multiply(...args) {
830
+ const expressions = args.map((arg) => {
831
+ if (isTaggedTemplateValue(arg)) {
832
+ return arg.toRefString({ nestedContext: "expression" });
833
+ }
834
+ return String(arg);
835
+ });
836
+ return expression`${expressions.join(" * ")}`;
837
+ }
838
+ function divide(left, right) {
839
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : String(left);
840
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : String(right);
841
+ return expression`${leftExpr} / ${rightExpr}`;
842
+ }
843
+ function modulo(left, right) {
844
+ const leftExpr = isTaggedTemplateValue(left) ? left.toRefString({ nestedContext: "expression" }) : String(left);
845
+ const rightExpr = isTaggedTemplateValue(right) ? right.toRefString({ nestedContext: "expression" }) : String(right);
846
+ return expression`${leftExpr} % ${rightExpr}`;
847
+ }
848
+ function conditional(condition, ifTrue, ifFalse) {
849
+ const conditionExpr = isTaggedTemplateValue(condition) ? condition.toRefString({ nestedContext: "expression" }) : String(condition);
850
+ const trueExpr = isTaggedTemplateValue(ifTrue) ? ifTrue.toRefString({ nestedContext: "expression" }) : JSON.stringify(ifTrue);
851
+ const falseExpr = isTaggedTemplateValue(ifFalse) ? ifFalse.toRefString({ nestedContext: "expression" }) : JSON.stringify(ifFalse);
852
+ return expression`${conditionExpr} ? ${trueExpr} : ${falseExpr}`;
853
+ }
854
+ function call(functionName, ...args) {
855
+ const argExpressions = args.map((arg) => {
856
+ if (isTaggedTemplateValue(arg)) {
857
+ return arg.toRefString({
858
+ nestedContext: "expression"
859
+ });
860
+ }
861
+ return JSON.stringify(arg);
862
+ });
863
+ return expression`${functionName}(${argExpressions.join(", ")})`;
864
+ }
865
+ function literal(value) {
866
+ return expression`${JSON.stringify(value)}`;
867
+ }
868
+
869
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/value-resolver.ts
870
+ function extractObject(value, options) {
871
+ const visited = options.visited ?? /* @__PURE__ */ new WeakSet();
872
+ if (visited.has(value)) {
873
+ return value;
874
+ }
875
+ visited.add(value);
876
+ const result = {};
877
+ for (const [key, val] of Object.entries(value)) {
878
+ result[key] = extractValue(val, { propertyKey: key, visited });
879
+ }
880
+ return result;
881
+ }
882
+ function extractValue(value, options = {}) {
883
+ const { propertyKey, visited = /* @__PURE__ */ new WeakSet() } = options;
884
+ if (isTaggedTemplateValue(value)) {
885
+ if (propertyKey === "data" || propertyKey === "binding") {
886
+ return value.toValue();
887
+ }
888
+ return value.toString();
889
+ }
890
+ if (Array.isArray(value)) {
891
+ if (visited.has(value)) {
892
+ return value;
893
+ }
894
+ visited.add(value);
895
+ return value.map((item) => extractValue(item, { visited }));
896
+ }
897
+ if (isPlainObject(value) && !isFluentBuilder(value) && !isAssetWrapper(value)) {
898
+ return extractObject(value, { visited });
899
+ }
900
+ return value;
901
+ }
902
+ function wrapAsset(asset, context, slotName) {
903
+ if (!context) {
904
+ return { asset };
905
+ }
906
+ if (asset.id) {
907
+ return { asset: { ...asset } };
908
+ }
909
+ const parentId = peekId(context);
910
+ const slotCtx = {
911
+ parentId,
912
+ branch: { type: BranchTypes.SLOT, name: slotName }
913
+ };
914
+ return {
915
+ asset: {
916
+ ...asset,
917
+ id: genId(slotCtx)
918
+ }
919
+ };
920
+ }
921
+ function resolveValue(value, options = {}) {
922
+ const { context, propertyName, visited = /* @__PURE__ */ new WeakSet() } = options;
923
+ if (isTaggedTemplateValue(value)) {
924
+ if (propertyName === "data" || propertyName === "binding") {
925
+ return value.toValue();
926
+ }
927
+ return value.toString();
928
+ }
929
+ if (value === null || value === void 0) {
930
+ return value;
931
+ }
932
+ if (isFluentBuilder(value)) {
933
+ return value.build(context);
934
+ }
935
+ if (isAssetWrapper(value)) {
936
+ if (visited.has(value)) return value;
937
+ visited.add(value);
938
+ const innerAsset = value.asset;
939
+ const resolvedAsset = resolveValue(innerAsset, {
940
+ context,
941
+ propertyName,
942
+ visited
943
+ });
944
+ return { asset: resolvedAsset };
945
+ }
946
+ if (Array.isArray(value)) {
947
+ if (visited.has(value)) return value;
948
+ visited.add(value);
949
+ return value.filter((item) => item !== null && item !== void 0).map((item, index) => {
950
+ const arrayContext = context ? createNestedContext({
951
+ parentContext: context,
952
+ parameterName: propertyName || "array",
953
+ index
954
+ }) : void 0;
955
+ return resolveValue(item, {
956
+ context: arrayContext,
957
+ propertyName: String(index),
958
+ visited
959
+ });
960
+ });
961
+ }
962
+ if (isPlainObject(value) && !isAsset(value)) {
963
+ if (visited.has(value)) return value;
964
+ visited.add(value);
965
+ const resolved = {};
966
+ for (const [key, val] of Object.entries(value)) {
967
+ const nestedContext = context ? createNestedContext({ parentContext: context, parameterName: key }) : void 0;
968
+ resolved[key] = resolveValue(val, {
969
+ context: nestedContext,
970
+ propertyName: key,
971
+ visited
972
+ });
973
+ }
974
+ return resolved;
975
+ }
976
+ return value;
977
+ }
978
+ function resolveAndWrapAsset(value, options) {
979
+ const { context, slotName, visited = /* @__PURE__ */ new WeakSet() } = options;
980
+ if (value === null || value === void 0) {
981
+ return value;
982
+ }
983
+ if (isAssetWrapper(value)) {
984
+ if (visited.has(value)) return value;
985
+ visited.add(value);
986
+ const resolvedAsset = resolveValue(value.asset, {
987
+ context,
988
+ propertyName: slotName,
989
+ visited
990
+ });
991
+ return { asset: resolvedAsset };
992
+ }
993
+ if (isFluentBuilder(value)) {
994
+ if (!context) {
995
+ const built2 = value.build(void 0);
996
+ if (isAssetWrapper(built2)) {
997
+ return built2;
998
+ }
999
+ if (isAsset(built2)) {
1000
+ return { asset: built2 };
1001
+ }
1002
+ return built2;
1003
+ }
1004
+ const parentId = peekId(context);
1005
+ const slotContext = {
1006
+ ...context,
1007
+ parentId,
1008
+ branch: { type: BranchTypes.SLOT, name: slotName }
1009
+ };
1010
+ const built = value.build(slotContext);
1011
+ if (isAssetWrapper(built)) {
1012
+ return built;
1013
+ }
1014
+ if (isAsset(built)) {
1015
+ return { asset: built };
1016
+ }
1017
+ return built;
1018
+ }
1019
+ if (isAsset(value)) {
1020
+ return wrapAsset(value, context, slotName);
1021
+ }
1022
+ return resolveValue(value, { context, propertyName: slotName, visited });
1023
+ }
1024
+
1025
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/storage/value-storage.ts
1026
+ var ValueStorage = class _ValueStorage {
1027
+ values = {};
1028
+ builders = /* @__PURE__ */ new Map();
1029
+ mixedArrays = /* @__PURE__ */ new Map();
1030
+ constructor(initial) {
1031
+ if (initial) {
1032
+ Object.entries(initial).forEach(([key, value]) => {
1033
+ this.set(key, value);
1034
+ });
1035
+ }
1036
+ }
1037
+ /**
1038
+ * Sets a property value, intelligently routing it to the appropriate storage
1039
+ *
1040
+ * This method performs runtime type checking to determine how to store the value:
1041
+ * - FluentBuilder instances → builders Map
1042
+ * - Arrays with builders → mixedArrays Map
1043
+ * - Objects with builders → builders Map
1044
+ * - Everything else → values (static storage)
1045
+ */
1046
+ set(key, value) {
1047
+ const keyStr = String(key);
1048
+ if (isFluentBuilder(value)) {
1049
+ this.builders.set(keyStr, value);
1050
+ delete this.values[key];
1051
+ this.mixedArrays.delete(keyStr);
1052
+ } else if (Array.isArray(value)) {
1053
+ this.handleArrayValue(key, keyStr, value);
1054
+ } else if (typeof value === "object" && value !== null && this.containsBuilder(value)) {
1055
+ this.builders.set(keyStr, value);
1056
+ delete this.values[key];
1057
+ this.mixedArrays.delete(keyStr);
1058
+ } else {
1059
+ this.setStaticValue(key, keyStr, value);
1060
+ }
1061
+ }
1062
+ /**
1063
+ * Handles array value storage, detecting mixed arrays with builders
1064
+ */
1065
+ handleArrayValue(key, keyStr, value) {
1066
+ const builderIndices = /* @__PURE__ */ new Set();
1067
+ const objectIndices = /* @__PURE__ */ new Set();
1068
+ value.forEach((item, index) => {
1069
+ if (isFluentBuilder(item)) {
1070
+ builderIndices.add(index);
1071
+ } else if (typeof item === "object" && item !== null && this.containsBuilder(item)) {
1072
+ objectIndices.add(index);
1073
+ }
1074
+ });
1075
+ const hasBuilders = builderIndices.size > 0 || objectIndices.size > 0;
1076
+ if (hasBuilders) {
1077
+ this.mixedArrays.set(keyStr, {
1078
+ array: value,
1079
+ builderIndices,
1080
+ objectIndices
1081
+ });
1082
+ delete this.values[key];
1083
+ } else {
1084
+ this.setStaticValue(key, keyStr, value);
1085
+ this.mixedArrays.delete(keyStr);
1086
+ }
1087
+ this.builders.delete(keyStr);
1088
+ }
1089
+ /**
1090
+ * Sets a static value with proper type handling
1091
+ */
1092
+ setStaticValue(key, keyStr, value) {
1093
+ this.values[key] = value;
1094
+ this.builders.delete(keyStr);
1095
+ this.mixedArrays.delete(keyStr);
1096
+ }
1097
+ /**
1098
+ * Checks if an object contains any builders recursively
1099
+ * Handles circular references gracefully
1100
+ */
1101
+ containsBuilder(obj, visited = /* @__PURE__ */ new WeakSet()) {
1102
+ if (isFluentBuilder(obj)) return true;
1103
+ if (!obj || typeof obj !== "object") return false;
1104
+ if (visited.has(obj)) return false;
1105
+ visited.add(obj);
1106
+ if (Array.isArray(obj)) {
1107
+ return obj.some((item) => this.containsBuilder(item, visited));
1108
+ }
1109
+ const proto = Object.getPrototypeOf(obj);
1110
+ if (proto === Object.prototype || proto === null) {
1111
+ return Object.values(obj).some(
1112
+ (val) => this.containsBuilder(val, visited)
1113
+ );
1114
+ }
1115
+ return false;
1116
+ }
1117
+ /**
1118
+ * Checks if a property has been set
1119
+ */
1120
+ has(key) {
1121
+ const keyStr = String(key);
1122
+ return key in this.values || this.builders.has(keyStr) || this.mixedArrays.has(keyStr);
1123
+ }
1124
+ /**
1125
+ * Peeks at a property value without resolving builders
1126
+ * Returns the raw value if it's static, the array if it's mixed, or undefined if it's a builder
1127
+ */
1128
+ peek(key) {
1129
+ const keyStr = String(key);
1130
+ const mixedArray = this.mixedArrays.get(keyStr);
1131
+ if (mixedArray) {
1132
+ return mixedArray.array;
1133
+ }
1134
+ if (this.builders.has(keyStr)) {
1135
+ return void 0;
1136
+ }
1137
+ return this.values[key];
1138
+ }
1139
+ /**
1140
+ * Gets builder for a property if one is set
1141
+ */
1142
+ peekBuilder(key) {
1143
+ const keyStr = String(key);
1144
+ const entry = this.builders.get(keyStr);
1145
+ if (!entry) return void 0;
1146
+ if (isFluentBuilder(entry)) {
1147
+ return entry;
1148
+ }
1149
+ return void 0;
1150
+ }
1151
+ /**
1152
+ * Gets the type of value stored for a property
1153
+ */
1154
+ getValueType(key) {
1155
+ const keyStr = String(key);
1156
+ if (this.mixedArrays.has(keyStr)) {
1157
+ return "mixed-array";
1158
+ }
1159
+ if (this.builders.has(keyStr)) {
1160
+ return "builder";
1161
+ }
1162
+ if (key in this.values) {
1163
+ return "static";
1164
+ }
1165
+ return "unset";
1166
+ }
1167
+ /**
1168
+ * Gets all static values for the build pipeline
1169
+ */
1170
+ getValues() {
1171
+ return this.values;
1172
+ }
1173
+ /**
1174
+ * Gets all builder entries for the build pipeline
1175
+ */
1176
+ getBuilders() {
1177
+ return this.builders;
1178
+ }
1179
+ /**
1180
+ * Gets all mixed array entries for the build pipeline
1181
+ */
1182
+ getMixedArrays() {
1183
+ return this.mixedArrays;
1184
+ }
1185
+ /**
1186
+ * Unsets a property, removing it from storage
1187
+ */
1188
+ unset(key) {
1189
+ const keyStr = String(key);
1190
+ delete this.values[key];
1191
+ this.builders.delete(keyStr);
1192
+ this.mixedArrays.delete(keyStr);
1193
+ }
1194
+ /**
1195
+ * Clears all properties from storage
1196
+ */
1197
+ clear() {
1198
+ this.values = {};
1199
+ this.builders.clear();
1200
+ this.mixedArrays.clear();
1201
+ }
1202
+ /**
1203
+ * Clones the storage, creating an independent copy
1204
+ */
1205
+ clone() {
1206
+ const cloned = new _ValueStorage();
1207
+ cloned.values = { ...this.values };
1208
+ cloned.builders = new Map(this.builders);
1209
+ cloned.mixedArrays = new Map(
1210
+ Array.from(this.mixedArrays.entries()).map(([key, metadata]) => [
1211
+ key,
1212
+ {
1213
+ array: metadata.array,
1214
+ builderIndices: new Set(metadata.builderIndices),
1215
+ objectIndices: new Set(metadata.objectIndices)
1216
+ }
1217
+ ])
1218
+ );
1219
+ return cloned;
1220
+ }
1221
+ };
1222
+
1223
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/storage/auxiliary-storage.ts
1224
+ var AuxiliaryStorage = class _AuxiliaryStorage {
1225
+ data = /* @__PURE__ */ new Map();
1226
+ /**
1227
+ * Sets auxiliary data with a given key
1228
+ */
1229
+ set(key, value) {
1230
+ this.data.set(key, value);
1231
+ }
1232
+ /**
1233
+ * Gets auxiliary data with type assertion
1234
+ * The caller is responsible for knowing the correct type
1235
+ */
1236
+ get(key) {
1237
+ const value = this.data.get(key);
1238
+ return value;
1239
+ }
1240
+ /**
1241
+ * Pushes an item to an auxiliary data array
1242
+ * Creates the array if it doesn't exist
1243
+ */
1244
+ push(key, item) {
1245
+ const existing = this.data.get(key);
1246
+ if (Array.isArray(existing)) {
1247
+ existing.push(item);
1248
+ } else {
1249
+ this.data.set(key, [item]);
1250
+ }
1251
+ }
1252
+ /**
1253
+ * Gets an auxiliary data array
1254
+ * Returns empty array if doesn't exist or isn't an array
1255
+ */
1256
+ getArray(key) {
1257
+ const existing = this.data.get(key);
1258
+ return Array.isArray(existing) ? existing : [];
1259
+ }
1260
+ /**
1261
+ * Checks if auxiliary data exists for a key
1262
+ */
1263
+ has(key) {
1264
+ return this.data.has(key);
1265
+ }
1266
+ /**
1267
+ * Deletes auxiliary data for a key
1268
+ */
1269
+ delete(key) {
1270
+ return this.data.delete(key);
1271
+ }
1272
+ /**
1273
+ * Clears all auxiliary data
1274
+ */
1275
+ clear() {
1276
+ this.data.clear();
1277
+ }
1278
+ /**
1279
+ * Clones the auxiliary storage, creating an independent copy
1280
+ */
1281
+ clone() {
1282
+ const cloned = new _AuxiliaryStorage();
1283
+ cloned.data = new Map(this.data);
1284
+ return cloned;
1285
+ }
1286
+ };
1287
+
1288
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/static-values.ts
1289
+ function resolveStaticValues(storage, result, context) {
1290
+ const values = storage.getValues();
1291
+ for (const [key, value] of Object.entries(values)) {
1292
+ if (!isAssetWrapperValue(value)) {
1293
+ const extracted = extractValue(value, { propertyKey: key });
1294
+ result[key] = resolveValue(extracted, { context, propertyName: key });
1295
+ } else {
1296
+ result[key] = value;
1297
+ }
1298
+ }
1299
+ }
1300
+
1301
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/asset-id.ts
1302
+ function generateAssetIdForBuilder(storage, result, context) {
1303
+ const hasIdSet = storage.has("id");
1304
+ const hasType = storage.has("type") || "type" in result;
1305
+ const hasIdField = "id" in result;
1306
+ if (!hasIdSet && hasType) {
1307
+ const typeValue = result.type;
1308
+ const assetValue = result.value;
1309
+ const assetBinding = result.binding;
1310
+ if (!isStringOrUndefined(typeValue)) {
1311
+ return;
1312
+ }
1313
+ if (!isStringOrUndefined(assetValue)) {
1314
+ return;
1315
+ }
1316
+ if (!isStringOrUndefined(assetBinding)) {
1317
+ return;
1318
+ }
1319
+ const assetMetadata = {
1320
+ type: typeValue,
1321
+ ...assetValue ? { value: assetValue } : {},
1322
+ ...assetBinding ? { binding: assetBinding } : {}
1323
+ };
1324
+ const generatedId = generateAssetId({
1325
+ context,
1326
+ parameterName: typeValue,
1327
+ assetMetadata,
1328
+ explicitId: void 0
1329
+ });
1330
+ if (generatedId) {
1331
+ result.id = generatedId;
1332
+ }
1333
+ } else if (!hasIdSet && hasIdField && !hasType && context && context.branch) {
1334
+ const generatedId = generateAssetId({
1335
+ context,
1336
+ parameterName: "item",
1337
+ assetMetadata: void 0,
1338
+ explicitId: void 0
1339
+ });
1340
+ if (generatedId) {
1341
+ result.id = generatedId;
1342
+ }
1343
+ }
1344
+ }
1345
+
1346
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/asset-wrappers.ts
1347
+ function resolveAssetWrappers(storage, result, nestedParentContext) {
1348
+ if (!nestedParentContext) {
1349
+ return;
1350
+ }
1351
+ const values = storage.getValues();
1352
+ for (const key of Object.keys(values)) {
1353
+ const value = values[key];
1354
+ if (isAssetWrapperValue(value)) {
1355
+ const unwrapped = value.asset;
1356
+ if (Array.isArray(unwrapped)) {
1357
+ result[key] = resolveAssetWrapperArray(
1358
+ unwrapped,
1359
+ nestedParentContext,
1360
+ key
1361
+ );
1362
+ } else {
1363
+ result[key] = resolveAndWrapAsset(unwrapped, {
1364
+ context: nestedParentContext,
1365
+ slotName: key
1366
+ });
1367
+ }
1368
+ }
1369
+ }
1370
+ }
1371
+ function resolveAssetWrapperArray(array, context, key) {
1372
+ return array.filter((item) => item !== null && item !== void 0).map((item, index) => {
1373
+ const slotName = `${key}-${index}`;
1374
+ return resolveAndWrapAsset(item, { context, slotName });
1375
+ });
1376
+ }
1377
+
1378
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/mixed-arrays.ts
1379
+ function resolveMixedArrays(storage, result, nestedParentContext) {
1380
+ const mixedArrays = storage.getMixedArrays();
1381
+ mixedArrays.forEach((metadata, key) => {
1382
+ const { array, builderIndices, objectIndices } = metadata;
1383
+ const currentValue = result[key];
1384
+ if (isAssetWrapperValue(currentValue)) {
1385
+ resolveMixedArrayAsAssetWrapper(
1386
+ result,
1387
+ key,
1388
+ currentValue,
1389
+ nestedParentContext
1390
+ );
1391
+ } else {
1392
+ resolveMixedArrayNormal(
1393
+ result,
1394
+ key,
1395
+ array,
1396
+ builderIndices,
1397
+ objectIndices,
1398
+ nestedParentContext
1399
+ );
1400
+ }
1401
+ });
1402
+ }
1403
+ function resolveMixedArrayAsAssetWrapper(result, key, wrapperValue, nestedParentContext) {
1404
+ const unwrappedArray = wrapperValue.asset;
1405
+ if (Array.isArray(unwrappedArray)) {
1406
+ result[key] = unwrappedArray.filter((item) => item !== null && item !== void 0).map((item, index) => {
1407
+ const slotName = `${key}-${index}`;
1408
+ return resolveAndWrapAsset(item, {
1409
+ context: nestedParentContext,
1410
+ slotName
1411
+ });
1412
+ });
1413
+ }
1414
+ }
1415
+ function resolveMixedArrayNormal(result, key, array, builderIndices, objectIndices, nestedParentContext) {
1416
+ result[key] = array.filter((item) => item !== null && item !== void 0).map((item, index) => {
1417
+ const slotName = `${key}-${index}`;
1418
+ return resolveAndWrapAsset(item, {
1419
+ context: nestedParentContext,
1420
+ slotName
1421
+ });
1422
+ });
1423
+ }
1424
+
1425
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/builders.ts
1426
+ function resolveBuilders(storage, result, nestedParentContext) {
1427
+ const builders = storage.getBuilders();
1428
+ builders.forEach((value, key) => {
1429
+ if (isAssetWrapperValue(value)) {
1430
+ resolveBuilderAsAssetWrapper(result, key, value, nestedParentContext);
1431
+ } else {
1432
+ resolveBuilderNormal(result, key, value, nestedParentContext);
1433
+ }
1434
+ });
1435
+ }
1436
+ function resolveBuilderAsAssetWrapper(result, key, wrapperValue, nestedParentContext) {
1437
+ const unwrapped = wrapperValue.asset;
1438
+ if (nestedParentContext) {
1439
+ if (Array.isArray(unwrapped)) {
1440
+ result[key] = unwrapped.filter((item) => item !== null && item !== void 0).map((item, index) => {
1441
+ const slotName = `${key}-${index}`;
1442
+ return resolveAndWrapAsset(item, {
1443
+ context: nestedParentContext,
1444
+ slotName
1445
+ });
1446
+ });
1447
+ } else {
1448
+ result[key] = resolveAndWrapAsset(unwrapped, {
1449
+ context: nestedParentContext,
1450
+ slotName: key
1451
+ });
1452
+ }
1453
+ } else {
1454
+ result[key] = resolveValue(wrapperValue, {});
1455
+ }
1456
+ }
1457
+ function resolveBuilderNormal(result, key, value, nestedParentContext) {
1458
+ result[key] = resolveAndWrapAsset(value, {
1459
+ context: nestedParentContext,
1460
+ slotName: key
1461
+ });
1462
+ }
1463
+
1464
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/path-resolver.ts
1465
+ function asRecordOrEmpty(value) {
1466
+ return isPlainObject(value) ? value : {};
1467
+ }
1468
+ function setValueAtPath(obj, path, value) {
1469
+ if (path.length === 0) return;
1470
+ if (path.length === 1) {
1471
+ obj[path[0]] = value;
1472
+ return;
1473
+ }
1474
+ const [currentKey, ...restPath] = path;
1475
+ const nextKey = restPath[0];
1476
+ const currentValue = obj[currentKey];
1477
+ const isAssetWrapperWithArray = isAssetWrapperValue(currentValue) && Array.isArray(currentValue.asset);
1478
+ if (isAssetWrapperWithArray && typeof nextKey === "number") {
1479
+ setValueInAssetWrapperArray(
1480
+ obj,
1481
+ currentKey,
1482
+ currentValue,
1483
+ nextKey,
1484
+ restPath,
1485
+ value
1486
+ );
1487
+ } else if (Array.isArray(currentValue) && typeof nextKey === "number") {
1488
+ setValueInArray(obj, currentKey, currentValue, nextKey, restPath, value);
1489
+ } else {
1490
+ setValueInObject(obj, currentKey, restPath, value);
1491
+ }
1492
+ }
1493
+ function setValueInAssetWrapperArray(obj, currentKey, wrappedArray, nextKey, restPath, value) {
1494
+ const arrayResult = [...wrappedArray.asset];
1495
+ if (restPath.length === 1) {
1496
+ arrayResult[nextKey] = value;
1497
+ } else {
1498
+ const nestedObj = asRecordOrEmpty(arrayResult[nextKey]);
1499
+ setValueAtPath(nestedObj, restPath.slice(1), value);
1500
+ arrayResult[nextKey] = nestedObj;
1501
+ }
1502
+ obj[currentKey] = { asset: arrayResult };
1503
+ }
1504
+ function setValueInArray(obj, currentKey, array, nextKey, restPath, value) {
1505
+ const arrayResult = [...array];
1506
+ if (restPath.length === 1) {
1507
+ arrayResult[nextKey] = value;
1508
+ } else {
1509
+ const nestedObj = asRecordOrEmpty(arrayResult[nextKey]);
1510
+ setValueAtPath(nestedObj, restPath.slice(1), value);
1511
+ arrayResult[nextKey] = nestedObj;
1512
+ }
1513
+ obj[currentKey] = arrayResult;
1514
+ }
1515
+ function setValueInObject(obj, currentKey, restPath, value) {
1516
+ const nestedObj = asRecordOrEmpty(obj[currentKey]);
1517
+ setValueAtPath(nestedObj, restPath, value);
1518
+ obj[currentKey] = nestedObj;
1519
+ }
1520
+
1521
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/switches.ts
1522
+ function resolveSwitches(auxiliaryStorage, result, nestedParentContext, arrayProperties) {
1523
+ const switches = auxiliaryStorage.getArray(
1524
+ StorageKeys.SWITCHES
1525
+ );
1526
+ if (switches.length === 0 || !nestedParentContext) {
1527
+ return;
1528
+ }
1529
+ let globalCaseIndex = 0;
1530
+ switches.forEach(({ path, switchFn }) => {
1531
+ const propertyName = String(path[0]);
1532
+ const switchParentId = nestedParentContext.parentId ? `${nestedParentContext.parentId}-${propertyName}` : propertyName;
1533
+ const switchContext = {
1534
+ ...nestedParentContext,
1535
+ parentId: switchParentId,
1536
+ branch: void 0
1537
+ };
1538
+ let switchResult = switchFn(switchContext, globalCaseIndex);
1539
+ if (isSwitchResult(switchResult)) {
1540
+ const switchCases = switchResult.staticSwitch ?? switchResult.dynamicSwitch;
1541
+ if (Array.isArray(switchCases)) {
1542
+ globalCaseIndex += switchCases.length;
1543
+ }
1544
+ }
1545
+ if (arrayProperties.has(propertyName) && path.length === 1) {
1546
+ switchResult = [switchResult];
1547
+ }
1548
+ setValueAtPath(result, path, switchResult);
1549
+ });
1550
+ }
1551
+
1552
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/templates.ts
1553
+ function resolveTemplates(auxiliaryStorage, result, context) {
1554
+ const templateFns = auxiliaryStorage.getArray(StorageKeys.TEMPLATES);
1555
+ if (templateFns.length === 0) {
1556
+ return;
1557
+ }
1558
+ if (!context) {
1559
+ if (process.env.NODE_ENV !== "production") {
1560
+ console.warn(
1561
+ `resolveTemplates: ${templateFns.length} template(s) exist but no context provided. Templates will be ignored. Pass a build context to .build() to enable template resolution.`
1562
+ );
1563
+ }
1564
+ return;
1565
+ }
1566
+ const templates = templateFns.map((fn) => fn(context));
1567
+ result.template = templates;
1568
+ }
1569
+
1570
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/nested-asset-wrappers.ts
1571
+ function resolveNestedAssetWrappers(result, context, assetWrapperPaths) {
1572
+ if (assetWrapperPaths.length === 0) {
1573
+ return;
1574
+ }
1575
+ for (const path of assetWrapperPaths) {
1576
+ if (path.length === 0) {
1577
+ continue;
1578
+ }
1579
+ if (path.length < 2) {
1580
+ continue;
1581
+ }
1582
+ resolvePathInResult(result, path, context);
1583
+ }
1584
+ }
1585
+ function resolvePathInResult(result, path, context) {
1586
+ let current = result;
1587
+ for (let i = 0; i < path.length - 1; i++) {
1588
+ const key = path[i];
1589
+ if (!isPlainObject(current)) {
1590
+ return;
1591
+ }
1592
+ let next = current[key];
1593
+ if (next === void 0 || next === null) {
1594
+ return;
1595
+ }
1596
+ if (isFluentBuilder(next)) {
1597
+ next = resolveValue(next, { context, propertyName: key });
1598
+ current[key] = next;
1599
+ }
1600
+ current = next;
1601
+ }
1602
+ const finalKey = path[path.length - 1];
1603
+ if (!isPlainObject(current)) {
1604
+ return;
1605
+ }
1606
+ const parent = current;
1607
+ const value = parent[finalKey];
1608
+ if (value === void 0 || value === null) {
1609
+ return;
1610
+ }
1611
+ if (isAssetWrapper(value)) {
1612
+ return;
1613
+ }
1614
+ const slotName = path.join("-");
1615
+ if (Array.isArray(value)) {
1616
+ parent[finalKey] = value.filter((item) => item !== null && item !== void 0).map((item, index) => {
1617
+ if (isAssetWrapper(item)) {
1618
+ return item;
1619
+ }
1620
+ return resolveAndWrapAsset(item, {
1621
+ context,
1622
+ slotName: `${slotName}-${index}`
1623
+ });
1624
+ });
1625
+ return;
1626
+ }
1627
+ if (isFluentBuilder(value) || isAsset(value)) {
1628
+ parent[finalKey] = resolveAndWrapAsset(value, {
1629
+ context,
1630
+ slotName
1631
+ });
1632
+ }
1633
+ }
1634
+
1635
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/pipeline.ts
1636
+ function createNestedParentContext(result, context) {
1637
+ if (!context) {
1638
+ return void 0;
1639
+ }
1640
+ const parentId = "id" in result && typeof result.id === "string" ? result.id : void 0;
1641
+ return {
1642
+ ...context,
1643
+ parentId,
1644
+ branch: void 0
1645
+ };
1646
+ }
1647
+ function executeBuildPipeline(valueStorage, auxiliaryStorage, defaults, context, arrayProperties, assetWrapperPaths = []) {
1648
+ const result = defaults ? { ...defaults } : {};
1649
+ resolveStaticValues(valueStorage, result, context);
1650
+ generateAssetIdForBuilder(valueStorage, result, context);
1651
+ const nestedParentContext = createNestedParentContext(result, context);
1652
+ resolveAssetWrappers(valueStorage, result, nestedParentContext);
1653
+ resolveMixedArrays(valueStorage, result, nestedParentContext);
1654
+ resolveBuilders(valueStorage, result, nestedParentContext);
1655
+ resolveNestedAssetWrappers(result, nestedParentContext, assetWrapperPaths);
1656
+ resolveSwitches(
1657
+ auxiliaryStorage,
1658
+ result,
1659
+ nestedParentContext,
1660
+ arrayProperties
1661
+ );
1662
+ resolveTemplates(auxiliaryStorage, result, context);
1663
+ return result;
1664
+ }
1665
+
1666
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/conditional/index.ts
1667
+ function resolveValueOrFunction(value) {
1668
+ if (typeof value === "function" && !isFluentBuilder(value)) {
1669
+ return value();
1670
+ }
1671
+ return value;
1672
+ }
1673
+ function shouldWrapInAssetWrapper(value) {
1674
+ if (isAssetWrapperValue(value)) {
1675
+ return false;
1676
+ }
1677
+ if (isFluentBuilder(value)) {
1678
+ return true;
1679
+ }
1680
+ if (isAsset(value)) {
1681
+ return true;
1682
+ }
1683
+ if (Array.isArray(value) && value.length > 0) {
1684
+ const firstItem = value[0];
1685
+ return isFluentBuilder(firstItem) || isAsset(firstItem);
1686
+ }
1687
+ return false;
1688
+ }
1689
+ function maybeWrapAsset(value) {
1690
+ if (shouldWrapInAssetWrapper(value)) {
1691
+ return { asset: value };
1692
+ }
1693
+ return value;
1694
+ }
1695
+
1696
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/switch/index.ts
1697
+ function processCaseExpression(exp) {
1698
+ if (typeof exp === "boolean") {
1699
+ return exp;
1700
+ }
1701
+ if (isTaggedTemplateValue(exp)) {
1702
+ return exp.toString();
1703
+ }
1704
+ return String(exp);
1705
+ }
1706
+ var switch_ = ({
1707
+ cases,
1708
+ isDynamic = false
1709
+ }) => (ctx, caseOffset = 0) => {
1710
+ const switchType = isDynamic ? "dynamic" : "static";
1711
+ return {
1712
+ [`${switchType}Switch`]: cases.map((c, index) => {
1713
+ const caseParentCtx = {
1714
+ ...ctx,
1715
+ parentId: ctx.parentId,
1716
+ branch: {
1717
+ type: BranchTypes.SWITCH,
1718
+ kind: switchType,
1719
+ index: caseOffset + index
1720
+ }
1721
+ };
1722
+ const asset = isFluentBuilder(c.asset) && "build" in c.asset ? c.asset.build(caseParentCtx) : c.asset;
1723
+ return {
1724
+ case: processCaseExpression(c.case),
1725
+ asset: {
1726
+ ...asset,
1727
+ id: asset.id ?? genId(caseParentCtx)
1728
+ }
1729
+ };
1730
+ })
1731
+ };
1732
+ };
1733
+
1734
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/fluent-builder-base.ts
1735
+ var FluentBuilderBase = class {
1736
+ [FLUENT_BUILDER_SYMBOL] = true;
1737
+ valueStorage;
1738
+ auxiliaryStorage;
1739
+ context;
1740
+ /**
1741
+ * Creates a new builder instance
1742
+ * @param initial - Optional initial values (accepts FluentPartial for TaggedTemplateValue support)
1743
+ */
1744
+ constructor(initial) {
1745
+ this.valueStorage = new ValueStorage(initial);
1746
+ this.auxiliaryStorage = new AuxiliaryStorage();
1747
+ }
1748
+ /**
1749
+ * Accessor for generated builders to access values
1750
+ * This maintains backward compatibility with generated code
1751
+ */
1752
+ get values() {
1753
+ return this.valueStorage.getValues();
1754
+ }
1755
+ /**
1756
+ * Setter for generated builders to set values in bulk
1757
+ * Used by withAdditionalProperties() in generated builders
1758
+ */
1759
+ set values(newValues) {
1760
+ Object.entries(newValues).forEach(([key, value]) => {
1761
+ this.valueStorage.set(key, value);
1762
+ });
1763
+ }
1764
+ /**
1765
+ * Sets additional properties in bulk that may not be defined in the type schema
1766
+ * Useful for extensibility and forward compatibility
1767
+ */
1768
+ withAdditionalProperties(values) {
1769
+ this.values = values;
1770
+ return this;
1771
+ }
1772
+ /**
1773
+ * Sets a property value, intelligently routing it to the appropriate storage
1774
+ * @param key - The property key to set
1775
+ * @param value - The value to set
1776
+ * @returns This builder instance for chaining
1777
+ */
1778
+ set(key, value) {
1779
+ this.valueStorage.set(key, value);
1780
+ return this;
1781
+ }
1782
+ /**
1783
+ * Builds the final object with defaults and nested builder resolution
1784
+ * Executes the complete 8-step build pipeline
1785
+ *
1786
+ * @param defaults - Optional default values
1787
+ * @param context - Optional build context
1788
+ */
1789
+ buildWithDefaults(defaults, context) {
1790
+ const arrayProperties = this.getArrayPropertiesMetadata();
1791
+ const assetWrapperPaths = this.getAssetWrapperPathsMetadata();
1792
+ return executeBuildPipeline(
1793
+ this.valueStorage,
1794
+ this.auxiliaryStorage,
1795
+ defaults,
1796
+ context,
1797
+ arrayProperties,
1798
+ assetWrapperPaths
1799
+ );
1800
+ }
1801
+ /**
1802
+ * Gets array property metadata from the builder class
1803
+ * Generated builders include a static __arrayProperties__ set
1804
+ */
1805
+ getArrayPropertiesMetadata() {
1806
+ const constructor = this.constructor;
1807
+ return constructor.__arrayProperties__ ?? /* @__PURE__ */ new Set();
1808
+ }
1809
+ /**
1810
+ * Gets asset wrapper paths metadata from the builder class.
1811
+ * Generated builders include a static __assetWrapperPaths__ array of paths.
1812
+ * Each path is an array of property names leading to an AssetWrapper.
1813
+ */
1814
+ getAssetWrapperPathsMetadata() {
1815
+ const constructor = this.constructor;
1816
+ return constructor.__assetWrapperPaths__ ?? [];
1817
+ }
1818
+ /**
1819
+ * Conditionally sets a property based on a predicate
1820
+ *
1821
+ * Accepts unwrapped Asset builders and automatically wraps them in AssetWrapper format.
1822
+ *
1823
+ * @param predicate - Function to determine if the property should be set
1824
+ * @param property - The property key
1825
+ * @param value - The value, builder, or function returning either
1826
+ *
1827
+ * @example
1828
+ * action()
1829
+ * .if(() => showLabel, "label", text().withValue("Submit"))
1830
+ */
1831
+ if(predicate, property, value) {
1832
+ if (predicate(this)) {
1833
+ const resolved = resolveValueOrFunction(value);
1834
+ const wrapped = maybeWrapAsset(resolved);
1835
+ this.set(property, wrapped);
1836
+ }
1837
+ return this;
1838
+ }
1839
+ /**
1840
+ * Conditionally sets a property choosing between two values
1841
+ *
1842
+ * Accepts unwrapped Asset builders and automatically wraps them in AssetWrapper format.
1843
+ *
1844
+ * @param predicate - Function to determine which value to use
1845
+ * @param property - The property key
1846
+ * @param trueValue - Value to use if predicate is true
1847
+ * @param falseValue - Value to use if predicate is false
1848
+ *
1849
+ * @example
1850
+ * action()
1851
+ * .ifElse(
1852
+ * () => isActive,
1853
+ * "label",
1854
+ * text().withValue("Deactivate"),
1855
+ * text().withValue("Activate")
1856
+ * )
1857
+ */
1858
+ ifElse(predicate, property, trueValue, falseValue) {
1859
+ const valueToUse = predicate(this) ? trueValue : falseValue;
1860
+ const resolved = resolveValueOrFunction(valueToUse);
1861
+ const wrapped = maybeWrapAsset(resolved);
1862
+ this.set(property, wrapped);
1863
+ return this;
1864
+ }
1865
+ /**
1866
+ * Checks if a property has been set
1867
+ */
1868
+ has(key) {
1869
+ return this.valueStorage.has(key);
1870
+ }
1871
+ /**
1872
+ * Peeks at a property value without resolving builders
1873
+ */
1874
+ peek(key) {
1875
+ return this.valueStorage.peek(key);
1876
+ }
1877
+ /**
1878
+ * Gets builder for a property if one is set
1879
+ */
1880
+ peekBuilder(key) {
1881
+ return this.valueStorage.peekBuilder(key);
1882
+ }
1883
+ /**
1884
+ * Gets the type of value stored for a property
1885
+ */
1886
+ getValueType(key) {
1887
+ return this.valueStorage.getValueType(key);
1888
+ }
1889
+ /**
1890
+ * Clones the builder, creating an independent copy with the same state.
1891
+ *
1892
+ * Note: This method requires that the builder class has a constructor that
1893
+ * accepts an optional `initial` parameter (like all generated builders do).
1894
+ * If your custom builder has required constructor parameters, you must
1895
+ * override this method.
1896
+ */
1897
+ clone() {
1898
+ const BuilderClass = this.constructor;
1899
+ let cloned;
1900
+ try {
1901
+ cloned = new BuilderClass();
1902
+ } catch (error) {
1903
+ throw new Error(
1904
+ `clone() failed: Builder class "${this.constructor.name}" requires constructor arguments. Override clone() in your subclass to handle this case.`
1905
+ );
1906
+ }
1907
+ cloned.valueStorage = this.valueStorage.clone();
1908
+ cloned.auxiliaryStorage = this.auxiliaryStorage.clone();
1909
+ if (this.context) {
1910
+ cloned.context = this.context;
1911
+ }
1912
+ return cloned;
1913
+ }
1914
+ /**
1915
+ * Unsets a property, removing it from the builder
1916
+ */
1917
+ unset(key) {
1918
+ this.valueStorage.unset(key);
1919
+ return this;
1920
+ }
1921
+ /**
1922
+ * Clears all properties from the builder, resetting it to initial state
1923
+ */
1924
+ clear() {
1925
+ this.valueStorage.clear();
1926
+ return this;
1927
+ }
1928
+ /**
1929
+ * Adds a template to this builder
1930
+ */
1931
+ template(templateFn) {
1932
+ this.auxiliaryStorage.push(StorageKeys.TEMPLATES, templateFn);
1933
+ return this;
1934
+ }
1935
+ /**
1936
+ * Adds a switch to this builder at a specific path
1937
+ */
1938
+ switch(path, switchFnArgs) {
1939
+ this.auxiliaryStorage.push(StorageKeys.SWITCHES, {
1940
+ path,
1941
+ switchFn: switch_(switchFnArgs)
1942
+ });
1943
+ return this;
1944
+ }
1945
+ };
1946
+
1947
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/utils.ts
1948
+ function createInspectMethod(builderName, properties) {
1949
+ return `${builderName} { properties: ${JSON.stringify(
1950
+ properties,
1951
+ null,
1952
+ 2
1953
+ )} }`;
1954
+ }
1955
+
1956
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/errors.ts
1957
+ var ErrorCodes = {
1958
+ /** Context is missing when required */
1959
+ MISSING_CONTEXT: "FLUENT_MISSING_CONTEXT",
1960
+ /** Invalid branch type in ID generation */
1961
+ INVALID_BRANCH: "FLUENT_INVALID_BRANCH",
1962
+ /** Template produced no output */
1963
+ TEMPLATE_NO_OUTPUT: "FLUENT_TEMPLATE_NO_OUTPUT",
1964
+ /** Invalid path in value resolution */
1965
+ INVALID_PATH: "FLUENT_INVALID_PATH"
1966
+ };
1967
+ var FluentError = class _FluentError extends Error {
1968
+ code;
1969
+ context;
1970
+ constructor(code, message, context) {
1971
+ const contextStr = context ? ` Context: ${JSON.stringify(context)}` : "";
1972
+ super(`[${code}] ${message}${contextStr}`);
1973
+ this.name = "FluentError";
1974
+ this.code = code;
1975
+ this.context = context;
1976
+ if (Error.captureStackTrace) {
1977
+ Error.captureStackTrace(this, _FluentError);
1978
+ }
1979
+ }
1980
+ };
1981
+ function createFluentError(code, message, context) {
1982
+ return new FluentError(code, message, context);
1983
+ }
1984
+
1985
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/template/index.ts
1986
+ var TEMPLATE_MARKER = Symbol.for("fluent-builder-template");
1987
+ function isTemplate(fn) {
1988
+ return typeof fn === "function" && TEMPLATE_MARKER in fn;
1989
+ }
1990
+ var template = ({
1991
+ data,
1992
+ output,
1993
+ value,
1994
+ dynamic = false
1995
+ }) => {
1996
+ const templateFn = (parentCtx) => {
1997
+ const resolvedOutput = output || inferOutputFromContext(parentCtx);
1998
+ if (!resolvedOutput) {
1999
+ throw new Error(
2000
+ "Template output must be provided or inferrable from context. When using template in asset arrays, ensure the array property can be inferred (e.g., collection().withValues([template(...)]) infers 'values' as output)."
2001
+ );
2002
+ }
2003
+ const templateValueCtx = {
2004
+ parentId: genId(parentCtx),
2005
+ branch: {
2006
+ type: BranchTypes.TEMPLATE,
2007
+ depth: 0
2008
+ }
2009
+ };
2010
+ let resolvedAsset;
2011
+ if (isFluentBuilder(value)) {
2012
+ resolvedAsset = value.build(templateValueCtx);
2013
+ } else if (typeof value === "function") {
2014
+ const builderResult = value(templateValueCtx);
2015
+ if (typeof builderResult === "function") {
2016
+ resolvedAsset = builderResult(
2017
+ templateValueCtx
2018
+ );
2019
+ } else {
2020
+ resolvedAsset = builderResult;
2021
+ }
2022
+ } else {
2023
+ if (typeof value === "object" && value !== null) {
2024
+ resolvedAsset = { ...value };
2025
+ } else {
2026
+ resolvedAsset = value;
2027
+ }
2028
+ }
2029
+ return {
2030
+ data: isTaggedTemplateValue(data) ? data.toString() : data,
2031
+ output: resolvedOutput,
2032
+ value: {
2033
+ asset: resolvedAsset
2034
+ },
2035
+ ...dynamic && { dynamic }
2036
+ };
2037
+ };
2038
+ templateFn[TEMPLATE_MARKER] = true;
2039
+ return templateFn;
2040
+ };
2041
+ function inferOutputFromContext(parentCtx) {
2042
+ if (parentCtx.branch?.type === "slot") {
2043
+ const slotName = parentCtx.branch.name;
2044
+ const match = slotName.match(/^([a-zA-Z_][a-zA-Z0-9_]*)-\d+$/);
2045
+ if (match) {
2046
+ return match[1];
2047
+ }
2048
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(slotName)) {
2049
+ return slotName;
2050
+ }
2051
+ }
2052
+ return void 0;
2053
+ }
2054
+
2055
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/flow/index.ts
2056
+ function isBuilder(value) {
2057
+ return typeof value === "object" && value !== null && "build" in value && typeof value.build === "function";
2058
+ }
2059
+ function isBuilderFunction(value) {
2060
+ return typeof value === "function";
2061
+ }
2062
+ function flow(options) {
2063
+ const flowId = options.id || "root";
2064
+ const viewsNamespace = `${flowId}-views`;
2065
+ const processedViews = (() => {
2066
+ const processViews = () => {
2067
+ const results = [];
2068
+ for (let index = 0; index < options.views.length; index++) {
2069
+ const viewOrFn = options.views[index];
2070
+ const ctx = {
2071
+ parentId: viewsNamespace,
2072
+ branch: {
2073
+ type: BranchTypes.ARRAY_ITEM,
2074
+ index
2075
+ },
2076
+ ...options.context ?? {}
2077
+ };
2078
+ if (isBuilder(viewOrFn)) {
2079
+ results.push(viewOrFn.build(ctx));
2080
+ } else if (isBuilderFunction(viewOrFn)) {
2081
+ results.push(viewOrFn(ctx));
2082
+ } else {
2083
+ results.push(viewOrFn);
2084
+ }
2085
+ }
2086
+ return results;
2087
+ };
2088
+ return processViews();
2089
+ })();
2090
+ const { views: _views, context: _context, ...restOptions } = options;
2091
+ return {
2092
+ ...restOptions,
2093
+ id: flowId,
2094
+ views: processedViews,
2095
+ ...options.data && { data: options.data },
2096
+ ...options.schema && { schema: options.schema },
2097
+ navigation: options.navigation
2098
+ };
2099
+ }
2100
+
2101
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/schema/index.ts
2102
+ var import_tapable_ts = require("tapable-ts");
2103
+ var import_dequal = require("dequal");
2104
+ var SchemaTypeName = Symbol.for("Schema Rename");
2105
+ var isTypeDef = (property) => {
2106
+ return property.type !== void 0;
2107
+ };
2108
+ var SchemaGenerator = class {
2109
+ children = [];
2110
+ generatedDataTypes = /* @__PURE__ */ new Map();
2111
+ typeNameCache = /* @__PURE__ */ new Map();
2112
+ logger;
2113
+ hooks = {
2114
+ createSchemaNode: new import_tapable_ts.SyncWaterfallHook()
2115
+ };
2116
+ constructor(logger) {
2117
+ this.logger = logger ?? console;
2118
+ }
2119
+ /**
2120
+ * Converts an object to a `Schema.Schema` representation
2121
+ * Optimized to minimize object operations and memory allocations
2122
+ */
2123
+ toSchema = (schema) => {
2124
+ this.children.length = 0;
2125
+ this.generatedDataTypes.clear();
2126
+ this.typeNameCache.clear();
2127
+ const newSchema = {
2128
+ ROOT: {}
2129
+ };
2130
+ const rootKeys = Object.keys(schema);
2131
+ for (let i = 0; i < rootKeys.length; i++) {
2132
+ const property = rootKeys[i];
2133
+ const subType = schema[property];
2134
+ newSchema.ROOT[property] = this.hooks.createSchemaNode.call(
2135
+ this.processChild(property, subType),
2136
+ subType
2137
+ );
2138
+ }
2139
+ while (this.children.length > 0) {
2140
+ const { name, child } = this.children.pop();
2141
+ const typeDef = {};
2142
+ const childKeys = Object.keys(child);
2143
+ for (let i = 0; i < childKeys.length; i++) {
2144
+ const property = childKeys[i];
2145
+ const subType = child[property];
2146
+ typeDef[property] = this.hooks.createSchemaNode.call(
2147
+ this.processChild(property, subType),
2148
+ subType
2149
+ );
2150
+ }
2151
+ newSchema[name] = typeDef;
2152
+ }
2153
+ return newSchema;
2154
+ };
2155
+ processChild(property, subType) {
2156
+ if (isTypeDef(subType)) {
2157
+ return subType;
2158
+ }
2159
+ let intermediateType;
2160
+ let child;
2161
+ if (Array.isArray(subType)) {
2162
+ if (subType.length > 1) {
2163
+ this.logger.warn(
2164
+ `Type ${property} has multiple types in array, should only contain one top level object type. Only taking first defined type`
2165
+ );
2166
+ }
2167
+ const subTypeName = subType[0][SchemaTypeName] ?? property;
2168
+ intermediateType = this.makePlaceholderArrayType(subTypeName);
2169
+ child = subType[0];
2170
+ } else {
2171
+ const subTypeName = subType[SchemaTypeName] ?? property;
2172
+ intermediateType = this.makePlaceholderType(subTypeName);
2173
+ child = subType;
2174
+ }
2175
+ const typeName = intermediateType.type;
2176
+ if (this.generatedDataTypes.has(typeName)) {
2177
+ const generatedType = this.generatedDataTypes.get(typeName);
2178
+ if (!(0, import_dequal.dequal)(child, this.generatedDataTypes.get(typeName)?.node)) {
2179
+ generatedType.count += 1;
2180
+ const newTypeName = `${typeName}${generatedType.count}`;
2181
+ intermediateType = {
2182
+ ...intermediateType,
2183
+ type: newTypeName
2184
+ };
2185
+ this.logger.warn(
2186
+ `WARNING: Generated two intermediate types with the name: ${typeName} that are of different shapes, using artificial type ${newTypeName}`
2187
+ );
2188
+ this.generatedDataTypes.set(newTypeName, {
2189
+ node: subType,
2190
+ count: 1
2191
+ });
2192
+ this.children.push({ name: newTypeName, child });
2193
+ return intermediateType;
2194
+ }
2195
+ } else {
2196
+ this.generatedDataTypes.set(typeName, {
2197
+ node: subType,
2198
+ count: 1
2199
+ });
2200
+ }
2201
+ this.children.push({ name: intermediateType.type, child });
2202
+ return intermediateType;
2203
+ }
2204
+ /**
2205
+ * Cached type name generation
2206
+ */
2207
+ makePlaceholderType = (typeName) => {
2208
+ let cachedName = this.typeNameCache.get(typeName);
2209
+ if (!cachedName) {
2210
+ cachedName = `${typeName}Type`;
2211
+ this.typeNameCache.set(typeName, cachedName);
2212
+ }
2213
+ return { type: cachedName };
2214
+ };
2215
+ /**
2216
+ * Cached array type name generation
2217
+ */
2218
+ makePlaceholderArrayType(typeName) {
2219
+ let cachedName = this.typeNameCache.get(typeName);
2220
+ if (!cachedName) {
2221
+ cachedName = `${typeName}Type`;
2222
+ this.typeNameCache.set(typeName, cachedName);
2223
+ }
2224
+ return {
2225
+ type: cachedName,
2226
+ isArray: true
2227
+ };
2228
+ }
2229
+ };
2230
+
2231
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/utils/index.ts
2232
+ function safeToString(value) {
2233
+ if (isTaggedTemplateValue(value)) {
2234
+ return value.toString();
2235
+ }
2236
+ return String(value);
2237
+ }
2238
+ function safeToBoolean(value) {
2239
+ if (isTaggedTemplateValue(value)) {
2240
+ return value.toString() === "true";
2241
+ }
2242
+ return Boolean(value);
2243
+ }
2244
+ function safeToNumber(value) {
2245
+ if (isTaggedTemplateValue(value)) {
2246
+ return Number(value.toString());
2247
+ }
2248
+ return Number(value);
2249
+ }
2250
+ function safeToArray(value) {
2251
+ if (isTaggedTemplateValue(value)) {
2252
+ return [value.toString()];
2253
+ }
2254
+ if (Array.isArray(value)) {
2255
+ return value.map((item) => {
2256
+ if (isTaggedTemplateValue(item)) {
2257
+ return item.toString();
2258
+ } else if (Array.isArray(item)) {
2259
+ return safeToArray(item);
2260
+ } else if (item && typeof item === "object" && !isTaggedTemplateValue(item)) {
2261
+ return safeToObject(item);
2262
+ }
2263
+ return item;
2264
+ });
2265
+ }
2266
+ return [value];
2267
+ }
2268
+ function safeToObject(value) {
2269
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
2270
+ return value;
2271
+ }
2272
+ return Object.fromEntries(
2273
+ Object.entries(value).map(([key, val]) => {
2274
+ if (isTaggedTemplateValue(val)) {
2275
+ return [key, val.toString()];
2276
+ } else if (Array.isArray(val)) {
2277
+ return [key, safeToArray(val)];
2278
+ } else if (val && typeof val === "object" && !isTaggedTemplateValue(val)) {
2279
+ return [key, safeToObject(val)];
2280
+ }
2281
+ return [key, val];
2282
+ })
2283
+ );
2284
+ }
2285
+ function safeFromMixedType(value) {
2286
+ if (isTaggedTemplateValue(value)) {
2287
+ return value.toString();
2288
+ }
2289
+ if (value && typeof value === "object" && !Array.isArray(value)) {
2290
+ return safeToObject(
2291
+ value
2292
+ );
2293
+ }
2294
+ if (Array.isArray(value)) {
2295
+ return safeToArray(value);
2296
+ }
2297
+ return value;
2298
+ }
2299
+ // Annotate the CommonJS export names for ESM import in node:
2300
+ 0 && (module.exports = {
2301
+ AND,
2302
+ BranchTypes,
2303
+ ErrorCodes,
2304
+ FLUENT_BUILDER_SYMBOL,
2305
+ FluentBuilderBase,
2306
+ FluentError,
2307
+ IDRegistry,
2308
+ NAND,
2309
+ NOR,
2310
+ NOT,
2311
+ OR,
2312
+ PropertyKeys,
2313
+ SchemaGenerator,
2314
+ SchemaTypeName,
2315
+ StorageKeys,
2316
+ TEMPLATE_MARKER,
2317
+ TaggedTemplateValueSymbol,
2318
+ XOR,
2319
+ add,
2320
+ and,
2321
+ binding,
2322
+ call,
2323
+ conditional,
2324
+ createFluentError,
2325
+ createIdRegistry,
2326
+ createInspectMethod,
2327
+ createNestedContext,
2328
+ createSwitchContext,
2329
+ createTemplateContext,
2330
+ determineSlotName,
2331
+ div,
2332
+ divide,
2333
+ eq,
2334
+ equal,
2335
+ expression,
2336
+ extractBindingsFromSchema,
2337
+ extractValue,
2338
+ flow,
2339
+ genId,
2340
+ generateAssetId,
2341
+ globalIdRegistry,
2342
+ greaterThan,
2343
+ greaterThanOrEqual,
2344
+ gt,
2345
+ gte,
2346
+ ifElse,
2347
+ isAsset,
2348
+ isAssetWrapper,
2349
+ isAssetWrapperValue,
2350
+ isAssetWrapperWithAsset,
2351
+ isBuilderArray,
2352
+ isFluentBuilder,
2353
+ isPlainObject,
2354
+ isStringOrUndefined,
2355
+ isSwitchResult,
2356
+ isTaggedTemplateValue,
2357
+ isTemplate,
2358
+ lessThan,
2359
+ lessThanOrEqual,
2360
+ literal,
2361
+ lt,
2362
+ lte,
2363
+ minus,
2364
+ mod,
2365
+ modulo,
2366
+ multiply,
2367
+ nand,
2368
+ needsAssetWrapper,
2369
+ neq,
2370
+ nor,
2371
+ not,
2372
+ notEqual,
2373
+ or,
2374
+ peekId,
2375
+ plus,
2376
+ resetGlobalIdSet,
2377
+ resolveAndWrapAsset,
2378
+ resolveValue,
2379
+ safeFromMixedType,
2380
+ safeToArray,
2381
+ safeToBoolean,
2382
+ safeToNumber,
2383
+ safeToObject,
2384
+ safeToString,
2385
+ strictEq,
2386
+ strictEqual,
2387
+ strictNeq,
2388
+ strictNotEqual,
2389
+ subtract,
2390
+ switch_,
2391
+ template,
2392
+ ternary,
2393
+ times,
2394
+ xor
2395
+ });
2396
+ //# sourceMappingURL=index.cjs.map