@almadar/ui 4.44.1 → 4.46.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
  }
@@ -10747,12 +10739,15 @@ function ControlButton({
10747
10739
  sizeMap3[size] ?? sizeMap3.md,
10748
10740
  shapeMap[shape] ?? shapeMap.circle,
10749
10741
  variantMap[variant] ?? variantMap.secondary,
10750
- actualPressed && "scale-95 brightness-110 border-white",
10742
+ actualPressed && "scale-95 brightness-110 border-foreground",
10751
10743
  disabled && "opacity-50 cursor-not-allowed",
10752
10744
  className
10753
10745
  ),
10754
10746
  children: [
10755
- icon && /* @__PURE__ */ jsx("span", { className: "text-2xl", children: icon }),
10747
+ icon && /* @__PURE__ */ jsx("span", { className: "text-2xl", children: typeof icon === "string" ? (() => {
10748
+ const I = resolveIcon(icon);
10749
+ return I ? /* @__PURE__ */ jsx(I, { className: "w-6 h-6" }) : null;
10750
+ })() : icon }),
10756
10751
  label && !icon && /* @__PURE__ */ jsx("span", { children: label })
10757
10752
  ]
10758
10753
  }
@@ -10764,6 +10759,7 @@ var init_ControlButton = __esm({
10764
10759
  "use client";
10765
10760
  init_cn();
10766
10761
  init_useEventBus();
10762
+ init_Icon();
10767
10763
  sizeMap3 = {
10768
10764
  sm: "w-10 h-10 text-sm",
10769
10765
  md: "w-14 h-14 text-base",
@@ -10776,9 +10772,9 @@ var init_ControlButton = __esm({
10776
10772
  square: "rounded-md"
10777
10773
  };
10778
10774
  variantMap = {
10779
- primary: "bg-blue-600 text-[var(--color-foreground)] border-blue-400 hover:bg-blue-500",
10780
- secondary: "bg-[var(--color-surface,#374151)] text-[var(--color-foreground)] border-gray-500 hover:bg-gray-600",
10781
- ghost: "bg-transparent text-[var(--color-foreground)] border-white/30 hover:bg-white/10"
10775
+ primary: "bg-primary text-primary-foreground border-primary hover:bg-primary-hover",
10776
+ secondary: "bg-secondary text-secondary-foreground border-border hover:bg-secondary-hover",
10777
+ ghost: "bg-transparent text-foreground border-border hover:bg-muted"
10782
10778
  };
10783
10779
  ControlButton.displayName = "ControlButton";
10784
10780
  }
@@ -11506,8 +11502,8 @@ function ChoiceButton({
11506
11502
  className: cn(
11507
11503
  "w-full text-left px-4 py-2.5 rounded-md border transition-all duration-150",
11508
11504
  "flex items-center gap-2",
11509
- selected ? "bg-yellow-500/20 border-yellow-400 text-yellow-300" : "bg-white/5 border-white/10 text-[var(--color-foreground)] hover:bg-white/10 hover:border-white/30",
11510
- disabled && "opacity-40 cursor-not-allowed hover:bg-white/5 hover:border-white/10",
11505
+ selected ? "bg-accent/15 border-accent text-foreground" : "bg-muted/40 border-border text-foreground hover:bg-muted hover:border-border",
11506
+ disabled && "opacity-40 cursor-not-allowed hover:bg-muted/40 hover:border-border",
11511
11507
  className
11512
11508
  ),
11513
11509
  children: [
@@ -11516,7 +11512,7 @@ function ChoiceButton({
11516
11512
  {
11517
11513
  className: cn(
11518
11514
  "flex-shrink-0 font-mono font-bold text-sm",
11519
- selected ? "text-yellow-400" : "text-gray-500"
11515
+ selected ? "text-accent" : "text-muted-foreground"
11520
11516
  ),
11521
11517
  children: [
11522
11518
  index,
@@ -11557,7 +11553,7 @@ function ActionButton({
11557
11553
  disabled: isDisabled,
11558
11554
  onClick,
11559
11555
  className: cn(
11560
- "relative inline-flex items-center gap-1.5 rounded-md border font-medium text-[var(--color-foreground)] overflow-hidden transition-colors duration-150",
11556
+ "relative inline-flex items-center gap-1.5 rounded-md border font-medium overflow-hidden transition-colors duration-150",
11561
11557
  sizes.button,
11562
11558
  variantStyles8[variant],
11563
11559
  isDisabled && "opacity-60 cursor-not-allowed",
@@ -11567,7 +11563,7 @@ function ActionButton({
11567
11563
  onCooldown && /* @__PURE__ */ jsx(
11568
11564
  "div",
11569
11565
  {
11570
- className: "absolute inset-0 bg-black/60 pointer-events-none",
11566
+ className: "absolute inset-0 bg-foreground/40 pointer-events-none",
11571
11567
  style: {
11572
11568
  clipPath: `conic-gradient(from 0deg, transparent ${360 - cooldownDeg}deg, black ${360 - cooldownDeg}deg)`,
11573
11569
  WebkitClipPath: `conic-gradient(from 0deg, transparent ${360 - cooldownDeg}deg, black ${360 - cooldownDeg}deg)`,
@@ -11575,13 +11571,16 @@ function ActionButton({
11575
11571
  }
11576
11572
  }
11577
11573
  ),
11578
- icon && /* @__PURE__ */ jsx("span", { className: cn("flex-shrink-0", sizes.icon), children: icon }),
11574
+ icon && /* @__PURE__ */ jsx("span", { className: cn("flex-shrink-0", sizes.icon), children: typeof icon === "string" ? (() => {
11575
+ const I = resolveIcon(icon);
11576
+ return I ? /* @__PURE__ */ jsx(I, { className: "w-4 h-4" }) : null;
11577
+ })() : icon }),
11579
11578
  /* @__PURE__ */ jsx("span", { className: "relative z-10", children: label }),
11580
11579
  hotkey && /* @__PURE__ */ jsx(
11581
11580
  "span",
11582
11581
  {
11583
11582
  className: cn(
11584
- "absolute top-0.5 right-0.5 bg-black/50 text-gray-300 rounded font-mono leading-tight",
11583
+ "absolute top-0.5 right-0.5 bg-foreground/30 text-primary-foreground rounded font-mono leading-tight",
11585
11584
  sizes.hotkey
11586
11585
  ),
11587
11586
  children: hotkey
@@ -11595,15 +11594,16 @@ var sizeMap13, variantStyles8;
11595
11594
  var init_ActionButton = __esm({
11596
11595
  "components/atoms/game/ActionButton.tsx"() {
11597
11596
  init_cn();
11597
+ init_Icon();
11598
11598
  sizeMap13 = {
11599
11599
  sm: { button: "px-3 py-1.5 text-xs", hotkey: "text-[9px] px-1", icon: "text-xs" },
11600
11600
  md: { button: "px-4 py-2 text-sm", hotkey: "text-[10px] px-1.5", icon: "text-sm" },
11601
11601
  lg: { button: "px-5 py-2.5 text-base", hotkey: "text-xs px-2", icon: "text-base" }
11602
11602
  };
11603
11603
  variantStyles8 = {
11604
- primary: "bg-blue-600 hover:bg-blue-500 border-blue-400/40",
11605
- secondary: "bg-gray-700 hover:bg-gray-600 border-gray-500/40",
11606
- danger: "bg-red-700 hover:bg-red-600 border-red-400/40"
11604
+ primary: "bg-primary text-primary-foreground hover:bg-primary-hover border-primary",
11605
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary-hover border-border",
11606
+ danger: "bg-error text-error-foreground hover:bg-error/90 border-error"
11607
11607
  };
11608
11608
  ActionButton.displayName = "ActionButton";
11609
11609
  }
@@ -12176,6 +12176,7 @@ function getAllPages(schema) {
12176
12176
  var init_navigation = __esm({
12177
12177
  "renderer/navigation.tsx"() {
12178
12178
  "use client";
12179
+ createLogger("almadar:ui:navigation");
12179
12180
  createContext(null);
12180
12181
  }
12181
12182
  });
@@ -14653,7 +14654,7 @@ function recordTransition(trace) {
14653
14654
  ...trace,
14654
14655
  id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
14655
14656
  };
14656
- log2.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
14657
+ log7.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
14657
14658
  getState().transitions.push(entry);
14658
14659
  if (getState().transitions.length > MAX_TRANSITIONS) {
14659
14660
  getState().transitions.shift();
@@ -14752,7 +14753,7 @@ function getTraitSnapshots() {
14752
14753
  try {
14753
14754
  snapshots.push(getter());
14754
14755
  } catch (err) {
14755
- log2.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
14756
+ log7.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
14756
14757
  }
14757
14758
  }
14758
14759
  return snapshots;
@@ -14800,12 +14801,12 @@ function waitForTransition(event, timeoutMs = 1e4) {
14800
14801
  }
14801
14802
  function bindEventBus(eventBus) {
14802
14803
  if (typeof window === "undefined") return;
14803
- log2.info("bindEventBus", { hasOnAny: !!eventBus.onAny });
14804
+ log7.info("bindEventBus", { hasOnAny: !!eventBus.onAny });
14804
14805
  exposeOnWindow();
14805
14806
  if (window.__orbitalVerification) {
14806
14807
  window.__orbitalVerification.sendEvent = (event, payload, traitScope) => {
14807
14808
  const prefixed = event.startsWith("UI:") ? event : traitScope ? `UI:${traitScope}.${event}` : `UI:${event}`;
14808
- log2.debug("sendEvent", { event: prefixed, traitScope, payloadKeys: payload ? Object.keys(payload) : [] });
14809
+ log7.debug("sendEvent", { event: prefixed, traitScope, payloadKeys: payload ? Object.keys(payload) : [] });
14809
14810
  eventBus.emit(prefixed, payload);
14810
14811
  };
14811
14812
  const eventLog = [];
@@ -14868,10 +14869,10 @@ function updateAssetStatus(url, status) {
14868
14869
  window.__orbitalVerification.assetStatus[url] = status;
14869
14870
  }
14870
14871
  }
14871
- var log2, MAX_TRANSITIONS;
14872
+ var log7, MAX_TRANSITIONS;
14872
14873
  var init_verificationRegistry = __esm({
14873
14874
  "lib/verificationRegistry.ts"() {
14874
- log2 = createLogger("almadar:bridge");
14875
+ log7 = createLogger("almadar:bridge");
14875
14876
  MAX_TRANSITIONS = 500;
14876
14877
  exposeOnWindow();
14877
14878
  }
@@ -16432,7 +16433,7 @@ function computeFoldRegions(code) {
16432
16433
  }
16433
16434
  return regions.sort((a, b) => a.start - b.start);
16434
16435
  }
16435
- var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
16436
+ var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, log8, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
16436
16437
  var init_CodeBlock = __esm({
16437
16438
  "components/molecules/markdown/CodeBlock.tsx"() {
16438
16439
  init_Box();
@@ -16509,6 +16510,7 @@ var init_CodeBlock = __esm({
16509
16510
  "lolo-op-async": { color: ORB_COLORS.dark.async }
16510
16511
  };
16511
16512
  loloStyle = { ...dark, ...loloStyleOverrides };
16513
+ log8 = createLogger("almadar:ui:markdown-code");
16512
16514
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
16513
16515
  HIDDEN_LINE_NUMBERS = { display: "none" };
16514
16516
  CodeBlock = React147__default.memo(
@@ -16707,7 +16709,7 @@ var init_CodeBlock = __esm({
16707
16709
  eventBus.emit("UI:COPY_CODE", { language, success: true });
16708
16710
  setTimeout(() => setCopied(false), 2e3);
16709
16711
  } catch (err) {
16710
- console.error("Failed to copy code:", err);
16712
+ log8.error("Failed to copy code", { error: err instanceof Error ? err : String(err) });
16711
16713
  eventBus.emit("UI:COPY_CODE", { language, success: false });
16712
16714
  }
16713
16715
  };
@@ -20269,13 +20271,14 @@ function useSafeEventBus2() {
20269
20271
  } };
20270
20272
  }
20271
20273
  }
20272
- var ButtonGroup;
20274
+ var log9, ButtonGroup;
20273
20275
  var init_ButtonGroup = __esm({
20274
20276
  "components/molecules/ButtonGroup.tsx"() {
20275
20277
  "use client";
20276
20278
  init_cn();
20277
20279
  init_atoms();
20278
20280
  init_useEventBus();
20281
+ log9 = createLogger("almadar:ui:button-group");
20279
20282
  ButtonGroup = ({
20280
20283
  children,
20281
20284
  primary,
@@ -20348,7 +20351,7 @@ var init_ButtonGroup = __esm({
20348
20351
  {
20349
20352
  variant: "ghost",
20350
20353
  onClick: () => {
20351
- console.log(`Filter clicked: ${filter.field}`);
20354
+ log9.debug("Filter clicked", { field: filter.field });
20352
20355
  },
20353
20356
  children: filter.label
20354
20357
  },
@@ -25109,7 +25112,7 @@ function DataGrid({
25109
25112
  onClick: handleActionClick(action, itemData),
25110
25113
  "data-testid": `action-${action.event}`,
25111
25114
  "data-row-id": String(itemData.id),
25112
- className: "text-error hover:bg-error/10 px-2",
25115
+ className: "text-error hover:text-error hover:bg-error/10 px-2",
25113
25116
  children: [
25114
25117
  action.icon && /* @__PURE__ */ jsx(Icon, { name: action.icon, size: "xs" }),
25115
25118
  action.label
@@ -26365,31 +26368,56 @@ var init_InputGroup = __esm({
26365
26368
  InputGroup.displayName = "InputGroup";
26366
26369
  }
26367
26370
  });
26368
-
26369
- // lib/debug.ts
26371
+ function gateEnabled(level, ns = NAMESPACE) {
26372
+ return isLogLevelEnabled(level, ns);
26373
+ }
26370
26374
  function isDebugEnabled() {
26371
- if (DEBUG_ENABLED) return true;
26372
- return typeof window !== "undefined" && window.__ALMADAR_DEBUG_VERIFY__ === true;
26375
+ return gateEnabled("DEBUG");
26373
26376
  }
26374
26377
  function debug(...args) {
26375
- if (isDebugEnabled()) {
26376
- console.log("[DEBUG]", ...args);
26378
+ if (!gateEnabled("DEBUG")) return;
26379
+ const [first, ...rest] = args;
26380
+ const message = typeof first === "string" ? first : "<debug>";
26381
+ if (rest.length === 0 && typeof first === "string") {
26382
+ log10.debug(message);
26383
+ } else {
26384
+ log10.debug(message, { args: rest.length > 0 ? formatArgs(rest) : formatArgs([first]) });
26377
26385
  }
26378
26386
  }
26379
26387
  function debugGroup(label) {
26380
- if (isDebugEnabled()) {
26381
- console.group(`[DEBUG] ${label}`);
26382
- }
26388
+ if (gateEnabled("DEBUG")) console.group(`[${NAMESPACE}] ${label}`);
26383
26389
  }
26384
26390
  function debugGroupEnd() {
26385
- if (isDebugEnabled()) {
26386
- console.groupEnd();
26391
+ if (gateEnabled("DEBUG")) console.groupEnd();
26392
+ }
26393
+ function formatArgs(values) {
26394
+ if (values.length === 1) return toLogMetaValue(values[0]);
26395
+ return values.map(toLogMetaValue);
26396
+ }
26397
+ function toLogMetaValue(v) {
26398
+ if (v === null || v === void 0) return v;
26399
+ if (v instanceof Error) return v;
26400
+ const t = typeof v;
26401
+ if (t === "string" || t === "number" || t === "boolean") return v;
26402
+ if (Array.isArray(v)) return v.map(toLogMetaValue);
26403
+ if (t === "object") {
26404
+ const out = {};
26405
+ for (const [k, val] of Object.entries(v)) {
26406
+ out[k] = toLogMetaValue(val);
26407
+ }
26408
+ return out;
26387
26409
  }
26410
+ return String(v);
26388
26411
  }
26389
- var DEBUG_ENABLED;
26412
+ var NAMESPACE, log10;
26390
26413
  var init_debug = __esm({
26391
26414
  "lib/debug.ts"() {
26392
- DEBUG_ENABLED = typeof window !== "undefined" && (localStorage.getItem("debug") === "true" || process.env.NODE_ENV === "development");
26415
+ NAMESPACE = "almadar:ui:debug";
26416
+ log10 = createLogger(NAMESPACE);
26417
+ createLogger("almadar:ui:debug:input");
26418
+ createLogger("almadar:ui:debug:collision");
26419
+ createLogger("almadar:ui:debug:physics");
26420
+ createLogger("almadar:ui:debug:game-state");
26393
26421
  }
26394
26422
  });
26395
26423
  var isRelationsDebugEnabled, RelationSelect;
@@ -27677,7 +27705,7 @@ function StatBadge({
27677
27705
  const I = resolveIcon(icon);
27678
27706
  return I ? /* @__PURE__ */ jsx(I, { className: "w-4 h-4" }) : icon;
27679
27707
  })() : icon }),
27680
- /* @__PURE__ */ jsx("span", { className: "text-gray-400 font-medium", children: label }),
27708
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground font-medium", children: label }),
27681
27709
  format === "hearts" && max && /* @__PURE__ */ jsx(
27682
27710
  HealthBar,
27683
27711
  {
@@ -27704,7 +27732,7 @@ function StatBadge({
27704
27732
  animated: true
27705
27733
  }
27706
27734
  ),
27707
- format === "text" && /* @__PURE__ */ jsx("span", { className: "font-bold text-[var(--color-foreground)]", children: value })
27735
+ format === "text" && /* @__PURE__ */ jsx("span", { className: "font-bold text-foreground", children: value })
27708
27736
  ]
27709
27737
  }
27710
27738
  );
@@ -27722,11 +27750,11 @@ var init_StatBadge = __esm({
27722
27750
  lg: "text-base px-4 py-2"
27723
27751
  };
27724
27752
  variantMap2 = {
27725
- default: "bg-[var(--color-card)]/80 border-gray-700",
27726
- primary: "bg-blue-900/80 border-blue-700",
27727
- success: "bg-green-900/80 border-green-700",
27728
- warning: "bg-yellow-900/80 border-yellow-700",
27729
- danger: "bg-red-900/80 border-red-700"
27753
+ default: "bg-card/80 border-border text-foreground",
27754
+ primary: "bg-primary/15 border-primary/40 text-foreground",
27755
+ success: "bg-success/15 border-success/40 text-foreground",
27756
+ warning: "bg-warning/15 border-warning/40 text-foreground",
27757
+ danger: "bg-error/15 border-error/40 text-foreground"
27730
27758
  };
27731
27759
  StatBadge.displayName = "StatBadge";
27732
27760
  }
@@ -39896,9 +39924,45 @@ var init_List = __esm({
39896
39924
  List3.displayName = "List";
39897
39925
  }
39898
39926
  });
39899
- var DefaultEmptyDetail, MasterDetail;
39927
+ function MasterDetail({
39928
+ entity,
39929
+ masterFields,
39930
+ detailFields: _detailFields,
39931
+ // Captured but not used here - detail handled separately
39932
+ loading: externalLoading,
39933
+ isLoading: externalIsLoading,
39934
+ error: externalError,
39935
+ className,
39936
+ ...rest
39937
+ }) {
39938
+ const loading = externalLoading ?? false;
39939
+ const isLoading = externalIsLoading ?? false;
39940
+ const error = externalError ?? null;
39941
+ return /* @__PURE__ */ jsx(
39942
+ DataTable,
39943
+ {
39944
+ fields: masterFields,
39945
+ columns: masterFields,
39946
+ entity,
39947
+ isLoading: loading || isLoading,
39948
+ error,
39949
+ className,
39950
+ emptyTitle: "No items found",
39951
+ emptyDescription: "Create your first item to get started.",
39952
+ ...rest
39953
+ }
39954
+ );
39955
+ }
39900
39956
  var init_MasterDetail = __esm({
39901
- "components/organisms/layout/MasterDetail.tsx"() {
39957
+ "components/organisms/MasterDetail.tsx"() {
39958
+ "use client";
39959
+ init_DataTable();
39960
+ MasterDetail.displayName = "MasterDetail";
39961
+ }
39962
+ });
39963
+ var DefaultEmptyDetail, MasterDetailLayout;
39964
+ var init_MasterDetailLayout = __esm({
39965
+ "components/organisms/layout/MasterDetailLayout.tsx"() {
39902
39966
  init_cn();
39903
39967
  init_Typography();
39904
39968
  DefaultEmptyDetail = () => /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full border-2 border-dashed border-border", children: /* @__PURE__ */ jsx(
@@ -39909,7 +39973,7 @@ var init_MasterDetail = __esm({
39909
39973
  children: "Select an item to view details"
39910
39974
  }
39911
39975
  ) });
39912
- MasterDetail = ({
39976
+ MasterDetailLayout = ({
39913
39977
  master,
39914
39978
  detail,
39915
39979
  emptyDetail,
@@ -39944,7 +40008,7 @@ var init_MasterDetail = __esm({
39944
40008
  }
39945
40009
  );
39946
40010
  };
39947
- MasterDetail.displayName = "MasterDetail";
40011
+ MasterDetailLayout.displayName = "MasterDetailLayout";
39948
40012
  }
39949
40013
  });
39950
40014
  var COLUMN_CLASSES, ASPECT_CLASSES, MediaGallery;
@@ -42362,7 +42426,7 @@ function getAllEvents(traits2) {
42362
42426
  }
42363
42427
  function EventDispatcherTab({ traits: traits2, schema }) {
42364
42428
  const eventBus = useEventBus();
42365
- const [log4, setLog] = React147.useState([]);
42429
+ const [log18, setLog] = React147.useState([]);
42366
42430
  const prevStatesRef = React147.useRef(/* @__PURE__ */ new Map());
42367
42431
  React147.useEffect(() => {
42368
42432
  for (const trait of traits2) {
@@ -42426,9 +42490,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
42426
42490
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
42427
42491
  /* @__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
42492
  ] }),
42429
- log4.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
42493
+ log18.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
42430
42494
  /* @__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: [
42495
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log18.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
42432
42496
  /* @__PURE__ */ jsx("span", { className: "text-purple-400", children: entry.traitName }),
42433
42497
  " ",
42434
42498
  /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -46798,10 +46862,11 @@ var init_Canvas3DErrorBoundary = __esm({
46798
46862
  "components/organisms/game/three/components/Canvas3DErrorBoundary.css"() {
46799
46863
  }
46800
46864
  });
46801
- var Canvas3DErrorBoundary;
46865
+ var log11, Canvas3DErrorBoundary;
46802
46866
  var init_Canvas3DErrorBoundary2 = __esm({
46803
46867
  "components/organisms/game/three/components/Canvas3DErrorBoundary.tsx"() {
46804
46868
  init_Canvas3DErrorBoundary();
46869
+ log11 = createLogger("almadar:ui:game:canvas3d:error-boundary");
46805
46870
  Canvas3DErrorBoundary = class extends Component {
46806
46871
  constructor(props) {
46807
46872
  super(props);
@@ -46829,8 +46894,8 @@ var init_Canvas3DErrorBoundary2 = __esm({
46829
46894
  componentDidCatch(error, errorInfo) {
46830
46895
  this.setState({ errorInfo });
46831
46896
  this.props.onError?.(error, errorInfo);
46832
- console.error("[Canvas3DErrorBoundary] Error caught:", error);
46833
- console.error("[Canvas3DErrorBoundary] Component stack:", errorInfo.componentStack);
46897
+ log11.error("Error caught", { error });
46898
+ log11.error("Component stack", { componentStack: errorInfo.componentStack ?? "<none>" });
46834
46899
  }
46835
46900
  render() {
46836
46901
  if (this.state.hasError) {
@@ -46893,7 +46958,7 @@ function useGLTFModel(url, resourceBasePath) {
46893
46958
  setState({ model: null, isLoading: false, error: null });
46894
46959
  return;
46895
46960
  }
46896
- console.log("[ModelLoader] Loading:", url);
46961
+ log12.debug("Loading", { url });
46897
46962
  setState((prev) => ({ ...prev, isLoading: true, error: null }));
46898
46963
  const assetRoot = resourceBasePath || detectAssetRoot(url);
46899
46964
  const loader = new GLTFLoader();
@@ -46901,7 +46966,7 @@ function useGLTFModel(url, resourceBasePath) {
46901
46966
  loader.load(
46902
46967
  url,
46903
46968
  (gltf) => {
46904
- console.log("[ModelLoader] Loaded:", url);
46969
+ log12.debug("Loaded", { url });
46905
46970
  setState({
46906
46971
  model: gltf.scene,
46907
46972
  isLoading: false,
@@ -46910,8 +46975,7 @@ function useGLTFModel(url, resourceBasePath) {
46910
46975
  },
46911
46976
  void 0,
46912
46977
  (err) => {
46913
- const errorMsg = err instanceof Error ? err.message : String(err);
46914
- console.warn("[ModelLoader] Failed:", url, errorMsg);
46978
+ log12.warn("Failed", { url, error: err instanceof Error ? err : String(err) });
46915
46979
  setState({
46916
46980
  model: null,
46917
46981
  isLoading: false,
@@ -47027,9 +47091,11 @@ function ModelLoader({
47027
47091
  }
47028
47092
  );
47029
47093
  }
47094
+ var log12;
47030
47095
  var init_ModelLoader = __esm({
47031
47096
  "components/organisms/game/three/components/ModelLoader.tsx"() {
47032
47097
  "use client";
47098
+ log12 = createLogger("almadar:ui:game:model-loader");
47033
47099
  }
47034
47100
  });
47035
47101
  function PhysicsObject3D({
@@ -47120,13 +47186,13 @@ function PhysicsObject3D({
47120
47186
  }
47121
47187
  function usePhysics3DController(entityId) {
47122
47188
  const applyForce = (fx, fy, fz) => {
47123
- console.log(`Apply force to ${entityId}:`, { fx, fy, fz });
47189
+ log13.debug("apply force", { entityId, fx, fy, fz });
47124
47190
  };
47125
47191
  const setVelocity = (vx, vy, vz) => {
47126
- console.log(`Set velocity for ${entityId}:`, { vx, vy, vz });
47192
+ log13.debug("set velocity", { entityId, vx, vy, vz });
47127
47193
  };
47128
47194
  const setPosition = (x, y, z) => {
47129
- console.log(`Set position for ${entityId}:`, { x, y, z });
47195
+ log13.debug("set position", { entityId, x, y, z });
47130
47196
  };
47131
47197
  const jump = (force = 10) => {
47132
47198
  applyForce(0, force, 0);
@@ -47138,10 +47204,12 @@ function usePhysics3DController(entityId) {
47138
47204
  jump
47139
47205
  };
47140
47206
  }
47207
+ var log13;
47141
47208
  var init_PhysicsObject3D = __esm({
47142
47209
  "components/organisms/game/three/components/PhysicsObject3D.tsx"() {
47143
47210
  "use client";
47144
47211
  init_ModelLoader();
47212
+ log13 = createLogger("almadar:ui:game:physics");
47145
47213
  }
47146
47214
  });
47147
47215
  function detectAssetRoot2(modelUrl) {
@@ -48727,14 +48795,16 @@ function preloadFeatures(urls) {
48727
48795
  const loader = new GLTFLoader();
48728
48796
  loader.setResourcePath(detectAssetRoot3(url));
48729
48797
  loader.load(url, () => {
48730
- console.log("[FeatureRenderer3D] Preloaded:", url);
48798
+ log14.debug("Preloaded", { url });
48731
48799
  });
48732
48800
  }
48733
48801
  });
48734
48802
  }
48803
+ var log14;
48735
48804
  var init_FeatureRenderer3D = __esm({
48736
48805
  "components/organisms/game/three/renderers/FeatureRenderer3D.tsx"() {
48737
48806
  "use client";
48807
+ log14 = createLogger("almadar:ui:game:feature-renderer");
48738
48808
  }
48739
48809
  });
48740
48810
 
@@ -52165,6 +52235,7 @@ var init_component_registry_generated = __esm({
52165
52235
  init_LoadingState();
52166
52236
  init_MarkdownContent();
52167
52237
  init_MasterDetail();
52238
+ init_MasterDetailLayout();
52168
52239
  init_MatrixQuestion();
52169
52240
  init_MediaGallery();
52170
52241
  init_Meter();
@@ -52459,6 +52530,7 @@ var init_component_registry_generated = __esm({
52459
52530
  "MapViewPattern": MapViewPattern,
52460
52531
  "MarkdownContent": MarkdownContent,
52461
52532
  "MasterDetail": MasterDetail,
52533
+ "MasterDetailLayout": MasterDetailLayout,
52462
52534
  "MatrixQuestion": MatrixQuestion,
52463
52535
  "MediaGallery": MediaGallery,
52464
52536
  "Menu": MenuPattern,
@@ -53216,7 +53288,7 @@ function SlotContentRenderer({
53216
53288
  }) {
53217
53289
  const entityProp = content.props.entity;
53218
53290
  if (content.pattern === "form-section") {
53219
- slotLog2.debug("SlotContentRenderer:form-section-render", {
53291
+ slotLog.debug("SlotContentRenderer:form-section-render", {
53220
53292
  contentId: content.id,
53221
53293
  sourceTrait: content.sourceTrait,
53222
53294
  entityRefId: refId(entityProp),
@@ -56262,6 +56334,7 @@ init_EventBusProvider();
56262
56334
 
56263
56335
  // providers/SelectionProvider.tsx
56264
56336
  init_useEventBus();
56337
+ var log4 = createLogger("almadar:ui:selection");
56265
56338
  var SelectionContext = createContext(null);
56266
56339
  var defaultCompareEntities = (a, b) => {
56267
56340
  if (a === b) return true;
@@ -56284,7 +56357,10 @@ function SelectionProvider({
56284
56357
  (entity) => {
56285
56358
  setSelectedState(entity);
56286
56359
  if (debug2) {
56287
- console.log("[SelectionProvider] Selection set:", entity);
56360
+ log4.debug("Selection set", () => ({
56361
+ hasEntity: entity !== null && entity !== void 0,
56362
+ entityId: entity && typeof entity === "object" ? String(entity.id ?? "") : ""
56363
+ }));
56288
56364
  }
56289
56365
  },
56290
56366
  [debug2]
@@ -56292,7 +56368,7 @@ function SelectionProvider({
56292
56368
  const clearSelection = useCallback(() => {
56293
56369
  setSelectedState(null);
56294
56370
  if (debug2) {
56295
- console.log("[SelectionProvider] Selection cleared");
56371
+ log4.debug("Selection cleared");
56296
56372
  }
56297
56373
  }, [debug2]);
56298
56374
  const isSelected = useCallback(
@@ -56307,14 +56383,17 @@ function SelectionProvider({
56307
56383
  if (row) {
56308
56384
  setSelected(row);
56309
56385
  if (debug2) {
56310
- console.log(`[SelectionProvider] ${event.type} received:`, row);
56386
+ log4.debug("event received", () => ({
56387
+ type: event.type,
56388
+ rowId: row && typeof row === "object" ? String(row.id ?? "") : ""
56389
+ }));
56311
56390
  }
56312
56391
  }
56313
56392
  };
56314
56393
  const handleDeselect = (event) => {
56315
56394
  clearSelection();
56316
56395
  if (debug2) {
56317
- console.log(`[SelectionProvider] ${event.type} received - clearing selection`);
56396
+ log4.debug("event received - clearing selection", { type: event.type });
56318
56397
  }
56319
56398
  };
56320
56399
  const unsubView = eventBus.on("UI:VIEW", handleSelect);
@@ -56345,7 +56424,7 @@ init_UISlotRenderer();
56345
56424
  // providers/VerificationProvider.tsx
56346
56425
  init_useEventBus();
56347
56426
  init_verificationRegistry();
56348
- var log3 = createLogger("almadar:verify");
56427
+ var log15 = createLogger("almadar:verify");
56349
56428
  var DISPATCH_SUFFIX = ":DISPATCH";
56350
56429
  var SUCCESS_SUFFIX = ":SUCCESS";
56351
56430
  var ERROR_SUFFIX = ":ERROR";
@@ -56391,7 +56470,7 @@ function VerificationProvider({
56391
56470
  const verificationProviderLifecycleListener = (evt) => {
56392
56471
  const parsed = parseLifecycleEvent(evt.type);
56393
56472
  if (!parsed) return;
56394
- log3.debug("lifecycle:event", { kind: parsed.kind, traitName: parsed.traitName, event: parsed.event, type: evt.type });
56473
+ log15.debug("lifecycle:event", { kind: parsed.kind, traitName: parsed.traitName, event: parsed.event, type: evt.type });
56395
56474
  const payload = evt.payload ?? {};
56396
56475
  if (parsed.kind === "dispatch") {
56397
56476
  const key = `${parsed.traitName}:${String(payload["event"] ?? "")}`;
@@ -56446,7 +56525,7 @@ function VerificationProvider({
56446
56525
  },
56447
56526
  timestamp: Date.now()
56448
56527
  });
56449
- log3.debug("transition:success", { trait: parsed.traitName, event: parsed.event, from: pending?.from, to: newState, effectCount: effects.length });
56528
+ log15.debug("transition:success", { trait: parsed.traitName, event: parsed.event, from: pending?.from, to: newState, effectCount: effects.length });
56450
56529
  } else if (parsed.kind === "error" && parsed.event) {
56451
56530
  const key = `${parsed.traitName}:${parsed.event}`;
56452
56531
  const pending = pendingRef.current.get(key);
@@ -56476,7 +56555,7 @@ function VerificationProvider({
56476
56555
  },
56477
56556
  timestamp: Date.now()
56478
56557
  });
56479
- log3.warn("transition:error", { trait: parsed.traitName, event: parsed.event, from: fromState, error: errorMsg });
56558
+ log15.warn("transition:error", { trait: parsed.traitName, event: parsed.event, from: fromState, error: errorMsg });
56480
56559
  }
56481
56560
  };
56482
56561
  Object.defineProperty(verificationProviderLifecycleListener, "name", {
@@ -56629,7 +56708,11 @@ function useResolvedSchema(schema, pageName) {
56629
56708
  };
56630
56709
  }
56631
56710
  const page = getPage(ir, pageName);
56632
- console.log("[useResolvedSchema] Resolved page:", page?.name, "| path:", page?.path, "| traits:", page?.traits.length);
56711
+ resolvedSchemaLog.debug("Resolved page", () => ({
56712
+ name: page?.name,
56713
+ path: page?.path,
56714
+ traits: page?.traits.length
56715
+ }));
56633
56716
  const traits2 = page?.traits || [];
56634
56717
  const entities = /* @__PURE__ */ new Map();
56635
56718
  if (page) {
@@ -56832,8 +56915,7 @@ function convertFnFormLambdasInProps(props) {
56832
56915
  // hooks/index.ts
56833
56916
  init_useEventBus();
56834
56917
  var ALMADAR_DND_MIME = "application/x-almadar-dnd";
56835
-
56836
- // runtime/createClientEffectHandlers.ts
56918
+ var log16 = createLogger("almadar:ui:effects:client-handlers");
56837
56919
  function createClientEffectHandlers(options) {
56838
56920
  const { eventBus, slotSetter, navigate, notify, callService } = options;
56839
56921
  return {
@@ -56842,10 +56924,10 @@ function createClientEffectHandlers(options) {
56842
56924
  eventBus.emit(prefixedEvent, payload);
56843
56925
  },
56844
56926
  persist: async () => {
56845
- console.warn("[ClientEffectHandlers] persist is server-side only, ignored on client");
56927
+ log16.warn("persist is server-side only, ignored on client");
56846
56928
  },
56847
56929
  set: () => {
56848
- console.warn("[ClientEffectHandlers] set is server-side only, ignored on client");
56930
+ log16.warn("set is server-side only, ignored on client");
56849
56931
  },
56850
56932
  callService: async (service, action, params) => {
56851
56933
  if (callService) return callService(service, action, params);
@@ -56874,10 +56956,10 @@ function createClientEffectHandlers(options) {
56874
56956
  slotSetter.addPattern(slot, pattern, props);
56875
56957
  },
56876
56958
  navigate: navigate ?? ((path) => {
56877
- console.warn("[ClientEffectHandlers] No navigate handler, ignoring:", path);
56959
+ log16.warn("No navigate handler, ignoring", { path });
56878
56960
  }),
56879
56961
  notify: notify ?? ((msg, type) => {
56880
- console.log(`[ClientEffectHandlers] notify (${type}):`, msg);
56962
+ log16.debug("notify", { type, message: msg });
56881
56963
  })
56882
56964
  };
56883
56965
  }
@@ -57072,10 +57154,9 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57072
57154
  });
57073
57155
  snapshotUnregs.push(unreg);
57074
57156
  }
57075
- console.log(
57076
- "[TraitStateMachine] Reset states for page navigation:",
57077
- Array.from(newManager.getAllStates().keys()).join(", ")
57078
- );
57157
+ stateLog.debug("reset-states-for-nav", () => ({
57158
+ traits: Array.from(newManager.getAllStates().keys()).join(", ")
57159
+ }));
57079
57160
  return () => {
57080
57161
  for (const unreg of snapshotUnregs) unreg();
57081
57162
  };
@@ -57162,9 +57243,9 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57162
57243
  const normalizedEvent = normalizeEventKey(eventKey);
57163
57244
  const bindings = traitBindingsRef.current;
57164
57245
  const currentManager = managerRef.current;
57165
- console.log("[TraitStateMachine] Processing event:", normalizedEvent, "payload:", payload);
57166
57246
  crossTraitLog.debug("processEvent:enter", () => ({
57167
57247
  event: normalizedEvent,
57248
+ payload: JSON.stringify(payload ?? null),
57168
57249
  traitCount: bindings.length,
57169
57250
  traitNames: bindings.map((b) => b.trait.name).join(","),
57170
57251
  orbitalsByTrait: JSON.stringify(orbitalsByTrait ?? null)
@@ -57223,18 +57304,13 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57223
57304
  }
57224
57305
  }
57225
57306
  if (result.executed && result.effects.length > 0) {
57226
- console.log(
57227
- "[TraitStateMachine] Executing",
57228
- result.effects.length,
57229
- "effects for",
57307
+ stateLog.debug("executing-effects", () => ({
57308
+ effectCount: result.effects.length,
57230
57309
  traitName,
57231
- "| linkedEntity:",
57232
- binding.linkedEntity,
57233
- "| transition:",
57234
- `${result.previousState} -> ${result.newState}`,
57235
- "| effects:",
57236
- JSON.stringify(result.effects)
57237
- );
57310
+ linkedEntity: binding.linkedEntity,
57311
+ transition: `${result.previousState} -> ${result.newState}`,
57312
+ effects: JSON.stringify(result.effects)
57313
+ }));
57238
57314
  const linkedEntity = binding.linkedEntity || "";
57239
57315
  const entityId = payload?.entityId;
57240
57316
  const pendingSlots = /* @__PURE__ */ new Map();
@@ -57380,30 +57456,25 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57380
57456
  }
57381
57457
  } else if (!result.executed) {
57382
57458
  if (result.guardResult === false) {
57383
- console.log(
57384
- "[TraitStateMachine] Guard blocked transition:",
57459
+ stateLog.debug("guard-blocked-transition", {
57385
57460
  traitName,
57386
- result.previousState,
57387
- "->",
57388
- result.transition?.to
57389
- );
57461
+ from: result.previousState,
57462
+ to: result.transition?.to
57463
+ });
57390
57464
  } else if (!result.transition) {
57391
57465
  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
- );
57466
+ stateLog.warn("closed-circuit-violation", {
57467
+ traitName,
57468
+ currentState: traitState.currentState,
57469
+ event: normalizedEvent,
57470
+ 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.`
57471
+ });
57398
57472
  } else {
57399
- console.log(
57400
- "[TraitStateMachine] No transition for",
57473
+ stateLog.debug("no-transition", {
57401
57474
  traitName,
57402
- "from state:",
57403
- traitState.currentState,
57404
- "on event:",
57405
- normalizedEvent
57406
- );
57475
+ from: traitState.currentState,
57476
+ event: normalizedEvent
57477
+ });
57407
57478
  }
57408
57479
  }
57409
57480
  }
@@ -57511,7 +57582,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
57511
57582
  allEvents.add(transition.event);
57512
57583
  }
57513
57584
  }
57514
- console.log("[TraitStateMachine] Subscribing to events:", Array.from(allEvents));
57585
+ stateLog.debug("subscribing-to-events", () => ({ events: Array.from(allEvents) }));
57515
57586
  const unsubscribes = [];
57516
57587
  const subscribedBusKeys = /* @__PURE__ */ new Set();
57517
57588
  for (const binding of traitBindings) {
@@ -57589,6 +57660,7 @@ init_EntitySchemaContext();
57589
57660
  // runtime/ServerBridge.tsx
57590
57661
  init_useEventBus();
57591
57662
  var xOrbitalLog = createLogger("almadar:runtime:cross-orbital");
57663
+ var serverBridgeLog = createLogger("almadar:ui:server-bridge");
57592
57664
  function createHttpTransport(serverUrl) {
57593
57665
  return {
57594
57666
  register: async (schema) => {
@@ -57601,7 +57673,7 @@ function createHttpTransport(serverUrl) {
57601
57673
  const result = await res.json();
57602
57674
  return !!result.success;
57603
57675
  } catch (err) {
57604
- console.error("[ServerBridge] Registration failed:", err);
57676
+ serverBridgeLog.error("Registration failed", { error: err instanceof Error ? err : String(err) });
57605
57677
  return false;
57606
57678
  }
57607
57679
  },
@@ -58349,7 +58421,7 @@ function entityNameOf(ref) {
58349
58421
  }
58350
58422
  var eventHandleLog = createLogger("almadar:ui:nan-coord");
58351
58423
  var orbPreviewLog = createLogger("almadar:ui:orb-preview-node");
58352
- orbPreviewLog.info("module-init", { browserPlayground: typeof BrowserPlayground });
58424
+ orbPreviewLog.debug("module-init", () => ({ browserPlayground: typeof BrowserPlayground }));
58353
58425
  var ScreenSizeContext = createContext("tablet");
58354
58426
  var PatternSelectionContext = createContext({ selected: null, select: () => {
58355
58427
  } });
@@ -58806,11 +58878,11 @@ var OrbPreviewNodeInner = (props) => {
58806
58878
  };
58807
58879
  var OrbPreviewNode = React147__default.memo(OrbPreviewNodeInner);
58808
58880
  OrbPreviewNode.displayName = "OrbPreviewNode";
58809
- orbPreviewLog.info("export-resolved", {
58881
+ orbPreviewLog.debug("export-resolved", () => ({
58810
58882
  type: typeof OrbPreviewNode,
58811
- displayName: OrbPreviewNode.displayName,
58883
+ displayName: OrbPreviewNode.displayName ?? null,
58812
58884
  innerDefined: typeof OrbPreviewNodeInner === "function"
58813
- });
58885
+ }));
58814
58886
  var edgeLog = createLogger("almadar:ui:nan-coord");
58815
58887
  var EventFlowEdgeInner = (props) => {
58816
58888
  const {
@@ -59642,12 +59714,12 @@ var NODE_TYPES = {
59642
59714
  preview: OrbPreviewNode,
59643
59715
  behaviorCompose: BehaviorComposeNode
59644
59716
  };
59645
- flowCanvasLog.info("node-type-registry", {
59717
+ flowCanvasLog.debug("node-type-registry", () => ({
59646
59718
  registered: Object.keys(NODE_TYPES),
59647
59719
  preview: typeof OrbPreviewNode,
59648
59720
  previewIsValid: typeof OrbPreviewNode === "function" || typeof OrbPreviewNode === "object" && OrbPreviewNode !== null,
59649
59721
  behaviorCompose: typeof BehaviorComposeNode
59650
- });
59722
+ }));
59651
59723
  var DEFAULT_EDGE_OPTIONS = {
59652
59724
  markerEnd: { type: MarkerType.ArrowClosed, width: 12, height: 12 }
59653
59725
  };
@@ -60105,6 +60177,7 @@ init_AvlTransitionLane();
60105
60177
  init_AvlSwimLane();
60106
60178
  init_types();
60107
60179
  init_avl_elk_layout();
60180
+ var log17 = createLogger("almadar:ui:avl:trait-scene");
60108
60181
  var SWIM_GUTTER2 = 120;
60109
60182
  var CENTER_W2 = 360;
60110
60183
  var AvlTraitScene = ({
@@ -60115,7 +60188,9 @@ var AvlTraitScene = ({
60115
60188
  const [layout, setLayout] = useState(null);
60116
60189
  const dataKey = useMemo(() => JSON.stringify(data), [data]);
60117
60190
  useEffect(() => {
60118
- computeTraitLayout(data).then(setLayout).catch(console.error);
60191
+ computeTraitLayout(data).then(setLayout).catch((error) => {
60192
+ log17.error("computeTraitLayout failed", { error: error instanceof Error ? error : String(error) });
60193
+ });
60119
60194
  }, [dataKey]);
60120
60195
  if (!layout) {
60121
60196
  return /* @__PURE__ */ jsx("g", { children: /* @__PURE__ */ jsx("text", { x: 300, y: 200, textAnchor: "middle", fill: color, fontSize: 12, opacity: 0.5, children: "Computing layout..." }) });