@almadar/shell-web 0.0.0-stage → 1.0.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.
- package/bundling.d.mts +18 -0
- package/bundling.mjs +28 -0
- package/dist/ArbitraryClassCompiler-CO_iASBn.d.ts +195 -0
- package/dist/AvlGlyph-EPJKFEO3.js +6 -0
- package/dist/AvlStateMachine-RKZIKNGC.js +9 -0
- package/dist/AvlTransitionDetail-63SD6GZF.js +11 -0
- package/dist/AvlTransitionExplainer-ZBTLOM3T.js +12 -0
- package/dist/BehaviorView-YS5G4GNB.js +11 -0
- package/dist/Canvas3DHost-BkZQB5l2.d.ts +552 -0
- package/dist/EventBusProvider-BFFHfN4O.d.ts +296 -0
- package/dist/FileTree-BCFnBEuQ.d.ts +254 -0
- package/dist/FlowCanvas-3JRMNJLV.css +1756 -0
- package/dist/FlowCanvas-AUMTWMNG.js +26 -0
- package/dist/GameAudioProvider-ceM_n0ey.d.ts +90 -0
- package/dist/KaTeX_AMS-Regular-CYEKBG2K.woff +0 -0
- package/dist/KaTeX_AMS-Regular-JKX5W2C4.ttf +0 -0
- package/dist/KaTeX_AMS-Regular-U6PRYMIZ.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-5QL5CMTE.woff2 +0 -0
- package/dist/KaTeX_Caligraphic-Bold-WZ3QSGD3.woff +0 -0
- package/dist/KaTeX_Caligraphic-Bold-ZTS3R3HK.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-3LKEU76G.woff +0 -0
- package/dist/KaTeX_Caligraphic-Regular-A7XRTZ5Q.ttf +0 -0
- package/dist/KaTeX_Caligraphic-Regular-KX5MEWCF.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-2QVFK6NQ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Bold-T4SWXBMT.woff +0 -0
- package/dist/KaTeX_Fraktur-Bold-WGHVTYOR.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-2PEIFJSJ.woff2 +0 -0
- package/dist/KaTeX_Fraktur-Regular-5U4OPH2X.ttf +0 -0
- package/dist/KaTeX_Fraktur-Regular-PQMHCIK6.woff +0 -0
- package/dist/KaTeX_Main-Bold-2GA4IZIN.woff +0 -0
- package/dist/KaTeX_Main-Bold-W5FBVCZM.ttf +0 -0
- package/dist/KaTeX_Main-Bold-YP5VVQRP.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-4P4C7HJH.woff +0 -0
- package/dist/KaTeX_Main-BoldItalic-N4V3DX7S.woff2 +0 -0
- package/dist/KaTeX_Main-BoldItalic-ODMLBJJQ.ttf +0 -0
- package/dist/KaTeX_Main-Italic-I43T2HSR.ttf +0 -0
- package/dist/KaTeX_Main-Italic-RELBIK7M.woff2 +0 -0
- package/dist/KaTeX_Main-Italic-SASNQFN2.woff +0 -0
- package/dist/KaTeX_Main-Regular-ARRPAO67.woff2 +0 -0
- package/dist/KaTeX_Main-Regular-P5I74A2A.woff +0 -0
- package/dist/KaTeX_Main-Regular-W74P5G27.ttf +0 -0
- package/dist/KaTeX_Math-BoldItalic-6EBV3DK5.woff +0 -0
- package/dist/KaTeX_Math-BoldItalic-K4WTGH3J.woff2 +0 -0
- package/dist/KaTeX_Math-BoldItalic-VB447A4D.ttf +0 -0
- package/dist/KaTeX_Math-Italic-6KGCHLFN.woff2 +0 -0
- package/dist/KaTeX_Math-Italic-KKK3USB2.woff +0 -0
- package/dist/KaTeX_Math-Italic-SON4MRCA.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-RRNVJFFW.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Bold-STQ6RXC7.ttf +0 -0
- package/dist/KaTeX_SansSerif-Bold-X5M5EMOD.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-HMPFTM52.woff2 +0 -0
- package/dist/KaTeX_SansSerif-Italic-PSN4QKYX.woff +0 -0
- package/dist/KaTeX_SansSerif-Italic-WTBAZBGY.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-2TL3USAE.ttf +0 -0
- package/dist/KaTeX_SansSerif-Regular-OQCII6EP.woff +0 -0
- package/dist/KaTeX_SansSerif-Regular-XIQ62X4E.woff2 +0 -0
- package/dist/KaTeX_Script-Regular-72OLXYNA.ttf +0 -0
- package/dist/KaTeX_Script-Regular-A5IFOEBS.woff +0 -0
- package/dist/KaTeX_Script-Regular-APUWIHLP.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-4HRHTS65.woff +0 -0
- package/dist/KaTeX_Size1-Regular-5LRUTBFT.woff2 +0 -0
- package/dist/KaTeX_Size1-Regular-7K6AASVL.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-222HN3GT.ttf +0 -0
- package/dist/KaTeX_Size2-Regular-K5ZHAIS6.woff +0 -0
- package/dist/KaTeX_Size2-Regular-LELKET5D.woff2 +0 -0
- package/dist/KaTeX_Size3-Regular-TLFPAHDE.woff +0 -0
- package/dist/KaTeX_Size3-Regular-UFCO6WCA.ttf +0 -0
- package/dist/KaTeX_Size3-Regular-WQRQ47UD.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-7PGNVPQK.ttf +0 -0
- package/dist/KaTeX_Size4-Regular-CDMV7U5C.woff2 +0 -0
- package/dist/KaTeX_Size4-Regular-PKMWZHNC.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-3F5K6SQ6.ttf +0 -0
- package/dist/KaTeX_Typewriter-Regular-MJMFSK64.woff +0 -0
- package/dist/KaTeX_Typewriter-Regular-VBYJ4NRC.woff2 +0 -0
- package/dist/KernelEngineContext-CcxGYtlr.d.ts +33 -0
- package/dist/LayersPanel-M2LHWUFF.js +6 -0
- package/dist/ModuleCard-QHDGK5XK.js +7 -0
- package/dist/OrbInspector-MHLJ6OEE.css +1756 -0
- package/dist/OrbInspector-QCPEPUPH.js +26 -0
- package/dist/Select-B-iDdnvE.d.ts +185 -0
- package/dist/ServerBridge-Bqsj-lOU.d.ts +124 -0
- package/dist/ThemeContext-DJmO59xd.d.ts +147 -0
- package/dist/UISlotContext-Dl_ewwCI.d.ts +79 -0
- package/dist/UISlotRenderer-C7WWOK43.js +26 -0
- package/dist/UISlotRenderer-KVFO6J7R.css +1756 -0
- package/dist/auth/browser/index.d.ts +2 -0
- package/dist/auth/browser/index.js +2 -0
- package/dist/auth/react/index.d.ts +56 -0
- package/dist/auth/react/index.js +157 -0
- package/dist/avl/index.css +1756 -0
- package/dist/avl/index.d.ts +2248 -0
- package/dist/avl/index.js +2693 -0
- package/dist/avl-3d-context-BycmO6tG.d.ts +201 -0
- package/dist/avl-schema-parser-CtJxJ9KU.d.ts +132 -0
- package/dist/avl-zoom-state-CKMVuBFg.d.ts +17 -0
- package/dist/chunk-3BBUBJFF.js +339 -0
- package/dist/chunk-3S54FWRC.js +131 -0
- package/dist/chunk-3VZ36ZKO.js +775 -0
- package/dist/chunk-4T3P43NS.js +1133 -0
- package/dist/chunk-4YXBKHHM.js +11488 -0
- package/dist/chunk-57DC34LY.js +525 -0
- package/dist/chunk-5QTYQTPS.js +15 -0
- package/dist/chunk-A2LR6VQQ.js +349 -0
- package/dist/chunk-AB3X7QTE.js +505 -0
- package/dist/chunk-AE7VCQB6.js +561 -0
- package/dist/chunk-AGXD77SL.js +98 -0
- package/dist/chunk-AU7O65OX.js +66 -0
- package/dist/chunk-CPLN6NBQ.js +701 -0
- package/dist/chunk-DZBQA2OW.js +176 -0
- package/dist/chunk-E6KA4J6N.js +227 -0
- package/dist/chunk-EOWMARUB.js +16 -0
- package/dist/chunk-G7DCAZ22.js +19 -0
- package/dist/chunk-GFXCPUMX.js +1334 -0
- package/dist/chunk-HH5KSMH5.js +311 -0
- package/dist/chunk-ILQXJ2AR.js +280 -0
- package/dist/chunk-ILZ7ORX7.js +432 -0
- package/dist/chunk-K4MOPSEL.js +674 -0
- package/dist/chunk-LHP2TK7O.js +47587 -0
- package/dist/chunk-P4ZFUQFF.js +93 -0
- package/dist/chunk-PCR37T3U.js +296 -0
- package/dist/chunk-PRXQGGCO.js +580 -0
- package/dist/chunk-REXYVBUO.js +191 -0
- package/dist/chunk-ROICKAU7.js +24 -0
- package/dist/chunk-SP5CDJ6K.js +338 -0
- package/dist/chunk-TUPZWTRE.js +1051 -0
- package/dist/chunk-TXAUOLWZ.js +490 -0
- package/dist/chunk-TZZBINQY.js +82 -0
- package/dist/chunk-UTDC2NEA.js +14 -0
- package/dist/chunk-UU57VNS2.js +1053 -0
- package/dist/chunk-UXLE3IPR.js +421 -0
- package/dist/chunk-VO2TTLS5.js +94 -0
- package/dist/chunk-X3DMMX27.js +11 -0
- package/dist/chunk-YHMRX6YA.js +455 -0
- package/dist/components/index.css +1756 -0
- package/dist/components/index.d.ts +11299 -0
- package/dist/components/index.js +1110 -0
- package/dist/context/index.d.ts +8 -0
- package/dist/context/index.js +8 -0
- package/dist/core.d.ts +2599 -0
- package/dist/core.js +3 -0
- package/dist/design-classes/index.cjs +431 -0
- package/dist/design-classes/index.d.cts +165 -0
- package/dist/design-classes/index.d.ts +165 -0
- package/dist/design-classes/index.js +399 -0
- package/dist/emojiItems-QGSNAABW.js +20 -0
- package/dist/fx-CmQjnHmT.d.ts +371 -0
- package/dist/hooks/index.d.ts +971 -0
- package/dist/hooks/index.js +8 -0
- package/dist/index.d.ts +408 -0
- package/dist/index.js +178 -0
- package/dist/katexPlugin-FA7NX4PE.css +1161 -0
- package/dist/katexPlugin-NCDKOOQY.js +2 -0
- package/dist/kernel-client-TZKGHJRY.js +516 -0
- package/dist/kernel-wire-wNdAPfhJ.d.ts +88 -0
- package/dist/lib/index.d.ts +602 -0
- package/dist/lib/index.js +1289 -0
- package/dist/paintDispatch-CuJLsr9Y.d.ts +688 -0
- package/dist/parseLessonSegments-GpCeMrb2.d.ts +334 -0
- package/dist/perf-CKiBKbkw.d.ts +22 -0
- package/dist/perf-Dr28-AgT.d.ts +57 -0
- package/dist/prism-X5YWKXO5.js +136 -0
- package/dist/providers/index.css +1756 -0
- package/dist/providers/index.d.ts +355 -0
- package/dist/providers/index.js +29 -0
- package/dist/renderer/index.d.ts +465 -0
- package/dist/renderer/index.js +4 -0
- package/dist/runtime/index.css +1756 -0
- package/dist/runtime/index.d.ts +239 -0
- package/dist/runtime/index.js +28 -0
- package/dist/slot-host-CPzrxLo9.d.ts +48 -0
- package/dist/ssr/index.cjs +9739 -0
- package/dist/ssr/index.d.cts +464 -0
- package/dist/ssr/index.d.ts +464 -0
- package/dist/ssr/index.js +9703 -0
- package/dist/storage/browser/index.d.ts +1 -0
- package/dist/storage/browser/index.js +2 -0
- package/dist/test-support.d.ts +42 -0
- package/dist/test-support.js +181 -0
- package/dist/themeTokens-CRd8AEDF.d.ts +125 -0
- package/dist/three/index.css +503 -0
- package/dist/three/index.d.ts +1185 -0
- package/dist/three/index.js +3908 -0
- package/dist/useUISlots-CiobNFGb.d.ts +211 -0
- package/dist/verification-C5pTeMJv.d.ts +66 -0
- package/dist/verificationRegistry-CVrcxG1s.d.ts +122 -0
- package/dist/wrapCallbackForEvent-B9QLbhxX.d.ts +19 -0
- package/index.css +199 -0
- package/package.json +273 -3
- package/src/core/lib/band-shapes.json +7 -0
- package/src/core/locales/ar.json +1276 -0
- package/src/core/locales/en.json +1276 -0
- package/src/core/locales/index.ts +54 -0
- package/src/core/locales/sl.json +1276 -0
- package/src/core/tokens/native-tokens.json +369 -0
- package/tailwind-compile.cjs +29 -0
- package/tailwind-preset.cjs +1020 -0
- package/themes/_base.css +451 -0
- package/themes/_contract.md +307 -0
- package/themes/_fonts-kenney.css +11 -0
- package/themes/_fonts.css +12 -0
- package/themes/_foundation.css +105 -0
- package/themes/_head.css +22 -0
- package/themes/_presets.css +67 -0
- package/themes/almadar-heritage.css +455 -0
- package/themes/almadar-website.css +269 -0
- package/themes/almadar.css +269 -0
- package/themes/aqua.css +455 -0
- package/themes/arabesque.css +459 -0
- package/themes/art-deco.css +457 -0
- package/themes/art-nouveau.css +459 -0
- package/themes/atelier.css +463 -0
- package/themes/bauhaus.css +461 -0
- package/themes/bloomberg-dense.css +463 -0
- package/themes/blueprint.css +457 -0
- package/themes/clay.css +449 -0
- package/themes/comic.css +453 -0
- package/themes/constructivist.css +457 -0
- package/themes/corporate.css +449 -0
- package/themes/cyberpunk.css +453 -0
- package/themes/frutiger-aero.css +458 -0
- package/themes/game-adventure.css +201 -0
- package/themes/game-rpg.css +203 -0
- package/themes/game-sci-fi.css +201 -0
- package/themes/game-ui-pack.css +200 -0
- package/themes/gazette.css +449 -0
- package/themes/glass.css +457 -0
- package/themes/gothic.css +453 -0
- package/themes/index.css +21 -0
- package/themes/ink-wash.css +459 -0
- package/themes/kawaii.css +459 -0
- package/themes/kflow.css +310 -0
- package/themes/kiosk.css +449 -0
- package/themes/linear-clean.css +463 -0
- package/themes/luxury.css +451 -0
- package/themes/mac-classic.css +455 -0
- package/themes/material.css +463 -0
- package/themes/memphis.css +453 -0
- package/themes/mid-century.css +455 -0
- package/themes/minimalist.css +449 -0
- package/themes/mudcloth.css +459 -0
- package/themes/nata.css +310 -0
- package/themes/neon.css +453 -0
- package/themes/neumorphic.css +451 -0
- package/themes/newsprint.css +455 -0
- package/themes/notion-editorial.css +463 -0
- package/themes/orb.css +465 -0
- package/themes/pixel.css +449 -0
- package/themes/prism.css +309 -0
- package/themes/rawi.css +310 -0
- package/themes/retro.css +452 -0
- package/themes/risograph.css +463 -0
- package/themes/scandi.css +469 -0
- package/themes/sketch.css +455 -0
- package/themes/solarpunk.css +469 -0
- package/themes/steampunk.css +451 -0
- package/themes/swiss.css +455 -0
- package/themes/terminal.css +466 -0
- package/themes/trait-wars.css +487 -0
- package/themes/ukiyo-e.css +459 -0
- package/themes/vaporwave.css +455 -0
- package/themes/victorian.css +453 -0
- package/themes/wabi-sabi.css +459 -0
- package/themes/win95.css +455 -0
- package/themes/wireframe.css +439 -0
- package/themes/zine.css +455 -0
- package/README.md +0 -3
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { traitLevelFromDescription } from './chunk-PCR37T3U.js';
|
|
2
|
+
import { useContentSurface, useEventBus, Typography, Icon, cn, domPassthrough } from './chunk-4YXBKHHM.js';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
function generateItemId(item, index) {
|
|
7
|
+
if (item.id) return item.id;
|
|
8
|
+
const headerText = item.header ?? item.title;
|
|
9
|
+
if (typeof headerText === "string") {
|
|
10
|
+
return `accordion-${headerText.toLowerCase().replace(/\s+/g, "-")}-${index}`;
|
|
11
|
+
}
|
|
12
|
+
return `accordion-item-${index}`;
|
|
13
|
+
}
|
|
14
|
+
function normalizeItem(item, index) {
|
|
15
|
+
return {
|
|
16
|
+
...item,
|
|
17
|
+
id: generateItemId(item, index),
|
|
18
|
+
header: item.header ?? item.title ?? ""
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var Accordion = ({
|
|
22
|
+
items,
|
|
23
|
+
multiple = false,
|
|
24
|
+
defaultOpenItems,
|
|
25
|
+
defaultOpen,
|
|
26
|
+
openItems: controlledOpenItems,
|
|
27
|
+
onItemToggle,
|
|
28
|
+
className,
|
|
29
|
+
toggleEvent,
|
|
30
|
+
surface = "auto",
|
|
31
|
+
...rest
|
|
32
|
+
}) => {
|
|
33
|
+
const contentSurface = useContentSurface(surface);
|
|
34
|
+
const eventBus = useEventBus();
|
|
35
|
+
const normalizedItems = items.map(
|
|
36
|
+
(item, index) => normalizeItem(item, index)
|
|
37
|
+
);
|
|
38
|
+
const resolveDefaultOpen = () => {
|
|
39
|
+
if (defaultOpenItems) return defaultOpenItems;
|
|
40
|
+
if (defaultOpen) {
|
|
41
|
+
return defaultOpen.filter((index) => index >= 0 && index < normalizedItems.length).map((index) => normalizedItems[index].id);
|
|
42
|
+
}
|
|
43
|
+
return normalizedItems.filter((item) => item.defaultOpen).map((item) => item.id);
|
|
44
|
+
};
|
|
45
|
+
const [internalOpenItems, setInternalOpenItems] = useState(
|
|
46
|
+
new Set(resolveDefaultOpen())
|
|
47
|
+
);
|
|
48
|
+
const openItemsSet = controlledOpenItems ? new Set(controlledOpenItems) : internalOpenItems;
|
|
49
|
+
const handleToggle = (itemId) => {
|
|
50
|
+
const isOpen = openItemsSet.has(itemId);
|
|
51
|
+
const newOpenItems = new Set(openItemsSet);
|
|
52
|
+
if (isOpen) {
|
|
53
|
+
newOpenItems.delete(itemId);
|
|
54
|
+
} else {
|
|
55
|
+
if (!multiple) {
|
|
56
|
+
newOpenItems.clear();
|
|
57
|
+
}
|
|
58
|
+
newOpenItems.add(itemId);
|
|
59
|
+
}
|
|
60
|
+
if (controlledOpenItems === void 0) {
|
|
61
|
+
setInternalOpenItems(newOpenItems);
|
|
62
|
+
}
|
|
63
|
+
onItemToggle?.(itemId, !isOpen);
|
|
64
|
+
if (toggleEvent) eventBus.emit(`UI:${toggleEvent}`, { itemId, isOpen: !isOpen });
|
|
65
|
+
};
|
|
66
|
+
return contentSurface.provide(
|
|
67
|
+
/* @__PURE__ */ jsx(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
...domPassthrough(rest),
|
|
71
|
+
className: cn("w-full divide-y divide-border", contentSurface.className && cn(contentSurface.className, "overflow-hidden"), className),
|
|
72
|
+
children: normalizedItems.map((item) => {
|
|
73
|
+
const isOpen = openItemsSet.has(item.id);
|
|
74
|
+
const isDisabled = item.disabled;
|
|
75
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "overflow-hidden", children: [
|
|
76
|
+
/* @__PURE__ */ jsxs(
|
|
77
|
+
"button",
|
|
78
|
+
{
|
|
79
|
+
type: "button",
|
|
80
|
+
onClick: () => !isDisabled && handleToggle(item.id),
|
|
81
|
+
disabled: isDisabled,
|
|
82
|
+
className: cn(
|
|
83
|
+
"w-full flex items-center justify-between px-4 py-3",
|
|
84
|
+
"hover:bg-muted",
|
|
85
|
+
"transition-colors duration-fast",
|
|
86
|
+
"focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
|
|
87
|
+
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
88
|
+
isOpen && "bg-muted font-bold"
|
|
89
|
+
),
|
|
90
|
+
"aria-expanded": isOpen,
|
|
91
|
+
"aria-controls": `accordion-content-${item.id}`,
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 text-left", children: typeof item.header === "string" ? /* @__PURE__ */ jsx(Typography, { variant: "body", weight: "medium", children: item.header }) : item.header }),
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
Icon,
|
|
96
|
+
{
|
|
97
|
+
name: "chevron-down",
|
|
98
|
+
size: "sm",
|
|
99
|
+
className: cn(
|
|
100
|
+
"transition-transform duration-fast",
|
|
101
|
+
isOpen && "transform rotate-180"
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
isOpen && /* @__PURE__ */ jsx(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
id: `accordion-content-${item.id}`,
|
|
112
|
+
className: "px-4 py-3 border-t-heavy border-border",
|
|
113
|
+
children: item.content
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] }) }, item.id);
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
Accordion.displayName = "Accordion";
|
|
123
|
+
|
|
124
|
+
// src/lib/avl-play.ts
|
|
125
|
+
function armsOf(trait, from, event) {
|
|
126
|
+
return trait.transitions.filter((t) => t.from === from && t.event === event);
|
|
127
|
+
}
|
|
128
|
+
function armPosition(trait, transition) {
|
|
129
|
+
return armsOf(trait, transition.from, transition.event).findIndex((t) => t.index === transition.index);
|
|
130
|
+
}
|
|
131
|
+
function firedTransition(trait, step) {
|
|
132
|
+
if (step.result.firedArm === void 0 || !step.result.transitionFired) return void 0;
|
|
133
|
+
return armsOf(trait, step.from, step.result.event)[step.result.firedArm];
|
|
134
|
+
}
|
|
135
|
+
var ofTrait = (steps, orbital, trait) => steps.filter((s) => s.orbital === orbital && s.trait === trait);
|
|
136
|
+
function stateMachinePlayback(trait, orbital, steps, cursor) {
|
|
137
|
+
const played = ofTrait(steps.slice(0, cursor + 1), orbital, trait.name);
|
|
138
|
+
const visitedStates = [];
|
|
139
|
+
for (const step of played) {
|
|
140
|
+
for (const state of [step.result.state.before, step.result.state.after]) {
|
|
141
|
+
if (state !== null && visitedStates[visitedStates.length - 1] !== state) visitedStates.push(state);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const last = played[played.length - 1];
|
|
145
|
+
if (!last) return { visitedStates };
|
|
146
|
+
return {
|
|
147
|
+
activeState: last.result.state.after ?? last.result.state.before ?? void 0,
|
|
148
|
+
activeTransition: firedTransition(trait, last)?.index,
|
|
149
|
+
visitedStates
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function tracedTransition(trait, trace) {
|
|
153
|
+
const arms = armsOf(trait, trace.from, trace.event);
|
|
154
|
+
const arm = trace.firedArm;
|
|
155
|
+
if (arm !== void 0) return arms[arm];
|
|
156
|
+
const entering = arms.filter((t) => t.to === trace.to);
|
|
157
|
+
return entering.length === 1 ? entering[0] : void 0;
|
|
158
|
+
}
|
|
159
|
+
function tracePlayback(trait, traces) {
|
|
160
|
+
const hops = traces.filter((t) => t.traitName === trait.name);
|
|
161
|
+
const visitedStates = [];
|
|
162
|
+
for (const hop of hops) {
|
|
163
|
+
for (const state of [hop.from, hop.to]) {
|
|
164
|
+
if (visitedStates[visitedStates.length - 1] !== state) visitedStates.push(state);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const last = hops[hops.length - 1];
|
|
168
|
+
if (!last) return { visitedStates };
|
|
169
|
+
return { activeState: last.to, activeTransition: tracedTransition(trait, last)?.index, visitedStates };
|
|
170
|
+
}
|
|
171
|
+
function describedTransitionLines(description, running, transition) {
|
|
172
|
+
const printed = traitLevelFromDescription(description);
|
|
173
|
+
if (!printed || !description.source) return void 0;
|
|
174
|
+
const match = armsOf(printed, transition.from, transition.event)[armPosition(running, transition)];
|
|
175
|
+
const lines = match ? description.source.transitions.find((l) => l.index === match.index) : void 0;
|
|
176
|
+
return lines ? { start: lines.start, end: lines.end } : void 0;
|
|
177
|
+
}
|
|
178
|
+
function transitionPlayback(trait, orbital, transition, steps, cursor) {
|
|
179
|
+
const arm = armPosition(trait, transition);
|
|
180
|
+
const played = ofTrait(steps.slice(0, cursor + 1), orbital, trait.name);
|
|
181
|
+
for (let i = played.length - 1; i >= 0; i--) {
|
|
182
|
+
const step = played[i];
|
|
183
|
+
if (step.from !== transition.from || step.result.event !== transition.event) continue;
|
|
184
|
+
const fired = step.result.transitionFired && step.result.firedArm === arm;
|
|
185
|
+
const guard = step.result.guards?.find((g) => g.arm === arm);
|
|
186
|
+
if (fired || guard) return { step, fired, ...guard ? { guard } : {}, effects: fired ? step.result.effects : [] };
|
|
187
|
+
}
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { Accordion, armPosition, armsOf, describedTransitionLines, firedTransition, stateMachinePlayback, tracePlayback, transitionPlayback };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AvlStateMachine } from './chunk-SP5CDJ6K.js';
|
|
2
|
+
import { EmptyState } from './chunk-AGXD77SL.js';
|
|
3
|
+
import { useTranslate, Box, domPassthrough } from './chunk-4YXBKHHM.js';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var BehaviorView = ({ data, ...rest }) => {
|
|
7
|
+
const { t } = useTranslate();
|
|
8
|
+
const details = data.traits.map((tr) => data.traitDetails[tr.name]).filter((d) => d !== void 0);
|
|
9
|
+
if (details.length === 0) {
|
|
10
|
+
return /* @__PURE__ */ jsx(Box, { ...domPassthrough(rest), "data-testid": "behavior-view-empty", children: /* @__PURE__ */ jsx(EmptyState, { icon: "workflow", title: t("avl.noTraitData") }) });
|
|
11
|
+
}
|
|
12
|
+
return /* @__PURE__ */ jsx(Box, { ...domPassthrough(rest), className: "flex flex-col gap-4", style: { width: "100%" }, children: details.map((trait) => /* @__PURE__ */ jsx(
|
|
13
|
+
Box,
|
|
14
|
+
{
|
|
15
|
+
className: "rounded-lg border px-5 pb-4 pt-4",
|
|
16
|
+
style: { background: "var(--color-card)", borderColor: "var(--color-border)", boxShadow: "var(--shadow-sm)" },
|
|
17
|
+
children: /* @__PURE__ */ jsx(AvlStateMachine, { trait })
|
|
18
|
+
},
|
|
19
|
+
trait.name
|
|
20
|
+
)) });
|
|
21
|
+
};
|
|
22
|
+
BehaviorView.displayName = "BehaviorView";
|
|
23
|
+
|
|
24
|
+
export { BehaviorView };
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { useContainerWidth, computeTraitLayout, roundedEdgePath } from './chunk-TXAUOLWZ.js';
|
|
2
|
+
import { AvlExplain, AvlEffectChip } from './chunk-AB3X7QTE.js';
|
|
3
|
+
import { gearTeethPath } from './chunk-TZZBINQY.js';
|
|
4
|
+
import { AVL_INK, AVL_FONT, AVL_STROKE, avlTint } from './chunk-UXLE3IPR.js';
|
|
5
|
+
import { domPassthrough, useTranslate, useEventBus, useMediaQuery, Box, Typography, Button } from './chunk-4YXBKHHM.js';
|
|
6
|
+
import { useState, useRef, useMemo, useEffect } from 'react';
|
|
7
|
+
import { formatSExpr } from '@almadar/core';
|
|
8
|
+
import { createLogger } from '@almadar/logger';
|
|
9
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
var log = createLogger("almadar:ui:avl:state-machine");
|
|
12
|
+
var MONO_CHAR = 7.3;
|
|
13
|
+
var BODY_CHAR = 7.6;
|
|
14
|
+
var NODE_H = 44;
|
|
15
|
+
var PILL_H = 24;
|
|
16
|
+
var EFFECT_CHIP = 14;
|
|
17
|
+
var EFFECT_GAP = 4;
|
|
18
|
+
var MARGIN = 28;
|
|
19
|
+
var MIN_SCALE = 0.85;
|
|
20
|
+
var MAX_SCALE = 1.25;
|
|
21
|
+
function effectText(effect) {
|
|
22
|
+
return effect.args.length === 0 ? void 0 : formatSExpr([effect.type, ...effect.args]);
|
|
23
|
+
}
|
|
24
|
+
function guardText(t) {
|
|
25
|
+
return t.guard === void 0 || t.guard === null ? null : formatSExpr(t.guard);
|
|
26
|
+
}
|
|
27
|
+
function pillWidth(t) {
|
|
28
|
+
return 20 + (guardText(t) === null ? 0 : 16) + t.event.length * MONO_CHAR + t.effects.length * (EFFECT_CHIP + EFFECT_GAP);
|
|
29
|
+
}
|
|
30
|
+
function gearDiameter(name) {
|
|
31
|
+
return Math.max(96, Math.round(name.length * BODY_CHAR + 40));
|
|
32
|
+
}
|
|
33
|
+
function metricsFor(nodeShape, direction) {
|
|
34
|
+
return {
|
|
35
|
+
nodeSize: (name) => nodeShape === "gear" ? { width: gearDiameter(name), height: gearDiameter(name) } : { width: Math.max(112, Math.round(name.length * BODY_CHAR + 44)), height: NODE_H },
|
|
36
|
+
labelSize: (t) => ({ width: pillWidth(t), height: PILL_H }),
|
|
37
|
+
nodeSpacing: 40,
|
|
38
|
+
layerSpacing: 88,
|
|
39
|
+
orthogonal: true,
|
|
40
|
+
direction
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
var AvlStateMachine = ({
|
|
44
|
+
trait,
|
|
45
|
+
activeState,
|
|
46
|
+
activeTransition,
|
|
47
|
+
visitedStates,
|
|
48
|
+
followActive = false,
|
|
49
|
+
stateClickEvent,
|
|
50
|
+
transitionClickEvent,
|
|
51
|
+
onTransitionClick,
|
|
52
|
+
selectedState,
|
|
53
|
+
pendingSourceState,
|
|
54
|
+
nodeShape = "pill",
|
|
55
|
+
entityFields,
|
|
56
|
+
direction = "ltr",
|
|
57
|
+
showHeader = true,
|
|
58
|
+
annotations,
|
|
59
|
+
className,
|
|
60
|
+
...rest
|
|
61
|
+
}) => {
|
|
62
|
+
const passthrough = domPassthrough(rest);
|
|
63
|
+
const { t } = useTranslate();
|
|
64
|
+
const eventBus = useEventBus();
|
|
65
|
+
const clickable = transitionClickEvent !== void 0 || onTransitionClick !== void 0;
|
|
66
|
+
const reduceMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
67
|
+
const [layout, setLayout] = useState(null);
|
|
68
|
+
const [layoutFailed, setLayoutFailed] = useState(false);
|
|
69
|
+
const [layoutAttempt, setLayoutAttempt] = useState(0);
|
|
70
|
+
const hostRef = useRef(null);
|
|
71
|
+
const hostWidth = useContainerWidth(hostRef);
|
|
72
|
+
const traitKey = useMemo(() => JSON.stringify(trait), [trait]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (trait.states.length === 0) return;
|
|
75
|
+
let live = true;
|
|
76
|
+
setLayoutFailed(false);
|
|
77
|
+
computeTraitLayout(trait, metricsFor(nodeShape, direction)).then((l) => {
|
|
78
|
+
if (live) setLayout(l);
|
|
79
|
+
}).catch((error) => {
|
|
80
|
+
log.error("layout-failed", { trait: trait.name, error: error instanceof Error ? error : String(error) });
|
|
81
|
+
if (live) setLayoutFailed(true);
|
|
82
|
+
});
|
|
83
|
+
return () => {
|
|
84
|
+
live = false;
|
|
85
|
+
};
|
|
86
|
+
}, [traitKey, nodeShape, direction, layoutAttempt]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const host = hostRef.current;
|
|
89
|
+
if (!followActive || layout === null || host === null || activeState === void 0) return;
|
|
90
|
+
const node = [...host.querySelectorAll('[data-testid="avl-sm-state"]')].find((n) => n.getAttribute("data-state") === activeState);
|
|
91
|
+
if (node === void 0) return;
|
|
92
|
+
const hostBox = host.getBoundingClientRect();
|
|
93
|
+
const nodeBox = node.getBoundingClientRect();
|
|
94
|
+
const left = host.scrollLeft + (nodeBox.left + nodeBox.width / 2) - (hostBox.left + hostBox.width / 2);
|
|
95
|
+
host.scrollTo({ left: Math.max(0, left), behavior: reduceMotion ? "auto" : "smooth" });
|
|
96
|
+
}, [followActive, layout, activeState, reduceMotion]);
|
|
97
|
+
const visitOrder = useMemo(() => new Map((visitedStates ?? []).map((s, i) => [s, i + 1])), [visitedStates]);
|
|
98
|
+
const nextFromActive = useMemo(
|
|
99
|
+
() => new Set(trait.transitions.filter((tr) => activeState !== void 0 && tr.from === activeState).map((tr) => tr.index)),
|
|
100
|
+
[trait.transitions, activeState]
|
|
101
|
+
);
|
|
102
|
+
const header = showHeader ? /* @__PURE__ */ jsxs(Box, { className: "flex flex-wrap items-baseline justify-between gap-2 pb-3", children: [
|
|
103
|
+
/* @__PURE__ */ jsxs(Box, { className: "flex items-baseline gap-2", children: [
|
|
104
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body", weight: "semibold", children: trait.name }),
|
|
105
|
+
/* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "muted", children: [
|
|
106
|
+
t("avl.onEntity", { entity: trait.linkedEntity }),
|
|
107
|
+
" \xB7 ",
|
|
108
|
+
t("avl.stateCount", { count: trait.states.length }),
|
|
109
|
+
" \xB7 ",
|
|
110
|
+
t("avl.transitionCount", { count: trait.transitions.length })
|
|
111
|
+
] })
|
|
112
|
+
] }),
|
|
113
|
+
/* @__PURE__ */ jsxs(Box, { className: "flex flex-wrap gap-2", children: [
|
|
114
|
+
entityFields && entityFields.length > 0 ? /* @__PURE__ */ jsxs(Box, { as: "span", "data-testid": "avl-sm-fields", style: { fontFamily: AVL_FONT.mono, fontSize: 12, lineHeight: "20px", color: AVL_INK.quiet }, children: [
|
|
115
|
+
trait.linkedEntity,
|
|
116
|
+
" ",
|
|
117
|
+
"{ ",
|
|
118
|
+
entityFields.join(", "),
|
|
119
|
+
" }"
|
|
120
|
+
] }) : null,
|
|
121
|
+
trait.listenedEvents.map((ev) => /* @__PURE__ */ jsx(Rail, { kind: t("avl.listensRail"), event: ev }, `in-${ev}`)),
|
|
122
|
+
trait.emittedEvents.map((ev) => /* @__PURE__ */ jsx(Rail, { kind: t("avl.emitsRail"), event: ev }, `out-${ev}`))
|
|
123
|
+
] })
|
|
124
|
+
] }) : null;
|
|
125
|
+
if (trait.states.length === 0) {
|
|
126
|
+
return /* @__PURE__ */ jsxs(Box, { "data-testid": "avl-state-machine", className, style: { width: "100%" }, ...passthrough, children: [
|
|
127
|
+
header,
|
|
128
|
+
/* @__PURE__ */ jsx(Box, { "data-testid": "avl-state-machine-empty", className: "rounded-md border border-dashed p-6 text-center", style: { borderColor: AVL_INK.line }, children: /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "muted", children: t("avl.noStateMachine") }) })
|
|
129
|
+
] });
|
|
130
|
+
}
|
|
131
|
+
const w = layout ? layout.width + 2 * MARGIN : 0;
|
|
132
|
+
const h = layout ? layout.height + 2 * MARGIN : 0;
|
|
133
|
+
const fit = layout && hostWidth ? hostWidth / w : 1;
|
|
134
|
+
const scale = Math.min(MAX_SCALE, Math.max(MIN_SCALE, fit));
|
|
135
|
+
return /* @__PURE__ */ jsxs(Box, { "data-testid": "avl-state-machine", className, style: { width: "100%" }, ...passthrough, children: [
|
|
136
|
+
header,
|
|
137
|
+
/* @__PURE__ */ jsx(Box, { ref: hostRef, className: "overflow-x-auto", style: { width: "100%" }, children: layout ? /* @__PURE__ */ jsx(Box, { className: "relative mx-auto", style: { width: w * scale, height: h * scale }, children: /* @__PURE__ */ jsxs(Box, { className: "absolute left-0 top-0", style: { width: w, height: h, transform: `scale(${scale})`, transformOrigin: "0 0" }, children: [
|
|
138
|
+
/* @__PURE__ */ jsxs("svg", { width: w, height: h, className: "absolute left-0 top-0 overflow-visible", "aria-hidden": "true", children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
140
|
+
/* @__PURE__ */ jsx("marker", { id: `avl-sm-head-${trait.name}`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: /* @__PURE__ */ jsx("path", { d: "M0 0 L10 5 L0 10z", fill: AVL_INK.quiet, fillOpacity: 0.8 }) }),
|
|
141
|
+
/* @__PURE__ */ jsx("marker", { id: `avl-sm-head-hot-${trait.name}`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "6", markerHeight: "6", orient: "auto-start-reverse", children: /* @__PURE__ */ jsx("path", { d: "M0 0 L10 5 L0 10z", fill: AVL_INK.focus }) })
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(${MARGIN},${MARGIN})`, children: [
|
|
144
|
+
layout.nodes.filter((n) => n.isInitial).map((n) => {
|
|
145
|
+
const cy = n.y + n.height / 2;
|
|
146
|
+
const rtl = direction === "rtl";
|
|
147
|
+
const dot = rtl ? n.x + n.width + 18 : n.x - 18;
|
|
148
|
+
const d = rtl ? `M ${n.x + n.width + 13} ${cy} H ${n.x + n.width + 1}` : `M ${n.x - 13} ${cy} H ${n.x - 1}`;
|
|
149
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
150
|
+
/* @__PURE__ */ jsx("circle", { cx: dot, cy, r: 5, fill: AVL_INK.text }),
|
|
151
|
+
/* @__PURE__ */ jsx("path", { d, stroke: AVL_INK.quiet, strokeWidth: AVL_STROKE.wire, markerEnd: `url(#avl-sm-head-${trait.name})` })
|
|
152
|
+
] }, `init-${n.id}`);
|
|
153
|
+
}),
|
|
154
|
+
layout.edges.map((e) => {
|
|
155
|
+
const fired = e.index === activeTransition;
|
|
156
|
+
return /* @__PURE__ */ jsx(
|
|
157
|
+
"path",
|
|
158
|
+
{
|
|
159
|
+
"data-testid": "avl-sm-wire",
|
|
160
|
+
"data-event": e.event,
|
|
161
|
+
"data-fired": fired ? "true" : "false",
|
|
162
|
+
d: roundedEdgePath(e.points, 10),
|
|
163
|
+
fill: "none",
|
|
164
|
+
stroke: fired ? AVL_INK.focus : AVL_INK.quiet,
|
|
165
|
+
strokeOpacity: fired ? 1 : 0.55,
|
|
166
|
+
strokeWidth: fired ? AVL_STROKE.active : AVL_STROKE.wire,
|
|
167
|
+
strokeDasharray: fired ? "8 6" : e.isBackward || e.isSelf ? "5 4" : void 0,
|
|
168
|
+
markerEnd: `url(#avl-sm-head${fired ? "-hot" : ""}-${trait.name})`,
|
|
169
|
+
children: fired && !reduceMotion ? /* @__PURE__ */ jsx("animate", { attributeName: "stroke-dashoffset", from: "0", to: "-14", dur: "0.8s", repeatCount: "indefinite" }) : null
|
|
170
|
+
},
|
|
171
|
+
e.id
|
|
172
|
+
);
|
|
173
|
+
}),
|
|
174
|
+
layout.nodes.filter((n) => n.id === activeState).map((n) => /* @__PURE__ */ jsx(
|
|
175
|
+
"rect",
|
|
176
|
+
{
|
|
177
|
+
x: n.x - 5,
|
|
178
|
+
y: n.y - 5,
|
|
179
|
+
width: n.width + 10,
|
|
180
|
+
height: n.height + 10,
|
|
181
|
+
rx: 12,
|
|
182
|
+
fill: "none",
|
|
183
|
+
stroke: AVL_INK.focus,
|
|
184
|
+
strokeWidth: 4,
|
|
185
|
+
strokeOpacity: 0.22,
|
|
186
|
+
children: !reduceMotion ? /* @__PURE__ */ jsx("animate", { attributeName: "stroke-opacity", values: "0.28;0.06;0.28", dur: "1.6s", repeatCount: "indefinite" }) : null
|
|
187
|
+
},
|
|
188
|
+
`ring-${n.id}`
|
|
189
|
+
))
|
|
190
|
+
] })
|
|
191
|
+
] }),
|
|
192
|
+
layout.edges.map((e) => {
|
|
193
|
+
const tr = trait.transitions.find((x) => x.index === e.index);
|
|
194
|
+
if (!tr) return null;
|
|
195
|
+
const fired = e.index === activeTransition;
|
|
196
|
+
const next = !fired && nextFromActive.has(e.index);
|
|
197
|
+
const guard = guardText(tr);
|
|
198
|
+
const pw = pillWidth(tr);
|
|
199
|
+
return /* @__PURE__ */ jsx(
|
|
200
|
+
Box,
|
|
201
|
+
{
|
|
202
|
+
"data-testid": "avl-sm-label",
|
|
203
|
+
"data-event": tr.event,
|
|
204
|
+
role: clickable ? "button" : void 0,
|
|
205
|
+
tabIndex: clickable ? 0 : void 0,
|
|
206
|
+
"aria-current": fired ? "true" : void 0,
|
|
207
|
+
onClick: clickable ? () => {
|
|
208
|
+
const payload = { index: tr.index, event: tr.event, from: tr.from, to: tr.to };
|
|
209
|
+
onTransitionClick?.(payload);
|
|
210
|
+
if (transitionClickEvent) eventBus.emit(`UI:${transitionClickEvent}`, payload);
|
|
211
|
+
} : void 0,
|
|
212
|
+
className: `absolute flex flex-col items-center justify-center ${clickable ? "cursor-pointer" : ""}`,
|
|
213
|
+
style: { left: MARGIN + e.labelX, top: MARGIN + e.labelY, width: e.labelW, height: e.labelH },
|
|
214
|
+
children: /* @__PURE__ */ jsxs(
|
|
215
|
+
Box,
|
|
216
|
+
{
|
|
217
|
+
className: "flex items-center gap-1 rounded-md px-2",
|
|
218
|
+
style: {
|
|
219
|
+
height: PILL_H,
|
|
220
|
+
width: pw,
|
|
221
|
+
background: AVL_INK.surface,
|
|
222
|
+
border: `1px ${next ? "dashed" : "solid"} ${fired ? AVL_INK.focus : AVL_INK.line}`,
|
|
223
|
+
fontFamily: AVL_FONT.mono,
|
|
224
|
+
fontSize: 12,
|
|
225
|
+
color: fired ? AVL_INK.focus : AVL_INK.text,
|
|
226
|
+
fontWeight: fired ? 600 : 400
|
|
227
|
+
},
|
|
228
|
+
children: [
|
|
229
|
+
guard !== null ? /* @__PURE__ */ jsx(AvlExplain, { lines: [t("avl.guard"), t("avl.guardCaption")], code: guard, children: /* @__PURE__ */ jsx(Box, { as: "span", role: "img", tabIndex: 0, "aria-label": `${t("avl.guard")}: ${guard}`, "data-testid": "avl-guard-glyph", className: "inline-flex shrink-0 cursor-help rounded-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: /* @__PURE__ */ jsx("svg", { width: 12, height: 12, viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M6 1 L11 6 L6 11 L1 6z", fill: AVL_INK.surface, stroke: fired ? AVL_INK.focus : AVL_INK.quiet, strokeWidth: 1.2 }) }) }) }) : null,
|
|
230
|
+
annotations?.transitions?.[tr.event] ? /* @__PURE__ */ jsx(AvlExplain, { lines: [tr.event], code: guard ?? void 0, note: annotations.transitions[tr.event], children: /* @__PURE__ */ jsx(Box, { as: "span", tabIndex: 0, "data-explain": `transition:${tr.event}`, className: "whitespace-nowrap underline decoration-dotted underline-offset-2 cursor-help", children: tr.event }) }) : /* @__PURE__ */ jsx(Box, { as: "span", className: "whitespace-nowrap", children: tr.event }),
|
|
231
|
+
tr.effects.map((fx, i) => /* @__PURE__ */ jsx(AvlEffectChip, { effectType: fx.type, size: EFFECT_CHIP, note: annotations?.effects?.[fx.type], code: effectText(fx) }, `${fx.type}-${i}`))
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
},
|
|
236
|
+
`label-${e.id}`
|
|
237
|
+
);
|
|
238
|
+
}),
|
|
239
|
+
trait.states.map((s) => {
|
|
240
|
+
const n = layout.nodes.find((x) => x.id === s.name);
|
|
241
|
+
if (!n) return null;
|
|
242
|
+
const active = s.name === activeState;
|
|
243
|
+
const selected = s.name === selectedState;
|
|
244
|
+
const pending = s.name === pendingSourceState;
|
|
245
|
+
const visit = visitOrder.get(s.name);
|
|
246
|
+
const idle = activeState !== void 0 && !active && visit === void 0;
|
|
247
|
+
const gear = nodeShape === "gear";
|
|
248
|
+
const emphasis = active || selected || pending;
|
|
249
|
+
return /* @__PURE__ */ jsxs(
|
|
250
|
+
Box,
|
|
251
|
+
{
|
|
252
|
+
"data-testid": "avl-sm-state",
|
|
253
|
+
"data-state": s.name,
|
|
254
|
+
"data-active": active ? "true" : "false",
|
|
255
|
+
"data-selected": selected ? "true" : "false",
|
|
256
|
+
"data-pending": pending ? "true" : "false",
|
|
257
|
+
"data-shape": nodeShape,
|
|
258
|
+
role: stateClickEvent ? "button" : void 0,
|
|
259
|
+
tabIndex: stateClickEvent ? 0 : void 0,
|
|
260
|
+
"aria-current": active ? "true" : void 0,
|
|
261
|
+
"aria-pressed": stateClickEvent ? selected : void 0,
|
|
262
|
+
onClick: stateClickEvent ? () => eventBus.emit(`UI:${stateClickEvent}`, { stateId: s.name }) : void 0,
|
|
263
|
+
className: `absolute flex items-center justify-center ${gear ? "rounded-full" : "rounded-lg"} ${stateClickEvent ? "cursor-pointer" : ""}`,
|
|
264
|
+
style: {
|
|
265
|
+
left: MARGIN + n.x,
|
|
266
|
+
top: MARGIN + n.y,
|
|
267
|
+
width: n.width,
|
|
268
|
+
height: n.height,
|
|
269
|
+
background: gear ? "transparent" : AVL_INK.surface,
|
|
270
|
+
border: gear ? "none" : `${emphasis ? 2 : 1}px ${pending ? "dashed" : "solid"} ${emphasis ? AVL_INK.focus : AVL_INK.line}`,
|
|
271
|
+
boxShadow: gear ? "none" : s.isTerminal ? `0 0 0 3px ${AVL_INK.surface}, 0 0 0 4px ${AVL_INK.line}, var(--shadow-sm)` : selected ? `0 0 0 4px ${avlTint(AVL_INK.focus, 18)}, var(--shadow-hover)` : active ? "var(--shadow-hover)" : "var(--shadow-sm)",
|
|
272
|
+
color: idle ? AVL_INK.quiet : AVL_INK.text,
|
|
273
|
+
fontFamily: AVL_FONT.body,
|
|
274
|
+
fontSize: 13,
|
|
275
|
+
fontWeight: active ? 600 : 500,
|
|
276
|
+
transition: "border-color var(--duration-normal, 200ms), box-shadow var(--duration-normal, 200ms)"
|
|
277
|
+
},
|
|
278
|
+
children: [
|
|
279
|
+
pending ? /* @__PURE__ */ jsx(Box, { as: "span", className: "sr-only", children: t("avl.pendingSourceState") }) : null,
|
|
280
|
+
visit !== void 0 && !active ? /* @__PURE__ */ jsx(
|
|
281
|
+
Box,
|
|
282
|
+
{
|
|
283
|
+
as: "span",
|
|
284
|
+
"data-testid": "avl-sm-visit",
|
|
285
|
+
className: "absolute flex items-center justify-center rounded-full",
|
|
286
|
+
style: { top: -9, left: -9, width: 18, height: 18, fontSize: 11, fontWeight: 600, background: AVL_INK.wash, color: AVL_INK.quiet, border: `1px solid ${AVL_INK.line}` },
|
|
287
|
+
children: visit
|
|
288
|
+
}
|
|
289
|
+
) : null,
|
|
290
|
+
active ? /* @__PURE__ */ jsx(
|
|
291
|
+
Box,
|
|
292
|
+
{
|
|
293
|
+
as: "span",
|
|
294
|
+
className: "absolute rounded-full px-1.5",
|
|
295
|
+
style: { top: -10, right: 8, fontSize: 11, fontWeight: 600, background: AVL_INK.focus, color: AVL_INK.onFocus, boxShadow: `0 0 0 2px ${avlTint(AVL_INK.focus, 18)}` },
|
|
296
|
+
children: t("avl.now")
|
|
297
|
+
}
|
|
298
|
+
) : null,
|
|
299
|
+
gear ? /* @__PURE__ */ jsxs("svg", { "data-testid": "avl-sm-gear", width: n.width, height: n.height, className: "absolute left-0 top-0", "aria-hidden": "true", children: [
|
|
300
|
+
/* @__PURE__ */ jsx(
|
|
301
|
+
"path",
|
|
302
|
+
{
|
|
303
|
+
d: gearTeethPath(n.width / 2, n.height / 2, n.width / 2 - 8, n.width / 2 - 1, 12),
|
|
304
|
+
fill: AVL_INK.surface,
|
|
305
|
+
stroke: emphasis ? AVL_INK.focus : AVL_INK.line,
|
|
306
|
+
strokeWidth: emphasis ? 2 : 1.25,
|
|
307
|
+
strokeDasharray: pending || s.isTerminal ? "4 3" : void 0
|
|
308
|
+
}
|
|
309
|
+
),
|
|
310
|
+
/* @__PURE__ */ jsx("circle", { cx: n.width / 2, cy: n.height / 2, r: n.width / 2 - 14, fill: "none", stroke: AVL_INK.line, strokeWidth: 1 })
|
|
311
|
+
] }) : null,
|
|
312
|
+
annotations?.states?.[s.name] ? /* @__PURE__ */ jsx(AvlExplain, { lines: [s.name], note: annotations.states[s.name], children: /* @__PURE__ */ jsx(Box, { as: "span", tabIndex: 0, "data-explain": `state:${s.name}`, className: "relative underline decoration-dotted underline-offset-2 cursor-help", children: s.name }) }) : /* @__PURE__ */ jsx(Box, { as: "span", className: "relative", children: s.name })
|
|
313
|
+
]
|
|
314
|
+
},
|
|
315
|
+
s.name
|
|
316
|
+
);
|
|
317
|
+
})
|
|
318
|
+
] }) }) : layoutFailed ? /* @__PURE__ */ jsxs(Box, { role: "alert", className: "flex flex-col items-center justify-center gap-2 py-10", children: [
|
|
319
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "muted", children: t("avl.layoutFailed") }),
|
|
320
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", label: t("common.retry"), onClick: () => setLayoutAttempt((n) => n + 1) })
|
|
321
|
+
] }) : /* @__PURE__ */ jsx(Box, { className: "flex items-center justify-center py-10", children: /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "muted", children: t("avl.computingLayout") }) }) })
|
|
322
|
+
] });
|
|
323
|
+
};
|
|
324
|
+
var Rail = ({ kind, event }) => /* @__PURE__ */ jsxs(
|
|
325
|
+
Box,
|
|
326
|
+
{
|
|
327
|
+
as: "span",
|
|
328
|
+
className: "inline-flex items-center gap-1 rounded-full px-2",
|
|
329
|
+
style: { fontFamily: AVL_FONT.mono, fontSize: 12, lineHeight: "20px", border: `1px solid ${AVL_INK.line}`, background: AVL_INK.wash, color: AVL_INK.quiet },
|
|
330
|
+
children: [
|
|
331
|
+
kind,
|
|
332
|
+
/* @__PURE__ */ jsx(Box, { as: "span", style: { color: AVL_INK.text, fontWeight: 600 }, children: event })
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
AvlStateMachine.displayName = "AvlStateMachine";
|
|
337
|
+
|
|
338
|
+
export { AvlStateMachine, BODY_CHAR, MARGIN, MAX_SCALE, MIN_SCALE, MONO_CHAR, PILL_H, metricsFor, pillWidth };
|