@almadar/ui 4.44.0 → 4.45.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.
package/dist/avl/index.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { OrbitControls as OrbitControls$1, Grid as Grid$1, Stars, Sparkles, Html, RoundedBox } from '@react-three/drei';
3
3
  import * as React147 from 'react';
4
4
  import React147__default, { createContext, useState, useEffect, useMemo, useContext, useRef, useCallback, Suspense, useLayoutEffect, useReducer, lazy, useId, forwardRef, useImperativeHandle, Component } from 'react';
5
- import { createLogger } from '@almadar/logger';
5
+ import { createLogger, isLogLevelEnabled } from '@almadar/logger';
6
6
  import ELK from 'elkjs/lib/elk.bundled.js';
7
7
  import { MarkerType, Handle, Position, getBezierPath, EdgeLabelRenderer, BaseEdge, ReactFlowProvider, useNodesState, useEdgesState, useReactFlow, ReactFlow, Controls, Background, BackgroundVariant } from '@xyflow/react';
8
8
  import * as LucideIcons from 'lucide-react';
@@ -3302,24 +3302,24 @@ function captureSubscriberTag(listener) {
3302
3302
  }
3303
3303
  return "unknown";
3304
3304
  }
3305
- function EventBusProvider({ children, debug: debug2 = false }) {
3305
+ function EventBusProvider({ children }) {
3306
3306
  const listenersRef = useRef(/* @__PURE__ */ new Map());
3307
3307
  const anyListenersRef = useRef(/* @__PURE__ */ new Set());
3308
3308
  const deprecationWarningShown = useRef(false);
3309
3309
  const getSelectedEntity = useCallback(() => {
3310
3310
  if (!deprecationWarningShown.current) {
3311
- console.warn(
3312
- "[EventBus] getSelectedEntity is deprecated. Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
3313
- );
3311
+ busLog.warn("deprecated:getSelectedEntity", {
3312
+ migration: "Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
3313
+ });
3314
3314
  deprecationWarningShown.current = true;
3315
3315
  }
3316
3316
  return null;
3317
3317
  }, []);
3318
3318
  const clearSelectedEntity = useCallback(() => {
3319
3319
  if (!deprecationWarningShown.current) {
3320
- console.warn(
3321
- "[EventBus] clearSelectedEntity is deprecated. Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
3322
- );
3320
+ busLog.warn("deprecated:clearSelectedEntity", {
3321
+ migration: "Use SelectionProvider and useSelection hook instead. See SelectionProvider.tsx for migration guide."
3322
+ });
3323
3323
  deprecationWarningShown.current = true;
3324
3324
  }
3325
3325
  }, []);
@@ -3333,12 +3333,8 @@ function EventBusProvider({ children, debug: debug2 = false }) {
3333
3333
  const listeners6 = listenersRef.current.get(type);
3334
3334
  const listenerCount = (listeners6?.size ?? 0) + anyListenersRef.current.size;
3335
3335
  busLog.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount });
3336
- if (debug2) {
3337
- if (listenerCount > 0) {
3338
- console.log(`[EventBus] Emit: ${type} \u2192 ${listenerCount} listener(s)`, payload);
3339
- } else {
3340
- console.warn(`[EventBus] Emit: ${type} (NO LISTENERS - event may be lost!)`, payload);
3341
- }
3336
+ if (listenerCount === 0) {
3337
+ busLog.warn("emit:no-listeners", { type });
3342
3338
  }
3343
3339
  if (listeners6) {
3344
3340
  const listenersCopy = Array.from(listeners6);
@@ -3353,7 +3349,7 @@ function EventBusProvider({ children, debug: debug2 = false }) {
3353
3349
  try {
3354
3350
  listener(event);
3355
3351
  } catch (error) {
3356
- console.error(`[EventBus] Error in listener for '${type}':`, error);
3352
+ busLog.error("listener-threw", { type, error: error instanceof Error ? error : String(error) });
3357
3353
  }
3358
3354
  }
3359
3355
  }
@@ -3369,10 +3365,10 @@ function EventBusProvider({ children, debug: debug2 = false }) {
3369
3365
  try {
3370
3366
  listener(event);
3371
3367
  } catch (error) {
3372
- console.error(`[EventBus] Error in onAny listener for '${type}':`, error);
3368
+ busLog.error("onAny-listener-threw", { type, error: error instanceof Error ? error : String(error) });
3373
3369
  }
3374
3370
  }
3375
- }, [debug2]);
3371
+ }, []);
3376
3372
  const on = useCallback((type, listener) => {
3377
3373
  if (!listenersRef.current.has(type)) {
3378
3374
  listenersRef.current.set(type, /* @__PURE__ */ new Set());
@@ -3381,19 +3377,14 @@ function EventBusProvider({ children, debug: debug2 = false }) {
3381
3377
  listeners6.add(listener);
3382
3378
  if (!listenerTags.has(listener)) listenerTags.set(listener, captureSubscriberTag(listener));
3383
3379
  subLog.debug("subscribe", { type, totalListeners: listeners6.size, tag: listenerTags.get(listener) });
3384
- if (debug2) {
3385
- console.log(`[EventBus] Subscribed to '${type}', total: ${listeners6.size}`);
3386
- }
3387
3380
  return () => {
3388
3381
  listeners6.delete(listener);
3389
- if (debug2) {
3390
- console.log(`[EventBus] Unsubscribed from '${type}', remaining: ${listeners6.size}`);
3391
- }
3382
+ subLog.debug("unsubscribe", { type, remaining: listeners6.size });
3392
3383
  if (listeners6.size === 0) {
3393
3384
  listenersRef.current.delete(type);
3394
3385
  }
3395
3386
  };
3396
- }, [debug2]);
3387
+ }, []);
3397
3388
  const once = useCallback((type, listener) => {
3398
3389
  const wrappedListener = (event) => {
3399
3390
  listenersRef.current.get(type)?.delete(wrappedListener);
@@ -3409,16 +3400,11 @@ function EventBusProvider({ children, debug: debug2 = false }) {
3409
3400
  anyListenersRef.current.add(listener);
3410
3401
  if (!listenerTags.has(listener)) listenerTags.set(listener, captureSubscriberTag(listener));
3411
3402
  subLog.debug("subscribe:any", { totalAnyListeners: anyListenersRef.current.size, tag: listenerTags.get(listener) });
3412
- if (debug2) {
3413
- console.log(`[EventBus] onAny subscribed, total: ${anyListenersRef.current.size}`);
3414
- }
3415
3403
  return () => {
3416
3404
  anyListenersRef.current.delete(listener);
3417
- if (debug2) {
3418
- console.log(`[EventBus] onAny unsubscribed, remaining: ${anyListenersRef.current.size}`);
3419
- }
3405
+ subLog.debug("unsubscribe:any", { remaining: anyListenersRef.current.size });
3420
3406
  };
3421
- }, [debug2]);
3407
+ }, []);
3422
3408
  const contextValue = useMemo(
3423
3409
  () => ({
3424
3410
  emit,
@@ -3578,7 +3564,7 @@ var init_useEventBus = __esm({
3578
3564
  try {
3579
3565
  handler(event);
3580
3566
  } catch (error) {
3581
- console.error(`[EventBus] Error in listener for '${type}':`, error);
3567
+ log.error("Error in listener", { type, error: error instanceof Error ? error : String(error) });
3582
3568
  }
3583
3569
  });
3584
3570
  }
@@ -3586,7 +3572,7 @@ var init_useEventBus = __esm({
3586
3572
  try {
3587
3573
  handler(event);
3588
3574
  } catch (error) {
3589
- console.error(`[EventBus] Error in onAny listener for '${type}':`, error);
3575
+ log.error("Error in onAny listener", { type, error: error instanceof Error ? error : String(error) });
3590
3576
  }
3591
3577
  });
3592
3578
  },
@@ -4898,7 +4884,7 @@ var init_ModuleCard = __esm({
4898
4884
  ModuleCard.displayName = "ModuleCard";
4899
4885
  }
4900
4886
  });
4901
- var SWIM_GUTTER, CENTER_W, BehaviorView;
4887
+ var log2, SWIM_GUTTER, CENTER_W, BehaviorView;
4902
4888
  var init_BehaviorView = __esm({
4903
4889
  "components/molecules/avl/BehaviorView.tsx"() {
4904
4890
  "use client";
@@ -4907,6 +4893,7 @@ var init_BehaviorView = __esm({
4907
4893
  init_AvlSwimLane();
4908
4894
  init_types();
4909
4895
  init_avl_elk_layout();
4896
+ log2 = createLogger("almadar:ui:avl:behavior-view");
4910
4897
  SWIM_GUTTER = 120;
4911
4898
  CENTER_W = 360;
4912
4899
  BehaviorView = ({ data }) => {
@@ -4916,7 +4903,7 @@ var init_BehaviorView = __esm({
4916
4903
  const dataKey = useMemo(() => JSON.stringify(traitData), [traitData]);
4917
4904
  useEffect(() => {
4918
4905
  if (!traitData) return;
4919
- computeTraitLayout(traitData).then(setLayout).catch(console.error);
4906
+ computeTraitLayout(traitData).then(setLayout).catch((err) => log2.error("compute-trait-layout-failed", { error: err instanceof Error ? err : String(err) }));
4920
4907
  }, [dataKey]);
4921
4908
  if (!traitData) {
4922
4909
  return /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-[var(--color-border)] bg-[var(--color-card)] p-4 text-center text-[var(--color-muted-foreground)] text-sm", children: "No trait data" });
@@ -5042,10 +5029,11 @@ function useTheme() {
5042
5029
  }
5043
5030
  return context;
5044
5031
  }
5045
- var BUILT_IN_THEMES, ThemeContext, THEME_STORAGE_KEY, MODE_STORAGE_KEY, ThemeProvider;
5032
+ var log3, BUILT_IN_THEMES, ThemeContext, THEME_STORAGE_KEY, MODE_STORAGE_KEY, ThemeProvider;
5046
5033
  var init_ThemeContext = __esm({
5047
5034
  "context/ThemeContext.tsx"() {
5048
5035
  "use client";
5036
+ log3 = createLogger("almadar:ui:theme");
5049
5037
  BUILT_IN_THEMES = [
5050
5038
  {
5051
5039
  name: "wireframe",
@@ -5225,9 +5213,10 @@ var init_ThemeContext = __esm({
5225
5213
  localStorage.setItem(THEME_STORAGE_KEY, newTheme);
5226
5214
  }
5227
5215
  } else {
5228
- console.warn(
5229
- `Theme "${newTheme}" not found. Available: ${availableThemes.map((t) => t.name).join(", ")}`
5230
- );
5216
+ log3.warn("Theme not found", {
5217
+ theme: newTheme,
5218
+ available: availableThemes.map((t) => t.name)
5219
+ });
5231
5220
  }
5232
5221
  },
5233
5222
  [availableThemes]
@@ -5363,7 +5352,7 @@ function useUISlotManager() {
5363
5352
  try {
5364
5353
  callback(slot, content);
5365
5354
  } catch (error) {
5366
- console.error("[UISlots] Subscriber error:", error);
5355
+ log5.error("Subscriber error", { error: error instanceof Error ? error : String(error) });
5367
5356
  }
5368
5357
  });
5369
5358
  }, []);
@@ -5375,7 +5364,7 @@ function useUISlotManager() {
5375
5364
  try {
5376
5365
  callback(content);
5377
5366
  } catch (error) {
5378
- console.error(`[UISlots] Trait subscriber error (${traitName}):`, error);
5367
+ log5.error("Trait subscriber error", { traitName, error: error instanceof Error ? error : String(error) });
5379
5368
  }
5380
5369
  });
5381
5370
  },
@@ -5426,9 +5415,12 @@ function useUISlotManager() {
5426
5415
  const slotSources = prev[config.target] ?? {};
5427
5416
  const existing = slotSources[sourceKey];
5428
5417
  if (existing && existing.priority > content.priority) {
5429
- console.warn(
5430
- `[UISlots] Slot "${config.target}" source "${sourceKey}" already has higher priority content (${existing.priority} > ${content.priority})`
5431
- );
5418
+ log5.warn("Slot already has higher priority content", {
5419
+ slot: config.target,
5420
+ sourceKey,
5421
+ existingPriority: existing.priority,
5422
+ newPriority: content.priority
5423
+ });
5432
5424
  return prev;
5433
5425
  }
5434
5426
  const nextSources = {
@@ -5440,7 +5432,7 @@ function useUISlotManager() {
5440
5432
  indexTraitRender(content.sourceTrait, content);
5441
5433
  notifyTraitSubscribers(content.sourceTrait, content);
5442
5434
  }
5443
- slotLog.info("slot:written", {
5435
+ log5.info("slot:written", {
5444
5436
  slot: config.target,
5445
5437
  sourceKey,
5446
5438
  sourceTrait: content.sourceTrait,
@@ -5485,7 +5477,7 @@ function useUISlotManager() {
5485
5477
  setSources((prev) => {
5486
5478
  const slotSources = prev[slot];
5487
5479
  if (!slotSources || !(sourceKey in slotSources)) {
5488
- slotLog.debug("slot:clear-noop", { slot, sourceTrait, reason: !slotSources ? "no-slot" : "no-source" });
5480
+ log5.debug("slot:clear-noop", { slot, sourceTrait, reason: !slotSources ? "no-slot" : "no-source" });
5489
5481
  return prev;
5490
5482
  }
5491
5483
  const content = slotSources[sourceKey];
@@ -5501,7 +5493,7 @@ function useUISlotManager() {
5501
5493
  }
5502
5494
  const nextSources = { ...slotSources };
5503
5495
  delete nextSources[sourceKey];
5504
- slotLog.info("slot:cleared", { slot, sourceTrait, lastPatternType: content.pattern });
5496
+ log5.info("slot:cleared", { slot, sourceTrait, lastPatternType: content.pattern });
5505
5497
  notifySubscribers(slot, aggregateSlot(nextSources));
5506
5498
  return { ...prev, [slot]: nextSources };
5507
5499
  });
@@ -5620,11 +5612,11 @@ function useUISlotManager() {
5620
5612
  updateTraitContent
5621
5613
  };
5622
5614
  }
5623
- var slotLog, DEFAULT_SOURCE_KEY, MULTI_SOURCE_STACK_TRAIT, ALL_SLOTS, DEFAULT_SLOTS, DEFAULT_SOURCES, idCounter;
5615
+ var log5, DEFAULT_SOURCE_KEY, MULTI_SOURCE_STACK_TRAIT, ALL_SLOTS, DEFAULT_SLOTS, DEFAULT_SOURCES, idCounter;
5624
5616
  var init_useUISlots = __esm({
5625
5617
  "hooks/useUISlots.ts"() {
5626
5618
  "use client";
5627
- slotLog = createLogger("almadar:ui:useUISlots");
5619
+ log5 = createLogger("almadar:ui:ui-slots");
5628
5620
  DEFAULT_SOURCE_KEY = "__default__";
5629
5621
  MULTI_SOURCE_STACK_TRAIT = "__multi_source_stack__";
5630
5622
  ALL_SLOTS = [
@@ -6528,10 +6520,10 @@ function refId(obj) {
6528
6520
  refIds.set(obj, id);
6529
6521
  return id;
6530
6522
  }
6531
- var slotLog2, refIds, nextRefId;
6523
+ var slotLog, refIds, nextRefId;
6532
6524
  var init_slot_types = __esm({
6533
6525
  "runtime/ui/slot-types.ts"() {
6534
- slotLog2 = createLogger("almadar:ui:slot-render");
6526
+ slotLog = createLogger("almadar:ui:slot-render");
6535
6527
  refIds = /* @__PURE__ */ new WeakMap();
6536
6528
  nextRefId = 1;
6537
6529
  }
@@ -12176,6 +12168,7 @@ function getAllPages(schema) {
12176
12168
  var init_navigation = __esm({
12177
12169
  "renderer/navigation.tsx"() {
12178
12170
  "use client";
12171
+ createLogger("almadar:ui:navigation");
12179
12172
  createContext(null);
12180
12173
  }
12181
12174
  });
@@ -14653,7 +14646,7 @@ function recordTransition(trace) {
14653
14646
  ...trace,
14654
14647
  id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
14655
14648
  };
14656
- log2.info("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
14649
+ log7.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
14657
14650
  getState().transitions.push(entry);
14658
14651
  if (getState().transitions.length > MAX_TRANSITIONS) {
14659
14652
  getState().transitions.shift();
@@ -14752,7 +14745,7 @@ function getTraitSnapshots() {
14752
14745
  try {
14753
14746
  snapshots.push(getter());
14754
14747
  } catch (err) {
14755
- log2.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
14748
+ log7.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
14756
14749
  }
14757
14750
  }
14758
14751
  return snapshots;
@@ -14800,12 +14793,12 @@ function waitForTransition(event, timeoutMs = 1e4) {
14800
14793
  }
14801
14794
  function bindEventBus(eventBus) {
14802
14795
  if (typeof window === "undefined") return;
14803
- log2.info("bindEventBus", { hasOnAny: !!eventBus.onAny });
14796
+ log7.info("bindEventBus", { hasOnAny: !!eventBus.onAny });
14804
14797
  exposeOnWindow();
14805
14798
  if (window.__orbitalVerification) {
14806
14799
  window.__orbitalVerification.sendEvent = (event, payload, traitScope) => {
14807
14800
  const prefixed = event.startsWith("UI:") ? event : traitScope ? `UI:${traitScope}.${event}` : `UI:${event}`;
14808
- log2.debug("sendEvent", { event: prefixed, traitScope, payloadKeys: payload ? Object.keys(payload) : [] });
14801
+ log7.debug("sendEvent", { event: prefixed, traitScope, payloadKeys: payload ? Object.keys(payload) : [] });
14809
14802
  eventBus.emit(prefixed, payload);
14810
14803
  };
14811
14804
  const eventLog = [];
@@ -14868,10 +14861,10 @@ function updateAssetStatus(url, status) {
14868
14861
  window.__orbitalVerification.assetStatus[url] = status;
14869
14862
  }
14870
14863
  }
14871
- var log2, MAX_TRANSITIONS;
14864
+ var log7, MAX_TRANSITIONS;
14872
14865
  var init_verificationRegistry = __esm({
14873
14866
  "lib/verificationRegistry.ts"() {
14874
- log2 = createLogger("almadar:bridge");
14867
+ log7 = createLogger("almadar:bridge");
14875
14868
  MAX_TRANSITIONS = 500;
14876
14869
  exposeOnWindow();
14877
14870
  }
@@ -16432,7 +16425,7 @@ function computeFoldRegions(code) {
16432
16425
  }
16433
16426
  return regions.sort((a, b) => a.start - b.start);
16434
16427
  }
16435
- var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
16428
+ var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, log8, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
16436
16429
  var init_CodeBlock = __esm({
16437
16430
  "components/molecules/markdown/CodeBlock.tsx"() {
16438
16431
  init_Box();
@@ -16509,6 +16502,7 @@ var init_CodeBlock = __esm({
16509
16502
  "lolo-op-async": { color: ORB_COLORS.dark.async }
16510
16503
  };
16511
16504
  loloStyle = { ...dark, ...loloStyleOverrides };
16505
+ log8 = createLogger("almadar:ui:markdown-code");
16512
16506
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
16513
16507
  HIDDEN_LINE_NUMBERS = { display: "none" };
16514
16508
  CodeBlock = React147__default.memo(
@@ -16707,7 +16701,7 @@ var init_CodeBlock = __esm({
16707
16701
  eventBus.emit("UI:COPY_CODE", { language, success: true });
16708
16702
  setTimeout(() => setCopied(false), 2e3);
16709
16703
  } catch (err) {
16710
- console.error("Failed to copy code:", err);
16704
+ log8.error("Failed to copy code", { error: err instanceof Error ? err : String(err) });
16711
16705
  eventBus.emit("UI:COPY_CODE", { language, success: false });
16712
16706
  }
16713
16707
  };
@@ -20269,13 +20263,14 @@ function useSafeEventBus2() {
20269
20263
  } };
20270
20264
  }
20271
20265
  }
20272
- var ButtonGroup;
20266
+ var log9, ButtonGroup;
20273
20267
  var init_ButtonGroup = __esm({
20274
20268
  "components/molecules/ButtonGroup.tsx"() {
20275
20269
  "use client";
20276
20270
  init_cn();
20277
20271
  init_atoms();
20278
20272
  init_useEventBus();
20273
+ log9 = createLogger("almadar:ui:button-group");
20279
20274
  ButtonGroup = ({
20280
20275
  children,
20281
20276
  primary,
@@ -20348,7 +20343,7 @@ var init_ButtonGroup = __esm({
20348
20343
  {
20349
20344
  variant: "ghost",
20350
20345
  onClick: () => {
20351
- console.log(`Filter clicked: ${filter.field}`);
20346
+ log9.debug("Filter clicked", { field: filter.field });
20352
20347
  },
20353
20348
  children: filter.label
20354
20349
  },
@@ -26365,31 +26360,56 @@ var init_InputGroup = __esm({
26365
26360
  InputGroup.displayName = "InputGroup";
26366
26361
  }
26367
26362
  });
26368
-
26369
- // lib/debug.ts
26363
+ function gateEnabled(level, ns = NAMESPACE) {
26364
+ return isLogLevelEnabled(level, ns);
26365
+ }
26370
26366
  function isDebugEnabled() {
26371
- if (DEBUG_ENABLED) return true;
26372
- return typeof window !== "undefined" && window.__ALMADAR_DEBUG_VERIFY__ === true;
26367
+ return gateEnabled("DEBUG");
26373
26368
  }
26374
26369
  function debug(...args) {
26375
- if (isDebugEnabled()) {
26376
- console.log("[DEBUG]", ...args);
26370
+ if (!gateEnabled("DEBUG")) return;
26371
+ const [first, ...rest] = args;
26372
+ const message = typeof first === "string" ? first : "<debug>";
26373
+ if (rest.length === 0 && typeof first === "string") {
26374
+ log10.debug(message);
26375
+ } else {
26376
+ log10.debug(message, { args: rest.length > 0 ? formatArgs(rest) : formatArgs([first]) });
26377
26377
  }
26378
26378
  }
26379
26379
  function debugGroup(label) {
26380
- if (isDebugEnabled()) {
26381
- console.group(`[DEBUG] ${label}`);
26382
- }
26380
+ if (gateEnabled("DEBUG")) console.group(`[${NAMESPACE}] ${label}`);
26383
26381
  }
26384
26382
  function debugGroupEnd() {
26385
- if (isDebugEnabled()) {
26386
- console.groupEnd();
26383
+ if (gateEnabled("DEBUG")) console.groupEnd();
26384
+ }
26385
+ function formatArgs(values) {
26386
+ if (values.length === 1) return toLogMetaValue(values[0]);
26387
+ return values.map(toLogMetaValue);
26388
+ }
26389
+ function toLogMetaValue(v) {
26390
+ if (v === null || v === void 0) return v;
26391
+ if (v instanceof Error) return v;
26392
+ const t = typeof v;
26393
+ if (t === "string" || t === "number" || t === "boolean") return v;
26394
+ if (Array.isArray(v)) return v.map(toLogMetaValue);
26395
+ if (t === "object") {
26396
+ const out = {};
26397
+ for (const [k, val] of Object.entries(v)) {
26398
+ out[k] = toLogMetaValue(val);
26399
+ }
26400
+ return out;
26387
26401
  }
26402
+ return String(v);
26388
26403
  }
26389
- var DEBUG_ENABLED;
26404
+ var NAMESPACE, log10;
26390
26405
  var init_debug = __esm({
26391
26406
  "lib/debug.ts"() {
26392
- DEBUG_ENABLED = typeof window !== "undefined" && (localStorage.getItem("debug") === "true" || process.env.NODE_ENV === "development");
26407
+ NAMESPACE = "almadar:ui:debug";
26408
+ log10 = createLogger(NAMESPACE);
26409
+ createLogger("almadar:ui:debug:input");
26410
+ createLogger("almadar:ui:debug:collision");
26411
+ createLogger("almadar:ui:debug:physics");
26412
+ createLogger("almadar:ui:debug:game-state");
26393
26413
  }
26394
26414
  });
26395
26415
  var isRelationsDebugEnabled, RelationSelect;
@@ -42362,7 +42382,7 @@ function getAllEvents(traits2) {
42362
42382
  }
42363
42383
  function EventDispatcherTab({ traits: traits2, schema }) {
42364
42384
  const eventBus = useEventBus();
42365
- const [log4, setLog] = React147.useState([]);
42385
+ const [log18, setLog] = React147.useState([]);
42366
42386
  const prevStatesRef = React147.useRef(/* @__PURE__ */ new Map());
42367
42387
  React147.useEffect(() => {
42368
42388
  for (const trait of traits2) {
@@ -42426,9 +42446,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
42426
42446
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
42427
42447
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
42428
42448
  ] }),
42429
- log4.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
42449
+ log18.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
42430
42450
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Recent Transitions" }),
42431
- /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log4.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
42451
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log18.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
42432
42452
  /* @__PURE__ */ jsx("span", { className: "text-purple-400", children: entry.traitName }),
42433
42453
  " ",
42434
42454
  /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -46798,10 +46818,11 @@ var init_Canvas3DErrorBoundary = __esm({
46798
46818
  "components/organisms/game/three/components/Canvas3DErrorBoundary.css"() {
46799
46819
  }
46800
46820
  });
46801
- var Canvas3DErrorBoundary;
46821
+ var log11, Canvas3DErrorBoundary;
46802
46822
  var init_Canvas3DErrorBoundary2 = __esm({
46803
46823
  "components/organisms/game/three/components/Canvas3DErrorBoundary.tsx"() {
46804
46824
  init_Canvas3DErrorBoundary();
46825
+ log11 = createLogger("almadar:ui:game:canvas3d:error-boundary");
46805
46826
  Canvas3DErrorBoundary = class extends Component {
46806
46827
  constructor(props) {
46807
46828
  super(props);
@@ -46829,8 +46850,8 @@ var init_Canvas3DErrorBoundary2 = __esm({
46829
46850
  componentDidCatch(error, errorInfo) {
46830
46851
  this.setState({ errorInfo });
46831
46852
  this.props.onError?.(error, errorInfo);
46832
- console.error("[Canvas3DErrorBoundary] Error caught:", error);
46833
- console.error("[Canvas3DErrorBoundary] Component stack:", errorInfo.componentStack);
46853
+ log11.error("Error caught", { error });
46854
+ log11.error("Component stack", { componentStack: errorInfo.componentStack ?? "<none>" });
46834
46855
  }
46835
46856
  render() {
46836
46857
  if (this.state.hasError) {
@@ -46893,7 +46914,7 @@ function useGLTFModel(url, resourceBasePath) {
46893
46914
  setState({ model: null, isLoading: false, error: null });
46894
46915
  return;
46895
46916
  }
46896
- console.log("[ModelLoader] Loading:", url);
46917
+ log12.debug("Loading", { url });
46897
46918
  setState((prev) => ({ ...prev, isLoading: true, error: null }));
46898
46919
  const assetRoot = resourceBasePath || detectAssetRoot(url);
46899
46920
  const loader = new GLTFLoader();
@@ -46901,7 +46922,7 @@ function useGLTFModel(url, resourceBasePath) {
46901
46922
  loader.load(
46902
46923
  url,
46903
46924
  (gltf) => {
46904
- console.log("[ModelLoader] Loaded:", url);
46925
+ log12.debug("Loaded", { url });
46905
46926
  setState({
46906
46927
  model: gltf.scene,
46907
46928
  isLoading: false,
@@ -46910,8 +46931,7 @@ function useGLTFModel(url, resourceBasePath) {
46910
46931
  },
46911
46932
  void 0,
46912
46933
  (err) => {
46913
- const errorMsg = err instanceof Error ? err.message : String(err);
46914
- console.warn("[ModelLoader] Failed:", url, errorMsg);
46934
+ log12.warn("Failed", { url, error: err instanceof Error ? err : String(err) });
46915
46935
  setState({
46916
46936
  model: null,
46917
46937
  isLoading: false,
@@ -47027,9 +47047,11 @@ function ModelLoader({
47027
47047
  }
47028
47048
  );
47029
47049
  }
47050
+ var log12;
47030
47051
  var init_ModelLoader = __esm({
47031
47052
  "components/organisms/game/three/components/ModelLoader.tsx"() {
47032
47053
  "use client";
47054
+ log12 = createLogger("almadar:ui:game:model-loader");
47033
47055
  }
47034
47056
  });
47035
47057
  function PhysicsObject3D({
@@ -47120,13 +47142,13 @@ function PhysicsObject3D({
47120
47142
  }
47121
47143
  function usePhysics3DController(entityId) {
47122
47144
  const applyForce = (fx, fy, fz) => {
47123
- console.log(`Apply force to ${entityId}:`, { fx, fy, fz });
47145
+ log13.debug("apply force", { entityId, fx, fy, fz });
47124
47146
  };
47125
47147
  const setVelocity = (vx, vy, vz) => {
47126
- console.log(`Set velocity for ${entityId}:`, { vx, vy, vz });
47148
+ log13.debug("set velocity", { entityId, vx, vy, vz });
47127
47149
  };
47128
47150
  const setPosition = (x, y, z) => {
47129
- console.log(`Set position for ${entityId}:`, { x, y, z });
47151
+ log13.debug("set position", { entityId, x, y, z });
47130
47152
  };
47131
47153
  const jump = (force = 10) => {
47132
47154
  applyForce(0, force, 0);
@@ -47138,10 +47160,12 @@ function usePhysics3DController(entityId) {
47138
47160
  jump
47139
47161
  };
47140
47162
  }
47163
+ var log13;
47141
47164
  var init_PhysicsObject3D = __esm({
47142
47165
  "components/organisms/game/three/components/PhysicsObject3D.tsx"() {
47143
47166
  "use client";
47144
47167
  init_ModelLoader();
47168
+ log13 = createLogger("almadar:ui:game:physics");
47145
47169
  }
47146
47170
  });
47147
47171
  function detectAssetRoot2(modelUrl) {
@@ -48727,14 +48751,16 @@ function preloadFeatures(urls) {
48727
48751
  const loader = new GLTFLoader();
48728
48752
  loader.setResourcePath(detectAssetRoot3(url));
48729
48753
  loader.load(url, () => {
48730
- console.log("[FeatureRenderer3D] Preloaded:", url);
48754
+ log14.debug("Preloaded", { url });
48731
48755
  });
48732
48756
  }
48733
48757
  });
48734
48758
  }
48759
+ var log14;
48735
48760
  var init_FeatureRenderer3D = __esm({
48736
48761
  "components/organisms/game/three/renderers/FeatureRenderer3D.tsx"() {
48737
48762
  "use client";
48763
+ log14 = createLogger("almadar:ui:game:feature-renderer");
48738
48764
  }
48739
48765
  });
48740
48766
 
@@ -52821,7 +52847,7 @@ function MaybeTraitScope({
52821
52847
  const schemaCtx = useEntitySchemaOptional();
52822
52848
  const orbital = sourceTrait !== void 0 && schemaCtx !== null ? schemaCtx.orbitalsByTrait.get(sourceTrait) : void 0;
52823
52849
  const wrap = sourceTrait !== void 0 && orbital !== void 0;
52824
- scopeWrapLog.info("decide", {
52850
+ scopeWrapLog.debug("decide", {
52825
52851
  sourceTrait,
52826
52852
  schemaCtxPresent: schemaCtx !== null,
52827
52853
  orbitalsByTraitSize: schemaCtx?.orbitalsByTrait.size ?? 0,
@@ -53216,7 +53242,7 @@ function SlotContentRenderer({
53216
53242
  }) {
53217
53243
  const entityProp = content.props.entity;
53218
53244
  if (content.pattern === "form-section") {
53219
- slotLog2.debug("SlotContentRenderer:form-section-render", {
53245
+ slotLog.debug("SlotContentRenderer:form-section-render", {
53220
53246
  contentId: content.id,
53221
53247
  sourceTrait: content.sourceTrait,
53222
53248
  entityRefId: refId(entityProp),
@@ -56262,6 +56288,7 @@ init_EventBusProvider();
56262
56288
 
56263
56289
  // providers/SelectionProvider.tsx
56264
56290
  init_useEventBus();
56291
+ var log4 = createLogger("almadar:ui:selection");
56265
56292
  var SelectionContext = createContext(null);
56266
56293
  var defaultCompareEntities = (a, b) => {
56267
56294
  if (a === b) return true;
@@ -56284,7 +56311,10 @@ function SelectionProvider({
56284
56311
  (entity) => {
56285
56312
  setSelectedState(entity);
56286
56313
  if (debug2) {
56287
- console.log("[SelectionProvider] Selection set:", entity);
56314
+ log4.debug("Selection set", () => ({
56315
+ hasEntity: entity !== null && entity !== void 0,
56316
+ entityId: entity && typeof entity === "object" ? String(entity.id ?? "") : ""
56317
+ }));
56288
56318
  }
56289
56319
  },
56290
56320
  [debug2]
@@ -56292,7 +56322,7 @@ function SelectionProvider({
56292
56322
  const clearSelection = useCallback(() => {
56293
56323
  setSelectedState(null);
56294
56324
  if (debug2) {
56295
- console.log("[SelectionProvider] Selection cleared");
56325
+ log4.debug("Selection cleared");
56296
56326
  }
56297
56327
  }, [debug2]);
56298
56328
  const isSelected = useCallback(
@@ -56307,14 +56337,17 @@ function SelectionProvider({
56307
56337
  if (row) {
56308
56338
  setSelected(row);
56309
56339
  if (debug2) {
56310
- console.log(`[SelectionProvider] ${event.type} received:`, row);
56340
+ log4.debug("event received", () => ({
56341
+ type: event.type,
56342
+ rowId: row && typeof row === "object" ? String(row.id ?? "") : ""
56343
+ }));
56311
56344
  }
56312
56345
  }
56313
56346
  };
56314
56347
  const handleDeselect = (event) => {
56315
56348
  clearSelection();
56316
56349
  if (debug2) {
56317
- console.log(`[SelectionProvider] ${event.type} received - clearing selection`);
56350
+ log4.debug("event received - clearing selection", { type: event.type });
56318
56351
  }
56319
56352
  };
56320
56353
  const unsubView = eventBus.on("UI:VIEW", handleSelect);
@@ -56345,7 +56378,7 @@ init_UISlotRenderer();
56345
56378
  // providers/VerificationProvider.tsx
56346
56379
  init_useEventBus();
56347
56380
  init_verificationRegistry();
56348
- var log3 = createLogger("almadar:verify");
56381
+ var log15 = createLogger("almadar:verify");
56349
56382
  var DISPATCH_SUFFIX = ":DISPATCH";
56350
56383
  var SUCCESS_SUFFIX = ":SUCCESS";
56351
56384
  var ERROR_SUFFIX = ":ERROR";
@@ -56391,7 +56424,7 @@ function VerificationProvider({
56391
56424
  const verificationProviderLifecycleListener = (evt) => {
56392
56425
  const parsed = parseLifecycleEvent(evt.type);
56393
56426
  if (!parsed) return;
56394
- log3.debug("lifecycle:event", { kind: parsed.kind, traitName: parsed.traitName, event: parsed.event, type: evt.type });
56427
+ log15.debug("lifecycle:event", { kind: parsed.kind, traitName: parsed.traitName, event: parsed.event, type: evt.type });
56395
56428
  const payload = evt.payload ?? {};
56396
56429
  if (parsed.kind === "dispatch") {
56397
56430
  const key = `${parsed.traitName}:${String(payload["event"] ?? "")}`;
@@ -56446,7 +56479,7 @@ function VerificationProvider({
56446
56479
  },
56447
56480
  timestamp: Date.now()
56448
56481
  });
56449
- log3.info("transition:success", { trait: parsed.traitName, event: parsed.event, from: pending?.from, to: newState, effectCount: effects.length });
56482
+ log15.debug("transition:success", { trait: parsed.traitName, event: parsed.event, from: pending?.from, to: newState, effectCount: effects.length });
56450
56483
  } else if (parsed.kind === "error" && parsed.event) {
56451
56484
  const key = `${parsed.traitName}:${parsed.event}`;
56452
56485
  const pending = pendingRef.current.get(key);
@@ -56476,7 +56509,7 @@ function VerificationProvider({
56476
56509
  },
56477
56510
  timestamp: Date.now()
56478
56511
  });
56479
- log3.warn("transition:error", { trait: parsed.traitName, event: parsed.event, from: fromState, error: errorMsg });
56512
+ log15.warn("transition:error", { trait: parsed.traitName, event: parsed.event, from: fromState, error: errorMsg });
56480
56513
  }
56481
56514
  };
56482
56515
  Object.defineProperty(verificationProviderLifecycleListener, "name", {
@@ -56629,7 +56662,11 @@ function useResolvedSchema(schema, pageName) {
56629
56662
  };
56630
56663
  }
56631
56664
  const page = getPage(ir, pageName);
56632
- console.log("[useResolvedSchema] Resolved page:", page?.name, "| path:", page?.path, "| traits:", page?.traits.length);
56665
+ resolvedSchemaLog.debug("Resolved page", () => ({
56666
+ name: page?.name,
56667
+ path: page?.path,
56668
+ traits: page?.traits.length
56669
+ }));
56633
56670
  const traits2 = page?.traits || [];
56634
56671
  const entities = /* @__PURE__ */ new Map();
56635
56672
  if (page) {
@@ -56832,8 +56869,7 @@ function convertFnFormLambdasInProps(props) {
56832
56869
  // hooks/index.ts
56833
56870
  init_useEventBus();
56834
56871
  var ALMADAR_DND_MIME = "application/x-almadar-dnd";
56835
-
56836
- // runtime/createClientEffectHandlers.ts
56872
+ var log16 = createLogger("almadar:ui:effects:client-handlers");
56837
56873
  function createClientEffectHandlers(options) {
56838
56874
  const { eventBus, slotSetter, navigate, notify, callService } = options;
56839
56875
  return {
@@ -56842,10 +56878,10 @@ function createClientEffectHandlers(options) {
56842
56878
  eventBus.emit(prefixedEvent, payload);
56843
56879
  },
56844
56880
  persist: async () => {
56845
- console.warn("[ClientEffectHandlers] persist is server-side only, ignored on client");
56881
+ log16.warn("persist is server-side only, ignored on client");
56846
56882
  },
56847
56883
  set: () => {
56848
- console.warn("[ClientEffectHandlers] set is server-side only, ignored on client");
56884
+ log16.warn("set is server-side only, ignored on client");
56849
56885
  },
56850
56886
  callService: async (service, action, params) => {
56851
56887
  if (callService) return callService(service, action, params);
@@ -56874,10 +56910,10 @@ function createClientEffectHandlers(options) {
56874
56910
  slotSetter.addPattern(slot, pattern, props);
56875
56911
  },
56876
56912
  navigate: navigate ?? ((path) => {
56877
- console.warn("[ClientEffectHandlers] No navigate handler, ignoring:", path);
56913
+ log16.warn("No navigate handler, ignoring", { path });
56878
56914
  }),
56879
56915
  notify: notify ?? ((msg, type) => {
56880
- console.log(`[ClientEffectHandlers] notify (${type}):`, msg);
56916
+ log16.debug("notify", { type, message: msg });
56881
56917
  })
56882
56918
  };
56883
56919
  }
@@ -56944,7 +56980,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
56944
56980
  const slots = uiSlotsRef.current;
56945
56981
  const embedded = embeddedTraitsRef.current;
56946
56982
  if (patterns.length === 0) {
56947
- flushLog.info("clear", { traitName, slot });
56983
+ flushLog.debug("clear", { traitName, slot });
56948
56984
  slots.clearBySource(slot, traitName);
56949
56985
  return;
56950
56986
  }
@@ -56959,7 +56995,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
56959
56995
  const props = convertFnFormLambdasInProps(rawProps);
56960
56996
  const isEmbedded = embedded?.has(traitName) ?? false;
56961
56997
  if (isEmbedded) {
56962
- flushLog.info("embed-route", {
56998
+ flushLog.debug("embed-route", {
56963
56999
  traitName,
56964
57000
  slot,
56965
57001
  patternType: typeof patternType === "string" ? patternType : void 0,
@@ -56973,12 +57009,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
56973
57009
  });
56974
57010
  return;
56975
57011
  }
56976
- flushLog.info("slot-render", {
57012
+ flushLog.debug("slot-render", () => ({
56977
57013
  traitName,
56978
57014
  slot,
56979
57015
  patternType: typeof patternType === "string" ? patternType : void 0,
56980
57016
  embedded: Array.from(embedded ?? [])
56981
- });
57017
+ }));
56982
57018
  slots.render({
56983
57019
  target: slot,
56984
57020
  pattern: patternType,
@@ -57072,10 +57108,9 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57072
57108
  });
57073
57109
  snapshotUnregs.push(unreg);
57074
57110
  }
57075
- console.log(
57076
- "[TraitStateMachine] Reset states for page navigation:",
57077
- Array.from(newManager.getAllStates().keys()).join(", ")
57078
- );
57111
+ stateLog.debug("reset-states-for-nav", () => ({
57112
+ traits: Array.from(newManager.getAllStates().keys()).join(", ")
57113
+ }));
57079
57114
  return () => {
57080
57115
  for (const unreg of snapshotUnregs) unreg();
57081
57116
  };
@@ -57162,13 +57197,13 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57162
57197
  const normalizedEvent = normalizeEventKey(eventKey);
57163
57198
  const bindings = traitBindingsRef.current;
57164
57199
  const currentManager = managerRef.current;
57165
- console.log("[TraitStateMachine] Processing event:", normalizedEvent, "payload:", payload);
57166
- crossTraitLog.debug("processEvent:enter", {
57200
+ crossTraitLog.debug("processEvent:enter", () => ({
57167
57201
  event: normalizedEvent,
57202
+ payload: JSON.stringify(payload ?? null),
57168
57203
  traitCount: bindings.length,
57169
57204
  traitNames: bindings.map((b) => b.trait.name).join(","),
57170
57205
  orbitalsByTrait: JSON.stringify(orbitalsByTrait ?? null)
57171
- });
57206
+ }));
57172
57207
  const bindingMap = new Map(bindings.map((b) => [b.trait.name, b]));
57173
57208
  const entityByTrait = {};
57174
57209
  for (const [name, fields] of traitFieldStatesRef.current) {
@@ -57223,18 +57258,13 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57223
57258
  }
57224
57259
  }
57225
57260
  if (result.executed && result.effects.length > 0) {
57226
- console.log(
57227
- "[TraitStateMachine] Executing",
57228
- result.effects.length,
57229
- "effects for",
57261
+ stateLog.debug("executing-effects", () => ({
57262
+ effectCount: result.effects.length,
57230
57263
  traitName,
57231
- "| linkedEntity:",
57232
- binding.linkedEntity,
57233
- "| transition:",
57234
- `${result.previousState} -> ${result.newState}`,
57235
- "| effects:",
57236
- JSON.stringify(result.effects)
57237
- );
57264
+ linkedEntity: binding.linkedEntity,
57265
+ transition: `${result.previousState} -> ${result.newState}`,
57266
+ effects: JSON.stringify(result.effects)
57267
+ }));
57238
57268
  const linkedEntity = binding.linkedEntity || "";
57239
57269
  const entityId = payload?.entityId;
57240
57270
  const pendingSlots = /* @__PURE__ */ new Map();
@@ -57354,7 +57384,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57354
57384
  const executor = new EffectExecutor({ handlers: trackingHandlers, bindings: bindingCtx, context: effectContext });
57355
57385
  try {
57356
57386
  await executor.executeAll(result.effects);
57357
- stateLog.info("transition:render-ui-dispatched", {
57387
+ stateLog.debug("transition:render-ui-dispatched", () => ({
57358
57388
  traitName,
57359
57389
  fromState: result.previousState,
57360
57390
  toState: result.newState,
@@ -57363,7 +57393,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57363
57393
  patternTypes: Array.from(pendingSlots.entries()).map(
57364
57394
  ([slot, patterns]) => `${slot}:[${patterns.map((p2) => p2.pattern?.type ?? "null").join(",")}]`
57365
57395
  ).join(";")
57366
- });
57396
+ }));
57367
57397
  void slotSource;
57368
57398
  for (const [slot, patterns] of pendingSlots) {
57369
57399
  flushSlot(traitName, slot, patterns);
@@ -57380,30 +57410,25 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57380
57410
  }
57381
57411
  } else if (!result.executed) {
57382
57412
  if (result.guardResult === false) {
57383
- console.log(
57384
- "[TraitStateMachine] Guard blocked transition:",
57413
+ stateLog.debug("guard-blocked-transition", {
57385
57414
  traitName,
57386
- result.previousState,
57387
- "->",
57388
- result.transition?.to
57389
- );
57415
+ from: result.previousState,
57416
+ to: result.transition?.to
57417
+ });
57390
57418
  } else if (!result.transition) {
57391
57419
  if (isCircuitEvent(normalizedEvent)) {
57392
- console.warn(
57393
- `[CLOSED CIRCUIT VIOLATION] Trait "${traitName}" in state "${traitState.currentState}" received event "${normalizedEvent}" but has no transition to handle it.
57394
- This is likely a schema issue. To fix, add a transition:
57395
- { from: "${traitState.currentState}", to: "<target_state>", event: "${normalizedEvent}", effects: [...] }
57396
- Or ensure the previous action (that opened this UI) properly transitions back before emitting this event.`
57397
- );
57420
+ stateLog.warn("closed-circuit-violation", {
57421
+ traitName,
57422
+ currentState: traitState.currentState,
57423
+ event: normalizedEvent,
57424
+ remediation: `Add transition { from: "${traitState.currentState}", to: "<target_state>", event: "${normalizedEvent}", effects: [...] } \u2014 or ensure the previous action (that opened this UI) transitions back before emitting.`
57425
+ });
57398
57426
  } else {
57399
- console.log(
57400
- "[TraitStateMachine] No transition for",
57427
+ stateLog.debug("no-transition", {
57401
57428
  traitName,
57402
- "from state:",
57403
- traitState.currentState,
57404
- "on event:",
57405
- normalizedEvent
57406
- );
57429
+ from: traitState.currentState,
57430
+ event: normalizedEvent
57431
+ });
57407
57432
  }
57408
57433
  }
57409
57434
  }
@@ -57511,7 +57536,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57511
57536
  allEvents.add(transition.event);
57512
57537
  }
57513
57538
  }
57514
- console.log("[TraitStateMachine] Subscribing to events:", Array.from(allEvents));
57539
+ stateLog.debug("subscribing-to-events", () => ({ events: Array.from(allEvents) }));
57515
57540
  const unsubscribes = [];
57516
57541
  const subscribedBusKeys = /* @__PURE__ */ new Set();
57517
57542
  for (const binding of traitBindings) {
@@ -57532,7 +57557,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57532
57557
  crossTraitLog.debug("self:fire-skipped-bridge-echo", { traitName, busKey: selfBusKey, eventKey });
57533
57558
  return;
57534
57559
  }
57535
- crossTraitLog.info("self:fire", { traitName, busKey: selfBusKey, eventKey });
57560
+ crossTraitLog.debug("self:fire", { traitName, busKey: selfBusKey, eventKey });
57536
57561
  enqueueAndDrain(eventKey, event.payload);
57537
57562
  });
57538
57563
  unsubscribes.push(() => {
@@ -57558,7 +57583,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57558
57583
  const busKey = `UI:${sourceOrbital}.${sourceTrait}.${listen.event}`;
57559
57584
  crossTraitLog.debug("listen:subscribed", { busKey, targetTrait: binding.trait.name, sourceOrbital, sourceTrait, listenEvent: listen.event, triggers: listen.triggers });
57560
57585
  const unsub = eventBus.on(busKey, (event) => {
57561
- crossTraitLog.info("listen:fired", { busKey, targetTrait: binding.trait.name, triggers: listen.triggers });
57586
+ crossTraitLog.debug("listen:fired", { busKey, targetTrait: binding.trait.name, triggers: listen.triggers });
57562
57587
  enqueueAndDrain(listen.triggers, event.payload);
57563
57588
  });
57564
57589
  unsubscribes.push(() => {
@@ -57589,6 +57614,7 @@ init_EntitySchemaContext();
57589
57614
  // runtime/ServerBridge.tsx
57590
57615
  init_useEventBus();
57591
57616
  var xOrbitalLog = createLogger("almadar:runtime:cross-orbital");
57617
+ var serverBridgeLog = createLogger("almadar:ui:server-bridge");
57592
57618
  function createHttpTransport(serverUrl) {
57593
57619
  return {
57594
57620
  register: async (schema) => {
@@ -57601,7 +57627,7 @@ function createHttpTransport(serverUrl) {
57601
57627
  const result = await res.json();
57602
57628
  return !!result.success;
57603
57629
  } catch (err) {
57604
- console.error("[ServerBridge] Registration failed:", err);
57630
+ serverBridgeLog.error("Registration failed", { error: err instanceof Error ? err : String(err) });
57605
57631
  return false;
57606
57632
  }
57607
57633
  },
@@ -57864,7 +57890,7 @@ function applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits) {
57864
57890
  };
57865
57891
  const props = convertFnFormLambdasInProps(rawProps);
57866
57892
  if (isEmbedded) {
57867
- xOrbitalLog2.info("slot:embed-routed", {
57893
+ xOrbitalLog2.debug("slot:embed-routed", {
57868
57894
  sourceTrait,
57869
57895
  slot: eff.slot,
57870
57896
  patternType: typeof patternType === "string" ? patternType : void 0
@@ -57876,7 +57902,7 @@ function applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits) {
57876
57902
  animation: "fade"
57877
57903
  });
57878
57904
  } else {
57879
- xOrbitalLog2.info("slot-write", {
57905
+ xOrbitalLog2.debug("slot-write", {
57880
57906
  slot: eff.slot,
57881
57907
  sourceTrait,
57882
57908
  patternType: typeof patternType === "string" ? patternType : void 0
@@ -57899,12 +57925,12 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
57899
57925
  const onEventProcessed = useCallback(async (event, payload, dispatchedOrbitals) => {
57900
57926
  if (!bridge.connected || !orbitalNames?.length) return;
57901
57927
  const targets = dispatchedOrbitals && dispatchedOrbitals.size > 0 ? orbitalNames.filter((n) => dispatchedOrbitals.has(n)) : orbitalNames;
57902
- xOrbitalLog2.info("TraitInitializer:fanout", {
57928
+ xOrbitalLog2.debug("TraitInitializer:fanout", () => ({
57903
57929
  event,
57904
57930
  sentTo: targets,
57905
57931
  skipped: orbitalNames.filter((n) => !targets.includes(n)),
57906
57932
  dispatchedOrbitalsSize: dispatchedOrbitals?.size ?? 0
57907
- });
57933
+ }));
57908
57934
  for (const name of targets) {
57909
57935
  const { effects, meta } = await bridge.sendEvent(name, event, payload);
57910
57936
  recordServerResponse(name, event, meta);
@@ -57917,7 +57943,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
57917
57943
  useEffect(() => {
57918
57944
  const traitNames = traits2.map((b) => b.trait?.name ?? "").filter(Boolean).sort().join(",");
57919
57945
  if (prevTraitNamesRef.current && prevTraitNamesRef.current !== traitNames) {
57920
- navLog.info("page:trait-set-changed", {
57946
+ navLog.debug("page:trait-set-changed", {
57921
57947
  from: prevTraitNamesRef.current,
57922
57948
  to: traitNames,
57923
57949
  action: "clearAll-slots"
@@ -58184,11 +58210,11 @@ function OrbPreview({
58184
58210
  }, [initialPageName, currentPage]);
58185
58211
  const handleNavigate = useCallback((path) => {
58186
58212
  const match = pages.find(({ page }) => page.path === path);
58187
- navLog.info("handleNavigate", {
58213
+ navLog.debug("handleNavigate", () => ({
58188
58214
  path,
58189
58215
  matched: match?.page.name ?? null,
58190
58216
  availablePaths: pages.map((p2) => p2.page.path)
58191
- });
58217
+ }));
58192
58218
  if (match) {
58193
58219
  setCurrentPage(match.page.name);
58194
58220
  if (typeof window !== "undefined") {
@@ -58210,19 +58236,19 @@ function OrbPreview({
58210
58236
  const el = containerRef.current;
58211
58237
  if (!el) return;
58212
58238
  if (pages.length <= 1) {
58213
- navLog.info("interceptor:skipped", { reason: "single-page schema", pageCount: pages.length });
58239
+ navLog.debug("interceptor:skipped", { reason: "single-page schema", pageCount: pages.length });
58214
58240
  return;
58215
58241
  }
58216
58242
  const handler = (e) => {
58217
58243
  const anchor = e.target.closest("a");
58218
58244
  if (!anchor) return;
58219
58245
  const href = anchor.getAttribute("href") ?? anchor.getAttribute("to") ?? "";
58220
- navLog.info("click:intercepted", {
58246
+ navLog.debug("click:intercepted", {
58221
58247
  href,
58222
58248
  anchorText: anchor.textContent?.trim().slice(0, 40)
58223
58249
  });
58224
58250
  if (!href || href.startsWith("http") || href.startsWith("mailto:") || href.startsWith("#")) {
58225
- navLog.info("click:skipped", { href, reason: "external/empty/hash" });
58251
+ navLog.debug("click:skipped", { href, reason: "external/empty/hash" });
58226
58252
  return;
58227
58253
  }
58228
58254
  e.preventDefault();
@@ -59682,11 +59708,11 @@ function FlowCanvasInner({
59682
59708
  const EDGE_TYPES_LOCAL = useMemo(() => ({
59683
59709
  eventFlow: EventFlowEdge
59684
59710
  }), []);
59685
- flowCanvasLog.info("node-type-registry:render", {
59711
+ flowCanvasLog.debug("node-type-registry:render", () => ({
59686
59712
  registered: Object.keys(NODE_TYPES2),
59687
59713
  preview: typeof OrbPreviewNode,
59688
59714
  previewIsValid: typeof OrbPreviewNode === "function" || typeof OrbPreviewNode === "object" && OrbPreviewNode !== null
59689
- });
59715
+ }));
59690
59716
  const parsedSchema = useMemo(() => {
59691
59717
  if (typeof schemaProp === "string") return JSON.parse(schemaProp);
59692
59718
  return schemaProp;
@@ -60105,6 +60131,7 @@ init_AvlTransitionLane();
60105
60131
  init_AvlSwimLane();
60106
60132
  init_types();
60107
60133
  init_avl_elk_layout();
60134
+ var log17 = createLogger("almadar:ui:avl:trait-scene");
60108
60135
  var SWIM_GUTTER2 = 120;
60109
60136
  var CENTER_W2 = 360;
60110
60137
  var AvlTraitScene = ({
@@ -60115,7 +60142,9 @@ var AvlTraitScene = ({
60115
60142
  const [layout, setLayout] = useState(null);
60116
60143
  const dataKey = useMemo(() => JSON.stringify(data), [data]);
60117
60144
  useEffect(() => {
60118
- computeTraitLayout(data).then(setLayout).catch(console.error);
60145
+ computeTraitLayout(data).then(setLayout).catch((error) => {
60146
+ log17.error("computeTraitLayout failed", { error: error instanceof Error ? error : String(error) });
60147
+ });
60119
60148
  }, [dataKey]);
60120
60149
  if (!layout) {
60121
60150
  return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("text", { x: 300, y: 200, textAnchor: "middle", fill: color, fontSize: 12, opacity: 0.5, children: "Computing layout..." }) });