@almadar/core 10.9.0 → 10.11.0

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,1727 @@
1
+ import { z } from 'zod';
2
+ import '@almadar/patterns';
3
+
4
+ // src/factory-runtime/extract-manifest.ts
5
+ var STATIC_PARAM_FIELDS = [
6
+ {
7
+ name: "fields",
8
+ type: "EntityField[]",
9
+ description: "Extra fields appended to the canonical entity."
10
+ },
11
+ {
12
+ name: "pagePath",
13
+ type: "string",
14
+ description: "URL override for the orbital first page."
15
+ },
16
+ {
17
+ name: "persistence",
18
+ type: "'persistent' | 'runtime' | 'singleton' | 'instance' | 'local'",
19
+ description: "Override the canonical entity persistence mode."
20
+ },
21
+ {
22
+ name: "entityName",
23
+ type: "string",
24
+ description: "Rename the canonical entity. PascalCase singular, \u226432 chars. Threads through every trait's linkedEntity binding; compiler rewrites @Entity.x refs."
25
+ },
26
+ {
27
+ name: "collection",
28
+ type: "string",
29
+ description: "Override derived collection key. Defaults to plural(entityName).toLowerCase()."
30
+ },
31
+ {
32
+ name: "traitOverrides",
33
+ type: "Partial<Record<TraitName, { config?, linkedEntity?, events?, name?, emitsScope?, listens? }>>",
34
+ description: ".lolo's native trait-composition surface 1:1: per-imported-trait config, linkedEntity, events, name, emitsScope, listens. effects is excluded (atom-owned; use listens via a sibling trait)."
35
+ }
36
+ ];
37
+ function splitTraits(traits) {
38
+ const refTraitNames = [];
39
+ const inlineTraitNames = [];
40
+ for (const t of traits) {
41
+ if (!t || typeof t !== "object") continue;
42
+ const tName = typeof t.name === "string" ? t.name : null;
43
+ if (!tName) continue;
44
+ if (typeof t.ref === "string") {
45
+ refTraitNames.push(tName);
46
+ } else {
47
+ inlineTraitNames.push(tName);
48
+ }
49
+ }
50
+ return { refTraitNames, inlineTraitNames };
51
+ }
52
+ function extractManifest(orb) {
53
+ const behaviorName = orb.name;
54
+ return orb.orbitals.map((orbital) => {
55
+ const { refTraitNames, inlineTraitNames } = splitTraits(orbital.traits);
56
+ return {
57
+ organism: behaviorName,
58
+ orbitalName: orbital.name,
59
+ paramFields: STATIC_PARAM_FIELDS,
60
+ traitNames: refTraitNames,
61
+ inlineTraitNames
62
+ };
63
+ });
64
+ }
65
+ z.enum([
66
+ "string",
67
+ "number",
68
+ "boolean",
69
+ "date",
70
+ "timestamp",
71
+ "datetime",
72
+ "array",
73
+ "object",
74
+ "enum",
75
+ "relation",
76
+ "trait",
77
+ "slot",
78
+ "pattern"
79
+ ]);
80
+ var RelationCardinalitySchema = z.enum([
81
+ "one",
82
+ "many",
83
+ "one-to-many",
84
+ "many-to-one",
85
+ "many-to-many"
86
+ ]);
87
+ var RelationConfigSchema = z.object({
88
+ entity: z.string().min(1, "Target entity is required"),
89
+ field: z.string().optional(),
90
+ cardinality: RelationCardinalitySchema.optional(),
91
+ onDelete: z.enum(["cascade", "nullify", "restrict"]).optional(),
92
+ // Legacy compatibility fields
93
+ foreignKey: z.string().optional(),
94
+ target: z.string().optional(),
95
+ type: RelationCardinalitySchema.optional()
96
+ }).transform((data) => {
97
+ const normalized = {
98
+ entity: data.entity || data.target || "",
99
+ cardinality: data.cardinality || data.type,
100
+ field: data.field,
101
+ onDelete: data.onDelete
102
+ };
103
+ return normalized;
104
+ });
105
+ var FieldFormatSchema = z.enum([
106
+ "email",
107
+ "url",
108
+ "phone",
109
+ "date",
110
+ "datetime",
111
+ "uuid",
112
+ "image",
113
+ "avatar",
114
+ "thumbnail"
115
+ ]);
116
+ var FIELD_TYPE_ALIASES = {
117
+ text: "string",
118
+ int: "number",
119
+ float: "number",
120
+ ts: "timestamp"
121
+ };
122
+ var EntityFieldSchema = z.lazy(() => {
123
+ const baseFieldShape = {
124
+ name: z.string().min(1, "Field name is required").optional(),
125
+ required: z.boolean().optional(),
126
+ default: z.unknown().optional(),
127
+ format: FieldFormatSchema.optional(),
128
+ min: z.number().optional(),
129
+ max: z.number().optional(),
130
+ properties: z.record(EntityFieldSchema).optional(),
131
+ intrinsic: z.boolean().optional(),
132
+ description: z.string().optional(),
133
+ synonyms: z.string().optional()
134
+ };
135
+ function scalarVariant(t) {
136
+ return z.object({
137
+ ...baseFieldShape,
138
+ type: z.literal(t),
139
+ values: z.array(z.string()).optional()
140
+ });
141
+ }
142
+ return z.preprocess(
143
+ (input) => {
144
+ if (input === null || typeof input !== "object" || !("type" in input) || typeof input.type !== "string") {
145
+ return input;
146
+ }
147
+ const obj = input;
148
+ const next = { ...obj };
149
+ const aliased = FIELD_TYPE_ALIASES[obj.type];
150
+ if (aliased !== void 0) next.type = aliased;
151
+ if (next.enum !== void 0 && next.values === void 0) {
152
+ next.values = next.enum;
153
+ }
154
+ delete next.enum;
155
+ return next;
156
+ },
157
+ z.discriminatedUnion("type", [
158
+ scalarVariant("string"),
159
+ scalarVariant("number"),
160
+ scalarVariant("boolean"),
161
+ scalarVariant("date"),
162
+ scalarVariant("timestamp"),
163
+ scalarVariant("datetime"),
164
+ scalarVariant("trait"),
165
+ scalarVariant("slot"),
166
+ scalarVariant("pattern"),
167
+ // Enum variant — REQUIRES non-empty values.
168
+ z.object({
169
+ ...baseFieldShape,
170
+ type: z.literal("enum"),
171
+ values: z.array(z.string()).min(1, "Enum field requires a non-empty `values` array")
172
+ }),
173
+ // Relation variant — REQUIRES relation config.
174
+ z.object({
175
+ ...baseFieldShape,
176
+ type: z.literal("relation"),
177
+ relation: RelationConfigSchema
178
+ }),
179
+ // Array variant — items optional to match relaxed TS shape.
180
+ z.object({
181
+ ...baseFieldShape,
182
+ type: z.literal("array"),
183
+ items: EntityFieldSchema.optional()
184
+ }),
185
+ // Object variant — fixed-key struct (`properties`) or dynamic-key
186
+ // map (`Map K V`, uniform value schema in `items`).
187
+ z.object({
188
+ ...baseFieldShape,
189
+ type: z.literal("object"),
190
+ items: EntityFieldSchema.optional(),
191
+ values: z.array(z.string()).optional()
192
+ })
193
+ ])
194
+ );
195
+ });
196
+ var ENTITY_ROLES = [
197
+ "player",
198
+ "enemy",
199
+ "npc",
200
+ "item",
201
+ "tile",
202
+ "projectile",
203
+ "effect",
204
+ "ui",
205
+ "decoration",
206
+ "vehicle"
207
+ ];
208
+ var EntityRoleSchema = z.enum(ENTITY_ROLES);
209
+ var VISUAL_STYLES = ["pixel", "vector", "hd", "1-bit", "isometric"];
210
+ var VisualStyleSchema = z.enum(VISUAL_STYLES);
211
+ var ASSET_DIMENSIONS = ["2d", "3d"];
212
+ var AssetDimensionSchema = z.enum(ASSET_DIMENSIONS);
213
+ var ASSET_ASPECTS = ["1:1", "16:9", "5:7", "8:1"];
214
+ var AssetAspectSchema = z.enum(ASSET_ASPECTS);
215
+ var GAME_TYPES = [
216
+ "platformer",
217
+ "roguelike",
218
+ "top-down",
219
+ "puzzle",
220
+ "racing",
221
+ "card",
222
+ "board",
223
+ "shooter",
224
+ "rpg"
225
+ ];
226
+ var GameTypeSchema = z.enum(GAME_TYPES);
227
+ var AnimationDefSchema = z.object({
228
+ frames: z.union([z.array(z.number()), z.array(z.string())]),
229
+ fps: z.number().positive(),
230
+ loop: z.boolean()
231
+ });
232
+ var SemanticAssetRefSchema = z.object({
233
+ role: EntityRoleSchema,
234
+ category: z.string().min(1),
235
+ animations: z.array(z.string()).optional(),
236
+ style: VisualStyleSchema.optional(),
237
+ variant: z.string().optional(),
238
+ dimension: AssetDimensionSchema.optional(),
239
+ aspect: AssetAspectSchema.optional()
240
+ });
241
+ SemanticAssetRefSchema.extend({
242
+ url: z.string(),
243
+ name: z.string().optional(),
244
+ thumbnailUrl: z.string().optional()
245
+ });
246
+ z.object({
247
+ basePath: z.string(),
248
+ path: z.string(),
249
+ tiles: z.array(z.number()).optional(),
250
+ tileSize: z.number().positive().optional(),
251
+ files: z.array(z.string()).optional(),
252
+ animations: z.record(AnimationDefSchema).optional()
253
+ });
254
+ var AssetMappingSchema = z.object({
255
+ path: z.string(),
256
+ tiles: z.array(z.number()).optional(),
257
+ tileSize: z.number().positive().optional(),
258
+ files: z.array(z.string()).optional(),
259
+ animations: z.record(AnimationDefSchema).optional()
260
+ });
261
+ z.object({
262
+ gameType: GameTypeSchema,
263
+ style: VisualStyleSchema,
264
+ basePath: z.string(),
265
+ mappings: z.record(AssetMappingSchema)
266
+ });
267
+ var AssetCatalogEntrySchema = z.object({
268
+ url: z.string(),
269
+ name: z.string(),
270
+ category: z.string(),
271
+ kind: z.enum(["image", "spritesheet", "audio", "scene", "portrait", "model", "other"]),
272
+ thumbnailUrl: z.string().optional(),
273
+ dimension: AssetDimensionSchema.optional(),
274
+ aspect: AssetAspectSchema.optional()
275
+ });
276
+ z.array(AssetCatalogEntrySchema);
277
+
278
+ // src/types/entity.ts
279
+ var EntityPersistenceSchema = z.enum([
280
+ "persistent",
281
+ "runtime",
282
+ "singleton",
283
+ "instance",
284
+ "local"
285
+ ]);
286
+ var OrbitalEntitySchema = z.object({
287
+ name: z.string().min(1, "Entity name is required"),
288
+ persistence: EntityPersistenceSchema.default("persistent"),
289
+ collection: z.string().optional(),
290
+ fields: z.array(EntityFieldSchema).min(1, "At least one field is required"),
291
+ instances: z.array(z.record(z.unknown())).optional(),
292
+ timestamps: z.boolean().optional(),
293
+ softDelete: z.boolean().optional(),
294
+ description: z.string().optional(),
295
+ visual_prompt: z.string().optional(),
296
+ assetRef: SemanticAssetRefSchema.optional()
297
+ });
298
+ var EntitySchema = OrbitalEntitySchema;
299
+ var UI_SLOTS = [
300
+ // App slots
301
+ "main",
302
+ "sidebar",
303
+ "modal",
304
+ "drawer",
305
+ "overlay",
306
+ "center",
307
+ "toast",
308
+ "floating",
309
+ "system",
310
+ // For invisible system components (InputListener, CollisionDetector)
311
+ "content",
312
+ "screen",
313
+ // Game HUD slots
314
+ "hud",
315
+ "hud-top",
316
+ "hud-bottom",
317
+ "hud.health",
318
+ "hud.score",
319
+ "hud.inventory",
320
+ "hud.stamina",
321
+ // Game overlay slots
322
+ "overlay.inventory",
323
+ "overlay.dialogue",
324
+ "overlay.menu",
325
+ "overlay.pause"
326
+ ];
327
+ z.enum(UI_SLOTS);
328
+ var EffectSchema = z.array(z.unknown()).min(1).refine(
329
+ (arr) => typeof arr[0] === "string",
330
+ { message: "Effect must be an S-expression with a string operator as first element" }
331
+ );
332
+ var SExprAtomSchema = z.union([
333
+ z.string(),
334
+ z.number(),
335
+ z.boolean(),
336
+ z.null(),
337
+ z.record(z.unknown())
338
+ // Objects for payload data
339
+ ]);
340
+ var SExprSchema = z.lazy(
341
+ () => z.union([
342
+ SExprAtomSchema,
343
+ z.array(z.lazy(() => SExprSchema)).min(1).refine(
344
+ (arr) => typeof arr[0] === "string",
345
+ { message: "S-expression array must have a string operator as first element" }
346
+ )
347
+ ])
348
+ );
349
+ var ExpressionSchema = SExprSchema;
350
+
351
+ // src/types/state-machine.ts
352
+ var StateSchema = z.object({
353
+ name: z.string().min(1, "State name is required"),
354
+ isInitial: z.boolean().optional(),
355
+ isTerminal: z.boolean().optional(),
356
+ isFinal: z.boolean().optional(),
357
+ description: z.string().optional(),
358
+ onEntry: z.array(z.string()).optional(),
359
+ onExit: z.array(z.string()).optional()
360
+ });
361
+ var PayloadFieldSchema = z.object({
362
+ name: z.string().min(1),
363
+ type: z.string().min(1),
364
+ required: z.boolean().optional()
365
+ });
366
+ var EventSchema = z.object({
367
+ key: z.string().min(1, "Event key is required"),
368
+ name: z.string().min(1, "Event name is required"),
369
+ description: z.string().optional(),
370
+ synonyms: z.string().optional(),
371
+ tier: z.string().optional(),
372
+ payloadSchema: z.array(PayloadFieldSchema).optional(),
373
+ classification: z.enum(["domain", "system"]).optional(),
374
+ semanticRole: z.string().optional()
375
+ });
376
+ var GuardSchema = z.object({
377
+ name: z.string().min(1, "Guard name is required"),
378
+ expression: ExpressionSchema,
379
+ description: z.string().optional()
380
+ });
381
+ var TransitionSchema = z.object({
382
+ from: z.string().min(1, "Transition source state is required"),
383
+ to: z.string().min(1, "Transition target state is required"),
384
+ event: z.string().min(1, "Transition event is required"),
385
+ guard: ExpressionSchema.nullish(),
386
+ effects: z.array(EffectSchema).optional(),
387
+ description: z.string().nullish()
388
+ });
389
+ var StateMachineSchema = z.object({
390
+ states: z.array(StateSchema).min(1, "At least one state is required"),
391
+ events: z.array(EventSchema),
392
+ transitions: z.array(TransitionSchema),
393
+ guards: z.array(GuardSchema).optional()
394
+ });
395
+
396
+ // src/types/trait.ts
397
+ var TraitConfigValueSchema = z.lazy(
398
+ () => z.union([
399
+ z.string(),
400
+ z.number(),
401
+ z.boolean(),
402
+ z.null(),
403
+ z.array(TraitConfigValueSchema),
404
+ z.record(TraitConfigValueSchema)
405
+ ])
406
+ );
407
+ var TraitConfigSchema = z.record(TraitConfigValueSchema);
408
+ function isCallSiteConfigDeclaration(entry) {
409
+ return typeof entry === "object" && entry !== null && !Array.isArray(entry) && "type" in entry && typeof entry.type === "string" && "default" in entry;
410
+ }
411
+ var ConfigFieldDeclarationSchema = z.object({
412
+ type: z.string(),
413
+ default: TraitConfigValueSchema.optional(),
414
+ label: z.string().optional(),
415
+ description: z.string().optional(),
416
+ tier: z.string().optional(),
417
+ values: z.array(z.string()).optional(),
418
+ synonyms: z.string().optional()
419
+ });
420
+ var DeclaredTraitConfigSchema = z.record(
421
+ ConfigFieldDeclarationSchema
422
+ );
423
+ var TraitCategorySchema = z.enum([
424
+ "lifecycle",
425
+ "temporal",
426
+ "validation",
427
+ "notification",
428
+ "integration",
429
+ "interaction",
430
+ "agent",
431
+ "game-core",
432
+ "game-character",
433
+ "game-ai",
434
+ "game-combat",
435
+ "game-items",
436
+ "game-cards",
437
+ "game-board",
438
+ "game-puzzle"
439
+ ]);
440
+ var TraitEntityFieldSchema = z.object({
441
+ name: z.string().min(1),
442
+ type: z.enum([
443
+ "string",
444
+ "number",
445
+ "boolean",
446
+ "date",
447
+ "array",
448
+ "object",
449
+ "timestamp",
450
+ "datetime",
451
+ "enum"
452
+ ]),
453
+ required: z.boolean().optional(),
454
+ default: z.unknown().optional(),
455
+ values: z.array(z.string()).optional()
456
+ });
457
+ var TraitDataEntitySchema = z.object({
458
+ name: z.string().min(1),
459
+ collection: z.string().optional(),
460
+ fields: z.array(TraitEntityFieldSchema).min(1),
461
+ timestamps: z.boolean().optional(),
462
+ description: z.string().optional(),
463
+ runtime: z.boolean().optional(),
464
+ singleton: z.boolean().optional(),
465
+ pages: z.array(z.string()).optional()
466
+ });
467
+ var TraitTickSchema = z.object({
468
+ name: z.string().min(1),
469
+ description: z.string().optional(),
470
+ priority: z.number().optional(),
471
+ interval: z.union([z.literal("frame"), z.number().positive()]),
472
+ appliesTo: z.array(z.string()).optional(),
473
+ pages: z.array(z.string()).optional(),
474
+ guard: ExpressionSchema.optional(),
475
+ effects: z.array(EffectSchema).min(1),
476
+ emits: z.array(z.string()).optional()
477
+ });
478
+ var EventScopeSchema = z.enum(["internal", "external"]);
479
+ var EventPayloadFieldSchema = z.object({
480
+ name: z.string().min(1),
481
+ /**
482
+ * Field type. Mirrors the Rust validator's acceptance: any non-empty
483
+ * string. Primitives ('string' | 'number' | 'boolean' | 'object' |
484
+ * 'array') are the canonical values; entity-name references like
485
+ * 'ModalRecord' and array-of-entity references like '[ModalRecord]'
486
+ * are also valid because the Rust IR's PayloadField.field_type is
487
+ * just a String. Only enforced narrowly at the call site (e.g.
488
+ * emit-literal type-mismatch warnings in
489
+ * orbital-compiler/phases/validation/emit_payload.rs) — not here.
490
+ */
491
+ type: z.string().min(1),
492
+ required: z.boolean().optional(),
493
+ description: z.string().optional(),
494
+ entityType: z.string().optional()
495
+ });
496
+ var TraitEventContractSchema = z.object({
497
+ /**
498
+ * Event name. Mirrors the Rust validator's `is_valid_event_identifier`:
499
+ * starts with a letter, then any letters / digits / underscores. Both
500
+ * UPPER_SNAKE_CASE and PascalCase shapes are valid identifiers in the
501
+ * post-Phase 2.5 nominal-event type system (events declared via
502
+ * `type X = Event<T>`).
503
+ */
504
+ event: z.string().min(1).regex(
505
+ /^[A-Za-z][A-Za-z0-9_]*$/,
506
+ "Event name must start with a letter and contain only letters, digits, and underscores"
507
+ ),
508
+ description: z.string().optional(),
509
+ synonyms: z.string().optional(),
510
+ tier: z.string().optional(),
511
+ payloadSchema: z.array(EventPayloadFieldSchema).optional(),
512
+ scope: EventScopeSchema.optional()
513
+ });
514
+ var ListenSourceSchema = z.union([
515
+ z.object({ kind: z.literal("any") }),
516
+ z.object({ kind: z.literal("trait"), trait: z.string().min(1) }),
517
+ z.object({
518
+ kind: z.literal("orbital"),
519
+ orbital: z.string().min(1),
520
+ trait: z.string().min(1)
521
+ })
522
+ ]);
523
+ var TraitEventListenerSchema = z.object({
524
+ event: z.string().min(1),
525
+ triggers: z.string().min(1),
526
+ description: z.string().optional(),
527
+ synonyms: z.string().optional(),
528
+ tier: z.string().optional(),
529
+ guard: ExpressionSchema.optional(),
530
+ scope: EventScopeSchema.optional(),
531
+ payloadMapping: z.record(z.string()).optional(),
532
+ source: ListenSourceSchema.optional()
533
+ });
534
+ var RequiredFieldSchema = z.object({
535
+ name: z.string().min(1),
536
+ type: z.enum(["string", "number", "boolean", "date", "array", "object", "timestamp", "datetime", "enum"]),
537
+ description: z.string().optional()
538
+ });
539
+ z.object({
540
+ ref: z.string().min(1),
541
+ // Phase 1.2: optional registry path disambiguator, pairs with `ref`.
542
+ from: z.string().optional(),
543
+ linkedEntity: z.string().optional(),
544
+ name: z.string().optional(),
545
+ events: z.record(
546
+ z.string().min(1, "events key (atom event name) must be non-empty"),
547
+ z.string().min(1, "events value (caller event name) must be non-empty")
548
+ ).optional(),
549
+ fields: z.record(
550
+ z.string().min(1, "fields key (canonical field name) must be non-empty"),
551
+ z.string().min(1, "fields value (consumer field name) must be non-empty")
552
+ ).optional(),
553
+ // Each value is either a plain wiring value (TraitConfigValue) or an
554
+ // annotated ConfigFieldDeclaration. Declaration form is tried first
555
+ // (it's more specific — has a `"type"` string key); plain values fall
556
+ // through to the recursive TraitConfigValue union.
557
+ config: z.record(z.union([ConfigFieldDeclarationSchema, TraitConfigValueSchema])).optional(),
558
+ appliesTo: z.array(z.string()).optional(),
559
+ // Phase F.7: zod accepts an array (the inliner validates element
560
+ // shape). The full ListenDefinition shape isn't recursively encoded
561
+ // here because TraitReference is the call-site form — listen entries
562
+ // pasted in are already-resolved structured definitions, not nested
563
+ // overrides.
564
+ listens: z.array(z.unknown()).optional(),
565
+ emitsScope: z.enum(["internal", "external"]).optional(),
566
+ // Phase F.8: per-transition effects override. The keys are event
567
+ // names (the transition triggers AFTER renames). Values are arrays
568
+ // of SExpression-shaped data; the inliner validates the SExpression
569
+ // shape during application, so the schema accepts loose `unknown[]`.
570
+ effects: z.record(
571
+ z.string().min(1, "effects override key (event name) must be non-empty"),
572
+ z.array(z.unknown())
573
+ ).optional()
574
+ }).refine(
575
+ (ref2) => {
576
+ if (!ref2.events) return true;
577
+ for (const [from, to] of Object.entries(ref2.events)) {
578
+ if (from.length === 0 || to.length === 0) return false;
579
+ }
580
+ return true;
581
+ },
582
+ {
583
+ message: 'TraitReference "events" entries must have non-empty atom and caller event names',
584
+ path: ["events"]
585
+ }
586
+ );
587
+ var TraitScopeSchema = z.enum(["instance", "collection"]);
588
+ var EntityFieldContractSchema = z.object({
589
+ requires: z.array(z.string()),
590
+ provides: z.array(z.string())
591
+ });
592
+ var SourceBehaviorMetadataSchema = z.object({
593
+ behavior: z.string().min(1),
594
+ alias: z.string().min(1),
595
+ originalName: z.string().min(1)
596
+ });
597
+ var TraitSchema = z.object({
598
+ name: z.string().min(1),
599
+ description: z.string().optional(),
600
+ description_visual_prompt: z.string().optional(),
601
+ category: TraitCategorySchema.optional(),
602
+ entityRebindable: z.boolean().optional(),
603
+ entityContract: EntityFieldContractSchema.optional(),
604
+ entityBindingDescription: z.string().optional(),
605
+ entityBindingSynonyms: z.string().optional(),
606
+ capabilities: z.array(z.string()).optional(),
607
+ scope: TraitScopeSchema,
608
+ linkedEntity: z.string().optional(),
609
+ requiredFields: z.array(RequiredFieldSchema).optional(),
610
+ dataEntities: z.array(TraitDataEntitySchema).optional(),
611
+ stateMachine: StateMachineSchema.optional(),
612
+ initialEffects: z.array(EffectSchema).optional(),
613
+ ticks: z.array(TraitTickSchema).optional(),
614
+ emits: z.array(TraitEventContractSchema).optional(),
615
+ listens: z.array(TraitEventListenerSchema).optional(),
616
+ ui: z.record(z.unknown()).optional(),
617
+ config: DeclaredTraitConfigSchema.optional(),
618
+ sourceBehavior: SourceBehaviorMetadataSchema.optional(),
619
+ sourceEntityDefinition: EntitySchema.optional()
620
+ });
621
+ var TraitRefSchema = z.union([
622
+ z.string().min(1),
623
+ z.object({
624
+ ref: z.string().min(1),
625
+ config: TraitConfigSchema.optional(),
626
+ linkedEntity: z.string().optional(),
627
+ name: z.string().optional(),
628
+ // Phase F.4: same non-empty refine as TraitReferenceSchema.events.
629
+ // Both schemas accept the same call-site argument shape, so the
630
+ // validators should agree.
631
+ events: z.record(
632
+ z.string().min(1, "events key (atom event name) must be non-empty"),
633
+ z.string().min(1, "events value (caller event name) must be non-empty")
634
+ ).optional()
635
+ }),
636
+ TraitSchema
637
+ // Allow inline trait definitions
638
+ ]);
639
+
640
+ // src/types/page.ts
641
+ var ViewTypeSchema = z.enum([
642
+ "list",
643
+ "detail",
644
+ "create",
645
+ "edit",
646
+ "dashboard",
647
+ "custom"
648
+ ]);
649
+ var PageTraitRefSchema = z.object({
650
+ ref: z.string().min(1, "Trait ref is required"),
651
+ linkedEntity: z.string().optional(),
652
+ config: TraitConfigSchema.optional()
653
+ });
654
+ z.object({
655
+ name: z.string().min(1, "Page name is required"),
656
+ path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
657
+ primaryEntity: z.string().min(1, "Primary entity is required"),
658
+ traits: z.array(PageTraitRefSchema).min(1, "Page must have at least one trait"),
659
+ title: z.string().optional()
660
+ }).strict();
661
+ var OrbitalPageSchema = z.object({
662
+ name: z.string().min(1, "Page name is required"),
663
+ path: z.string().min(1, "Page path is required").startsWith("/", "Path must start with /"),
664
+ viewType: ViewTypeSchema.optional(),
665
+ title: z.string().optional(),
666
+ primaryEntity: z.string().optional(),
667
+ traits: z.array(PageTraitRefSchema).optional(),
668
+ isInitial: z.boolean().optional()
669
+ }).strict();
670
+ var PageSchema = OrbitalPageSchema;
671
+ z.enum([
672
+ "healthcare",
673
+ "education",
674
+ "finance",
675
+ "ecommerce",
676
+ "real-estate",
677
+ "logistics",
678
+ "hospitality",
679
+ "hr-management",
680
+ "project-management",
681
+ "social",
682
+ "content-management",
683
+ "iot",
684
+ "analytics",
685
+ "game",
686
+ "custom"
687
+ ]);
688
+ var AGENT_DOMAIN_CATEGORIES = [
689
+ "game",
690
+ "business",
691
+ "dashboard",
692
+ "form",
693
+ "content",
694
+ "social",
695
+ "ecommerce",
696
+ "workflow"
697
+ ];
698
+ var AgentDomainCategorySchema = z.enum([...AGENT_DOMAIN_CATEGORIES]);
699
+ z.enum([
700
+ "platformer",
701
+ "shooter",
702
+ "puzzle",
703
+ "rpg",
704
+ "board",
705
+ "racing",
706
+ "fighting",
707
+ "tower-defense",
708
+ "endless-runner",
709
+ "simulation",
710
+ "arcade",
711
+ "adventure"
712
+ ]);
713
+ z.enum(["domain", "system"]);
714
+ z.enum([
715
+ "pending",
716
+ "active",
717
+ "completed",
718
+ "cancelled",
719
+ "error",
720
+ "suspended",
721
+ "blocked",
722
+ "domain_workflow",
723
+ "domain_status",
724
+ "system_loading",
725
+ "system_error",
726
+ "system_idle",
727
+ "system_editing",
728
+ "system_confirming"
729
+ ]);
730
+ z.enum([
731
+ "domain_action",
732
+ "domain_trigger",
733
+ "system_crud",
734
+ "system_navigation",
735
+ "system_form",
736
+ "system_ui"
737
+ ]);
738
+ z.enum([
739
+ "domain_core",
740
+ "domain_supporting",
741
+ "domain_reference",
742
+ "system_user",
743
+ "system_config",
744
+ "system_audit"
745
+ ]);
746
+ var DomainVocabularySchema = z.record(z.string(), z.string()).optional();
747
+ var UserPersonaSchema = z.object({
748
+ name: z.string().min(1),
749
+ role: z.string().optional(),
750
+ device: z.enum(["mobile", "tablet", "desktop"]).optional()
751
+ });
752
+ var DomainContextSchema = z.object({
753
+ request: z.string().min(1, "Original request is required"),
754
+ requestFragment: z.string().optional(),
755
+ category: AgentDomainCategorySchema,
756
+ subDomain: z.string().optional(),
757
+ personas: z.array(UserPersonaSchema).optional(),
758
+ vocabulary: DomainVocabularySchema.optional()
759
+ });
760
+ var UXHintsSchema = z.object({
761
+ flowPattern: z.string().optional(),
762
+ listPattern: z.string().optional(),
763
+ formPattern: z.string().optional(),
764
+ detailPattern: z.string().optional(),
765
+ relatedLinks: z.array(z.lazy(() => RelatedLinkSchema)).optional()
766
+ });
767
+ var RelatedLinkSchema = z.object({
768
+ relation: z.string().min(1),
769
+ label: z.string().min(1),
770
+ targetView: z.enum(["list", "detail"]).optional()
771
+ });
772
+ var SuggestedGuardSchema = z.object({
773
+ id: z.string().min(1),
774
+ description: z.string().min(1),
775
+ appliesTo: z.array(z.string().min(1))
776
+ });
777
+ var DesignPreferencesSchema = z.object({
778
+ style: z.enum(["minimal", "modern", "playful", "data-driven", "immersive"]).optional(),
779
+ primaryColor: z.string().regex(/^#[0-9A-Fa-f]{6}$/, "Must be valid hex color").optional(),
780
+ device: z.enum(["mobile", "tablet", "desktop", "all"]).optional(),
781
+ darkMode: z.boolean().optional(),
782
+ uxHints: UXHintsSchema.optional()
783
+ });
784
+ var SpacingScaleSchema = z.object({
785
+ space0: z.string().optional(),
786
+ space1: z.string().optional(),
787
+ space2: z.string().optional(),
788
+ space3: z.string().optional(),
789
+ space4: z.string().optional(),
790
+ space5: z.string().optional(),
791
+ space6: z.string().optional(),
792
+ space7: z.string().optional(),
793
+ space8: z.string().optional(),
794
+ space9: z.string().optional(),
795
+ space10: z.string().optional(),
796
+ space11: z.string().optional(),
797
+ space12: z.string().optional()
798
+ });
799
+ var DensityTokensSchema = z.object({
800
+ spacing: SpacingScaleSchema.optional(),
801
+ buttonHeightSm: z.string().optional(),
802
+ buttonHeightMd: z.string().optional(),
803
+ buttonHeightLg: z.string().optional(),
804
+ inputHeightSm: z.string().optional(),
805
+ inputHeightMd: z.string().optional(),
806
+ inputHeightLg: z.string().optional(),
807
+ rowHeightCompact: z.string().optional(),
808
+ rowHeightNormal: z.string().optional(),
809
+ rowHeightSpacious: z.string().optional(),
810
+ cardPaddingSm: z.string().optional(),
811
+ cardPaddingMd: z.string().optional(),
812
+ cardPaddingLg: z.string().optional(),
813
+ dialogPadding: z.string().optional(),
814
+ sectionGap: z.string().optional()
815
+ });
816
+ var TypeScaleEntrySchema = z.object({
817
+ size: z.string(),
818
+ lineHeight: z.string()
819
+ });
820
+ var TypeSlotSchema = z.enum(["display", "body", "mono"]);
821
+ var TypeSizeKeySchema = z.enum([
822
+ "xs",
823
+ "sm",
824
+ "base",
825
+ "lg",
826
+ "xl",
827
+ "2xl",
828
+ "3xl",
829
+ "4xl",
830
+ "display-1",
831
+ "display-2"
832
+ ]);
833
+ var TypeWeightSchema = z.enum(["normal", "medium", "bold"]);
834
+ var TypeIntentSchema = z.object({
835
+ slot: TypeSlotSchema,
836
+ size: TypeSizeKeySchema,
837
+ weight: TypeWeightSchema
838
+ });
839
+ var TypeScaleSchema = z.object({
840
+ xs: TypeScaleEntrySchema.optional(),
841
+ sm: TypeScaleEntrySchema.optional(),
842
+ base: TypeScaleEntrySchema.optional(),
843
+ lg: TypeScaleEntrySchema.optional(),
844
+ xl: TypeScaleEntrySchema.optional(),
845
+ "2xl": TypeScaleEntrySchema.optional(),
846
+ "3xl": TypeScaleEntrySchema.optional(),
847
+ "4xl": TypeScaleEntrySchema.optional(),
848
+ "display-1": TypeScaleEntrySchema.optional(),
849
+ "display-2": TypeScaleEntrySchema.optional()
850
+ });
851
+ var TypeIntentMapSchema = z.object({
852
+ headingMajor: TypeIntentSchema.optional(),
853
+ headingMinor: TypeIntentSchema.optional(),
854
+ bodyEmphasis: TypeIntentSchema.optional(),
855
+ bodyDefault: TypeIntentSchema.optional(),
856
+ bodyQuiet: TypeIntentSchema.optional(),
857
+ caption: TypeIntentSchema.optional(),
858
+ numeric: TypeIntentSchema.optional()
859
+ });
860
+ var TypeScaleTokensSchema = z.object({
861
+ displayFamily: z.string().optional(),
862
+ bodyFamily: z.string().optional(),
863
+ monoFamily: z.string().optional(),
864
+ scale: TypeScaleSchema.optional(),
865
+ intents: TypeIntentMapSchema.optional()
866
+ });
867
+ var MotionDurationKeySchema = z.enum([
868
+ "instant",
869
+ "fast",
870
+ "normal",
871
+ "slow",
872
+ "dramatic"
873
+ ]);
874
+ var MotionEasingKeySchema = z.enum([
875
+ "linear",
876
+ "standard",
877
+ "emphasized",
878
+ "spring"
879
+ ]);
880
+ var MotionIntentSchema = z.object({
881
+ duration: MotionDurationKeySchema,
882
+ easing: MotionEasingKeySchema
883
+ });
884
+ var MotionDurationPaletteSchema = z.object({
885
+ instant: z.string().optional(),
886
+ fast: z.string().optional(),
887
+ normal: z.string().optional(),
888
+ slow: z.string().optional(),
889
+ dramatic: z.string().optional()
890
+ });
891
+ var MotionEasingPaletteSchema = z.object({
892
+ linear: z.string().optional(),
893
+ standard: z.string().optional(),
894
+ emphasized: z.string().optional(),
895
+ spring: z.string().optional()
896
+ });
897
+ var MotionIntentMapSchema = z.object({
898
+ enter: MotionIntentSchema.optional(),
899
+ exit: MotionIntentSchema.optional(),
900
+ hover: MotionIntentSchema.optional(),
901
+ press: MotionIntentSchema.optional(),
902
+ expand: MotionIntentSchema.optional(),
903
+ transition: MotionIntentSchema.optional()
904
+ });
905
+ var MotionTokensSchema = z.object({
906
+ durations: MotionDurationPaletteSchema.optional(),
907
+ easings: MotionEasingPaletteSchema.optional(),
908
+ intents: MotionIntentMapSchema.optional()
909
+ });
910
+ var IconFamilySchema = z.enum([
911
+ "lucide",
912
+ "phosphor-outline",
913
+ "phosphor-fill",
914
+ "phosphor-duotone",
915
+ "tabler",
916
+ "fa-solid"
917
+ ]);
918
+ var IconographyTokensSchema = z.object({
919
+ family: IconFamilySchema.optional(),
920
+ strokeWidth: z.string().optional(),
921
+ defaultSize: z.string().optional()
922
+ });
923
+ var ElevationTokensSchema = z.object({
924
+ cardElevation: z.string().optional(),
925
+ popoverElevation: z.string().optional(),
926
+ dialogElevation: z.string().optional(),
927
+ toastElevation: z.string().optional()
928
+ });
929
+ var GeometryTokensSchema = z.object({
930
+ radiusContainer: z.string().optional(),
931
+ radiusInteractive: z.string().optional(),
932
+ radiusPill: z.string().optional(),
933
+ borderHairline: z.string().optional(),
934
+ borderStandard: z.string().optional(),
935
+ borderHeavy: z.string().optional()
936
+ });
937
+ var ColorTokensSchema = z.object({
938
+ primary: z.string().optional(),
939
+ primaryHover: z.string().optional(),
940
+ primaryForeground: z.string().optional(),
941
+ secondary: z.string().optional(),
942
+ secondaryHover: z.string().optional(),
943
+ secondaryForeground: z.string().optional(),
944
+ accent: z.string().optional(),
945
+ accentForeground: z.string().optional(),
946
+ muted: z.string().optional(),
947
+ mutedForeground: z.string().optional(),
948
+ background: z.string().optional(),
949
+ foreground: z.string().optional(),
950
+ card: z.string().optional(),
951
+ cardForeground: z.string().optional(),
952
+ surface: z.string().optional(),
953
+ border: z.string().optional(),
954
+ input: z.string().optional(),
955
+ ring: z.string().optional(),
956
+ error: z.string().optional(),
957
+ errorForeground: z.string().optional(),
958
+ success: z.string().optional(),
959
+ successForeground: z.string().optional(),
960
+ warning: z.string().optional(),
961
+ warningForeground: z.string().optional(),
962
+ info: z.string().optional(),
963
+ infoForeground: z.string().optional(),
964
+ tableHeader: z.string().optional(),
965
+ tableBorder: z.string().optional(),
966
+ tableRowHover: z.string().optional(),
967
+ surfaceHover: z.string().optional(),
968
+ borderHover: z.string().optional(),
969
+ placeholder: z.string().optional()
970
+ });
971
+ var IllustrationStyleSchema = z.enum([
972
+ "minimal",
973
+ "illustrated",
974
+ "photo",
975
+ "text-only",
976
+ "mascot"
977
+ ]);
978
+ var IllustrationTokensSchema = z.object({
979
+ style: IllustrationStyleSchema.optional(),
980
+ emptyAsset: z.string().optional(),
981
+ loadingAsset: z.string().optional(),
982
+ errorAsset: z.string().optional(),
983
+ onboardingAsset: z.string().optional()
984
+ });
985
+ var ThemeTokensSchema = z.object({
986
+ color: ColorTokensSchema.optional(),
987
+ density: DensityTokensSchema.optional(),
988
+ typeScale: TypeScaleTokensSchema.optional(),
989
+ motion: MotionTokensSchema.optional(),
990
+ iconography: IconographyTokensSchema.optional(),
991
+ elevation: ElevationTokensSchema.optional(),
992
+ geometry: GeometryTokensSchema.optional(),
993
+ illustration: IllustrationTokensSchema.optional(),
994
+ // Legacy
995
+ colors: z.record(z.string(), z.string()).optional(),
996
+ radii: z.record(z.string(), z.string()).optional(),
997
+ spacing: z.record(z.string(), z.string()).optional(),
998
+ typography: z.record(z.string(), z.string()).optional(),
999
+ shadows: z.record(z.string(), z.string()).optional()
1000
+ });
1001
+ var ThemeVariantSchema = z.object({
1002
+ color: ColorTokensSchema.optional(),
1003
+ density: DensityTokensSchema.optional(),
1004
+ typeScale: TypeScaleTokensSchema.optional(),
1005
+ motion: MotionTokensSchema.optional(),
1006
+ iconography: IconographyTokensSchema.optional(),
1007
+ elevation: ElevationTokensSchema.optional(),
1008
+ geometry: GeometryTokensSchema.optional(),
1009
+ illustration: IllustrationTokensSchema.optional(),
1010
+ colors: z.record(z.string(), z.string()).optional(),
1011
+ radii: z.record(z.string(), z.string()).optional(),
1012
+ spacing: z.record(z.string(), z.string()).optional(),
1013
+ typography: z.record(z.string(), z.string()).optional(),
1014
+ shadows: z.record(z.string(), z.string()).optional()
1015
+ });
1016
+ var ThemeDefinitionSchema = z.object({
1017
+ name: z.string().min(1, "Theme name is required"),
1018
+ tokens: ThemeTokensSchema,
1019
+ variants: z.record(z.string(), ThemeVariantSchema).optional()
1020
+ });
1021
+ var ThemeRefStringSchema = z.string().regex(
1022
+ /^[A-Z][a-zA-Z0-9]*\.theme$/,
1023
+ 'Theme reference must be in format "Alias.theme" (e.g., "Ocean.theme")'
1024
+ );
1025
+ var ThemeRefSchema = z.union([
1026
+ ThemeDefinitionSchema,
1027
+ ThemeRefStringSchema
1028
+ ]);
1029
+ var DesignTokensSchema = z.record(z.string(), z.record(z.string(), z.string())).optional();
1030
+ var ALLOWED_CUSTOM_COMPONENTS = [
1031
+ "div",
1032
+ "span",
1033
+ "button",
1034
+ "a",
1035
+ "p",
1036
+ "h1",
1037
+ "h2",
1038
+ "h3",
1039
+ "h4",
1040
+ "h5",
1041
+ "h6",
1042
+ "header",
1043
+ "footer",
1044
+ "section",
1045
+ "article",
1046
+ "nav",
1047
+ "main",
1048
+ "aside",
1049
+ "ul",
1050
+ "ol",
1051
+ "li",
1052
+ "img",
1053
+ "label",
1054
+ "input",
1055
+ "form"
1056
+ ];
1057
+ var CustomPatternDefinitionSchema = z.object({
1058
+ type: z.literal("custom"),
1059
+ component: z.enum(ALLOWED_CUSTOM_COMPONENTS),
1060
+ className: z.string(),
1061
+ slots: z.array(z.string()).optional(),
1062
+ props: z.array(z.string()).optional()
1063
+ });
1064
+ var CustomPatternMapSchema = z.record(z.string(), CustomPatternDefinitionSchema).optional();
1065
+ var SERVICE_TYPES = ["rest", "socket", "mcp"];
1066
+ z.enum(SERVICE_TYPES);
1067
+ var RestAuthConfigSchema = z.object({
1068
+ type: z.enum(["api-key", "bearer", "basic", "oauth2"]),
1069
+ keyName: z.string().optional(),
1070
+ location: z.enum(["query", "header"]).optional(),
1071
+ secretEnv: z.string().optional()
1072
+ });
1073
+ var RestServiceDefSchema = z.object({
1074
+ name: z.string().min(1, "Service name is required"),
1075
+ type: z.literal("rest"),
1076
+ description: z.string().optional(),
1077
+ baseUrl: z.string().url("Base URL must be a valid URL"),
1078
+ headers: z.record(z.string()).optional(),
1079
+ auth: RestAuthConfigSchema.optional(),
1080
+ timeout: z.number().positive().optional()
1081
+ });
1082
+ var SocketEventsSchema = z.object({
1083
+ inbound: z.array(z.string()),
1084
+ outbound: z.array(z.string())
1085
+ });
1086
+ var SocketServiceDefSchema = z.object({
1087
+ name: z.string().min(1, "Service name is required"),
1088
+ type: z.literal("socket"),
1089
+ description: z.string().optional(),
1090
+ url: z.string().url("WebSocket URL must be valid"),
1091
+ events: SocketEventsSchema,
1092
+ reconnect: z.object({
1093
+ enabled: z.boolean(),
1094
+ maxAttempts: z.number().positive().optional(),
1095
+ delayMs: z.number().positive().optional()
1096
+ }).optional()
1097
+ });
1098
+ var McpServiceDefSchema = z.object({
1099
+ name: z.string().min(1, "Service name is required"),
1100
+ type: z.literal("mcp"),
1101
+ description: z.string().optional(),
1102
+ serverPath: z.string().min(1, "Server path is required"),
1103
+ capabilities: z.array(z.string()).min(1, "At least one capability is required"),
1104
+ env: z.record(z.string()).optional()
1105
+ });
1106
+ var ServiceDefinitionSchema = z.discriminatedUnion("type", [
1107
+ RestServiceDefSchema,
1108
+ SocketServiceDefSchema,
1109
+ McpServiceDefSchema
1110
+ ]);
1111
+ var ServiceRefStringSchema = z.string().regex(
1112
+ /^[A-Z][a-zA-Z0-9]*\.services\.[a-zA-Z][a-zA-Z0-9]*$/,
1113
+ 'Service reference must be in format "Alias.services.ServiceName" (e.g., "Weather.services.openweather")'
1114
+ );
1115
+ var ServiceRefObjectSchema = z.object({
1116
+ ref: ServiceRefStringSchema,
1117
+ description: z.string().optional(),
1118
+ baseUrl: z.string().url("baseUrl override must be a valid URL").optional(),
1119
+ headers: z.record(z.string()).optional(),
1120
+ url: z.string().url("url override must be a valid URL").optional(),
1121
+ serverPath: z.string().optional()
1122
+ });
1123
+ var ServiceRefSchema = z.union([
1124
+ ServiceDefinitionSchema,
1125
+ ServiceRefObjectSchema,
1126
+ ServiceRefStringSchema
1127
+ ]);
1128
+
1129
+ // src/types/orbital.ts
1130
+ var UseDeclarationSchema = z.object({
1131
+ from: z.string().min(1, "Import source is required"),
1132
+ as: z.string().min(1, "Alias is required").regex(
1133
+ /^[A-Z][a-zA-Z0-9]*$/,
1134
+ 'Alias must be PascalCase (e.g., "Health", "GameCore")'
1135
+ )
1136
+ });
1137
+ var EntityRefStringSchema = z.string().regex(
1138
+ /^[A-Z][a-zA-Z0-9]*\.entity$/,
1139
+ 'Entity reference must be in format "Alias.entity" (e.g., "Goblin.entity")'
1140
+ );
1141
+ var EntityCallSchema = z.object({
1142
+ extends: z.string().regex(
1143
+ /^[A-Z][a-zA-Z0-9]*\.entity$/,
1144
+ 'EntityCall "extends" must be in format "Alias.entity"'
1145
+ ),
1146
+ name: z.string().optional(),
1147
+ fields: z.array(EntityFieldSchema).optional(),
1148
+ persistence: EntityPersistenceSchema.optional(),
1149
+ collection: z.string().optional()
1150
+ }).refine(
1151
+ (call) => {
1152
+ if (!call.fields) return true;
1153
+ const seen = /* @__PURE__ */ new Set();
1154
+ for (const field of call.fields) {
1155
+ if (field.name === void 0) continue;
1156
+ if (seen.has(field.name)) return false;
1157
+ seen.add(field.name);
1158
+ }
1159
+ return true;
1160
+ },
1161
+ {
1162
+ message: 'EntityCall "fields" override list must not contain duplicate field names',
1163
+ path: ["fields"]
1164
+ }
1165
+ );
1166
+ var EntityRefSchema = z.union([
1167
+ EntitySchema,
1168
+ EntityRefStringSchema,
1169
+ EntityCallSchema
1170
+ ]);
1171
+ var PageRefStringSchema = z.string().regex(
1172
+ /^[A-Z][a-zA-Z0-9]*\.pages\.[A-Z][a-zA-Z0-9]*$/,
1173
+ 'Page reference must be in format "Alias.pages.PageName" (e.g., "User.pages.Profile")'
1174
+ );
1175
+ var PageRefObjectSchema = z.object({
1176
+ ref: PageRefStringSchema,
1177
+ // Phase 1.2: optional registry path disambiguator, pairs with `ref`.
1178
+ from: z.string().optional(),
1179
+ path: z.string().startsWith("/").optional(),
1180
+ linkedEntity: z.string().optional(),
1181
+ traits: z.array(TraitRefSchema).optional()
1182
+ });
1183
+ var PageRefSchema = z.union([
1184
+ PageSchema,
1185
+ PageRefStringSchema,
1186
+ PageRefObjectSchema
1187
+ ]);
1188
+ z.string().regex(
1189
+ /^([A-Z][a-zA-Z0-9]*\.traits\.)?[A-Z][a-zA-Z0-9]*$/,
1190
+ 'Trait reference must be "TraitName" or "Alias.traits.TraitName"'
1191
+ );
1192
+ z.object({
1193
+ event: z.string().min(1),
1194
+ triggers: z.string().min(1),
1195
+ guard: z.string().optional()
1196
+ });
1197
+ var EventSourceSchema = z.object({
1198
+ trait: z.string().min(1),
1199
+ transition: z.string().optional(),
1200
+ tick: z.string().optional()
1201
+ });
1202
+ var ComputedEventContractSchema = z.object({
1203
+ event: z.string().min(1),
1204
+ originalEvent: z.string().min(1),
1205
+ source: EventSourceSchema,
1206
+ description: z.string().optional(),
1207
+ payload: z.array(EventPayloadFieldSchema).optional()
1208
+ });
1209
+ var ComputedEventListenerSchema = z.object({
1210
+ event: z.string().min(1),
1211
+ source: EventSourceSchema,
1212
+ triggers: z.string().min(1),
1213
+ guard: ExpressionSchema.optional(),
1214
+ payloadMapping: z.record(z.string()).optional()
1215
+ });
1216
+ var OrbitalDefinitionSchema = z.object({
1217
+ name: z.string().min(1, "Orbital name is required"),
1218
+ description: z.string().optional(),
1219
+ visual_prompt: z.string().optional(),
1220
+ // Import system
1221
+ uses: z.array(UseDeclarationSchema).optional(),
1222
+ // Theme & Services
1223
+ theme: ThemeRefSchema.optional(),
1224
+ services: z.array(ServiceRefSchema).optional(),
1225
+ // Components (inline or reference)
1226
+ entity: EntityRefSchema,
1227
+ traits: z.array(TraitRefSchema),
1228
+ pages: z.array(PageRefSchema),
1229
+ // Event interface (trait-centric model) - computed by resolver
1230
+ emits: z.array(ComputedEventContractSchema).optional(),
1231
+ listens: z.array(ComputedEventListenerSchema).optional(),
1232
+ // Filter for exposed events (trait-centric model)
1233
+ exposes: z.array(z.string()).optional(),
1234
+ // Context fields - persisted throughout orbital lifecycle
1235
+ domainContext: DomainContextSchema.optional(),
1236
+ design: DesignPreferencesSchema.optional(),
1237
+ suggestedGuards: z.array(SuggestedGuardSchema).optional()
1238
+ });
1239
+ var OrbitalSchema = OrbitalDefinitionSchema;
1240
+ var OrbitalConfigSchema = z.object({
1241
+ theme: z.object({
1242
+ primary: z.string().optional(),
1243
+ secondary: z.string().optional(),
1244
+ mode: z.enum(["light", "dark", "system"]).optional()
1245
+ }).optional(),
1246
+ features: z.record(z.boolean()).optional(),
1247
+ api: z.object({
1248
+ baseUrl: z.string().optional(),
1249
+ timeout: z.number().optional()
1250
+ }).optional()
1251
+ });
1252
+ var ConfigProvenanceRecordSchema = z.object({
1253
+ trait: z.string(),
1254
+ patternPath: z.string().optional(),
1255
+ prop: z.string(),
1256
+ knob: z.string()
1257
+ });
1258
+ var SchemaMetadataSchema = z.object({
1259
+ version: z.number().optional(),
1260
+ createdAt: z.number().optional(),
1261
+ source: z.string().optional(),
1262
+ updatedAt: z.number().optional(),
1263
+ configProvenance: z.record(z.array(ConfigProvenanceRecordSchema)).optional()
1264
+ });
1265
+ z.object({
1266
+ name: z.string().min(1, "Schema name is required"),
1267
+ description: z.string().optional(),
1268
+ summary: z.string().optional(),
1269
+ version: z.string().optional(),
1270
+ domainContext: DomainContextSchema.optional(),
1271
+ design: DesignPreferencesSchema.optional(),
1272
+ designTokens: DesignTokensSchema,
1273
+ customPatterns: CustomPatternMapSchema,
1274
+ orbitals: z.array(OrbitalSchema).min(1, "At least one orbital is required"),
1275
+ services: z.array(ServiceDefinitionSchema).optional(),
1276
+ config: OrbitalConfigSchema.optional(),
1277
+ _metadata: SchemaMetadataSchema.optional()
1278
+ });
1279
+ z.string().refine(
1280
+ (val) => {
1281
+ if (!val.startsWith("@")) return false;
1282
+ const parts = val.slice(1).split(".");
1283
+ if (parts.length === 0 || parts[0] === "") return false;
1284
+ return parts.every((part) => /^[\p{L}_][\p{L}0-9_]*$/u.test(part));
1285
+ },
1286
+ { message: "Invalid binding format. Must be @name or @name.path.to.field" }
1287
+ );
1288
+ var BINDING_ROOTS = [
1289
+ "entity",
1290
+ "payload",
1291
+ "state",
1292
+ "config",
1293
+ "user",
1294
+ "trait",
1295
+ "item",
1296
+ "now",
1297
+ "computed",
1298
+ "other"
1299
+ ];
1300
+ new Set(BINDING_ROOTS.filter((r) => r !== "other"));
1301
+ var TRAIT_REF_PATTERN = /^@trait\.[A-Z][a-zA-Z0-9]*$/;
1302
+ z.string().regex(TRAIT_REF_PATTERN, "expected `@trait.<TraitName>` reference");
1303
+ z.object({
1304
+ createFlow: z.enum(["modal", "page", "inline", "none"]),
1305
+ editFlow: z.enum(["modal", "page", "inline", "none"]),
1306
+ viewFlow: z.enum(["drawer", "page", "modal", "inline", "none"]),
1307
+ deleteFlow: z.enum(["confirm", "instant", "none"]),
1308
+ listInteraction: z.enum(["click-to-view", "click-to-edit", "inline-edit"]).optional(),
1309
+ bulkActions: z.boolean().optional(),
1310
+ realtime: z.boolean().optional()
1311
+ });
1312
+ z.string();
1313
+
1314
+ // src/builders.ts
1315
+ function makeTraitRef(opts) {
1316
+ const ref2 = { ref: opts.ref };
1317
+ if (opts.from !== void 0) ref2.from = opts.from;
1318
+ if (opts.name !== void 0) ref2.name = opts.name;
1319
+ if (opts.linkedEntity !== void 0) ref2.linkedEntity = opts.linkedEntity;
1320
+ if (opts.events !== void 0) ref2.events = opts.events;
1321
+ if (opts.fields !== void 0) ref2.fields = opts.fields;
1322
+ if (opts.effects !== void 0) ref2.effects = opts.effects;
1323
+ if (opts.listens !== void 0) ref2.listens = opts.listens;
1324
+ if (opts.emitsScope !== void 0) ref2.emitsScope = opts.emitsScope;
1325
+ if (opts.config !== void 0) ref2.config = opts.config;
1326
+ return ref2;
1327
+ }
1328
+ function makePageRef(opts) {
1329
+ const ref2 = { ref: opts.ref };
1330
+ if (opts.from !== void 0) ref2.from = opts.from;
1331
+ if (opts.path !== void 0) ref2.path = opts.path;
1332
+ if (opts.linkedEntity !== void 0) ref2.linkedEntity = opts.linkedEntity;
1333
+ if (opts.traits !== void 0) ref2.traits = opts.traits;
1334
+ return ref2;
1335
+ }
1336
+ function makeOrbitalWithUses(opts) {
1337
+ const orbital = {
1338
+ name: opts.name,
1339
+ uses: opts.uses,
1340
+ entity: opts.entity,
1341
+ traits: opts.traits,
1342
+ pages: opts.pages ?? []
1343
+ };
1344
+ return orbital;
1345
+ }
1346
+
1347
+ // src/factory-runtime/apply-params-to-orb.ts
1348
+ function validateOrbitalFactoryParams(manifest, raw) {
1349
+ if (raw === null || Array.isArray(raw)) {
1350
+ return {
1351
+ ok: false,
1352
+ error: { kind: "not-object", received: Array.isArray(raw) ? "array" : "null" }
1353
+ };
1354
+ }
1355
+ const ALLOWED_KEYS = /* @__PURE__ */ new Set([
1356
+ "fields",
1357
+ "pagePath",
1358
+ "persistence",
1359
+ "entityName",
1360
+ "collection",
1361
+ "traitOverrides"
1362
+ ]);
1363
+ for (const key of Object.keys(raw)) {
1364
+ if (!ALLOWED_KEYS.has(key)) {
1365
+ return { ok: false, error: { kind: "unknown-key", key } };
1366
+ }
1367
+ }
1368
+ const candidate = raw;
1369
+ if (candidate.traitOverrides !== void 0) {
1370
+ const to = candidate.traitOverrides;
1371
+ if (to === null || typeof to !== "object" || Array.isArray(to)) {
1372
+ return {
1373
+ ok: false,
1374
+ error: {
1375
+ kind: "trait-overrides-not-object",
1376
+ received: Array.isArray(to) ? "array" : typeof to
1377
+ }
1378
+ };
1379
+ }
1380
+ const allowed = new Set(manifest.traitNames);
1381
+ for (const traitName of Object.keys(to)) {
1382
+ if (!allowed.has(traitName)) {
1383
+ return {
1384
+ ok: false,
1385
+ error: {
1386
+ kind: "unknown-trait-override",
1387
+ trait: traitName,
1388
+ allowed: manifest.traitNames
1389
+ }
1390
+ };
1391
+ }
1392
+ }
1393
+ }
1394
+ return { ok: true, params: candidate };
1395
+ }
1396
+ function assertResolvedEntity(entity, orbitalName, orbName) {
1397
+ if (typeof entity === "string") {
1398
+ throw new Error(
1399
+ `applyParamsToOrb: orbital "${orbitalName}" in orb "${orbName}" has an unresolved entity reference (string form). Pass a resolved .orb.`
1400
+ );
1401
+ }
1402
+ if ("extends" in entity) {
1403
+ throw new Error(
1404
+ `applyParamsToOrb: orbital "${orbitalName}" in orb "${orbName}" has an unresolved EntityCall ("extends" form). Pass a resolved .orb.`
1405
+ );
1406
+ }
1407
+ return entity;
1408
+ }
1409
+ function findOrbitalOrThrow(orb, orbitalName) {
1410
+ const orbital = orb.orbitals.find((o) => o.name === orbitalName);
1411
+ if (!orbital) {
1412
+ throw new Error(
1413
+ `applyParamsToOrb: orbital "${orbitalName}" not found in orb "${orb.name}". Available: ${orb.orbitals.map((o) => o.name).join(", ")}`
1414
+ );
1415
+ }
1416
+ return orbital;
1417
+ }
1418
+ function buildEntity(ctx, effectiveName, effectiveCollection, params) {
1419
+ const canonicalFields = Array.isArray(ctx.canonicalEntity.fields) ? ctx.canonicalEntity.fields : [];
1420
+ const extras = params.fields ?? [];
1421
+ for (const f of extras) {
1422
+ if (f.type === "enum") {
1423
+ if (!Array.isArray(f.values) || f.values.length === 0) {
1424
+ throw new Error(
1425
+ `Field "${f.name ?? "<unnamed>"}" (type: "enum") requires a non-empty \`values: string[]\` array. Got: ${f.values === void 0 ? "undefined" : JSON.stringify(f.values)}.`
1426
+ );
1427
+ }
1428
+ }
1429
+ if (f.type === "relation") {
1430
+ const rel = f.relation;
1431
+ if (!rel || typeof rel.entity !== "string" || rel.entity.length === 0) {
1432
+ throw new Error(
1433
+ `Field "${f.name ?? "<unnamed>"}" (type: "relation") requires \`relation: { entity: <EntityName>, cardinality: "one" | "many" }\`. Got: ${rel === void 0 ? "undefined" : JSON.stringify(rel)}.`
1434
+ );
1435
+ }
1436
+ if (rel.cardinality !== "one" && rel.cardinality !== "many") {
1437
+ throw new Error(
1438
+ `Field "${f.name ?? "<unnamed>"}" (type: "relation") requires \`relation.cardinality: "one" | "many"\`. Got: ${rel.cardinality === void 0 ? "undefined" : JSON.stringify(rel.cardinality)}.`
1439
+ );
1440
+ }
1441
+ }
1442
+ }
1443
+ let mergedFields;
1444
+ if (extras.length === 0) {
1445
+ mergedFields = canonicalFields;
1446
+ } else {
1447
+ const extraNames = new Set(extras.map((f) => f.name));
1448
+ mergedFields = [
1449
+ ...canonicalFields.filter((f) => !extraNames.has(f.name)),
1450
+ ...extras
1451
+ ];
1452
+ }
1453
+ const entity = {
1454
+ name: effectiveName,
1455
+ persistence: params.persistence ?? ctx.canonicalEntity.persistence,
1456
+ fields: [...mergedFields]
1457
+ };
1458
+ if (effectiveCollection !== void 0) {
1459
+ entity.collection = effectiveCollection;
1460
+ }
1461
+ return entity;
1462
+ }
1463
+ function isTraitReferenceObject(t) {
1464
+ if (t === null || typeof t !== "object") return false;
1465
+ if (!("ref" in t)) return false;
1466
+ return typeof t.ref === "string";
1467
+ }
1468
+ function isPageRefObject(p) {
1469
+ if (p === null || typeof p !== "object") return false;
1470
+ if (!("ref" in p)) return false;
1471
+ return typeof p.ref === "string";
1472
+ }
1473
+ function rewriteInlineLinkedEntity(shape, oldName, newName) {
1474
+ if (shape.linkedEntity !== oldName) return shape;
1475
+ return { ...shape, linkedEntity: newName };
1476
+ }
1477
+ var ENTITY_POSITIONAL_OPS = [
1478
+ { op: "fetch", entityIndex: 1 },
1479
+ { op: "ref", entityIndex: 1 },
1480
+ { op: "spawn", entityIndex: 1 },
1481
+ { op: "persist", actionGuard: /* @__PURE__ */ new Set(["create", "update", "delete"]), entityIndex: 2 }
1482
+ ];
1483
+ var ENTITY_VALUED_PROPS = /* @__PURE__ */ new Set([
1484
+ "entity",
1485
+ "source",
1486
+ "entityType",
1487
+ "linkedEntity"
1488
+ ]);
1489
+ function rewriteEntityInSExpr(value, oldName, newName) {
1490
+ if (value === null) return null;
1491
+ if (typeof value === "boolean" || typeof value === "number") return value;
1492
+ if (typeof value === "string") {
1493
+ const prefix = `@${oldName}`;
1494
+ if (value === prefix || value.startsWith(`${prefix}.`)) {
1495
+ return `@${newName}${value.slice(prefix.length)}`;
1496
+ }
1497
+ return value;
1498
+ }
1499
+ if (Array.isArray(value)) {
1500
+ const first = value[0];
1501
+ if (typeof first === "string") {
1502
+ for (const entry of ENTITY_POSITIONAL_OPS) {
1503
+ if (first !== entry.op) continue;
1504
+ if (entry.actionGuard !== void 0) {
1505
+ const action = value[1];
1506
+ if (typeof action !== "string" || !entry.actionGuard.has(action)) continue;
1507
+ }
1508
+ const at = entry.entityIndex;
1509
+ const slot = value[at];
1510
+ if (typeof slot !== "string" || slot !== oldName) continue;
1511
+ const rewritten = [];
1512
+ for (let i = 0; i < value.length; i++) {
1513
+ rewritten.push(i === at ? newName : rewriteEntityInSExpr(value[i], oldName, newName));
1514
+ }
1515
+ return rewritten;
1516
+ }
1517
+ }
1518
+ return value.map((v) => rewriteEntityInSExpr(v, oldName, newName));
1519
+ }
1520
+ return rewriteEntityInSExprMap(value, oldName, newName);
1521
+ }
1522
+ function rewriteEntityInSExprMap(obj, oldName, newName) {
1523
+ const next = {};
1524
+ for (const [k, v] of Object.entries(obj)) {
1525
+ if (ENTITY_VALUED_PROPS.has(k) && typeof v === "string" && v === oldName) {
1526
+ next[k] = newName;
1527
+ } else {
1528
+ next[k] = rewriteEntityInSExpr(v, oldName, newName);
1529
+ }
1530
+ }
1531
+ return next;
1532
+ }
1533
+ function rewritePayloadFieldType(typeStr, oldName, newName) {
1534
+ if (typeStr === oldName) return newName;
1535
+ if (typeStr === `[${oldName}]`) return `[${newName}]`;
1536
+ return typeStr;
1537
+ }
1538
+ function rewriteEventContract(contract, oldName, newName) {
1539
+ if (!contract.payloadSchema || contract.payloadSchema.length === 0) return contract;
1540
+ return {
1541
+ ...contract,
1542
+ payloadSchema: contract.payloadSchema.map((f) => {
1543
+ const next = { ...f, type: rewritePayloadFieldType(f.type, oldName, newName) };
1544
+ if (typeof f.entityType === "string" && f.entityType === oldName) {
1545
+ next.entityType = newName;
1546
+ }
1547
+ return next;
1548
+ })
1549
+ };
1550
+ }
1551
+ function rewriteListener(listener, oldName, newName) {
1552
+ if (!listener.payloadMapping) return listener;
1553
+ const prefix = `@${oldName}`;
1554
+ const nextMapping = {};
1555
+ for (const [k, v] of Object.entries(listener.payloadMapping)) {
1556
+ nextMapping[k] = v === prefix || v.startsWith(`${prefix}.`) ? `@${newName}${v.slice(prefix.length)}` : v;
1557
+ }
1558
+ return { ...listener, payloadMapping: nextMapping };
1559
+ }
1560
+ function rewriteTick(tick, oldName, newName) {
1561
+ const next = { ...tick };
1562
+ if (next.guard !== void 0 && next.guard !== null) {
1563
+ next.guard = rewriteEntityInSExpr(next.guard, oldName, newName);
1564
+ }
1565
+ next.effects = next.effects.map(
1566
+ (e) => rewriteEntityInSExpr(e, oldName, newName)
1567
+ );
1568
+ return next;
1569
+ }
1570
+ function rebindInlineTraitEntity(trait, oldName, newName) {
1571
+ if (oldName === newName) return trait;
1572
+ return rewriteEntityInInlineTrait(rewriteInlineLinkedEntity(trait, oldName, newName), oldName, newName);
1573
+ }
1574
+ function rewriteEntityInInlineTrait(trait, oldName, newName) {
1575
+ if (oldName === newName) return trait;
1576
+ const next = { ...trait };
1577
+ if (next.stateMachine) {
1578
+ next.stateMachine = {
1579
+ ...next.stateMachine,
1580
+ transitions: next.stateMachine.transitions.map((t) => {
1581
+ const updated = { ...t };
1582
+ if (updated.guard !== void 0 && updated.guard !== null) {
1583
+ updated.guard = rewriteEntityInSExpr(updated.guard, oldName, newName);
1584
+ }
1585
+ if (updated.effects) {
1586
+ updated.effects = updated.effects.map(
1587
+ (e) => rewriteEntityInSExpr(e, oldName, newName)
1588
+ );
1589
+ }
1590
+ return updated;
1591
+ })
1592
+ };
1593
+ }
1594
+ if (next.initialEffects) {
1595
+ next.initialEffects = next.initialEffects.map(
1596
+ (e) => rewriteEntityInSExpr(e, oldName, newName)
1597
+ );
1598
+ }
1599
+ if (next.ticks) {
1600
+ next.ticks = next.ticks.map((t) => rewriteTick(t, oldName, newName));
1601
+ }
1602
+ if (next.emits) {
1603
+ next.emits = next.emits.map((c) => rewriteEventContract(c, oldName, newName));
1604
+ }
1605
+ if (next.listens) {
1606
+ next.listens = next.listens.map((l) => rewriteListener(l, oldName, newName));
1607
+ }
1608
+ return next;
1609
+ }
1610
+ function rebuildTraits(ctx, effectiveEntityName, traits) {
1611
+ return traits.map((t) => {
1612
+ if (!isTraitReferenceObject(t)) {
1613
+ if (typeof t === "string") return t;
1614
+ return rebindInlineTraitEntity(t, ctx.canonicalEntityName, effectiveEntityName);
1615
+ }
1616
+ const rewrittenLinkedEntity = t.linkedEntity === ctx.canonicalEntityName ? effectiveEntityName : t.linkedEntity;
1617
+ const opts = {
1618
+ ...t,
1619
+ linkedEntity: rewrittenLinkedEntity
1620
+ };
1621
+ return makeTraitRef(opts);
1622
+ });
1623
+ }
1624
+ function rebuildPages(ctx, effectiveEntityName, pages) {
1625
+ if (!pages) return [];
1626
+ return pages.map((p) => {
1627
+ if (!isPageRefObject(p)) {
1628
+ return p;
1629
+ }
1630
+ const rewrittenLinkedEntity = p.linkedEntity === ctx.canonicalEntityName ? effectiveEntityName : p.linkedEntity;
1631
+ const opts = {
1632
+ ...p,
1633
+ linkedEntity: rewrittenLinkedEntity
1634
+ };
1635
+ return makePageRef(opts);
1636
+ });
1637
+ }
1638
+ function mergeCallSiteConfigOverrides(base, overrides) {
1639
+ const next = {};
1640
+ for (const [k, entry] of Object.entries(base)) {
1641
+ next[k] = isCallSiteConfigDeclaration(entry) ? entry : { type: "unknown", default: entry };
1642
+ }
1643
+ for (const [k, v] of Object.entries(overrides)) {
1644
+ if (isCallSiteConfigDeclaration(v)) {
1645
+ next[k] = v;
1646
+ continue;
1647
+ }
1648
+ const existing = base[k];
1649
+ next[k] = existing !== void 0 && isCallSiteConfigDeclaration(existing) ? { ...existing, default: v } : { type: "unknown", default: v };
1650
+ }
1651
+ return next;
1652
+ }
1653
+ function applyParamsToOrb(orb, orbitalName, _manifest, params) {
1654
+ const orbital = findOrbitalOrThrow(orb, orbitalName);
1655
+ const canonicalEntity = assertResolvedEntity(orbital.entity, orbitalName, orb.name);
1656
+ const canonicalEntityName = canonicalEntity.name;
1657
+ const effectiveEntityName = params.entityName ?? canonicalEntityName;
1658
+ const effectiveCollection = typeof canonicalEntity.collection === "string" ? params.collection ?? (params.entityName ? `${params.entityName.toLowerCase()}s` : canonicalEntity.collection) : params.collection;
1659
+ const ctx = { canonicalEntityName, canonicalEntity };
1660
+ const built = makeOrbitalWithUses({
1661
+ name: orbital.name,
1662
+ uses: orbital.uses ?? [],
1663
+ entity: buildEntity(ctx, effectiveEntityName, effectiveCollection, params),
1664
+ traits: rebuildTraits(ctx, effectiveEntityName, orbital.traits),
1665
+ pages: rebuildPages(ctx, effectiveEntityName, orbital.pages)
1666
+ });
1667
+ if (built.traits && params.traitOverrides !== void 0) {
1668
+ built.traits = built.traits.map((t) => {
1669
+ if (!isTraitReferenceObject(t) || typeof t.name !== "string") return t;
1670
+ const override = params.traitOverrides?.[t.name];
1671
+ if (!override) return t;
1672
+ const merged = { ...t };
1673
+ if (override.config !== void 0) {
1674
+ merged.config = mergeCallSiteConfigOverrides(t.config ?? {}, override.config);
1675
+ }
1676
+ if (override.linkedEntity !== void 0) merged.linkedEntity = override.linkedEntity;
1677
+ if (override.events !== void 0) {
1678
+ if (override.events === null || typeof override.events !== "object" || Array.isArray(override.events)) {
1679
+ throw new Error(
1680
+ `traitOverrides["${t.name}"].events must be a Record<string,string> (rename map like { "OPEN": "ADD_ITEM" }), got ${Array.isArray(override.events) ? "an array" : typeof override.events}`
1681
+ );
1682
+ }
1683
+ for (const [k, v] of Object.entries(override.events)) {
1684
+ if (typeof v !== "string") {
1685
+ throw new Error(
1686
+ `traitOverrides["${t.name}"].events["${k}"] must be a string (target event name), got ${typeof v}`
1687
+ );
1688
+ }
1689
+ }
1690
+ merged.events = { ...t.events ?? {}, ...override.events };
1691
+ }
1692
+ if (override.name !== void 0) merged.name = override.name;
1693
+ if (override.emitsScope !== void 0) merged.emitsScope = override.emitsScope;
1694
+ if (override.listens !== void 0) merged.listens = override.listens;
1695
+ return merged;
1696
+ });
1697
+ }
1698
+ if (built.pages && params.pagePath !== void 0) {
1699
+ built.pages = built.pages.map((p, idx) => {
1700
+ if (!isPageRefObject(p) || idx !== 0) return p;
1701
+ return { ...p, path: params.pagePath };
1702
+ });
1703
+ }
1704
+ return built;
1705
+ }
1706
+
1707
+ // src/factory-runtime/apply-params-to-whole-orb.ts
1708
+ function applyParamsToWholeOrb(orb, manifests, params) {
1709
+ const manifestByOrbital = /* @__PURE__ */ new Map();
1710
+ for (const m of manifests) {
1711
+ manifestByOrbital.set(m.orbitalName, m);
1712
+ }
1713
+ const rebuilt = [];
1714
+ for (const orbital of orb.orbitals) {
1715
+ const manifest = manifestByOrbital.get(orbital.name);
1716
+ if (!manifest) {
1717
+ rebuilt.push(orbital);
1718
+ continue;
1719
+ }
1720
+ rebuilt.push(applyParamsToOrb(orb, orbital.name, manifest, params));
1721
+ }
1722
+ return { ...orb, orbitals: rebuilt };
1723
+ }
1724
+
1725
+ export { applyParamsToOrb, applyParamsToWholeOrb, extractManifest, mergeCallSiteConfigOverrides, rebindInlineTraitEntity, rewriteEntityInInlineTrait, validateOrbitalFactoryParams };
1726
+ //# sourceMappingURL=index.js.map
1727
+ //# sourceMappingURL=index.js.map