@almadar/ui 5.89.0 → 5.91.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 (26) hide show
  1. package/dist/avl/index.cjs +63 -65
  2. package/dist/avl/index.js +63 -65
  3. package/dist/components/game/2d/{organisms → molecules}/ObjectRulePanel.d.ts +9 -4
  4. package/dist/components/game/2d/molecules/StateJsonView.d.ts +37 -0
  5. package/dist/components/game/2d/{organisms → molecules}/TraitSlot.d.ts +6 -3
  6. package/dist/components/game/2d/{organisms → molecules}/TraitStateViewer.d.ts +0 -2
  7. package/dist/components/game/2d/molecules/VariablePanel.d.ts +28 -0
  8. package/dist/components/game/2d/molecules/index.d.ts +11 -11
  9. package/dist/components/game/2d/organisms/EventHandlerBoard.d.ts +1 -1
  10. package/dist/components/game/2d/organisms/SequenceBar.d.ts +1 -1
  11. package/dist/components/game/shared/lib/puzzleObject.d.ts +1 -1
  12. package/dist/components/index.cjs +63 -65
  13. package/dist/components/index.js +63 -65
  14. package/dist/providers/index.cjs +63 -65
  15. package/dist/providers/index.js +63 -65
  16. package/dist/runtime/index.cjs +63 -65
  17. package/dist/runtime/index.js +63 -65
  18. package/package.json +1 -1
  19. package/dist/components/game/2d/organisms/StateJsonView.d.ts +0 -17
  20. package/dist/components/game/2d/organisms/VariablePanel.d.ts +0 -22
  21. /package/dist/components/game/2d/{organisms → molecules}/ActionPalette.d.ts +0 -0
  22. /package/dist/components/game/2d/{organisms → molecules}/ActionTile.d.ts +0 -0
  23. /package/dist/components/game/2d/{organisms → molecules}/EventLog.d.ts +0 -0
  24. /package/dist/components/game/2d/{organisms → molecules}/RuleEditor.d.ts +0 -0
  25. /package/dist/components/game/2d/{organisms → molecules}/StateNode.d.ts +0 -0
  26. /package/dist/components/game/2d/{organisms → molecules}/TransitionArrow.d.ts +0 -0
@@ -9437,7 +9437,7 @@ function StateNode({
9437
9437
  );
9438
9438
  }
9439
9439
  var init_StateNode = __esm({
9440
- "components/game/2d/organisms/StateNode.tsx"() {
9440
+ "components/game/2d/molecules/StateNode.tsx"() {
9441
9441
  init_atoms();
9442
9442
  init_cn();
9443
9443
  StateNode.displayName = "StateNode";
@@ -9509,7 +9509,7 @@ function TransitionArrow({
9509
9509
  }
9510
9510
  var NODE_RADIUS;
9511
9511
  var init_TransitionArrow = __esm({
9512
- "components/game/2d/organisms/TransitionArrow.tsx"() {
9512
+ "components/game/2d/molecules/TransitionArrow.tsx"() {
9513
9513
  init_cn();
9514
9514
  NODE_RADIUS = 40;
9515
9515
  TransitionArrow.displayName = "TransitionArrow";
@@ -11393,7 +11393,7 @@ function TraitStateViewer({
11393
11393
  }
11394
11394
  var SIZE_CONFIG;
11395
11395
  var init_TraitStateViewer = __esm({
11396
- "components/game/2d/organisms/TraitStateViewer.tsx"() {
11396
+ "components/game/2d/molecules/TraitStateViewer.tsx"() {
11397
11397
  "use client";
11398
11398
  init_cn();
11399
11399
  init_Box();
@@ -11426,7 +11426,8 @@ function TraitSlot({
11426
11426
  onClick,
11427
11427
  onRemove,
11428
11428
  clickEvent,
11429
- removeEvent
11429
+ removeEvent,
11430
+ dropEvent
11430
11431
  }) {
11431
11432
  const { emit } = useEventBus();
11432
11433
  const [isHovered, setIsHovered] = useState(false);
@@ -11458,29 +11459,30 @@ function TraitSlot({
11458
11459
  onDragStart?.(equippedItem);
11459
11460
  }, [equippedItem, draggable, onDragStart]);
11460
11461
  const handleDragOver = useCallback((e) => {
11461
- if (locked || !onItemDrop) return;
11462
+ if (locked || !onItemDrop && !dropEvent) return;
11462
11463
  if (e.dataTransfer.types.includes(DRAG_MIME)) {
11463
11464
  e.preventDefault();
11464
11465
  const allowed = e.dataTransfer.effectAllowed;
11465
11466
  e.dataTransfer.dropEffect = allowed === "copy" ? "copy" : "move";
11466
11467
  setIsDragOver(true);
11467
11468
  }
11468
- }, [locked, onItemDrop]);
11469
+ }, [locked, onItemDrop, dropEvent]);
11469
11470
  const handleDragLeave = useCallback(() => {
11470
11471
  setIsDragOver(false);
11471
11472
  }, []);
11472
11473
  const handleDrop = useCallback((e) => {
11473
11474
  e.preventDefault();
11474
11475
  setIsDragOver(false);
11475
- if (locked || !onItemDrop) return;
11476
+ if (locked || !onItemDrop && !dropEvent) return;
11476
11477
  const raw = e.dataTransfer.getData(DRAG_MIME);
11477
11478
  if (!raw) return;
11478
11479
  try {
11479
11480
  const item = JSON.parse(raw);
11480
- onItemDrop(item);
11481
+ if (dropEvent) emit(`UI:${dropEvent}`, { slotNumber, itemId: item.id });
11482
+ else onItemDrop?.(item);
11481
11483
  } catch {
11482
11484
  }
11483
- }, [locked, onItemDrop]);
11485
+ }, [locked, onItemDrop, dropEvent, emit, slotNumber]);
11484
11486
  const getTooltipStyle = () => {
11485
11487
  if (!slotRef.current) return {};
11486
11488
  const rect = slotRef.current.getBoundingClientRect();
@@ -11600,7 +11602,7 @@ function TraitSlot({
11600
11602
  }
11601
11603
  var SIZE_CONFIG2, DRAG_MIME;
11602
11604
  var init_TraitSlot = __esm({
11603
- "components/game/2d/organisms/TraitSlot.tsx"() {
11605
+ "components/game/2d/molecules/TraitSlot.tsx"() {
11604
11606
  "use client";
11605
11607
  init_cn();
11606
11608
  init_useEventBus();
@@ -11659,7 +11661,7 @@ function ActionTile({
11659
11661
  }
11660
11662
  var DRAG_MIME2, SIZE_CONFIG3;
11661
11663
  var init_ActionTile = __esm({
11662
- "components/game/2d/organisms/ActionTile.tsx"() {
11664
+ "components/game/2d/molecules/ActionTile.tsx"() {
11663
11665
  init_atoms();
11664
11666
  init_cn();
11665
11667
  DRAG_MIME2 = "application/x-almadar-slot-item";
@@ -11696,7 +11698,7 @@ function ActionPalette({
11696
11698
  ] });
11697
11699
  }
11698
11700
  var init_ActionPalette = __esm({
11699
- "components/game/2d/organisms/ActionPalette.tsx"() {
11701
+ "components/game/2d/molecules/ActionPalette.tsx"() {
11700
11702
  init_atoms();
11701
11703
  init_cn();
11702
11704
  init_ActionTile();
@@ -12072,7 +12074,7 @@ function RuleEditor({
12072
12074
  ] });
12073
12075
  }
12074
12076
  var init_RuleEditor = __esm({
12075
- "components/game/2d/organisms/RuleEditor.tsx"() {
12077
+ "components/game/2d/molecules/RuleEditor.tsx"() {
12076
12078
  init_atoms();
12077
12079
  init_cn();
12078
12080
  RuleEditor.displayName = "RuleEditor";
@@ -12113,7 +12115,7 @@ function EventLog({
12113
12115
  }
12114
12116
  var STATUS_STYLES, STATUS_DOTS;
12115
12117
  var init_EventLog = __esm({
12116
- "components/game/2d/organisms/EventLog.tsx"() {
12118
+ "components/game/2d/molecules/EventLog.tsx"() {
12117
12119
  init_atoms();
12118
12120
  init_cn();
12119
12121
  STATUS_STYLES = {
@@ -12168,10 +12170,12 @@ var init_puzzleObject = __esm({
12168
12170
  function ObjectRulePanel({
12169
12171
  object,
12170
12172
  onRulesChange,
12173
+ rulesChangeEvent,
12171
12174
  disabled = false,
12172
12175
  className
12173
12176
  }) {
12174
12177
  const { t } = useTranslate();
12178
+ const { emit } = useEventBus();
12175
12179
  const id = objId(object);
12176
12180
  const name = objName(object);
12177
12181
  const icon = objIcon(object);
@@ -12182,15 +12186,19 @@ function ObjectRulePanel({
12182
12186
  const rules = objRules(object);
12183
12187
  const maxRules = objMaxRules(object);
12184
12188
  const canAdd = rules.length < maxRules;
12189
+ const emitRules = useCallback((newRules) => {
12190
+ if (rulesChangeEvent) emit(`UI:${rulesChangeEvent}`, { objectId: id, rules: newRules });
12191
+ else onRulesChange?.(id, newRules);
12192
+ }, [rulesChangeEvent, emit, id, onRulesChange]);
12185
12193
  const handleRuleChange = useCallback((index, updatedRule) => {
12186
12194
  const newRules = [...rules];
12187
12195
  newRules[index] = updatedRule;
12188
- onRulesChange(id, newRules);
12189
- }, [id, rules, onRulesChange]);
12196
+ emitRules(newRules);
12197
+ }, [rules, emitRules]);
12190
12198
  const handleRuleRemove = useCallback((index) => {
12191
12199
  const newRules = rules.filter((_, i) => i !== index);
12192
- onRulesChange(id, newRules);
12193
- }, [id, rules, onRulesChange]);
12200
+ emitRules(newRules);
12201
+ }, [rules, emitRules]);
12194
12202
  const handleAddRule = useCallback(() => {
12195
12203
  if (!canAdd || disabled) return;
12196
12204
  const firstEvent = availableEvents[0]?.value || "";
@@ -12200,8 +12208,8 @@ function ObjectRulePanel({
12200
12208
  whenEvent: firstEvent,
12201
12209
  thenAction: firstAction
12202
12210
  };
12203
- onRulesChange(id, [...rules, newRule]);
12204
- }, [canAdd, disabled, id, rules, availableEvents, availableActions, onRulesChange]);
12211
+ emitRules([...rules, newRule]);
12212
+ }, [canAdd, disabled, rules, availableEvents, availableActions, emitRules]);
12205
12213
  const machine = {
12206
12214
  name,
12207
12215
  states,
@@ -12241,9 +12249,10 @@ function ObjectRulePanel({
12241
12249
  }
12242
12250
  var nextRuleId;
12243
12251
  var init_ObjectRulePanel = __esm({
12244
- "components/game/2d/organisms/ObjectRulePanel.tsx"() {
12252
+ "components/game/2d/molecules/ObjectRulePanel.tsx"() {
12245
12253
  init_atoms();
12246
12254
  init_cn();
12255
+ init_useEventBus();
12247
12256
  init_TraitStateViewer();
12248
12257
  init_RuleEditor();
12249
12258
  init_puzzleObject();
@@ -12473,61 +12482,35 @@ function VariablePanel({
12473
12482
  const { t } = useTranslate();
12474
12483
  return /* @__PURE__ */ jsxs(VStack, { className: cn("p-3 rounded-lg bg-card border border-border", className), gap: "sm", children: [
12475
12484
  /* @__PURE__ */ jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.variables", { name: entityName }) }),
12476
- variables.map((v) => {
12477
- const name = v.name == null ? "" : String(v.name);
12478
- const value = numField(v.value);
12479
- const max = numField(v.max, 100);
12480
- const min = numField(v.min, 0);
12481
- const unit = v.unit == null ? "" : String(v.unit);
12482
- const pct = Math.round((value - min) / (max - min) * 100);
12483
- const isHigh = pct > 80;
12484
- const isLow = pct < 20;
12485
- return /* @__PURE__ */ jsxs(VStack, { gap: "none", children: [
12486
- /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
12487
- /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: name }),
12488
- /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: cn(
12489
- isHigh ? "text-error" : isLow ? "text-warning" : "text-foreground"
12490
- ), children: [
12491
- value,
12492
- unit,
12493
- " / ",
12494
- max,
12495
- unit
12496
- ] })
12497
- ] }),
12498
- /* @__PURE__ */ jsx(
12499
- ProgressBar,
12500
- {
12501
- value: pct,
12502
- color: isHigh ? "danger" : isLow ? "warning" : "primary",
12503
- size: "sm"
12504
- }
12505
- )
12506
- ] }, name);
12507
- })
12485
+ (variables ?? []).map((v) => /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between", children: [
12486
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: v.name }),
12487
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-accent font-mono", children: v.value })
12488
+ ] }, v.name))
12508
12489
  ] });
12509
12490
  }
12510
- var numField;
12511
12491
  var init_VariablePanel = __esm({
12512
- "components/game/2d/organisms/VariablePanel.tsx"() {
12492
+ "components/game/2d/molecules/VariablePanel.tsx"() {
12513
12493
  init_atoms();
12514
12494
  init_cn();
12515
- numField = (v, fallback = 0) => {
12516
- const n = Number(v);
12517
- return Number.isFinite(n) ? n : fallback;
12518
- };
12519
12495
  VariablePanel.displayName = "VariablePanel";
12520
12496
  }
12521
12497
  });
12522
12498
  function StateJsonView({
12523
- data,
12499
+ name,
12500
+ initialState,
12501
+ states,
12502
+ transitions,
12524
12503
  label,
12525
12504
  defaultExpanded = false,
12526
12505
  className
12527
12506
  }) {
12528
12507
  const { t } = useTranslate();
12529
12508
  const [expanded, setExpanded] = useState(defaultExpanded);
12530
- const jsonString = JSON.stringify(data, null, 2);
12509
+ const jsonString = JSON.stringify(
12510
+ { name, initialState, states: states ?? [], transitions: transitions ?? [] },
12511
+ null,
12512
+ 2
12513
+ );
12531
12514
  return /* @__PURE__ */ jsxs(VStack, { className: cn("rounded-lg border border-border overflow-hidden", className), gap: "none", children: [
12532
12515
  /* @__PURE__ */ jsxs(HStack, { className: "items-center justify-between p-2 bg-muted", gap: "sm", children: [
12533
12516
  /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: label ?? t("stateArchitect.viewCode") }),
@@ -12544,7 +12527,7 @@ function StateJsonView({
12544
12527
  ] });
12545
12528
  }
12546
12529
  var init_StateJsonView = __esm({
12547
- "components/game/2d/organisms/StateJsonView.tsx"() {
12530
+ "components/game/2d/molecules/StateJsonView.tsx"() {
12548
12531
  init_atoms();
12549
12532
  init_cn();
12550
12533
  StateJsonView.displayName = "StateJsonView";
@@ -12713,7 +12696,7 @@ function StateArchitectBoard({
12713
12696
  setAddingFrom(null);
12714
12697
  if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
12715
12698
  }, [initialState, entityVariables, playAgainEvent, emit]);
12716
- const codeData = useMemo(() => ({
12699
+ useMemo(() => ({
12717
12700
  name: entityName,
12718
12701
  states: entityStates,
12719
12702
  initialState,
@@ -12848,7 +12831,7 @@ function StateArchitectBoard({
12848
12831
  VariablePanel,
12849
12832
  {
12850
12833
  entityName,
12851
- variables
12834
+ variables: variables.map((v) => ({ name: String(v.name ?? ""), value: String(v.value ?? "") }))
12852
12835
  }
12853
12836
  ),
12854
12837
  testResults.length > 0 && /* @__PURE__ */ jsxs(VStack, { className: "p-3 rounded-container bg-card border border-border", gap: "xs", children: [
@@ -12859,7 +12842,16 @@ function StateArchitectBoard({
12859
12842
  !r.passed && /* @__PURE__ */ jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r.actualState }) })
12860
12843
  ] }, i))
12861
12844
  ] }),
12862
- resolved.showCodeView !== false && /* @__PURE__ */ jsx(StateJsonView, { data: codeData, label: "View Code" })
12845
+ resolved.showCodeView !== false && /* @__PURE__ */ jsx(
12846
+ StateJsonView,
12847
+ {
12848
+ name: entityName,
12849
+ initialState,
12850
+ states: entityStates,
12851
+ transitions: transitions.map((tr) => ({ from: tr.from, to: tr.to, event: tr.event })),
12852
+ label: "View Code"
12853
+ }
12854
+ )
12863
12855
  ] })
12864
12856
  ] }),
12865
12857
  isSuccess && /* @__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: str(resolved.successMessage) || t("stateArchitect.allPassed") }) }),
@@ -46197,6 +46189,7 @@ var init_component_registry_generated = __esm({
46197
46189
  init_Navigation();
46198
46190
  init_NegotiatorBoard();
46199
46191
  init_NumberStepper();
46192
+ init_ObjectRulePanel();
46200
46193
  init_OptionConstraintGroup();
46201
46194
  init_OrbitalVisualization();
46202
46195
  init_Overlay();
@@ -46260,6 +46253,7 @@ var init_component_registry_generated = __esm({
46260
46253
  init_StateArchitectBoard();
46261
46254
  init_StateGraph();
46262
46255
  init_StateIndicator();
46256
+ init_StateJsonView();
46263
46257
  init_StateMachineView();
46264
46258
  init_StatsGrid();
46265
46259
  init_StatsOrganism();
@@ -46306,6 +46300,7 @@ var init_component_registry_generated = __esm({
46306
46300
  init_Typography();
46307
46301
  init_UISlotRenderer();
46308
46302
  init_UploadDropZone();
46303
+ init_VariablePanel();
46309
46304
  init_VersionDiff();
46310
46305
  init_ViolationAlert();
46311
46306
  init_VoteStack();
@@ -46506,6 +46501,7 @@ var init_component_registry_generated = __esm({
46506
46501
  "Navigation": Navigation,
46507
46502
  "NegotiatorBoard": NegotiatorBoard,
46508
46503
  "NumberStepper": NumberStepper,
46504
+ "ObjectRulePanel": ObjectRulePanel,
46509
46505
  "OptionConstraintGroup": OptionConstraintGroup,
46510
46506
  "OrbitalVisualization": OrbitalVisualization,
46511
46507
  "Overlay": Overlay,
@@ -46572,6 +46568,7 @@ var init_component_registry_generated = __esm({
46572
46568
  "StateArchitectBoard": StateArchitectBoard,
46573
46569
  "StateGraph": StateGraph,
46574
46570
  "StateIndicator": StateIndicator,
46571
+ "StateJsonView": StateJsonView,
46575
46572
  "StateMachineView": StateMachineView,
46576
46573
  "StatsGrid": StatsGrid,
46577
46574
  "StatsOrganism": StatsOrganism,
@@ -46619,6 +46616,7 @@ var init_component_registry_generated = __esm({
46619
46616
  "UISlotRenderer": UISlotRenderer,
46620
46617
  "UploadDropZone": UploadDropZone,
46621
46618
  "VStack": VStack,
46619
+ "VariablePanel": VariablePanel,
46622
46620
  "VersionDiff": VersionDiff,
46623
46621
  "ViolationAlert": ViolationAlert,
46624
46622
  "VoteStack": VoteStack,
@@ -10008,7 +10008,7 @@ function StateNode({
10008
10008
  );
10009
10009
  }
10010
10010
  var init_StateNode = __esm({
10011
- "components/game/2d/organisms/StateNode.tsx"() {
10011
+ "components/game/2d/molecules/StateNode.tsx"() {
10012
10012
  init_atoms();
10013
10013
  init_cn();
10014
10014
  StateNode.displayName = "StateNode";
@@ -10080,7 +10080,7 @@ function TransitionArrow({
10080
10080
  }
10081
10081
  var NODE_RADIUS;
10082
10082
  var init_TransitionArrow = __esm({
10083
- "components/game/2d/organisms/TransitionArrow.tsx"() {
10083
+ "components/game/2d/molecules/TransitionArrow.tsx"() {
10084
10084
  init_cn();
10085
10085
  NODE_RADIUS = 40;
10086
10086
  TransitionArrow.displayName = "TransitionArrow";
@@ -11785,7 +11785,7 @@ function TraitStateViewer({
11785
11785
  }
11786
11786
  var SIZE_CONFIG;
11787
11787
  var init_TraitStateViewer = __esm({
11788
- "components/game/2d/organisms/TraitStateViewer.tsx"() {
11788
+ "components/game/2d/molecules/TraitStateViewer.tsx"() {
11789
11789
  "use client";
11790
11790
  init_cn();
11791
11791
  init_Box();
@@ -11818,7 +11818,8 @@ function TraitSlot({
11818
11818
  onClick,
11819
11819
  onRemove,
11820
11820
  clickEvent,
11821
- removeEvent
11821
+ removeEvent,
11822
+ dropEvent
11822
11823
  }) {
11823
11824
  const { emit } = useEventBus();
11824
11825
  const [isHovered, setIsHovered] = React96.useState(false);
@@ -11850,29 +11851,30 @@ function TraitSlot({
11850
11851
  onDragStart?.(equippedItem);
11851
11852
  }, [equippedItem, draggable, onDragStart]);
11852
11853
  const handleDragOver = React96.useCallback((e) => {
11853
- if (locked || !onItemDrop) return;
11854
+ if (locked || !onItemDrop && !dropEvent) return;
11854
11855
  if (e.dataTransfer.types.includes(DRAG_MIME)) {
11855
11856
  e.preventDefault();
11856
11857
  const allowed = e.dataTransfer.effectAllowed;
11857
11858
  e.dataTransfer.dropEffect = allowed === "copy" ? "copy" : "move";
11858
11859
  setIsDragOver(true);
11859
11860
  }
11860
- }, [locked, onItemDrop]);
11861
+ }, [locked, onItemDrop, dropEvent]);
11861
11862
  const handleDragLeave = React96.useCallback(() => {
11862
11863
  setIsDragOver(false);
11863
11864
  }, []);
11864
11865
  const handleDrop = React96.useCallback((e) => {
11865
11866
  e.preventDefault();
11866
11867
  setIsDragOver(false);
11867
- if (locked || !onItemDrop) return;
11868
+ if (locked || !onItemDrop && !dropEvent) return;
11868
11869
  const raw = e.dataTransfer.getData(DRAG_MIME);
11869
11870
  if (!raw) return;
11870
11871
  try {
11871
11872
  const item = JSON.parse(raw);
11872
- onItemDrop(item);
11873
+ if (dropEvent) emit(`UI:${dropEvent}`, { slotNumber, itemId: item.id });
11874
+ else onItemDrop?.(item);
11873
11875
  } catch {
11874
11876
  }
11875
- }, [locked, onItemDrop]);
11877
+ }, [locked, onItemDrop, dropEvent, emit, slotNumber]);
11876
11878
  const getTooltipStyle = () => {
11877
11879
  if (!slotRef.current) return {};
11878
11880
  const rect = slotRef.current.getBoundingClientRect();
@@ -11992,7 +11994,7 @@ function TraitSlot({
11992
11994
  }
11993
11995
  var SIZE_CONFIG2, DRAG_MIME;
11994
11996
  var init_TraitSlot = __esm({
11995
- "components/game/2d/organisms/TraitSlot.tsx"() {
11997
+ "components/game/2d/molecules/TraitSlot.tsx"() {
11996
11998
  "use client";
11997
11999
  init_cn();
11998
12000
  init_useEventBus();
@@ -12051,7 +12053,7 @@ function ActionTile({
12051
12053
  }
12052
12054
  var DRAG_MIME2, SIZE_CONFIG3;
12053
12055
  var init_ActionTile = __esm({
12054
- "components/game/2d/organisms/ActionTile.tsx"() {
12056
+ "components/game/2d/molecules/ActionTile.tsx"() {
12055
12057
  init_atoms();
12056
12058
  init_cn();
12057
12059
  DRAG_MIME2 = "application/x-almadar-slot-item";
@@ -12088,7 +12090,7 @@ function ActionPalette({
12088
12090
  ] });
12089
12091
  }
12090
12092
  var init_ActionPalette = __esm({
12091
- "components/game/2d/organisms/ActionPalette.tsx"() {
12093
+ "components/game/2d/molecules/ActionPalette.tsx"() {
12092
12094
  init_atoms();
12093
12095
  init_cn();
12094
12096
  init_ActionTile();
@@ -12464,7 +12466,7 @@ function RuleEditor({
12464
12466
  ] });
12465
12467
  }
12466
12468
  var init_RuleEditor = __esm({
12467
- "components/game/2d/organisms/RuleEditor.tsx"() {
12469
+ "components/game/2d/molecules/RuleEditor.tsx"() {
12468
12470
  init_atoms();
12469
12471
  init_cn();
12470
12472
  RuleEditor.displayName = "RuleEditor";
@@ -12505,7 +12507,7 @@ function EventLog({
12505
12507
  }
12506
12508
  var STATUS_STYLES, STATUS_DOTS;
12507
12509
  var init_EventLog = __esm({
12508
- "components/game/2d/organisms/EventLog.tsx"() {
12510
+ "components/game/2d/molecules/EventLog.tsx"() {
12509
12511
  init_atoms();
12510
12512
  init_cn();
12511
12513
  STATUS_STYLES = {
@@ -12560,10 +12562,12 @@ var init_puzzleObject = __esm({
12560
12562
  function ObjectRulePanel({
12561
12563
  object,
12562
12564
  onRulesChange,
12565
+ rulesChangeEvent,
12563
12566
  disabled = false,
12564
12567
  className
12565
12568
  }) {
12566
12569
  const { t } = hooks.useTranslate();
12570
+ const { emit } = useEventBus();
12567
12571
  const id = objId(object);
12568
12572
  const name = objName(object);
12569
12573
  const icon = objIcon(object);
@@ -12574,15 +12578,19 @@ function ObjectRulePanel({
12574
12578
  const rules = objRules(object);
12575
12579
  const maxRules = objMaxRules(object);
12576
12580
  const canAdd = rules.length < maxRules;
12581
+ const emitRules = React96.useCallback((newRules) => {
12582
+ if (rulesChangeEvent) emit(`UI:${rulesChangeEvent}`, { objectId: id, rules: newRules });
12583
+ else onRulesChange?.(id, newRules);
12584
+ }, [rulesChangeEvent, emit, id, onRulesChange]);
12577
12585
  const handleRuleChange = React96.useCallback((index, updatedRule) => {
12578
12586
  const newRules = [...rules];
12579
12587
  newRules[index] = updatedRule;
12580
- onRulesChange(id, newRules);
12581
- }, [id, rules, onRulesChange]);
12588
+ emitRules(newRules);
12589
+ }, [rules, emitRules]);
12582
12590
  const handleRuleRemove = React96.useCallback((index) => {
12583
12591
  const newRules = rules.filter((_, i) => i !== index);
12584
- onRulesChange(id, newRules);
12585
- }, [id, rules, onRulesChange]);
12592
+ emitRules(newRules);
12593
+ }, [rules, emitRules]);
12586
12594
  const handleAddRule = React96.useCallback(() => {
12587
12595
  if (!canAdd || disabled) return;
12588
12596
  const firstEvent = availableEvents[0]?.value || "";
@@ -12592,8 +12600,8 @@ function ObjectRulePanel({
12592
12600
  whenEvent: firstEvent,
12593
12601
  thenAction: firstAction
12594
12602
  };
12595
- onRulesChange(id, [...rules, newRule]);
12596
- }, [canAdd, disabled, id, rules, availableEvents, availableActions, onRulesChange]);
12603
+ emitRules([...rules, newRule]);
12604
+ }, [canAdd, disabled, rules, availableEvents, availableActions, emitRules]);
12597
12605
  const machine = {
12598
12606
  name,
12599
12607
  states,
@@ -12633,9 +12641,10 @@ function ObjectRulePanel({
12633
12641
  }
12634
12642
  var nextRuleId;
12635
12643
  var init_ObjectRulePanel = __esm({
12636
- "components/game/2d/organisms/ObjectRulePanel.tsx"() {
12644
+ "components/game/2d/molecules/ObjectRulePanel.tsx"() {
12637
12645
  init_atoms();
12638
12646
  init_cn();
12647
+ init_useEventBus();
12639
12648
  init_TraitStateViewer();
12640
12649
  init_RuleEditor();
12641
12650
  init_puzzleObject();
@@ -12865,61 +12874,35 @@ function VariablePanel({
12865
12874
  const { t } = hooks.useTranslate();
12866
12875
  return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { className: cn("p-3 rounded-lg bg-card border border-border", className), gap: "sm", children: [
12867
12876
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body2", className: "text-muted-foreground font-medium", children: t("stateArchitect.variables", { name: entityName }) }),
12868
- variables.map((v) => {
12869
- const name = v.name == null ? "" : String(v.name);
12870
- const value = numField(v.value);
12871
- const max = numField(v.max, 100);
12872
- const min = numField(v.min, 0);
12873
- const unit = v.unit == null ? "" : String(v.unit);
12874
- const pct = Math.round((value - min) / (max - min) * 100);
12875
- const isHigh = pct > 80;
12876
- const isLow = pct < 20;
12877
- return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "none", children: [
12878
- /* @__PURE__ */ jsxRuntime.jsxs(HStack, { className: "items-center justify-between", children: [
12879
- /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: name }),
12880
- /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "caption", className: cn(
12881
- isHigh ? "text-error" : isLow ? "text-warning" : "text-foreground"
12882
- ), children: [
12883
- value,
12884
- unit,
12885
- " / ",
12886
- max,
12887
- unit
12888
- ] })
12889
- ] }),
12890
- /* @__PURE__ */ jsxRuntime.jsx(
12891
- ProgressBar,
12892
- {
12893
- value: pct,
12894
- color: isHigh ? "danger" : isLow ? "warning" : "primary",
12895
- size: "sm"
12896
- }
12897
- )
12898
- ] }, name);
12899
- })
12877
+ (variables ?? []).map((v) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { className: "items-center justify-between", children: [
12878
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-foreground font-medium", children: v.name }),
12879
+ /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-accent font-mono", children: v.value })
12880
+ ] }, v.name))
12900
12881
  ] });
12901
12882
  }
12902
- var numField;
12903
12883
  var init_VariablePanel = __esm({
12904
- "components/game/2d/organisms/VariablePanel.tsx"() {
12884
+ "components/game/2d/molecules/VariablePanel.tsx"() {
12905
12885
  init_atoms();
12906
12886
  init_cn();
12907
- numField = (v, fallback = 0) => {
12908
- const n = Number(v);
12909
- return Number.isFinite(n) ? n : fallback;
12910
- };
12911
12887
  VariablePanel.displayName = "VariablePanel";
12912
12888
  }
12913
12889
  });
12914
12890
  function StateJsonView({
12915
- data,
12891
+ name,
12892
+ initialState,
12893
+ states,
12894
+ transitions,
12916
12895
  label,
12917
12896
  defaultExpanded = false,
12918
12897
  className
12919
12898
  }) {
12920
12899
  const { t } = hooks.useTranslate();
12921
12900
  const [expanded, setExpanded] = React96.useState(defaultExpanded);
12922
- const jsonString = JSON.stringify(data, null, 2);
12901
+ const jsonString = JSON.stringify(
12902
+ { name, initialState, states: states ?? [], transitions: transitions ?? [] },
12903
+ null,
12904
+ 2
12905
+ );
12923
12906
  return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { className: cn("rounded-lg border border-border overflow-hidden", className), gap: "none", children: [
12924
12907
  /* @__PURE__ */ jsxRuntime.jsxs(HStack, { className: "items-center justify-between p-2 bg-muted", gap: "sm", children: [
12925
12908
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-muted-foreground font-medium", children: label ?? t("stateArchitect.viewCode") }),
@@ -12936,7 +12919,7 @@ function StateJsonView({
12936
12919
  ] });
12937
12920
  }
12938
12921
  var init_StateJsonView = __esm({
12939
- "components/game/2d/organisms/StateJsonView.tsx"() {
12922
+ "components/game/2d/molecules/StateJsonView.tsx"() {
12940
12923
  init_atoms();
12941
12924
  init_cn();
12942
12925
  StateJsonView.displayName = "StateJsonView";
@@ -13105,7 +13088,7 @@ function StateArchitectBoard({
13105
13088
  setAddingFrom(null);
13106
13089
  if (playAgainEvent) emit(`UI:${playAgainEvent}`, {});
13107
13090
  }, [initialState, entityVariables, playAgainEvent, emit]);
13108
- const codeData = React96.useMemo(() => ({
13091
+ React96.useMemo(() => ({
13109
13092
  name: entityName,
13110
13093
  states: entityStates,
13111
13094
  initialState,
@@ -13240,7 +13223,7 @@ function StateArchitectBoard({
13240
13223
  VariablePanel,
13241
13224
  {
13242
13225
  entityName,
13243
- variables
13226
+ variables: variables.map((v) => ({ name: String(v.name ?? ""), value: String(v.value ?? "") }))
13244
13227
  }
13245
13228
  ),
13246
13229
  testResults.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(VStack, { className: "p-3 rounded-container bg-card border border-border", gap: "xs", children: [
@@ -13251,7 +13234,16 @@ function StateArchitectBoard({
13251
13234
  !r.passed && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "caption", className: "text-error", children: t("stateArchitect.gotState", { state: r.actualState }) })
13252
13235
  ] }, i))
13253
13236
  ] }),
13254
- resolved.showCodeView !== false && /* @__PURE__ */ jsxRuntime.jsx(StateJsonView, { data: codeData, label: "View Code" })
13237
+ resolved.showCodeView !== false && /* @__PURE__ */ jsxRuntime.jsx(
13238
+ StateJsonView,
13239
+ {
13240
+ name: entityName,
13241
+ initialState,
13242
+ states: entityStates,
13243
+ transitions: transitions.map((tr) => ({ from: tr.from, to: tr.to, event: tr.event })),
13244
+ label: "View Code"
13245
+ }
13246
+ )
13255
13247
  ] })
13256
13248
  ] }),
13257
13249
  isSuccess && /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "p-4 rounded-container bg-success/20 border border-success text-center", children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h5", className: "text-success", children: str(resolved.successMessage) || t("stateArchitect.allPassed") }) }),
@@ -45892,6 +45884,7 @@ var init_component_registry_generated = __esm({
45892
45884
  init_Navigation();
45893
45885
  init_NegotiatorBoard();
45894
45886
  init_NumberStepper();
45887
+ init_ObjectRulePanel();
45895
45888
  init_OptionConstraintGroup();
45896
45889
  init_OrbitalVisualization();
45897
45890
  init_Overlay();
@@ -45955,6 +45948,7 @@ var init_component_registry_generated = __esm({
45955
45948
  init_StateArchitectBoard();
45956
45949
  init_StateGraph();
45957
45950
  init_StateIndicator();
45951
+ init_StateJsonView();
45958
45952
  init_StateMachineView();
45959
45953
  init_StatsGrid();
45960
45954
  init_StatsOrganism();
@@ -46001,6 +45995,7 @@ var init_component_registry_generated = __esm({
46001
45995
  init_Typography();
46002
45996
  init_UISlotRenderer();
46003
45997
  init_UploadDropZone();
45998
+ init_VariablePanel();
46004
45999
  init_VersionDiff();
46005
46000
  init_ViolationAlert();
46006
46001
  init_VoteStack();
@@ -46201,6 +46196,7 @@ var init_component_registry_generated = __esm({
46201
46196
  "Navigation": Navigation,
46202
46197
  "NegotiatorBoard": NegotiatorBoard,
46203
46198
  "NumberStepper": NumberStepper,
46199
+ "ObjectRulePanel": ObjectRulePanel,
46204
46200
  "OptionConstraintGroup": OptionConstraintGroup,
46205
46201
  "OrbitalVisualization": OrbitalVisualization,
46206
46202
  "Overlay": Overlay,
@@ -46267,6 +46263,7 @@ var init_component_registry_generated = __esm({
46267
46263
  "StateArchitectBoard": StateArchitectBoard,
46268
46264
  "StateGraph": StateGraph,
46269
46265
  "StateIndicator": StateIndicator,
46266
+ "StateJsonView": StateJsonView,
46270
46267
  "StateMachineView": StateMachineView,
46271
46268
  "StatsGrid": StatsGrid,
46272
46269
  "StatsOrganism": StatsOrganism,
@@ -46314,6 +46311,7 @@ var init_component_registry_generated = __esm({
46314
46311
  "UISlotRenderer": UISlotRenderer,
46315
46312
  "UploadDropZone": UploadDropZone,
46316
46313
  "VStack": VStack,
46314
+ "VariablePanel": VariablePanel,
46317
46315
  "VersionDiff": VersionDiff,
46318
46316
  "ViolationAlert": ViolationAlert,
46319
46317
  "VoteStack": VoteStack,