@almadar/ui 5.17.0 → 5.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/avl/index.cjs +219 -171
  2. package/dist/avl/index.js +219 -171
  3. package/dist/components/atoms/Avatar.d.ts +4 -2
  4. package/dist/components/atoms/ConditionalWrapper.d.ts +2 -2
  5. package/dist/components/atoms/Icon.d.ts +6 -2
  6. package/dist/components/atoms/Input.d.ts +3 -2
  7. package/dist/components/atoms/LawReferenceTooltip.d.ts +2 -2
  8. package/dist/components/atoms/types.d.ts +10 -10
  9. package/dist/components/index.cjs +188 -156
  10. package/dist/components/index.js +188 -156
  11. package/dist/components/molecules/OptionConstraintGroup.d.ts +5 -3
  12. package/dist/components/molecules/ViolationAlert.d.ts +2 -2
  13. package/dist/components/molecules/game/CraftingRecipe.d.ts +4 -4
  14. package/dist/components/molecules/game/DialogueBox.d.ts +2 -2
  15. package/dist/components/organisms/ComponentPatterns.d.ts +2 -1
  16. package/dist/components/organisms/CustomPattern.d.ts +2 -1
  17. package/dist/components/organisms/DataTable.d.ts +1 -1
  18. package/dist/components/organisms/Form.d.ts +3 -3
  19. package/dist/components/organisms/LayoutPatterns.d.ts +4 -3
  20. package/dist/components/organisms/StateMachineView.d.ts +6 -3
  21. package/dist/components/organisms/book/types.d.ts +2 -2
  22. package/dist/components/organisms/game/CastleBoard.d.ts +4 -3
  23. package/dist/components/organisms/game/TraitStateViewer.d.ts +4 -4
  24. package/dist/components/organisms/game/UncontrolledBattleBoard.d.ts +9 -4
  25. package/dist/components/organisms/game/WorldMapBoard.d.ts +5 -4
  26. package/dist/components/organisms/game/puzzles/builder/BuilderBoard.d.ts +3 -3
  27. package/dist/components/organisms/game/puzzles/classifier/ClassifierBoard.d.ts +3 -3
  28. package/dist/components/organisms/game/puzzles/debugger/DebuggerBoard.d.ts +3 -3
  29. package/dist/components/organisms/game/puzzles/event-handler/EventHandlerBoard.d.ts +7 -4
  30. package/dist/components/organisms/game/puzzles/event-handler/ObjectRulePanel.d.ts +2 -2
  31. package/dist/components/organisms/game/puzzles/negotiator/NegotiatorBoard.d.ts +3 -3
  32. package/dist/components/organisms/game/puzzles/sequencer/SequencerBoard.d.ts +5 -4
  33. package/dist/components/organisms/game/puzzles/simulator/SimulatorBoard.d.ts +3 -3
  34. package/dist/components/organisms/game/puzzles/state-architect/StateArchitectBoard.d.ts +5 -4
  35. package/dist/components/templates/GenericAppTemplate.d.ts +1 -7
  36. package/dist/components/templates/types.d.ts +14 -6
  37. package/dist/docs/index.cjs +60 -22
  38. package/dist/docs/index.d.cts +9 -4
  39. package/dist/docs/index.js +58 -20
  40. package/dist/marketing/index.cjs +61 -23
  41. package/dist/marketing/index.d.cts +10 -6
  42. package/dist/marketing/index.js +58 -20
  43. package/dist/providers/index.cjs +188 -156
  44. package/dist/providers/index.js +188 -156
  45. package/dist/runtime/fn-form-lambda.d.ts +1 -1
  46. package/dist/runtime/index.cjs +219 -171
  47. package/dist/runtime/index.js +219 -171
  48. package/package.json +1 -1
@@ -1721,11 +1721,13 @@ var init_Icon = __esm({
1721
1721
  strokeWidth,
1722
1722
  style
1723
1723
  }) => {
1724
+ const directIcon = typeof icon === "string" ? void 0 : icon;
1725
+ const effectiveName = typeof icon === "string" ? icon : name;
1724
1726
  const family = useIconFamily();
1725
1727
  const RenderedComponent = React85__default.useMemo(() => {
1726
- if (icon) return null;
1727
- return name ? resolveIconForFamily(name, family) : null;
1728
- }, [icon, name, family]);
1728
+ if (directIcon) return null;
1729
+ return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
1730
+ }, [directIcon, effectiveName, family]);
1729
1731
  const effectiveStrokeWidth = strokeWidth ?? void 0;
1730
1732
  const inlineStyle = {
1731
1733
  ...effectiveStrokeWidth === void 0 ? { strokeWidth: "var(--icon-stroke-width, 2)" } : {},
@@ -1737,8 +1739,8 @@ var init_Icon = __esm({
1737
1739
  color ? color : "text-current",
1738
1740
  className
1739
1741
  );
1740
- if (icon) {
1741
- const Direct = icon;
1742
+ if (directIcon) {
1743
+ const Direct = directIcon;
1742
1744
  return /* @__PURE__ */ jsx(
1743
1745
  Direct,
1744
1746
  {
@@ -3611,7 +3613,7 @@ var init_Input = __esm({
3611
3613
  error,
3612
3614
  leftIcon,
3613
3615
  rightIcon,
3614
- icon: IconComponent,
3616
+ icon: iconProp,
3615
3617
  clearable,
3616
3618
  onClear,
3617
3619
  value,
@@ -3621,6 +3623,7 @@ var init_Input = __esm({
3621
3623
  ...props
3622
3624
  }, ref) => {
3623
3625
  const type = inputType || htmlType || "text";
3626
+ const IconComponent = typeof iconProp === "string" ? resolveIcon(iconProp) : iconProp;
3624
3627
  const resolvedLeftIcon = leftIcon || IconComponent && /* @__PURE__ */ jsx(IconComponent, { className: "h-icon-default w-icon-default" });
3625
3628
  const showClearButton = clearable && value && String(value).length > 0;
3626
3629
  const isMultiline = type === "textarea";
@@ -4168,7 +4171,7 @@ var init_Avatar = __esm({
4168
4171
  alt,
4169
4172
  name,
4170
4173
  initials: providedInitials,
4171
- icon: IconComponent,
4174
+ icon: iconProp,
4172
4175
  size = "md",
4173
4176
  status,
4174
4177
  badge,
@@ -4179,6 +4182,7 @@ var init_Avatar = __esm({
4179
4182
  }) => {
4180
4183
  const eventBus = useEventBus();
4181
4184
  const initials = providedInitials ?? (name ? generateInitials(name) : void 0);
4185
+ const IconComponent = typeof iconProp === "string" ? resolveIcon(iconProp) : iconProp;
4182
4186
  const hasImage = !!src;
4183
4187
  const hasInitials = !!initials;
4184
4188
  const hasIcon = !!IconComponent;
@@ -15008,6 +15012,7 @@ var init_StateMachineView = __esm({
15008
15012
  setTooltip((prev) => ({ ...prev, pinned: false, visible: false }));
15009
15013
  }, []);
15010
15014
  useEventListener("UI:TOOLTIP_CLOSE", handleCloseTooltip);
15015
+ if (!layoutData) return null;
15011
15016
  const { width, height, title, states, labels, entity, outputs, config } = layoutData;
15012
15017
  const bundles = useMemo(() => {
15013
15018
  const bundleMap = {};
@@ -17352,13 +17357,14 @@ function BuilderBoard({
17352
17357
  }) {
17353
17358
  const { emit } = useEventBus();
17354
17359
  const { t } = useTranslate();
17360
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
17355
17361
  const [placements, setPlacements] = useState({});
17356
17362
  const [headerError, setHeaderError] = useState(false);
17357
17363
  const [submitted, setSubmitted] = useState(false);
17358
17364
  const [attempts, setAttempts] = useState(0);
17359
17365
  const [showHint, setShowHint] = useState(false);
17360
- const components = entity?.components ?? [];
17361
- const slots = entity?.slots ?? [];
17366
+ const components = resolved?.components ?? [];
17367
+ const slots = resolved?.slots ?? [];
17362
17368
  const usedComponentIds = new Set(Object.values(placements));
17363
17369
  const availableComponents = components.filter((c) => !usedComponentIds.has(c.id));
17364
17370
  const [selectedComponent, setSelectedComponent] = useState(null);
@@ -17392,7 +17398,7 @@ function BuilderBoard({
17392
17398
  }, [slots, placements, attempts, completeEvent, emit]);
17393
17399
  const handleReset = () => {
17394
17400
  setSubmitted(false);
17395
- if (attempts >= 2 && entity.hint) {
17401
+ if (attempts >= 2 && resolved?.hint) {
17396
17402
  setShowHint(true);
17397
17403
  }
17398
17404
  };
@@ -17404,20 +17410,21 @@ function BuilderBoard({
17404
17410
  setShowHint(false);
17405
17411
  };
17406
17412
  const getComponentById = (id) => components.find((c) => c.id === id);
17413
+ if (!resolved) return null;
17407
17414
  return /* @__PURE__ */ jsx(
17408
17415
  Box,
17409
17416
  {
17410
17417
  className,
17411
17418
  style: {
17412
- backgroundImage: entity.theme?.background ? `url(${entity.theme.background})` : void 0,
17419
+ backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
17413
17420
  backgroundSize: "cover",
17414
17421
  backgroundPosition: "center"
17415
17422
  },
17416
17423
  children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
17417
- entity.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: entity.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : entity.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
17424
+ resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
17418
17425
  /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
17419
- /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: entity.title }),
17420
- /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.description })
17426
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title }),
17427
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description })
17421
17428
  ] }) }),
17422
17429
  /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
17423
17430
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("builder.components") }),
@@ -17477,9 +17484,9 @@ function BuilderBoard({
17477
17484
  ] }) }),
17478
17485
  submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
17479
17486
  /* @__PURE__ */ jsx(Icon, { icon: allCorrect ? CheckCircle : XCircle, size: "lg", className: allCorrect ? "text-success" : "text-error" }),
17480
- /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? entity.successMessage ?? t("builder.success") : entity.failMessage ?? t("builder.incorrect") })
17487
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? resolved.successMessage ?? t("builder.success") : resolved.failMessage ?? t("builder.incorrect") })
17481
17488
  ] }) }),
17482
- showHint && entity.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.hint }) }),
17489
+ showHint && resolved.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
17483
17490
  /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
17484
17491
  !submitted ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: !allPlaced, children: [
17485
17492
  /* @__PURE__ */ jsx(Icon, { icon: Wrench, size: "sm" }),
@@ -19953,11 +19960,12 @@ function CastleBoard({
19953
19960
  className
19954
19961
  }) {
19955
19962
  const eventBus = useEventBus();
19956
- const tiles = entity.tiles;
19957
- const features = entity.features ?? [];
19958
- const units = entity.units ?? [];
19959
- const assetManifest = entity.assetManifest;
19960
- const backgroundImage = entity.backgroundImage;
19963
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
19964
+ const tiles = resolved?.tiles ?? [];
19965
+ const features = resolved?.features ?? [];
19966
+ const units = resolved?.units ?? [];
19967
+ const assetManifest = resolved?.assetManifest;
19968
+ const backgroundImage = resolved?.backgroundImage;
19961
19969
  const [hoveredTile, setHoveredTile] = useState(null);
19962
19970
  const [selectedFeature, setSelectedFeature] = useState(null);
19963
19971
  const hoveredFeature = useMemo(() => {
@@ -20862,13 +20870,14 @@ function ClassifierBoard({
20862
20870
  }) {
20863
20871
  const { emit } = useEventBus();
20864
20872
  const { t } = useTranslate();
20873
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
20865
20874
  const [assignments, setAssignments] = useState({});
20866
20875
  const [headerError, setHeaderError] = useState(false);
20867
20876
  const [submitted, setSubmitted] = useState(false);
20868
20877
  const [attempts, setAttempts] = useState(0);
20869
20878
  const [showHint, setShowHint] = useState(false);
20870
- const items = entity?.items ?? [];
20871
- const categories = entity?.categories ?? [];
20879
+ const items = resolved?.items ?? [];
20880
+ const categories = resolved?.categories ?? [];
20872
20881
  const unassignedItems = items.filter((item) => !assignments[item.id]);
20873
20882
  const allAssigned = Object.keys(assignments).length === items.length;
20874
20883
  const results = submitted ? items.map((item) => ({
@@ -20900,7 +20909,7 @@ function ClassifierBoard({
20900
20909
  }, [items, assignments, attempts, completeEvent, emit]);
20901
20910
  const handleReset = () => {
20902
20911
  setSubmitted(false);
20903
- if (attempts >= 2 && entity.hint) {
20912
+ if (attempts >= 2 && resolved?.hint) {
20904
20913
  setShowHint(true);
20905
20914
  }
20906
20915
  };
@@ -20910,20 +20919,21 @@ function ClassifierBoard({
20910
20919
  setAttempts(0);
20911
20920
  setShowHint(false);
20912
20921
  };
20922
+ if (!resolved) return null;
20913
20923
  return /* @__PURE__ */ jsx(
20914
20924
  Box,
20915
20925
  {
20916
20926
  className,
20917
20927
  style: {
20918
- backgroundImage: entity.theme?.background ? `url(${entity.theme.background})` : void 0,
20928
+ backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
20919
20929
  backgroundSize: "cover",
20920
20930
  backgroundPosition: "center"
20921
20931
  },
20922
20932
  children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
20923
- entity.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: entity.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : entity.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
20933
+ resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
20924
20934
  /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
20925
- /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: entity.title }),
20926
- /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.description })
20935
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title }),
20936
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description })
20927
20937
  ] }) }),
20928
20938
  unassignedItems.length > 0 && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
20929
20939
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("classifier.itemsToSort") }),
@@ -20975,10 +20985,10 @@ function ClassifierBoard({
20975
20985
  }) }),
20976
20986
  submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
20977
20987
  /* @__PURE__ */ jsx(Icon, { icon: allCorrect ? CheckCircle : XCircle, size: "lg", className: allCorrect ? "text-success" : "text-error" }),
20978
- /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? entity.successMessage ?? t("classifier.allCorrect") : `${correctCount}/${items.length} ${t("classifier.correct")}` }),
20979
- !allCorrect && entity.failMessage && /* @__PURE__ */ jsx(Typography, { variant: "body", className: "text-muted-foreground", children: entity.failMessage })
20988
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? resolved.successMessage ?? t("classifier.allCorrect") : `${correctCount}/${items.length} ${t("classifier.correct")}` }),
20989
+ !allCorrect && resolved.failMessage && /* @__PURE__ */ jsx(Typography, { variant: "body", className: "text-muted-foreground", children: resolved.failMessage })
20980
20990
  ] }) }),
20981
- showHint && entity.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.hint }) }),
20991
+ showHint && resolved.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
20982
20992
  /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
20983
20993
  !submitted ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: !allAssigned, children: [
20984
20994
  /* @__PURE__ */ jsx(Icon, { icon: Send, size: "sm" }),
@@ -32097,7 +32107,7 @@ var init_OptionConstraintGroup = __esm({
32097
32107
  title,
32098
32108
  description,
32099
32109
  options,
32100
- constraint,
32110
+ constraint = { type: "single" },
32101
32111
  selected = [],
32102
32112
  onChange,
32103
32113
  changeEvent,
@@ -35235,7 +35245,7 @@ function DataTable({
35235
35245
  children: /* @__PURE__ */ jsx(
35236
35246
  EmptyState,
35237
35247
  {
35238
- icon: emptyIcon,
35248
+ icon: typeof emptyIcon === "string" ? resolveIcon(emptyIcon) : emptyIcon,
35239
35249
  title: resolvedEmptyTitle,
35240
35250
  description: resolvedEmptyDescription,
35241
35251
  actionLabel: emptyAction?.label,
@@ -35364,6 +35374,7 @@ var init_DataTable = __esm({
35364
35374
  init_Stack();
35365
35375
  init_Typography();
35366
35376
  init_molecules();
35377
+ init_Icon();
35367
35378
  init_useEventBus();
35368
35379
  init_useTranslate();
35369
35380
  init_types3();
@@ -35384,6 +35395,7 @@ function DebuggerBoard({
35384
35395
  }) {
35385
35396
  const { emit } = useEventBus();
35386
35397
  const { t } = useTranslate();
35398
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
35387
35399
  const [flaggedLines, setFlaggedLines] = useState(/* @__PURE__ */ new Set());
35388
35400
  const [headerError, setHeaderError] = useState(false);
35389
35401
  const [submitted, setSubmitted] = useState(false);
@@ -35401,7 +35413,7 @@ function DebuggerBoard({
35401
35413
  return next;
35402
35414
  });
35403
35415
  };
35404
- const lines = entity?.lines ?? [];
35416
+ const lines = resolved?.lines ?? [];
35405
35417
  const bugLines = lines.filter((l) => l.isBug);
35406
35418
  const correctFlags = lines.filter((l) => l.isBug && flaggedLines.has(l.id));
35407
35419
  const falseFlags = lines.filter((l) => !l.isBug && flaggedLines.has(l.id));
@@ -35416,7 +35428,7 @@ function DebuggerBoard({
35416
35428
  }, [correctFlags.length, bugLines.length, falseFlags.length, attempts, completeEvent, emit]);
35417
35429
  const handleReset = () => {
35418
35430
  setSubmitted(false);
35419
- if (attempts >= 2 && entity.hint) {
35431
+ if (attempts >= 2 && resolved?.hint) {
35420
35432
  setShowHint(true);
35421
35433
  }
35422
35434
  };
@@ -35426,24 +35438,25 @@ function DebuggerBoard({
35426
35438
  setAttempts(0);
35427
35439
  setShowHint(false);
35428
35440
  };
35441
+ if (!resolved) return null;
35429
35442
  return /* @__PURE__ */ jsx(
35430
35443
  Box,
35431
35444
  {
35432
35445
  className,
35433
35446
  style: {
35434
- backgroundImage: entity.theme?.background ? `url(${entity.theme.background})` : void 0,
35447
+ backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
35435
35448
  backgroundSize: "cover",
35436
35449
  backgroundPosition: "center"
35437
35450
  },
35438
35451
  children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
35439
- entity.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: entity.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : entity.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
35452
+ resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
35440
35453
  /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
35441
35454
  /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
35442
35455
  /* @__PURE__ */ jsx(Icon, { icon: Bug, size: "sm" }),
35443
- /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: entity.title })
35456
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title })
35444
35457
  ] }),
35445
- /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.description }),
35446
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("debugger.findBugs", { count: String(entity.bugCount) }) })
35458
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description }),
35459
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("debugger.findBugs", { count: String(resolved.bugCount) }) })
35447
35460
  ] }) }),
35448
35461
  /* @__PURE__ */ jsx(Card, { className: "p-0 overflow-hidden", children: /* @__PURE__ */ jsx(VStack, { gap: "none", children: lines.map((line, i) => {
35449
35462
  const isFlagged = flaggedLines.has(line.id);
@@ -35475,7 +35488,7 @@ function DebuggerBoard({
35475
35488
  );
35476
35489
  }) }) }),
35477
35490
  submitted && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
35478
- /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? entity.successMessage ?? t("debugger.allFound") : `${correctFlags.length}/${bugLines.length} ${t("debugger.bugsFound")}` }),
35491
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? resolved.successMessage ?? t("debugger.allFound") : `${correctFlags.length}/${bugLines.length} ${t("debugger.bugsFound")}` }),
35479
35492
  bugLines.map((line) => /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "start", children: [
35480
35493
  /* @__PURE__ */ jsx(
35481
35494
  Icon,
@@ -35491,7 +35504,7 @@ function DebuggerBoard({
35491
35504
  ] })
35492
35505
  ] }, line.id))
35493
35506
  ] }) }),
35494
- showHint && entity.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.hint }) }),
35507
+ showHint && resolved.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
35495
35508
  /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
35496
35509
  !submitted ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, disabled: flaggedLines.size === 0, children: [
35497
35510
  /* @__PURE__ */ jsx(Icon, { icon: Send, size: "sm" }),
@@ -36623,7 +36636,8 @@ function EventHandlerBoard({
36623
36636
  }) {
36624
36637
  const { emit } = useEventBus();
36625
36638
  const { t } = useTranslate();
36626
- const entityObjects = entity?.objects ?? [];
36639
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
36640
+ const entityObjects = resolved?.objects ?? [];
36627
36641
  const [objects, setObjects] = useState(entityObjects);
36628
36642
  const [selectedObjectId, setSelectedObjectId] = useState(
36629
36643
  entityObjects[0]?.id || null
@@ -36658,7 +36672,7 @@ function EventHandlerBoard({
36658
36672
  allRules.push({ object: obj, rule });
36659
36673
  });
36660
36674
  });
36661
- const triggers = entity.triggerEvents || [];
36675
+ const triggers = resolved?.triggerEvents || [];
36662
36676
  const eventQueue = [...triggers];
36663
36677
  const firedEvents = /* @__PURE__ */ new Set();
36664
36678
  let stepIdx = 0;
@@ -36689,12 +36703,12 @@ function EventHandlerBoard({
36689
36703
  matching.forEach(({ object, rule }) => {
36690
36704
  addLogEntry(object.icon, t("eventHandler.heardEvent", { object: object.name, event: currentEvent, action: rule.thenAction }), "done");
36691
36705
  eventQueue.push(rule.thenAction);
36692
- if (rule.thenAction === entity.goalEvent) {
36706
+ if (rule.thenAction === resolved?.goalEvent) {
36693
36707
  goalReached = true;
36694
36708
  }
36695
36709
  });
36696
36710
  }
36697
- if (currentEvent === entity.goalEvent) {
36711
+ if (currentEvent === resolved?.goalEvent) {
36698
36712
  goalReached = true;
36699
36713
  }
36700
36714
  stepIdx++;
@@ -36704,7 +36718,7 @@ function EventHandlerBoard({
36704
36718
  addLogEntry("\u{1F3AC}", t("eventHandler.simulationStarted", { events: triggers.join(", ") }), "active");
36705
36719
  }
36706
36720
  timerRef.current = setTimeout(processNext, stepDurationMs);
36707
- }, [playState, objects, entity, stepDurationMs, playEvent, completeEvent, emit, addLogEntry, t]);
36721
+ }, [playState, objects, resolved, stepDurationMs, playEvent, completeEvent, emit, addLogEntry, t]);
36708
36722
  const handleTryAgain = useCallback(() => {
36709
36723
  if (timerRef.current) clearTimeout(timerRef.current);
36710
36724
  setPlayState("editing");
@@ -36712,12 +36726,13 @@ function EventHandlerBoard({
36712
36726
  }, []);
36713
36727
  const handleReset = useCallback(() => {
36714
36728
  if (timerRef.current) clearTimeout(timerRef.current);
36715
- setObjects(entity?.objects ?? []);
36729
+ setObjects(resolved?.objects ?? []);
36716
36730
  setPlayState("editing");
36717
36731
  setEventLog([]);
36718
- setSelectedObjectId((entity?.objects ?? [])[0]?.id || null);
36732
+ setSelectedObjectId((resolved?.objects ?? [])[0]?.id || null);
36719
36733
  setAttempts(0);
36720
- }, [entity?.objects]);
36734
+ }, [resolved?.objects]);
36735
+ if (!resolved) return null;
36721
36736
  const objectViewers = objects.map((obj) => {
36722
36737
  const machine = {
36723
36738
  name: obj.name,
@@ -36731,25 +36746,25 @@ function EventHandlerBoard({
36731
36746
  };
36732
36747
  return { obj, machine };
36733
36748
  });
36734
- const showHint = attempts >= 3 && entity.hint;
36749
+ const showHint = attempts >= 3 && resolved.hint;
36735
36750
  const encourageKey = ENCOURAGEMENT_KEYS[Math.min(attempts - 1, ENCOURAGEMENT_KEYS.length - 1)] ?? ENCOURAGEMENT_KEYS[0];
36736
36751
  return /* @__PURE__ */ jsxs(
36737
36752
  VStack,
36738
36753
  {
36739
36754
  className: cn("p-4 gap-6", className),
36740
36755
  style: {
36741
- backgroundImage: entity.theme?.background ? `url(${entity.theme.background})` : void 0,
36756
+ backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
36742
36757
  backgroundSize: "cover",
36743
36758
  backgroundPosition: "center"
36744
36759
  },
36745
36760
  children: [
36746
- entity.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: entity.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : entity.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
36761
+ resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
36747
36762
  /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
36748
- /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: entity.title }),
36749
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: entity.description }),
36763
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: resolved.title }),
36764
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: resolved.description }),
36750
36765
  /* @__PURE__ */ jsxs(HStack, { className: "items-center p-2 rounded bg-primary/10 border border-primary/30", gap: "xs", children: [
36751
36766
  /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-primary font-bold", children: t("game.goal") + ":" }),
36752
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: entity.goalCondition })
36767
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: resolved.goalCondition })
36753
36768
  ] })
36754
36769
  ] }),
36755
36770
  /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
@@ -36780,12 +36795,12 @@ function EventHandlerBoard({
36780
36795
  }
36781
36796
  ),
36782
36797
  eventLog.length > 0 && /* @__PURE__ */ jsx(EventLog, { entries: eventLog }),
36783
- playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: entity.successMessage || t("eventHandler.chainComplete") }) }),
36798
+ playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: resolved.successMessage || t("eventHandler.chainComplete") }) }),
36784
36799
  playState === "fail" && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
36785
36800
  /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-warning/10 border border-warning/30 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "body1", className: "text-foreground font-medium", children: t(encourageKey) }) }),
36786
36801
  showHint && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-accent/10 border border-accent/30", children: /* @__PURE__ */ jsxs(HStack, { className: "items-start", gap: "xs", children: [
36787
36802
  /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
36788
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: entity.hint })
36803
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: resolved.hint })
36789
36804
  ] }) })
36790
36805
  ] }),
36791
36806
  /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
@@ -39906,19 +39921,20 @@ function NegotiatorBoard({
39906
39921
  }) {
39907
39922
  const { emit } = useEventBus();
39908
39923
  const { t } = useTranslate();
39924
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
39909
39925
  const [history, setHistory] = useState([]);
39910
39926
  const [headerError, setHeaderError] = useState(false);
39911
39927
  const [showHint, setShowHint] = useState(false);
39912
39928
  const currentRound = history.length;
39913
- const isComplete = currentRound >= entity.totalRounds;
39929
+ const isComplete = currentRound >= (resolved?.totalRounds ?? 0);
39914
39930
  const playerTotal = history.reduce((s, r) => s + r.playerPayoff, 0);
39915
39931
  const opponentTotal = history.reduce((s, r) => s + r.opponentPayoff, 0);
39916
- const won = isComplete && playerTotal >= entity.targetScore;
39917
- const actions = entity?.actions ?? [];
39918
- const payoffMatrix = entity?.payoffMatrix ?? [];
39932
+ const won = isComplete && playerTotal >= (resolved?.targetScore ?? 0);
39933
+ const actions = resolved?.actions ?? [];
39934
+ const payoffMatrix = resolved?.payoffMatrix ?? [];
39919
39935
  const handleAction = useCallback((actionId) => {
39920
39936
  if (isComplete) return;
39921
- const opponentAction = getOpponentAction(entity.opponentStrategy, actions, history);
39937
+ const opponentAction = getOpponentAction(resolved?.opponentStrategy ?? "random", actions, history);
39922
39938
  const payoff = payoffMatrix.find(
39923
39939
  (p2) => p2.playerAction === actionId && p2.opponentAction === opponentAction
39924
39940
  );
@@ -39931,41 +39947,42 @@ function NegotiatorBoard({
39931
39947
  };
39932
39948
  const newHistory = [...history, result];
39933
39949
  setHistory(newHistory);
39934
- if (newHistory.length >= entity.totalRounds) {
39950
+ if (newHistory.length >= (resolved?.totalRounds ?? 0)) {
39935
39951
  const total = newHistory.reduce((s, r) => s + r.playerPayoff, 0);
39936
- if (total >= entity.targetScore) {
39952
+ if (total >= (resolved?.targetScore ?? 0)) {
39937
39953
  emit(`UI:${completeEvent}`, { success: true, score: total });
39938
39954
  }
39939
- if (newHistory.length >= 3 && entity.hint) {
39955
+ if (newHistory.length >= 3 && resolved?.hint) {
39940
39956
  setShowHint(true);
39941
39957
  }
39942
39958
  }
39943
- }, [isComplete, entity, actions, payoffMatrix, history, currentRound, completeEvent, emit]);
39959
+ }, [isComplete, resolved, actions, payoffMatrix, history, currentRound, completeEvent, emit]);
39944
39960
  const handleReset = () => {
39945
39961
  setHistory([]);
39946
39962
  setShowHint(false);
39947
39963
  };
39948
39964
  const getActionLabel = (id) => actions.find((a) => a.id === id)?.label ?? id;
39965
+ if (!resolved) return null;
39949
39966
  return /* @__PURE__ */ jsx(
39950
39967
  Box,
39951
39968
  {
39952
39969
  className,
39953
39970
  style: {
39954
- backgroundImage: entity.theme?.background ? `url(${entity.theme.background})` : void 0,
39971
+ backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
39955
39972
  backgroundSize: "cover",
39956
39973
  backgroundPosition: "center"
39957
39974
  },
39958
39975
  children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
39959
- entity.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: entity.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : entity.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
39976
+ resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
39960
39977
  /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
39961
- /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: entity.title }),
39962
- /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.description }),
39978
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title }),
39979
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description }),
39963
39980
  /* @__PURE__ */ jsxs(HStack, { gap: "md", children: [
39964
- /* @__PURE__ */ jsx(Badge, { size: "sm", children: t("negotiator.round", { current: String(currentRound), total: String(entity.totalRounds) }) }),
39981
+ /* @__PURE__ */ jsx(Badge, { size: "sm", children: t("negotiator.round", { current: String(currentRound), total: String(resolved.totalRounds) }) }),
39965
39982
  /* @__PURE__ */ jsxs(Badge, { size: "sm", children: [
39966
39983
  t("negotiator.target"),
39967
39984
  ": ",
39968
- entity.targetScore
39985
+ resolved.targetScore
39969
39986
  ] })
39970
39987
  ] })
39971
39988
  ] }) }),
@@ -40014,16 +40031,16 @@ function NegotiatorBoard({
40014
40031
  ] }) }),
40015
40032
  isComplete && /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
40016
40033
  /* @__PURE__ */ jsx(Icon, { icon: CheckCircle, size: "lg", className: won ? "text-success" : "text-error" }),
40017
- /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: won ? entity.successMessage ?? t("negotiator.success") : entity.failMessage ?? t("negotiator.failed") }),
40034
+ /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: won ? resolved.successMessage ?? t("negotiator.success") : resolved.failMessage ?? t("negotiator.failed") }),
40018
40035
  /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
40019
40036
  t("negotiator.finalScore"),
40020
40037
  ": ",
40021
40038
  playerTotal,
40022
40039
  "/",
40023
- entity.targetScore
40040
+ resolved.targetScore
40024
40041
  ] })
40025
40042
  ] }) }),
40026
- showHint && entity.hint && !won && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.hint }) }),
40043
+ showHint && resolved.hint && !won && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
40027
40044
  isComplete && !won && /* @__PURE__ */ jsx(HStack, { justify: "center", children: /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: handleReset, children: t("negotiator.playAgain") }) })
40028
40045
  ] })
40029
40046
  }
@@ -42816,15 +42833,16 @@ function SequencerBoard({
42816
42833
  }) {
42817
42834
  const { emit } = useEventBus();
42818
42835
  const { t } = useTranslate();
42836
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
42819
42837
  const [headerError, setHeaderError] = useState(false);
42820
42838
  const [slots, setSlots] = useState(
42821
- () => Array.from({ length: entity.maxSlots }, () => void 0)
42839
+ () => Array.from({ length: resolved?.maxSlots ?? 0 }, () => void 0)
42822
42840
  );
42823
42841
  const [playState, setPlayState] = useState("idle");
42824
42842
  const [currentStep, setCurrentStep] = useState(-1);
42825
42843
  const [attempts, setAttempts] = useState(0);
42826
42844
  const [slotFeedback, setSlotFeedback] = useState(
42827
- () => Array.from({ length: entity.maxSlots }, () => null)
42845
+ () => Array.from({ length: resolved?.maxSlots ?? 0 }, () => null)
42828
42846
  );
42829
42847
  const timerRef = useRef(null);
42830
42848
  useEffect(() => () => {
@@ -42858,17 +42876,17 @@ function SequencerBoard({
42858
42876
  }, [emit]);
42859
42877
  const handleReset = useCallback(() => {
42860
42878
  if (timerRef.current) clearTimeout(timerRef.current);
42861
- setSlots(Array.from({ length: entity.maxSlots }, () => void 0));
42879
+ setSlots(Array.from({ length: resolved?.maxSlots ?? 0 }, () => void 0));
42862
42880
  setPlayState("idle");
42863
42881
  setCurrentStep(-1);
42864
42882
  setAttempts(0);
42865
- setSlotFeedback(Array.from({ length: entity.maxSlots }, () => null));
42866
- }, [entity.maxSlots]);
42883
+ setSlotFeedback(Array.from({ length: resolved?.maxSlots ?? 0 }, () => null));
42884
+ }, [resolved?.maxSlots]);
42867
42885
  const filledSlots = slots.filter((s) => !!s);
42868
42886
  const canPlay = filledSlots.length > 0 && playState === "idle";
42869
42887
  const handlePlay = useCallback(() => {
42870
42888
  if (!canPlay) return;
42871
- setSlotFeedback(Array.from({ length: entity.maxSlots }, () => null));
42889
+ setSlotFeedback(Array.from({ length: resolved?.maxSlots ?? 0 }, () => null));
42872
42890
  emit("UI:PLAY_SOUND", { key: "confirm" });
42873
42891
  const sequence = slots.map((s) => s?.id || "");
42874
42892
  if (playEvent) {
@@ -42879,10 +42897,10 @@ function SequencerBoard({
42879
42897
  let step = 0;
42880
42898
  const advance = () => {
42881
42899
  step++;
42882
- if (step >= entity.maxSlots) {
42900
+ if (step >= (resolved?.maxSlots ?? 0)) {
42883
42901
  const playerSeq = slots.map((s) => s?.id);
42884
42902
  const playerIds = slots.filter(Boolean).map((s) => s?.id || "");
42885
- const success = entity.solutions.some(
42903
+ const success = (resolved?.solutions ?? []).some(
42886
42904
  (sol) => sol.length === playerIds.length && sol.every((id, i) => id === playerIds[i])
42887
42905
  );
42888
42906
  if (success) {
@@ -42894,7 +42912,7 @@ function SequencerBoard({
42894
42912
  }
42895
42913
  } else {
42896
42914
  setAttempts((prev) => prev + 1);
42897
- const feedback = computeSlotFeedback(playerSeq, entity.solutions);
42915
+ const feedback = computeSlotFeedback(playerSeq, resolved?.solutions ?? []);
42898
42916
  setSlotFeedback(feedback);
42899
42917
  setPlayState("idle");
42900
42918
  setCurrentStep(-1);
@@ -42912,10 +42930,10 @@ function SequencerBoard({
42912
42930
  }
42913
42931
  };
42914
42932
  timerRef.current = setTimeout(advance, stepDurationMs);
42915
- }, [canPlay, slots, entity.maxSlots, entity.solutions, stepDurationMs, playEvent, completeEvent, emit]);
42933
+ }, [canPlay, slots, resolved?.maxSlots, resolved?.solutions, stepDurationMs, playEvent, completeEvent, emit]);
42916
42934
  const machine = {
42917
- name: entity.title,
42918
- description: entity.description,
42935
+ name: resolved?.title ?? "",
42936
+ description: resolved?.description ?? "",
42919
42937
  states: slots.map((s, i) => stepLabel(s, i)),
42920
42938
  currentState: currentStep >= 0 ? stepLabel(slots[currentStep], currentStep) : "__idle__",
42921
42939
  transitions: slots.slice(0, -1).map((s, i) => ({
@@ -42924,36 +42942,37 @@ function SequencerBoard({
42924
42942
  event: "NEXT"
42925
42943
  }))
42926
42944
  };
42927
- const usedIds = entity.allowDuplicates === false ? slots.filter(Boolean).map((s) => s?.id || "") : [];
42928
- const showHint = attempts >= 3 && !!entity.hint;
42945
+ const usedIds = resolved?.allowDuplicates === false ? slots.filter(Boolean).map((s) => s?.id || "") : [];
42946
+ const showHint = attempts >= 3 && !!resolved?.hint;
42929
42947
  const hasFeedback = slotFeedback.some((f3) => f3 !== null);
42930
42948
  const correctCount = slotFeedback.filter((f3) => f3 === "correct").length;
42931
42949
  const encourageKey = ENCOURAGEMENT_KEYS2[Math.min(attempts - 1, ENCOURAGEMENT_KEYS2.length - 1)] ?? ENCOURAGEMENT_KEYS2[0];
42950
+ if (!resolved) return null;
42932
42951
  return /* @__PURE__ */ jsxs(
42933
42952
  VStack,
42934
42953
  {
42935
42954
  className: cn("p-4 gap-6", className),
42936
42955
  style: {
42937
- backgroundImage: entity.theme?.background ? `url(${entity.theme.background})` : void 0,
42956
+ backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
42938
42957
  backgroundSize: "cover",
42939
42958
  backgroundPosition: "center"
42940
42959
  },
42941
42960
  children: [
42942
- entity.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: entity.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : entity.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
42961
+ resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
42943
42962
  /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
42944
- /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: entity.title }),
42945
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: entity.description })
42963
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: resolved.title }),
42964
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: resolved.description })
42946
42965
  ] }),
42947
42966
  showHint && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-accent/10 border border-accent/30", children: /* @__PURE__ */ jsxs(HStack, { className: "items-start", gap: "xs", children: [
42948
42967
  /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
42949
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: entity.hint })
42968
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: resolved.hint })
42950
42969
  ] }) }),
42951
42970
  filledSlots.length > 0 && /* @__PURE__ */ jsx(TraitStateViewer, { trait: machine, variant: "linear", size: "md" }),
42952
42971
  /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
42953
42972
  /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
42954
42973
  /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("sequencer.yourSequence") + ":" }),
42955
42974
  hasFeedback && playState === "idle" && /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
42956
- `${correctCount}/${entity.maxSlots} `,
42975
+ `${correctCount}/${resolved.maxSlots} `,
42957
42976
  "\u2705"
42958
42977
  ] })
42959
42978
  ] }),
@@ -42961,7 +42980,7 @@ function SequencerBoard({
42961
42980
  SequenceBar,
42962
42981
  {
42963
42982
  slots,
42964
- maxSlots: entity.maxSlots,
42983
+ maxSlots: resolved.maxSlots,
42965
42984
  onSlotDrop: handleSlotDrop,
42966
42985
  onSlotRemove: handleSlotRemove,
42967
42986
  playing: playState === "playing",
@@ -42975,15 +42994,15 @@ function SequencerBoard({
42975
42994
  playState !== "playing" && /* @__PURE__ */ jsx(
42976
42995
  ActionPalette,
42977
42996
  {
42978
- actions: entity.availableActions,
42997
+ actions: resolved.availableActions,
42979
42998
  usedActionIds: usedIds,
42980
- allowDuplicates: entity.allowDuplicates !== false,
42999
+ allowDuplicates: resolved.allowDuplicates !== false,
42981
43000
  categoryColors,
42982
43001
  label: t("sequencer.dragActions")
42983
43002
  }
42984
43003
  ),
42985
43004
  hasFeedback && playState === "idle" && attempts > 0 && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-warning/10 border border-warning/30 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: t(encourageKey) }) }),
42986
- playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: entity.successMessage || t("sequencer.levelComplete") }) }),
43005
+ playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: resolved.successMessage || t("sequencer.levelComplete") }) }),
42987
43006
  /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
42988
43007
  /* @__PURE__ */ jsx(
42989
43008
  Button,
@@ -43806,7 +43825,8 @@ function SimulatorBoard({
43806
43825
  }) {
43807
43826
  const { emit } = useEventBus();
43808
43827
  const { t } = useTranslate();
43809
- const parameters = entity?.parameters ?? [];
43828
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
43829
+ const parameters = resolved?.parameters ?? [];
43810
43830
  const [values, setValues] = useState(() => {
43811
43831
  const init = {};
43812
43832
  for (const p2 of parameters) {
@@ -43820,15 +43840,15 @@ function SimulatorBoard({
43820
43840
  const [showHint, setShowHint] = useState(false);
43821
43841
  const computeOutput = useCallback((params) => {
43822
43842
  try {
43823
- const fn = new Function("params", `return (${entity.computeExpression})`);
43843
+ const fn = new Function("params", `return (${resolved?.computeExpression})`);
43824
43844
  return fn(params);
43825
43845
  } catch {
43826
43846
  return 0;
43827
43847
  }
43828
- }, [entity.computeExpression]);
43848
+ }, [resolved?.computeExpression]);
43829
43849
  const output = useMemo(() => computeOutput(values) ?? 0, [computeOutput, values]);
43830
- const targetValue = entity?.targetValue ?? 0;
43831
- const targetTolerance = entity?.targetTolerance ?? 0;
43850
+ const targetValue = resolved?.targetValue ?? 0;
43851
+ const targetTolerance = resolved?.targetTolerance ?? 0;
43832
43852
  const isCorrect = Math.abs(output - targetValue) <= targetTolerance;
43833
43853
  const handleParameterChange = (id, value) => {
43834
43854
  if (submitted) return;
@@ -43843,7 +43863,7 @@ function SimulatorBoard({
43843
43863
  };
43844
43864
  const handleReset = () => {
43845
43865
  setSubmitted(false);
43846
- if (attempts >= 2 && entity.hint) {
43866
+ if (attempts >= 2 && resolved?.hint) {
43847
43867
  setShowHint(true);
43848
43868
  }
43849
43869
  };
@@ -43857,20 +43877,21 @@ function SimulatorBoard({
43857
43877
  setAttempts(0);
43858
43878
  setShowHint(false);
43859
43879
  };
43880
+ if (!resolved) return null;
43860
43881
  return /* @__PURE__ */ jsx(
43861
43882
  Box,
43862
43883
  {
43863
43884
  className,
43864
43885
  style: {
43865
- backgroundImage: entity.theme?.background ? `url(${entity.theme.background})` : void 0,
43886
+ backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
43866
43887
  backgroundSize: "cover",
43867
43888
  backgroundPosition: "center"
43868
43889
  },
43869
43890
  children: /* @__PURE__ */ jsxs(VStack, { gap: "lg", className: "p-4", children: [
43870
- entity.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: entity.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : entity.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
43891
+ resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
43871
43892
  /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
43872
- /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: entity.title }),
43873
- /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.description })
43893
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title }),
43894
+ /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.description })
43874
43895
  ] }) }),
43875
43896
  /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "md", children: [
43876
43897
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: t("simulator.parameters") }),
@@ -43911,28 +43932,28 @@ function SimulatorBoard({
43911
43932
  ] }, param.id))
43912
43933
  ] }) }),
43913
43934
  /* @__PURE__ */ jsx(Card, { className: "p-4", children: /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", children: [
43914
- /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: entity.outputLabel }),
43935
+ /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "bold", className: "uppercase tracking-wider text-muted-foreground", children: resolved.outputLabel }),
43915
43936
  /* @__PURE__ */ jsxs(Typography, { variant: "h3", weight: "bold", children: [
43916
43937
  output.toFixed(2),
43917
43938
  " ",
43918
- entity.outputUnit
43939
+ resolved.outputUnit
43919
43940
  ] }),
43920
43941
  submitted && /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
43921
43942
  /* @__PURE__ */ jsx(Icon, { icon: isCorrect ? CheckCircle : XCircle, size: "sm", className: isCorrect ? "text-success" : "text-error" }),
43922
- /* @__PURE__ */ jsx(Typography, { variant: "body", className: isCorrect ? "text-success" : "text-error", children: isCorrect ? entity.successMessage ?? t("simulator.correct") : entity.failMessage ?? t("simulator.incorrect") })
43943
+ /* @__PURE__ */ jsx(Typography, { variant: "body", className: isCorrect ? "text-success" : "text-error", children: isCorrect ? resolved.successMessage ?? t("simulator.correct") : resolved.failMessage ?? t("simulator.incorrect") })
43923
43944
  ] }),
43924
43945
  /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-muted-foreground", children: [
43925
43946
  t("simulator.target"),
43926
43947
  ": ",
43927
43948
  targetValue,
43928
43949
  " ",
43929
- entity?.outputUnit ?? "",
43950
+ resolved.outputUnit,
43930
43951
  " (\xB1",
43931
43952
  targetTolerance,
43932
43953
  ")"
43933
43954
  ] })
43934
43955
  ] }) }),
43935
- showHint && entity.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: entity.hint }) }),
43956
+ showHint && resolved.hint && /* @__PURE__ */ jsx(Card, { className: "p-4 border-l-4 border-l-warning", children: /* @__PURE__ */ jsx(Typography, { variant: "body", children: resolved.hint }) }),
43936
43957
  /* @__PURE__ */ jsxs(HStack, { gap: "sm", justify: "center", children: [
43937
43958
  !submitted ? /* @__PURE__ */ jsxs(Button, { variant: "primary", onClick: handleSubmit, children: [
43938
43959
  /* @__PURE__ */ jsx(Icon, { icon: Play, size: "sm" }),
@@ -44512,13 +44533,14 @@ function StateArchitectBoard({
44512
44533
  }) {
44513
44534
  const { emit } = useEventBus();
44514
44535
  const { t } = useTranslate();
44515
- const [transitions, setTransitions] = useState(entity.transitions);
44536
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
44537
+ const [transitions, setTransitions] = useState(resolved?.transitions ?? []);
44516
44538
  const [headerError, setHeaderError] = useState(false);
44517
44539
  const [playState, setPlayState] = useState("editing");
44518
- const [currentState, setCurrentState] = useState(entity.initialState);
44540
+ const [currentState, setCurrentState] = useState(resolved?.initialState ?? "");
44519
44541
  const [selectedState, setSelectedState] = useState(null);
44520
44542
  const [testResults, setTestResults] = useState([]);
44521
- const [variables, setVariables] = useState(entity.variables);
44543
+ const [variables, setVariables] = useState(resolved?.variables ?? []);
44522
44544
  const [attempts, setAttempts] = useState(0);
44523
44545
  const timerRef = useRef(null);
44524
44546
  const [addingFrom, setAddingFrom] = useState(null);
@@ -44527,12 +44549,12 @@ function StateArchitectBoard({
44527
44549
  }, []);
44528
44550
  const GRAPH_W = 500;
44529
44551
  const GRAPH_H = 400;
44530
- const positions = useMemo(() => layoutStates(entity.states, GRAPH_W, GRAPH_H), [entity.states]);
44552
+ const positions = useMemo(() => layoutStates(resolved?.states ?? [], GRAPH_W, GRAPH_H), [resolved?.states]);
44531
44553
  const handleStateClick = useCallback((state) => {
44532
44554
  if (playState !== "editing") return;
44533
44555
  if (addingFrom) {
44534
44556
  if (addingFrom !== state) {
44535
- const event = entity.availableEvents[0] || "EVENT";
44557
+ const event = resolved?.availableEvents[0] || "EVENT";
44536
44558
  const newTrans = {
44537
44559
  id: `t-${nextTransId++}`,
44538
44560
  from: addingFrom,
@@ -44545,7 +44567,7 @@ function StateArchitectBoard({
44545
44567
  } else {
44546
44568
  setSelectedState(state);
44547
44569
  }
44548
- }, [playState, addingFrom, entity.availableEvents]);
44570
+ }, [playState, addingFrom, resolved?.availableEvents]);
44549
44571
  const handleStartAddTransition = useCallback(() => {
44550
44572
  if (!selectedState) return;
44551
44573
  setAddingFrom(selectedState);
@@ -44554,9 +44576,9 @@ function StateArchitectBoard({
44554
44576
  setTransitions((prev) => prev.filter((t2) => t2.id !== transId));
44555
44577
  }, []);
44556
44578
  const machine = useMemo(() => ({
44557
- name: entity.entityName,
44558
- description: entity.description,
44559
- states: entity.states,
44579
+ name: resolved?.entityName ?? "",
44580
+ description: resolved?.description ?? "",
44581
+ states: resolved?.states ?? [],
44560
44582
  currentState,
44561
44583
  transitions: transitions.map((t2) => ({
44562
44584
  from: t2.from,
@@ -44564,7 +44586,7 @@ function StateArchitectBoard({
44564
44586
  event: t2.event,
44565
44587
  guardHint: t2.guardHint
44566
44588
  }))
44567
- }), [entity, currentState, transitions]);
44589
+ }), [resolved, currentState, transitions]);
44568
44590
  const handleTest = useCallback(() => {
44569
44591
  if (playState !== "editing") return;
44570
44592
  if (testEvent) emit(`UI:${testEvent}`, {});
@@ -44573,7 +44595,7 @@ function StateArchitectBoard({
44573
44595
  const results = [];
44574
44596
  let testIdx = 0;
44575
44597
  const runNextTest = () => {
44576
- if (testIdx >= entity.testCases.length) {
44598
+ if (testIdx >= (resolved?.testCases.length ?? 0)) {
44577
44599
  const allPassed = results.every((r) => r.passed);
44578
44600
  setPlayState(allPassed ? "success" : "fail");
44579
44601
  setTestResults(results);
@@ -44588,8 +44610,9 @@ function StateArchitectBoard({
44588
44610
  }
44589
44611
  return;
44590
44612
  }
44591
- const testCase = entity.testCases[testIdx];
44592
- let state = entity.initialState;
44613
+ const testCase = resolved?.testCases[testIdx];
44614
+ if (!testCase) return;
44615
+ let state = resolved.initialState;
44593
44616
  for (const event of testCase.events) {
44594
44617
  const trans = transitions.find((t2) => t2.from === state && t2.event === event);
44595
44618
  if (trans) {
@@ -44607,52 +44630,53 @@ function StateArchitectBoard({
44607
44630
  timerRef.current = setTimeout(runNextTest, stepDurationMs);
44608
44631
  };
44609
44632
  timerRef.current = setTimeout(runNextTest, stepDurationMs);
44610
- }, [playState, transitions, entity, stepDurationMs, testEvent, completeEvent, emit]);
44633
+ }, [playState, transitions, resolved, stepDurationMs, testEvent, completeEvent, emit]);
44611
44634
  const handleTryAgain = useCallback(() => {
44612
44635
  if (timerRef.current) clearTimeout(timerRef.current);
44613
44636
  setPlayState("editing");
44614
- setCurrentState(entity.initialState);
44637
+ setCurrentState(resolved?.initialState ?? "");
44615
44638
  setTestResults([]);
44616
- }, [entity.initialState]);
44639
+ }, [resolved?.initialState]);
44617
44640
  const handleReset = useCallback(() => {
44618
44641
  if (timerRef.current) clearTimeout(timerRef.current);
44619
- setTransitions(entity.transitions);
44642
+ setTransitions(resolved?.transitions ?? []);
44620
44643
  setPlayState("editing");
44621
- setCurrentState(entity.initialState);
44644
+ setCurrentState(resolved?.initialState ?? "");
44622
44645
  setTestResults([]);
44623
- setVariables(entity.variables);
44646
+ setVariables(resolved?.variables ?? []);
44624
44647
  setSelectedState(null);
44625
44648
  setAddingFrom(null);
44626
44649
  setAttempts(0);
44627
- }, [entity]);
44650
+ }, [resolved]);
44628
44651
  const codeData = useMemo(() => ({
44629
- name: entity.entityName,
44630
- states: entity.states,
44631
- initialState: entity.initialState,
44652
+ name: resolved?.entityName ?? "",
44653
+ states: resolved?.states ?? [],
44654
+ initialState: resolved?.initialState ?? "",
44632
44655
  transitions: transitions.map((t2) => ({
44633
44656
  from: t2.from,
44634
44657
  to: t2.to,
44635
44658
  event: t2.event,
44636
44659
  ...t2.guardHint ? { guard: t2.guardHint } : {}
44637
44660
  }))
44638
- }), [entity, transitions]);
44661
+ }), [resolved, transitions]);
44662
+ if (!resolved) return null;
44639
44663
  return /* @__PURE__ */ jsxs(
44640
44664
  VStack,
44641
44665
  {
44642
44666
  className: cn("p-4 gap-6", className),
44643
44667
  style: {
44644
- backgroundImage: entity.theme?.background ? `url(${entity.theme.background})` : void 0,
44668
+ backgroundImage: resolved.theme?.background ? `url(${resolved.theme.background})` : void 0,
44645
44669
  backgroundSize: "cover",
44646
44670
  backgroundPosition: "center"
44647
44671
  },
44648
44672
  children: [
44649
- entity.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: entity.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : entity.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
44673
+ resolved.headerImage && !headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 overflow-hidden rounded-container", children: /* @__PURE__ */ jsx("img", { src: resolved.headerImage, alt: "", onError: () => setHeaderError(true), className: "w-full h-full object-cover" }) }) : resolved.headerImage && headerError ? /* @__PURE__ */ jsx(Box, { className: "w-full h-32 rounded-container bg-gradient-to-br from-muted to-accent opacity-60" }) : null,
44650
44674
  /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
44651
- /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: entity.title }),
44652
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: entity.description }),
44675
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-foreground", children: resolved.title }),
44676
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children: resolved.description }),
44653
44677
  /* @__PURE__ */ jsxs(HStack, { className: "items-center p-2 rounded bg-warning/10 border border-warning/30", gap: "xs", children: [
44654
44678
  /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-warning font-bold", children: t("game.hint") + ":" }),
44655
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: entity.hint })
44679
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground", children: resolved.hint })
44656
44680
  ] })
44657
44681
  ] }),
44658
44682
  /* @__PURE__ */ jsxs(HStack, { className: "flex-wrap items-start", gap: "lg", children: [
@@ -44700,14 +44724,14 @@ function StateArchitectBoard({
44700
44724
  ]
44701
44725
  }
44702
44726
  ),
44703
- entity.states.map((state) => /* @__PURE__ */ jsx(
44727
+ resolved.states.map((state) => /* @__PURE__ */ jsx(
44704
44728
  StateNode2,
44705
44729
  {
44706
44730
  name: state,
44707
44731
  position: positions[state],
44708
44732
  isCurrent: state === currentState,
44709
44733
  isSelected: state === selectedState,
44710
- isInitial: state === entity.initialState,
44734
+ isInitial: state === resolved.initialState,
44711
44735
  onClick: () => handleStateClick(state)
44712
44736
  },
44713
44737
  state
@@ -44754,7 +44778,7 @@ function StateArchitectBoard({
44754
44778
  /* @__PURE__ */ jsx(
44755
44779
  VariablePanel,
44756
44780
  {
44757
- entityName: entity.entityName,
44781
+ entityName: resolved.entityName,
44758
44782
  variables
44759
44783
  }
44760
44784
  ),
@@ -44766,15 +44790,15 @@ function StateArchitectBoard({
44766
44790
  !r.passed && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r.actualState }) })
44767
44791
  ] }, i))
44768
44792
  ] }),
44769
- entity.showCodeView !== false && /* @__PURE__ */ jsx(CodeView, { data: codeData, label: "View Code" })
44793
+ resolved.showCodeView !== false && /* @__PURE__ */ jsx(CodeView, { data: codeData, label: "View Code" })
44770
44794
  ] })
44771
44795
  ] }),
44772
- playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: entity.successMessage || t("stateArchitect.allPassed") }) }),
44796
+ playState === "success" && /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "h5", className: "text-success", children: resolved.successMessage || t("stateArchitect.allPassed") }) }),
44773
44797
  playState === "fail" && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
44774
44798
  /* @__PURE__ */ jsx(Box, { className: "p-4 rounded-container bg-warning/10 border border-warning/30 text-center", children: /* @__PURE__ */ jsx(Typography, { variant: "body1", className: "text-foreground font-medium", children: t(ENCOURAGEMENT_KEYS3[Math.min(attempts - 1, ENCOURAGEMENT_KEYS3.length - 1)] ?? ENCOURAGEMENT_KEYS3[0]) }) }),
44775
- attempts >= 3 && entity.hint && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-accent/10 border border-accent/30", children: /* @__PURE__ */ jsxs(HStack, { className: "items-start", gap: "xs", children: [
44799
+ attempts >= 3 && resolved.hint && /* @__PURE__ */ jsx(Box, { className: "p-3 rounded-container bg-accent/10 border border-accent/30", children: /* @__PURE__ */ jsxs(HStack, { className: "items-start", gap: "xs", children: [
44776
44800
  /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-accent font-bold shrink-0", children: "\u{1F4A1} " + t("game.hint") + ":" }),
44777
- /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: entity.hint })
44801
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-foreground", children: resolved.hint })
44778
44802
  ] }) })
44779
44803
  ] }),
44780
44804
  /* @__PURE__ */ jsxs(HStack, { gap: "sm", children: [
@@ -45630,8 +45654,9 @@ var init_useBattleState = __esm({
45630
45654
  }
45631
45655
  });
45632
45656
  function UncontrolledBattleBoard({ entity, ...rest }) {
45657
+ const resolved = Array.isArray(entity) ? entity[0] : entity;
45633
45658
  const battleState = useBattleState(
45634
- entity.initialUnits,
45659
+ resolved?.initialUnits ?? [],
45635
45660
  {
45636
45661
  tileClickEvent: rest.tileClickEvent,
45637
45662
  unitClickEvent: rest.unitClickEvent,
@@ -45648,12 +45673,13 @@ function UncontrolledBattleBoard({ entity, ...rest }) {
45648
45673
  calculateDamage: rest.calculateDamage
45649
45674
  }
45650
45675
  );
45676
+ if (!resolved) return null;
45651
45677
  return /* @__PURE__ */ jsx(
45652
45678
  BattleBoard,
45653
45679
  {
45654
45680
  ...rest,
45655
45681
  entity: {
45656
- ...entity,
45682
+ ...resolved,
45657
45683
  units: battleState.units,
45658
45684
  phase: battleState.phase,
45659
45685
  turn: battleState.turn,
@@ -46356,6 +46382,7 @@ var init_component_registry_generated = __esm({
46356
46382
  init_StatsOrganism();
46357
46383
  init_StatusDot();
46358
46384
  init_StatusEffect();
46385
+ init_StepFlow();
46359
46386
  init_StepFlowOrganism();
46360
46387
  init_SvgBranch();
46361
46388
  init_SvgConnection();
@@ -46674,6 +46701,7 @@ var init_component_registry_generated = __esm({
46674
46701
  "StatsOrganism": StatsOrganism,
46675
46702
  "StatusDot": StatusDot,
46676
46703
  "StatusEffect": StatusEffect,
46704
+ "StepFlow": StepFlow,
46677
46705
  "StepFlowOrganism": StepFlowOrganism,
46678
46706
  "SvgBranch": SvgBranch,
46679
46707
  "SvgConnection": SvgConnection,
@@ -47401,11 +47429,15 @@ function SlotContentRenderer({
47401
47429
  }
47402
47430
  if (propsSchema) {
47403
47431
  for (const [propKey, propDef] of Object.entries(propsSchema)) {
47404
- const v = renderedProps[propKey];
47405
- if ((typeof v === "string" || typeof v === "number") && propDef.types?.some(
47432
+ const isDate = propDef.types?.some(
47406
47433
  (t) => t === "date" || t === "datetime" || t === "timestamp"
47407
- )) {
47434
+ );
47435
+ if (!isDate) continue;
47436
+ const v = renderedProps[propKey];
47437
+ if (typeof v === "string" || typeof v === "number") {
47408
47438
  renderedProps[propKey] = new Date(v);
47439
+ } else if (v == null && propDef.required) {
47440
+ renderedProps[propKey] = /* @__PURE__ */ new Date();
47409
47441
  }
47410
47442
  }
47411
47443
  }
@@ -47649,12 +47681,26 @@ function createClientEffectHandlers(options) {
47649
47681
  }
47650
47682
  var lambdaLog = createLogger("almadar:ui:fn-form-lambda");
47651
47683
  function isFnFormLambda(value) {
47652
- return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
47684
+ if (!Array.isArray(value)) return false;
47685
+ const arr = value;
47686
+ if (arr.length !== 3 || arr[0] !== "fn" || arr[2] === null || typeof arr[2] !== "object") {
47687
+ return false;
47688
+ }
47689
+ const params = arr[1];
47690
+ return typeof params === "string" || Array.isArray(params) && params.length > 0 && params.every((p2) => typeof p2 === "string");
47691
+ }
47692
+ function fnFormParams(value) {
47693
+ const p2 = value[1];
47694
+ if (typeof p2 === "string") return [p2];
47695
+ if (Array.isArray(p2)) return p2.filter((x) => typeof x === "string");
47696
+ return [];
47653
47697
  }
47654
- function resolveLambdaBindings(body, argName, arg) {
47655
- const prefix = `@${argName}.`;
47698
+ function resolveLambdaBindings(body, params, item, index) {
47699
+ const itemName = params[0];
47700
+ const indexName = params[1];
47701
+ const itemPrefix = itemName ? `@${itemName}.` : null;
47656
47702
  const lookup = (path) => {
47657
- let cur = arg;
47703
+ let cur = item;
47658
47704
  for (const seg of path.split(".")) {
47659
47705
  if (cur === null || cur === void 0) return void 0;
47660
47706
  if (typeof cur !== "object" || Array.isArray(cur)) return void 0;
@@ -47662,21 +47708,23 @@ function resolveLambdaBindings(body, argName, arg) {
47662
47708
  }
47663
47709
  return cur;
47664
47710
  };
47711
+ const recur = (b) => resolveLambdaBindings(b, params, item, index);
47665
47712
  if (typeof body === "string") {
47666
- if (body === `@${argName}`) return arg;
47667
- if (body.startsWith(prefix)) {
47668
- const v = lookup(body.slice(prefix.length));
47713
+ if (indexName && body === `@${indexName}`) return index;
47714
+ if (itemName && body === `@${itemName}`) return item;
47715
+ if (itemPrefix && body.startsWith(itemPrefix)) {
47716
+ const v = lookup(body.slice(itemPrefix.length));
47669
47717
  return v === void 0 || v === null ? "" : v;
47670
47718
  }
47671
47719
  return body;
47672
47720
  }
47673
47721
  if (Array.isArray(body)) {
47674
- return body.map((b) => resolveLambdaBindings(b, argName, arg));
47722
+ return body.map((b) => recur(b));
47675
47723
  }
47676
47724
  if (body !== null && typeof body === "object" && !React85__default.isValidElement(body) && !(body instanceof Date) && typeof body !== "function") {
47677
47725
  const out = {};
47678
47726
  for (const [k, v] of Object.entries(body)) {
47679
- out[k] = resolveLambdaBindings(v, argName, arg);
47727
+ out[k] = recur(v);
47680
47728
  }
47681
47729
  return out;
47682
47730
  }
@@ -47689,9 +47737,9 @@ function getSlotContentRenderer2() {
47689
47737
  _slotContentRenderer2 = mod.SlotContentRenderer;
47690
47738
  return _slotContentRenderer2;
47691
47739
  }
47692
- function makeLambdaFn(argName, lambdaBody, callerKey) {
47740
+ function makeLambdaFn(params, lambdaBody, callerKey) {
47693
47741
  return (item, index) => {
47694
- const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
47742
+ const resolvedBody = resolveLambdaBindings(lambdaBody, params, item, index);
47695
47743
  if (resolvedBody === null || typeof resolvedBody !== "object" || Array.isArray(resolvedBody) || typeof resolvedBody === "function" || React85__default.isValidElement(resolvedBody) || resolvedBody instanceof Date) {
47696
47744
  return null;
47697
47745
  }
@@ -47718,8 +47766,8 @@ function convertNode(node, callerKey) {
47718
47766
  if (node === null || node === void 0) return node;
47719
47767
  if (Array.isArray(node)) {
47720
47768
  if (isFnFormLambda(node)) {
47721
- const [, argName, body] = node;
47722
- return makeLambdaFn(argName, body, callerKey);
47769
+ const arr2 = node;
47770
+ return makeLambdaFn(fnFormParams(arr2), arr2[2], callerKey);
47723
47771
  }
47724
47772
  const arr = node;
47725
47773
  let anyChanged = false;
@@ -47741,9 +47789,9 @@ function convertObjectProps(props) {
47741
47789
  for (const [key, value] of Object.entries(props)) {
47742
47790
  if (isFnFormLambda(value)) {
47743
47791
  convertedAny = true;
47744
- const [, argName, body] = value;
47792
+ const arr = value;
47745
47793
  const targetKey = key === "renderItem" ? "children" : key;
47746
- out[targetKey] = makeLambdaFn(argName, body, key);
47794
+ out[targetKey] = makeLambdaFn(fnFormParams(arr), arr[2], key);
47747
47795
  lambdaLog.debug(`convert key=${key} \u2192 ${targetKey}`);
47748
47796
  continue;
47749
47797
  }