@almadar/ui 5.16.4 → 5.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/avl/index.cjs +191 -153
- package/dist/avl/index.js +191 -153
- package/dist/components/atoms/Avatar.d.ts +4 -2
- package/dist/components/atoms/ConditionalWrapper.d.ts +2 -2
- package/dist/components/atoms/Icon.d.ts +6 -2
- package/dist/components/atoms/Input.d.ts +3 -2
- package/dist/components/atoms/LawReferenceTooltip.d.ts +2 -2
- package/dist/components/atoms/game/MiniMap.d.ts +15 -17
- package/dist/components/atoms/index.d.ts +1 -0
- package/dist/components/atoms/types.d.ts +40 -0
- package/dist/components/index.cjs +191 -153
- package/dist/components/index.js +191 -153
- package/dist/components/molecules/CTABanner.d.ts +3 -8
- package/dist/components/molecules/CalendarGrid.d.ts +2 -2
- package/dist/components/molecules/CommunityLinks.d.ts +15 -12
- package/dist/components/molecules/DataGrid.d.ts +2 -1
- package/dist/components/molecules/DataList.d.ts +12 -11
- package/dist/components/molecules/GraphView.d.ts +2 -2
- package/dist/components/molecules/HeroSection.d.ts +4 -12
- package/dist/components/molecules/MapView.d.ts +2 -2
- package/dist/components/molecules/MarketingFooter.d.ts +6 -5
- package/dist/components/molecules/Meter.d.ts +2 -1
- package/dist/components/molecules/OptionConstraintGroup.d.ts +5 -3
- package/dist/components/molecules/PricingCard.d.ts +2 -4
- package/dist/components/molecules/QrScanner.d.ts +2 -2
- package/dist/components/molecules/RepeatableFormSection.d.ts +2 -2
- package/dist/components/molecules/ShowcaseCard.d.ts +2 -4
- package/dist/components/molecules/SplitSection.d.ts +2 -4
- package/dist/components/molecules/StatDisplay.d.ts +2 -1
- package/dist/components/molecules/StatsGrid.d.ts +5 -4
- package/dist/components/molecules/TableView.d.ts +2 -1
- package/dist/components/molecules/ViolationAlert.d.ts +2 -2
- package/dist/components/molecules/game/CraftingRecipe.d.ts +11 -7
- package/dist/components/molecules/game/DialogueBox.d.ts +2 -2
- package/dist/components/molecules/game/HealthPanel.d.ts +6 -5
- package/dist/components/molecules/game/IsometricCanvas.d.ts +9 -13
- package/dist/components/organisms/Chart.d.ts +2 -1
- package/dist/components/organisms/CodeViewer.d.ts +8 -6
- package/dist/components/organisms/ComponentPatterns.d.ts +2 -1
- package/dist/components/organisms/ConfirmDialog.d.ts +2 -1
- package/dist/components/organisms/CustomPattern.d.ts +2 -1
- package/dist/components/organisms/DataTable.d.ts +6 -5
- package/dist/components/organisms/DetailPanel.d.ts +5 -4
- package/dist/components/organisms/DocumentViewer.d.ts +9 -7
- package/dist/components/organisms/DrawerSlot.d.ts +2 -1
- package/dist/components/organisms/Form.d.ts +5 -4
- package/dist/components/organisms/GraphCanvas.d.ts +2 -1
- package/dist/components/organisms/Header.d.ts +17 -14
- package/dist/components/organisms/JazariStateMachine.d.ts +2 -1
- package/dist/components/organisms/LayoutPatterns.d.ts +4 -3
- package/dist/components/organisms/List.d.ts +2 -2
- package/dist/components/organisms/Meter.d.ts +2 -1
- package/dist/components/organisms/ModalSlot.d.ts +2 -1
- package/dist/components/organisms/Navigation.d.ts +2 -1
- package/dist/components/organisms/OrbitalVisualization.d.ts +2 -1
- package/dist/components/organisms/PageHeader.d.ts +7 -5
- package/dist/components/organisms/Section.d.ts +2 -1
- package/dist/components/organisms/Sidebar.d.ts +2 -1
- package/dist/components/organisms/SignaturePad.d.ts +2 -1
- package/dist/components/organisms/Split.d.ts +2 -1
- package/dist/components/organisms/StateMachineView.d.ts +8 -4
- package/dist/components/organisms/Timeline.d.ts +2 -1
- package/dist/components/organisms/ToastSlot.d.ts +2 -1
- package/dist/components/organisms/UISlotRenderer.d.ts +4 -3
- package/dist/components/organisms/WizardContainer.d.ts +2 -1
- package/dist/components/organisms/book/types.d.ts +2 -2
- package/dist/components/organisms/game/BattleBoard.d.ts +4 -4
- package/dist/components/organisms/game/CanvasEffect.d.ts +2 -1
- package/dist/components/organisms/game/CastleBoard.d.ts +6 -5
- package/dist/components/organisms/game/GameAudioProvider.d.ts +2 -1
- package/dist/components/organisms/game/GameAudioToggle.d.ts +2 -1
- package/dist/components/organisms/game/TraitSlot.d.ts +4 -3
- package/dist/components/organisms/game/TraitStateViewer.d.ts +6 -5
- package/dist/components/organisms/game/UncontrolledBattleBoard.d.ts +9 -4
- package/dist/components/organisms/game/WorldMapBoard.d.ts +11 -9
- package/dist/components/organisms/game/physics-sim/SimulationControls.d.ts +8 -7
- package/dist/components/organisms/game/puzzles/builder/BuilderBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/classifier/ClassifierBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/debugger/DebuggerBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/event-handler/EventHandlerBoard.d.ts +7 -4
- package/dist/components/organisms/game/puzzles/event-handler/ObjectRulePanel.d.ts +2 -2
- package/dist/components/organisms/game/puzzles/event-handler/RuleEditor.d.ts +7 -9
- package/dist/components/organisms/game/puzzles/negotiator/NegotiatorBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/sequencer/SequencerBoard.d.ts +5 -4
- package/dist/components/organisms/game/puzzles/simulator/SimulatorBoard.d.ts +3 -3
- package/dist/components/organisms/game/puzzles/state-architect/StateArchitectBoard.d.ts +5 -4
- package/dist/components/organisms/game/puzzles/state-architect/StateNode.d.ts +2 -4
- package/dist/components/organisms/game/puzzles/state-architect/TransitionArrow.d.ts +3 -8
- package/dist/components/organisms/game/types/isometric.d.ts +4 -4
- package/dist/components/organisms/index.d.ts +1 -1
- package/dist/components/organisms/types.d.ts +3 -1
- package/dist/components/templates/DashboardLayout.d.ts +6 -5
- package/dist/components/templates/GameTemplate.d.ts +7 -6
- package/dist/components/templates/GenericAppTemplate.d.ts +1 -7
- package/dist/components/templates/types.d.ts +14 -6
- package/dist/docs/index.cjs +60 -22
- package/dist/docs/index.d.cts +9 -4
- package/dist/docs/index.js +58 -20
- package/dist/marketing/index.cjs +61 -23
- package/dist/marketing/index.d.cts +54 -55
- package/dist/marketing/index.js +58 -20
- package/dist/providers/index.cjs +191 -153
- package/dist/providers/index.js +191 -153
- package/dist/runtime/index.cjs +191 -153
- package/dist/runtime/index.js +191 -153
- package/package.json +1 -1
package/dist/runtime/index.js
CHANGED
|
@@ -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 (
|
|
1727
|
-
return
|
|
1728
|
-
}, [
|
|
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 (
|
|
1741
|
-
const Direct =
|
|
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:
|
|
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:
|
|
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 =
|
|
17361
|
-
const 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 &&
|
|
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:
|
|
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
|
-
|
|
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:
|
|
17420
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
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 ?
|
|
17487
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "bold", children: allCorrect ? resolved.successMessage ?? t("builder.success") : resolved.failMessage ?? t("builder.incorrect") })
|
|
17481
17488
|
] }) }),
|
|
17482
|
-
showHint &&
|
|
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
|
|
19957
|
-
const
|
|
19958
|
-
const
|
|
19959
|
-
const
|
|
19960
|
-
const
|
|
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 =
|
|
20871
|
-
const 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 &&
|
|
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:
|
|
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
|
-
|
|
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:
|
|
20926
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
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 ?
|
|
20979
|
-
!allCorrect &&
|
|
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 &&
|
|
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 =
|
|
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 &&
|
|
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:
|
|
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
|
-
|
|
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:
|
|
35456
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", weight: "bold", children: resolved.title })
|
|
35444
35457
|
] }),
|
|
35445
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
35446
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground", children: t("debugger.findBugs", { count: String(
|
|
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 ?
|
|
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 &&
|
|
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
|
|
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 =
|
|
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 ===
|
|
36706
|
+
if (rule.thenAction === resolved?.goalEvent) {
|
|
36693
36707
|
goalReached = true;
|
|
36694
36708
|
}
|
|
36695
36709
|
});
|
|
36696
36710
|
}
|
|
36697
|
-
if (currentEvent ===
|
|
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,
|
|
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(
|
|
36729
|
+
setObjects(resolved?.objects ?? []);
|
|
36716
36730
|
setPlayState("editing");
|
|
36717
36731
|
setEventLog([]);
|
|
36718
|
-
setSelectedObjectId((
|
|
36732
|
+
setSelectedObjectId((resolved?.objects ?? [])[0]?.id || null);
|
|
36719
36733
|
setAttempts(0);
|
|
36720
|
-
}, [
|
|
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 &&
|
|
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:
|
|
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
|
-
|
|
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:
|
|
36749
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children:
|
|
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:
|
|
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:
|
|
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:
|
|
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 >=
|
|
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 >=
|
|
39917
|
-
const actions =
|
|
39918
|
-
const 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(
|
|
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 >=
|
|
39950
|
+
if (newHistory.length >= (resolved?.totalRounds ?? 0)) {
|
|
39935
39951
|
const total = newHistory.reduce((s, r) => s + r.playerPayoff, 0);
|
|
39936
|
-
if (total >=
|
|
39952
|
+
if (total >= (resolved?.targetScore ?? 0)) {
|
|
39937
39953
|
emit(`UI:${completeEvent}`, { success: true, score: total });
|
|
39938
39954
|
}
|
|
39939
|
-
if (newHistory.length >= 3 &&
|
|
39955
|
+
if (newHistory.length >= 3 && resolved?.hint) {
|
|
39940
39956
|
setShowHint(true);
|
|
39941
39957
|
}
|
|
39942
39958
|
}
|
|
39943
|
-
}, [isComplete,
|
|
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:
|
|
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
|
-
|
|
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:
|
|
39962
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
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(
|
|
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
|
-
|
|
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 ?
|
|
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
|
-
|
|
40040
|
+
resolved.targetScore
|
|
40024
40041
|
] })
|
|
40025
40042
|
] }) }),
|
|
40026
|
-
showHint &&
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
42866
|
-
}, [
|
|
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:
|
|
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 >=
|
|
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 =
|
|
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,
|
|
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,
|
|
42933
|
+
}, [canPlay, slots, resolved?.maxSlots, resolved?.solutions, stepDurationMs, playEvent, completeEvent, emit]);
|
|
42916
42934
|
const machine = {
|
|
42917
|
-
name:
|
|
42918
|
-
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 =
|
|
42928
|
-
const showHint = attempts >= 3 && !!
|
|
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:
|
|
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
|
-
|
|
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:
|
|
42945
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children:
|
|
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:
|
|
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}/${
|
|
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:
|
|
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:
|
|
42997
|
+
actions: resolved.availableActions,
|
|
42979
42998
|
usedActionIds: usedIds,
|
|
42980
|
-
allowDuplicates:
|
|
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:
|
|
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
|
|
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 (${
|
|
43843
|
+
const fn = new Function("params", `return (${resolved?.computeExpression})`);
|
|
43824
43844
|
return fn(params);
|
|
43825
43845
|
} catch {
|
|
43826
43846
|
return 0;
|
|
43827
43847
|
}
|
|
43828
|
-
}, [
|
|
43848
|
+
}, [resolved?.computeExpression]);
|
|
43829
43849
|
const output = useMemo(() => computeOutput(values) ?? 0, [computeOutput, values]);
|
|
43830
|
-
const targetValue =
|
|
43831
|
-
const targetTolerance =
|
|
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 &&
|
|
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:
|
|
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
|
-
|
|
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:
|
|
43873
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body", children:
|
|
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:
|
|
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
|
-
|
|
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 ?
|
|
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
|
-
|
|
43950
|
+
resolved.outputUnit,
|
|
43930
43951
|
" (\xB1",
|
|
43931
43952
|
targetTolerance,
|
|
43932
43953
|
")"
|
|
43933
43954
|
] })
|
|
43934
43955
|
] }) }),
|
|
43935
|
-
showHint &&
|
|
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
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
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,
|
|
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:
|
|
44558
|
-
description:
|
|
44559
|
-
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
|
-
}), [
|
|
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 >=
|
|
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 =
|
|
44592
|
-
|
|
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,
|
|
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(
|
|
44637
|
+
setCurrentState(resolved?.initialState ?? "");
|
|
44615
44638
|
setTestResults([]);
|
|
44616
|
-
}, [
|
|
44639
|
+
}, [resolved?.initialState]);
|
|
44617
44640
|
const handleReset = useCallback(() => {
|
|
44618
44641
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
44619
|
-
setTransitions(
|
|
44642
|
+
setTransitions(resolved?.transitions ?? []);
|
|
44620
44643
|
setPlayState("editing");
|
|
44621
|
-
setCurrentState(
|
|
44644
|
+
setCurrentState(resolved?.initialState ?? "");
|
|
44622
44645
|
setTestResults([]);
|
|
44623
|
-
setVariables(
|
|
44646
|
+
setVariables(resolved?.variables ?? []);
|
|
44624
44647
|
setSelectedState(null);
|
|
44625
44648
|
setAddingFrom(null);
|
|
44626
44649
|
setAttempts(0);
|
|
44627
|
-
}, [
|
|
44650
|
+
}, [resolved]);
|
|
44628
44651
|
const codeData = useMemo(() => ({
|
|
44629
|
-
name:
|
|
44630
|
-
states:
|
|
44631
|
-
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
|
-
}), [
|
|
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:
|
|
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
|
-
|
|
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:
|
|
44652
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground", children:
|
|
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:
|
|
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
|
-
|
|
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 ===
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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 &&
|
|
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:
|
|
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
|
-
|
|
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
|
-
...
|
|
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,
|
|
@@ -47399,6 +47427,16 @@ function SlotContentRenderer({
|
|
|
47399
47427
|
);
|
|
47400
47428
|
}
|
|
47401
47429
|
}
|
|
47430
|
+
if (propsSchema) {
|
|
47431
|
+
for (const [propKey, propDef] of Object.entries(propsSchema)) {
|
|
47432
|
+
const v = renderedProps[propKey];
|
|
47433
|
+
if ((typeof v === "string" || typeof v === "number") && propDef.types?.some(
|
|
47434
|
+
(t) => t === "date" || t === "datetime" || t === "timestamp"
|
|
47435
|
+
)) {
|
|
47436
|
+
renderedProps[propKey] = new Date(v);
|
|
47437
|
+
}
|
|
47438
|
+
}
|
|
47439
|
+
}
|
|
47402
47440
|
const finalProps = renderedProps;
|
|
47403
47441
|
const resolvedItems = Array.isArray(
|
|
47404
47442
|
finalProps.entity
|