@almadar/ui 5.76.1 → 5.76.2

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.
@@ -1,6 +1,6 @@
1
- import * as React106 from 'react';
2
- import React106__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId, useSyncExternalStore } from 'react';
3
- import { EventBusContext, useTraitScope, useEntitySchemaOptional, TraitScopeProvider, useCurrentPagePath, useGameAudioContextOptional } from '@almadar/ui/providers';
1
+ import * as React107 from 'react';
2
+ import React107__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId, useSyncExternalStore } from 'react';
3
+ import { EventBusContext, useTraitScope, useEntitySchemaOptional, TraitScopeProvider, useCurrentPagePath } from '@almadar/ui/providers';
4
4
  import { createLogger, isLogLevelEnabled } from '@almadar/logger';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
@@ -10,7 +10,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import { createPortal } from 'react-dom';
11
11
  import { useTranslate } from '@almadar/ui/hooks';
12
12
  import { useUISlots, ThemeProvider, useTheme } from '@almadar/ui/context';
13
- export { BUILT_IN_THEMES, DesignThemeProvider, default as ThemeContext, ThemeProvider, UISlotContext, UISlotProvider, useDesignTheme, useSlotContent, useSlotHasContent, useTheme, useUISlots } from '@almadar/ui/context';
13
+ export { DesignThemeProvider, useDesignTheme } from '@almadar/ui/context';
14
14
  import { evaluate, createMinimalContext } from '@almadar/evaluator';
15
15
  import { getPatternDefinition, getComponentForPattern } from '@almadar/patterns';
16
16
  import { Link, Outlet, useLocation } from 'react-router-dom';
@@ -388,7 +388,7 @@ var init_Box = __esm({
388
388
  fixed: "fixed",
389
389
  sticky: "sticky"
390
390
  };
391
- Box = React106__default.forwardRef(
391
+ Box = React107__default.forwardRef(
392
392
  ({
393
393
  padding,
394
394
  paddingX,
@@ -453,7 +453,7 @@ var init_Box = __esm({
453
453
  onPointerDown?.(e);
454
454
  }, [hoverEvent, tapReveal, triggerProps, onPointerDown]);
455
455
  const isClickable = action || onClick;
456
- return React106__default.createElement(
456
+ return React107__default.createElement(
457
457
  Component,
458
458
  {
459
459
  ref,
@@ -549,7 +549,7 @@ function loadLib(key, importer) {
549
549
  return p2;
550
550
  }
551
551
  function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
552
- const Lazy = React106__default.lazy(async () => {
552
+ const Lazy = React107__default.lazy(async () => {
553
553
  const lib = await loadLib(libKey, importer);
554
554
  const Comp = pick(lib);
555
555
  if (!Comp) {
@@ -559,7 +559,7 @@ function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
559
559
  return { default: Comp };
560
560
  });
561
561
  const Wrapped = (props) => /* @__PURE__ */ jsx(
562
- React106__default.Suspense,
562
+ React107__default.Suspense,
563
563
  {
564
564
  fallback: /* @__PURE__ */ jsx(
565
565
  "span",
@@ -1286,7 +1286,7 @@ var init_Icon = __esm({
1286
1286
  const directIcon = typeof icon === "string" ? void 0 : icon;
1287
1287
  const effectiveName = typeof icon === "string" ? icon : name;
1288
1288
  const family = useIconFamily();
1289
- const RenderedComponent = React106__default.useMemo(() => {
1289
+ const RenderedComponent = React107__default.useMemo(() => {
1290
1290
  if (directIcon) return null;
1291
1291
  return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
1292
1292
  }, [directIcon, effectiveName, family]);
@@ -1348,7 +1348,7 @@ function resolveIconProp(value, sizeClass) {
1348
1348
  const IconComp = value;
1349
1349
  return /* @__PURE__ */ jsx(IconComp, { className: sizeClass });
1350
1350
  }
1351
- if (React106__default.isValidElement(value)) {
1351
+ if (React107__default.isValidElement(value)) {
1352
1352
  return value;
1353
1353
  }
1354
1354
  if (typeof value === "object" && value !== null && isIconLike(value)) {
@@ -1424,7 +1424,7 @@ var init_Button = __esm({
1424
1424
  md: "h-icon-default w-icon-default",
1425
1425
  lg: "h-icon-default w-icon-default"
1426
1426
  };
1427
- Button = React106__default.forwardRef(
1427
+ Button = React107__default.forwardRef(
1428
1428
  ({
1429
1429
  className,
1430
1430
  variant = "primary",
@@ -1490,7 +1490,7 @@ var Dialog;
1490
1490
  var init_Dialog = __esm({
1491
1491
  "components/core/atoms/Dialog.tsx"() {
1492
1492
  init_cn();
1493
- Dialog = React106__default.forwardRef(
1493
+ Dialog = React107__default.forwardRef(
1494
1494
  ({
1495
1495
  role = "dialog",
1496
1496
  "aria-modal": ariaModal = true,
@@ -1608,7 +1608,7 @@ var init_Typography = __esm({
1608
1608
  }) => {
1609
1609
  const variant = variantProp ?? (level ? `h${level}` : "body1");
1610
1610
  const Component = as || defaultElements[variant];
1611
- return React106__default.createElement(
1611
+ return React107__default.createElement(
1612
1612
  Component,
1613
1613
  {
1614
1614
  id,
@@ -2103,7 +2103,7 @@ var init_Badge = __esm({
2103
2103
  md: "px-2.5 py-1 text-sm",
2104
2104
  lg: "px-3 py-1.5 text-base"
2105
2105
  };
2106
- Badge = React106__default.forwardRef(
2106
+ Badge = React107__default.forwardRef(
2107
2107
  ({ className, variant = "default", size = "sm", amount, label, icon, children, onRemove, removeLabel, ...props }, ref) => {
2108
2108
  const iconSizes3 = {
2109
2109
  sm: "h-icon-default w-icon-default",
@@ -2439,7 +2439,7 @@ var init_SvgFlow = __esm({
2439
2439
  width = 100,
2440
2440
  height = 100
2441
2441
  }) => {
2442
- const markerId = React106__default.useMemo(() => {
2442
+ const markerId = React107__default.useMemo(() => {
2443
2443
  flowIdCounter += 1;
2444
2444
  return `almadar-flow-arrow-${flowIdCounter}`;
2445
2445
  }, []);
@@ -3032,7 +3032,7 @@ var init_SvgRing = __esm({
3032
3032
  width = 100,
3033
3033
  height = 100
3034
3034
  }) => {
3035
- const gradientId = React106__default.useMemo(() => {
3035
+ const gradientId = React107__default.useMemo(() => {
3036
3036
  ringIdCounter += 1;
3037
3037
  return `almadar-ring-glow-${ringIdCounter}`;
3038
3038
  }, []);
@@ -3213,7 +3213,7 @@ var init_Input = __esm({
3213
3213
  init_cn();
3214
3214
  init_Icon();
3215
3215
  init_useEventBus();
3216
- Input = React106__default.forwardRef(
3216
+ Input = React107__default.forwardRef(
3217
3217
  ({
3218
3218
  className,
3219
3219
  inputType,
@@ -3373,7 +3373,7 @@ var Label;
3373
3373
  var init_Label = __esm({
3374
3374
  "components/core/atoms/Label.tsx"() {
3375
3375
  init_cn();
3376
- Label = React106__default.forwardRef(
3376
+ Label = React107__default.forwardRef(
3377
3377
  ({ className, required, children, ...props }, ref) => {
3378
3378
  return /* @__PURE__ */ jsxs(
3379
3379
  "label",
@@ -3400,7 +3400,7 @@ var init_Textarea = __esm({
3400
3400
  "components/core/atoms/Textarea.tsx"() {
3401
3401
  init_cn();
3402
3402
  init_useEventBus();
3403
- Textarea = React106__default.forwardRef(
3403
+ Textarea = React107__default.forwardRef(
3404
3404
  ({ className, error, onChange, ...props }, ref) => {
3405
3405
  const eventBus = useEventBus();
3406
3406
  const handleChange = (e) => {
@@ -3639,7 +3639,7 @@ var init_Select = __esm({
3639
3639
  init_cn();
3640
3640
  init_Icon();
3641
3641
  init_useEventBus();
3642
- Select = React106__default.forwardRef(
3642
+ Select = React107__default.forwardRef(
3643
3643
  (props, _ref) => {
3644
3644
  const { multiple, searchable, clearable } = props;
3645
3645
  if (multiple || searchable || clearable) {
@@ -3656,7 +3656,7 @@ var init_Checkbox = __esm({
3656
3656
  "components/core/atoms/Checkbox.tsx"() {
3657
3657
  init_cn();
3658
3658
  init_useEventBus();
3659
- Checkbox = React106__default.forwardRef(
3659
+ Checkbox = React107__default.forwardRef(
3660
3660
  ({ className, label, id, onChange, ...props }, ref) => {
3661
3661
  const inputId = id || `checkbox-${Math.random().toString(36).substr(2, 9)}`;
3662
3662
  const eventBus = useEventBus();
@@ -3710,7 +3710,7 @@ var init_Spinner = __esm({
3710
3710
  md: "h-6 w-6",
3711
3711
  lg: "h-8 w-8"
3712
3712
  };
3713
- Spinner = React106__default.forwardRef(
3713
+ Spinner = React107__default.forwardRef(
3714
3714
  ({ className, size = "md", overlay, ...props }, ref) => {
3715
3715
  if (overlay) {
3716
3716
  return /* @__PURE__ */ jsx(
@@ -3800,7 +3800,7 @@ var init_Card = __esm({
3800
3800
  chip: "shadow-none rounded-pill border-[length:var(--border-width)] border-border",
3801
3801
  "tile-image-first": "p-0 overflow-hidden"
3802
3802
  };
3803
- Card = React106__default.forwardRef(
3803
+ Card = React107__default.forwardRef(
3804
3804
  ({
3805
3805
  className,
3806
3806
  variant = "bordered",
@@ -3848,9 +3848,9 @@ var init_Card = __esm({
3848
3848
  }
3849
3849
  );
3850
3850
  Card.displayName = "Card";
3851
- CardHeader = React106__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
3851
+ CardHeader = React107__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
3852
3852
  CardHeader.displayName = "CardHeader";
3853
- CardTitle = React106__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3853
+ CardTitle = React107__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3854
3854
  "h3",
3855
3855
  {
3856
3856
  ref,
@@ -3863,11 +3863,11 @@ var init_Card = __esm({
3863
3863
  }
3864
3864
  ));
3865
3865
  CardTitle.displayName = "CardTitle";
3866
- CardContent = React106__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
3866
+ CardContent = React107__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
3867
3867
  CardContent.displayName = "CardContent";
3868
3868
  CardBody = CardContent;
3869
3869
  CardBody.displayName = "CardBody";
3870
- CardFooter = React106__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3870
+ CardFooter = React107__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
3871
3871
  "div",
3872
3872
  {
3873
3873
  ref,
@@ -3922,7 +3922,7 @@ var init_FilterPill = __esm({
3922
3922
  md: "w-3.5 h-3.5",
3923
3923
  lg: "w-4 h-4"
3924
3924
  };
3925
- FilterPill = React106__default.forwardRef(
3925
+ FilterPill = React107__default.forwardRef(
3926
3926
  ({
3927
3927
  className,
3928
3928
  variant = "default",
@@ -4051,8 +4051,8 @@ var init_Avatar = __esm({
4051
4051
  actionPayload
4052
4052
  }) => {
4053
4053
  const eventBus = useEventBus();
4054
- const [imgFailed, setImgFailed] = React106__default.useState(false);
4055
- React106__default.useEffect(() => {
4054
+ const [imgFailed, setImgFailed] = React107__default.useState(false);
4055
+ React107__default.useEffect(() => {
4056
4056
  setImgFailed(false);
4057
4057
  }, [src]);
4058
4058
  const initials = providedInitials ?? (name ? generateInitials(name) : void 0);
@@ -4165,7 +4165,7 @@ var init_Center = __esm({
4165
4165
  as: Component = "div"
4166
4166
  }) => {
4167
4167
  const mergedStyle = minHeight ? { minHeight, ...style } : style;
4168
- return React106__default.createElement(Component, {
4168
+ return React107__default.createElement(Component, {
4169
4169
  className: cn(
4170
4170
  inline ? "inline-flex" : "flex",
4171
4171
  horizontal && "justify-center",
@@ -4433,7 +4433,7 @@ var init_Radio = __esm({
4433
4433
  md: "w-2.5 h-2.5",
4434
4434
  lg: "w-3 h-3"
4435
4435
  };
4436
- Radio = React106__default.forwardRef(
4436
+ Radio = React107__default.forwardRef(
4437
4437
  ({
4438
4438
  label,
4439
4439
  helperText,
@@ -4450,12 +4450,12 @@ var init_Radio = __esm({
4450
4450
  onChange,
4451
4451
  ...props
4452
4452
  }, ref) => {
4453
- const reactId = React106__default.useId();
4453
+ const reactId = React107__default.useId();
4454
4454
  const baseId = id || `radio-${reactId}`;
4455
4455
  const hasError = !!error;
4456
4456
  const eventBus = useEventBus();
4457
- const [selected, setSelected] = React106__default.useState(value);
4458
- React106__default.useEffect(() => {
4457
+ const [selected, setSelected] = React107__default.useState(value);
4458
+ React107__default.useEffect(() => {
4459
4459
  if (value !== void 0) setSelected(value);
4460
4460
  }, [value]);
4461
4461
  const pick = (next, e) => {
@@ -4637,7 +4637,7 @@ var init_Switch = __esm({
4637
4637
  "components/core/atoms/Switch.tsx"() {
4638
4638
  "use client";
4639
4639
  init_cn();
4640
- Switch = React106.forwardRef(
4640
+ Switch = React107.forwardRef(
4641
4641
  ({
4642
4642
  checked,
4643
4643
  defaultChecked = false,
@@ -4648,10 +4648,10 @@ var init_Switch = __esm({
4648
4648
  name,
4649
4649
  className
4650
4650
  }, ref) => {
4651
- const [isChecked, setIsChecked] = React106.useState(
4651
+ const [isChecked, setIsChecked] = React107.useState(
4652
4652
  checked !== void 0 ? checked : defaultChecked
4653
4653
  );
4654
- React106.useEffect(() => {
4654
+ React107.useEffect(() => {
4655
4655
  if (checked !== void 0) {
4656
4656
  setIsChecked(checked);
4657
4657
  }
@@ -4810,7 +4810,7 @@ var init_Stack = __esm({
4810
4810
  };
4811
4811
  const isHorizontal = direction === "horizontal";
4812
4812
  const directionClass = responsive && isHorizontal ? reverse ? "flex-col-reverse md:flex-row-reverse" : "flex-col md:flex-row" : isHorizontal ? reverse ? "flex-row-reverse" : "flex-row" : reverse ? "flex-col-reverse" : "flex-col";
4813
- return React106__default.createElement(
4813
+ return React107__default.createElement(
4814
4814
  Component,
4815
4815
  {
4816
4816
  className: cn(
@@ -5010,7 +5010,7 @@ var Aside;
5010
5010
  var init_Aside = __esm({
5011
5011
  "components/core/atoms/Aside.tsx"() {
5012
5012
  init_cn();
5013
- Aside = React106__default.forwardRef(
5013
+ Aside = React107__default.forwardRef(
5014
5014
  ({ className, children, ...rest }, ref) => /* @__PURE__ */ jsx("aside", { ref, className: cn(className), ...rest, children })
5015
5015
  );
5016
5016
  Aside.displayName = "Aside";
@@ -5089,9 +5089,9 @@ var init_LawReferenceTooltip = __esm({
5089
5089
  className
5090
5090
  }) => {
5091
5091
  const { t } = useTranslate();
5092
- const [isVisible, setIsVisible] = React106__default.useState(false);
5093
- const timeoutRef = React106__default.useRef(null);
5094
- const triggerRef = React106__default.useRef(null);
5092
+ const [isVisible, setIsVisible] = React107__default.useState(false);
5093
+ const timeoutRef = React107__default.useRef(null);
5094
+ const triggerRef = React107__default.useRef(null);
5095
5095
  const handleMouseEnter = () => {
5096
5096
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
5097
5097
  timeoutRef.current = setTimeout(() => setIsVisible(true), 200);
@@ -5102,7 +5102,7 @@ var init_LawReferenceTooltip = __esm({
5102
5102
  };
5103
5103
  const { revealed, triggerProps } = useTapReveal({ refs: [triggerRef] });
5104
5104
  const open = isVisible || revealed;
5105
- React106__default.useEffect(() => {
5105
+ React107__default.useEffect(() => {
5106
5106
  return () => {
5107
5107
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
5108
5108
  };
@@ -5312,7 +5312,7 @@ var init_StatusDot = __esm({
5312
5312
  md: "w-2.5 h-2.5",
5313
5313
  lg: "w-3 h-3"
5314
5314
  };
5315
- StatusDot = React106__default.forwardRef(
5315
+ StatusDot = React107__default.forwardRef(
5316
5316
  ({ className, status = "offline", pulse = false, size = "md", label, ...props }, ref) => {
5317
5317
  return /* @__PURE__ */ jsx(
5318
5318
  "span",
@@ -5366,7 +5366,7 @@ var init_TrendIndicator = __esm({
5366
5366
  down: "trending-down",
5367
5367
  flat: "arrow-right"
5368
5368
  };
5369
- TrendIndicator = React106__default.forwardRef(
5369
+ TrendIndicator = React107__default.forwardRef(
5370
5370
  ({
5371
5371
  className,
5372
5372
  value,
@@ -5433,7 +5433,7 @@ var init_RangeSlider = __esm({
5433
5433
  md: "w-4 h-4",
5434
5434
  lg: "w-5 h-5"
5435
5435
  };
5436
- RangeSlider = React106__default.forwardRef(
5436
+ RangeSlider = React107__default.forwardRef(
5437
5437
  ({
5438
5438
  className,
5439
5439
  min = 0,
@@ -5939,7 +5939,7 @@ var init_ContentSection = __esm({
5939
5939
  md: "py-16",
5940
5940
  lg: "py-24"
5941
5941
  };
5942
- ContentSection = React106__default.forwardRef(
5942
+ ContentSection = React107__default.forwardRef(
5943
5943
  ({ children, background = "default", padding = "lg", id, className }, ref) => {
5944
5944
  return /* @__PURE__ */ jsx(
5945
5945
  Box,
@@ -6473,7 +6473,7 @@ var init_AnimatedReveal = __esm({
6473
6473
  "scale-up": { opacity: 1, transform: "scale(1) translateY(0)" },
6474
6474
  "none": {}
6475
6475
  };
6476
- AnimatedReveal = React106__default.forwardRef(
6476
+ AnimatedReveal = React107__default.forwardRef(
6477
6477
  ({
6478
6478
  trigger = "scroll",
6479
6479
  animation = "fade-up",
@@ -6633,7 +6633,7 @@ var init_AnimatedGraphic = __esm({
6633
6633
  "components/marketing/atoms/AnimatedGraphic.tsx"() {
6634
6634
  "use client";
6635
6635
  init_cn();
6636
- AnimatedGraphic = React106__default.forwardRef(
6636
+ AnimatedGraphic = React107__default.forwardRef(
6637
6637
  ({
6638
6638
  src,
6639
6639
  svgContent,
@@ -6656,7 +6656,7 @@ var init_AnimatedGraphic = __esm({
6656
6656
  const fetchedSvg = useFetchedSvg(svgContent ? void 0 : src);
6657
6657
  const resolvedSvg = svgContent ?? fetchedSvg;
6658
6658
  const prevAnimateRef = useRef(animate);
6659
- const setRef = React106__default.useCallback(
6659
+ const setRef = React107__default.useCallback(
6660
6660
  (node) => {
6661
6661
  containerRef.current = node;
6662
6662
  if (typeof ref === "function") ref(node);
@@ -8276,7 +8276,7 @@ function GameCard({
8276
8276
  className
8277
8277
  }) {
8278
8278
  const eventBus = useEventBus();
8279
- const handleClick = React106.useCallback(() => {
8279
+ const handleClick = React107.useCallback(() => {
8280
8280
  if (disabled) return;
8281
8281
  onClick?.(id);
8282
8282
  if (clickEvent) eventBus.emit(`UI:${clickEvent}`, { cardId: id });
@@ -8548,9 +8548,9 @@ function ControlButton({
8548
8548
  className
8549
8549
  }) {
8550
8550
  const eventBus = useEventBus();
8551
- const [isPressed, setIsPressed] = React106.useState(false);
8551
+ const [isPressed, setIsPressed] = React107.useState(false);
8552
8552
  const actualPressed = pressed ?? isPressed;
8553
- const handlePointerDown = React106.useCallback(
8553
+ const handlePointerDown = React107.useCallback(
8554
8554
  (e) => {
8555
8555
  e.preventDefault();
8556
8556
  if (disabled) return;
@@ -8560,7 +8560,7 @@ function ControlButton({
8560
8560
  },
8561
8561
  [disabled, pressEvent, eventBus, onPress]
8562
8562
  );
8563
- const handlePointerUp = React106.useCallback(
8563
+ const handlePointerUp = React107.useCallback(
8564
8564
  (e) => {
8565
8565
  e.preventDefault();
8566
8566
  if (disabled) return;
@@ -8570,7 +8570,7 @@ function ControlButton({
8570
8570
  },
8571
8571
  [disabled, releaseEvent, eventBus, onRelease]
8572
8572
  );
8573
- const handlePointerLeave = React106.useCallback(
8573
+ const handlePointerLeave = React107.useCallback(
8574
8574
  (e) => {
8575
8575
  if (isPressed) {
8576
8576
  setIsPressed(false);
@@ -9629,8 +9629,8 @@ function MiniMap({
9629
9629
  viewportRect = DEFAULT_VIEWPORT,
9630
9630
  className
9631
9631
  }) {
9632
- const canvasRef = React106.useRef(null);
9633
- React106.useEffect(() => {
9632
+ const canvasRef = React107.useRef(null);
9633
+ React107.useEffect(() => {
9634
9634
  const canvas = canvasRef.current;
9635
9635
  if (!canvas) return;
9636
9636
  const ctx = canvas.getContext("2d");
@@ -9780,8 +9780,8 @@ function ControlGrid({
9780
9780
  className
9781
9781
  }) {
9782
9782
  const eventBus = useEventBus();
9783
- const [active, setActive] = React106.useState(/* @__PURE__ */ new Set());
9784
- const handlePress = React106.useCallback(
9783
+ const [active, setActive] = React107.useState(/* @__PURE__ */ new Set());
9784
+ const handlePress = React107.useCallback(
9785
9785
  (id) => {
9786
9786
  setActive((prev) => new Set(prev).add(id));
9787
9787
  if (actionEvent) eventBus.emit(`UI:${actionEvent}`, { id, pressed: true });
@@ -9793,7 +9793,7 @@ function ControlGrid({
9793
9793
  },
9794
9794
  [kind, actionEvent, directionEvent, eventBus, onAction, onDirection]
9795
9795
  );
9796
- const handleRelease = React106.useCallback(
9796
+ const handleRelease = React107.useCallback(
9797
9797
  (id) => {
9798
9798
  setActive((prev) => {
9799
9799
  const next = new Set(prev);
@@ -10054,7 +10054,7 @@ function InventoryGrid({
10054
10054
  const eventBus = useEventBus();
10055
10055
  const slotCount = totalSlots ?? items.length;
10056
10056
  const emptySlotCount = Math.max(0, slotCount - items.length);
10057
- const handleSelect = React106.useCallback(
10057
+ const handleSelect = React107.useCallback(
10058
10058
  (id) => {
10059
10059
  onSelect?.(id);
10060
10060
  if (selectEvent) {
@@ -10257,7 +10257,7 @@ function GameMenu({
10257
10257
  } catch {
10258
10258
  }
10259
10259
  const eventBus = eventBusProp || eventBusFromHook;
10260
- const handleOptionClick = React106.useCallback(
10260
+ const handleOptionClick = React107.useCallback(
10261
10261
  (option) => {
10262
10262
  if (option.event && eventBus) {
10263
10263
  eventBus.emit(`UI:${option.event}`, { option });
@@ -12100,6 +12100,24 @@ var init_useCanvasEffects = __esm({
12100
12100
  "use client";
12101
12101
  }
12102
12102
  });
12103
+ var init_useGameAudio = __esm({
12104
+ "components/game/shared/hooks/useGameAudio.ts"() {
12105
+ "use client";
12106
+ }
12107
+ });
12108
+ function useGameAudioContextOptional() {
12109
+ return useContext(GameAudioContext);
12110
+ }
12111
+ var GameAudioContext;
12112
+ var init_GameAudioProvider = __esm({
12113
+ "components/game/shared/providers/GameAudioProvider.tsx"() {
12114
+ "use client";
12115
+ init_useEventBus();
12116
+ init_useGameAudio();
12117
+ GameAudioContext = createContext(null);
12118
+ GameAudioContext.displayName = "GameAudioContext";
12119
+ }
12120
+ });
12103
12121
  function GameAudioToggle({
12104
12122
  size = "sm",
12105
12123
  className
@@ -12128,6 +12146,7 @@ var init_GameAudioToggle = __esm({
12128
12146
  "use client";
12129
12147
  init_atoms();
12130
12148
  init_cn();
12149
+ init_GameAudioProvider();
12131
12150
  GameAudioToggle.displayName = "GameAudioToggle";
12132
12151
  }
12133
12152
  });
@@ -15795,7 +15814,7 @@ function LinearView({
15795
15814
  /* @__PURE__ */ jsx(HStack, { className: "flex-wrap items-center", gap: "xs", children: trait.states.map((state, i) => {
15796
15815
  const isDone = i < currentIdx;
15797
15816
  const isCurrent = i === currentIdx;
15798
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
15817
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
15799
15818
  i > 0 && /* @__PURE__ */ jsx(
15800
15819
  Typography,
15801
15820
  {
@@ -16323,7 +16342,7 @@ function SequenceBar({
16323
16342
  onSlotRemove(index);
16324
16343
  }, [onSlotRemove, playing]);
16325
16344
  const paddedSlots = Array.from({ length: maxSlots }, (_, i) => slots[i]);
16326
- return /* @__PURE__ */ jsx(HStack, { className: cn("items-center", className), gap: "sm", children: paddedSlots.map((slot, i) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
16345
+ return /* @__PURE__ */ jsx(HStack, { className: cn("items-center", className), gap: "sm", children: paddedSlots.map((slot, i) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
16327
16346
  i > 0 && /* @__PURE__ */ jsx(
16328
16347
  Typography,
16329
16348
  {
@@ -18750,10 +18769,10 @@ function getSlotContentRenderer2() {
18750
18769
  }
18751
18770
  function resolveDescriptor(value, idPrefix) {
18752
18771
  if (value === null || value === void 0) return value;
18753
- if (React106__default.isValidElement(value)) return value;
18772
+ if (React107__default.isValidElement(value)) return value;
18754
18773
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
18755
18774
  if (Array.isArray(value)) {
18756
- return value.map((item, i) => /* @__PURE__ */ jsx(React106__default.Fragment, { children: resolveDescriptor(item, `${idPrefix}-${i}`) }, i));
18775
+ return value.map((item, i) => /* @__PURE__ */ jsx(React107__default.Fragment, { children: resolveDescriptor(item, `${idPrefix}-${i}`) }, i));
18757
18776
  }
18758
18777
  if (typeof value === "object") {
18759
18778
  const rec = value;
@@ -18889,7 +18908,7 @@ var init_GameTemplate = __esm({
18889
18908
  }
18890
18909
  });
18891
18910
  function asDescriptor(v) {
18892
- if (Array.isArray(v) || React106__default.isValidElement(v)) return null;
18911
+ if (Array.isArray(v) || React107__default.isValidElement(v)) return null;
18893
18912
  const o = v;
18894
18913
  if (typeof o.type !== "string") return null;
18895
18914
  const props = o.props !== void 0 && typeof o.props === "object" && !Array.isArray(o.props) && o.props !== null ? o.props : void 0;
@@ -18904,10 +18923,10 @@ function getSlotContentRenderer3() {
18904
18923
  }
18905
18924
  function resolveDescriptor2(value, idPrefix) {
18906
18925
  if (value === null || value === void 0) return value;
18907
- if (React106__default.isValidElement(value)) return value;
18926
+ if (React107__default.isValidElement(value)) return value;
18908
18927
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
18909
18928
  if (Array.isArray(value)) {
18910
- return value.map((item, i) => /* @__PURE__ */ jsx(React106__default.Fragment, { children: resolveDescriptor2(item, `${idPrefix}-${i}`) }, i));
18929
+ return value.map((item, i) => /* @__PURE__ */ jsx(React107__default.Fragment, { children: resolveDescriptor2(item, `${idPrefix}-${i}`) }, i));
18911
18930
  }
18912
18931
  if (typeof value === "object" && value !== null) {
18913
18932
  const desc = asDescriptor(value);
@@ -19791,6 +19810,8 @@ var init_CardBattlerTemplate = __esm({
19791
19810
  CardBattlerTemplate.displayName = "CardBattlerTemplate";
19792
19811
  }
19793
19812
  });
19813
+
19814
+ // components/game/2d/molecules/index.ts
19794
19815
  var init_molecules = __esm({
19795
19816
  "components/game/2d/molecules/index.ts"() {
19796
19817
  init_shared();
@@ -19885,7 +19906,7 @@ var init_ErrorBoundary = __esm({
19885
19906
  }
19886
19907
  );
19887
19908
  };
19888
- ErrorBoundary = class extends React106__default.Component {
19909
+ ErrorBoundary = class extends React107__default.Component {
19889
19910
  constructor(props) {
19890
19911
  super(props);
19891
19912
  __publicField(this, "reset", () => {
@@ -20550,7 +20571,7 @@ var init_Container = __esm({
20550
20571
  as: Component = "div"
20551
20572
  }) => {
20552
20573
  const resolvedSize = maxWidth ?? size ?? "lg";
20553
- return React106__default.createElement(
20574
+ return React107__default.createElement(
20554
20575
  Component,
20555
20576
  {
20556
20577
  className: cn(
@@ -23158,7 +23179,7 @@ var init_CodeBlock = __esm({
23158
23179
  };
23159
23180
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
23160
23181
  HIDDEN_LINE_NUMBERS = { display: "none" };
23161
- CodeBlock = React106__default.memo(
23182
+ CodeBlock = React107__default.memo(
23162
23183
  ({
23163
23184
  code: rawCode,
23164
23185
  language = "text",
@@ -23745,7 +23766,7 @@ var init_MarkdownContent = __esm({
23745
23766
  init_Box();
23746
23767
  init_CodeBlock();
23747
23768
  init_cn();
23748
- MarkdownContent = React106__default.memo(
23769
+ MarkdownContent = React107__default.memo(
23749
23770
  ({ content, direction = "ltr", className }) => {
23750
23771
  const { t: _t } = useTranslate();
23751
23772
  const safeContent = typeof content === "string" ? content : String(content ?? "");
@@ -25072,7 +25093,7 @@ var init_StateMachineView = __esm({
25072
25093
  style: { top: title ? 30 : 0 },
25073
25094
  children: [
25074
25095
  entity && /* @__PURE__ */ jsx(EntityBox, { entity, config }),
25075
- states.map((state) => renderStateNode ? /* @__PURE__ */ jsx(React106__default.Fragment, { children: renderStateNode(state, config) }, state.id) : /* @__PURE__ */ jsx(
25096
+ states.map((state) => renderStateNode ? /* @__PURE__ */ jsx(React107__default.Fragment, { children: renderStateNode(state, config) }, state.id) : /* @__PURE__ */ jsx(
25076
25097
  StateNode2,
25077
25098
  {
25078
25099
  state,
@@ -30701,8 +30722,8 @@ var init_Menu = __esm({
30701
30722
  "bottom-end": "bottom-start"
30702
30723
  };
30703
30724
  const effectivePosition = direction === "rtl" ? rtlMirror[position] ?? position : position;
30704
- const triggerChild = React106__default.isValidElement(trigger) ? trigger : /* @__PURE__ */ jsx(Typography, { variant: "small", as: "span", children: trigger });
30705
- const triggerElement = React106__default.cloneElement(
30725
+ const triggerChild = React107__default.isValidElement(trigger) ? trigger : /* @__PURE__ */ jsx(Typography, { variant: "small", as: "span", children: trigger });
30726
+ const triggerElement = React107__default.cloneElement(
30706
30727
  triggerChild,
30707
30728
  {
30708
30729
  ref: triggerRef,
@@ -30797,14 +30818,14 @@ function useDataDnd(args) {
30797
30818
  const isZone = Boolean(dragGroup || accepts || sortable);
30798
30819
  const enabled = isZone || Boolean(dndRoot);
30799
30820
  const eventBus = useEventBus();
30800
- const parentRoot = React106__default.useContext(RootCtx);
30821
+ const parentRoot = React107__default.useContext(RootCtx);
30801
30822
  const isRoot = enabled && parentRoot === null;
30802
- const zoneId = React106__default.useId();
30823
+ const zoneId = React107__default.useId();
30803
30824
  const ownGroup = dragGroup ?? accepts ?? zoneId;
30804
- const [optimisticOrders, setOptimisticOrders] = React106__default.useState(() => /* @__PURE__ */ new Map());
30805
- const optimisticOrdersRef = React106__default.useRef(optimisticOrders);
30825
+ const [optimisticOrders, setOptimisticOrders] = React107__default.useState(() => /* @__PURE__ */ new Map());
30826
+ const optimisticOrdersRef = React107__default.useRef(optimisticOrders);
30806
30827
  optimisticOrdersRef.current = optimisticOrders;
30807
- const clearOptimisticOrder = React106__default.useCallback((group) => {
30828
+ const clearOptimisticOrder = React107__default.useCallback((group) => {
30808
30829
  setOptimisticOrders((prev) => {
30809
30830
  if (!prev.has(group)) return prev;
30810
30831
  const next = new Map(prev);
@@ -30829,7 +30850,7 @@ function useDataDnd(args) {
30829
30850
  const raw = it[dndItemIdField];
30830
30851
  return raw != null ? String(raw) : `__idx_${idx}`;
30831
30852
  }).join("|");
30832
- const itemIds = React106__default.useMemo(
30853
+ const itemIds = React107__default.useMemo(
30833
30854
  () => orderedItems.map((it, idx) => {
30834
30855
  const raw = it[dndItemIdField];
30835
30856
  return raw != null ? String(raw) : `__idx_${idx}`;
@@ -30840,7 +30861,7 @@ function useDataDnd(args) {
30840
30861
  const raw = it[dndItemIdField];
30841
30862
  return raw != null ? String(raw) : `__${idx}`;
30842
30863
  }).join("|");
30843
- React106__default.useEffect(() => {
30864
+ React107__default.useEffect(() => {
30844
30865
  const root = isRoot ? null : parentRoot;
30845
30866
  if (root) {
30846
30867
  root.clearOptimisticOrder(ownGroup);
@@ -30848,20 +30869,20 @@ function useDataDnd(args) {
30848
30869
  clearOptimisticOrder(ownGroup);
30849
30870
  }
30850
30871
  }, [itemsContentSig, ownGroup]);
30851
- const zonesRef = React106__default.useRef(/* @__PURE__ */ new Map());
30852
- const registerZone = React106__default.useCallback((zoneId2, meta2) => {
30872
+ const zonesRef = React107__default.useRef(/* @__PURE__ */ new Map());
30873
+ const registerZone = React107__default.useCallback((zoneId2, meta2) => {
30853
30874
  zonesRef.current.set(zoneId2, meta2);
30854
30875
  }, []);
30855
- const unregisterZone = React106__default.useCallback((zoneId2) => {
30876
+ const unregisterZone = React107__default.useCallback((zoneId2) => {
30856
30877
  zonesRef.current.delete(zoneId2);
30857
30878
  }, []);
30858
- const [activeDrag, setActiveDrag] = React106__default.useState(null);
30859
- const [overZoneGroup, setOverZoneGroup] = React106__default.useState(null);
30860
- const meta = React106__default.useMemo(
30879
+ const [activeDrag, setActiveDrag] = React107__default.useState(null);
30880
+ const [overZoneGroup, setOverZoneGroup] = React107__default.useState(null);
30881
+ const meta = React107__default.useMemo(
30861
30882
  () => ({ group: ownGroup, dropEvent, reorderEvent, positionEvent, itemIds, rawItems: items, idField: dndItemIdField }),
30862
30883
  [ownGroup, dropEvent, reorderEvent, positionEvent, itemIds, items, dndItemIdField]
30863
30884
  );
30864
- React106__default.useEffect(() => {
30885
+ React107__default.useEffect(() => {
30865
30886
  const target = isRoot ? null : parentRoot;
30866
30887
  if (!target) {
30867
30888
  zonesRef.current.set(zoneId, meta);
@@ -30880,7 +30901,7 @@ function useDataDnd(args) {
30880
30901
  }, [parentRoot, isRoot, zoneId, meta]);
30881
30902
  const sensors = useAlmadarDndSensors(true);
30882
30903
  const collisionDetection = almadarDndCollisionDetection;
30883
- const findZoneByItem = React106__default.useCallback(
30904
+ const findZoneByItem = React107__default.useCallback(
30884
30905
  (id) => {
30885
30906
  for (const z of zonesRef.current.values()) {
30886
30907
  if (z.itemIds.includes(id)) return z;
@@ -30889,7 +30910,7 @@ function useDataDnd(args) {
30889
30910
  },
30890
30911
  []
30891
30912
  );
30892
- React106__default.useCallback(
30913
+ React107__default.useCallback(
30893
30914
  (group) => {
30894
30915
  for (const z of zonesRef.current.values()) {
30895
30916
  if (z.group === group) return z;
@@ -30898,7 +30919,7 @@ function useDataDnd(args) {
30898
30919
  },
30899
30920
  []
30900
30921
  );
30901
- const handleDragEnd = React106__default.useCallback(
30922
+ const handleDragEnd = React107__default.useCallback(
30902
30923
  (event) => {
30903
30924
  const { active, over } = event;
30904
30925
  const activeIdStr = String(active.id);
@@ -30989,8 +31010,8 @@ function useDataDnd(args) {
30989
31010
  },
30990
31011
  [eventBus]
30991
31012
  );
30992
- const sortableData = React106__default.useMemo(() => ({ dndGroup: ownGroup }), [ownGroup]);
30993
- const SortableItem = React106__default.useCallback(
31013
+ const sortableData = React107__default.useMemo(() => ({ dndGroup: ownGroup }), [ownGroup]);
31014
+ const SortableItem = React107__default.useCallback(
30994
31015
  ({ id, children }) => {
30995
31016
  const {
30996
31017
  attributes,
@@ -31030,7 +31051,7 @@ function useDataDnd(args) {
31030
31051
  id: droppableId,
31031
31052
  data: sortableData
31032
31053
  });
31033
- const ctx = React106__default.useContext(RootCtx);
31054
+ const ctx = React107__default.useContext(RootCtx);
31034
31055
  const activeDrag2 = ctx?.activeDrag ?? null;
31035
31056
  const overZoneGroup2 = ctx?.overZoneGroup ?? null;
31036
31057
  const isThisZoneOver = overZoneGroup2 === ownGroup;
@@ -31045,7 +31066,7 @@ function useDataDnd(args) {
31045
31066
  showForeignPlaceholder,
31046
31067
  ctxAvailable: ctx != null
31047
31068
  });
31048
- React106__default.useEffect(() => {
31069
+ React107__default.useEffect(() => {
31049
31070
  dndLog.info("dropzone:isOver:change", { droppableId, group: ownGroup, isOver, isThisZoneOver, showForeignPlaceholder, activeDragSourceGroup: activeDrag2?.sourceGroup ?? null });
31050
31071
  }, [droppableId, isOver, isThisZoneOver, showForeignPlaceholder]);
31051
31072
  return /* @__PURE__ */ jsx(
@@ -31059,11 +31080,11 @@ function useDataDnd(args) {
31059
31080
  }
31060
31081
  );
31061
31082
  };
31062
- const rootContextValue = React106__default.useMemo(
31083
+ const rootContextValue = React107__default.useMemo(
31063
31084
  () => ({ registerZone, unregisterZone, activeDrag, overZoneGroup, optimisticOrders, clearOptimisticOrder }),
31064
31085
  [registerZone, unregisterZone, activeDrag, overZoneGroup, optimisticOrders, clearOptimisticOrder]
31065
31086
  );
31066
- const handleDragStart = React106__default.useCallback((event) => {
31087
+ const handleDragStart = React107__default.useCallback((event) => {
31067
31088
  const sourceZone = findZoneByItem(event.active.id);
31068
31089
  const rect = event.active.rect.current.initial;
31069
31090
  const height = rect?.height && rect.height > 0 ? rect.height : 64;
@@ -31082,7 +31103,7 @@ function useDataDnd(args) {
31082
31103
  isRoot
31083
31104
  });
31084
31105
  }, [findZoneByItem, isRoot, zoneId]);
31085
- const handleDragOver = React106__default.useCallback((event) => {
31106
+ const handleDragOver = React107__default.useCallback((event) => {
31086
31107
  const { active, over } = event;
31087
31108
  const overData = over?.data?.current;
31088
31109
  const overGroup = overData?.dndGroup ?? null;
@@ -31152,7 +31173,7 @@ function useDataDnd(args) {
31152
31173
  return next;
31153
31174
  });
31154
31175
  }, []);
31155
- const handleDragCancel = React106__default.useCallback((event) => {
31176
+ const handleDragCancel = React107__default.useCallback((event) => {
31156
31177
  setActiveDrag(null);
31157
31178
  setOverZoneGroup(null);
31158
31179
  dndLog.warn("dragCancel", {
@@ -31160,12 +31181,12 @@ function useDataDnd(args) {
31160
31181
  reason: "dnd-kit cancelled the drag (escape key, pointer interrupted, or external)"
31161
31182
  });
31162
31183
  }, []);
31163
- const handleDragEndWithCleanup = React106__default.useCallback((event) => {
31184
+ const handleDragEndWithCleanup = React107__default.useCallback((event) => {
31164
31185
  handleDragEnd(event);
31165
31186
  setActiveDrag(null);
31166
31187
  setOverZoneGroup(null);
31167
31188
  }, [handleDragEnd]);
31168
- const wrapContainer = React106__default.useCallback(
31189
+ const wrapContainer = React107__default.useCallback(
31169
31190
  (children) => {
31170
31191
  if (!enabled) return children;
31171
31192
  const strategy = layout === "grid" ? rectSortingStrategy : verticalListSortingStrategy;
@@ -31219,7 +31240,7 @@ var init_useDataDnd = __esm({
31219
31240
  init_useAlmadarDndCollision();
31220
31241
  init_Box();
31221
31242
  dndLog = createLogger("almadar:ui:dnd");
31222
- RootCtx = React106__default.createContext(null);
31243
+ RootCtx = React107__default.createContext(null);
31223
31244
  }
31224
31245
  });
31225
31246
  function renderIconInput(icon, props) {
@@ -31745,7 +31766,7 @@ function DataList({
31745
31766
  }) {
31746
31767
  const eventBus = useEventBus();
31747
31768
  const { t } = useTranslate();
31748
- const [visibleCount, setVisibleCount] = React106__default.useState(pageSize || Infinity);
31769
+ const [visibleCount, setVisibleCount] = React107__default.useState(pageSize || Infinity);
31749
31770
  const fieldDefs = fields ?? columns ?? [];
31750
31771
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
31751
31772
  const dnd = useDataDnd({
@@ -31764,7 +31785,7 @@ function DataList({
31764
31785
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
31765
31786
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
31766
31787
  const hasRenderProp = typeof children === "function";
31767
- React106__default.useEffect(() => {
31788
+ React107__default.useEffect(() => {
31768
31789
  const renderItemTypeOf = typeof schemaRenderItem;
31769
31790
  const childrenTypeOf = typeof children;
31770
31791
  if (data.length > 0 && !hasRenderProp) {
@@ -31868,7 +31889,7 @@ function DataList({
31868
31889
  const items2 = [...data];
31869
31890
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
31870
31891
  const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
31871
- return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
31892
+ return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
31872
31893
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: "my-2" }),
31873
31894
  group.items.map((itemData, index) => {
31874
31895
  const id = itemData.id || `${gi}-${index}`;
@@ -32009,7 +32030,7 @@ function DataList({
32009
32030
  className
32010
32031
  ),
32011
32032
  children: [
32012
- groups.map((group, gi) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
32033
+ groups.map((group, gi) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
32013
32034
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: gi > 0 ? "mt-4" : "mt-0" }),
32014
32035
  group.items.map(
32015
32036
  (itemData, index) => renderItem(itemData, index, gi === groups.length - 1 && index === group.items.length - 1)
@@ -32802,7 +32823,7 @@ var init_Flex = __esm({
32802
32823
  flexStyle.flexBasis = typeof basis === "number" ? `${basis}px` : basis;
32803
32824
  }
32804
32825
  }
32805
- return React106__default.createElement(Component, {
32826
+ return React107__default.createElement(Component, {
32806
32827
  className: cn(
32807
32828
  inline ? "inline-flex" : "flex",
32808
32829
  directionStyles[direction],
@@ -32921,7 +32942,7 @@ var init_Grid = __esm({
32921
32942
  as: Component = "div"
32922
32943
  }) => {
32923
32944
  const mergedStyle = rows2 ? { gridTemplateRows: `repeat(${rows2}, minmax(0, 1fr))`, ...style } : style;
32924
- return React106__default.createElement(
32945
+ return React107__default.createElement(
32925
32946
  Component,
32926
32947
  {
32927
32948
  className: cn(
@@ -33117,9 +33138,9 @@ var init_Popover = __esm({
33117
33138
  onMouseLeave: handleClose,
33118
33139
  onPointerDown: tapTriggerProps.onPointerDown
33119
33140
  };
33120
- const childElement = React106__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
33141
+ const childElement = React107__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
33121
33142
  const childPointerDown = childElement.props.onPointerDown;
33122
- const triggerElement = React106__default.cloneElement(
33143
+ const triggerElement = React107__default.cloneElement(
33123
33144
  childElement,
33124
33145
  {
33125
33146
  ref: triggerRef,
@@ -33721,9 +33742,9 @@ var init_Tooltip = __esm({
33721
33742
  if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);
33722
33743
  };
33723
33744
  }, []);
33724
- const triggerElement = React106__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
33745
+ const triggerElement = React107__default.isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children });
33725
33746
  const childPointerDown = triggerElement.props.onPointerDown;
33726
- const trigger = React106__default.cloneElement(triggerElement, {
33747
+ const trigger = React107__default.cloneElement(triggerElement, {
33727
33748
  ref: triggerRef,
33728
33749
  onMouseEnter: handleMouseEnter,
33729
33750
  onMouseLeave: handleMouseLeave,
@@ -33813,7 +33834,7 @@ var init_WizardProgress = __esm({
33813
33834
  children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: normalizedSteps.map((step, index) => {
33814
33835
  const isActive = index === currentStep;
33815
33836
  const isCompleted = index < currentStep;
33816
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
33837
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
33817
33838
  /* @__PURE__ */ jsx(
33818
33839
  "button",
33819
33840
  {
@@ -35145,13 +35166,13 @@ var init_MapView = __esm({
35145
35166
  shadowSize: [41, 41]
35146
35167
  });
35147
35168
  L.Marker.prototype.options.icon = defaultIcon;
35148
- const { useEffect: useEffect72, useRef: useRef75, useCallback: useCallback114, useState: useState105 } = React106__default;
35169
+ const { useEffect: useEffect75, useRef: useRef76, useCallback: useCallback117, useState: useState108 } = React107__default;
35149
35170
  const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
35150
35171
  const { useEventBus: useEventBus2 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
35151
35172
  function MapUpdater({ centerLat, centerLng, zoom }) {
35152
35173
  const map = useMap();
35153
- const prevRef = useRef75({ centerLat, centerLng, zoom });
35154
- useEffect72(() => {
35174
+ const prevRef = useRef76({ centerLat, centerLng, zoom });
35175
+ useEffect75(() => {
35155
35176
  const prev = prevRef.current;
35156
35177
  if (prev.centerLat !== centerLat || prev.centerLng !== centerLng || prev.zoom !== zoom) {
35157
35178
  map.setView([centerLat, centerLng], zoom);
@@ -35162,7 +35183,7 @@ var init_MapView = __esm({
35162
35183
  }
35163
35184
  function MapClickHandler({ onMapClick }) {
35164
35185
  const map = useMap();
35165
- useEffect72(() => {
35186
+ useEffect75(() => {
35166
35187
  if (!onMapClick) return;
35167
35188
  const handler = (e) => {
35168
35189
  onMapClick(e.latlng.lat, e.latlng.lng);
@@ -35190,8 +35211,8 @@ var init_MapView = __esm({
35190
35211
  showAttribution = true
35191
35212
  }) {
35192
35213
  const eventBus = useEventBus2();
35193
- const [clickedPosition, setClickedPosition] = useState105(null);
35194
- const handleMapClick = useCallback114((lat, lng) => {
35214
+ const [clickedPosition, setClickedPosition] = useState108(null);
35215
+ const handleMapClick = useCallback117((lat, lng) => {
35195
35216
  if (showClickedPin) {
35196
35217
  setClickedPosition({ lat, lng });
35197
35218
  }
@@ -35200,7 +35221,7 @@ var init_MapView = __esm({
35200
35221
  eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
35201
35222
  }
35202
35223
  }, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
35203
- const handleMarkerClick = useCallback114((marker) => {
35224
+ const handleMarkerClick = useCallback117((marker) => {
35204
35225
  onMarkerClick?.(marker);
35205
35226
  if (markerClickEvent) {
35206
35227
  eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
@@ -36060,8 +36081,8 @@ function TableView({
36060
36081
  }) {
36061
36082
  const eventBus = useEventBus();
36062
36083
  const { t } = useTranslate();
36063
- const [visibleCount, setVisibleCount] = React106__default.useState(pageSize > 0 ? pageSize : Infinity);
36064
- const [localSelected, setLocalSelected] = React106__default.useState(/* @__PURE__ */ new Set());
36084
+ const [visibleCount, setVisibleCount] = React107__default.useState(pageSize > 0 ? pageSize : Infinity);
36085
+ const [localSelected, setLocalSelected] = React107__default.useState(/* @__PURE__ */ new Set());
36065
36086
  const colDefs = columns ?? fields ?? [];
36066
36087
  const allDataRaw = Array.isArray(entity) ? entity : entity ? [entity] : [];
36067
36088
  const dnd = useDataDnd({
@@ -36256,12 +36277,12 @@ function TableView({
36256
36277
  ]
36257
36278
  }
36258
36279
  );
36259
- return dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: row[idField] ?? id, children: rowInner }, id) : /* @__PURE__ */ jsx(React106__default.Fragment, { children: rowInner }, id);
36280
+ return dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: row[idField] ?? id, children: rowInner }, id) : /* @__PURE__ */ jsx(React107__default.Fragment, { children: rowInner }, id);
36260
36281
  };
36261
36282
  const items = Array.from(data);
36262
36283
  const groups = groupBy ? groupData2(items, groupBy) : [{ label: "", items }];
36263
36284
  let runningIndex = 0;
36264
- const body = /* @__PURE__ */ jsx(Box, { role: "rowgroup", children: groups.map((group, gi) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
36285
+ const body = /* @__PURE__ */ jsx(Box, { role: "rowgroup", children: groups.map((group, gi) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
36265
36286
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: gi > 0 ? "mt-3" : "mt-0" }),
36266
36287
  group.items.map((row) => renderRow(row, runningIndex++))
36267
36288
  ] }, gi)) });
@@ -37618,7 +37639,7 @@ var init_StepFlow = __esm({
37618
37639
  className
37619
37640
  }) => {
37620
37641
  if (orientation === "vertical") {
37621
- return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React106__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
37642
+ return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React107__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
37622
37643
  /* @__PURE__ */ jsxs(VStack, { gap: "none", align: "center", children: [
37623
37644
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
37624
37645
  showConnectors && index < steps.length - 1 && /* @__PURE__ */ jsx(Box, { className: "w-px h-8 bg-border" })
@@ -37629,7 +37650,7 @@ var init_StepFlow = __esm({
37629
37650
  ] })
37630
37651
  ] }) }, index)) });
37631
37652
  }
37632
- return /* @__PURE__ */ jsx(Box, { className: cn("w-full flex flex-col md:flex-row items-start gap-0", className), children: steps.map((step, index) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
37653
+ return /* @__PURE__ */ jsx(Box, { className: cn("w-full flex flex-col md:flex-row items-start gap-0", className), children: steps.map((step, index) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
37633
37654
  /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", className: "flex-1 w-full md:w-auto", children: [
37634
37655
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
37635
37656
  /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-center", children: step.title }),
@@ -38614,7 +38635,7 @@ var init_LikertScale = __esm({
38614
38635
  md: "text-base",
38615
38636
  lg: "text-lg"
38616
38637
  };
38617
- LikertScale = React106__default.forwardRef(
38638
+ LikertScale = React107__default.forwardRef(
38618
38639
  ({
38619
38640
  question,
38620
38641
  options = DEFAULT_LIKERT_OPTIONS,
@@ -38626,7 +38647,7 @@ var init_LikertScale = __esm({
38626
38647
  variant = "radios",
38627
38648
  className
38628
38649
  }, ref) => {
38629
- const groupId = React106__default.useId();
38650
+ const groupId = React107__default.useId();
38630
38651
  const eventBus = useEventBus();
38631
38652
  const handleSelect = useCallback(
38632
38653
  (next) => {
@@ -40908,7 +40929,7 @@ var init_DocBreadcrumb = __esm({
40908
40929
  "aria-label": t("aria.breadcrumb"),
40909
40930
  children: /* @__PURE__ */ jsx(HStack, { gap: "xs", align: "center", wrap: true, children: items.map((item, idx) => {
40910
40931
  const isLast = idx === items.length - 1;
40911
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
40932
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
40912
40933
  idx > 0 && /* @__PURE__ */ jsx(
40913
40934
  Icon,
40914
40935
  {
@@ -41777,7 +41798,7 @@ var init_MiniStateMachine = __esm({
41777
41798
  const x = 2 + i * (NODE_W + GAP + ARROW_W + GAP);
41778
41799
  const tc = transitionCounts[s.name] ?? 0;
41779
41800
  const role = getStateRole(s.name, s.isInitial ?? void 0, s.isTerminal ?? void 0, tc, maxTC);
41780
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
41801
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
41781
41802
  /* @__PURE__ */ jsx(
41782
41803
  AvlState,
41783
41804
  {
@@ -41981,7 +42002,7 @@ var init_PageHeader = __esm({
41981
42002
  info: "bg-info/10 text-info"
41982
42003
  };
41983
42004
  return /* @__PURE__ */ jsxs(Box, { className: cn("mb-6", className), children: [
41984
- breadcrumbs && breadcrumbs.length > 0 && /* @__PURE__ */ jsx(Box, { as: "nav", className: "mb-4", children: /* @__PURE__ */ jsx(Box, { as: "ol", className: "flex items-center gap-2 text-sm", children: breadcrumbs.map((crumb, idx) => /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
42005
+ breadcrumbs && breadcrumbs.length > 0 && /* @__PURE__ */ jsx(Box, { as: "nav", className: "mb-4", children: /* @__PURE__ */ jsx(Box, { as: "ol", className: "flex items-center gap-2 text-sm", children: breadcrumbs.map((crumb, idx) => /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
41985
42006
  idx > 0 && /* @__PURE__ */ jsx(Typography, { variant: "small", color: "muted", children: "/" }),
41986
42007
  crumb.href ? /* @__PURE__ */ jsx(
41987
42008
  "a",
@@ -42339,7 +42360,7 @@ var init_Section = __esm({
42339
42360
  as: Component = "section"
42340
42361
  }) => {
42341
42362
  const hasHeader = title || description || action;
42342
- return React106__default.createElement(
42363
+ return React107__default.createElement(
42343
42364
  Component,
42344
42365
  {
42345
42366
  className: cn(
@@ -42705,7 +42726,7 @@ var init_WizardContainer = __esm({
42705
42726
  const isCompleted = index < currentStep;
42706
42727
  const stepKey = step.id ?? step.tabId ?? `step-${index}`;
42707
42728
  const stepTitle = step.title ?? step.name ?? `Step ${index + 1}`;
42708
- return /* @__PURE__ */ jsxs(React106__default.Fragment, { children: [
42729
+ return /* @__PURE__ */ jsxs(React107__default.Fragment, { children: [
42709
42730
  /* @__PURE__ */ jsx(
42710
42731
  Button,
42711
42732
  {
@@ -45138,7 +45159,7 @@ var init_DetailPanel = __esm({
45138
45159
  }
45139
45160
  });
45140
45161
  function extractTitle(children) {
45141
- if (!React106__default.isValidElement(children)) return void 0;
45162
+ if (!React107__default.isValidElement(children)) return void 0;
45142
45163
  const props = children.props;
45143
45164
  if (typeof props.title === "string") {
45144
45165
  return props.title;
@@ -45484,12 +45505,12 @@ var init_Form = __esm({
45484
45505
  const isSchemaEntity = isOrbitalEntitySchema(entity);
45485
45506
  const resolvedEntity = isSchemaEntity ? entity : void 0;
45486
45507
  const entityName = typeof entity === "string" ? entity : resolvedEntity?.name;
45487
- const normalizedInitialData = React106__default.useMemo(() => {
45508
+ const normalizedInitialData = React107__default.useMemo(() => {
45488
45509
  const entityRowAsInitial = isPlainEntityRow(entity) ? entity : void 0;
45489
45510
  const callerInitial = initialData !== null && typeof initialData === "object" && !Array.isArray(initialData) ? initialData : {};
45490
45511
  return entityRowAsInitial !== void 0 ? { ...entityRowAsInitial, ...callerInitial } : callerInitial;
45491
45512
  }, [entity, initialData]);
45492
- const entityDerivedFields = React106__default.useMemo(() => {
45513
+ const entityDerivedFields = React107__default.useMemo(() => {
45493
45514
  if (fields && fields.length > 0) return void 0;
45494
45515
  if (!resolvedEntity) return void 0;
45495
45516
  return resolvedEntity.fields.map(
@@ -45510,16 +45531,16 @@ var init_Form = __esm({
45510
45531
  const conditionalFields = typeof conditionalFieldsRaw === "boolean" ? {} : conditionalFieldsRaw;
45511
45532
  const hiddenCalculations = typeof hiddenCalculationsRaw === "boolean" ? [] : hiddenCalculationsRaw;
45512
45533
  const violationTriggers = typeof violationTriggersRaw === "boolean" ? [] : violationTriggersRaw;
45513
- const [formData, setFormData] = React106__default.useState(
45534
+ const [formData, setFormData] = React107__default.useState(
45514
45535
  normalizedInitialData
45515
45536
  );
45516
- const [collapsedSections, setCollapsedSections] = React106__default.useState(
45537
+ const [collapsedSections, setCollapsedSections] = React107__default.useState(
45517
45538
  /* @__PURE__ */ new Set()
45518
45539
  );
45519
- const [submitError, setSubmitError] = React106__default.useState(null);
45520
- const formRef = React106__default.useRef(null);
45540
+ const [submitError, setSubmitError] = React107__default.useState(null);
45541
+ const formRef = React107__default.useRef(null);
45521
45542
  const formMode = props.mode;
45522
- const mountedRef = React106__default.useRef(false);
45543
+ const mountedRef = React107__default.useRef(false);
45523
45544
  if (!mountedRef.current) {
45524
45545
  mountedRef.current = true;
45525
45546
  debug("forms", "mount", {
@@ -45532,7 +45553,7 @@ var init_Form = __esm({
45532
45553
  });
45533
45554
  }
45534
45555
  const shouldShowCancel = showCancel ?? (fields && fields.length > 0);
45535
- const evalContext = React106__default.useMemo(
45556
+ const evalContext = React107__default.useMemo(
45536
45557
  () => ({
45537
45558
  formValues: formData,
45538
45559
  globalVariables: externalContext?.globalVariables ?? {},
@@ -45541,7 +45562,7 @@ var init_Form = __esm({
45541
45562
  }),
45542
45563
  [formData, externalContext]
45543
45564
  );
45544
- React106__default.useEffect(() => {
45565
+ React107__default.useEffect(() => {
45545
45566
  debug("forms", "initialData-sync", {
45546
45567
  mode: formMode,
45547
45568
  normalizedInitialData,
@@ -45552,7 +45573,7 @@ var init_Form = __esm({
45552
45573
  setFormData(normalizedInitialData);
45553
45574
  }
45554
45575
  }, [normalizedInitialData]);
45555
- const processCalculations = React106__default.useCallback(
45576
+ const processCalculations = React107__default.useCallback(
45556
45577
  (changedFieldId, newFormData) => {
45557
45578
  if (!hiddenCalculations.length) return;
45558
45579
  const context = {
@@ -45577,7 +45598,7 @@ var init_Form = __esm({
45577
45598
  },
45578
45599
  [hiddenCalculations, externalContext, eventBus]
45579
45600
  );
45580
- const checkViolations = React106__default.useCallback(
45601
+ const checkViolations = React107__default.useCallback(
45581
45602
  (changedFieldId, newFormData) => {
45582
45603
  if (!violationTriggers.length) return;
45583
45604
  const context = {
@@ -45615,7 +45636,7 @@ var init_Form = __esm({
45615
45636
  processCalculations(name, newFormData);
45616
45637
  checkViolations(name, newFormData);
45617
45638
  };
45618
- const isFieldVisible = React106__default.useCallback(
45639
+ const isFieldVisible = React107__default.useCallback(
45619
45640
  (fieldName) => {
45620
45641
  const condition = conditionalFields[fieldName];
45621
45642
  if (!condition) return true;
@@ -45623,7 +45644,7 @@ var init_Form = __esm({
45623
45644
  },
45624
45645
  [conditionalFields, evalContext]
45625
45646
  );
45626
- const isSectionVisible = React106__default.useCallback(
45647
+ const isSectionVisible = React107__default.useCallback(
45627
45648
  (section) => {
45628
45649
  if (!section.condition) return true;
45629
45650
  return Boolean(evaluateFormExpression(section.condition, evalContext));
@@ -45699,7 +45720,7 @@ var init_Form = __esm({
45699
45720
  eventBus.emit(`UI:${onCancel}`);
45700
45721
  }
45701
45722
  };
45702
- const renderField = React106__default.useCallback(
45723
+ const renderField = React107__default.useCallback(
45703
45724
  (field) => {
45704
45725
  const fieldName = field.name || field.field;
45705
45726
  if (!fieldName) return null;
@@ -45720,7 +45741,7 @@ var init_Form = __esm({
45720
45741
  [formData, isFieldVisible, relationsData, relationsLoading, isLoading]
45721
45742
  );
45722
45743
  const effectiveFields = entityDerivedFields ?? fields;
45723
- const normalizedFields = React106__default.useMemo(() => {
45744
+ const normalizedFields = React107__default.useMemo(() => {
45724
45745
  if (!effectiveFields || effectiveFields.length === 0) return [];
45725
45746
  return effectiveFields.map((field) => {
45726
45747
  if (typeof field === "string") {
@@ -45744,7 +45765,7 @@ var init_Form = __esm({
45744
45765
  return field;
45745
45766
  });
45746
45767
  }, [effectiveFields, resolvedEntity]);
45747
- const schemaFields = React106__default.useMemo(() => {
45768
+ const schemaFields = React107__default.useMemo(() => {
45748
45769
  if (normalizedFields.length === 0) return null;
45749
45770
  if (isDebugEnabled()) {
45750
45771
  debugGroup(`Form: ${entityName || "unknown"}`);
@@ -45754,7 +45775,7 @@ var init_Form = __esm({
45754
45775
  }
45755
45776
  return normalizedFields.map(renderField).filter(Boolean);
45756
45777
  }, [normalizedFields, renderField, entityName, conditionalFields]);
45757
- const sectionElements = React106__default.useMemo(() => {
45778
+ const sectionElements = React107__default.useMemo(() => {
45758
45779
  if (!sections || sections.length === 0) return null;
45759
45780
  return sections.map((section) => {
45760
45781
  if (!isSectionVisible(section)) {
@@ -46479,7 +46500,7 @@ var init_List = __esm({
46479
46500
  if (entity && typeof entity === "object" && "id" in entity) return [entity];
46480
46501
  return [];
46481
46502
  }, [entity]);
46482
- const getItemActions = React106__default.useCallback(
46503
+ const getItemActions = React107__default.useCallback(
46483
46504
  (item) => {
46484
46505
  if (!itemActions) return [];
46485
46506
  if (typeof itemActions === "function") {
@@ -46954,7 +46975,7 @@ var init_MediaGallery = __esm({
46954
46975
  [selectable, selectedItems, selectionEvent, eventBus]
46955
46976
  );
46956
46977
  const entityData = Array.isArray(entity) ? entity : [];
46957
- const items = React106__default.useMemo(() => {
46978
+ const items = React107__default.useMemo(() => {
46958
46979
  if (propItems) return propItems;
46959
46980
  if (entityData.length === 0) return [];
46960
46981
  return entityData.map((record, idx) => {
@@ -47117,7 +47138,7 @@ var init_MediaGallery = __esm({
47117
47138
  }
47118
47139
  });
47119
47140
  function extractTitle2(children) {
47120
- if (!React106__default.isValidElement(children)) return void 0;
47141
+ if (!React107__default.isValidElement(children)) return void 0;
47121
47142
  const props = children.props;
47122
47143
  if (typeof props.title === "string") {
47123
47144
  return props.title;
@@ -47368,7 +47389,7 @@ var init_debugRegistry = __esm({
47368
47389
  }
47369
47390
  });
47370
47391
  function useDebugData() {
47371
- const [data, setData] = React106.useState(() => ({
47392
+ const [data, setData] = React107.useState(() => ({
47372
47393
  traits: [],
47373
47394
  ticks: [],
47374
47395
  guards: [],
@@ -47382,7 +47403,7 @@ function useDebugData() {
47382
47403
  },
47383
47404
  lastUpdate: Date.now()
47384
47405
  }));
47385
- React106.useEffect(() => {
47406
+ React107.useEffect(() => {
47386
47407
  const updateData = () => {
47387
47408
  setData({
47388
47409
  traits: getAllTraits(),
@@ -47491,12 +47512,12 @@ function layoutGraph(states, transitions, initialState, width, height) {
47491
47512
  return positions;
47492
47513
  }
47493
47514
  function WalkMinimap() {
47494
- const [walkStep, setWalkStep] = React106.useState(null);
47495
- const [traits2, setTraits] = React106.useState([]);
47496
- const [coveredEdges, setCoveredEdges] = React106.useState([]);
47497
- const [completedTraits, setCompletedTraits] = React106.useState(/* @__PURE__ */ new Set());
47498
- const prevTraitRef = React106.useRef(null);
47499
- React106.useEffect(() => {
47515
+ const [walkStep, setWalkStep] = React107.useState(null);
47516
+ const [traits2, setTraits] = React107.useState([]);
47517
+ const [coveredEdges, setCoveredEdges] = React107.useState([]);
47518
+ const [completedTraits, setCompletedTraits] = React107.useState(/* @__PURE__ */ new Set());
47519
+ const prevTraitRef = React107.useRef(null);
47520
+ React107.useEffect(() => {
47500
47521
  const interval = setInterval(() => {
47501
47522
  const w = window;
47502
47523
  const step = w.__orbitalWalkStep;
@@ -47932,15 +47953,15 @@ var init_EntitiesTab = __esm({
47932
47953
  });
47933
47954
  function EventFlowTab({ events: events2 }) {
47934
47955
  const { t } = useTranslate();
47935
- const [filter, setFilter] = React106.useState("all");
47936
- const containerRef = React106.useRef(null);
47937
- const [autoScroll, setAutoScroll] = React106.useState(true);
47938
- React106.useEffect(() => {
47956
+ const [filter, setFilter] = React107.useState("all");
47957
+ const containerRef = React107.useRef(null);
47958
+ const [autoScroll, setAutoScroll] = React107.useState(true);
47959
+ React107.useEffect(() => {
47939
47960
  if (autoScroll && containerRef.current) {
47940
47961
  containerRef.current.scrollTop = containerRef.current.scrollHeight;
47941
47962
  }
47942
47963
  }, [events2.length, autoScroll]);
47943
- const filteredEvents = React106.useMemo(() => {
47964
+ const filteredEvents = React107.useMemo(() => {
47944
47965
  if (filter === "all") return events2;
47945
47966
  return events2.filter((e) => e.type === filter);
47946
47967
  }, [events2, filter]);
@@ -48056,7 +48077,7 @@ var init_EventFlowTab = __esm({
48056
48077
  });
48057
48078
  function GuardsPanel({ guards }) {
48058
48079
  const { t } = useTranslate();
48059
- const [filter, setFilter] = React106.useState("all");
48080
+ const [filter, setFilter] = React107.useState("all");
48060
48081
  if (guards.length === 0) {
48061
48082
  return /* @__PURE__ */ jsx(
48062
48083
  EmptyState,
@@ -48069,7 +48090,7 @@ function GuardsPanel({ guards }) {
48069
48090
  }
48070
48091
  const passedCount = guards.filter((g) => g.result).length;
48071
48092
  const failedCount = guards.length - passedCount;
48072
- const filteredGuards = React106.useMemo(() => {
48093
+ const filteredGuards = React107.useMemo(() => {
48073
48094
  if (filter === "all") return guards;
48074
48095
  if (filter === "passed") return guards.filter((g) => g.result);
48075
48096
  return guards.filter((g) => !g.result);
@@ -48232,10 +48253,10 @@ function EffectBadge({ effect }) {
48232
48253
  }
48233
48254
  function TransitionTimeline({ transitions }) {
48234
48255
  const { t } = useTranslate();
48235
- const containerRef = React106.useRef(null);
48236
- const [autoScroll, setAutoScroll] = React106.useState(true);
48237
- const [expandedId, setExpandedId] = React106.useState(null);
48238
- React106.useEffect(() => {
48256
+ const containerRef = React107.useRef(null);
48257
+ const [autoScroll, setAutoScroll] = React107.useState(true);
48258
+ const [expandedId, setExpandedId] = React107.useState(null);
48259
+ React107.useEffect(() => {
48239
48260
  if (autoScroll && containerRef.current) {
48240
48261
  containerRef.current.scrollTop = containerRef.current.scrollHeight;
48241
48262
  }
@@ -48515,9 +48536,9 @@ function getAllEvents(traits2) {
48515
48536
  function EventDispatcherTab({ traits: traits2, schema }) {
48516
48537
  const eventBus = useEventBus();
48517
48538
  const { t } = useTranslate();
48518
- const [log11, setLog] = React106.useState([]);
48519
- const prevStatesRef = React106.useRef(/* @__PURE__ */ new Map());
48520
- React106.useEffect(() => {
48539
+ const [log13, setLog] = React107.useState([]);
48540
+ const prevStatesRef = React107.useRef(/* @__PURE__ */ new Map());
48541
+ React107.useEffect(() => {
48521
48542
  for (const trait of traits2) {
48522
48543
  const prev = prevStatesRef.current.get(trait.id);
48523
48544
  if (prev && prev !== trait.currentState) {
@@ -48579,9 +48600,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
48579
48600
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: t("debug.otherEvents") }),
48580
48601
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
48581
48602
  ] }),
48582
- log11.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
48603
+ log13.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
48583
48604
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: t("debug.recentTransitions") }),
48584
- /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log11.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
48605
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log13.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
48585
48606
  /* @__PURE__ */ jsx("span", { className: "text-purple-400", children: entry.traitName }),
48586
48607
  " ",
48587
48608
  /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -48686,10 +48707,10 @@ function VerifyModePanel({
48686
48707
  localCount
48687
48708
  }) {
48688
48709
  const { t } = useTranslate();
48689
- const [expanded, setExpanded] = React106.useState(true);
48690
- const scrollRef = React106.useRef(null);
48691
- const prevCountRef = React106.useRef(0);
48692
- React106.useEffect(() => {
48710
+ const [expanded, setExpanded] = React107.useState(true);
48711
+ const scrollRef = React107.useRef(null);
48712
+ const prevCountRef = React107.useRef(0);
48713
+ React107.useEffect(() => {
48693
48714
  if (expanded && transitions.length > prevCountRef.current && scrollRef.current) {
48694
48715
  scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
48695
48716
  }
@@ -48746,10 +48767,10 @@ function RuntimeDebugger({
48746
48767
  schema
48747
48768
  }) {
48748
48769
  const { t } = useTranslate();
48749
- const [isCollapsed, setIsCollapsed] = React106.useState(mode === "verify" ? true : defaultCollapsed);
48750
- const [isVisible, setIsVisible] = React106.useState(mode === "inline" || mode === "verify" || isDebugEnabled2());
48770
+ const [isCollapsed, setIsCollapsed] = React107.useState(mode === "verify" ? true : defaultCollapsed);
48771
+ const [isVisible, setIsVisible] = React107.useState(mode === "inline" || mode === "verify" || isDebugEnabled2());
48751
48772
  const debugData = useDebugData();
48752
- React106.useEffect(() => {
48773
+ React107.useEffect(() => {
48753
48774
  if (mode === "inline") return;
48754
48775
  return onDebugToggle((enabled) => {
48755
48776
  setIsVisible(enabled);
@@ -48758,7 +48779,7 @@ function RuntimeDebugger({
48758
48779
  }
48759
48780
  });
48760
48781
  }, [mode]);
48761
- React106.useEffect(() => {
48782
+ React107.useEffect(() => {
48762
48783
  if (mode === "inline") return;
48763
48784
  const handleKeyDown = (e) => {
48764
48785
  if (e.key === "`" && isVisible) {
@@ -49278,7 +49299,7 @@ var init_StatCard = __esm({
49278
49299
  const labelToUse = propLabel ?? propTitle;
49279
49300
  const eventBus = useEventBus();
49280
49301
  const { t } = useTranslate();
49281
- const handleActionClick = React106__default.useCallback(() => {
49302
+ const handleActionClick = React107__default.useCallback(() => {
49282
49303
  if (action?.event) {
49283
49304
  eventBus.emit(`UI:${action.event}`, {});
49284
49305
  }
@@ -49289,7 +49310,7 @@ var init_StatCard = __esm({
49289
49310
  const data = Array.isArray(entity) ? entity : entity ? [entity] : [];
49290
49311
  const isLoading = externalLoading ?? false;
49291
49312
  const error = externalError;
49292
- const computeMetricValue = React106__default.useCallback(
49313
+ const computeMetricValue = React107__default.useCallback(
49293
49314
  (metric, items) => {
49294
49315
  if (metric.value !== void 0) {
49295
49316
  return metric.value;
@@ -49328,7 +49349,7 @@ var init_StatCard = __esm({
49328
49349
  },
49329
49350
  []
49330
49351
  );
49331
- const schemaStats = React106__default.useMemo(() => {
49352
+ const schemaStats = React107__default.useMemo(() => {
49332
49353
  if (!metrics || metrics.length === 0) return null;
49333
49354
  return metrics.map((metric) => ({
49334
49355
  label: metric.label,
@@ -49336,7 +49357,7 @@ var init_StatCard = __esm({
49336
49357
  format: metric.format
49337
49358
  }));
49338
49359
  }, [metrics, data, computeMetricValue]);
49339
- const calculatedTrend = React106__default.useMemo(() => {
49360
+ const calculatedTrend = React107__default.useMemo(() => {
49340
49361
  if (manualTrend !== void 0) return manualTrend;
49341
49362
  if (previousValue === void 0 || currentValue === void 0)
49342
49363
  return void 0;
@@ -49976,8 +49997,8 @@ var init_SubagentTracePanel = __esm({
49976
49997
  ] });
49977
49998
  };
49978
49999
  InlineActivityStream = ({ activities, autoScroll = true, className }) => {
49979
- const endRef = React106__default.useRef(null);
49980
- React106__default.useEffect(() => {
50000
+ const endRef = React107__default.useRef(null);
50001
+ React107__default.useEffect(() => {
49981
50002
  if (!autoScroll) return;
49982
50003
  endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
49983
50004
  }, [activities.length, autoScroll]);
@@ -50071,7 +50092,7 @@ var init_SubagentTracePanel = __esm({
50071
50092
  };
50072
50093
  SubagentRichCard = ({ subagent }) => {
50073
50094
  const { t } = useTranslate();
50074
- const activities = React106__default.useMemo(
50095
+ const activities = React107__default.useMemo(
50075
50096
  () => subagentMessagesToActivities(subagent.messages),
50076
50097
  [subagent.messages]
50077
50098
  );
@@ -50148,8 +50169,8 @@ var init_SubagentTracePanel = __esm({
50148
50169
  ] });
50149
50170
  };
50150
50171
  CoordinatorConversation = ({ messages, autoScroll = true, className }) => {
50151
- const endRef = React106__default.useRef(null);
50152
- React106__default.useEffect(() => {
50172
+ const endRef = React107__default.useRef(null);
50173
+ React107__default.useEffect(() => {
50153
50174
  if (!autoScroll) return;
50154
50175
  endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
50155
50176
  }, [messages.length, autoScroll]);
@@ -50579,7 +50600,7 @@ var init_Timeline = __esm({
50579
50600
  }) => {
50580
50601
  const { t } = useTranslate();
50581
50602
  const entityData = entity ?? [];
50582
- const items = React106__default.useMemo(() => {
50603
+ const items = React107__default.useMemo(() => {
50583
50604
  if (propItems) return propItems;
50584
50605
  if (entityData.length === 0) return [];
50585
50606
  return entityData.map((record, idx) => {
@@ -50681,7 +50702,7 @@ var init_Timeline = __esm({
50681
50702
  }
50682
50703
  });
50683
50704
  function extractToastProps(children) {
50684
- if (!React106__default.isValidElement(children)) {
50705
+ if (!React107__default.isValidElement(children)) {
50685
50706
  if (typeof children === "string") {
50686
50707
  return { message: children };
50687
50708
  }
@@ -50719,7 +50740,7 @@ var init_ToastSlot = __esm({
50719
50740
  eventBus.emit("UI:CLOSE");
50720
50741
  };
50721
50742
  if (!isVisible) return null;
50722
- const isCustomContent = React106__default.isValidElement(children) && !message;
50743
+ const isCustomContent = React107__default.isValidElement(children) && !message;
50723
50744
  return /* @__PURE__ */ jsx(Box, { className: "fixed bottom-4 right-4 z-50", children: isCustomContent ? children : /* @__PURE__ */ jsx(
50724
50745
  Toast,
50725
50746
  {
@@ -51361,7 +51382,7 @@ function SuspenseConfigProvider({
51361
51382
  config,
51362
51383
  children
51363
51384
  }) {
51364
- return React106__default.createElement(
51385
+ return React107__default.createElement(
51365
51386
  SuspenseConfigContext.Provider,
51366
51387
  { value: config },
51367
51388
  children
@@ -51403,7 +51424,7 @@ function enrichFormFields(fields, entityDef) {
51403
51424
  }
51404
51425
  return { name: field, label: field.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (c) => c.toUpperCase()) };
51405
51426
  }
51406
- if (field && typeof field === "object" && !Array.isArray(field) && !React106__default.isValidElement(field) && !(field instanceof Date)) {
51427
+ if (field && typeof field === "object" && !Array.isArray(field) && !React107__default.isValidElement(field) && !(field instanceof Date)) {
51407
51428
  const obj = field;
51408
51429
  const fieldName = typeof obj.name === "string" ? obj.name : typeof obj.field === "string" ? obj.field : void 0;
51409
51430
  if (!fieldName) return field;
@@ -51849,7 +51870,7 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
51849
51870
  const key = `${parentId}-${index}-trait:${traitName}`;
51850
51871
  return /* @__PURE__ */ jsx(TraitFrame, { traitName }, key);
51851
51872
  }
51852
- return /* @__PURE__ */ jsx(React106__default.Fragment, { children: child }, `${parentId}-${index}`);
51873
+ return /* @__PURE__ */ jsx(React107__default.Fragment, { children: child }, `${parentId}-${index}`);
51853
51874
  }
51854
51875
  if (!child || typeof child !== "object") return null;
51855
51876
  const childId = `${parentId}-${index}`;
@@ -51889,14 +51910,14 @@ function isPatternConfig(value) {
51889
51910
  if (value === null || value === void 0) return false;
51890
51911
  if (typeof value !== "object") return false;
51891
51912
  if (Array.isArray(value)) return false;
51892
- if (React106__default.isValidElement(value)) return false;
51913
+ if (React107__default.isValidElement(value)) return false;
51893
51914
  if (value instanceof Date) return false;
51894
51915
  if (typeof value === "function") return false;
51895
51916
  const record = value;
51896
51917
  return "type" in record && typeof record.type === "string" && getComponentForPattern(record.type) !== null;
51897
51918
  }
51898
51919
  function isPlainConfigObject(value) {
51899
- if (React106__default.isValidElement(value)) return false;
51920
+ if (React107__default.isValidElement(value)) return false;
51900
51921
  if (value instanceof Date) return false;
51901
51922
  const proto = Object.getPrototypeOf(value);
51902
51923
  return proto === Object.prototype || proto === null;
@@ -52022,7 +52043,7 @@ function SlotContentRenderer({
52022
52043
  for (const slotKey of CONTENT_NODE_SLOTS) {
52023
52044
  const slotVal = restProps[slotKey];
52024
52045
  if (slotVal === void 0 || slotVal === null) continue;
52025
- if (React106__default.isValidElement(slotVal) || typeof slotVal === "string" || typeof slotVal === "number" || typeof slotVal === "boolean") continue;
52046
+ if (React107__default.isValidElement(slotVal) || typeof slotVal === "string" || typeof slotVal === "number" || typeof slotVal === "boolean") continue;
52026
52047
  if (Array.isArray(slotVal) || typeof slotVal === "object" && "type" in slotVal) {
52027
52048
  nodeSlotOverrides[slotKey] = renderPatternChildren(
52028
52049
  slotVal,
@@ -52071,7 +52092,7 @@ function SlotContentRenderer({
52071
52092
  const resolvedItems = Array.isArray(entityVal) && entityVal[0] !== "fn" ? entityVal : null;
52072
52093
  if (resolvedItems && resolvedItems.length > 0 && !finalProps.fields && !finalProps.columns) {
52073
52094
  const sample = resolvedItems[0];
52074
- if (sample && typeof sample === "object" && !Array.isArray(sample) && !React106__default.isValidElement(sample) && !(sample instanceof Date)) {
52095
+ if (sample && typeof sample === "object" && !Array.isArray(sample) && !React107__default.isValidElement(sample) && !(sample instanceof Date)) {
52075
52096
  const keys = Object.keys(sample).filter((k) => k !== "id" && k !== "_id");
52076
52097
  finalProps.fields = keys.map((k, i) => ({ name: k, variant: i === 0 ? "h4" : "body" }));
52077
52098
  }
@@ -53067,6 +53088,525 @@ function useUserForEvaluation() {
53067
53088
  const { user, isLoggedIn } = useUser();
53068
53089
  return isLoggedIn && user ? user : void 0;
53069
53090
  }
53091
+ var EntitySchemaContext = createContext(null);
53092
+ function EntitySchemaProvider({
53093
+ entities,
53094
+ traitLinkedEntities,
53095
+ orbitalsByTrait,
53096
+ children
53097
+ }) {
53098
+ const entitiesMap = useMemo(() => {
53099
+ const map = /* @__PURE__ */ new Map();
53100
+ for (const entity of entities) {
53101
+ map.set(entity.name, entity);
53102
+ }
53103
+ return map;
53104
+ }, [entities]);
53105
+ const linkedMap = useMemo(() => {
53106
+ return traitLinkedEntities ?? /* @__PURE__ */ new Map();
53107
+ }, [traitLinkedEntities]);
53108
+ const orbitalsMap = useMemo(() => {
53109
+ return orbitalsByTrait ?? /* @__PURE__ */ new Map();
53110
+ }, [orbitalsByTrait]);
53111
+ const contextValue = useMemo(
53112
+ () => ({
53113
+ entities: entitiesMap,
53114
+ traitLinkedEntities: linkedMap,
53115
+ orbitalsByTrait: orbitalsMap
53116
+ }),
53117
+ [entitiesMap, linkedMap, orbitalsMap]
53118
+ );
53119
+ return /* @__PURE__ */ jsx(EntitySchemaContext.Provider, { value: contextValue, children });
53120
+ }
53121
+ function useEntitySchema() {
53122
+ const context = useContext(EntitySchemaContext);
53123
+ if (!context) {
53124
+ throw new Error("useEntitySchema must be used within an EntitySchemaProvider");
53125
+ }
53126
+ return context;
53127
+ }
53128
+ function useEntitySchemaOptional3() {
53129
+ return useContext(EntitySchemaContext);
53130
+ }
53131
+ var log11 = createLogger("almadar:ui:navigation");
53132
+ function matchPath2(pattern, path) {
53133
+ const normalizeSegment = (p2) => {
53134
+ let normalized = p2.trim();
53135
+ if (!normalized.startsWith("/")) normalized = "/" + normalized;
53136
+ if (normalized.length > 1 && normalized.endsWith("/")) {
53137
+ normalized = normalized.slice(0, -1);
53138
+ }
53139
+ return normalized;
53140
+ };
53141
+ const normalizedPattern = normalizeSegment(pattern);
53142
+ const normalizedPath = normalizeSegment(path);
53143
+ const patternParts = normalizedPattern.split("/").filter(Boolean);
53144
+ const pathParts = normalizedPath.split("/").filter(Boolean);
53145
+ if (patternParts.length !== pathParts.length) {
53146
+ return null;
53147
+ }
53148
+ const params = {};
53149
+ for (let i = 0; i < patternParts.length; i++) {
53150
+ const patternPart = patternParts[i];
53151
+ const pathPart = pathParts[i];
53152
+ if (patternPart.startsWith(":")) {
53153
+ const paramName = patternPart.slice(1);
53154
+ params[paramName] = decodeURIComponent(pathPart);
53155
+ } else if (patternPart !== pathPart) {
53156
+ return null;
53157
+ }
53158
+ }
53159
+ return params;
53160
+ }
53161
+ function extractRouteParams2(pattern, path) {
53162
+ return matchPath2(pattern, path) || {};
53163
+ }
53164
+ function pathMatches2(pattern, path) {
53165
+ return matchPath2(pattern, path) !== null;
53166
+ }
53167
+ function isInlineOrbital(orbital) {
53168
+ return "name" in orbital && typeof orbital.name === "string";
53169
+ }
53170
+ function isInlinePage(page) {
53171
+ return typeof page === "object" && page !== null && "name" in page && typeof page.name === "string";
53172
+ }
53173
+ function findPageByPath2(schema, path) {
53174
+ if (!schema.orbitals) return null;
53175
+ for (const orbital of schema.orbitals) {
53176
+ if (!isInlineOrbital(orbital)) continue;
53177
+ if (!orbital.pages) continue;
53178
+ for (const pageRef of orbital.pages) {
53179
+ if (!isInlinePage(pageRef)) continue;
53180
+ const page = pageRef;
53181
+ const pagePath = page.path;
53182
+ if (!pagePath) continue;
53183
+ const params = matchPath2(pagePath, path);
53184
+ if (params !== null) {
53185
+ return { page, params, orbitalName: orbital.name };
53186
+ }
53187
+ }
53188
+ }
53189
+ return null;
53190
+ }
53191
+ function findPageByName2(schema, pageName) {
53192
+ if (!schema.orbitals) return null;
53193
+ for (const orbital of schema.orbitals) {
53194
+ if (!isInlineOrbital(orbital)) continue;
53195
+ if (!orbital.pages) continue;
53196
+ for (const pageRef of orbital.pages) {
53197
+ if (!isInlinePage(pageRef)) continue;
53198
+ const page = pageRef;
53199
+ if (page.name === pageName) {
53200
+ return { page, orbitalName: orbital.name };
53201
+ }
53202
+ }
53203
+ }
53204
+ return null;
53205
+ }
53206
+ function getDefaultPage2(schema) {
53207
+ if (!schema.orbitals) return null;
53208
+ for (const orbital of schema.orbitals) {
53209
+ if (!isInlineOrbital(orbital)) continue;
53210
+ if (!orbital.pages) continue;
53211
+ for (const pageRef of orbital.pages) {
53212
+ if (isInlinePage(pageRef)) {
53213
+ return { page: pageRef, orbitalName: orbital.name };
53214
+ }
53215
+ }
53216
+ }
53217
+ return null;
53218
+ }
53219
+ function getAllPages2(schema) {
53220
+ const pages = [];
53221
+ if (!schema.orbitals) return pages;
53222
+ for (const orbital of schema.orbitals) {
53223
+ if (!isInlineOrbital(orbital)) continue;
53224
+ if (!orbital.pages) continue;
53225
+ for (const pageRef of orbital.pages) {
53226
+ if (isInlinePage(pageRef)) {
53227
+ pages.push({ page: pageRef, orbitalName: orbital.name });
53228
+ }
53229
+ }
53230
+ }
53231
+ return pages;
53232
+ }
53233
+ var NavigationContext = createContext(null);
53234
+ function NavigationProvider2({
53235
+ schema,
53236
+ initialPage,
53237
+ updateUrl = true,
53238
+ onNavigate,
53239
+ children
53240
+ }) {
53241
+ const initialState = useMemo(() => {
53242
+ let page = null;
53243
+ let path = "/";
53244
+ if (initialPage) {
53245
+ const found = findPageByName2(schema, initialPage);
53246
+ if (found) {
53247
+ page = found.page;
53248
+ path = page.path || "/";
53249
+ }
53250
+ }
53251
+ if (!page) {
53252
+ const defaultPage = getDefaultPage2(schema);
53253
+ if (defaultPage) {
53254
+ page = defaultPage.page;
53255
+ path = page.path || "/";
53256
+ }
53257
+ }
53258
+ return {
53259
+ activePage: page?.name || "",
53260
+ currentPath: path,
53261
+ initPayload: {},
53262
+ navigationId: 0
53263
+ };
53264
+ }, [schema, initialPage]);
53265
+ const [state, setState] = useState(initialState);
53266
+ const navigateTo = useCallback((path, payload) => {
53267
+ const result = findPageByPath2(schema, path);
53268
+ if (!result) {
53269
+ log11.error("No page found for path", { path });
53270
+ return;
53271
+ }
53272
+ const { page, params } = result;
53273
+ const finalPayload = { ...params, ...payload };
53274
+ log11.debug("Navigating to", () => ({
53275
+ path,
53276
+ page: page.name,
53277
+ params,
53278
+ payload: JSON.stringify(payload),
53279
+ finalPayload: JSON.stringify(finalPayload)
53280
+ }));
53281
+ setState((prev) => ({
53282
+ activePage: page.name,
53283
+ currentPath: path,
53284
+ initPayload: finalPayload,
53285
+ navigationId: prev.navigationId + 1
53286
+ }));
53287
+ if (updateUrl && typeof window !== "undefined") {
53288
+ try {
53289
+ window.history.pushState(finalPayload, "", path);
53290
+ } catch (e) {
53291
+ log11.warn("Could not update URL", { error: e instanceof Error ? e : String(e) });
53292
+ }
53293
+ }
53294
+ if (onNavigate) {
53295
+ onNavigate(page.name, path, finalPayload);
53296
+ }
53297
+ }, [schema, updateUrl, onNavigate]);
53298
+ const navigateToPage = useCallback((pageName, payload) => {
53299
+ const result = findPageByName2(schema, pageName);
53300
+ if (!result) {
53301
+ log11.error("No page found with name", { pageName });
53302
+ return;
53303
+ }
53304
+ const { page } = result;
53305
+ const path = page.path || `/${pageName.toLowerCase()}`;
53306
+ log11.debug("Navigating to page", () => ({
53307
+ pageName,
53308
+ path,
53309
+ payload: JSON.stringify(payload)
53310
+ }));
53311
+ setState((prev) => ({
53312
+ activePage: page.name,
53313
+ currentPath: path,
53314
+ initPayload: payload || {},
53315
+ navigationId: prev.navigationId + 1
53316
+ }));
53317
+ if (updateUrl && typeof window !== "undefined") {
53318
+ try {
53319
+ window.history.pushState(payload || {}, "", path);
53320
+ } catch (e) {
53321
+ log11.warn("Could not update URL", { error: e instanceof Error ? e : String(e) });
53322
+ }
53323
+ }
53324
+ if (onNavigate) {
53325
+ onNavigate(page.name, path, payload || {});
53326
+ }
53327
+ }, [schema, updateUrl, onNavigate]);
53328
+ const contextValue = useMemo(() => ({
53329
+ state,
53330
+ navigateTo,
53331
+ navigateToPage,
53332
+ schema,
53333
+ isReady: !!state.activePage
53334
+ }), [state, navigateTo, navigateToPage, schema]);
53335
+ return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: contextValue, children });
53336
+ }
53337
+ function useNavigation2() {
53338
+ return useContext(NavigationContext);
53339
+ }
53340
+ function useNavigateTo2() {
53341
+ const context = useContext(NavigationContext);
53342
+ const noOp = useCallback((path, _payload) => {
53343
+ log11.warn("navigateTo called outside NavigationProvider", { path });
53344
+ }, []);
53345
+ return context?.navigateTo || noOp;
53346
+ }
53347
+ function useNavigationState2() {
53348
+ const context = useContext(NavigationContext);
53349
+ return context?.state || null;
53350
+ }
53351
+ function useInitPayload2() {
53352
+ const context = useContext(NavigationContext);
53353
+ return context?.state.initPayload || {};
53354
+ }
53355
+ function useActivePage2() {
53356
+ const context = useContext(NavigationContext);
53357
+ return context?.state.activePage || null;
53358
+ }
53359
+ function useNavigationId2() {
53360
+ const context = useContext(NavigationContext);
53361
+ return context?.state.navigationId || 0;
53362
+ }
53363
+
53364
+ // providers/ServerBridge.tsx
53365
+ init_useEventBus();
53366
+ var xOrbitalLog = createLogger("almadar:runtime:cross-orbital");
53367
+ var serverBridgeLog = createLogger("almadar:ui:server-bridge");
53368
+ function createHttpTransport(serverUrl) {
53369
+ return {
53370
+ register: async (schema) => {
53371
+ try {
53372
+ const res = await fetch(`${serverUrl}/register`, {
53373
+ method: "POST",
53374
+ headers: { "Content-Type": "application/json" },
53375
+ body: JSON.stringify({ schema })
53376
+ });
53377
+ const result = await res.json();
53378
+ return !!result.success;
53379
+ } catch (err) {
53380
+ if (err instanceof TypeError) {
53381
+ serverBridgeLog.warn("Registration failed", { error: err.message });
53382
+ } else {
53383
+ serverBridgeLog.error("Registration failed", { error: err instanceof Error ? err : String(err) });
53384
+ }
53385
+ return false;
53386
+ }
53387
+ },
53388
+ unregister: async () => {
53389
+ try {
53390
+ await fetch(`${serverUrl}/unregister`, { method: "DELETE" });
53391
+ } catch {
53392
+ }
53393
+ },
53394
+ sendEvent: async (orbitalName, event, payload) => {
53395
+ const res = await fetch(`${serverUrl}/${orbitalName}/events`, {
53396
+ method: "POST",
53397
+ headers: { "Content-Type": "application/json" },
53398
+ body: JSON.stringify({ event, payload })
53399
+ });
53400
+ return res.json();
53401
+ }
53402
+ };
53403
+ }
53404
+ var ServerBridgeContext = createContext(null);
53405
+ function useServerBridge() {
53406
+ const ctx = useContext(ServerBridgeContext);
53407
+ if (!ctx) {
53408
+ const emptyMeta = { success: false, clientEffects: 0, dataEntities: {}, emittedEvents: [] };
53409
+ return { connected: false, sendEvent: async () => ({ effects: [], meta: emptyMeta }) };
53410
+ }
53411
+ return ctx;
53412
+ }
53413
+ function ServerBridgeProvider({
53414
+ schema,
53415
+ serverUrl,
53416
+ transport: customTransport,
53417
+ children
53418
+ }) {
53419
+ if (!serverUrl && !customTransport) {
53420
+ throw new Error("ServerBridgeProvider requires either serverUrl or transport");
53421
+ }
53422
+ if (serverUrl && customTransport) {
53423
+ throw new Error("ServerBridgeProvider accepts serverUrl OR transport, not both");
53424
+ }
53425
+ const eventBus = useEventBus();
53426
+ const [connected, setConnected] = useState(false);
53427
+ const transport = useMemo(
53428
+ () => customTransport ?? createHttpTransport(serverUrl),
53429
+ [serverUrl, customTransport]
53430
+ );
53431
+ const registerSchema = useCallback(
53432
+ async () => transport.register(schema),
53433
+ [schema, transport]
53434
+ );
53435
+ const unregisterSchema = useCallback(
53436
+ async () => transport.unregister(),
53437
+ [transport]
53438
+ );
53439
+ const sendEvent = useCallback(async (orbitalName, event, payload) => {
53440
+ const emptyMeta = { success: false, clientEffects: 0, dataEntities: {}, emittedEvents: [] };
53441
+ if (!connected) return { effects: [], meta: emptyMeta };
53442
+ try {
53443
+ const result = await transport.sendEvent(orbitalName, event, payload);
53444
+ const effects = [];
53445
+ const responseData = result.data || {};
53446
+ const dataEntities = {};
53447
+ for (const [entityName, records] of Object.entries(responseData)) {
53448
+ dataEntities[entityName] = Array.isArray(records) ? records.length : 0;
53449
+ }
53450
+ const meta = {
53451
+ success: !!result.success,
53452
+ clientEffects: result.clientEffects?.length ?? 0,
53453
+ dataEntities,
53454
+ data: responseData,
53455
+ emittedEvents: result.emittedEvents?.map((e) => e.event) ?? [],
53456
+ error: result.error
53457
+ };
53458
+ if (result.success) {
53459
+ const tagged = result.clientEffectsByTrait;
53460
+ const tuples = tagged ? tagged.map((entry) => ({ effect: entry.effect, traitName: entry.traitName })) : (result.clientEffects ?? []).map((eff) => ({ effect: eff }));
53461
+ for (const { effect, traitName } of tuples) {
53462
+ const effectType = effect[0];
53463
+ if (effectType === "render-ui") {
53464
+ const slot = effect[1];
53465
+ const pattern = effect[2];
53466
+ effects.push({
53467
+ type: "render-ui",
53468
+ slot,
53469
+ pattern: pattern !== null && typeof pattern === "object" ? pattern : void 0,
53470
+ traitName
53471
+ });
53472
+ } else if (effectType === "navigate") {
53473
+ const route = effect[1];
53474
+ const rawParams = effect[2];
53475
+ effects.push({
53476
+ type: "navigate",
53477
+ route,
53478
+ params: rawParams !== null && rawParams !== void 0 && typeof rawParams === "object" && !Array.isArray(rawParams) ? rawParams : void 0,
53479
+ traitName
53480
+ });
53481
+ } else if (effectType === "notify") {
53482
+ const message = effect[1];
53483
+ effects.push({ type: "notify", message: typeof message === "string" ? message : void 0, traitName });
53484
+ }
53485
+ }
53486
+ if (result.emittedEvents) {
53487
+ for (const emitted of result.emittedEvents) {
53488
+ const evTrait = emitted.source?.trait;
53489
+ if (!evTrait) {
53490
+ xOrbitalLog.warn("emit:dropped-no-source", {
53491
+ event: emitted.event,
53492
+ dispatchOrbital: orbitalName
53493
+ });
53494
+ continue;
53495
+ }
53496
+ const key = emitted.source?.orbital ? `UI:${emitted.source.orbital}.${evTrait}.${emitted.event}` : `UI:${evTrait}.${emitted.event}`;
53497
+ xOrbitalLog.info("emit:rebroadcast", {
53498
+ busKey: key,
53499
+ sourceOrbital: emitted.source?.orbital,
53500
+ sourceTrait: evTrait,
53501
+ dispatchOrbital: orbitalName
53502
+ });
53503
+ eventBus.emit(key, emitted.payload);
53504
+ }
53505
+ }
53506
+ } else if (result.error) {
53507
+ xOrbitalLog.warn("response:fail", {
53508
+ orbital: orbitalName,
53509
+ event,
53510
+ error: result.error
53511
+ });
53512
+ }
53513
+ return { effects, meta };
53514
+ } catch (err) {
53515
+ const msg = err instanceof Error ? err.message : String(err);
53516
+ if (err instanceof TypeError) {
53517
+ xOrbitalLog.warn("response:network", {
53518
+ orbital: orbitalName,
53519
+ event,
53520
+ error: msg,
53521
+ reason: "peer endpoint unreachable (expected in standalone single-orbital mode)"
53522
+ });
53523
+ } else {
53524
+ xOrbitalLog.error("response:network", {
53525
+ orbital: orbitalName,
53526
+ event,
53527
+ error: msg
53528
+ });
53529
+ }
53530
+ return { effects: [], meta: { ...emptyMeta, error: msg } };
53531
+ }
53532
+ }, [connected, transport, eventBus]);
53533
+ useEffect(() => {
53534
+ if (!schema) return;
53535
+ let cancelled = false;
53536
+ registerSchema().then((ok) => {
53537
+ if (!cancelled && ok) setConnected(true);
53538
+ });
53539
+ return () => {
53540
+ cancelled = true;
53541
+ setConnected(false);
53542
+ unregisterSchema();
53543
+ };
53544
+ }, [schema, registerSchema, unregisterSchema]);
53545
+ return /* @__PURE__ */ jsx(ServerBridgeContext.Provider, { value: { connected, sendEvent }, children });
53546
+ }
53547
+ var log12 = createLogger("almadar:ui:trait-provider");
53548
+ var TraitContext = createContext(null);
53549
+ function TraitProvider({
53550
+ traits: traitBindings,
53551
+ children
53552
+ }) {
53553
+ const traitInstances = useMemo(() => {
53554
+ const map = /* @__PURE__ */ new Map();
53555
+ for (const binding of traitBindings) {
53556
+ const trait = binding.trait;
53557
+ const initialState = trait.states.find((s) => s.isInitial);
53558
+ const stateName = initialState?.name || trait.states[0]?.name || "idle";
53559
+ const instance = {
53560
+ name: trait.name,
53561
+ currentState: stateName,
53562
+ availableEvents: trait.transitions.filter((t) => t.from === stateName).map((t) => t.event),
53563
+ dispatch: (eventKey, payload) => {
53564
+ log12.debug("Dispatch", () => ({
53565
+ trait: trait.name,
53566
+ event: eventKey,
53567
+ payloadKeys: payload ? Object.keys(payload) : []
53568
+ }));
53569
+ },
53570
+ canDispatch: (eventKey) => {
53571
+ return trait.transitions.some(
53572
+ (t) => t.from === stateName && t.event === eventKey
53573
+ );
53574
+ },
53575
+ trait
53576
+ };
53577
+ map.set(trait.name, instance);
53578
+ }
53579
+ return map;
53580
+ }, [traitBindings]);
53581
+ const contextValue = useMemo(() => {
53582
+ return {
53583
+ traits: traitInstances,
53584
+ getTrait: (name) => traitInstances.get(name),
53585
+ dispatchToTrait: (traitName, eventKey, payload) => {
53586
+ const instance = traitInstances.get(traitName);
53587
+ if (instance) {
53588
+ instance.dispatch(eventKey, payload);
53589
+ }
53590
+ },
53591
+ canDispatch: (traitName, eventKey) => {
53592
+ const instance = traitInstances.get(traitName);
53593
+ return instance?.canDispatch(eventKey) || false;
53594
+ }
53595
+ };
53596
+ }, [traitInstances]);
53597
+ return /* @__PURE__ */ jsx(TraitContext.Provider, { value: contextValue, children });
53598
+ }
53599
+ function useTraitContext() {
53600
+ const context = useContext(TraitContext);
53601
+ if (!context) {
53602
+ throw new Error("useTraitContext must be used within a TraitProvider");
53603
+ }
53604
+ return context;
53605
+ }
53606
+ function useTrait(traitName) {
53607
+ const context = useTraitContext();
53608
+ return context.getTrait(traitName);
53609
+ }
53070
53610
  var TraitScopeContext = createContext(null);
53071
53611
  function TraitScopeProvider3({
53072
53612
  orbital,
@@ -53112,4 +53652,4 @@ function useOptionalOfflineMode() {
53112
53652
  return useContext(OfflineModeContext);
53113
53653
  }
53114
53654
 
53115
- export { ANONYMOUS_USER, CurrentPagePathContext, CurrentPagePathProvider, EventBusContext2 as EventBusContext, EventBusProvider, OfflineModeProvider, OrbitalProvider, OrbitalThemeProvider, SelectionContext, SelectionProvider, TraitScopeProvider3 as TraitScopeProvider, UserContext, UserProvider, VerificationProvider, useCurrentPagePath2 as useCurrentPagePath, useHasPermission, useHasRole, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useTraitScope2 as useTraitScope, useUser, useUserForEvaluation };
53655
+ export { ANONYMOUS_USER, CurrentPagePathContext, CurrentPagePathProvider, EntitySchemaProvider, EventBusContext2 as EventBusContext, EventBusProvider, NavigationProvider2 as NavigationProvider, OfflineModeProvider, OrbitalProvider, OrbitalThemeProvider, SelectionContext, SelectionProvider, ServerBridgeProvider, TraitContext, TraitProvider, TraitScopeProvider3 as TraitScopeProvider, UserContext, UserProvider, VerificationProvider, extractRouteParams2 as extractRouteParams, findPageByName2 as findPageByName, findPageByPath2 as findPageByPath, getAllPages2 as getAllPages, getDefaultPage2 as getDefaultPage, matchPath2 as matchPath, pathMatches2 as pathMatches, useActivePage2 as useActivePage, useCurrentPagePath2 as useCurrentPagePath, useEntitySchema, useEntitySchemaOptional3 as useEntitySchemaOptional, useHasPermission, useHasRole, useInitPayload2 as useInitPayload, useNavigateTo2 as useNavigateTo, useNavigation2 as useNavigation, useNavigationId2 as useNavigationId, useNavigationState2 as useNavigationState, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional, useServerBridge, useTrait, useTraitContext, useTraitScope2 as useTraitScope, useUser, useUserForEvaluation };