@almadar/ui 5.113.0 → 5.114.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.
@@ -11,6 +11,7 @@ var reactDom = require('react-dom');
11
11
  var hooks = require('@almadar/ui/hooks');
12
12
  var context = require('@almadar/ui/context');
13
13
  var evaluator = require('@almadar/evaluator');
14
+ var ui = require('@almadar/runtime/ui');
14
15
  var reactRouterDom = require('react-router-dom');
15
16
  var ELK = require('elkjs/lib/elk.bundled.js');
16
17
  var SyntaxHighlighter = require('react-syntax-highlighter/dist/esm/prism-light.js');
@@ -43,6 +44,7 @@ var utilities = require('@dnd-kit/utilities');
43
44
  var react = require('@xyflow/react');
44
45
  var patterns = require('@almadar/core/patterns');
45
46
  var runtime = require('@almadar/runtime');
47
+ var registry = require('@almadar/std/registry');
46
48
  var OrbitalServerRuntime = require('@almadar/runtime/OrbitalServerRuntime');
47
49
 
48
50
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -1062,41 +1064,6 @@ function kebabToPascal(name) {
1062
1064
  return part.charAt(0).toUpperCase() + part.slice(1);
1063
1065
  }).join("");
1064
1066
  }
1065
- function loadLib(key, importer) {
1066
- let p = libPromises.get(key);
1067
- if (!p) {
1068
- p = importer();
1069
- libPromises.set(key, p);
1070
- }
1071
- return p;
1072
- }
1073
- function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
1074
- const Lazy = React81__namespace.default.lazy(async () => {
1075
- const lib = await loadLib(libKey, importer);
1076
- const Comp = pick(lib);
1077
- if (!Comp) {
1078
- warnFallback(fallbackName, family);
1079
- return { default: makeLucideAdapter(fallbackName, true) };
1080
- }
1081
- return { default: Comp };
1082
- });
1083
- const Wrapped = (props) => /* @__PURE__ */ jsxRuntime.jsx(
1084
- React81__namespace.default.Suspense,
1085
- {
1086
- fallback: /* @__PURE__ */ jsxRuntime.jsx(
1087
- "span",
1088
- {
1089
- "aria-hidden": true,
1090
- className: props.className,
1091
- style: { display: "inline-block", ...props.style }
1092
- }
1093
- ),
1094
- children: /* @__PURE__ */ jsxRuntime.jsx(Lazy, { ...props })
1095
- }
1096
- );
1097
- Wrapped.displayName = `Lazy.${libKey}.${fallbackName}`;
1098
- return Wrapped;
1099
- }
1100
1067
  function isComponentLike(v) {
1101
1068
  return v != null && (typeof v === "function" || typeof v === "object");
1102
1069
  }
@@ -1110,146 +1077,32 @@ function resolveLucide(name) {
1110
1077
  if (isComponentLike(asIs)) return asIs;
1111
1078
  return LucideIcons2__namespace.HelpCircle;
1112
1079
  }
1113
- function resolvePhosphor(name, weight, family) {
1114
- const target = phosphorAliases[name] ?? kebabToPascal(name);
1115
- return lazyFamilyIcon(
1116
- "phosphor",
1117
- () => import('@phosphor-icons/react'),
1118
- (lib) => {
1119
- const PhosphorComp = lib[target];
1120
- if (!PhosphorComp) return null;
1121
- const Component = PhosphorComp;
1122
- const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
1123
- Component,
1124
- {
1125
- weight,
1126
- className: props.className,
1127
- style: props.style,
1128
- size: props.size ?? "1em"
1129
- }
1130
- );
1131
- Adapter.displayName = `Phosphor.${target}.${weight}`;
1132
- return Adapter;
1133
- },
1134
- name,
1135
- family
1136
- );
1137
- }
1138
- function resolveTabler(name, family) {
1139
- const suffix = tablerAliases[name] ?? kebabToPascal(name);
1140
- const target = `Icon${suffix}`;
1141
- return lazyFamilyIcon(
1142
- "tabler",
1143
- () => import('@tabler/icons-react'),
1144
- (lib) => {
1145
- const TablerComp = lib[target];
1146
- if (!TablerComp) return null;
1147
- const Component = TablerComp;
1148
- const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
1149
- Component,
1150
- {
1151
- stroke: props.strokeWidth ?? 1.5,
1152
- className: props.className,
1153
- style: props.style,
1154
- size: props.size ?? 24
1155
- }
1156
- );
1157
- Adapter.displayName = `Tabler.${target}`;
1158
- return Adapter;
1159
- },
1160
- name,
1161
- family
1162
- );
1163
- }
1164
- function resolveFa(name, family) {
1165
- const suffix = faAliases[name] ?? kebabToPascal(name);
1166
- const target = `Fa${suffix}`;
1167
- return lazyFamilyIcon(
1168
- "fa",
1169
- () => import('react-icons/fa'),
1170
- (lib) => {
1171
- const FaComp = lib[target];
1172
- if (!FaComp) return null;
1173
- const Component = FaComp;
1174
- const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
1175
- Component,
1176
- {
1177
- className: props.className,
1178
- style: props.style,
1179
- size: props.size ?? "1em"
1180
- }
1181
- );
1182
- Adapter.displayName = `Fa.${target}`;
1183
- return Adapter;
1184
- },
1185
- name,
1186
- family
1187
- );
1188
- }
1189
- function warnFallback(name, family) {
1190
- const key = `${family}::${name}`;
1191
- if (warned.has(key)) return;
1192
- warned.add(key);
1193
- if (typeof console !== "undefined") {
1194
- console.warn(
1195
- `[iconFamily] No '${name}' mapping in family '${family}'; falling back to lucide. Add an alias in lib/iconFamily.ts.`
1196
- );
1197
- }
1198
- }
1199
- function makeLucideAdapter(name, isFallback = false) {
1080
+ function makeLucideAdapter(name) {
1200
1081
  const LucideComp = resolveLucide(name);
1201
- const Adapter = (props) => {
1202
- const stroke = props.strokeWidth ?? (isFallback ? 2 : void 0);
1203
- const style = isFallback ? { ...props.style ?? {}, strokeWidth: stroke ?? 2 } : props.style;
1204
- return /* @__PURE__ */ jsxRuntime.jsx(
1205
- LucideComp,
1206
- {
1207
- className: props.className,
1208
- strokeWidth: stroke,
1209
- style,
1210
- size: props.size
1211
- }
1212
- );
1213
- };
1214
- Adapter.displayName = `Lucide.${name}${isFallback ? ".fallback" : ""}`;
1082
+ const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
1083
+ LucideComp,
1084
+ {
1085
+ className: props.className,
1086
+ strokeWidth: props.strokeWidth,
1087
+ style: props.style,
1088
+ size: props.size
1089
+ }
1090
+ );
1091
+ Adapter.displayName = `Lucide.${name}`;
1215
1092
  return Adapter;
1216
1093
  }
1217
- function resolveIconForFamily(name, family) {
1218
- switch (family) {
1219
- case "lucide":
1220
- return makeLucideAdapter(name, false);
1221
- // Non-lucide families resolve to a lazy, Suspense-wrapped component that
1222
- // dynamic-imports the library on first render and falls back to lucide
1223
- // internally when the family lacks the icon (see lazyFamilyIcon).
1224
- case "phosphor-outline":
1225
- return resolvePhosphor(name, "regular", family);
1226
- case "phosphor-fill":
1227
- return resolvePhosphor(name, "fill", family);
1228
- case "phosphor-duotone":
1229
- return resolvePhosphor(name, "duotone", family);
1230
- case "tabler":
1231
- return resolveTabler(name, family);
1232
- case "fa-solid":
1233
- return resolveFa(name, family);
1234
- }
1235
- }
1236
- var DEFAULT_FAMILY, VALID_FAMILIES, cachedFamily, listeners, observer, libPromises, lucideAliases, phosphorAliases, tablerAliases, faAliases, warned;
1094
+ function resolveIconForFamily(name, _family) {
1095
+ return makeLucideAdapter(name);
1096
+ }
1097
+ var DEFAULT_FAMILY, VALID_FAMILIES, cachedFamily, listeners, observer, lucideAliases;
1237
1098
  var init_iconFamily = __esm({
1238
1099
  "lib/iconFamily.tsx"() {
1239
1100
  "use client";
1240
1101
  DEFAULT_FAMILY = "lucide";
1241
- VALID_FAMILIES = [
1242
- "lucide",
1243
- "phosphor-outline",
1244
- "phosphor-fill",
1245
- "phosphor-duotone",
1246
- "tabler",
1247
- "fa-solid"
1248
- ];
1102
+ VALID_FAMILIES = [DEFAULT_FAMILY];
1249
1103
  cachedFamily = null;
1250
1104
  listeners = /* @__PURE__ */ new Set();
1251
1105
  observer = null;
1252
- libPromises = /* @__PURE__ */ new Map();
1253
1106
  lucideAliases = {
1254
1107
  close: LucideIcons2__namespace.X,
1255
1108
  trash: LucideIcons2__namespace.Trash2,
@@ -1262,478 +1115,6 @@ var init_iconFamily = __esm({
1262
1115
  "sort-asc": LucideIcons2__namespace.ArrowUpNarrowWide,
1263
1116
  "sort-desc": LucideIcons2__namespace.ArrowDownNarrowWide
1264
1117
  };
1265
- phosphorAliases = {
1266
- // lucide name → phosphor PascalCase name
1267
- // Actions
1268
- plus: "Plus",
1269
- minus: "Minus",
1270
- x: "X",
1271
- check: "Check",
1272
- close: "X",
1273
- edit: "PencilSimple",
1274
- pencil: "PencilSimple",
1275
- trash: "Trash",
1276
- save: "FloppyDisk",
1277
- copy: "Copy",
1278
- share: "Share",
1279
- send: "PaperPlaneRight",
1280
- download: "DownloadSimple",
1281
- upload: "UploadSimple",
1282
- archive: "Archive",
1283
- refresh: "ArrowsClockwise",
1284
- loader: "CircleNotch",
1285
- link: "Link",
1286
- paperclip: "Paperclip",
1287
- // Navigation
1288
- "chevron-down": "CaretDown",
1289
- "chevron-up": "CaretUp",
1290
- "chevron-left": "CaretLeft",
1291
- "chevron-right": "CaretRight",
1292
- "arrow-up": "ArrowUp",
1293
- "arrow-down": "ArrowDown",
1294
- "arrow-left": "ArrowLeft",
1295
- "arrow-right": "ArrowRight",
1296
- menu: "List",
1297
- more: "DotsThree",
1298
- "more-vertical": "DotsThreeVertical",
1299
- "more-horizontal": "DotsThree",
1300
- external: "ArrowSquareOut",
1301
- "external-link": "ArrowSquareOut",
1302
- // Files
1303
- file: "File",
1304
- "file-text": "FileText",
1305
- "file-plus": "FilePlus",
1306
- "file-minus": "FileMinus",
1307
- folder: "Folder",
1308
- "folder-open": "FolderOpen",
1309
- document: "FileText",
1310
- // Charts
1311
- "bar-chart": "ChartBar",
1312
- "bar-chart-2": "ChartBar",
1313
- "bar-chart-3": "ChartBar",
1314
- "line-chart": "ChartLine",
1315
- "pie-chart": "ChartPie",
1316
- activity: "Pulse",
1317
- "trending-up": "TrendUp",
1318
- "trending-down": "TrendDown",
1319
- // Messages
1320
- message: "ChatCircle",
1321
- "message-circle": "ChatCircle",
1322
- "message-square": "ChatText",
1323
- "messages-square": "ChatsCircle",
1324
- comment: "ChatCircle",
1325
- comments: "ChatsCircle",
1326
- inbox: "Tray",
1327
- mail: "Envelope",
1328
- envelope: "Envelope",
1329
- // Status
1330
- "alert-circle": "WarningCircle",
1331
- "alert-triangle": "Warning",
1332
- "check-circle": "CheckCircle",
1333
- "x-circle": "XCircle",
1334
- info: "Info",
1335
- "help-circle": "Question",
1336
- "life-buoy": "Lifebuoy",
1337
- lifebuoy: "Lifebuoy",
1338
- warning: "Warning",
1339
- error: "WarningCircle",
1340
- // Media
1341
- image: "Image",
1342
- video: "VideoCamera",
1343
- film: "FilmStrip",
1344
- camera: "Camera",
1345
- music: "MusicNote",
1346
- play: "Play",
1347
- pause: "Pause",
1348
- stop: "Stop",
1349
- "skip-forward": "SkipForward",
1350
- "skip-back": "SkipBack",
1351
- volume: "SpeakerHigh",
1352
- "volume-2": "SpeakerHigh",
1353
- "volume-x": "SpeakerX",
1354
- mic: "Microphone",
1355
- "mic-off": "MicrophoneSlash",
1356
- // People
1357
- user: "User",
1358
- users: "Users",
1359
- "user-plus": "UserPlus",
1360
- "user-check": "UserCheck",
1361
- // Time
1362
- calendar: "Calendar",
1363
- clock: "Clock",
1364
- timer: "Timer",
1365
- // Location
1366
- map: "MapTrifold",
1367
- "map-pin": "MapPin",
1368
- navigation: "NavigationArrow",
1369
- compass: "Compass",
1370
- globe: "Globe",
1371
- target: "Target",
1372
- // Project / layout
1373
- kanban: "Kanban",
1374
- list: "List",
1375
- table: "Table",
1376
- grid: "GridFour",
1377
- layout: "Layout",
1378
- columns: "Columns",
1379
- rows: "Rows",
1380
- // Misc
1381
- bell: "Bell",
1382
- bookmark: "Bookmark",
1383
- briefcase: "Briefcase",
1384
- flag: "Flag",
1385
- tag: "Tag",
1386
- tags: "Tag",
1387
- star: "Star",
1388
- heart: "Heart",
1389
- home: "House",
1390
- settings: "Gear",
1391
- eye: "Eye",
1392
- "eye-off": "EyeSlash",
1393
- lock: "Lock",
1394
- unlock: "LockOpen",
1395
- key: "Key",
1396
- shield: "Shield",
1397
- search: "MagnifyingGlass",
1398
- filter: "Funnel",
1399
- "sort-asc": "SortAscending",
1400
- "sort-desc": "SortDescending",
1401
- zap: "Lightning",
1402
- sparkles: "Sparkle",
1403
- // Code
1404
- code: "Code",
1405
- terminal: "Terminal",
1406
- database: "Database",
1407
- server: "HardDrives",
1408
- cloud: "Cloud",
1409
- wifi: "WifiHigh",
1410
- package: "Package",
1411
- box: "Package",
1412
- // Theme
1413
- sun: "Sun",
1414
- moon: "Moon",
1415
- // Phone
1416
- phone: "Phone",
1417
- printer: "Printer",
1418
- // Hierarchy
1419
- tree: "Tree",
1420
- network: "Network"
1421
- };
1422
- tablerAliases = {
1423
- // lucide name → tabler suffix (after the `Icon` prefix)
1424
- // Actions
1425
- plus: "Plus",
1426
- minus: "Minus",
1427
- x: "X",
1428
- check: "Check",
1429
- close: "X",
1430
- edit: "Pencil",
1431
- pencil: "Pencil",
1432
- trash: "Trash",
1433
- save: "DeviceFloppy",
1434
- copy: "Copy",
1435
- share: "Share",
1436
- send: "Send",
1437
- download: "Download",
1438
- upload: "Upload",
1439
- archive: "Archive",
1440
- refresh: "Refresh",
1441
- loader: "Loader2",
1442
- link: "Link",
1443
- paperclip: "Paperclip",
1444
- external: "ExternalLink",
1445
- "external-link": "ExternalLink",
1446
- // Navigation
1447
- "chevron-down": "ChevronDown",
1448
- "chevron-up": "ChevronUp",
1449
- "chevron-left": "ChevronLeft",
1450
- "chevron-right": "ChevronRight",
1451
- "arrow-down": "ArrowDown",
1452
- "arrow-up": "ArrowUp",
1453
- "arrow-left": "ArrowLeft",
1454
- "arrow-right": "ArrowRight",
1455
- menu: "Menu2",
1456
- more: "Dots",
1457
- "more-vertical": "DotsVertical",
1458
- // Files
1459
- file: "File",
1460
- "file-text": "FileText",
1461
- "file-plus": "FilePlus",
1462
- "file-check": "FileCheck",
1463
- "file-minus": "FileMinus",
1464
- folder: "Folder",
1465
- "folder-open": "FolderOpen",
1466
- document: "FileText",
1467
- // Charts
1468
- "bar-chart": "ChartBar",
1469
- "bar-chart-2": "ChartBar",
1470
- "bar-chart-3": "ChartBar",
1471
- "line-chart": "ChartLine",
1472
- "pie-chart": "ChartPie",
1473
- activity: "Activity",
1474
- "trending-up": "TrendingUp",
1475
- "trending-down": "TrendingDown",
1476
- // Messages
1477
- message: "Message",
1478
- "message-circle": "MessageCircle",
1479
- "message-square": "Message2",
1480
- "messages-square": "Messages",
1481
- comment: "Message",
1482
- comments: "Messages",
1483
- inbox: "Inbox",
1484
- mail: "Mail",
1485
- envelope: "Mail",
1486
- // Status
1487
- "alert-circle": "AlertCircle",
1488
- "alert-triangle": "AlertTriangle",
1489
- "check-circle": "CircleCheck",
1490
- "x-circle": "CircleX",
1491
- info: "InfoCircle",
1492
- "help-circle": "HelpCircle",
1493
- "life-buoy": "Lifebuoy",
1494
- warning: "AlertTriangle",
1495
- error: "AlertOctagon",
1496
- // Media
1497
- image: "Photo",
1498
- video: "Video",
1499
- camera: "Camera",
1500
- music: "Music",
1501
- play: "PlayerPlay",
1502
- pause: "PlayerPause",
1503
- stop: "PlayerStop",
1504
- "skip-forward": "PlayerSkipForward",
1505
- "skip-back": "PlayerSkipBack",
1506
- volume: "Volume",
1507
- "volume-2": "Volume",
1508
- "volume-x": "VolumeOff",
1509
- mic: "Microphone",
1510
- "mic-off": "MicrophoneOff",
1511
- // People
1512
- user: "User",
1513
- users: "Users",
1514
- "user-plus": "UserPlus",
1515
- "user-check": "UserCheck",
1516
- // Time
1517
- calendar: "Calendar",
1518
- clock: "Clock",
1519
- timer: "Hourglass",
1520
- // Location
1521
- map: "Map",
1522
- "map-pin": "MapPin",
1523
- navigation: "Navigation",
1524
- compass: "Compass",
1525
- globe: "World",
1526
- target: "Target",
1527
- // Project / layout
1528
- kanban: "LayoutKanban",
1529
- list: "List",
1530
- table: "Table",
1531
- grid: "LayoutGrid",
1532
- layout: "Layout",
1533
- columns: "LayoutColumns",
1534
- rows: "LayoutRows",
1535
- // Misc
1536
- bell: "Bell",
1537
- bookmark: "Bookmark",
1538
- briefcase: "Briefcase",
1539
- flag: "Flag",
1540
- tag: "Tag",
1541
- tags: "Tags",
1542
- star: "Star",
1543
- heart: "Heart",
1544
- home: "Home",
1545
- settings: "Settings",
1546
- eye: "Eye",
1547
- "eye-off": "EyeOff",
1548
- lock: "Lock",
1549
- unlock: "LockOpen",
1550
- key: "Key",
1551
- shield: "Shield",
1552
- search: "Search",
1553
- filter: "Filter",
1554
- "sort-asc": "SortAscending",
1555
- "sort-desc": "SortDescending",
1556
- zap: "Bolt",
1557
- sparkles: "Sparkles",
1558
- // Code / data
1559
- code: "Code",
1560
- terminal: "Terminal",
1561
- database: "Database",
1562
- server: "Server",
1563
- cloud: "Cloud",
1564
- wifi: "Wifi",
1565
- package: "Package",
1566
- box: "Box",
1567
- // Theme
1568
- sun: "Sun",
1569
- moon: "Moon",
1570
- // Phone
1571
- phone: "Phone",
1572
- printer: "Printer",
1573
- // Hierarchy
1574
- tree: "Hierarchy",
1575
- network: "Network"
1576
- };
1577
- faAliases = {
1578
- // lucide name → fa-solid suffix (after the `Fa` prefix).
1579
- // react-icons/fa ships FontAwesome 5 — names like `FaFileText` don't exist
1580
- // (FA renamed to `FaFileAlt`). When you see a console.warn from
1581
- // [iconFamily] about an unmapped lucide name in this family, add the
1582
- // closest FA5 sibling here so the fallback stays in-family.
1583
- search: "Search",
1584
- close: "Times",
1585
- x: "Times",
1586
- loader: "Spinner",
1587
- refresh: "Sync",
1588
- "sort-asc": "SortAmountUp",
1589
- "sort-desc": "SortAmountDown",
1590
- "chevron-down": "ChevronDown",
1591
- "chevron-up": "ChevronUp",
1592
- "chevron-left": "ChevronLeft",
1593
- "chevron-right": "ChevronRight",
1594
- "help-circle": "QuestionCircle",
1595
- "alert-triangle": "ExclamationTriangle",
1596
- "alert-circle": "ExclamationCircle",
1597
- "check-circle": "CheckCircle",
1598
- "x-circle": "TimesCircle",
1599
- edit: "Edit",
1600
- pencil: "PencilAlt",
1601
- trash: "Trash",
1602
- send: "PaperPlane",
1603
- share: "ShareAlt",
1604
- external: "ExternalLinkAlt",
1605
- plus: "Plus",
1606
- minus: "Minus",
1607
- check: "Check",
1608
- star: "Star",
1609
- heart: "Heart",
1610
- home: "Home",
1611
- user: "User",
1612
- users: "Users",
1613
- "user-plus": "UserPlus",
1614
- "user-check": "UserCheck",
1615
- settings: "Cog",
1616
- menu: "Bars",
1617
- "arrow-up": "ArrowUp",
1618
- "arrow-down": "ArrowDown",
1619
- "arrow-left": "ArrowLeft",
1620
- "arrow-right": "ArrowRight",
1621
- copy: "Copy",
1622
- download: "Download",
1623
- upload: "Upload",
1624
- filter: "Filter",
1625
- calendar: "Calendar",
1626
- clock: "Clock",
1627
- bell: "Bell",
1628
- mail: "Envelope",
1629
- envelope: "Envelope",
1630
- lock: "Lock",
1631
- unlock: "LockOpen",
1632
- eye: "Eye",
1633
- "eye-off": "EyeSlash",
1634
- more: "EllipsisH",
1635
- "more-vertical": "EllipsisV",
1636
- info: "InfoCircle",
1637
- warning: "ExclamationTriangle",
1638
- error: "ExclamationCircle",
1639
- // Time
1640
- timer: "Hourglass",
1641
- // Files (FA renamed FileText → FileAlt)
1642
- file: "File",
1643
- "file-text": "FileAlt",
1644
- "file-plus": "FileMedical",
1645
- "file-minus": "FileExcel",
1646
- "file-check": "FileSignature",
1647
- document: "FileAlt",
1648
- // Charts (lucide BarChart2 / BarChart3 → FA ChartBar)
1649
- "bar-chart": "ChartBar",
1650
- "bar-chart-2": "ChartBar",
1651
- "bar-chart-3": "ChartBar",
1652
- "line-chart": "ChartLine",
1653
- "pie-chart": "ChartPie",
1654
- activity: "ChartLine",
1655
- "trending-up": "ChartLine",
1656
- "trending-down": "ChartLine",
1657
- // Messages (lucide MessageCircle/MessageSquare → FA CommentDots/CommentAlt)
1658
- message: "Comment",
1659
- "message-circle": "CommentDots",
1660
- "message-square": "CommentAlt",
1661
- "messages-square": "Comments",
1662
- comment: "Comment",
1663
- comments: "Comments",
1664
- inbox: "Inbox",
1665
- // Support / help
1666
- "life-buoy": "LifeRing",
1667
- lifebuoy: "LifeRing",
1668
- // Project / kanban (FA has no kanban; closest semantic is Tasks/Columns)
1669
- kanban: "Tasks",
1670
- columns: "Columns",
1671
- rows: "Bars",
1672
- layout: "ThLarge",
1673
- grid: "Th",
1674
- list: "List",
1675
- table: "Table",
1676
- // Storage / folders
1677
- folder: "Folder",
1678
- "folder-open": "FolderOpen",
1679
- archive: "Archive",
1680
- bookmark: "Bookmark",
1681
- briefcase: "Briefcase",
1682
- package: "Box",
1683
- box: "Box",
1684
- // Map / location
1685
- map: "Map",
1686
- "map-pin": "MapMarkerAlt",
1687
- navigation: "LocationArrow",
1688
- compass: "Compass",
1689
- globe: "Globe",
1690
- target: "Bullseye",
1691
- // Media
1692
- image: "Image",
1693
- video: "Video",
1694
- film: "Film",
1695
- camera: "Camera",
1696
- music: "Music",
1697
- play: "Play",
1698
- pause: "Pause",
1699
- stop: "Stop",
1700
- "skip-forward": "Forward",
1701
- "skip-back": "Backward",
1702
- volume: "VolumeUp",
1703
- "volume-2": "VolumeUp",
1704
- "volume-x": "VolumeMute",
1705
- mic: "Microphone",
1706
- "mic-off": "MicrophoneSlash",
1707
- phone: "Phone",
1708
- // Code / data
1709
- code: "Code",
1710
- terminal: "Terminal",
1711
- database: "Database",
1712
- server: "Server",
1713
- cloud: "Cloud",
1714
- wifi: "Wifi",
1715
- // Security
1716
- shield: "ShieldAlt",
1717
- key: "Key",
1718
- // Misc actions
1719
- printer: "Print",
1720
- save: "Save",
1721
- link: "Link",
1722
- unlink: "Unlink",
1723
- paperclip: "Paperclip",
1724
- flag: "Flag",
1725
- tag: "Tag",
1726
- tags: "Tags",
1727
- zap: "Bolt",
1728
- sparkles: "Magic",
1729
- // Theme
1730
- sun: "Sun",
1731
- moon: "Moon",
1732
- // Hierarchy (FA has no Tree icon for hierarchies; Sitemap is the org-chart icon)
1733
- tree: "Sitemap",
1734
- network: "NetworkWired"
1735
- };
1736
- warned = /* @__PURE__ */ new Set();
1737
1118
  }
1738
1119
  });
1739
1120
  function kebabToPascal2(name) {
@@ -1814,7 +1195,7 @@ var init_Icon = __esm({
1814
1195
  const family = useIconFamily();
1815
1196
  const RenderedComponent = React81__namespace.default.useMemo(() => {
1816
1197
  if (directIcon) return null;
1817
- return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
1198
+ return effectiveName ? resolveIconForFamily(effectiveName) : null;
1818
1199
  }, [directIcon, effectiveName, family]);
1819
1200
  const effectiveStrokeWidth = strokeWidth ?? void 0;
1820
1201
  const inlineStyle = {
@@ -2193,7 +1574,7 @@ var init_Button = __esm({
2193
1574
  ref,
2194
1575
  disabled: disabled || isLoading,
2195
1576
  className: cn(
2196
- "inline-flex items-center justify-center gap-2",
1577
+ "relative inline-flex items-center justify-center gap-2",
2197
1578
  "font-medium",
2198
1579
  "rounded-sm",
2199
1580
  "cursor-pointer",
@@ -3961,6 +3342,7 @@ var init_Input = __esm({
3961
3342
  icon: iconProp,
3962
3343
  clearable,
3963
3344
  onClear,
3345
+ action,
3964
3346
  value,
3965
3347
  options,
3966
3348
  rows = 3,
@@ -4010,6 +3392,11 @@ var init_Input = __esm({
4010
3392
  onClear?.();
4011
3393
  }
4012
3394
  };
3395
+ const handleKeyDown = (e) => {
3396
+ if (action && e.key === "Enter") {
3397
+ eventBus.emit(`UI:${action}`, { value: e.currentTarget.value });
3398
+ }
3399
+ };
4013
3400
  const wrapField = (field) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
4014
3401
  label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "block text-sm font-medium text-foreground mb-1", children: label }),
4015
3402
  field,
@@ -4083,6 +3470,7 @@ var init_Input = __esm({
4083
3470
  type,
4084
3471
  value,
4085
3472
  onChange: handleChange,
3473
+ onKeyDown: handleKeyDown,
4086
3474
  className: baseClassName,
4087
3475
  ...props
4088
3476
  }
@@ -4615,7 +4003,7 @@ var init_Card = __esm({
4615
4003
  });
4616
4004
  function GameIcon({ assetUrl, icon, size = "md", alt, className }) {
4617
4005
  const px = typeof size === "number" ? size : sizeMap[size];
4618
- const family = useIconFamily();
4006
+ useIconFamily();
4619
4007
  if (assetUrl?.url) {
4620
4008
  return /* @__PURE__ */ jsxRuntime.jsx(
4621
4009
  AtlasImage,
@@ -4627,7 +4015,7 @@ function GameIcon({ assetUrl, icon, size = "md", alt, className }) {
4627
4015
  }
4628
4016
  );
4629
4017
  }
4630
- const I = typeof icon === "string" ? resolveIconForFamily(icon, family) : icon;
4018
+ const I = typeof icon === "string" ? resolveIconForFamily(icon) : icon;
4631
4019
  return /* @__PURE__ */ jsxRuntime.jsx(I, { width: px, height: px, className: cn("flex-shrink-0", className) });
4632
4020
  }
4633
4021
  var sizeMap;
@@ -7024,8 +6412,8 @@ function Seigaiha({ size, color, strokeWidth }) {
7024
6412
  [s, s * 0.1]
7025
6413
  ];
7026
6414
  for (const [cx, cy] of centers) {
7027
- for (let ring2 = 1; ring2 <= 3; ring2++) {
7028
- const cr = r * (ring2 / 3);
6415
+ for (let ring = 1; ring <= 3; ring++) {
6416
+ const cr = r * (ring / 3);
7029
6417
  paths.push(
7030
6418
  `M ${f(cx - cr)},${f(cy)} A ${f(cr)} ${f(cr)} 0 0 1 ${f(cx + cr)},${f(cy)}`
7031
6419
  );
@@ -7122,8 +6510,8 @@ function Arch({ size, color, strokeWidth }) {
7122
6510
  const h = size * 1.5;
7123
6511
  const cx = w / 2;
7124
6512
  const paths = [];
7125
- for (let ring2 = 0; ring2 < 4; ring2++) {
7126
- const scale = 1 - ring2 * 0.2;
6513
+ for (let ring = 0; ring < 4; ring++) {
6514
+ const scale = 1 - ring * 0.2;
7127
6515
  const archW = w * 0.48 * scale;
7128
6516
  const archH = h * 0.7 * scale;
7129
6517
  const baseY = h * 0.85;
@@ -7138,7 +6526,7 @@ function Arch({ size, color, strokeWidth }) {
7138
6526
  paths.push(
7139
6527
  `M ${f(lx)},${f(baseY)} A ${f(radius)} ${f(radius)} 0 0 1 ${f(cx)},${f(tipY)} A ${f(radius)} ${f(radius)} 0 0 1 ${f(rx)},${f(baseY)}`
7140
6528
  );
7141
- if (ring2 === 0) {
6529
+ if (ring === 0) {
7142
6530
  paths.push(`M ${f(lx)},${f(baseY)} L ${f(rx)},${f(baseY)}`);
7143
6531
  }
7144
6532
  }
@@ -9546,9 +8934,9 @@ var init_webPainter2d = __esm({
9546
8934
  // lib/drawable/projector.ts
9547
8935
  function create2DProjector(opts) {
9548
8936
  const { scale, baseOffsetX, layout } = opts;
9549
- const tileWidth = TILE_WIDTH * scale;
9550
- const floorHeight = FLOOR_HEIGHT * scale;
9551
- const diamondTopY = (opts.diamondTopY ?? DIAMOND_TOP_Y) * scale;
8937
+ const tileWidth = layout === "free" ? 1 : TILE_WIDTH * scale;
8938
+ const floorHeight = layout === "free" ? 1 : FLOOR_HEIGHT * scale;
8939
+ const diamondTopY = layout === "free" ? 0 : (opts.diamondTopY ?? DIAMOND_TOP_Y) * scale;
9552
8940
  const squareGrid = layout === "flat" || layout === "free";
9553
8941
  const project = (pos) => layout === "free" ? { x: pos.x, y: pos.y } : isoToScreen(pos.x, pos.y, scale, baseOffsetX, layout);
9554
8942
  const anchorPoint = (pos, anchor) => {
@@ -9589,6 +8977,15 @@ var init_projector = __esm({
9589
8977
  }
9590
8978
  });
9591
8979
 
8980
+ // lib/drawable/contract.ts
8981
+ function isValidScenePos(pos) {
8982
+ return Number.isFinite(pos?.x) && Number.isFinite(pos?.y);
8983
+ }
8984
+ var init_contract = __esm({
8985
+ "lib/drawable/contract.ts"() {
8986
+ }
8987
+ });
8988
+
9592
8989
  // components/game/atoms/DrawSprite.tsx
9593
8990
  function DrawSprite(_props) {
9594
8991
  return null;
@@ -9598,10 +8995,12 @@ var init_DrawSprite = __esm({
9598
8995
  "components/game/atoms/DrawSprite.tsx"() {
9599
8996
  "use client";
9600
8997
  init_atlasSlice();
8998
+ init_contract();
9601
8999
  paintSprite = (painter, node, dctx) => {
9000
+ if (!node.asset?.url || !isValidScenePos(node.position)) return;
9602
9001
  const tex = painter.resolveTexture(node.asset.url);
9603
9002
  if (!tex) return;
9604
- let src = node.frame;
9003
+ let src = typeof node.frame === "object" ? node.frame : void 0;
9605
9004
  if (!src && isAtlasAsset(node.asset)) {
9606
9005
  const atlas = getAtlas(node.asset.atlas, dctx.invalidate);
9607
9006
  if (!atlas) return;
@@ -9646,7 +9045,9 @@ var paintShape;
9646
9045
  var init_DrawShape = __esm({
9647
9046
  "components/game/atoms/DrawShape.tsx"() {
9648
9047
  "use client";
9048
+ init_contract();
9649
9049
  paintShape = (painter, node, dctx) => {
9050
+ if (!isValidScenePos(node.position)) return;
9650
9051
  painter.save();
9651
9052
  if (node.opacity !== void 0 && node.opacity !== 1) painter.setAlpha(node.opacity);
9652
9053
  switch (node.shape) {
@@ -9700,7 +9101,9 @@ var paintText;
9700
9101
  var init_DrawText = __esm({
9701
9102
  "components/game/atoms/DrawText.tsx"() {
9702
9103
  "use client";
9104
+ init_contract();
9703
9105
  paintText = (painter, node, dctx) => {
9106
+ if (!isValidScenePos(node.position)) return;
9704
9107
  const p = dctx.projector.anchorPoint(node.position, node.anchor ?? "center");
9705
9108
  const x = p.x + (node.offsetX ?? 0);
9706
9109
  const y = p.y + (node.offsetY ?? 0);
@@ -9805,12 +9208,14 @@ function collectDrawnItems(nodes) {
9805
9208
  case "draw-sprite":
9806
9209
  case "draw-shape":
9807
9210
  case "draw-text":
9808
- out.push({ pos: n.position, id: n.id });
9211
+ if (isValidScenePos(n.position)) out.push({ pos: n.position, id: n.id });
9809
9212
  break;
9810
9213
  case "draw-sprite-layer":
9811
9214
  case "draw-shape-layer":
9812
9215
  case "draw-text-layer":
9813
- for (const it of n.items) out.push({ pos: it.position, id: it.id });
9216
+ for (const it of n.items) {
9217
+ if (isValidScenePos(it.position)) out.push({ pos: it.position, id: it.id });
9218
+ }
9814
9219
  break;
9815
9220
  }
9816
9221
  }
@@ -9825,6 +9230,7 @@ function buildHitIndex(items) {
9825
9230
  }
9826
9231
  var init_hitTest = __esm({
9827
9232
  "lib/drawable/hitTest.ts"() {
9233
+ init_contract();
9828
9234
  }
9829
9235
  });
9830
9236
  function normalizeBackdrop(bg) {
@@ -11864,21 +11270,6 @@ var init_renderer = __esm({
11864
11270
  init_slot_definitions();
11865
11271
  }
11866
11272
  });
11867
-
11868
- // lib/wrapCallbackForEvent.ts
11869
- function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
11870
- const argNames = (callbackArgs ?? []).map((a) => a.name);
11871
- if (argNames.length === 0) {
11872
- return () => emit(qualifiedEvent);
11873
- }
11874
- return (...args) => {
11875
- const payload = {};
11876
- for (let i = 0; i < argNames.length; i += 1) {
11877
- payload[argNames[i]] = args[i];
11878
- }
11879
- emit(qualifiedEvent, payload);
11880
- };
11881
- }
11882
11273
  var init_wrapCallbackForEvent = __esm({
11883
11274
  "lib/wrapCallbackForEvent.ts"() {
11884
11275
  }
@@ -22769,7 +22160,8 @@ function DataGrid({
22769
22160
  const { t } = hooks.useTranslate();
22770
22161
  const [selectedIds, setSelectedIds] = React81.useState(/* @__PURE__ */ new Set());
22771
22162
  const [visibleCount, setVisibleCount] = React81.useState(pageSize || Infinity);
22772
- const fieldDefs = fields ?? columns ?? [];
22163
+ const fieldDefs = (Array.isArray(fields) ? fields : void 0) ?? (Array.isArray(columns) ? columns : void 0) ?? [];
22164
+ const actionDefs = Array.isArray(itemActions) ? itemActions : [];
22773
22165
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
22774
22166
  const dnd = useDataDnd({
22775
22167
  items: allDataRaw,
@@ -22813,8 +22205,8 @@ function DataGrid({
22813
22205
  const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
22814
22206
  const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
22815
22207
  const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
22816
- const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
22817
- const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
22208
+ const primaryActions = actionDefs.filter((a) => a.variant !== "danger");
22209
+ const dangerActions = actionDefs.filter((a) => a.variant === "danger");
22818
22210
  const handleActionClick = (action, itemData) => (e) => {
22819
22211
  e.stopPropagation();
22820
22212
  const payload = {
@@ -35344,7 +34736,7 @@ function measureLabelWidth(text) {
35344
34736
  if (typeof document === "undefined") return text.length * 6;
35345
34737
  if (!labelMeasureCtx) labelMeasureCtx = document.createElement("canvas").getContext("2d");
35346
34738
  if (!labelMeasureCtx) return text.length * 6;
35347
- labelMeasureCtx.font = "10px system-ui";
34739
+ labelMeasureCtx.font = "12px system-ui";
35348
34740
  return labelMeasureCtx.measureText(text).width;
35349
34741
  }
35350
34742
  function getGroupColor(group, groups) {
@@ -35390,6 +34782,7 @@ var init_GraphCanvas = __esm({
35390
34782
  actions,
35391
34783
  onNodeClick,
35392
34784
  onNodeDoubleClick,
34785
+ onBadgeClick,
35393
34786
  nodeClickEvent,
35394
34787
  selectedNodeId,
35395
34788
  repulsion = 800,
@@ -35537,7 +34930,9 @@ var init_GraphCanvas = __esm({
35537
34930
  const dx = target.x - source.x;
35538
34931
  const dy = target.y - source.y;
35539
34932
  const dist = Math.sqrt(dx * dx + dy * dy) || 1;
35540
- const force = (dist - linkDistance) * 0.05;
34933
+ const w2 = edge.weight ?? 1;
34934
+ const linkTarget = linkDistance * (1 + (1 - Math.min(1, Math.max(0, w2))) * 1.5);
34935
+ const force = (dist - linkTarget) * 0.05;
35541
34936
  const fx = dx / dist * force;
35542
34937
  const fy = dy / dist * force;
35543
34938
  source.fx += fx;
@@ -35559,7 +34954,7 @@ var init_GraphCanvas = __esm({
35559
34954
  node.y = Math.max(30, Math.min(h - 30, node.y));
35560
34955
  }
35561
34956
  const LABEL_GAP = 12;
35562
- const LABEL_H = 12;
34957
+ const LABEL_H = 16;
35563
34958
  const pad = nodeSpacing / 2;
35564
34959
  for (let i = 0; i < nodes.length; i++) {
35565
34960
  for (let j = i + 1; j < nodes.length; j++) {
@@ -35580,13 +34975,13 @@ var init_GraphCanvas = __esm({
35580
34975
  const overlapY = Math.min(aBot, bBot) - Math.max(aTop, bTop);
35581
34976
  if (overlapX > 0 && overlapY > 0) {
35582
34977
  if (overlapX <= overlapY) {
35583
- const push2 = overlapX / 2 * (b.x >= a.x ? 1 : -1);
35584
- a.x = Math.max(30, Math.min(w - 30, a.x - push2));
35585
- b.x = Math.max(30, Math.min(w - 30, b.x + push2));
34978
+ const push = overlapX / 2 * (b.x >= a.x ? 1 : -1);
34979
+ a.x = Math.max(30, Math.min(w - 30, a.x - push));
34980
+ b.x = Math.max(30, Math.min(w - 30, b.x + push));
35586
34981
  } else {
35587
- const push2 = overlapY / 2 * (bTop + bBot >= aTop + aBot ? 1 : -1);
35588
- a.y = Math.max(30, Math.min(h - 30, a.y - push2));
35589
- b.y = Math.max(30, Math.min(h - 30, b.y + push2));
34982
+ const push = overlapY / 2 * (bTop + bBot >= aTop + aBot ? 1 : -1);
34983
+ a.y = Math.max(30, Math.min(h - 30, a.y - push));
34984
+ b.y = Math.max(30, Math.min(h - 30, b.y + push));
35590
34985
  }
35591
34986
  }
35592
34987
  }
@@ -35614,6 +35009,11 @@ var init_GraphCanvas = __esm({
35614
35009
  const h = height;
35615
35010
  const nodes = nodesRef.current;
35616
35011
  const accentColor = resolveColor3("var(--color-accent)", canvas);
35012
+ const fontFamily = resolveColor3("var(--font-family)", canvas) || "system-ui";
35013
+ const fgColor = resolveColor3("var(--color-foreground)", canvas);
35014
+ const mutedColor = resolveColor3("var(--color-muted-foreground)", canvas) || fgColor;
35015
+ const bgColor = resolveColor3("var(--color-background)", canvas) || "#ffffff";
35016
+ const accentFg = resolveColor3("var(--color-accent-foreground)", canvas) || "#ffffff";
35617
35017
  const dpr = typeof window !== "undefined" && window.devicePixelRatio || 1;
35618
35018
  ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
35619
35019
  ctx.clearRect(0, 0, w, h);
@@ -35633,19 +35033,21 @@ var init_GraphCanvas = __esm({
35633
35033
  const target = nodes.find((n) => n.id === edge.target);
35634
35034
  if (!source || !target) continue;
35635
35035
  const incident = !!hoveredNode && (edge.source === hoveredNode || edge.target === hoveredNode);
35636
- ctx.globalAlpha = hoveredNode ? incident ? 1 : 0.05 : linkOpacity;
35036
+ const w2 = edge.weight ?? 1;
35037
+ ctx.globalAlpha = hoveredNode ? incident ? 1 : 0.05 : linkOpacity * w2;
35637
35038
  ctx.beginPath();
35638
35039
  ctx.moveTo(source.x, source.y);
35639
35040
  ctx.lineTo(target.x, target.y);
35640
35041
  ctx.strokeStyle = incident ? accentColor : edge.color || "#888888";
35641
- ctx.lineWidth = incident ? 2 : edge.weight ? Math.max(1, edge.weight) : 1;
35042
+ ctx.lineWidth = incident ? 2 : Math.max(0.75, w2);
35642
35043
  ctx.stroke();
35643
35044
  if (edge.label && showLabels) {
35644
35045
  const mx = (source.x + target.x) / 2;
35645
35046
  const my = (source.y + target.y) / 2;
35646
- ctx.fillStyle = "#888888";
35647
- ctx.font = "9px system-ui";
35047
+ ctx.fillStyle = mutedColor;
35048
+ ctx.font = `9px ${fontFamily}`;
35648
35049
  ctx.textAlign = "center";
35050
+ ctx.textBaseline = "alphabetic";
35649
35051
  ctx.fillText(edge.label, mx, my - 4);
35650
35052
  }
35651
35053
  }
@@ -35670,10 +35072,33 @@ var init_GraphCanvas = __esm({
35670
35072
  }
35671
35073
  ctx.stroke();
35672
35074
  if (showLabels && node.label) {
35673
- ctx.fillStyle = "#666666";
35674
- ctx.font = `${isSelected || isHovered ? "bold " : ""}10px system-ui`;
35075
+ ctx.font = `${isSelected || isHovered ? "600" : "500"} 12px ${fontFamily}`;
35076
+ ctx.textAlign = "center";
35077
+ ctx.textBaseline = "middle";
35078
+ const ly = node.y + radius + 14;
35079
+ ctx.lineWidth = 3;
35080
+ ctx.lineJoin = "round";
35081
+ ctx.strokeStyle = bgColor;
35082
+ ctx.strokeText(node.label, node.x, ly);
35083
+ ctx.fillStyle = isSelected || isHovered ? fgColor : mutedColor;
35084
+ ctx.fillText(node.label, node.x, ly);
35085
+ }
35086
+ if (node.badge && node.badge > 1) {
35087
+ const bx = node.x + radius * 0.7;
35088
+ const by = node.y - radius * 0.7;
35089
+ const br = Math.max(7, Math.min(11, radius * 0.45));
35090
+ ctx.beginPath();
35091
+ ctx.arc(bx, by, br, 0, Math.PI * 2);
35092
+ ctx.fillStyle = accentColor;
35093
+ ctx.fill();
35094
+ ctx.strokeStyle = bgColor;
35095
+ ctx.lineWidth = 2;
35096
+ ctx.stroke();
35097
+ ctx.fillStyle = accentFg;
35098
+ ctx.font = `600 9px ${fontFamily}`;
35675
35099
  ctx.textAlign = "center";
35676
- ctx.fillText(node.label, node.x, node.y + radius + 12);
35100
+ ctx.textBaseline = "middle";
35101
+ ctx.fillText(String(node.badge), bx, by + 0.5);
35677
35102
  }
35678
35103
  }
35679
35104
  ctx.restore();
@@ -35766,11 +35191,21 @@ var init_GraphCanvas = __esm({
35766
35191
  if (!coords) return;
35767
35192
  const node = nodeAt(coords.graphX, coords.graphY);
35768
35193
  if (node) {
35194
+ if (node.badge && node.badge > 1 && onBadgeClick) {
35195
+ const r = (node.size || 8) + (selectedNodeId === node.id ? 4 : 0);
35196
+ const bx = node.x + r * 0.7;
35197
+ const by = node.y - r * 0.7;
35198
+ const br = Math.max(7, Math.min(11, r * 0.45)) + 3;
35199
+ if (Math.hypot(coords.graphX - bx, coords.graphY - by) <= br) {
35200
+ onBadgeClick(node);
35201
+ return;
35202
+ }
35203
+ }
35769
35204
  handleNodeClick(node);
35770
35205
  }
35771
35206
  }
35772
35207
  },
35773
- [toCoords, nodeAt, handleNodeClick]
35208
+ [toCoords, nodeAt, handleNodeClick, onBadgeClick, selectedNodeId]
35774
35209
  );
35775
35210
  const handlePointerLeave = React81.useCallback(() => {
35776
35211
  setHoveredNode(null);
@@ -40291,7 +39726,7 @@ function getAllEvents(traits2) {
40291
39726
  function EventDispatcherTab({ traits: traits2, schema }) {
40292
39727
  const eventBus = useEventBus();
40293
39728
  const { t } = hooks.useTranslate();
40294
- const [log10, setLog] = React81__namespace.useState([]);
39729
+ const [log9, setLog] = React81__namespace.useState([]);
40295
39730
  const prevStatesRef = React81__namespace.useRef(/* @__PURE__ */ new Map());
40296
39731
  React81__namespace.useEffect(() => {
40297
39732
  for (const trait of traits2) {
@@ -40355,9 +39790,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
40355
39790
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: t("debug.otherEvents") }),
40356
39791
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
40357
39792
  ] }),
40358
- log10.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
39793
+ log9.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
40359
39794
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: t("debug.recentTransitions") }),
40360
- /* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children: log10.map((entry, i) => /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
39795
+ /* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children: log9.map((entry, i) => /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
40361
39796
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-400", children: entry.traitName }),
40362
39797
  " ",
40363
39798
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -43759,7 +43194,7 @@ function SlotContentRenderer({
43759
43194
  if (typeof propValue !== "string") continue;
43760
43195
  const propDef = propsSchema[propKey];
43761
43196
  if (!propDef || propDef.kind !== "callback") continue;
43762
- renderedProps[propKey] = wrapCallbackForEvent(
43197
+ renderedProps[propKey] = ui.wrapCallbackForEvent(
43763
43198
  `UI:${propValue}`,
43764
43199
  propDef.callbackArgs,
43765
43200
  (eventKey, payload) => eventBus.emit(eventKey, payload)
@@ -43994,27 +43429,27 @@ var log2 = logger.createLogger("almadar:ui:shared-entity-store");
43994
43429
  var EMPTY_ENTITY_STATE = {};
43995
43430
  function createSharedEntityStore() {
43996
43431
  const states = /* @__PURE__ */ new Map();
43997
- const subscribers2 = /* @__PURE__ */ new Map();
43998
- const getSnapshot3 = (entityId) => states.get(entityId) ?? EMPTY_ENTITY_STATE;
43999
- const subscribe2 = (entityId, callback) => {
44000
- let set = subscribers2.get(entityId);
43432
+ const subscribers = /* @__PURE__ */ new Map();
43433
+ const getSnapshot2 = (entityId) => states.get(entityId) ?? EMPTY_ENTITY_STATE;
43434
+ const subscribe = (entityId, callback) => {
43435
+ let set = subscribers.get(entityId);
44001
43436
  if (!set) {
44002
43437
  set = /* @__PURE__ */ new Set();
44003
- subscribers2.set(entityId, set);
43438
+ subscribers.set(entityId, set);
44004
43439
  }
44005
43440
  set.add(callback);
44006
43441
  return () => {
44007
- const current = subscribers2.get(entityId);
43442
+ const current = subscribers.get(entityId);
44008
43443
  if (!current) return;
44009
43444
  current.delete(callback);
44010
43445
  if (current.size === 0) {
44011
- subscribers2.delete(entityId);
43446
+ subscribers.delete(entityId);
44012
43447
  }
44013
43448
  };
44014
43449
  };
44015
43450
  const commit = (entityId, nextState) => {
44016
43451
  states.set(entityId, nextState);
44017
- const set = subscribers2.get(entityId);
43452
+ const set = subscribers.get(entityId);
44018
43453
  if (!set) return;
44019
43454
  set.forEach((callback) => {
44020
43455
  try {
@@ -44032,7 +43467,7 @@ function createSharedEntityStore() {
44032
43467
  states.set(entityId, initialState);
44033
43468
  }
44034
43469
  };
44035
- return { getSnapshot: getSnapshot3, subscribe: subscribe2, commit, seed };
43470
+ return { getSnapshot: getSnapshot2, subscribe, commit, seed };
44036
43471
  }
44037
43472
  function useSharedEntityStore() {
44038
43473
  const storeRef = React81.useRef(null);
@@ -44108,6 +43543,11 @@ function createClientEffectHandlers(options) {
44108
43543
  };
44109
43544
  }
44110
43545
  var lambdaLog = logger.createLogger("almadar:ui:fn-form-lambda");
43546
+ function isOperatorCall(value) {
43547
+ const first = value[0];
43548
+ if (typeof first !== "string") return false;
43549
+ return registry.isKnownStdOperator(first) || first.includes("/") || first === "lambda" || first === "let";
43550
+ }
44111
43551
  function isFnFormLambda(value) {
44112
43552
  if (!Array.isArray(value)) return false;
44113
43553
  const arr = value;
@@ -44147,7 +43587,14 @@ function resolveLambdaBindings(body, params, item, index) {
44147
43587
  return body;
44148
43588
  }
44149
43589
  if (Array.isArray(body)) {
44150
- return body.map((b) => recur(b));
43590
+ if (isFnFormLambda(body)) return body;
43591
+ const arr = body;
43592
+ const substituted = arr.map((b) => recur(b));
43593
+ if (isOperatorCall(substituted) && core.isSExpr(substituted)) {
43594
+ const evaluated = evaluator.evaluate(substituted, evaluator.createMinimalContext());
43595
+ return core.isEventPayloadValue(evaluated) ? evaluated : String(evaluated);
43596
+ }
43597
+ return substituted;
44151
43598
  }
44152
43599
  if (body !== null && typeof body === "object" && !React81__namespace.default.isValidElement(body) && !(body instanceof Date) && typeof body !== "function") {
44153
43600
  const out = {};
@@ -44344,8 +43791,8 @@ function getBindingConfig(binding) {
44344
43791
  function evalFieldDefault(value) {
44345
43792
  if (!Array.isArray(value) || value.length === 0) return value;
44346
43793
  const head = value[0];
44347
- const isSExpr = typeof head === "string" && (head.includes("/") || head === "let" || head === "if" || head === "lambda");
44348
- if (!isSExpr) return value;
43794
+ const isSExpr2 = typeof head === "string" && (head.includes("/") || head === "let" || head === "if" || head === "lambda");
43795
+ if (!isSExpr2) return value;
44349
43796
  try {
44350
43797
  return evaluator.evaluate(value, evaluator.createMinimalContext({}, {}, ""));
44351
43798
  } catch {
@@ -44419,7 +43866,9 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44419
43866
  const traitDefs = traitBindings.map(toTraitDefinition);
44420
43867
  const m = new runtime.StateMachineManager(traitDefs);
44421
43868
  for (const binding of traitBindings) {
44422
- const cfg = getBindingConfig(binding) ?? traitConfigsByName?.[binding.trait.name];
43869
+ const rawCfg = getBindingConfig(binding);
43870
+ const resolvedCfg = traitConfigsByName?.[binding.trait.name];
43871
+ const cfg = rawCfg || resolvedCfg ? { ...rawCfg ?? {}, ...resolvedCfg ?? {} } : void 0;
44423
43872
  if (cfg !== void 0) {
44424
43873
  m.setTraitConfig(binding.trait.name, cfg);
44425
43874
  }
@@ -44597,7 +44046,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44597
44046
  };
44598
44047
  }, [traitBindings]);
44599
44048
  const executeTransitionEffects = React81.useCallback(async (params) => {
44600
- const { binding, previousState, newState, payload, flushEvent, syncOnly, log: log10 } = params;
44049
+ const { binding, previousState, newState, payload, flushEvent, syncOnly, log: log9 } = params;
44601
44050
  const traitName = binding.trait.name;
44602
44051
  const linkedEntity = binding.linkedEntity || "";
44603
44052
  const entityId = payload?.entityId;
@@ -44671,10 +44120,20 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44671
44120
  state: previousState
44672
44121
  };
44673
44122
  const sharedDeclared = runtime.collectDeclaredConfigDefaults(binding.trait);
44674
- const sharedCallSite = getBindingConfig(binding);
44675
- if (sharedDeclared || sharedCallSite) {
44123
+ const sharedResolved = traitConfigsByName?.[traitName];
44124
+ const sharedCallSiteRaw = getBindingConfig(binding);
44125
+ const sharedCallSite = sharedCallSiteRaw ? runtime.resolveCallSitePayloadCaptures(
44126
+ Object.fromEntries(
44127
+ Object.entries(sharedCallSiteRaw).filter(
44128
+ ([, v]) => !(typeof v === "string" && v.startsWith("@config."))
44129
+ )
44130
+ ),
44131
+ payload || {}
44132
+ ) : void 0;
44133
+ if (sharedDeclared || sharedResolved || sharedCallSite) {
44676
44134
  sharedBindings.config = {
44677
44135
  ...sharedDeclared ?? {},
44136
+ ...sharedResolved ?? {},
44678
44137
  ...sharedCallSite ?? {}
44679
44138
  };
44680
44139
  }
@@ -44708,7 +44167,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44708
44167
  ...handlers,
44709
44168
  set: async (targetId, field, value) => {
44710
44169
  if (baseSet) await baseSet(targetId, field, value);
44711
- log10.debug("set:write", {
44170
+ log9.debug("set:write", {
44712
44171
  traitName,
44713
44172
  field,
44714
44173
  value: JSON.stringify(value),
@@ -44722,11 +44181,21 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44722
44181
  state: previousState
44723
44182
  };
44724
44183
  const declaredDefaults = runtime.collectDeclaredConfigDefaults(binding.trait);
44184
+ const resolvedDefaults = traitConfigsByName?.[traitName];
44725
44185
  const callSiteConfig = getBindingConfig(binding);
44726
- if (declaredDefaults || callSiteConfig) {
44186
+ const callSiteOverrides = callSiteConfig ? runtime.resolveCallSitePayloadCaptures(
44187
+ Object.fromEntries(
44188
+ Object.entries(callSiteConfig).filter(
44189
+ ([, v]) => !(typeof v === "string" && v.startsWith("@config."))
44190
+ )
44191
+ ),
44192
+ payload || {}
44193
+ ) : void 0;
44194
+ if (declaredDefaults || resolvedDefaults || callSiteOverrides) {
44727
44195
  bindingCtx.config = {
44728
44196
  ...declaredDefaults ?? {},
44729
- ...callSiteConfig ?? {}
44197
+ ...resolvedDefaults ?? {},
44198
+ ...callSiteOverrides ?? {}
44730
44199
  };
44731
44200
  }
44732
44201
  if (traitName === "Authority" || traitName === "Hero") {
@@ -44775,7 +44244,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44775
44244
  if (sharedKey !== void 0) {
44776
44245
  sharedEntityStore.commit(sharedKey, liveEntity);
44777
44246
  }
44778
- log10.debug("effects:executed", () => ({
44247
+ log9.debug("effects:executed", () => ({
44779
44248
  traitName,
44780
44249
  transition: `${previousState}->${newState}`,
44781
44250
  event: flushEvent,
@@ -44785,7 +44254,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44785
44254
  slotsTouched: Array.from(pendingSlots.keys()).join(",")
44786
44255
  }));
44787
44256
  for (const [slot, patterns] of pendingSlots) {
44788
- log10.debug("flush:slot", {
44257
+ log9.debug("flush:slot", {
44789
44258
  traitName,
44790
44259
  slot,
44791
44260
  patternCount: patterns.length,
@@ -44800,7 +44269,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44800
44269
  });
44801
44270
  }
44802
44271
  } catch (error) {
44803
- log10.error("effects:error", {
44272
+ log9.error("effects:error", {
44804
44273
  traitName,
44805
44274
  transition: `${previousState}->${newState}`,
44806
44275
  event: flushEvent,
@@ -44822,7 +44291,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44822
44291
  payload: {},
44823
44292
  state: currentState
44824
44293
  };
44825
- const bindingCfg = getBindingConfig(binding);
44294
+ const bindingCfg = getBindingConfig(binding) ?? traitConfigsByName?.[traitName];
44826
44295
  if (bindingCfg) {
44827
44296
  guardCtx.config = bindingCfg;
44828
44297
  }
@@ -45185,17 +44654,19 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
45185
44654
  }, [traitBindings, eventBus, enqueueAndDrain]);
45186
44655
  React81.useEffect(() => {
45187
44656
  const mgr = managerRef.current;
45188
- const inited = initedTraitsRef.current;
44657
+ const eventsToFire = /* @__PURE__ */ new Set();
45189
44658
  for (const binding of traitBindings) {
45190
44659
  const traitName = binding.trait.name;
45191
- if (inited.has(traitName)) continue;
45192
44660
  const lifecycleEvent = LIFECYCLE_EVENTS.find(
45193
44661
  (evt) => mgr.canHandleEvent(traitName, evt)
45194
44662
  );
45195
- if (lifecycleEvent === void 0) continue;
45196
- inited.add(traitName);
45197
- stateLog.debug("mount:fire-lifecycle", { traitName, event: lifecycleEvent });
45198
- enqueueAndDrain(lifecycleEvent, {});
44663
+ if (lifecycleEvent !== void 0) {
44664
+ eventsToFire.add(lifecycleEvent);
44665
+ }
44666
+ }
44667
+ for (const event of eventsToFire) {
44668
+ stateLog.debug("mount:fire-lifecycle", { event, traitCount: traitBindings.length });
44669
+ enqueueAndDrain(event, {});
45199
44670
  }
45200
44671
  return () => {
45201
44672
  initedTraitsRef.current = /* @__PURE__ */ new Set();
@@ -45310,343 +44781,8 @@ init_Typography();
45310
44781
  init_UISlotRenderer();
45311
44782
  init_useEventBus();
45312
44783
 
45313
- // lib/embedded-traits.ts
45314
- var TRAIT_BINDING_PREFIX = "@trait.";
45315
- function collectTraitRefsFromValue(value, into) {
45316
- if (value === null || value === void 0) return;
45317
- if (typeof value === "string") {
45318
- if (value.startsWith(TRAIT_BINDING_PREFIX)) {
45319
- const rest = value.slice(TRAIT_BINDING_PREFIX.length);
45320
- const dot = rest.indexOf(".");
45321
- const traitName = dot === -1 ? rest : rest.slice(0, dot);
45322
- if (traitName.length > 0) into.add(traitName);
45323
- }
45324
- return;
45325
- }
45326
- if (Array.isArray(value)) {
45327
- for (const item of value) collectTraitRefsFromValue(item, into);
45328
- return;
45329
- }
45330
- if (typeof value === "object") {
45331
- for (const v of Object.values(value)) {
45332
- collectTraitRefsFromValue(v, into);
45333
- }
45334
- }
45335
- }
45336
- function collectTraitRefsFromEffects(effects, into) {
45337
- if (!effects) return;
45338
- for (const effect of effects) {
45339
- if (!Array.isArray(effect)) continue;
45340
- if (effect[0] === "render-ui" && effect.length >= 3) {
45341
- collectTraitRefsFromValue(effect[2], into);
45342
- continue;
45343
- }
45344
- for (let i = 1; i < effect.length; i++) {
45345
- const arg = effect[i];
45346
- if (Array.isArray(arg)) collectTraitRefsFromEffects([arg], into);
45347
- else collectTraitRefsFromValue(arg, into);
45348
- }
45349
- }
45350
- }
45351
- function collectTraitRefsFromResolvedTrait(trait) {
45352
- const out = /* @__PURE__ */ new Set();
45353
- for (const transition of trait.transitions ?? []) {
45354
- collectTraitRefsFromEffects(transition.effects, out);
45355
- }
45356
- for (const tick of trait.ticks ?? []) {
45357
- collectTraitRefsFromEffects(tick.effects, out);
45358
- }
45359
- return out;
45360
- }
45361
- function collectEmbeddedTraits(schema) {
45362
- const out = /* @__PURE__ */ new Set();
45363
- if (!schema?.orbitals) return out;
45364
- for (const orbital of schema.orbitals) {
45365
- const traits2 = orbital.traits;
45366
- if (!Array.isArray(traits2)) continue;
45367
- for (const traitRef of traits2) {
45368
- if (!traitRef || typeof traitRef !== "object") continue;
45369
- const resolved = traitRef._resolved;
45370
- const target = resolved && typeof resolved === "object" ? resolved : traitRef;
45371
- if (target.config) {
45372
- collectTraitRefsFromValue(target.config, out);
45373
- }
45374
- const transitions = target.stateMachine?.transitions;
45375
- if (!Array.isArray(transitions)) continue;
45376
- for (const t of transitions) {
45377
- collectTraitRefsFromEffects(t.effects, out);
45378
- }
45379
- collectTraitRefsFromEffects(target.initialEffects, out);
45380
- const ticks2 = target.ticks;
45381
- if (Array.isArray(ticks2)) {
45382
- for (const tick of ticks2) {
45383
- collectTraitRefsFromEffects(tick.effects, out);
45384
- }
45385
- }
45386
- }
45387
- }
45388
- return out;
45389
- }
45390
-
45391
- // lib/orbitalsByTrait.ts
45392
- function buildOrbitalsByTrait(schema, resolvedPages = []) {
45393
- const map = {};
45394
- if (!schema?.orbitals) return map;
45395
- const pagePathToOrbital = {};
45396
- for (const orb of schema.orbitals) {
45397
- for (const traitRef of orb.traits ?? []) {
45398
- let traitName;
45399
- if (typeof traitRef === "string") {
45400
- const parts = traitRef.split(".");
45401
- traitName = parts[parts.length - 1];
45402
- } else if (typeof traitRef.ref === "string") {
45403
- const parts = traitRef.ref.split(".");
45404
- traitName = traitRef.name ?? parts[parts.length - 1];
45405
- } else if (typeof traitRef.name === "string") {
45406
- traitName = traitRef.name;
45407
- }
45408
- if (traitName) map[traitName] = orb.name;
45409
- }
45410
- for (const pg of orb.pages ?? []) {
45411
- const path = typeof pg === "string" ? pg : pg?.path;
45412
- if (path) pagePathToOrbital[path] = orb.name;
45413
- }
45414
- }
45415
- for (const page of resolvedPages) {
45416
- const orbital = page.path ? pagePathToOrbital[page.path] : void 0;
45417
- if (!orbital) continue;
45418
- for (const traitName of page.traitNames) {
45419
- if (traitName && !(traitName in map)) map[traitName] = orbital;
45420
- }
45421
- }
45422
- return map;
45423
- }
45424
-
45425
44784
  // runtime/OrbPreview.tsx
45426
44785
  init_verificationRegistry();
45427
- var PERF_NAMESPACE = "almadar:perf:canvas";
45428
- var log9 = logger.createLogger(PERF_NAMESPACE);
45429
- var RING_SIZE = 50;
45430
- var ring = [];
45431
- var writeIdx = 0;
45432
- var subscribers = /* @__PURE__ */ new Set();
45433
- var notifyScheduled = false;
45434
- var revision = 0;
45435
- var cachedSnapshot = [];
45436
- var cachedRevision = -1;
45437
- function scheduleNotify() {
45438
- if (notifyScheduled) return;
45439
- notifyScheduled = true;
45440
- queueMicrotask(() => {
45441
- notifyScheduled = false;
45442
- revision++;
45443
- for (const fn of subscribers) fn();
45444
- });
45445
- }
45446
- function push(entry) {
45447
- if (ring.length < RING_SIZE) {
45448
- ring.push(entry);
45449
- } else {
45450
- ring[writeIdx] = entry;
45451
- }
45452
- writeIdx = (writeIdx + 1) % RING_SIZE;
45453
- scheduleNotify();
45454
- }
45455
- function isEnabled() {
45456
- return logger.isLogLevelEnabled("DEBUG", PERF_NAMESPACE);
45457
- }
45458
- function now() {
45459
- return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
45460
- }
45461
- function perfStart(name) {
45462
- if (!isEnabled()) return -1;
45463
- if (typeof performance !== "undefined" && typeof performance.mark === "function") {
45464
- try {
45465
- performance.mark(`${name}-start`);
45466
- } catch {
45467
- }
45468
- }
45469
- return now();
45470
- }
45471
- function perfEnd(name, startToken, detail) {
45472
- if (startToken < 0 || !isEnabled()) return;
45473
- const endTs = now();
45474
- const durationMs = endTs - startToken;
45475
- if (typeof performance !== "undefined" && typeof performance.measure === "function") {
45476
- try {
45477
- performance.mark(`${name}-end`);
45478
- performance.measure(name, `${name}-start`, `${name}-end`);
45479
- } catch {
45480
- }
45481
- }
45482
- push({ name, durationMs, ts: endTs, detail });
45483
- log9.debug(name, () => ({ durationMs, ...detail ?? {} }));
45484
- }
45485
- function perfTime(name, fn, detail) {
45486
- const t = perfStart(name);
45487
- try {
45488
- return fn();
45489
- } finally {
45490
- perfEnd(name, t, detail);
45491
- }
45492
- }
45493
- var profilerOnRender = (id, phase, actualDuration, baseDuration, _startTime, commitTime) => {
45494
- if (!isEnabled()) return;
45495
- push({
45496
- name: `profiler:${id}:${phase}`,
45497
- durationMs: actualDuration,
45498
- ts: commitTime,
45499
- detail: { baseDuration }
45500
- });
45501
- log9.debug(`profiler:${id}:${phase}`, () => ({ actualDuration, baseDuration }));
45502
- };
45503
- function getPerfSnapshot() {
45504
- if (ring.length < RING_SIZE) return ring.slice();
45505
- return [...ring.slice(writeIdx), ...ring.slice(0, writeIdx)];
45506
- }
45507
- function getSnapshot2() {
45508
- if (cachedRevision !== revision) {
45509
- cachedSnapshot = getPerfSnapshot();
45510
- cachedRevision = revision;
45511
- }
45512
- return cachedSnapshot;
45513
- }
45514
- function subscribe(fn) {
45515
- subscribers.add(fn);
45516
- return () => {
45517
- subscribers.delete(fn);
45518
- };
45519
- }
45520
- function usePerfBuffer() {
45521
- return React81.useSyncExternalStore(subscribe, getSnapshot2, getSnapshot2);
45522
- }
45523
- function clearPerf() {
45524
- ring.length = 0;
45525
- writeIdx = 0;
45526
- scheduleNotify();
45527
- }
45528
-
45529
- // lib/prepareSchemaForPreview.ts
45530
- function generateEntityRow(entity, idx) {
45531
- const row = { id: String(idx) };
45532
- for (const f3 of entity.fields) {
45533
- if (f3.name === void 0 || f3.name === "id") continue;
45534
- row[f3.name] = generateFieldValue(entity.name, f3, idx);
45535
- }
45536
- return row;
45537
- }
45538
- function generateFieldValue(entityName, field, idx) {
45539
- if ("values" in field && field.values && field.values.length > 0) {
45540
- return field.values[(idx - 1) % field.values.length];
45541
- }
45542
- const fieldName = field.name ?? "";
45543
- switch (field.type) {
45544
- case "string":
45545
- return `${entityName} ${fieldName.charAt(0).toUpperCase() + fieldName.slice(1)} ${idx}`;
45546
- case "number":
45547
- return idx * 10;
45548
- case "boolean":
45549
- return idx % 2 === 0;
45550
- default:
45551
- return field.default ?? null;
45552
- }
45553
- }
45554
- function buildMockData(schema) {
45555
- const t = perfStart("build-mock-data");
45556
- const result = {};
45557
- for (const orbital of schema.orbitals) {
45558
- const entity = orbital.entity;
45559
- if (!entity || typeof entity === "string") continue;
45560
- if (core.isEntityCall(entity)) continue;
45561
- const entityName = entity.name;
45562
- if (!entityName) continue;
45563
- if (entity.instances && entity.instances.length > 0) {
45564
- result[entityName] = entity.instances;
45565
- continue;
45566
- }
45567
- const rows = Array.from(
45568
- { length: 10 },
45569
- (_, i) => generateEntityRow(entity, i + 1)
45570
- );
45571
- result[entityName] = rows;
45572
- }
45573
- for (const orbital of schema.orbitals) {
45574
- for (const traitRef of orbital.traits ?? []) {
45575
- if (!isInlineTrait3(traitRef)) continue;
45576
- const trait = traitRef;
45577
- const sourceEntity = trait.sourceEntityDefinition;
45578
- if (!sourceEntity || core.isEntityCall(sourceEntity)) continue;
45579
- const sourceName = sourceEntity.name;
45580
- if (!sourceName) continue;
45581
- if (!result[sourceName]) {
45582
- result[sourceName] = sourceEntity.instances && sourceEntity.instances.length > 0 ? sourceEntity.instances : Array.from(
45583
- { length: 10 },
45584
- (_, i) => generateEntityRow(sourceEntity, i + 1)
45585
- );
45586
- }
45587
- const reboundName = trait.linkedEntity;
45588
- if (!reboundName || reboundName === sourceName) continue;
45589
- const reboundRows = result[reboundName];
45590
- if (!reboundRows || reboundRows.length === 0) continue;
45591
- reboundRows.forEach((row, i) => {
45592
- for (const f3 of sourceEntity.fields) {
45593
- if (f3.name === void 0 || f3.name === "id") continue;
45594
- if (row[f3.name] !== void 0) continue;
45595
- row[f3.name] = generateFieldValue(sourceName, f3, i + 1);
45596
- }
45597
- });
45598
- }
45599
- }
45600
- perfEnd("build-mock-data", t, { orbitalCount: schema.orbitals.length, entityCount: Object.keys(result).length });
45601
- return result;
45602
- }
45603
- function isInlineTrait3(traitRef) {
45604
- return typeof traitRef === "object" && traitRef !== null && "stateMachine" in traitRef;
45605
- }
45606
- function findDataState(sm, initialStateName) {
45607
- return sm.states.find((s) => {
45608
- if (s.name === initialStateName) return false;
45609
- return sm.transitions.some(
45610
- (t) => t.event === "INIT" && (t.from === s.name || Array.isArray(t.from) && t.from.includes(s.name))
45611
- );
45612
- });
45613
- }
45614
- function rewriteTraitInitialState(trait, mockData) {
45615
- const sm = trait.stateMachine;
45616
- if (!sm) return trait;
45617
- const linkedEntity = trait.linkedEntity;
45618
- if (!linkedEntity || !mockData[linkedEntity]?.length) return trait;
45619
- const initialStateName = sm.states.find((s) => s.isInitial)?.name ?? sm.states[0]?.name;
45620
- if (!initialStateName) return trait;
45621
- const dataState = findDataState(sm, initialStateName);
45622
- if (!dataState) return trait;
45623
- const updatedStates = sm.states.map((s) => {
45624
- if (s.name === initialStateName) return { ...s, isInitial: false };
45625
- if (s.name === dataState.name) return { ...s, isInitial: true };
45626
- return s;
45627
- });
45628
- return { ...trait, stateMachine: { ...sm, states: updatedStates } };
45629
- }
45630
- function adjustSchemaForMockData(schema, mockData) {
45631
- let changed = false;
45632
- const updatedOrbitals = schema.orbitals.map((orbital) => {
45633
- const traits2 = orbital.traits ?? [];
45634
- const updatedTraits = traits2.map((traitRef) => {
45635
- if (!isInlineTrait3(traitRef)) return traitRef;
45636
- const updated = rewriteTraitInitialState(traitRef, mockData);
45637
- if (updated !== traitRef) changed = true;
45638
- return updated;
45639
- });
45640
- return changed ? { ...orbital, traits: updatedTraits } : orbital;
45641
- });
45642
- return changed ? { ...schema, orbitals: updatedOrbitals } : schema;
45643
- }
45644
- function prepareSchemaForPreview(input) {
45645
- const parsed = typeof input === "string" ? JSON.parse(input) : input;
45646
- const mockData = buildMockData(parsed);
45647
- const schema = adjustSchemaForMockData(parsed, mockData);
45648
- return { schema, mockData };
45649
- }
45650
44786
  var xOrbitalLog = logger.createLogger("almadar:runtime:cross-orbital");
45651
44787
  var navLog = logger.createLogger("almadar:runtime:navigation");
45652
44788
  function normalizeChild(child) {
@@ -45813,7 +44949,7 @@ function SchemaRunner({ schema, serverUrl, transport, mockData, pageName, onNavi
45813
44949
  while (queue.length > 0) {
45814
44950
  const binding = queue.shift();
45815
44951
  if (!binding) continue;
45816
- for (const refName of collectTraitRefsFromResolvedTrait(binding.trait)) {
44952
+ for (const refName of ui.collectTraitRefsFromResolvedTrait(binding.trait)) {
45817
44953
  if (byName.has(refName)) continue;
45818
44954
  const rt = allTraits.get(refName);
45819
44955
  if (!rt) continue;
@@ -45831,7 +44967,7 @@ function SchemaRunner({ schema, serverUrl, transport, mockData, pageName, onNavi
45831
44967
  return orbitals.map((o) => o.name);
45832
44968
  }, [schema]);
45833
44969
  const orbitalsByTrait = React81.useMemo(
45834
- () => buildOrbitalsByTrait(
44970
+ () => ui.buildOrbitalsByTrait(
45835
44971
  schema,
45836
44972
  ir ? Array.from(ir.pages.values()).map((p) => ({
45837
44973
  path: p.path,
@@ -45880,26 +45016,12 @@ function SchemaRunner({ schema, serverUrl, transport, mockData, pageName, onNavi
45880
45016
  pageOrbitalNames: pageOrbitalNames.join(",")
45881
45017
  });
45882
45018
  }, [pageName, allPageTraits, orbitalsByTrait, pageOrbitalNames]);
45883
- const traitConfigsByName = React81.useMemo(() => {
45884
- const map = {};
45885
- const orbitals = schema?.orbitals;
45886
- if (!orbitals) return map;
45887
- for (const orb of orbitals) {
45888
- const traitRefs = orb.traits;
45889
- if (!traitRefs) continue;
45890
- for (const t of traitRefs) {
45891
- if (typeof t === "string") continue;
45892
- const name = t.name ?? t.ref;
45893
- const config = t.config;
45894
- if (typeof name === "string" && config !== void 0) {
45895
- map[name] = config;
45896
- }
45897
- }
45898
- }
45899
- return map;
45900
- }, [schema]);
45019
+ const traitConfigsByName = React81.useMemo(
45020
+ () => core.buildResolvedTraitConfigs(schema),
45021
+ [schema]
45022
+ );
45901
45023
  const embeddedTraits = React81.useMemo(() => {
45902
- const set = collectEmbeddedTraits(schema);
45024
+ const set = ui.collectEmbeddedTraits(schema);
45903
45025
  xOrbitalLog.info("SchemaRunner:embeddedTraits", {
45904
45026
  pageName,
45905
45027
  embedded: Array.from(set),
@@ -45984,7 +45106,7 @@ function OrbPreview({
45984
45106
  parsed = schema;
45985
45107
  }
45986
45108
  if (autoMock && !serverUrl && !transport) {
45987
- const prepared = prepareSchemaForPreview(parsed);
45109
+ const prepared = ui.prepareSchemaForPreview(parsed);
45988
45110
  return { ok: true, schema: prepared.schema, mockData: prepared.mockData };
45989
45111
  }
45990
45112
  return { ok: true, schema: parsed, mockData: mockData ?? {} };
@@ -46159,6 +45281,17 @@ function BrowserPlayground({
46159
45281
  }
46160
45282
  );
46161
45283
  }
45284
+ function usePerfBuffer() {
45285
+ return React81.useSyncExternalStore(ui.perfStore.subscribe, ui.perfStore.getSnapshot, ui.perfStore.getSnapshot);
45286
+ }
45287
+ var profilerOnRender = (id, phase, actualDuration, baseDuration, _startTime, commitTime) => {
45288
+ ui.pushPerfEntry({
45289
+ name: `profiler:${id}:${phase}`,
45290
+ durationMs: actualDuration,
45291
+ ts: commitTime,
45292
+ detail: { baseDuration }
45293
+ });
45294
+ };
46162
45295
 
46163
45296
  Object.defineProperty(exports, "EntitySchemaProvider", {
46164
45297
  enumerable: true,
@@ -46196,20 +45329,47 @@ Object.defineProperty(exports, "useTraitContext", {
46196
45329
  enumerable: true,
46197
45330
  get: function () { return providers.useTraitContext; }
46198
45331
  });
45332
+ Object.defineProperty(exports, "PERF_NAMESPACE", {
45333
+ enumerable: true,
45334
+ get: function () { return ui.PERF_NAMESPACE; }
45335
+ });
45336
+ Object.defineProperty(exports, "adjustSchemaForMockData", {
45337
+ enumerable: true,
45338
+ get: function () { return ui.adjustSchemaForMockData; }
45339
+ });
45340
+ Object.defineProperty(exports, "buildMockData", {
45341
+ enumerable: true,
45342
+ get: function () { return ui.buildMockData; }
45343
+ });
45344
+ Object.defineProperty(exports, "clearPerf", {
45345
+ enumerable: true,
45346
+ get: function () { return ui.clearPerf; }
45347
+ });
45348
+ Object.defineProperty(exports, "perfEnd", {
45349
+ enumerable: true,
45350
+ get: function () { return ui.perfEnd; }
45351
+ });
45352
+ Object.defineProperty(exports, "perfStart", {
45353
+ enumerable: true,
45354
+ get: function () { return ui.perfStart; }
45355
+ });
45356
+ Object.defineProperty(exports, "perfTime", {
45357
+ enumerable: true,
45358
+ get: function () { return ui.perfTime; }
45359
+ });
45360
+ Object.defineProperty(exports, "prepareSchemaForPreview", {
45361
+ enumerable: true,
45362
+ get: function () { return ui.prepareSchemaForPreview; }
45363
+ });
45364
+ Object.defineProperty(exports, "wrapCallbackForEvent", {
45365
+ enumerable: true,
45366
+ get: function () { return ui.wrapCallbackForEvent; }
45367
+ });
46199
45368
  exports.BrowserPlayground = BrowserPlayground;
46200
45369
  exports.OrbPreview = OrbPreview;
46201
- exports.PERF_NAMESPACE = PERF_NAMESPACE;
46202
- exports.adjustSchemaForMockData = adjustSchemaForMockData;
46203
- exports.buildMockData = buildMockData;
46204
- exports.clearPerf = clearPerf;
46205
45370
  exports.clearSchemaCache = clearSchemaCache;
46206
45371
  exports.createClientEffectHandlers = createClientEffectHandlers;
46207
- exports.perfEnd = perfEnd;
46208
- exports.perfStart = perfStart;
46209
- exports.perfTime = perfTime;
46210
- exports.prepareSchemaForPreview = prepareSchemaForPreview;
46211
45372
  exports.profilerOnRender = profilerOnRender;
46212
45373
  exports.usePerfBuffer = usePerfBuffer;
46213
45374
  exports.useResolvedSchema = useResolvedSchema;
46214
45375
  exports.useTraitStateMachine = useTraitStateMachine;
46215
- exports.wrapCallbackForEvent = wrapCallbackForEvent;