@almadar/ui 2.13.2 → 2.14.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.
Files changed (34) hide show
  1. package/dist/chunk-4N3BAPDB.js +1667 -0
  2. package/dist/{chunk-PERGHHON.js → chunk-IRIGCHP4.js} +2 -12
  3. package/dist/{chunk-ZW5N4AUU.js → chunk-M7MOIE46.js} +3 -3
  4. package/dist/{chunk-Y7IHEYYE.js → chunk-QU2X55WH.js} +11 -1
  5. package/dist/{chunk-77CBR3Z7.js → chunk-SKWPSQHQ.js} +13448 -2279
  6. package/dist/{chunk-4ZBSL37D.js → chunk-XL7WB2O5.js} +415 -58
  7. package/dist/components/index.css +508 -0
  8. package/dist/components/index.js +769 -11187
  9. package/dist/components/organisms/game/three/index.js +49 -1709
  10. package/dist/hooks/index.js +2 -2
  11. package/dist/lib/index.js +1 -3
  12. package/dist/providers/index.css +599 -0
  13. package/dist/providers/index.js +5 -4
  14. package/dist/runtime/index.css +599 -0
  15. package/dist/runtime/index.js +6 -6
  16. package/package.json +5 -4
  17. package/dist/ThemeContext-D9xUORq5.d.ts +0 -105
  18. package/dist/chunk-42YQ6JVR.js +0 -48
  19. package/dist/chunk-WCTZ7WZX.js +0 -311
  20. package/dist/cn-C_ATNPvi.d.ts +0 -332
  21. package/dist/components/index.d.ts +0 -9788
  22. package/dist/components/organisms/game/three/index.d.ts +0 -1233
  23. package/dist/context/index.d.ts +0 -208
  24. package/dist/event-bus-types-CjJduURa.d.ts +0 -73
  25. package/dist/hooks/index.d.ts +0 -1221
  26. package/dist/isometric-ynNHVPZx.d.ts +0 -111
  27. package/dist/lib/index.d.ts +0 -320
  28. package/dist/locales/index.d.ts +0 -22
  29. package/dist/offline-executor-CHr4uAhf.d.ts +0 -401
  30. package/dist/providers/index.d.ts +0 -465
  31. package/dist/renderer/index.d.ts +0 -525
  32. package/dist/runtime/index.d.ts +0 -280
  33. package/dist/stores/index.d.ts +0 -151
  34. package/dist/useUISlots-BBjNvQtb.d.ts +0 -85
@@ -1,3 +1,313 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ // lib/cn.ts
5
+ function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+
9
+ // lib/debug.ts
10
+ var DEBUG_ENABLED = typeof window !== "undefined" && (localStorage.getItem("debug") === "true" || process.env.NODE_ENV === "development");
11
+ function isDebugEnabled() {
12
+ return DEBUG_ENABLED;
13
+ }
14
+ function debug(...args) {
15
+ if (DEBUG_ENABLED) {
16
+ console.log("[DEBUG]", ...args);
17
+ }
18
+ }
19
+ function debugGroup(label) {
20
+ if (DEBUG_ENABLED) {
21
+ console.group(`[DEBUG] ${label}`);
22
+ }
23
+ }
24
+ function debugGroupEnd() {
25
+ if (DEBUG_ENABLED) {
26
+ console.groupEnd();
27
+ }
28
+ }
29
+ function debugWarn(...args) {
30
+ if (DEBUG_ENABLED) {
31
+ console.warn("[DEBUG]", ...args);
32
+ }
33
+ }
34
+ function debugError(...args) {
35
+ if (DEBUG_ENABLED) {
36
+ console.error("[DEBUG]", ...args);
37
+ }
38
+ }
39
+ function debugTable(data) {
40
+ if (DEBUG_ENABLED) {
41
+ console.table(data);
42
+ }
43
+ }
44
+ function debugTime(label) {
45
+ if (DEBUG_ENABLED) {
46
+ console.time(`[DEBUG] ${label}`);
47
+ }
48
+ }
49
+ function debugTimeEnd(label) {
50
+ if (DEBUG_ENABLED) {
51
+ console.timeEnd(`[DEBUG] ${label}`);
52
+ }
53
+ }
54
+ function debugInput(inputType, data) {
55
+ if (DEBUG_ENABLED) {
56
+ console.log(`[DEBUG:INPUT] ${inputType}:`, data);
57
+ }
58
+ }
59
+ function debugCollision(entityA, entityB, details) {
60
+ if (DEBUG_ENABLED) {
61
+ console.log(
62
+ `[DEBUG:COLLISION] ${entityA.type || entityA.id} <-> ${entityB.type || entityB.id}`,
63
+ details ?? ""
64
+ );
65
+ }
66
+ }
67
+ function debugPhysics(entityId, physics) {
68
+ if (DEBUG_ENABLED) {
69
+ console.log(`[DEBUG:PHYSICS] ${entityId}:`, physics);
70
+ }
71
+ }
72
+ function debugGameState(stateName, value) {
73
+ if (DEBUG_ENABLED) {
74
+ console.log(`[DEBUG:GAME_STATE] ${stateName}:`, value);
75
+ }
76
+ }
77
+
78
+ // lib/verificationRegistry.ts
79
+ var checks = /* @__PURE__ */ new Map();
80
+ var transitions = [];
81
+ var bridgeHealth = null;
82
+ var MAX_TRANSITIONS = 500;
83
+ var listeners = /* @__PURE__ */ new Set();
84
+ function notifyListeners() {
85
+ listeners.forEach((l) => l());
86
+ exposeOnWindow();
87
+ }
88
+ function registerCheck(id, label, status = "pending", details) {
89
+ checks.set(id, { id, label, status, details, updatedAt: Date.now() });
90
+ notifyListeners();
91
+ }
92
+ function updateCheck(id, status, details) {
93
+ const check = checks.get(id);
94
+ if (check) {
95
+ check.status = status;
96
+ if (details !== void 0) check.details = details;
97
+ check.updatedAt = Date.now();
98
+ } else {
99
+ checks.set(id, { id, label: id, status, details, updatedAt: Date.now() });
100
+ }
101
+ notifyListeners();
102
+ }
103
+ function getAllChecks() {
104
+ return Array.from(checks.values());
105
+ }
106
+ function recordTransition(trace) {
107
+ const entry = {
108
+ ...trace,
109
+ id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
110
+ };
111
+ transitions.push(entry);
112
+ if (transitions.length > MAX_TRANSITIONS) {
113
+ transitions.shift();
114
+ }
115
+ if (entry.event === "INIT") {
116
+ const hasFetch = entry.effects.some((e) => e.type === "fetch");
117
+ const checkId = `init-fetch-${entry.traitName}`;
118
+ if (hasFetch) {
119
+ registerCheck(
120
+ checkId,
121
+ `INIT transition for "${entry.traitName}" has fetch effect`,
122
+ "pass"
123
+ );
124
+ } else {
125
+ const hasRenderUI = entry.effects.some((e) => e.type === "render-ui");
126
+ if (hasRenderUI) {
127
+ registerCheck(
128
+ checkId,
129
+ `INIT transition for "${entry.traitName}" missing fetch effect`,
130
+ "fail",
131
+ "Entity-bound render-ui without a fetch effect will show empty data"
132
+ );
133
+ }
134
+ }
135
+ }
136
+ const failedEffects = entry.effects.filter((e) => e.status === "failed");
137
+ if (failedEffects.length > 0) {
138
+ registerCheck(
139
+ `effects-${entry.id}`,
140
+ `Effects failed in ${entry.traitName}: ${entry.from} -> ${entry.to}`,
141
+ "fail",
142
+ failedEffects.map((e) => `${e.type}: ${e.error}`).join("; ")
143
+ );
144
+ }
145
+ notifyListeners();
146
+ }
147
+ function getTransitions() {
148
+ return [...transitions];
149
+ }
150
+ function getTransitionsForTrait(traitName) {
151
+ return transitions.filter((t) => t.traitName === traitName);
152
+ }
153
+ function updateBridgeHealth(health) {
154
+ bridgeHealth = { ...health };
155
+ const checkId = "server-bridge";
156
+ if (health.connected) {
157
+ registerCheck(checkId, "Server bridge connected", "pass");
158
+ } else {
159
+ registerCheck(
160
+ checkId,
161
+ "Server bridge disconnected",
162
+ "fail",
163
+ health.lastError || "Bridge is not connected"
164
+ );
165
+ }
166
+ notifyListeners();
167
+ }
168
+ function getBridgeHealth() {
169
+ return bridgeHealth ? { ...bridgeHealth } : null;
170
+ }
171
+ function getSummary() {
172
+ const allChecks = getAllChecks();
173
+ return {
174
+ totalChecks: allChecks.length,
175
+ passed: allChecks.filter((c) => c.status === "pass").length,
176
+ failed: allChecks.filter((c) => c.status === "fail").length,
177
+ warnings: allChecks.filter((c) => c.status === "warn").length,
178
+ pending: allChecks.filter((c) => c.status === "pending").length
179
+ };
180
+ }
181
+ function getSnapshot() {
182
+ return {
183
+ checks: getAllChecks(),
184
+ transitions: getTransitions(),
185
+ bridge: getBridgeHealth(),
186
+ summary: getSummary()
187
+ };
188
+ }
189
+ function subscribeToVerification(listener) {
190
+ listeners.add(listener);
191
+ return () => listeners.delete(listener);
192
+ }
193
+ function exposeOnWindow() {
194
+ if (typeof window === "undefined") return;
195
+ if (!window.__orbitalVerification) {
196
+ window.__orbitalVerification = {
197
+ getSnapshot,
198
+ getChecks: getAllChecks,
199
+ getTransitions,
200
+ getBridge: getBridgeHealth,
201
+ getSummary,
202
+ waitForTransition
203
+ };
204
+ }
205
+ }
206
+ function waitForTransition(event, timeoutMs = 1e4) {
207
+ return new Promise((resolve) => {
208
+ const existing = transitions.find((t) => t.event === event);
209
+ if (existing) {
210
+ resolve(existing);
211
+ return;
212
+ }
213
+ const timeout = setTimeout(() => {
214
+ unsub();
215
+ resolve(null);
216
+ }, timeoutMs);
217
+ const unsub = subscribeToVerification(() => {
218
+ const found = transitions.find((t) => t.event === event);
219
+ if (found) {
220
+ clearTimeout(timeout);
221
+ unsub();
222
+ resolve(found);
223
+ }
224
+ });
225
+ });
226
+ }
227
+ function bindEventBus(eventBus) {
228
+ if (typeof window === "undefined") return;
229
+ exposeOnWindow();
230
+ if (window.__orbitalVerification) {
231
+ window.__orbitalVerification.sendEvent = (event, payload) => {
232
+ const prefixed = event.startsWith("UI:") ? event : `UI:${event}`;
233
+ eventBus.emit(prefixed, payload);
234
+ };
235
+ const eventLog = [];
236
+ window.__orbitalVerification.eventLog = eventLog;
237
+ window.__orbitalVerification.clearEventLog = () => {
238
+ eventLog.length = 0;
239
+ };
240
+ if (eventBus.onAny) {
241
+ eventBus.onAny((event) => {
242
+ if (eventLog.length < 200) {
243
+ eventLog.push({
244
+ type: event.type,
245
+ payload: event.payload,
246
+ timestamp: Date.now()
247
+ });
248
+ }
249
+ });
250
+ }
251
+ }
252
+ }
253
+ function bindTraitStateGetter(getter) {
254
+ if (typeof window === "undefined") return;
255
+ exposeOnWindow();
256
+ if (window.__orbitalVerification) {
257
+ window.__orbitalVerification.getTraitState = getter;
258
+ }
259
+ }
260
+ function bindCanvasCapture(captureFn) {
261
+ if (typeof window === "undefined") return;
262
+ exposeOnWindow();
263
+ if (window.__orbitalVerification) {
264
+ window.__orbitalVerification.captureFrame = captureFn;
265
+ }
266
+ }
267
+ function updateAssetStatus(url, status) {
268
+ if (typeof window === "undefined") return;
269
+ exposeOnWindow();
270
+ if (window.__orbitalVerification) {
271
+ if (!window.__orbitalVerification.assetStatus) {
272
+ window.__orbitalVerification.assetStatus = {};
273
+ }
274
+ window.__orbitalVerification.assetStatus[url] = status;
275
+ }
276
+ }
277
+ function clearVerification() {
278
+ checks.clear();
279
+ transitions.length = 0;
280
+ bridgeHealth = null;
281
+ notifyListeners();
282
+ }
283
+ exposeOnWindow();
284
+
285
+ // lib/getNestedValue.ts
286
+ function getNestedValue(obj, path) {
287
+ if (obj === null || obj === void 0 || !path) {
288
+ return void 0;
289
+ }
290
+ if (!path.includes(".")) {
291
+ return obj[path];
292
+ }
293
+ const parts = path.split(".");
294
+ let value = obj;
295
+ for (const part of parts) {
296
+ if (value === null || value === void 0) {
297
+ return void 0;
298
+ }
299
+ if (typeof value !== "object") {
300
+ return void 0;
301
+ }
302
+ value = value[part];
303
+ }
304
+ return value;
305
+ }
306
+ function formatNestedFieldLabel(path) {
307
+ const lastPart = path.includes(".") ? path.split(".").pop() : path;
308
+ return lastPart.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()).replace(/Id$/, "").trim();
309
+ }
310
+
1
311
  // lib/visualizer/index.ts
2
312
  function formatSExprGuardToDomain(guard, _entityName) {
3
313
  if (Array.isArray(guard)) {
@@ -150,9 +460,9 @@ function getEffectSummary(effects) {
150
460
  });
151
461
  return summaries.join(" | ");
152
462
  }
153
- function extractOutputsFromTransitions(transitions) {
463
+ function extractOutputsFromTransitions(transitions2) {
154
464
  const outputs = /* @__PURE__ */ new Set();
155
- transitions.forEach((t) => {
465
+ transitions2.forEach((t) => {
156
466
  if (t.effects) {
157
467
  t.effects.forEach((effect) => {
158
468
  if (Array.isArray(effect)) {
@@ -177,7 +487,7 @@ function getNodeRadius(stateName, config) {
177
487
  if (textLength > 6) return baseRadius + 8;
178
488
  return baseRadius;
179
489
  }
180
- function calculateLayout(states, transitions, options, config) {
490
+ function calculateLayout(states, transitions2, options, config) {
181
491
  const positions = {};
182
492
  const entityBoxWidth = options.hasEntity ? 200 : 0;
183
493
  const outputBoxWidth = options.hasOutputs ? 200 : 0;
@@ -186,7 +496,7 @@ function calculateLayout(states, transitions, options, config) {
186
496
  states.filter((s) => s.isFinal);
187
497
  states.filter((s) => !s.isInitial && !s.isFinal);
188
498
  let maxLabelLength = 0;
189
- transitions.forEach((t) => {
499
+ transitions2.forEach((t) => {
190
500
  if (t.effects && t.effects.length > 0) {
191
501
  const summary = getEffectSummary(t.effects);
192
502
  maxLabelLength = Math.max(maxLabelLength, summary.length);
@@ -212,7 +522,7 @@ function calculateLayout(states, transitions, options, config) {
212
522
  if (stateColumn[name] === void 0) {
213
523
  stateColumn[name] = col;
214
524
  }
215
- transitions.forEach((t) => {
525
+ transitions2.forEach((t) => {
216
526
  if (t.from === name && t.from !== t.to && !visited.has(t.to)) {
217
527
  queue.push({ name: t.to, col: col + 1 });
218
528
  }
@@ -292,11 +602,11 @@ function drawStateSvg(name, x, y, state, config) {
292
602
  svg += `</g>`;
293
603
  return svg;
294
604
  }
295
- function drawTransitionPathSvg(from, to, transitions, positions, config) {
605
+ function drawTransitionPathSvg(from, to, transitions2, positions, config) {
296
606
  const fromPos = positions[from];
297
607
  const toPos = positions[to];
298
608
  if (!fromPos || !toPos) return "";
299
- const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
609
+ const relevantTransitions = transitions2.filter((t) => t.from === from && t.to === to);
300
610
  if (relevantTransitions.length === 0) return "";
301
611
  const fromRadius = getNodeRadius(from, config);
302
612
  const toRadius = getNodeRadius(to, config);
@@ -310,7 +620,7 @@ function drawTransitionPathSvg(from, to, transitions, positions, config) {
310
620
  const startY = fromPos.y + ny * fromRadius;
311
621
  const endX = toPos.x - nx * (toRadius + 5);
312
622
  const endY = toPos.y - ny * (toRadius + 5);
313
- const hasReverse = transitions.some((t) => t.from === to && t.to === from);
623
+ const hasReverse = transitions2.some((t) => t.from === to && t.to === from);
314
624
  const isReverse = hasReverse && from > to;
315
625
  const baseOffset = hasReverse ? 50 : 30;
316
626
  const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 20 : 0);
@@ -319,11 +629,11 @@ function drawTransitionPathSvg(from, to, transitions, positions, config) {
319
629
  const midY = (startY + endY) / 2 + curveOffset * curveDirection;
320
630
  return `<path class="transition-path" data-from="${from}" data-to="${to}" d="M ${startX} ${startY} Q ${midX} ${midY} ${endX} ${endY}" stroke="${config.colors.arrow}" stroke-width="1.5" fill="none" marker-end="url(#arrow)"/>`;
321
631
  }
322
- function drawTransitionLabelsSvg(from, to, transitions, positions, config) {
632
+ function drawTransitionLabelsSvg(from, to, transitions2, positions, config) {
323
633
  const fromPos = positions[from];
324
634
  const toPos = positions[to];
325
635
  if (!fromPos || !toPos) return "";
326
- const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
636
+ const relevantTransitions = transitions2.filter((t) => t.from === from && t.to === to);
327
637
  if (relevantTransitions.length === 0) return "";
328
638
  const fromRadius = getNodeRadius(from, config);
329
639
  const toRadius = getNodeRadius(to, config);
@@ -337,7 +647,7 @@ function drawTransitionLabelsSvg(from, to, transitions, positions, config) {
337
647
  const startY = fromPos.y + ny * fromRadius;
338
648
  const endX = toPos.x - nx * (toRadius + 5);
339
649
  const endY = toPos.y - ny * (toRadius + 5);
340
- const hasReverse = transitions.some((t) => t.from === to && t.to === from);
650
+ const hasReverse = transitions2.some((t) => t.from === to && t.to === from);
341
651
  const isReverse = hasReverse && from > to;
342
652
  const baseOffset = hasReverse ? 50 : 40;
343
653
  const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 25 : 0);
@@ -442,15 +752,15 @@ function drawLegendSvg(y, config) {
442
752
  }
443
753
  function renderStateMachineToSvg(stateMachine, options = {}, config = DEFAULT_CONFIG) {
444
754
  const states = stateMachine.states || [];
445
- const transitions = stateMachine.transitions || [];
755
+ const transitions2 = stateMachine.transitions || [];
446
756
  const title = options.title || "";
447
757
  const entity = options.entity;
448
- const outputs = extractOutputsFromTransitions(transitions);
758
+ const outputs = extractOutputsFromTransitions(transitions2);
449
759
  const layoutOptions = {
450
760
  hasEntity: !!entity,
451
761
  hasOutputs: outputs.length > 0
452
762
  };
453
- const { positions, width, height } = calculateLayout(states, transitions, layoutOptions, config);
763
+ const { positions, width, height } = calculateLayout(states, transitions2, layoutOptions, config);
454
764
  let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height + 40}" viewBox="0 0 ${width} ${height + 40}" class="orbital-state-machine" style="display: block; max-width: none;">`;
455
765
  svg += `<defs>`;
456
766
  svg += createArrowMarkerSvg("arrow", config.colors.arrow, config);
@@ -468,22 +778,22 @@ function renderStateMachineToSvg(stateMachine, options = {}, config = DEFAULT_CO
468
778
  svg += drawEntityInputSvg(entity, 20, height / 2);
469
779
  }
470
780
  const drawnPairs = /* @__PURE__ */ new Set();
471
- transitions.forEach((transition) => {
781
+ transitions2.forEach((transition) => {
472
782
  const pairKey = `${transition.from}->${transition.to}`;
473
783
  if (!drawnPairs.has(pairKey)) {
474
784
  drawnPairs.add(pairKey);
475
- svg += drawTransitionPathSvg(transition.from, transition.to, transitions, positions, config);
785
+ svg += drawTransitionPathSvg(transition.from, transition.to, transitions2, positions, config);
476
786
  }
477
787
  });
478
788
  for (const [name, pos] of Object.entries(positions)) {
479
789
  svg += drawStateSvg(name, pos.x, pos.y, pos.state, config);
480
790
  }
481
791
  drawnPairs.clear();
482
- transitions.forEach((transition) => {
792
+ transitions2.forEach((transition) => {
483
793
  const pairKey = `${transition.from}->${transition.to}`;
484
794
  if (!drawnPairs.has(pairKey)) {
485
795
  drawnPairs.add(pairKey);
486
- svg += drawTransitionLabelsSvg(transition.from, transition.to, transitions, positions, config);
796
+ svg += drawTransitionLabelsSvg(transition.from, transition.to, transitions2, positions, config);
487
797
  }
488
798
  });
489
799
  if (outputs.length > 0) {
@@ -514,11 +824,11 @@ function extractStateMachine(data) {
514
824
  }
515
825
  return null;
516
826
  }
517
- function calculateTransitionPathData(from, to, transitions, positions, config) {
827
+ function calculateTransitionPathData(from, to, transitions2, positions, config) {
518
828
  const fromPos = positions[from];
519
829
  const toPos = positions[to];
520
830
  if (!fromPos || !toPos) return null;
521
- const relevantTransitions = transitions.filter((t) => t.from === from && t.to === to);
831
+ const relevantTransitions = transitions2.filter((t) => t.from === from && t.to === to);
522
832
  if (relevantTransitions.length === 0) return null;
523
833
  const fromRadius = getNodeRadius(from, config);
524
834
  const toRadius = getNodeRadius(to, config);
@@ -549,7 +859,7 @@ function calculateTransitionPathData(from, to, transitions, positions, config) {
549
859
  const startY = fromPos.y + ny * fromRadius;
550
860
  const endX = toPos.x - nx * (toRadius + 5);
551
861
  const endY = toPos.y - ny * (toRadius + 5);
552
- const hasReverse = transitions.some((t) => t.from === to && t.to === from);
862
+ const hasReverse = transitions2.some((t) => t.from === to && t.to === from);
553
863
  const isReverse = hasReverse && from > to;
554
864
  const baseOffset = hasReverse ? 50 : 30;
555
865
  const curveOffset = baseOffset + (relevantTransitions.length > 1 ? 20 : 0);
@@ -564,15 +874,15 @@ function calculateTransitionPathData(from, to, transitions, positions, config) {
564
874
  }
565
875
  function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAULT_CONFIG) {
566
876
  const states = stateMachine.states || [];
567
- const transitions = stateMachine.transitions || [];
877
+ const transitions2 = stateMachine.transitions || [];
568
878
  const title = options.title || "";
569
879
  const entity = options.entity;
570
- const outputs = extractOutputsFromTransitions(transitions);
880
+ const outputs = extractOutputsFromTransitions(transitions2);
571
881
  const layoutOptions = {
572
882
  hasEntity: !!entity,
573
883
  hasOutputs: outputs.length > 0
574
884
  };
575
- const { positions, width, height } = calculateLayout(states, transitions, layoutOptions, config);
885
+ const { positions, width, height } = calculateLayout(states, transitions2, layoutOptions, config);
576
886
  const domStates = Object.entries(positions).map(([name, pos]) => ({
577
887
  id: `state-${name}`,
578
888
  name,
@@ -586,14 +896,14 @@ function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAUL
586
896
  const domPaths = [];
587
897
  const domLabels = [];
588
898
  const drawnPairs = /* @__PURE__ */ new Set();
589
- transitions.forEach((transition, idx) => {
899
+ transitions2.forEach((transition, idx) => {
590
900
  const pairKey = `${transition.from}->${transition.to}`;
591
901
  if (!drawnPairs.has(pairKey)) {
592
902
  drawnPairs.add(pairKey);
593
903
  const pathData2 = calculateTransitionPathData(
594
904
  transition.from,
595
905
  transition.to,
596
- transitions,
906
+ transitions2,
597
907
  positions,
598
908
  config
599
909
  );
@@ -614,7 +924,7 @@ function renderStateMachineToDomData(stateMachine, options = {}, config = DEFAUL
614
924
  const pathData = calculateTransitionPathData(
615
925
  transition.from,
616
926
  transition.to,
617
- transitions,
927
+ transitions2,
618
928
  positions,
619
929
  config
620
930
  );
@@ -744,15 +1054,62 @@ function parseContentSegments(content) {
744
1054
  return segments;
745
1055
  }
746
1056
 
1057
+ // lib/traitRegistry.ts
1058
+ var traits = /* @__PURE__ */ new Map();
1059
+ var listeners2 = /* @__PURE__ */ new Set();
1060
+ function notifyListeners2() {
1061
+ listeners2.forEach((listener) => listener());
1062
+ }
1063
+ function registerTrait(info) {
1064
+ traits.set(info.id, info);
1065
+ notifyListeners2();
1066
+ }
1067
+ function updateTraitState(id, newState) {
1068
+ const trait = traits.get(id);
1069
+ if (trait) {
1070
+ trait.currentState = newState;
1071
+ trait.transitionCount++;
1072
+ notifyListeners2();
1073
+ }
1074
+ }
1075
+ function updateGuardResult(traitId, guardName, result) {
1076
+ const trait = traits.get(traitId);
1077
+ if (trait) {
1078
+ const guard = trait.guards.find((g) => g.name === guardName);
1079
+ if (guard) {
1080
+ guard.lastResult = result;
1081
+ notifyListeners2();
1082
+ }
1083
+ }
1084
+ }
1085
+ function unregisterTrait(id) {
1086
+ traits.delete(id);
1087
+ notifyListeners2();
1088
+ }
1089
+ function getAllTraits() {
1090
+ return Array.from(traits.values());
1091
+ }
1092
+ function getTrait(id) {
1093
+ return traits.get(id);
1094
+ }
1095
+ function subscribeToTraitChanges(listener) {
1096
+ listeners2.add(listener);
1097
+ return () => listeners2.delete(listener);
1098
+ }
1099
+ function clearTraits() {
1100
+ traits.clear();
1101
+ notifyListeners2();
1102
+ }
1103
+
747
1104
  // lib/tickRegistry.ts
748
1105
  var ticks = /* @__PURE__ */ new Map();
749
- var listeners = /* @__PURE__ */ new Set();
750
- function notifyListeners() {
751
- listeners.forEach((listener) => listener());
1106
+ var listeners3 = /* @__PURE__ */ new Set();
1107
+ function notifyListeners3() {
1108
+ listeners3.forEach((listener) => listener());
752
1109
  }
753
1110
  function registerTick(tick) {
754
1111
  ticks.set(tick.id, tick);
755
- notifyListeners();
1112
+ notifyListeners3();
756
1113
  }
757
1114
  function updateTickExecution(id, timestamp) {
758
1115
  const tick = ticks.get(id);
@@ -760,19 +1117,19 @@ function updateTickExecution(id, timestamp) {
760
1117
  tick.lastExecuted = timestamp;
761
1118
  tick.nextExecution = timestamp + tick.interval;
762
1119
  tick.executionCount++;
763
- notifyListeners();
1120
+ notifyListeners3();
764
1121
  }
765
1122
  }
766
1123
  function setTickActive(id, isActive) {
767
1124
  const tick = ticks.get(id);
768
1125
  if (tick) {
769
1126
  tick.isActive = isActive;
770
- notifyListeners();
1127
+ notifyListeners3();
771
1128
  }
772
1129
  }
773
1130
  function unregisterTick(id) {
774
1131
  ticks.delete(id);
775
- notifyListeners();
1132
+ notifyListeners3();
776
1133
  }
777
1134
  function getAllTicks() {
778
1135
  return Array.from(ticks.values());
@@ -781,20 +1138,20 @@ function getTick(id) {
781
1138
  return ticks.get(id);
782
1139
  }
783
1140
  function subscribeToTickChanges(listener) {
784
- listeners.add(listener);
785
- return () => listeners.delete(listener);
1141
+ listeners3.add(listener);
1142
+ return () => listeners3.delete(listener);
786
1143
  }
787
1144
  function clearTicks() {
788
1145
  ticks.clear();
789
- notifyListeners();
1146
+ notifyListeners3();
790
1147
  }
791
1148
 
792
1149
  // lib/guardRegistry.ts
793
1150
  var guardHistory = [];
794
- var listeners2 = /* @__PURE__ */ new Set();
1151
+ var listeners4 = /* @__PURE__ */ new Set();
795
1152
  var MAX_HISTORY = 100;
796
- function notifyListeners2() {
797
- listeners2.forEach((listener) => listener());
1153
+ function notifyListeners4() {
1154
+ listeners4.forEach((listener) => listener());
798
1155
  }
799
1156
  function recordGuardEvaluation(evaluation) {
800
1157
  const entry = {
@@ -806,7 +1163,7 @@ function recordGuardEvaluation(evaluation) {
806
1163
  if (guardHistory.length > MAX_HISTORY) {
807
1164
  guardHistory.pop();
808
1165
  }
809
- notifyListeners2();
1166
+ notifyListeners4();
810
1167
  }
811
1168
  function getGuardHistory() {
812
1169
  return [...guardHistory];
@@ -818,12 +1175,12 @@ function getGuardEvaluationsForTrait(traitName) {
818
1175
  return guardHistory.filter((g) => g.traitName === traitName);
819
1176
  }
820
1177
  function subscribeToGuardChanges(listener) {
821
- listeners2.add(listener);
822
- return () => listeners2.delete(listener);
1178
+ listeners4.add(listener);
1179
+ return () => listeners4.delete(listener);
823
1180
  }
824
1181
  function clearGuardHistory() {
825
1182
  guardHistory.length = 0;
826
- notifyListeners2();
1183
+ notifyListeners4();
827
1184
  }
828
1185
 
829
1186
  // lib/entityDebug.ts
@@ -863,10 +1220,10 @@ function getEntitiesByType(type) {
863
1220
 
864
1221
  // lib/debugRegistry.ts
865
1222
  var events = [];
866
- var listeners3 = /* @__PURE__ */ new Set();
1223
+ var listeners5 = /* @__PURE__ */ new Set();
867
1224
  var MAX_EVENTS = 500;
868
- function notifyListeners3() {
869
- listeners3.forEach((listener) => listener());
1225
+ function notifyListeners5() {
1226
+ listeners5.forEach((listener) => listener());
870
1227
  }
871
1228
  function logDebugEvent(type, source, message, data) {
872
1229
  const event = {
@@ -881,7 +1238,7 @@ function logDebugEvent(type, source, message, data) {
881
1238
  if (events.length > MAX_EVENTS) {
882
1239
  events.pop();
883
1240
  }
884
- notifyListeners3();
1241
+ notifyListeners5();
885
1242
  }
886
1243
  function logStateChange(source, from, to, event) {
887
1244
  logDebugEvent("state-change", source, `${from} \u2192 ${to}`, { from, to, event });
@@ -914,34 +1271,34 @@ function getEventsBySource(source) {
914
1271
  return events.filter((e) => e.source === source);
915
1272
  }
916
1273
  function subscribeToDebugEvents(listener) {
917
- listeners3.add(listener);
918
- return () => listeners3.delete(listener);
1274
+ listeners5.add(listener);
1275
+ return () => listeners5.delete(listener);
919
1276
  }
920
1277
  function clearDebugEvents() {
921
1278
  events.length = 0;
922
- notifyListeners3();
1279
+ notifyListeners5();
923
1280
  }
924
1281
 
925
1282
  // lib/debugUtils.ts
926
1283
  var DEBUG_STORAGE_KEY = "orbital-debug";
927
- var listeners4 = /* @__PURE__ */ new Set();
928
- function isDebugEnabled() {
1284
+ var listeners6 = /* @__PURE__ */ new Set();
1285
+ function isDebugEnabled2() {
929
1286
  if (typeof window === "undefined") return false;
930
1287
  return localStorage.getItem(DEBUG_STORAGE_KEY) === "true";
931
1288
  }
932
1289
  function setDebugEnabled(enabled) {
933
1290
  if (typeof window === "undefined") return;
934
1291
  localStorage.setItem(DEBUG_STORAGE_KEY, String(enabled));
935
- listeners4.forEach((listener) => listener(enabled));
1292
+ listeners6.forEach((listener) => listener(enabled));
936
1293
  }
937
1294
  function toggleDebug() {
938
- const newValue = !isDebugEnabled();
1295
+ const newValue = !isDebugEnabled2();
939
1296
  setDebugEnabled(newValue);
940
1297
  return newValue;
941
1298
  }
942
1299
  function onDebugToggle(listener) {
943
- listeners4.add(listener);
944
- return () => listeners4.delete(listener);
1300
+ listeners6.add(listener);
1301
+ return () => listeners6.delete(listener);
945
1302
  }
946
1303
  function initDebugShortcut() {
947
1304
  if (typeof window === "undefined") return () => {
@@ -956,4 +1313,4 @@ function initDebugShortcut() {
956
1313
  return () => window.removeEventListener("keydown", handleKeyDown);
957
1314
  }
958
1315
 
959
- export { DEFAULT_CONFIG, clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, extractOutputsFromTransitions, extractStateMachine, formatGuard, getAllTicks, getDebugEvents, getEffectSummary, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getRecentEvents, getRecentGuardEvaluations, getTick, initDebugShortcut, isDebugEnabled, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, onDebugToggle, parseContentSegments, parseMarkdownWithCodeBlocks, recordGuardEvaluation, registerTick, renderStateMachineToDomData, renderStateMachineToSvg, setDebugEnabled, setEntityProvider, setTickActive, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, toggleDebug, unregisterTick, updateTickExecution };
1316
+ export { DEFAULT_CONFIG, bindCanvasCapture, bindEventBus, bindTraitStateGetter, clearDebugEvents, clearEntityProvider, clearGuardHistory, clearTicks, clearTraits, clearVerification, cn, debug, debugCollision, debugError, debugGameState, debugGroup, debugGroupEnd, debugInput, debugPhysics, debugTable, debugTime, debugTimeEnd, debugWarn, extractOutputsFromTransitions, extractStateMachine, formatGuard, formatNestedFieldLabel, getAllChecks, getAllTicks, getAllTraits, getBridgeHealth, getDebugEvents, getEffectSummary, getEntitiesByType, getEntityById, getEntitySnapshot, getEventsBySource, getEventsByType, getGuardEvaluationsForTrait, getGuardHistory, getNestedValue, getRecentEvents, getRecentGuardEvaluations, getSnapshot, getSummary, getTick, getTrait, getTransitions, getTransitionsForTrait, initDebugShortcut, isDebugEnabled, isDebugEnabled2, logDebugEvent, logEffectExecuted, logError, logEventFired, logInfo, logStateChange, logWarning, onDebugToggle, parseContentSegments, parseMarkdownWithCodeBlocks, recordGuardEvaluation, recordTransition, registerCheck, registerTick, registerTrait, renderStateMachineToDomData, renderStateMachineToSvg, setDebugEnabled, setEntityProvider, setTickActive, subscribeToDebugEvents, subscribeToGuardChanges, subscribeToTickChanges, subscribeToTraitChanges, subscribeToVerification, toggleDebug, unregisterTick, unregisterTrait, updateAssetStatus, updateBridgeHealth, updateCheck, updateGuardResult, updateTickExecution, updateTraitState, waitForTransition };