@almadar/ui 6.19.0 → 6.21.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.
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
3
  import { ResolvedEntity, EventPayload, EntityRow, OrbitalSchema, BusEventSource, SExpr, ResolvedTrait, ResolvedTraitBinding, TraitConfig } from '@almadar/core';
4
4
  import { AnyPatternConfig } from '@almadar/core/patterns';
5
- import { ServerEffectResult } from '@almadar/runtime';
5
+ import { ServerEffectResult, TransitionResult } from '@almadar/runtime';
6
6
 
7
7
  /**
8
8
  * EntitySchemaContext
@@ -162,7 +162,14 @@ interface SendEventResult {
162
162
  }
163
163
  interface ServerBridgeContextValue {
164
164
  connected: boolean;
165
- sendEvent: (orbitalName: string, event: string, payload?: EventPayload, tick?: string, sourceTrait?: string, locallyEmitted?: readonly string[]) => Promise<SendEventResult>;
165
+ sendEvent: (orbitalName: string, event: string, payload?: EventPayload, tick?: string, sourceTrait?: string, locallyEmitted?: readonly string[],
166
+ /** Part G: traits the client's own local dispatch already executed for this event. */
167
+ results?: ReadonlyArray<{
168
+ traitName: string;
169
+ result: TransitionResult;
170
+ }>,
171
+ /** Part G: the client's own current entity snapshot per trait. */
172
+ entityByTrait?: Readonly<Record<string, EntityRow>>) => Promise<SendEventResult>;
166
173
  }
167
174
  /**
168
175
  * Transport adapter for ServerBridgeProvider. Decouples the bridge's
@@ -190,7 +197,10 @@ interface ServerBridgeTransport {
190
197
  * tick-originated latest-state broadcast: the server coalesces these
191
198
  * newest-per-key and relays them to other tabs at snapshot rate.
192
199
  */
193
- sendEvent: (orbitalName: string, event: string, payload?: EventPayload, clientId?: string, tick?: string, sourceTrait?: string) => Promise<OrbitalEventResponse>;
200
+ sendEvent: (orbitalName: string, event: string, payload?: EventPayload, clientId?: string, tick?: string, sourceTrait?: string, results?: ReadonlyArray<{
201
+ traitName: string;
202
+ result: TransitionResult;
203
+ }>, entityByTrait?: Readonly<Record<string, EntityRow>>) => Promise<OrbitalEventResponse>;
194
204
  }
195
205
  /**
196
206
  * Supplies the bearer token the hosting server authenticates with. Resolved
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
3
  import { ResolvedEntity, EventPayload, EntityRow, OrbitalSchema, BusEventSource, SExpr, ResolvedTrait, ResolvedTraitBinding, TraitConfig } from '@almadar/core';
4
4
  import { AnyPatternConfig } from '@almadar/core/patterns';
5
- import { ServerEffectResult } from '@almadar/runtime';
5
+ import { ServerEffectResult, TransitionResult } from '@almadar/runtime';
6
6
 
7
7
  /**
8
8
  * EntitySchemaContext
@@ -162,7 +162,14 @@ interface SendEventResult {
162
162
  }
163
163
  interface ServerBridgeContextValue {
164
164
  connected: boolean;
165
- sendEvent: (orbitalName: string, event: string, payload?: EventPayload, tick?: string, sourceTrait?: string, locallyEmitted?: readonly string[]) => Promise<SendEventResult>;
165
+ sendEvent: (orbitalName: string, event: string, payload?: EventPayload, tick?: string, sourceTrait?: string, locallyEmitted?: readonly string[],
166
+ /** Part G: traits the client's own local dispatch already executed for this event. */
167
+ results?: ReadonlyArray<{
168
+ traitName: string;
169
+ result: TransitionResult;
170
+ }>,
171
+ /** Part G: the client's own current entity snapshot per trait. */
172
+ entityByTrait?: Readonly<Record<string, EntityRow>>) => Promise<SendEventResult>;
166
173
  }
167
174
  /**
168
175
  * Transport adapter for ServerBridgeProvider. Decouples the bridge's
@@ -190,7 +197,10 @@ interface ServerBridgeTransport {
190
197
  * tick-originated latest-state broadcast: the server coalesces these
191
198
  * newest-per-key and relays them to other tabs at snapshot rate.
192
199
  */
193
- sendEvent: (orbitalName: string, event: string, payload?: EventPayload, clientId?: string, tick?: string, sourceTrait?: string) => Promise<OrbitalEventResponse>;
200
+ sendEvent: (orbitalName: string, event: string, payload?: EventPayload, clientId?: string, tick?: string, sourceTrait?: string, results?: ReadonlyArray<{
201
+ traitName: string;
202
+ result: TransitionResult;
203
+ }>, entityByTrait?: Readonly<Record<string, EntityRow>>) => Promise<OrbitalEventResponse>;
194
204
  }
195
205
  /**
196
206
  * Supplies the bearer token the hosting server authenticates with. Resolved
@@ -5398,6 +5398,36 @@ var init_Dialog = __esm({
5398
5398
  Dialog.displayName = "Dialog";
5399
5399
  }
5400
5400
  });
5401
+
5402
+ // lib/portalRoot.ts
5403
+ function lastThemedElement(selector, portalRoot) {
5404
+ const matches = Array.from(document.querySelectorAll(selector)).filter(
5405
+ (el) => el !== document.documentElement && el !== portalRoot
5406
+ );
5407
+ return matches[matches.length - 1] ?? null;
5408
+ }
5409
+ function getOrCreatePortalRoot() {
5410
+ let root = document.getElementById("ui-slot-portal-root");
5411
+ if (!root) {
5412
+ root = document.createElement("div");
5413
+ root.id = "ui-slot-portal-root";
5414
+ root.style.position = "relative";
5415
+ root.style.zIndex = "9999";
5416
+ document.body.appendChild(root);
5417
+ }
5418
+ const themed = lastThemedElement('[data-theme*="-"]', root) ?? lastThemedElement("[data-theme]", root);
5419
+ if (themed) {
5420
+ const theme = themed.getAttribute("data-theme");
5421
+ if (theme && root.getAttribute("data-theme") !== theme) {
5422
+ root.setAttribute("data-theme", theme);
5423
+ }
5424
+ }
5425
+ return root;
5426
+ }
5427
+ var init_portalRoot = __esm({
5428
+ "lib/portalRoot.ts"() {
5429
+ }
5430
+ });
5401
5431
  function isMotionEnabled() {
5402
5432
  if (typeof document === "undefined") return true;
5403
5433
  if (motionEnabledCache !== null) return motionEnabledCache;
@@ -5478,6 +5508,7 @@ var init_Modal = __esm({
5478
5508
  init_Dialog();
5479
5509
  init_Typography();
5480
5510
  init_cn();
5511
+ init_portalRoot();
5481
5512
  init_useEventBus();
5482
5513
  init_Presence();
5483
5514
  sizeClasses2 = {
@@ -5688,7 +5719,7 @@ var init_Modal = __esm({
5688
5719
  )
5689
5720
  }
5690
5721
  ),
5691
- document.body
5722
+ getOrCreatePortalRoot()
5692
5723
  );
5693
5724
  };
5694
5725
  Modal.displayName = "Modal";
@@ -23054,6 +23085,7 @@ var init_StateMachineView = __esm({
23054
23085
  init_Icon();
23055
23086
  init_useEventBus();
23056
23087
  init_cn();
23088
+ init_portalRoot();
23057
23089
  StateNode2 = ({ state, config }) => {
23058
23090
  const { t } = hooks.useTranslate();
23059
23091
  const size = state.radius * 2;
@@ -23570,7 +23602,7 @@ var init_StateMachineView = __esm({
23570
23602
  )
23571
23603
  }
23572
23604
  ),
23573
- document.body
23605
+ getOrCreatePortalRoot()
23574
23606
  );
23575
23607
  };
23576
23608
  EntityBox = ({ entity, config }) => {
@@ -30211,7 +30243,7 @@ function SubMenu({
30211
30243
  })
30212
30244
  }
30213
30245
  );
30214
- return typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel;
30246
+ return typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel;
30215
30247
  }
30216
30248
  function MenuItemRow({
30217
30249
  item,
@@ -30298,6 +30330,7 @@ var init_Menu = __esm({
30298
30330
  init_Typography();
30299
30331
  init_Badge();
30300
30332
  init_cn();
30333
+ init_portalRoot();
30301
30334
  init_useEventBus();
30302
30335
  MENU_GAP = 4;
30303
30336
  menuContainerStyles = cn(
@@ -30434,7 +30467,7 @@ var init_Menu = __esm({
30434
30467
  ) : null;
30435
30468
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
30436
30469
  triggerElement,
30437
- panel && typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel
30470
+ panel && typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel
30438
30471
  ] });
30439
30472
  };
30440
30473
  Menu.displayName = "Menu";
@@ -33818,6 +33851,7 @@ var init_Popover = __esm({
33818
33851
  init_Typography();
33819
33852
  init_Presence();
33820
33853
  init_cn();
33854
+ init_portalRoot();
33821
33855
  init_useTapReveal();
33822
33856
  arrowClasses = {
33823
33857
  top: "top-full left-1/2 -translate-x-1/2 border-t-white border-l-transparent border-r-transparent border-b-transparent",
@@ -33977,7 +34011,7 @@ var init_Popover = __esm({
33977
34011
  ) : null;
33978
34012
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
33979
34013
  triggerElement,
33980
- panel && typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel
34014
+ panel && typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel
33981
34015
  ] });
33982
34016
  };
33983
34017
  Popover.displayName = "Popover";
@@ -34483,6 +34517,7 @@ var init_Tooltip = __esm({
34483
34517
  "use client";
34484
34518
  init_Typography();
34485
34519
  init_cn();
34520
+ init_portalRoot();
34486
34521
  init_useTapReveal();
34487
34522
  TRIGGER_GAP2 = 8;
34488
34523
  arrowClasses2 = {
@@ -34588,7 +34623,7 @@ var init_Tooltip = __esm({
34588
34623
  ) : null;
34589
34624
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
34590
34625
  trigger,
34591
- typeof window !== "undefined" && tooltipContent ? reactDom.createPortal(tooltipContent, document.body) : tooltipContent
34626
+ typeof window !== "undefined" && tooltipContent ? reactDom.createPortal(tooltipContent, getOrCreatePortalRoot()) : tooltipContent
34592
34627
  ] });
34593
34628
  };
34594
34629
  Tooltip.displayName = "Tooltip";
@@ -45599,6 +45634,7 @@ var init_GraphCanvas = __esm({
45599
45634
  "components/core/molecules/GraphCanvas.tsx"() {
45600
45635
  "use client";
45601
45636
  init_cn();
45637
+ init_portalRoot();
45602
45638
  init_atoms();
45603
45639
  init_Stack();
45604
45640
  init_LoadingState();
@@ -46310,7 +46346,7 @@ var init_GraphCanvas = __esm({
46310
46346
  children: hoveredObj?.label
46311
46347
  }
46312
46348
  ),
46313
- document.body
46349
+ getOrCreatePortalRoot()
46314
46350
  )
46315
46351
  ] }),
46316
46352
  groups.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "md", className: "px-4 py-2 border-t border-border", wrap: true, children: groups.map((group, idx) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "xs", align: "center", children: [
@@ -47471,6 +47507,7 @@ var init_DetailPanel = __esm({
47471
47507
  init_ErrorState();
47472
47508
  init_EmptyState();
47473
47509
  init_cn();
47510
+ init_portalRoot();
47474
47511
  init_format();
47475
47512
  init_getNestedValue();
47476
47513
  init_relationLabel();
@@ -47890,7 +47927,7 @@ var init_DetailPanel = __esm({
47890
47927
  return /* @__PURE__ */ jsxRuntime.jsx(Box, { className, children: content });
47891
47928
  }
47892
47929
  const panel = /* @__PURE__ */ jsxRuntime.jsx(Box, { className: cn("fixed inset-y-0 right-0 w-full max-w-2xl bg-card shadow-lg z-50 overflow-y-auto p-6", className), children: content });
47893
- return typeof document === "undefined" ? panel : reactDom.createPortal(panel, document.body);
47930
+ return typeof document === "undefined" ? panel : reactDom.createPortal(panel, getOrCreatePortalRoot());
47894
47931
  };
47895
47932
  DetailPanel.displayName = "DetailPanel";
47896
47933
  }
@@ -54800,24 +54837,6 @@ function UISlotComponentInner({
54800
54837
  }
54801
54838
  );
54802
54839
  }
54803
- function getOrCreatePortalRoot() {
54804
- let root = document.getElementById("ui-slot-portal-root");
54805
- if (!root) {
54806
- root = document.createElement("div");
54807
- root.id = "ui-slot-portal-root";
54808
- root.style.position = "relative";
54809
- root.style.zIndex = "9999";
54810
- document.body.appendChild(root);
54811
- }
54812
- const themed = document.querySelector('[data-theme*="-"]') ?? document.querySelector("[data-theme]");
54813
- if (themed) {
54814
- const theme = themed.getAttribute("data-theme");
54815
- if (theme && root.getAttribute("data-theme") !== theme) {
54816
- root.setAttribute("data-theme", theme);
54817
- }
54818
- }
54819
- return root;
54820
- }
54821
54840
  function CompiledPortal({ slot, className, pattern, sourceTrait, children }) {
54822
54841
  const [portalRoot, setPortalRoot] = React96.useState(null);
54823
54842
  const slotsBus = context.useUISlots();
@@ -55440,6 +55459,7 @@ var init_UISlotRenderer = __esm({
55440
55459
  init_slot_types();
55441
55460
  init_cn();
55442
55461
  init_format();
55462
+ init_portalRoot();
55443
55463
  init_ErrorBoundary();
55444
55464
  init_Skeleton();
55445
55465
  init_renderer();
@@ -60208,7 +60228,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
60208
60228
  }
60209
60229
  const relayPayload = targetTrait !== void 0 ? { ...payload ?? {}, _targetTrait: targetTrait } : payload;
60210
60230
  const locallyEmitted = Array.from(emittedByTrait.values()).flat();
60211
- void onEventProcessed(normalizedEvent, relayPayload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted);
60231
+ void onEventProcessed(normalizedEvent, relayPayload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted, results, entityByTrait);
60212
60232
  }
60213
60233
  ui.perfEnd("processEvent:total", _perfT0);
60214
60234
  ui.perfEnd(`event:${normalizedEvent}`, _perfT0);
@@ -60543,7 +60563,7 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
60543
60563
  [serverActiveTraits]
60544
60564
  );
60545
60565
  const uiSlots = context.useUISlots();
60546
- const onEventProcessed = React96.useCallback((event, payload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted) => {
60566
+ const onEventProcessed = React96.useCallback((event, payload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted, results, entityByTrait) => {
60547
60567
  if (!bridge.connected || !orbitalNames?.length) return;
60548
60568
  const targets = dispatchedOrbitals && dispatchedOrbitals.size > 0 ? orbitalNames.filter((n) => dispatchedOrbitals.has(n)) : orbitalNames;
60549
60569
  xOrbitalLog.debug("TraitInitializer:fanout", () => ({
@@ -60557,7 +60577,7 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
60557
60577
  void bridge.sendEvent(name, event, withActiveTraits(payload), tick, sourceTrait);
60558
60578
  continue;
60559
60579
  }
60560
- void bridge.sendEvent(name, event, withActiveTraits(payload), void 0, void 0, locallyEmitted).then(({ effects, meta }) => {
60580
+ void bridge.sendEvent(name, event, withActiveTraits(payload), void 0, void 0, locallyEmitted, results, entityByTrait).then(({ effects, meta }) => {
60561
60581
  recordServerResponse(name, event, { ...meta, effectResults: effectResultsToTraces(meta.effectResults) });
60562
60582
  applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits, activeTraitNames, onNavigateBack);
60563
60583
  });
package/dist/avl/index.js CHANGED
@@ -5322,6 +5322,36 @@ var init_Dialog = __esm({
5322
5322
  Dialog.displayName = "Dialog";
5323
5323
  }
5324
5324
  });
5325
+
5326
+ // lib/portalRoot.ts
5327
+ function lastThemedElement(selector, portalRoot) {
5328
+ const matches = Array.from(document.querySelectorAll(selector)).filter(
5329
+ (el) => el !== document.documentElement && el !== portalRoot
5330
+ );
5331
+ return matches[matches.length - 1] ?? null;
5332
+ }
5333
+ function getOrCreatePortalRoot() {
5334
+ let root = document.getElementById("ui-slot-portal-root");
5335
+ if (!root) {
5336
+ root = document.createElement("div");
5337
+ root.id = "ui-slot-portal-root";
5338
+ root.style.position = "relative";
5339
+ root.style.zIndex = "9999";
5340
+ document.body.appendChild(root);
5341
+ }
5342
+ const themed = lastThemedElement('[data-theme*="-"]', root) ?? lastThemedElement("[data-theme]", root);
5343
+ if (themed) {
5344
+ const theme = themed.getAttribute("data-theme");
5345
+ if (theme && root.getAttribute("data-theme") !== theme) {
5346
+ root.setAttribute("data-theme", theme);
5347
+ }
5348
+ }
5349
+ return root;
5350
+ }
5351
+ var init_portalRoot = __esm({
5352
+ "lib/portalRoot.ts"() {
5353
+ }
5354
+ });
5325
5355
  function isMotionEnabled() {
5326
5356
  if (typeof document === "undefined") return true;
5327
5357
  if (motionEnabledCache !== null) return motionEnabledCache;
@@ -5402,6 +5432,7 @@ var init_Modal = __esm({
5402
5432
  init_Dialog();
5403
5433
  init_Typography();
5404
5434
  init_cn();
5435
+ init_portalRoot();
5405
5436
  init_useEventBus();
5406
5437
  init_Presence();
5407
5438
  sizeClasses2 = {
@@ -5612,7 +5643,7 @@ var init_Modal = __esm({
5612
5643
  )
5613
5644
  }
5614
5645
  ),
5615
- document.body
5646
+ getOrCreatePortalRoot()
5616
5647
  );
5617
5648
  };
5618
5649
  Modal.displayName = "Modal";
@@ -22978,6 +23009,7 @@ var init_StateMachineView = __esm({
22978
23009
  init_Icon();
22979
23010
  init_useEventBus();
22980
23011
  init_cn();
23012
+ init_portalRoot();
22981
23013
  StateNode2 = ({ state, config }) => {
22982
23014
  const { t } = useTranslate();
22983
23015
  const size = state.radius * 2;
@@ -23494,7 +23526,7 @@ var init_StateMachineView = __esm({
23494
23526
  )
23495
23527
  }
23496
23528
  ),
23497
- document.body
23529
+ getOrCreatePortalRoot()
23498
23530
  );
23499
23531
  };
23500
23532
  EntityBox = ({ entity, config }) => {
@@ -30135,7 +30167,7 @@ function SubMenu({
30135
30167
  })
30136
30168
  }
30137
30169
  );
30138
- return typeof document !== "undefined" ? createPortal(panel, document.body) : panel;
30170
+ return typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel;
30139
30171
  }
30140
30172
  function MenuItemRow({
30141
30173
  item,
@@ -30222,6 +30254,7 @@ var init_Menu = __esm({
30222
30254
  init_Typography();
30223
30255
  init_Badge();
30224
30256
  init_cn();
30257
+ init_portalRoot();
30225
30258
  init_useEventBus();
30226
30259
  MENU_GAP = 4;
30227
30260
  menuContainerStyles = cn(
@@ -30358,7 +30391,7 @@ var init_Menu = __esm({
30358
30391
  ) : null;
30359
30392
  return /* @__PURE__ */ jsxs(Fragment, { children: [
30360
30393
  triggerElement,
30361
- panel && typeof document !== "undefined" ? createPortal(panel, document.body) : panel
30394
+ panel && typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel
30362
30395
  ] });
30363
30396
  };
30364
30397
  Menu.displayName = "Menu";
@@ -33742,6 +33775,7 @@ var init_Popover = __esm({
33742
33775
  init_Typography();
33743
33776
  init_Presence();
33744
33777
  init_cn();
33778
+ init_portalRoot();
33745
33779
  init_useTapReveal();
33746
33780
  arrowClasses = {
33747
33781
  top: "top-full left-1/2 -translate-x-1/2 border-t-white border-l-transparent border-r-transparent border-b-transparent",
@@ -33901,7 +33935,7 @@ var init_Popover = __esm({
33901
33935
  ) : null;
33902
33936
  return /* @__PURE__ */ jsxs(Fragment, { children: [
33903
33937
  triggerElement,
33904
- panel && typeof document !== "undefined" ? createPortal(panel, document.body) : panel
33938
+ panel && typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel
33905
33939
  ] });
33906
33940
  };
33907
33941
  Popover.displayName = "Popover";
@@ -34407,6 +34441,7 @@ var init_Tooltip = __esm({
34407
34441
  "use client";
34408
34442
  init_Typography();
34409
34443
  init_cn();
34444
+ init_portalRoot();
34410
34445
  init_useTapReveal();
34411
34446
  TRIGGER_GAP2 = 8;
34412
34447
  arrowClasses2 = {
@@ -34512,7 +34547,7 @@ var init_Tooltip = __esm({
34512
34547
  ) : null;
34513
34548
  return /* @__PURE__ */ jsxs(Fragment, { children: [
34514
34549
  trigger,
34515
- typeof window !== "undefined" && tooltipContent ? createPortal(tooltipContent, document.body) : tooltipContent
34550
+ typeof window !== "undefined" && tooltipContent ? createPortal(tooltipContent, getOrCreatePortalRoot()) : tooltipContent
34516
34551
  ] });
34517
34552
  };
34518
34553
  Tooltip.displayName = "Tooltip";
@@ -45523,6 +45558,7 @@ var init_GraphCanvas = __esm({
45523
45558
  "components/core/molecules/GraphCanvas.tsx"() {
45524
45559
  "use client";
45525
45560
  init_cn();
45561
+ init_portalRoot();
45526
45562
  init_atoms();
45527
45563
  init_Stack();
45528
45564
  init_LoadingState();
@@ -46234,7 +46270,7 @@ var init_GraphCanvas = __esm({
46234
46270
  children: hoveredObj?.label
46235
46271
  }
46236
46272
  ),
46237
- document.body
46273
+ getOrCreatePortalRoot()
46238
46274
  )
46239
46275
  ] }),
46240
46276
  groups.length > 1 && /* @__PURE__ */ jsx(HStack, { gap: "md", className: "px-4 py-2 border-t border-border", wrap: true, children: groups.map((group, idx) => /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
@@ -47395,6 +47431,7 @@ var init_DetailPanel = __esm({
47395
47431
  init_ErrorState();
47396
47432
  init_EmptyState();
47397
47433
  init_cn();
47434
+ init_portalRoot();
47398
47435
  init_format();
47399
47436
  init_getNestedValue();
47400
47437
  init_relationLabel();
@@ -47814,7 +47851,7 @@ var init_DetailPanel = __esm({
47814
47851
  return /* @__PURE__ */ jsx(Box, { className, children: content });
47815
47852
  }
47816
47853
  const panel = /* @__PURE__ */ jsx(Box, { className: cn("fixed inset-y-0 right-0 w-full max-w-2xl bg-card shadow-lg z-50 overflow-y-auto p-6", className), children: content });
47817
- return typeof document === "undefined" ? panel : createPortal(panel, document.body);
47854
+ return typeof document === "undefined" ? panel : createPortal(panel, getOrCreatePortalRoot());
47818
47855
  };
47819
47856
  DetailPanel.displayName = "DetailPanel";
47820
47857
  }
@@ -54724,24 +54761,6 @@ function UISlotComponentInner({
54724
54761
  }
54725
54762
  );
54726
54763
  }
54727
- function getOrCreatePortalRoot() {
54728
- let root = document.getElementById("ui-slot-portal-root");
54729
- if (!root) {
54730
- root = document.createElement("div");
54731
- root.id = "ui-slot-portal-root";
54732
- root.style.position = "relative";
54733
- root.style.zIndex = "9999";
54734
- document.body.appendChild(root);
54735
- }
54736
- const themed = document.querySelector('[data-theme*="-"]') ?? document.querySelector("[data-theme]");
54737
- if (themed) {
54738
- const theme = themed.getAttribute("data-theme");
54739
- if (theme && root.getAttribute("data-theme") !== theme) {
54740
- root.setAttribute("data-theme", theme);
54741
- }
54742
- }
54743
- return root;
54744
- }
54745
54764
  function CompiledPortal({ slot, className, pattern, sourceTrait, children }) {
54746
54765
  const [portalRoot, setPortalRoot] = useState(null);
54747
54766
  const slotsBus = useUISlots();
@@ -55364,6 +55383,7 @@ var init_UISlotRenderer = __esm({
55364
55383
  init_slot_types();
55365
55384
  init_cn();
55366
55385
  init_format();
55386
+ init_portalRoot();
55367
55387
  init_ErrorBoundary();
55368
55388
  init_Skeleton();
55369
55389
  init_renderer();
@@ -60132,7 +60152,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
60132
60152
  }
60133
60153
  const relayPayload = targetTrait !== void 0 ? { ...payload ?? {}, _targetTrait: targetTrait } : payload;
60134
60154
  const locallyEmitted = Array.from(emittedByTrait.values()).flat();
60135
- void onEventProcessed(normalizedEvent, relayPayload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted);
60155
+ void onEventProcessed(normalizedEvent, relayPayload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted, results, entityByTrait);
60136
60156
  }
60137
60157
  perfEnd("processEvent:total", _perfT0);
60138
60158
  perfEnd(`event:${normalizedEvent}`, _perfT0);
@@ -60467,7 +60487,7 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
60467
60487
  [serverActiveTraits]
60468
60488
  );
60469
60489
  const uiSlots = useUISlots();
60470
- const onEventProcessed = useCallback((event, payload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted) => {
60490
+ const onEventProcessed = useCallback((event, payload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted, results, entityByTrait) => {
60471
60491
  if (!bridge.connected || !orbitalNames?.length) return;
60472
60492
  const targets = dispatchedOrbitals && dispatchedOrbitals.size > 0 ? orbitalNames.filter((n) => dispatchedOrbitals.has(n)) : orbitalNames;
60473
60493
  xOrbitalLog.debug("TraitInitializer:fanout", () => ({
@@ -60481,7 +60501,7 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
60481
60501
  void bridge.sendEvent(name, event, withActiveTraits(payload), tick, sourceTrait);
60482
60502
  continue;
60483
60503
  }
60484
- void bridge.sendEvent(name, event, withActiveTraits(payload), void 0, void 0, locallyEmitted).then(({ effects, meta }) => {
60504
+ void bridge.sendEvent(name, event, withActiveTraits(payload), void 0, void 0, locallyEmitted, results, entityByTrait).then(({ effects, meta }) => {
60485
60505
  recordServerResponse(name, event, { ...meta, effectResults: effectResultsToTraces(meta.effectResults) });
60486
60506
  applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits, activeTraitNames, onNavigateBack);
60487
60507
  });