@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.ci-release-guard.668.ec1f74f

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 (91) hide show
  1. package/README.md +185 -124
  2. package/dist/3d.cjs +1 -1
  3. package/dist/3d.d.ts +0 -3
  4. package/dist/3d.js +16 -21
  5. package/dist/SafetyBar/index.cjs +1 -1
  6. package/dist/SafetyBar/index.js +1 -1
  7. package/dist/chunks/ConnectedMotionGroup-BewSDQvD.cjs +4 -0
  8. package/dist/chunks/ConnectedMotionGroup-D6-4wBkk.js +2654 -0
  9. package/dist/chunks/Robot-C0uICTOn.js +1271 -0
  10. package/dist/chunks/Robot-D6RUDXEz.cjs +1 -0
  11. package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-C2-H1ifP.js} +1 -1
  12. package/dist/chunks/{SafetyBar-DPrv_OQA.cjs → SafetyBar-Cq_WsuK2.cjs} +1 -1
  13. package/dist/chunks/externalizeComponent-Bue3-Wra.cjs +2 -0
  14. package/dist/chunks/{externalizeComponent-EDymnaGR.js → externalizeComponent-C0cVcPE2.js} +29 -107
  15. package/dist/chunks/useSmoothedMotionState-COMJRcOt.js +214 -0
  16. package/dist/chunks/useSmoothedMotionState-Con0E5Bx.cjs +1 -0
  17. package/dist/components/AppHeader.d.ts +1 -1
  18. package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +1 -1
  19. package/dist/components/jogging/JoggingJointTab.d.ts +1 -1
  20. package/dist/components/jogging/JoggingPanel.d.ts +6 -3
  21. package/dist/components/jogging/JoggingStore.d.ts +5 -1
  22. package/dist/components/jogging/joggingColors.d.ts +18 -0
  23. package/dist/components/robots/GenericRobot.d.ts +2 -1
  24. package/dist/components/robots/LinearAxis.d.ts +1 -1
  25. package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
  26. package/dist/components/robots/Robot.d.ts +1 -1
  27. package/dist/components/robots/robotModelLogic.d.ts +11 -9
  28. package/dist/components/utils/hooks.d.ts +1 -6
  29. package/dist/core.cjs +1 -1
  30. package/dist/core.d.ts +3 -18
  31. package/dist/core.js +27 -54
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.js +39 -71
  34. package/dist/lib/ConnectedMotionGroup.d.ts +5 -7
  35. package/dist/lib/JoggerConnection.d.ts +29 -5
  36. package/dist/lib/MotionStreamConnection.d.ts +4 -6
  37. package/dist/lib/novaConnection.d.ts +23 -0
  38. package/package.json +32 -66
  39. package/dist/Setup.d.ts +0 -11
  40. package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
  41. package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
  42. package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
  43. package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
  44. package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
  45. package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
  46. package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
  47. package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -11
  48. package/dist/components/AdornedTextField.d.ts +0 -7
  49. package/dist/components/CopyableText.d.ts +0 -6
  50. package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
  51. package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
  52. package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
  53. package/dist/components/CycleTimer/index.d.ts +0 -27
  54. package/dist/components/CycleTimer/types.d.ts +0 -49
  55. package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
  56. package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
  57. package/dist/components/CycleTimer/utils.d.ts +0 -21
  58. package/dist/components/CycleTimer.d.ts +0 -3
  59. package/dist/components/DataGrid.d.ts +0 -66
  60. package/dist/components/LogPanel.d.ts +0 -38
  61. package/dist/components/LogStore.d.ts +0 -12
  62. package/dist/components/LogViewer.d.ts +0 -46
  63. package/dist/components/ProgramControl.d.ts +0 -55
  64. package/dist/components/ProgramStateIndicator.d.ts +0 -26
  65. package/dist/components/RobotCard.d.ts +0 -98
  66. package/dist/components/RobotListItem.d.ts +0 -34
  67. package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
  68. package/dist/components/SelectableFab.d.ts +0 -7
  69. package/dist/components/TabBar.d.ts +0 -45
  70. package/dist/components/ThemeSelect.d.ts +0 -6
  71. package/dist/components/Timer/Timer.d.ts +0 -3
  72. package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
  73. package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
  74. package/dist/components/Timer/index.d.ts +0 -19
  75. package/dist/components/Timer/types.d.ts +0 -35
  76. package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
  77. package/dist/components/Timer/useTimerLogic.d.ts +0 -19
  78. package/dist/components/Timer/utils.d.ts +0 -17
  79. package/dist/components/Timer.d.ts +0 -3
  80. package/dist/components/TransparentOverlay.d.ts +0 -4
  81. package/dist/components/jogging/JoggingFreedriveTab.d.ts +0 -1
  82. package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
  83. package/dist/components/jogging/PoseJointValues.d.ts +0 -8
  84. package/dist/components/robots/AxisConfig.d.ts +0 -2
  85. package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
  86. package/dist/icons/DropdownArrowIcon.d.ts +0 -2
  87. package/dist/icons/index.d.ts +0 -12
  88. package/dist/lib/novaCompat.d.ts +0 -16
  89. package/dist/themes/createDarkTheme.d.ts +0 -7
  90. package/dist/themes/themeTypes.d.ts +0 -40
  91. package/dist/themes/theming.d.ts +0 -24
@@ -0,0 +1,2654 @@
1
+ import { jsxs as S, Fragment as et, jsx as r } from "react/jsx-runtime";
2
+ import Vt from "@mui/material/AppBar";
3
+ import Mt from "@mui/material/Backdrop";
4
+ import V from "@mui/material/Box";
5
+ import Lt from "@mui/material/Menu";
6
+ import $ from "@mui/material/MenuItem";
7
+ import Bt from "@mui/material/Toolbar";
8
+ import j from "@mui/material/Typography";
9
+ import { ZeroGravityComponentsBackdropFill as $t } from "@wandelbots/design-tokens";
10
+ import { ExpandMoreFilled as Ft } from "@wandelbots/icons/ExpandMoreFilled";
11
+ import { RoundedIconButton as Nt } from "@wandelbots/mui";
12
+ import { observer as k, useLocalObservable as jt } from "mobx-react-lite";
13
+ import * as C from "react";
14
+ import { useState as Y, forwardRef as N, useEffect as ot, useRef as nt, useId as zt } from "react";
15
+ import { e as Z } from "./externalizeComponent-C0cVcPE2.js";
16
+ import Gt from "@mui/icons-material/OpenWith";
17
+ import Ut from "@mui/icons-material/Share";
18
+ import w from "@mui/material/Stack";
19
+ import Wt from "@mui/material/Tab";
20
+ import Ht from "@mui/material/Tabs";
21
+ import { runInAction as x, makeAutoObservable as dt, when as tt, autorun as ft } from "mobx";
22
+ import { useTranslation as D } from "react-i18next";
23
+ import { radiansToDegrees as _t, tryParseJson as P, XYZ_TO_VECTOR as W, degreesToRadians as qt } from "@wandelbots/nova-js";
24
+ import { JointTypeEnum as A } from "@wandelbots/nova-js/v2";
25
+ import { Vector3 as rt } from "three/src/math/Vector3.js";
26
+ import { d as ht, c as H, e as st } from "./useSmoothedMotionState-COMJRcOt.js";
27
+ import kt from "@mui/material/CircularProgress";
28
+ import { capitalize as Yt } from "@mui/material/utils";
29
+ import { lowerFirst as Zt, countBy as Xt } from "lodash-es";
30
+ import { m as Kt } from "./SafetyBar-C2-H1ifP.js";
31
+ import Qt from "@mui/material/Alert";
32
+ import te from "@mui/material/AlertTitle";
33
+ import lt from "@mui/material/Button";
34
+ import { useTheme as z, styled as Et } from "@mui/material/styles";
35
+ import F from "@mui/material/Divider";
36
+ import yt from "@mui/material/ToggleButton";
37
+ import it from "@mui/material/IconButton";
38
+ import ee from "lodash-es/isEqual.js";
39
+ import oe from "@mui/material/InputAdornment";
40
+ import ie from "@mui/material/FormControl";
41
+ import ne from "@mui/material/InputLabel";
42
+ import re from "@mui/material/Select";
43
+ import K from "lodash-es/keyBy.js";
44
+ import ae from "lodash-es/uniqueId.js";
45
+ import se from "@mui/material/ToggleButtonGroup";
46
+ import Tt from "@mui/material/Slider";
47
+ import le from "lodash-es/isNumber.js";
48
+ import ce from "@mui/icons-material/ChevronLeft";
49
+ import ge from "@mui/icons-material/ChevronRight";
50
+ import de from "lodash-es/throttle.js";
51
+ import he from "@mui/material/Dialog";
52
+ import me from "@mui/material/DialogActions";
53
+ import ue from "@mui/material/DialogContent";
54
+ import pe from "@mui/material/DialogTitle";
55
+ import * as bt from "three";
56
+ import { Vector3 as St } from "three";
57
+ const Ho = Z(
58
+ k((e) => {
59
+ const {
60
+ appIcon: t,
61
+ appName: o,
62
+ apps: i = [],
63
+ onAppSelect: n,
64
+ disabled: a = !1,
65
+ sx: l
66
+ } = e, [s, h] = Y(null), g = !!s, p = (c) => {
67
+ h(c.currentTarget);
68
+ }, m = () => {
69
+ h(null);
70
+ }, d = (c) => {
71
+ m(), c.onClick ? c.onClick() : c.href && (window.location.href = c.href), n == null || n(c);
72
+ };
73
+ return /* @__PURE__ */ S(et, { children: [
74
+ /* @__PURE__ */ r(
75
+ Vt,
76
+ {
77
+ position: "static",
78
+ sx: {
79
+ boxShadow: "none",
80
+ backgroundImage: "none",
81
+ "& .MuiAppBar-root": {
82
+ backgroundImage: "none",
83
+ backgroundColor: "transparent"
84
+ },
85
+ ...l
86
+ },
87
+ children: /* @__PURE__ */ S(Bt, { sx: { minHeight: "62px !important" }, children: [
88
+ /* @__PURE__ */ r(V, { sx: { mr: 1, display: "flex", alignItems: "center" }, children: t }),
89
+ /* @__PURE__ */ S(V, { sx: { display: "flex", alignItems: "center", flexGrow: 1 }, children: [
90
+ /* @__PURE__ */ r(j, { component: "h1", variant: "subtitle1", children: o }),
91
+ i.length > 0 && /* @__PURE__ */ r(
92
+ Nt,
93
+ {
94
+ icon: /* @__PURE__ */ r(Ft, { size: 20 }),
95
+ ariaLabel: "switch app",
96
+ "aria-controls": "app-menu",
97
+ "aria-haspopup": "true",
98
+ onClick: p,
99
+ disabled: a,
100
+ sx: { ml: 1 }
101
+ }
102
+ )
103
+ ] })
104
+ ] })
105
+ }
106
+ ),
107
+ /* @__PURE__ */ r(
108
+ Mt,
109
+ {
110
+ open: g,
111
+ onClick: m,
112
+ sx: {
113
+ backdropFilter: "blur(4px)",
114
+ backgroundColor: $t,
115
+ zIndex: (c) => c.zIndex.modal - 1
116
+ }
117
+ }
118
+ ),
119
+ /* @__PURE__ */ r(
120
+ Lt,
121
+ {
122
+ id: "app-menu",
123
+ anchorEl: s,
124
+ open: g,
125
+ onClose: m,
126
+ anchorOrigin: {
127
+ vertical: "bottom",
128
+ horizontal: "left"
129
+ },
130
+ transformOrigin: {
131
+ vertical: "top",
132
+ horizontal: "left"
133
+ },
134
+ sx: {
135
+ zIndex: (c) => c.zIndex.modal,
136
+ "& .MuiPaper-root": {
137
+ minWidth: 200,
138
+ mt: 1
139
+ }
140
+ },
141
+ children: i.map((c) => /* @__PURE__ */ S($, { onClick: () => d(c), children: [
142
+ /* @__PURE__ */ r(V, { sx: { display: "flex", alignItems: "center" }, children: c.icon }),
143
+ /* @__PURE__ */ r(j, { variant: "body1", sx: { ml: 2 }, children: c.name })
144
+ ] }, c.id))
145
+ }
146
+ )
147
+ ] });
148
+ })
149
+ ), fe = ({
150
+ title: e,
151
+ titleId: t,
152
+ ...o
153
+ }, i) => /* @__PURE__ */ C.createElement("svg", { width: 21, height: 21, viewBox: "0 0 21 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("g", { id: "JogMinus" }, /* @__PURE__ */ C.createElement("path", { id: "Minus", d: "M0 13V8H21V13H0Z", fill: "white" }))), ye = N(fe), be = ({
154
+ title: e,
155
+ titleId: t,
156
+ ...o
157
+ }, i) => /* @__PURE__ */ C.createElement("svg", { width: 21, height: 21, viewBox: "0 0 21 21", fill: "none", xmlns: "http://www.w3.org/2000/svg", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("g", { id: "JogPlus" }, /* @__PURE__ */ C.createElement("g", { id: "Plus" }, /* @__PURE__ */ C.createElement("path", { d: "M0 13V8H8V13H0Z", fill: "white" }), /* @__PURE__ */ C.createElement("path", { d: "M8 0L13 2.18557e-07L13 21H8L8 0Z", fill: "white" }), /* @__PURE__ */ C.createElement("path", { d: "M13 13V8H21V13H13Z", fill: "white" })))), Se = N(be), vt = Z(
158
+ k(
159
+ ({
160
+ colors: e,
161
+ label: t,
162
+ getDisplayedValue: o,
163
+ startJogging: i,
164
+ stopJogging: n,
165
+ disabled: a,
166
+ activeJoggingDirection: l,
167
+ ...s
168
+ }) => {
169
+ var M, _, J, E, R, L, B;
170
+ ht(() => {
171
+ const T = o(), O = d.current;
172
+ O && (O.textContent = T);
173
+ });
174
+ const h = z(), [g, p] = Y(null);
175
+ ot(() => {
176
+ a && I();
177
+ }, [a]);
178
+ const m = l || g, d = nt(null);
179
+ e || (e = {
180
+ color: "#fff",
181
+ backgroundColor: "#000",
182
+ borderColor: "#000",
183
+ buttonBackgroundColor: {
184
+ disabled: "#000",
185
+ default: "#000",
186
+ hovered: "#000",
187
+ pressed: "#000"
188
+ },
189
+ labelColor: "#000"
190
+ });
191
+ const c = m ? (M = e.buttonBackgroundColor) == null ? void 0 : M.pressed : e.borderColor, f = {
192
+ width: "55px",
193
+ color: e.color,
194
+ path: { fill: e.color },
195
+ alignContent: "center",
196
+ fontSize: "37px",
197
+ svg: {
198
+ pointerEvents: "none"
199
+ }
200
+ }, y = {
201
+ ...f,
202
+ backgroundColor: (_ = e.buttonBackgroundColor) == null ? void 0 : _.default,
203
+ ":hover": {
204
+ backgroundColor: (J = e.buttonBackgroundColor) == null ? void 0 : J.hovered
205
+ },
206
+ ":active": {
207
+ backgroundColor: (E = e.buttonBackgroundColor) == null ? void 0 : E.pressed,
208
+ color: e.backgroundColor,
209
+ path: { fill: e.backgroundColor }
210
+ },
211
+ ":disabled": {
212
+ backgroundColor: (R = e.buttonBackgroundColor) == null ? void 0 : R.disabled,
213
+ "svg path": { fill: h.palette.action.disabled }
214
+ }
215
+ }, u = {
216
+ ...f,
217
+ backgroundColor: (L = e.buttonBackgroundColor) == null ? void 0 : L.pressed,
218
+ color: e.backgroundColor,
219
+ path: { fill: e.backgroundColor },
220
+ ":disabled": {
221
+ backgroundColor: (B = e.buttonBackgroundColor) == null ? void 0 : B.pressed,
222
+ "svg path": { fill: h.palette.action.disabled }
223
+ }
224
+ };
225
+ function b(T, O) {
226
+ a || T.button === 0 && (p(O), i(O));
227
+ }
228
+ function I() {
229
+ p(null), n();
230
+ }
231
+ return /* @__PURE__ */ S(w, { height: "64px", direction: "row", justifyContent: "center", ...s, children: [
232
+ /* @__PURE__ */ r(
233
+ it,
234
+ {
235
+ disabled: a,
236
+ disableRipple: !0,
237
+ onPointerDown: (T) => b(T, "-"),
238
+ onPointerUp: I,
239
+ onPointerOut: I,
240
+ size: "large",
241
+ sx: {
242
+ ...m === "-" ? u : y,
243
+ borderRadius: "16px 0px 0px 16px",
244
+ borderLeft: `2px solid ${c ?? "#fff"}`,
245
+ borderBottom: `2px solid ${c ?? "#fff"}`,
246
+ borderTop: `2px solid ${c ?? "#fff"}`
247
+ },
248
+ children: /* @__PURE__ */ r(ye, {})
249
+ }
250
+ ),
251
+ /* @__PURE__ */ S(
252
+ w,
253
+ {
254
+ spacing: "6px",
255
+ sx: {
256
+ width: "150px",
257
+ backgroundColor: e.backgroundColor,
258
+ alignItems: "center",
259
+ justifyContent: "center",
260
+ opacity: "0.9",
261
+ borderBottom: `2px solid ${c ?? "#fff"}`,
262
+ borderTop: `2px solid ${c ?? "#fff"}`
263
+ },
264
+ children: [
265
+ /* @__PURE__ */ r(
266
+ w,
267
+ {
268
+ height: "22px",
269
+ direction: "row",
270
+ alignItems: "center",
271
+ justifyItems: "center",
272
+ spacing: 1,
273
+ sx: {
274
+ userSelect: "none",
275
+ color: e.color,
276
+ ".MuiTypography-root": {
277
+ fontWeight: 700,
278
+ ...a ? { color: h.palette.action.disabled } : {}
279
+ },
280
+ ...a ? { "svg path": { fill: h.palette.action.disabled } } : {}
281
+ },
282
+ children: t
283
+ }
284
+ ),
285
+ /* @__PURE__ */ r(
286
+ j,
287
+ {
288
+ height: "22px",
289
+ sx: {
290
+ fontSize: "15px",
291
+ color: a ? h.palette.action.disabled : e.color,
292
+ fontWeight: 700,
293
+ fontVariantNumeric: "tabular-nums",
294
+ minWidth: "80px",
295
+ textAlign: "center"
296
+ },
297
+ ref: d,
298
+ children: o()
299
+ }
300
+ )
301
+ ]
302
+ }
303
+ ),
304
+ /* @__PURE__ */ r(
305
+ it,
306
+ {
307
+ disableRipple: !0,
308
+ disabled: a,
309
+ onPointerDown: (T) => b(T, "+"),
310
+ onPointerUp: I,
311
+ onPointerOut: I,
312
+ size: "large",
313
+ sx: {
314
+ ...m === "+" ? u : y,
315
+ borderRadius: "0px 16px 16px 0px",
316
+ borderRight: `2px solid ${c ?? "#fff"}`,
317
+ borderBottom: `2px solid ${c ?? "#fff"}`,
318
+ borderTop: `2px solid ${c ?? "#fff"}`
319
+ },
320
+ children: /* @__PURE__ */ r(Se, {})
321
+ }
322
+ )
323
+ ] });
324
+ }
325
+ )
326
+ ), q = "rgba(255, 255, 255, 1)", at = {
327
+ X: {
328
+ backgroundColor: "rgba(215, 66, 56, 1)",
329
+ borderColor: "rgba(215, 66, 56, 1)",
330
+ buttonBackgroundColor: {
331
+ default: "rgba(241, 77, 66, 1)",
332
+ pressed: "rgba(138, 41, 35, 1)",
333
+ hovered: "rgba(241, 77, 66, 1)",
334
+ disabled: "rgba(241, 77, 66, 1)"
335
+ },
336
+ color: "rgba(255, 198, 198, 1)",
337
+ labelColor: q
338
+ },
339
+ Y: {
340
+ backgroundColor: "rgba(20, 151, 108, 1)",
341
+ borderColor: "rgba(20, 151, 108, 1)",
342
+ buttonBackgroundColor: {
343
+ default: "rgba(28, 188, 135, 1)",
344
+ pressed: "rgba(11, 89, 63, 1)",
345
+ disabled: "rgba(28, 188, 135, 1)",
346
+ hovered: "rgba(28, 188, 135, 1)"
347
+ },
348
+ color: "rgba(215, 255, 242, 1)",
349
+ labelColor: q
350
+ },
351
+ Z: {
352
+ backgroundColor: "rgba(1, 87, 155, 1)",
353
+ borderColor: "rgba(1, 87, 155, 1)",
354
+ buttonBackgroundColor: {
355
+ default: "rgba(2, 136, 209, 1)",
356
+ pressed: "rgba(2, 64, 114, 1)",
357
+ disabled: "rgba(2, 136, 209, 1)",
358
+ hovered: "rgba(2, 136, 209, 1)"
359
+ },
360
+ color: "rgba(210, 239, 255, 1)",
361
+ labelColor: q
362
+ }
363
+ }, xt = q, ve = q, xe = Z(
364
+ k(
365
+ ({
366
+ startJogging: e,
367
+ stopJogging: t,
368
+ lowerLimit: o,
369
+ upperLimit: i,
370
+ useDegree: n,
371
+ getValue: a,
372
+ disabled: l,
373
+ ...s
374
+ }) => {
375
+ var E, R, L, B, T, O, X;
376
+ const { t: h } = D(), [g, p] = Y(), m = z(), d = {
377
+ background: (E = m.palette.backgroundPaperElevation) == null ? void 0 : E[4],
378
+ color: (R = m.palette.backgroundPaperElevation) == null ? void 0 : R[11]
379
+ }, c = jt(() => ({
380
+ activeJoggingDir: null,
381
+ startJogging(v) {
382
+ this.activeJoggingDir = v, e(v);
383
+ },
384
+ stopJogging() {
385
+ this.activeJoggingDir = null, t();
386
+ }
387
+ })), f = de(() => {
388
+ const v = n ? y(a()) : a();
389
+ (v === void 0 || g === void 0 || Math.abs(g - v) > 1e-9) && p(v);
390
+ }, 50);
391
+ ht(f);
392
+ function y(v) {
393
+ if (v !== void 0)
394
+ return _t(v);
395
+ }
396
+ function u(v) {
397
+ v.button === 0 && c.startJogging("-");
398
+ }
399
+ function b(v) {
400
+ v.button === 0 && c.startJogging("+");
401
+ }
402
+ function I(v) {
403
+ c.stopJogging();
404
+ }
405
+ function M(v) {
406
+ c.stopJogging();
407
+ }
408
+ function _(v, G = 1) {
409
+ if (v === void 0 || Number.isNaN(v)) return "";
410
+ const U = h("General.degree.variable", {
411
+ amount: v.toFixed(G)
412
+ });
413
+ return v > 0 && G === 0 ? `+${U}` : U;
414
+ }
415
+ function J(v, G = 1) {
416
+ if (v === void 0 || Number.isNaN(v)) return "";
417
+ const U = h("General.mm.variable", {
418
+ amount: v.toFixed(G)
419
+ });
420
+ return v > 0 && G === 0 ? `+${U}` : U;
421
+ }
422
+ return /* @__PURE__ */ S(
423
+ w,
424
+ {
425
+ height: "64px",
426
+ width: "100%",
427
+ maxWidth: "260px",
428
+ direction: "row",
429
+ ...s,
430
+ sx: {
431
+ "& .MuiIconButton-root": {
432
+ width: "52px",
433
+ color: m.palette.text.primary,
434
+ alignContent: "center",
435
+ backgroundColor: (L = m.palette.backgroundPaperElevation) == null ? void 0 : L[11],
436
+ "& svg": {
437
+ width: "42px",
438
+ height: "42px"
439
+ },
440
+ "&.Mui-disabled": {
441
+ backgroundColor: (B = m.palette.backgroundPaperElevation) == null ? void 0 : B[11],
442
+ color: m.palette.action.disabled,
443
+ opacity: 1
444
+ },
445
+ "&:hover": {
446
+ backgroundColor: (T = m.palette.backgroundPaperElevation) == null ? void 0 : T[9]
447
+ },
448
+ "&:active": {
449
+ ...d
450
+ }
451
+ }
452
+ },
453
+ children: [
454
+ /* @__PURE__ */ r(
455
+ it,
456
+ {
457
+ onPointerDown: u,
458
+ onPointerUp: I,
459
+ onPointerOut: M,
460
+ disabled: l,
461
+ disableRipple: !0,
462
+ sx: {
463
+ borderRadius: "16px 0px 0px 16px",
464
+ ...c.activeJoggingDir === "-" ? d : {}
465
+ },
466
+ children: /* @__PURE__ */ r(
467
+ ce,
468
+ {
469
+ sx: {
470
+ pointerEvents: "none",
471
+ color: xt
472
+ }
473
+ }
474
+ )
475
+ }
476
+ ),
477
+ /* @__PURE__ */ S(
478
+ w,
479
+ {
480
+ flexGrow: 1,
481
+ alignItems: "center",
482
+ justifyContent: "center",
483
+ sx: {
484
+ borderStyle: "solid",
485
+ borderLeftWidth: 0,
486
+ borderRightWidth: 0,
487
+ border: "none",
488
+ backgroundColor: (O = m.palette.backgroundPaperElevation) == null ? void 0 : O[11],
489
+ paddingLeft: "20px",
490
+ paddingRight: "20px",
491
+ zIndex: 1
492
+ },
493
+ children: [
494
+ /* @__PURE__ */ r(
495
+ j,
496
+ {
497
+ sx: {
498
+ fontSize: "15px",
499
+ fontWeight: 700,
500
+ position: "relative",
501
+ top: "5px",
502
+ fontVariantNumeric: "tabular-nums",
503
+ minWidth: "80px",
504
+ textAlign: "center",
505
+ color: l ? m.palette.action.disabled : m.palette.text.primary
506
+ },
507
+ children: n ? _(g) : J(g)
508
+ }
509
+ ),
510
+ /* @__PURE__ */ r(
511
+ Tt,
512
+ {
513
+ disabled: !0,
514
+ "aria-label": "Joint position",
515
+ min: n ? y(o) : o,
516
+ max: n ? y(i) : i,
517
+ value: g || 0,
518
+ track: !1,
519
+ sx: {
520
+ "& .MuiSlider-mark": {
521
+ display: "none"
522
+ },
523
+ "& .MuiSlider-thumb": {
524
+ width: "5px",
525
+ height: "12px",
526
+ borderRadius: "2px",
527
+ color: l ? m.palette.action.disabled : m.palette.text.primary
528
+ },
529
+ "& .MuiSlider-markLabel": {
530
+ top: "20px",
531
+ fontSize: "12px",
532
+ color: l ? m.palette.action.disabled : m.palette.text.secondary
533
+ },
534
+ "& .MuiSlider-rail": {
535
+ backgroundColor: (X = m.palette.backgroundPaperElevation) == null ? void 0 : X[5],
536
+ opacity: 1
537
+ }
538
+ },
539
+ marks: o !== void 0 && i !== void 0 && [
540
+ {
541
+ value: n ? y(o) : o,
542
+ label: n ? _(y(o), 0) : J(o)
543
+ },
544
+ {
545
+ value: n ? y(i) : i,
546
+ label: n ? _(y(i), 0) : J(i)
547
+ }
548
+ ]
549
+ }
550
+ )
551
+ ]
552
+ }
553
+ ),
554
+ /* @__PURE__ */ r(
555
+ it,
556
+ {
557
+ onPointerDown: b,
558
+ onPointerUp: I,
559
+ onPointerOut: M,
560
+ disabled: l,
561
+ disableRipple: !0,
562
+ sx: {
563
+ borderRadius: "0px 16px 16px 0px",
564
+ ...c.activeJoggingDir === "+" ? d : {}
565
+ },
566
+ children: /* @__PURE__ */ r(
567
+ ge,
568
+ {
569
+ sx: {
570
+ pointerEvents: "none",
571
+ color: xt
572
+ }
573
+ }
574
+ )
575
+ }
576
+ )
577
+ ]
578
+ }
579
+ );
580
+ }
581
+ )
582
+ );
583
+ function Jt(e, t, o) {
584
+ if (t.length !== e.length)
585
+ return !0;
586
+ for (let i = 0; i < t.length; i++)
587
+ if (
588
+ // biome-ignore lint/style/noNonNullAssertion: legacy code
589
+ Math.abs(t[i] - e[i]) > o
590
+ )
591
+ return !1;
592
+ return !0;
593
+ }
594
+ function Ce(e, t, o) {
595
+ if (e === void 0 && t || e && t === void 0 || (e == null ? void 0 : e.orientation) === void 0 || (t == null ? void 0 : t.orientation) === void 0 || (e == null ? void 0 : e.position) === void 0 || (t == null ? void 0 : t.position) === void 0)
596
+ return !1;
597
+ if (e === void 0 || t === void 0)
598
+ return !0;
599
+ let i = 0;
600
+ return i += Math.abs(e.orientation[0] - t.orientation[0]), i += Math.abs(e.orientation[1] - t.orientation[1]), i += Math.abs(e.orientation[2] - t.orientation[2]), i += Math.abs(e.position[0] - t.position[0]), i += Math.abs(e.position[1] - t.position[1]), i += Math.abs(e.position[2] - t.position[2]), i <= o;
601
+ }
602
+ function Rt(e, t, o) {
603
+ return e.coordinate_system === t.coordinate_system && e.tcp === t.tcp && Ce(
604
+ e.tcp_pose,
605
+ t.tcp_pose,
606
+ o
607
+ );
608
+ }
609
+ function we(e, t) {
610
+ const o = new St(
611
+ t[0],
612
+ t[1],
613
+ t[2]
614
+ ), i = new St(
615
+ e[0],
616
+ e[1],
617
+ e[2]
618
+ ), n = o.length(), a = o.normalize();
619
+ let l = i.length(), s = i.normalize();
620
+ s.dot(a) < 0 && (l = -l, s = s.multiplyScalar(-1));
621
+ let h = l - n;
622
+ return h -= 2 * Math.PI * Math.floor((h + Math.PI) / (2 * Math.PI)), l = n + h, [...s.multiplyScalar(l)];
623
+ }
624
+ const Ct = 1e-4;
625
+ class mt {
626
+ constructor(t, o, i, n, a, l, s = "cell") {
627
+ this.controller = o, this.motionGroup = i, this.description = n, this.initialMotionState = a, this.motionStateSocket = l, this.cellId = s, this.nova = H(t), this.rapidlyChangingMotionState = a, l.addEventListener("message", (h) => {
628
+ var d;
629
+ const g = (d = P(h.data)) == null ? void 0 : d.result;
630
+ if (!g)
631
+ throw new Error(
632
+ `Failed to get motion state for ${this.motionGroupId}: ${h.data}`
633
+ );
634
+ Jt(
635
+ this.rapidlyChangingMotionState.joint_position,
636
+ g.joint_position,
637
+ Ct
638
+ ) || x(() => {
639
+ this.rapidlyChangingMotionState.joint_position = g.joint_position;
640
+ }), Rt(
641
+ this.rapidlyChangingMotionState,
642
+ g,
643
+ Ct
644
+ ) || x(() => {
645
+ var c, f, y;
646
+ this.rapidlyChangingMotionState.tcp_pose == null ? this.rapidlyChangingMotionState.tcp_pose = g.tcp_pose : (c = g.tcp_pose) != null && c.orientation && ((f = g.tcp_pose) != null && f.position) && ((y = this.rapidlyChangingMotionState.tcp_pose) != null && y.orientation) ? this.rapidlyChangingMotionState.tcp_pose = {
647
+ position: g.tcp_pose.position,
648
+ orientation: we(
649
+ g.tcp_pose.orientation,
650
+ this.rapidlyChangingMotionState.tcp_pose.orientation
651
+ )
652
+ } : console.warn(
653
+ "Received incomplete tcp_pose, ignoring",
654
+ g.tcp_pose
655
+ );
656
+ }), g.tcp !== void 0 && this.rapidlyChangingMotionState.tcp !== g.tcp && x(() => {
657
+ this.rapidlyChangingMotionState.tcp = g.tcp;
658
+ }), this.rapidlyChangingMotionState.standstill !== g.standstill && x(() => {
659
+ this.rapidlyChangingMotionState.standstill = g.standstill;
660
+ });
661
+ const p = this.rapidlyChangingMotionState.joint_limit_reached.limit_reached, m = g.joint_limit_reached.limit_reached;
662
+ p.some((c, f) => c !== m[f]) && x(() => {
663
+ this.rapidlyChangingMotionState.joint_limit_reached = g.joint_limit_reached;
664
+ }), this.rapidlyChangingMotionState.execute !== g.execute && x(() => {
665
+ this.rapidlyChangingMotionState.execute = g.execute;
666
+ });
667
+ }), dt(this);
668
+ }
669
+ static async open(t, o, i = {}) {
670
+ var f;
671
+ const n = H(t), a = i.cellId ?? st(t) ?? "cell", [l, s] = o.split("@"), h = await n.api.controller.getCurrentRobotControllerState(
672
+ a,
673
+ s
674
+ ), g = h == null ? void 0 : h.motion_groups.find(
675
+ (y) => y.motion_group === o
676
+ );
677
+ if (!h || !g)
678
+ throw new Error(
679
+ `Controller ${s} or motion group ${o} not found`
680
+ );
681
+ const p = n.openReconnectingWebsocket(
682
+ `/cells/${a}/controllers/${s}/motion-groups/${o}/state-stream`
683
+ ), m = await p.firstMessage(), d = (f = P(m.data)) == null ? void 0 : f.result;
684
+ if (!d)
685
+ throw new Error(
686
+ `Unable to parse initial motion state message ${m.data}`
687
+ );
688
+ console.log(
689
+ `Connected motion state websocket to motion group ${g.motion_group}. Initial state:
690
+ `,
691
+ d
692
+ );
693
+ const c = await n.api.motionGroup.getMotionGroupDescription(
694
+ a,
695
+ s,
696
+ g.motion_group
697
+ );
698
+ return new mt(
699
+ n,
700
+ h,
701
+ g,
702
+ c,
703
+ d,
704
+ p,
705
+ a
706
+ );
707
+ }
708
+ get motionGroupId() {
709
+ return this.motionGroup.motion_group;
710
+ }
711
+ get controllerId() {
712
+ return this.controller.controller;
713
+ }
714
+ get joints() {
715
+ return this.initialMotionState.joint_position.map((t, o) => ({
716
+ index: o
717
+ }));
718
+ }
719
+ dispose() {
720
+ this.motionStateSocket.close();
721
+ }
722
+ }
723
+ const wt = "Movement request rejected. Another client is currently executing a 'Jogging' motion!";
724
+ class ut {
725
+ constructor(t, o = {}) {
726
+ this.motionStream = t, this.options = o, this.DEFAULT_MODE = "off", this.DEFAULT_TCP = "Flange", this.NO_TCP = void 0, this.DEFAULT_INIT_TIMEOUT = 5e3, this.DEFAULT_ORIENTATION = "coordsys", this.mode = "off", this.joggingSocket = null, this.trajectorySocket = null, this.timeout = this.DEFAULT_INIT_TIMEOUT, this.ownsMotionStream = !1, this.tcp = (o == null ? void 0 : o.tcp) || t.motionGroup.tcp || this.getDefaultTcp(t), this.orientation = (o == null ? void 0 : o.orientation) || this.DEFAULT_ORIENTATION, this.timeout = (o == null ? void 0 : o.timeout) || this.DEFAULT_INIT_TIMEOUT, this.mode = (o == null ? void 0 : o.mode) || this.DEFAULT_MODE, this.onError = o == null ? void 0 : o.onError;
727
+ }
728
+ /**
729
+ * Initialize the jogging connection using jogging endpoint or trajectory endpoint depending on the selected mode.
730
+ *
731
+ * @param connection - The base URL of a NOVA instance, or a NOVA client of the app (see `NovaConnection`)
732
+ * @param motionGroupId - The ID of the motion group to connect to
733
+ * @param options - Configuration options for the jogger connection
734
+ * @param options.mode - The jogging mode to initialize:
735
+ * - "jogging": Continuous jogging mode with persistent websocket for real-time velocity commands
736
+ * - "trajectory": Incremental jogging mode for fixed-distance motions via trajectory planning
737
+ * - "off": No jogging enabled, all websockets closed (default)
738
+ * @param options.timeout - Timeout in milliseconds for websocket initialization (default: 5000ms)
739
+ * @param options.tcp - TCP frame to use for motions (default: from motion group)
740
+ * //param options.coordinateSystem - Coordinate system for jogging commands (default: "world"). Please note: Currently not implemented
741
+ * @param options.orientation - If set to "tool", jogging TcpVelocityRequest will use `use_tool_coordinate_system` option (default: "coordsys")
742
+ * @param options.onError - Error handler for websocket errors
743
+ * @returns Promise resolving to initialized JoggerConnection instance. Its
744
+ * `dispose()` also closes the motion stream that this function opens.
745
+ */
746
+ static async open(t, o, i = {}) {
747
+ const n = await mt.open(
748
+ t,
749
+ o,
750
+ {
751
+ cellId: i.cellId
752
+ }
753
+ ), a = new ut(n, i);
754
+ a.ownsMotionStream = !0;
755
+ try {
756
+ await a.setJoggingMode(a.mode);
757
+ } catch (l) {
758
+ throw a.dispose(), l;
759
+ }
760
+ return a;
761
+ }
762
+ getDefaultTcp(t) {
763
+ var i, n;
764
+ const o = (n = (i = t.description.dh_parameters) == null ? void 0 : i[0]) == null ? void 0 : n.type;
765
+ return t.joints.length < 6 && (o === A.RevoluteJoint || o === A.PrismaticJoint) ? this.NO_TCP : this.DEFAULT_TCP;
766
+ }
767
+ // Set a new tcp or other options. If current mode is jogging, will reinitialize the jogging websocket
768
+ async setOptions(t) {
769
+ return t.tcp && (this.tcp = t.tcp), t.orientation && (this.orientation = t.orientation), t.timeout && (this.timeout = t.timeout), t.mode && (this.mode = t.mode), t.onError && (this.onError = t.onError), this.setJoggingMode(this.mode, !1);
770
+ }
771
+ get motionGroupId() {
772
+ return this.motionStream.motionGroupId;
773
+ }
774
+ /**
775
+ * The library's own NOVA client of the motion stream
776
+ * @internal
777
+ */
778
+ get nova() {
779
+ return this.motionStream.nova;
780
+ }
781
+ get cellId() {
782
+ return this.motionStream.cellId;
783
+ }
784
+ get numJoints() {
785
+ return this.motionStream.joints.length;
786
+ }
787
+ // get activeJoggingMode() {
788
+ // return this.mode
789
+ // }
790
+ // get activeWebsocket() {
791
+ // return this.mode === "jogging" ? this.joggingSocket : this.trajectorySocket;
792
+ // }
793
+ // Sends stop movement command to robot
794
+ async stop() {
795
+ if (this.joggingSocket) {
796
+ const t = new Array(this.numJoints).fill(0);
797
+ this.joggingSocket.sendJson({
798
+ message_type: "JointVelocityRequest",
799
+ velocity: t
800
+ });
801
+ }
802
+ this.trajectorySocket && this.trajectorySocket.sendJson({
803
+ message_type: "PauseMovementRequest"
804
+ });
805
+ }
806
+ /**
807
+ * Dispose the jogger, closing all open websockets: the jogging websockets,
808
+ * and the motion stream if the jogger opened it (in `open()`). A motion
809
+ * stream given to the constructor stays open: its caller closes it.
810
+ */
811
+ async dispose() {
812
+ const t = this.closeJoggingSockets();
813
+ return this.ownsMotionStream && this.motionStream.dispose(), t;
814
+ }
815
+ /** Closes the jogging and trajectory websockets */
816
+ closeJoggingSockets() {
817
+ var o;
818
+ (o = this.endJoggingInit) == null || o.call(this);
819
+ const t = [this.joggingSocket, this.trajectorySocket].filter(
820
+ (i) => i !== null
821
+ );
822
+ return t.forEach((i) => {
823
+ i.dispose();
824
+ }), this.joggingSocket = null, this.trajectorySocket = null, Promise.all(t.map((i) => i.closed()));
825
+ }
826
+ // Activate jogger in one of the supported modes
827
+ // Will iniitialize or close websockets as necessary
828
+ // If mode is unchanged, does nothing (unless skipReinitializeIfSameMode is false)
829
+ async setJoggingMode(t, o = !0) {
830
+ if (!(this.mode === t && o) && (this.closeJoggingSockets(), this.mode = t, this.mode === "jogging"))
831
+ return this.initializeJoggingWebsocket();
832
+ }
833
+ /**
834
+ * Opens the continuous jogging websocket and initializes it; called by
835
+ * `setJoggingMode("jogging")`. The promise settles once:
836
+ * - it resolves when NOVA confirms the initialization (INITIALIZE_RECEIVED),
837
+ * when the jogger closes the websocket before that (`setJoggingMode`,
838
+ * `dispose`), or when an error message goes to `onBlocked` or `onError`;
839
+ * - it rejects on an error message without such a handler, and when NOVA
840
+ * does not confirm the initialization within `timeout` milliseconds.
841
+ */
842
+ async initializeJoggingWebsocket() {
843
+ return new Promise((t, o) => {
844
+ const i = this.nova.openReconnectingWebsocket(
845
+ `/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/jogging`
846
+ );
847
+ this.joggingSocket = i;
848
+ let n = !1;
849
+ const a = setTimeout(() => {
850
+ l(
851
+ new Error(`Jogging initialization timeout after ${this.timeout} ms`)
852
+ );
853
+ }, this.timeout), l = (g) => {
854
+ n || (n = !0, clearTimeout(a), i.removeEventListener("close", h), this.endJoggingInit === s && (this.endJoggingInit = void 0), g ? o(g) : t());
855
+ }, s = () => l(), h = () => {
856
+ i.disposed && l();
857
+ };
858
+ this.endJoggingInit = s, i.addEventListener("close", h), i.addEventListener("message", (g) => {
859
+ var m, d, c;
860
+ const p = P(g.data);
861
+ if (((m = p == null ? void 0 : p.result) == null ? void 0 : m.kind) === "INITIALIZE_RECEIVED") {
862
+ l();
863
+ return;
864
+ }
865
+ if (((d = p == null ? void 0 : p.result) == null ? void 0 : d.kind) === "MOTION_ERROR")
866
+ if (this.onBlocked && ((c = p == null ? void 0 : p.result) != null && c.message.includes(wt))) {
867
+ l(), i.dispose(), this.onBlocked();
868
+ return;
869
+ } else this.onError ? (l(), this.onError(g.data)) : l(new Error(g.data));
870
+ }), i.sendJson({
871
+ message_type: "InitializeJoggingRequest",
872
+ motion_group: this.motionGroupId,
873
+ ...this.tcp ? { tcp: this.tcp } : {}
874
+ });
875
+ });
876
+ }
877
+ /**
878
+ * Jogging: Start rotation of a single robot joint at the specified velocity
879
+ */
880
+ async rotateJoints({
881
+ joint: t,
882
+ direction: o,
883
+ velocityValue: i,
884
+ velocityUnit: n
885
+ }) {
886
+ if (!this.joggingSocket || this.mode !== "jogging")
887
+ throw new Error(
888
+ "Joint jogging websocket not connected; create one by setting jogging mode to 'jogging'"
889
+ );
890
+ const a = new Array(this.numJoints).fill(0);
891
+ a[t] = o === "-" ? -i : i, this.joggingSocket.sendJson({
892
+ message_type: "JointVelocityRequest",
893
+ velocity: a
894
+ });
895
+ }
896
+ /**
897
+ * Jogging: Start the TCP moving along a specified axis at a given velocity
898
+ */
899
+ async translateTCP({
900
+ axis: t,
901
+ direction: o,
902
+ velocityMmPerSec: i
903
+ }) {
904
+ if (!this.joggingSocket || this.mode !== "jogging")
905
+ throw new Error(
906
+ "Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'"
907
+ );
908
+ const n = [0, 0, 0], a = [0, 0, 0];
909
+ a[W[t]] = o === "-" ? -i : i, this.joggingSocket.sendJson({
910
+ message_type: "TcpVelocityRequest",
911
+ translation: a,
912
+ rotation: n,
913
+ use_tool_coordinate_system: this.orientation === "tool"
914
+ });
915
+ }
916
+ /**
917
+ * Jogging: Start the TCP rotating around a specified axis at a given velocity
918
+ */
919
+ async rotateTCP({
920
+ axis: t,
921
+ direction: o,
922
+ velocityRadsPerSec: i
923
+ }) {
924
+ if (!this.joggingSocket || this.mode !== "jogging")
925
+ throw new Error(
926
+ "Continuous jogging websocket not connected; create one by setting jogging mode to 'jogging'"
927
+ );
928
+ const n = [0, 0, 0], a = [0, 0, 0];
929
+ n[W[t]] = o === "-" ? -i : i, this.joggingSocket.sendJson({
930
+ message_type: "TcpVelocityRequest",
931
+ translation: a,
932
+ rotation: n,
933
+ use_tool_coordinate_system: this.orientation === "tool"
934
+ });
935
+ }
936
+ /**
937
+ * Trajectory jogging:
938
+ *
939
+ * Move the robot by a fixed distance in a single cartesian
940
+ * axis, either rotating or translating relative to the TCP.
941
+ * Promise resolves only after the motion has completed.
942
+ */
943
+ async runIncrementalCartesianMotion({
944
+ currentTcpPose: t,
945
+ currentJoints: o,
946
+ // coordSystemId,
947
+ velocityInRelevantUnits: i,
948
+ axis: n,
949
+ direction: a,
950
+ motion: l
951
+ }) {
952
+ const s = [];
953
+ if (this.mode !== "trajectory")
954
+ throw new Error(
955
+ "Set jogging mode to 'trajectory' to run incremental cartesian motions"
956
+ );
957
+ if (l.type === "translate") {
958
+ if (!t.position)
959
+ throw new Error(
960
+ "Current pose has no position, cannot perform translation"
961
+ );
962
+ const u = [...t.position];
963
+ u[W[n]] += l.distanceMm * (a === "-" ? -1 : 1), s.push({
964
+ limits_override: {
965
+ tcp_velocity_limit: i
966
+ },
967
+ path: {
968
+ path_definition_name: "PathLine",
969
+ target_pose: {
970
+ position: u,
971
+ orientation: t.orientation
972
+ }
973
+ }
974
+ });
975
+ } else if (l.type === "rotate") {
976
+ if (!t.orientation)
977
+ throw new Error(
978
+ "Current pose has no orientation, cannot perform rotation"
979
+ );
980
+ const u = new rt(
981
+ t.orientation[0],
982
+ t.orientation[1],
983
+ t.orientation[2]
984
+ ), b = u.length(), I = u.clone().normalize(), M = l.distanceRads * (a === "-" ? -1 : 1), _ = new rt(0, 0, 0);
985
+ _[n] = 1;
986
+ const J = Math.cos(0.5 * M) * Math.cos(0.5 * b), E = Math.sin(0.5 * M) * Math.sin(0.5 * b), R = Math.sin(0.5 * M) * Math.cos(0.5 * b), L = Math.cos(0.5 * M) * Math.sin(0.5 * b), B = _.dot(
987
+ I
988
+ ), T = _.clone().cross(I), O = 2 * Math.acos(J - E * B), X = O / Math.sin(0.5 * O), v = new rt().addScaledVector(T, E).addScaledVector(_, R).addScaledVector(I, L).multiplyScalar(X);
989
+ s.push({
990
+ limits_override: {
991
+ tcp_orientation_velocity_limit: i
992
+ },
993
+ path: {
994
+ path_definition_name: "PathLine",
995
+ target_pose: {
996
+ position: t.position,
997
+ orientation: [...v]
998
+ }
999
+ }
1000
+ });
1001
+ }
1002
+ const h = this.motionStream.description;
1003
+ if (h.cycle_time === void 0) {
1004
+ console.warn(
1005
+ "Current motion group has no cycle time, cannot plan jogging motion"
1006
+ );
1007
+ return;
1008
+ }
1009
+ const g = {
1010
+ motion_group_model: h.motion_group_model,
1011
+ cycle_time: h.cycle_time,
1012
+ mounting: h.mounting,
1013
+ // tcp_offset: description.tcp_offset, TODO: implement tcp_offset handling
1014
+ // FIXME use proper mode's limits if set
1015
+ global: h.operation_limits.auto_limits
1016
+ }, p = await this.nova.api.trajectoryPlanning.planTrajectory(
1017
+ this.cellId,
1018
+ {
1019
+ motion_group_setup: g,
1020
+ start_joint_position: o,
1021
+ motion_commands: s
1022
+ }
1023
+ ), m = p.response;
1024
+ if (!m)
1025
+ throw new Error(
1026
+ `Failed to plan jogging increment motion ${JSON.stringify(p)}`
1027
+ );
1028
+ this.trajectorySocket && (console.warn("Trajectory jogging websocket already open; will close"), this.trajectorySocket.dispose()), this.trajectorySocket = this.nova.openReconnectingWebsocket(
1029
+ `/cells/${this.cellId}/controllers/${this.motionStream.controllerId}/execution/trajectory`
1030
+ );
1031
+ const d = (u) => {
1032
+ var b;
1033
+ if (!u || u.add_trajectory_error || u.message)
1034
+ if (this.onError)
1035
+ this.onError(u);
1036
+ else
1037
+ throw new Error(
1038
+ ((b = u == null ? void 0 : u.add_trajectory_error) == null ? void 0 : b.message) || (u == null ? void 0 : u.message) || "Failed to execute trajectory, unknown error"
1039
+ );
1040
+ if (!this.trajectorySocket)
1041
+ throw new Error(
1042
+ "Failed to execute trajectory, websocket not available anymore"
1043
+ );
1044
+ this.trajectorySocket.sendJson({
1045
+ message_type: "StartMovementRequest",
1046
+ direction: "DIRECTION_FORWARD"
1047
+ });
1048
+ }, c = async () => {
1049
+ var u;
1050
+ await tt(() => !this.motionStream.rapidlyChangingMotionState.standstill), await tt(() => this.motionStream.rapidlyChangingMotionState.standstill), (u = this.trajectorySocket) == null || u.dispose(), this.trajectorySocket = null;
1051
+ }, f = async () => {
1052
+ var u;
1053
+ await tt(() => this.motionStream.rapidlyChangingMotionState.standstill), (u = this.trajectorySocket) == null || u.dispose(), this.trajectorySocket = null;
1054
+ }, y = async (u) => {
1055
+ if (u != null && u.message)
1056
+ if (this.onError) {
1057
+ this.onError(u);
1058
+ return;
1059
+ } else
1060
+ throw new Error(
1061
+ u.message || "Failed to execute trajectory, unknown error"
1062
+ );
1063
+ this.motionStream.rapidlyChangingMotionState.standstill ? await c() : await f();
1064
+ };
1065
+ this.trajectorySocket.addEventListener("message", (u) => {
1066
+ var I, M;
1067
+ const b = P(u.data);
1068
+ if (!((I = b == null ? void 0 : b.result) != null && I.kind))
1069
+ throw new Error(
1070
+ `Failed to execute trajectory: Received invalid message ${u.data}`
1071
+ );
1072
+ if (this.onBlocked && ((M = b.result.message) != null && M.includes(wt))) {
1073
+ this.onBlocked();
1074
+ return;
1075
+ }
1076
+ if (b.result.kind === "INITIALIZE_RECEIVED")
1077
+ d(b.result);
1078
+ else if (b.result.kind === "START_RECEIVED")
1079
+ y(b);
1080
+ else if (b.result.kind !== "PAUSE_RECEIVED") if (b.result.kind === "MOTION_ERROR" && b.result.message)
1081
+ if (this.onError) {
1082
+ this.onError(b);
1083
+ return;
1084
+ } else
1085
+ throw new Error(b.result.message);
1086
+ else
1087
+ throw new Error(
1088
+ `Failed to execute trajectory, cannot handle message type "${b.result.kind}"`
1089
+ );
1090
+ }), this.trajectorySocket.sendJson({
1091
+ message_type: "InitializeMovementRequest",
1092
+ trajectory: {
1093
+ message_type: "TrajectoryData",
1094
+ motion_group: this.motionGroupId,
1095
+ data: m,
1096
+ tcp: this.tcp
1097
+ }
1098
+ });
1099
+ }
1100
+ }
1101
+ const Ie = (e) => {
1102
+ const t = e.softTimeout || 3e3, [o, i] = Y(!1);
1103
+ return ot(() => {
1104
+ const n = setTimeout(() => {
1105
+ i(!0);
1106
+ }, t);
1107
+ return () => clearTimeout(n);
1108
+ }), /* @__PURE__ */ r(
1109
+ w,
1110
+ {
1111
+ width: "100%",
1112
+ height: "100%",
1113
+ alignItems: "center",
1114
+ justifyContent: "center",
1115
+ sx: { color: "text.primary" },
1116
+ children: e.error ? /* @__PURE__ */ r(
1117
+ Me,
1118
+ {
1119
+ loadingMessage: e.message,
1120
+ error: e.error
1121
+ }
1122
+ ) : /* @__PURE__ */ S(et, { children: [
1123
+ /* @__PURE__ */ r(kt, { sx: { mb: 3 } }),
1124
+ !!e.message && /* @__PURE__ */ r(j, { variant: "body1", children: e.message }),
1125
+ /* @__PURE__ */ r(
1126
+ j,
1127
+ {
1128
+ variant: "body2",
1129
+ sx: {
1130
+ visibility: o ? "visible" : "hidden",
1131
+ mt: 2,
1132
+ color: "text.secondary"
1133
+ },
1134
+ children: "This is taking longer than expected..."
1135
+ }
1136
+ )
1137
+ ] })
1138
+ }
1139
+ );
1140
+ }, Me = (e) => {
1141
+ const t = Kt(e.error), o = e.error instanceof Error ? e.error.stack : null;
1142
+ return /* @__PURE__ */ S(
1143
+ w,
1144
+ {
1145
+ sx: {
1146
+ maxHeight: "100%",
1147
+ maxWidth: "min(100%, 800px)",
1148
+ p: 2,
1149
+ overflow: "auto",
1150
+ color: "error.main"
1151
+ },
1152
+ children: [
1153
+ /* @__PURE__ */ r(j, { variant: "body1", children: (e.loadingMessage ? `Error while ${Zt(Yt(e.loadingMessage))} - ` : "") + t }),
1154
+ o && /* @__PURE__ */ r(
1155
+ V,
1156
+ {
1157
+ component: "pre",
1158
+ sx: {
1159
+ typography: "body2",
1160
+ fontFamily: "monospace",
1161
+ whiteSpace: "pre-wrap",
1162
+ wordBreak: "break-word",
1163
+ mt: 2,
1164
+ pb: 6
1165
+ },
1166
+ children: o
1167
+ }
1168
+ )
1169
+ ]
1170
+ }
1171
+ );
1172
+ }, je = k(({ store: e }) => {
1173
+ const { t } = D();
1174
+ return /* @__PURE__ */ r(
1175
+ Mt,
1176
+ {
1177
+ "data-testid": "jogging-blocked",
1178
+ "aria-label": "jogging-blocked",
1179
+ open: !0,
1180
+ sx: {
1181
+ position: "absolute",
1182
+ zIndex: (o) => o.zIndex.drawer + 1,
1183
+ color: "#fff",
1184
+ background: "rgba(15, 15, 15, 0.88)",
1185
+ justifyContent: "flex-start",
1186
+ alignItems: "flex-start"
1187
+ },
1188
+ children: /* @__PURE__ */ S(w, { sx: { m: 2, width: "100%" }, children: [
1189
+ /* @__PURE__ */ S(Qt, { severity: "error", sx: { mb: 2 }, children: [
1190
+ /* @__PURE__ */ r(te, { children: t("Jogging.Blocked.ti") }),
1191
+ t("Jogging.Blocked.lb")
1192
+ ] }),
1193
+ /* @__PURE__ */ r(
1194
+ lt,
1195
+ {
1196
+ variant: "contained",
1197
+ color: "secondary",
1198
+ onClick: () => e.unblock(),
1199
+ children: t("Jogging.Blocked.Reenable.bt")
1200
+ }
1201
+ )
1202
+ ] })
1203
+ }
1204
+ );
1205
+ }), _e = ({
1206
+ title: e,
1207
+ titleId: t,
1208
+ ...o
1209
+ }, i) => /* @__PURE__ */ C.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 19, height: 10, fill: "none", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("path", { fill: "#fff", fillRule: "evenodd", d: "M5.131.312a.9.9 0 0 1 0 1.272L3.07 3.645h12.44l-2.06-2.061A.9.9 0 0 1 14.72.313l3.596 3.596a.9.9 0 0 1 0 1.271l-3.596 3.597a.9.9 0 0 1-1.271-1.272l2.061-2.062H3.07L5.13 7.505A.9.9 0 0 1 3.86 8.777L.263 5.18a.9.9 0 0 1 0-1.271L3.86.312a.9.9 0 0 1 1.271 0", clipRule: "evenodd" })), ke = N(_e), Ee = ({
1210
+ title: e,
1211
+ titleId: t,
1212
+ ...o
1213
+ }, i) => /* @__PURE__ */ C.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 19, height: 10, fill: "none", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("path", { fill: "#fff", fillRule: "evenodd", d: "M5.131.312a.9.9 0 0 1 0 1.272L3.07 3.645h12.44l-2.06-2.061A.9.9 0 0 1 14.72.313l3.596 3.596a.9.9 0 0 1 0 1.271l-3.596 3.597a.9.9 0 0 1-1.271-1.272l2.061-2.062H3.07L5.13 7.505A.9.9 0 0 1 3.86 8.777L.263 5.18a.9.9 0 0 1 0-1.271L3.86.312a.9.9 0 0 1 1.271 0", clipRule: "evenodd" })), Te = N(Ee), Je = ({
1214
+ title: e,
1215
+ titleId: t,
1216
+ ...o
1217
+ }, i) => /* @__PURE__ */ C.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 10, height: 19, fill: "none", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("path", { fill: "#fff", fillRule: "evenodd", d: "M9.522 14.811A.899.899 0 1 0 8.25 13.54L6.19 15.601V3.16L8.25 5.221A.9.9 0 0 0 9.522 3.95L5.926.354a.9.9 0 0 0-1.272 0L1.058 3.95a.9.9 0 1 0 1.271 1.271L4.391 3.16v12.442L2.329 13.54a.899.899 0 1 0-1.271 1.271l3.596 3.597a.9.9 0 0 0 1.272 0z", clipRule: "evenodd" })), Re = N(Je), Oe = ({
1218
+ title: e,
1219
+ titleId: t,
1220
+ ...o
1221
+ }, i) => /* @__PURE__ */ C.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ref: i, "aria-labelledby": t, ...o }, e ? /* @__PURE__ */ C.createElement("title", { id: t }, e) : null, /* @__PURE__ */ C.createElement("path", { d: "M8 16C5.76667 16 3.875 15.225 2.325 13.675C0.775 12.125 0 10.2333 0 8C0 5.76667 0.775 3.875 2.325 2.325C3.875 0.775 5.76667 0 8 0C9.15 0 10.25 0.2375 11.3 0.7125C12.35 1.1875 13.25 1.86667 14 2.75V0H16V7H9V5H13.2C12.6667 4.06667 11.9375 3.33333 11.0125 2.8C10.0875 2.26667 9.08333 2 8 2C6.33333 2 4.91667 2.58333 3.75 3.75C2.58333 4.91667 2 6.33333 2 8C2 9.66667 2.58333 11.0833 3.75 12.25C4.91667 13.4167 6.33333 14 8 14C9.28333 14 10.4417 13.6333 11.475 12.9C11.0583 14.1 12.5083 12.1667 11.475 12.9L12.9 14.325C11.4667 15.4417 9.83333 16 8 16Z", fill: "white" })), Pe = N(Oe), Ot = k(
1222
+ ({ store: e }) => {
1223
+ const { t } = D(), [o, i] = Y(
1224
+ e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached
1225
+ ), n = nt(o);
1226
+ ht(() => {
1227
+ const l = e.jogger.motionStream.rapidlyChangingMotionState.joint_limit_reached.limit_reached;
1228
+ ee(n.current, l) || (n.current = l, i(l));
1229
+ });
1230
+ const a = [];
1231
+ for (const [l, s] of o.entries())
1232
+ s && a.push(l);
1233
+ return /* @__PURE__ */ r(
1234
+ V,
1235
+ {
1236
+ sx: {
1237
+ display: "flex",
1238
+ flexDirection: "row",
1239
+ justifyContent: "center"
1240
+ },
1241
+ children: /* @__PURE__ */ r(
1242
+ j,
1243
+ {
1244
+ "data-testid": "jogging-joint-limit-detector",
1245
+ "aria-label": "jogging-joint-limit-detector",
1246
+ color: "error",
1247
+ variant: "body2",
1248
+ sx: {
1249
+ fontSize: "0.75rem",
1250
+ lineHeight: 1.2,
1251
+ visibility: a.length ? "visible" : "hidden"
1252
+ },
1253
+ children: t("Jogging.JointLimitsReached.lb", {
1254
+ jointNumbers: a.map((l) => l + 1).join(", ")
1255
+ })
1256
+ }
1257
+ )
1258
+ }
1259
+ );
1260
+ }
1261
+ ), De = Et(ie)(({ theme: e }) => ({
1262
+ "&.MuiFormControl-root": {
1263
+ ".MuiSelect-select": {
1264
+ paddingTop: "20px",
1265
+ paddingLeft: "12px"
1266
+ },
1267
+ label: {
1268
+ pointerEvents: "none",
1269
+ fontSize: "16px"
1270
+ },
1271
+ ".MuiInputLabel-root": {
1272
+ "&.Mui-focused": {
1273
+ color: e.palette.text.primary
1274
+ }
1275
+ }
1276
+ }
1277
+ }));
1278
+ function Q({
1279
+ labelValue: e,
1280
+ ...t
1281
+ }) {
1282
+ return /* @__PURE__ */ S(De, { fullWidth: !0, variant: "filled", children: [
1283
+ /* @__PURE__ */ r(ne, { id: t.labelId, children: e }),
1284
+ /* @__PURE__ */ r(re, { ...t })
1285
+ ] });
1286
+ }
1287
+ const ct = [
1288
+ { id: "0.1", mm: 0.1, degrees: 0.05 },
1289
+ { id: "1", mm: 1, degrees: 0.5 },
1290
+ { id: "5", mm: 5, degrees: 2.5 },
1291
+ { id: "10", mm: 10, degrees: 5 }
1292
+ ], Ae = [
1293
+ { id: "continuous" },
1294
+ ...ct
1295
+ ], Ve = ["coordsys", "tool"];
1296
+ class pt {
1297
+ constructor(t, o, i, n, a) {
1298
+ var l, s, h;
1299
+ this.jogger = t, this.coordSystems = o, this.motionGroupDescription = i, this.tcps = n, this.inverseSolverValue = a, this.selectedTabId = "cartesian", this.locks = /* @__PURE__ */ new Set(), this.blocked = !1, this.selectedCoordSystemId = "world", this.selectedTcpId = "", this.tcpChangeInProgress = !1, this.selectedOrientation = "coordsys", this.selectedIncrementId = "continuous", this.selectedCartesianMotionType = "translate", this.incrementJogInProgress = null, this.translationVelocityMmPerSec = 10, this.rotationVelocityDegPerSec = 1, this.minTranslationVelocityMmPerSec = 5, this.maxTranslationVelocityMmPerSec = 250, this.minRotationVelocityDegPerSec = 1, this.maxRotationVelocityDegPerSec = 60, this.showCoordSystemSelect = !1, this.showTcpSelect = !0, this.showOrientationSelect = !0, this.showIncrementSelect = !0, this.showTabIcons = !1, this.showVelocitySliderLabel = !0, this.showVelocityLegend = !1, this.showJointsLegend = !1, this.disposers = [], this.inverseSolver = void 0, this.jointType = A.RevoluteJoint;
1300
+ for (const g of o)
1301
+ if (g.coordinate_system === "") {
1302
+ g.coordinate_system = "world";
1303
+ break;
1304
+ }
1305
+ this.selectedCoordSystemId = ((l = o[0]) == null ? void 0 : l.coordinate_system) || "world", this.selectedTcpId = t.motionStream.rapidlyChangingMotionState.tcp ?? "", this.tcpChangeInProgress = this.tcps.length > 0 && !this.selectedTcpId, this.inverseSolver = a, this.jointType = ((h = (s = i == null ? void 0 : i.dh_parameters) == null ? void 0 : s[0]) == null ? void 0 : h.type) ?? A.RevoluteJoint, dt(this, {}, { autoBind: !0 }), this.jogger.onBlocked = () => {
1306
+ this.block();
1307
+ }, this.loadFromLocalStorage(), this.disposers.push(ft(() => this.saveToLocalStorage())), this.disposers.push(
1308
+ ft(() => {
1309
+ const g = this.jogger.motionStream.rapidlyChangingMotionState.tcp;
1310
+ g && g !== this.selectedTcpId && x(() => {
1311
+ this.selectedTcpId = g, this.tcpChangeInProgress = !1;
1312
+ });
1313
+ })
1314
+ ), window.joggingStore = this;
1315
+ }
1316
+ /**
1317
+ * Load a jogging store with the relevant data it needs
1318
+ * from the backend
1319
+ */
1320
+ static async loadFor(t) {
1321
+ const { nova: o, cellId: i } = t, [n, a] = await Promise.all([
1322
+ // Fetch coord systems so user can select between them
1323
+ o.api.controller.listCoordinateSystems(
1324
+ i,
1325
+ t.motionStream.controllerId,
1326
+ "ROTATION_VECTOR"
1327
+ ),
1328
+ // Same for TCPs and other info from description
1329
+ o.api.motionGroup.getMotionGroupDescription(
1330
+ i,
1331
+ t.motionStream.controllerId,
1332
+ t.motionGroupId
1333
+ )
1334
+ ]), l = await o.api.motionGroupModels.getMotionGroupKinematicModel(
1335
+ a.motion_group_model
1336
+ ), s = Object.entries(a.tcps || {}).map(([h, g]) => ({
1337
+ id: h,
1338
+ readable_name: g.name,
1339
+ position: g.pose.position,
1340
+ orientation: g.pose.orientation
1341
+ }));
1342
+ return new pt(
1343
+ t,
1344
+ n || [],
1345
+ a,
1346
+ s,
1347
+ l.inverse_solver
1348
+ );
1349
+ }
1350
+ dispose() {
1351
+ for (const t of this.disposers)
1352
+ t();
1353
+ this.jogger.dispose();
1354
+ }
1355
+ get coordSystemCountByName() {
1356
+ return Xt(this.coordSystems, (t) => t.name);
1357
+ }
1358
+ async deactivate() {
1359
+ this.jogger.mode === "jogging" && await this.jogger.setJoggingMode("off");
1360
+ }
1361
+ /**
1362
+ * Activate the jogger with current settings. Resolves when the jogging
1363
+ * websocket is initialized, or when the jogging was stopped before that
1364
+ * (`deactivate`).
1365
+ */
1366
+ async activate() {
1367
+ return this.currentTab.id === "cartesian" ? ((this.jogger.tcp !== this.selectedTcpId || this.jogger.orientation !== this.selectedOrientation) && await this.jogger.setOptions({
1368
+ tcp: this.selectedTcpId || void 0,
1369
+ orientation: this.selectedOrientation
1370
+ }), this.activeDiscreteIncrement ? await this.jogger.setJoggingMode("trajectory") : await this.jogger.setJoggingMode("jogging")) : await this.jogger.setJoggingMode("jogging"), this.jogger;
1371
+ }
1372
+ loadFromLocalStorage() {
1373
+ const t = P(localStorage.getItem("joggingToolStore"));
1374
+ t && (this.tabsById[t.selectedTabId] && (this.selectedTabId = t.selectedTabId), this.coordSystemsById[t.selectedCoordSystemId] && (this.selectedCoordSystemId = t.selectedCoordSystemId), this.incrementOptionsById[t.selectedIncrementId] && (this.selectedIncrementId = t.selectedIncrementId), ["translate", "rotate"].includes(t.selectedCartesianMotionType) && (this.selectedCartesianMotionType = t.selectedCartesianMotionType), ["coordsys", "tool"].includes(t.selectedOrientation) && (this.selectedOrientation = t.selectedOrientation));
1375
+ }
1376
+ saveToLocalStorage() {
1377
+ localStorage.setItem(
1378
+ "joggingToolStore",
1379
+ JSON.stringify(this.localStorageSave)
1380
+ );
1381
+ }
1382
+ get isLocked() {
1383
+ return this.locks.size > 0;
1384
+ }
1385
+ get localStorageSave() {
1386
+ return {
1387
+ selectedTabId: this.selectedTabId,
1388
+ selectedCoordSystemId: this.selectedCoordSystemId,
1389
+ selectedOrientation: this.selectedOrientation,
1390
+ selectedIncrementId: this.selectedIncrementId,
1391
+ selectedCartesianMotionType: this.selectedCartesianMotionType
1392
+ };
1393
+ }
1394
+ get tabs() {
1395
+ const t = [
1396
+ {
1397
+ id: "joint",
1398
+ label: "Joints"
1399
+ }
1400
+ ];
1401
+ return this.inverseSolver !== null && t.unshift({
1402
+ id: "cartesian",
1403
+ label: "Cartesian"
1404
+ }), t;
1405
+ }
1406
+ get incrementOptions() {
1407
+ return Ae;
1408
+ }
1409
+ get discreteIncrementOptions() {
1410
+ return ct;
1411
+ }
1412
+ get incrementOptionsById() {
1413
+ return K(this.incrementOptions, (t) => t.id);
1414
+ }
1415
+ get tabsById() {
1416
+ return K(this.tabs, (t) => t.id);
1417
+ }
1418
+ get currentTab() {
1419
+ return this.tabsById[this.selectedTabId] || this.tabs[0];
1420
+ }
1421
+ get tabIndex() {
1422
+ return this.tabs.indexOf(this.currentTab);
1423
+ }
1424
+ get coordSystemsById() {
1425
+ return K(this.coordSystems, (t) => t.coordinate_system);
1426
+ }
1427
+ /**
1428
+ * The id of the coordinate system to use for jogging.
1429
+ * If in tool orientation, this is set to "tool", not the
1430
+ * selected coordinate system.
1431
+ */
1432
+ get activeCoordSystemId() {
1433
+ return this.selectedOrientation === "tool" ? "tool" : this.selectedCoordSystemId;
1434
+ }
1435
+ get tcpsById() {
1436
+ return K(this.tcps, (t) => t.id);
1437
+ }
1438
+ get activeDiscreteIncrement() {
1439
+ return this.selectedOrientation === "tool" ? void 0 : ct.find((t) => t.id === this.selectedIncrementId);
1440
+ }
1441
+ /** The selected rotation velocity converted to radians per second */
1442
+ get rotationVelocityRadsPerSec() {
1443
+ return this.rotationVelocityDegPerSec * Math.PI / 180;
1444
+ }
1445
+ /** Selected velocity in mm/sec or deg/sec */
1446
+ velocityInDisplayUnits(t) {
1447
+ return t ? this.rotationVelocityDegPerSec : this.translationVelocityMmPerSec;
1448
+ }
1449
+ /** Minimum selectable velocity in mm/sec or deg/sec */
1450
+ minVelocityInDisplayUnits(t) {
1451
+ return t ? this.minRotationVelocityDegPerSec : this.minTranslationVelocityMmPerSec;
1452
+ }
1453
+ /** Maximum selectable velocity in mm/sec or deg/sec */
1454
+ maxVelocityInDisplayUnits(t) {
1455
+ return t ? this.maxRotationVelocityDegPerSec : this.maxTranslationVelocityMmPerSec;
1456
+ }
1457
+ onTabChange(t, o) {
1458
+ const i = this.tabs[o] || this.tabs[0];
1459
+ this.selectedTabId = i.id;
1460
+ }
1461
+ setSelectedCoordSystemId(t) {
1462
+ this.selectedCoordSystemId = t;
1463
+ }
1464
+ /**
1465
+ * @deprecated Use {@link JoggingStore.requestTcpChange} instead. This method now delegates
1466
+ * to `requestTcpChange` which properly communicates the TCP change to the server.
1467
+ */
1468
+ setSelectedTcpId(t) {
1469
+ this.requestTcpChange(t).catch((o) => {
1470
+ console.error("Failed to change TCP:", o);
1471
+ });
1472
+ }
1473
+ /**
1474
+ * Request a TCP change on the server. Sends an InitializeJoggingRequest
1475
+ * with the new TCP to the backend via the jogging websocket.
1476
+ *
1477
+ * If the jogger is actively jogging, the websocket is reinitialised with the new TCP.
1478
+ * If the jogger is idle, a jogging websocket is briefly opened to communicate the
1479
+ * TCP change. The websocket is kept open until the state-stream confirms the
1480
+ * change (or a 1s timeout), to ensure the backend has time to process it.
1481
+ */
1482
+ async requestTcpChange(t) {
1483
+ if (t === this.selectedTcpId) return;
1484
+ this.tcpChangeInProgress = !0;
1485
+ const o = this.jogger.tcp, i = this.jogger.mode !== "jogging";
1486
+ try {
1487
+ this.jogger.tcp = t, i ? await this.jogger.setJoggingMode("jogging") : await this.jogger.setJoggingMode("jogging", !1);
1488
+ let n = await this.waitForTcpConfirmation(t, 1e3);
1489
+ i && await this.jogger.setJoggingMode("off"), n || (n = await this.waitForTcpConfirmation(t, 2e3)), x(() => {
1490
+ n ? this.selectedTcpId = t : (this.jogger.tcp = o, this.selectedTcpId = this.jogger.motionStream.rapidlyChangingMotionState.tcp ?? "");
1491
+ });
1492
+ } catch (n) {
1493
+ throw i && await this.jogger.setJoggingMode("off").catch(() => {
1494
+ }), x(() => {
1495
+ this.jogger.tcp = o, this.selectedTcpId = this.jogger.motionStream.rapidlyChangingMotionState.tcp ?? "";
1496
+ }), n;
1497
+ } finally {
1498
+ x(() => {
1499
+ this.tcpChangeInProgress = !1;
1500
+ });
1501
+ }
1502
+ }
1503
+ waitForTcpConfirmation(t, o) {
1504
+ return new Promise((i) => {
1505
+ const n = setTimeout(() => {
1506
+ a(), i(!1);
1507
+ }, o), a = tt(
1508
+ () => this.jogger.motionStream.rapidlyChangingMotionState.tcp === t,
1509
+ () => {
1510
+ clearTimeout(n), i(!0);
1511
+ }
1512
+ );
1513
+ });
1514
+ }
1515
+ setSelectedOrientation(t) {
1516
+ this.selectedOrientation = t;
1517
+ }
1518
+ setSelectedIncrementId(t) {
1519
+ this.selectedIncrementId = t;
1520
+ }
1521
+ setCurrentIncrementJog(t) {
1522
+ this.incrementJogInProgress = t;
1523
+ }
1524
+ setVelocityFromSlider(t, o) {
1525
+ o ? this.rotationVelocityDegPerSec = t : this.translationVelocityMmPerSec = t;
1526
+ }
1527
+ setSelectedCartesianMotionType(t) {
1528
+ this.selectedCartesianMotionType = t;
1529
+ }
1530
+ lock(t) {
1531
+ this.locks.add(t);
1532
+ }
1533
+ unlock(t) {
1534
+ this.locks.delete(t);
1535
+ }
1536
+ block() {
1537
+ this.blocked = !0;
1538
+ }
1539
+ unblock() {
1540
+ this.blocked = !1, this.jogger.mode === "jogging" && this.jogger.initializeJoggingWebsocket().catch((t) => {
1541
+ console.error("Failed to initialize jogging:", t);
1542
+ });
1543
+ }
1544
+ /** Lock the UI until the given async callback resolves */
1545
+ async withMotionLock(t) {
1546
+ const o = ae();
1547
+ this.lock(o);
1548
+ try {
1549
+ return await t();
1550
+ } finally {
1551
+ this.unlock(o);
1552
+ }
1553
+ }
1554
+ }
1555
+ const Le = k(
1556
+ ({ store: e, useDegree: t }) => {
1557
+ var l;
1558
+ const { t: o } = D(), i = zt(), n = [];
1559
+ function a(s) {
1560
+ switch (s) {
1561
+ case "coordsys":
1562
+ return o("Jogging.Orientation.coordsys");
1563
+ case "tool":
1564
+ return o("Jogging.Orientation.tool");
1565
+ default:
1566
+ return s;
1567
+ }
1568
+ }
1569
+ return e.showCoordSystemSelect && n.push(
1570
+ /* @__PURE__ */ r(
1571
+ Q,
1572
+ {
1573
+ labelId: `jogging-coord-select-${i}`,
1574
+ labelValue: o("Jogging.CoordinateSystem.hlb"),
1575
+ value: e.selectedCoordSystemId,
1576
+ size: "small",
1577
+ variant: "filled",
1578
+ displayEmpty: !0,
1579
+ onChange: (s) => e.setSelectedCoordSystemId(s.target.value),
1580
+ children: e.coordSystems.map((s) => /* @__PURE__ */ r($, { value: s.coordinate_system, children: s.name && e.coordSystemCountByName[s.name] > 1 ? `${s.name} / ${s.coordinate_system}` : s.name || s.coordinate_system }, s.coordinate_system))
1581
+ },
1582
+ "coord"
1583
+ )
1584
+ ), e.showTcpSelect && n.push(
1585
+ /* @__PURE__ */ r(
1586
+ Q,
1587
+ {
1588
+ labelId: `jogging-tcp-select-${i}`,
1589
+ labelValue: "TCP",
1590
+ value: e.selectedTcpId,
1591
+ size: "small",
1592
+ variant: "filled",
1593
+ displayEmpty: e.tcpChangeInProgress,
1594
+ onChange: (s) => {
1595
+ e.requestTcpChange(s.target.value).catch((h) => {
1596
+ console.error("Failed to change TCP:", h);
1597
+ });
1598
+ },
1599
+ disabled: e.tcpChangeInProgress,
1600
+ endAdornment: e.tcpChangeInProgress ? /* @__PURE__ */ r(oe, { position: "end", children: /* @__PURE__ */ r(kt, { size: 16 }) }) : void 0,
1601
+ children: e.tcps.map((s) => /* @__PURE__ */ r($, { value: s.id, children: s.id }, s.id))
1602
+ },
1603
+ "tcp"
1604
+ )
1605
+ ), e.showOrientationSelect && n.push(
1606
+ /* @__PURE__ */ r(
1607
+ Q,
1608
+ {
1609
+ labelValue: o("Jogging.Cartesian.Orientation.lb"),
1610
+ labelId: `orientation-select-${i}`,
1611
+ value: e.selectedOrientation,
1612
+ onChange: (s) => e.setSelectedOrientation(s.target.value),
1613
+ children: Ve.map((s) => /* @__PURE__ */ r($, { value: s, children: a(s) }, s))
1614
+ },
1615
+ "orientation"
1616
+ )
1617
+ ), e.showIncrementSelect && n.push(
1618
+ /* @__PURE__ */ S(
1619
+ Q,
1620
+ {
1621
+ labelValue: o("Jogging.Increment.hlb"),
1622
+ labelId: `jogging-increment-select-${i}`,
1623
+ size: "small",
1624
+ variant: "filled",
1625
+ value: ((l = e.activeDiscreteIncrement) == null ? void 0 : l.id) || "continuous",
1626
+ onChange: (s) => e.setSelectedIncrementId(
1627
+ s.target.value
1628
+ ),
1629
+ children: [
1630
+ /* @__PURE__ */ r($, { value: "continuous", children: o("Jogging.Increment.Continuous.dd") }, "continuous"),
1631
+ e.selectedOrientation === "tool" ? null : e.discreteIncrementOptions.map((s) => /* @__PURE__ */ r($, { value: s.id, children: t ? `${s.degrees}°` : `${s.mm}mm` }, s.id))
1632
+ ]
1633
+ },
1634
+ "increment"
1635
+ )
1636
+ ), /* @__PURE__ */ r(
1637
+ V,
1638
+ {
1639
+ component: "div",
1640
+ "data-testid": "jogging-options",
1641
+ "aria-label": "jogging-options",
1642
+ sx: {
1643
+ display: "grid",
1644
+ gap: "16px",
1645
+ gridTemplateColumns: "1fr 1fr",
1646
+ gridAutoRows: "min-content",
1647
+ "& label": { opacity: 0.7, fontSize: "12px", marginBottom: "4px" }
1648
+ },
1649
+ children: n.map((s, h) => /* @__PURE__ */ r(
1650
+ V,
1651
+ {
1652
+ sx: {
1653
+ gridColumn: n.length % 2 === 1 && h === n.length - 1 ? "span 2" : "auto"
1654
+ },
1655
+ children: s
1656
+ },
1657
+ h
1658
+ ))
1659
+ }
1660
+ );
1661
+ }
1662
+ ), Be = Et(se)(({ theme: e }) => {
1663
+ var t;
1664
+ return {
1665
+ "&.MuiToggleButtonGroup-root": {
1666
+ background: (t = e.palette.backgroundPaperElevation) == null ? void 0 : t[8],
1667
+ borderRadius: "8px",
1668
+ padding: "4px",
1669
+ gap: "4px",
1670
+ button: {
1671
+ border: "none",
1672
+ borderRadius: "4px",
1673
+ flex: "1 1 0px",
1674
+ minWidth: 0,
1675
+ "&.MuiToggleButtonGroup-firstButton": {
1676
+ borderRadius: "8px 4px 4px 8px"
1677
+ },
1678
+ "&.MuiToggleButtonGroup-lastButton": {
1679
+ borderRadius: "4px 8px 8px 4px"
1680
+ }
1681
+ }
1682
+ }
1683
+ };
1684
+ }), $e = Z(
1685
+ k((e) => {
1686
+ const { store: t } = e, { t: o } = D();
1687
+ function i(n, a) {
1688
+ a === e.velocity || !le(a) || e.onVelocityChange(a, e.useDegree);
1689
+ }
1690
+ return /* @__PURE__ */ S(
1691
+ w,
1692
+ {
1693
+ direction: "row",
1694
+ gap: 2,
1695
+ alignItems: "center",
1696
+ "data-testid": "velocity-slider",
1697
+ "aria-label": "velocity-slider",
1698
+ children: [
1699
+ t.showVelocityLegend && /* @__PURE__ */ r(
1700
+ j,
1701
+ {
1702
+ sx: {
1703
+ color: ve,
1704
+ fontSize: "14px"
1705
+ },
1706
+ children: o("Jogging.Velocity.bt")
1707
+ }
1708
+ ),
1709
+ /* @__PURE__ */ r(
1710
+ Tt,
1711
+ {
1712
+ value: e.velocity,
1713
+ color: "secondary",
1714
+ onChange: i,
1715
+ min: e.min,
1716
+ max: e.max,
1717
+ "aria-labelledby": "input-slider",
1718
+ disabled: e.disabled,
1719
+ sx: {
1720
+ "& .MuiSlider-valueLabelOpen": {
1721
+ zIndex: 100,
1722
+ backgroundColor: "transparent",
1723
+ top: "0px"
1724
+ }
1725
+ }
1726
+ }
1727
+ ),
1728
+ t.showVelocitySliderLabel && (e.renderValue ? e.renderValue(e.velocity) : /* @__PURE__ */ r(Pt, { value: e.velocity.toString() }))
1729
+ ]
1730
+ }
1731
+ );
1732
+ })
1733
+ );
1734
+ function Pt({ value: e, sx: t }) {
1735
+ var i;
1736
+ const o = z();
1737
+ return /* @__PURE__ */ r(
1738
+ w,
1739
+ {
1740
+ direction: "row",
1741
+ justifyContent: "center",
1742
+ alignItems: "center",
1743
+ gap: "5px",
1744
+ sx: {
1745
+ padding: "6px 12px",
1746
+ background: (i = o.palette.backgroundPaperElevation) == null ? void 0 : i[8],
1747
+ borderRadius: "10px",
1748
+ minWidth: "111px",
1749
+ ...t
1750
+ },
1751
+ children: /* @__PURE__ */ r(
1752
+ j,
1753
+ {
1754
+ component: "span",
1755
+ sx: {
1756
+ textAlign: "right",
1757
+ fontSize: "14px",
1758
+ opacity: 0.8,
1759
+ color: o.palette.text.primary,
1760
+ whiteSpace: "nowrap"
1761
+ },
1762
+ children: e
1763
+ }
1764
+ )
1765
+ }
1766
+ );
1767
+ }
1768
+ const Dt = k(
1769
+ ({ store: e, useDegree: t }) => {
1770
+ const { t: o } = D();
1771
+ function i(n, a) {
1772
+ return a ? `ω = ${o("Jogging.Cartesian.Rotation.velocityDegPerSec.lb", { amount: n })}` : `v = ${o("Jogging.Cartesian.Translation.velocityMmPerSec.lb", { amount: n })}`;
1773
+ }
1774
+ return /* @__PURE__ */ r(
1775
+ $e,
1776
+ {
1777
+ store: e,
1778
+ velocity: e.velocityInDisplayUnits(t),
1779
+ min: e.minVelocityInDisplayUnits(t),
1780
+ max: e.maxVelocityInDisplayUnits(t),
1781
+ onVelocityChange: e.setVelocityFromSlider,
1782
+ useDegree: t,
1783
+ disabled: e.isLocked,
1784
+ renderValue: (n) => /* @__PURE__ */ r(
1785
+ Pt,
1786
+ {
1787
+ value: i(n, t),
1788
+ sx: {
1789
+ minWidth: "111px",
1790
+ span: {
1791
+ transform: "translateY(-1.5px)"
1792
+ }
1793
+ }
1794
+ }
1795
+ )
1796
+ }
1797
+ );
1798
+ }
1799
+ ), At = k(({ store: e }) => {
1800
+ var n, a, l;
1801
+ const { t } = D(), o = z(), i = ((l = (a = (n = e.jogger.motionStream.rapidlyChangingMotionState.execute) == null ? void 0 : n.details) == null ? void 0 : a.state) == null ? void 0 : l.kind) ?? "KIND_UNKNOWN";
1802
+ return /* @__PURE__ */ S(
1803
+ V,
1804
+ {
1805
+ sx: {
1806
+ display: "flex",
1807
+ flexDirection: "row",
1808
+ justifyContent: "space-between",
1809
+ color: o.palette.text.primary
1810
+ },
1811
+ children: [
1812
+ /* @__PURE__ */ r(
1813
+ j,
1814
+ {
1815
+ variant: "body2",
1816
+ sx: {
1817
+ fontSize: "0.75rem",
1818
+ // Smaller than body2
1819
+ lineHeight: 1.2
1820
+ },
1821
+ children: t("Jogging.StreamStateSection.lb")
1822
+ }
1823
+ ),
1824
+ /* @__PURE__ */ r(
1825
+ j,
1826
+ {
1827
+ variant: "body2",
1828
+ sx: {
1829
+ fontSize: "0.75rem",
1830
+ // Smaller than body2
1831
+ lineHeight: 1.2
1832
+ },
1833
+ "data-testid": i,
1834
+ children: t(`Jogging.StreamStateSection.${i}.lb`)
1835
+ }
1836
+ )
1837
+ ]
1838
+ }
1839
+ );
1840
+ }), Fe = k(
1841
+ ({
1842
+ store: e,
1843
+ children: t
1844
+ }) => {
1845
+ const { t: o } = D(), i = z(), n = nt(0);
1846
+ function a(d, c) {
1847
+ (c === "translate" || c === "rotate") && e.setSelectedCartesianMotionType(c);
1848
+ }
1849
+ async function l(d, c) {
1850
+ const f = await e.activate(), y = f.motionStream.rapidlyChangingMotionState.tcp_pose, u = f.motionStream.rapidlyChangingMotionState.joint_position;
1851
+ y && await e.withMotionLock(async () => {
1852
+ try {
1853
+ e.setCurrentIncrementJog({
1854
+ axis: d.axis,
1855
+ direction: d.direction
1856
+ }), await e.jogger.runIncrementalCartesianMotion({
1857
+ currentTcpPose: y,
1858
+ currentJoints: u,
1859
+ coordSystemId: e.activeCoordSystemId,
1860
+ velocityInRelevantUnits: e.selectedCartesianMotionType === "translate" ? e.translationVelocityMmPerSec : e.rotationVelocityRadsPerSec,
1861
+ axis: d.axis,
1862
+ direction: d.direction,
1863
+ motion: e.selectedCartesianMotionType === "translate" ? {
1864
+ type: "translate",
1865
+ distanceMm: c.mm
1866
+ } : {
1867
+ type: "rotate",
1868
+ distanceRads: qt(c.degrees)
1869
+ }
1870
+ });
1871
+ } finally {
1872
+ e.setCurrentIncrementJog(null), await e.deactivate();
1873
+ }
1874
+ });
1875
+ }
1876
+ async function s(d) {
1877
+ if (e.isLocked) return;
1878
+ const c = ++n.current;
1879
+ try {
1880
+ if (await e.activate(), c !== n.current) return;
1881
+ if (e.activeDiscreteIncrement)
1882
+ return await l(
1883
+ d,
1884
+ e.activeDiscreteIncrement
1885
+ );
1886
+ d.motionType === "translate" ? await e.jogger.translateTCP({
1887
+ axis: d.axis,
1888
+ direction: d.direction,
1889
+ velocityMmPerSec: e.translationVelocityMmPerSec
1890
+ }) : await e.jogger.rotateTCP({
1891
+ axis: d.axis,
1892
+ direction: d.direction,
1893
+ velocityRadsPerSec: e.rotationVelocityRadsPerSec
1894
+ });
1895
+ } catch (f) {
1896
+ console.error("Jogging failed:", f);
1897
+ }
1898
+ }
1899
+ async function h() {
1900
+ e.isLocked || e.activeDiscreteIncrement || (n.current++, await e.deactivate());
1901
+ }
1902
+ const g = [
1903
+ {
1904
+ id: "x",
1905
+ icon: /* @__PURE__ */ r(ke, {}),
1906
+ colors: at.X
1907
+ },
1908
+ {
1909
+ id: "y",
1910
+ icon: /* @__PURE__ */ r(Te, {}),
1911
+ colors: at.Y
1912
+ },
1913
+ {
1914
+ id: "z",
1915
+ icon: /* @__PURE__ */ r(Re, {}),
1916
+ colors: at.Z
1917
+ }
1918
+ ];
1919
+ function p(d) {
1920
+ return o("General.mm.variable", { amount: d.toFixed(1) });
1921
+ }
1922
+ function m(d) {
1923
+ return o("General.degree.variable", {
1924
+ amount: _t(d).toFixed(1)
1925
+ });
1926
+ }
1927
+ return /* @__PURE__ */ S(
1928
+ w,
1929
+ {
1930
+ "data-testid": "jogging-cartesian-tab",
1931
+ "aria-label": "jogging-cartesian-tab",
1932
+ flexGrow: 1,
1933
+ gap: 2,
1934
+ sx: { padding: "18px 24px" },
1935
+ children: [
1936
+ /* @__PURE__ */ S(w, { gap: 2, children: [
1937
+ /* @__PURE__ */ r(
1938
+ Le,
1939
+ {
1940
+ store: e,
1941
+ useDegree: e.selectedCartesianMotionType === "rotate"
1942
+ }
1943
+ ),
1944
+ /* @__PURE__ */ r(
1945
+ Dt,
1946
+ {
1947
+ store: e,
1948
+ useDegree: e.selectedCartesianMotionType === "rotate"
1949
+ }
1950
+ ),
1951
+ /* @__PURE__ */ r(F, {})
1952
+ ] }),
1953
+ /* @__PURE__ */ r(
1954
+ w,
1955
+ {
1956
+ marginLeft: "auto",
1957
+ marginRight: "auto",
1958
+ gap: "24px",
1959
+ justifyContent: "center",
1960
+ sx: { flexGrow: "1" },
1961
+ children: /* @__PURE__ */ S(
1962
+ w,
1963
+ {
1964
+ alignItems: "center",
1965
+ justifyContent: "center",
1966
+ gap: "24px",
1967
+ sx: { flexGrow: 1 },
1968
+ children: [
1969
+ /* @__PURE__ */ S(
1970
+ Be,
1971
+ {
1972
+ value: e.selectedCartesianMotionType,
1973
+ onChange: a,
1974
+ exclusive: !0,
1975
+ "aria-label": o("Jogging.Cartesian.MotionType.lb"),
1976
+ sx: { justifyContent: "center" },
1977
+ children: [
1978
+ /* @__PURE__ */ r(yt, { value: "translate", children: o("Jogging.Cartesian.Translation.bt") }),
1979
+ /* @__PURE__ */ r(yt, { value: "rotate", children: o("Jogging.Cartesian.Rotation.bt") })
1980
+ ]
1981
+ }
1982
+ ),
1983
+ e.selectedCartesianMotionType === "translate" && g.map((d) => {
1984
+ var c, f;
1985
+ return /* @__PURE__ */ r(
1986
+ vt,
1987
+ {
1988
+ "data-testid": `jogging-cartesian-axis-control-${d.id}`,
1989
+ "aria-label": `jogging-cartesian-axis-control-${d.id}`,
1990
+ colors: d.colors,
1991
+ disabled: e.isLocked,
1992
+ activeJoggingDirection: ((c = e.incrementJogInProgress) == null ? void 0 : c.axis) === d.id ? e.incrementJogInProgress.direction : void 0,
1993
+ label: /* @__PURE__ */ S(et, { children: [
1994
+ d.icon,
1995
+ /* @__PURE__ */ r(
1996
+ j,
1997
+ {
1998
+ sx: {
1999
+ fontSize: "24px",
2000
+ color: ((f = d.colors) == null ? void 0 : f.labelColor) ?? i.palette.text.primary
2001
+ },
2002
+ children: d.id.toUpperCase()
2003
+ }
2004
+ )
2005
+ ] }),
2006
+ getDisplayedValue: () => {
2007
+ var y, u;
2008
+ return p(
2009
+ ((u = (y = e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose) == null ? void 0 : y.position) == null ? void 0 : u[W[d.id]]) || 0
2010
+ );
2011
+ },
2012
+ startJogging: (y) => s({
2013
+ axis: d.id,
2014
+ motionType: "translate",
2015
+ direction: y
2016
+ }),
2017
+ stopJogging: h
2018
+ },
2019
+ d.id
2020
+ );
2021
+ }),
2022
+ e.selectedCartesianMotionType === "rotate" && g.map((d) => {
2023
+ var c, f;
2024
+ return /* @__PURE__ */ r(
2025
+ vt,
2026
+ {
2027
+ "data-testid": `jogging-cartesian-axis-control-${d.id}`,
2028
+ "aria-label": `jogging-cartesian-axis-control-${d.id}`,
2029
+ colors: d.colors,
2030
+ disabled: e.isLocked,
2031
+ activeJoggingDirection: ((c = e.incrementJogInProgress) == null ? void 0 : c.axis) === d.id ? e.incrementJogInProgress.direction : void 0,
2032
+ label: /* @__PURE__ */ S(et, { children: [
2033
+ /* @__PURE__ */ r(Pe, {}),
2034
+ /* @__PURE__ */ r(
2035
+ j,
2036
+ {
2037
+ sx: {
2038
+ fontSize: "24px",
2039
+ color: ((f = d.colors) == null ? void 0 : f.labelColor) ?? i.palette.text.primary
2040
+ },
2041
+ children: d.id.toUpperCase()
2042
+ }
2043
+ )
2044
+ ] }),
2045
+ getDisplayedValue: () => {
2046
+ var y, u;
2047
+ return m(
2048
+ ((u = (y = e.jogger.motionStream.rapidlyChangingMotionState.tcp_pose) == null ? void 0 : y.orientation) == null ? void 0 : u[W[d.id]]) || 0
2049
+ );
2050
+ },
2051
+ startJogging: (y) => s({
2052
+ axis: d.id,
2053
+ motionType: "rotate",
2054
+ direction: y
2055
+ }),
2056
+ stopJogging: h
2057
+ },
2058
+ d.id
2059
+ );
2060
+ })
2061
+ ]
2062
+ }
2063
+ )
2064
+ }
2065
+ ),
2066
+ /* @__PURE__ */ r(Ot, { store: e }),
2067
+ /* @__PURE__ */ r(F, {}),
2068
+ /* @__PURE__ */ r(At, { store: e }),
2069
+ t && /* @__PURE__ */ r(F, {}),
2070
+ t
2071
+ ]
2072
+ }
2073
+ );
2074
+ }
2075
+ ), Ne = k(
2076
+ ({ store: e, children: t }) => {
2077
+ const o = z(), i = nt(0);
2078
+ async function n(l) {
2079
+ const s = ++i.current;
2080
+ try {
2081
+ if (await e.activate(), s !== i.current) return;
2082
+ await e.jogger.rotateJoints({
2083
+ joint: l.joint,
2084
+ direction: l.direction,
2085
+ velocityUnit: e.jointType === A.PrismaticJoint ? "mm/s" : "rad/s",
2086
+ velocityValue: e.jointType === A.PrismaticJoint ? e.translationVelocityMmPerSec : e.rotationVelocityRadsPerSec
2087
+ });
2088
+ } catch (h) {
2089
+ console.error("Jogging failed:", h);
2090
+ }
2091
+ }
2092
+ async function a() {
2093
+ i.current++, await e.jogger.stop(), await e.deactivate();
2094
+ }
2095
+ return /* @__PURE__ */ S(
2096
+ w,
2097
+ {
2098
+ "data-testid": "jogging-joint-tab",
2099
+ "aria-label": "jogging-joint-tab",
2100
+ flexGrow: 1,
2101
+ gap: 2,
2102
+ sx: { padding: "18px 24px" },
2103
+ children: [
2104
+ /* @__PURE__ */ r(
2105
+ Dt,
2106
+ {
2107
+ store: e,
2108
+ useDegree: e.jointType === A.RevoluteJoint
2109
+ }
2110
+ ),
2111
+ /* @__PURE__ */ r(F, {}),
2112
+ /* @__PURE__ */ r(
2113
+ w,
2114
+ {
2115
+ justifyContent: "center",
2116
+ alignItems: "stretch",
2117
+ sx: { flexGrow: "1" },
2118
+ children: /* @__PURE__ */ r(
2119
+ w,
2120
+ {
2121
+ "data-testid": "jogging-joint-value-controls-wrapper",
2122
+ "aria-label": "jogging-joint-value-controls-wrapper",
2123
+ alignItems: "center",
2124
+ gap: "24px",
2125
+ children: e.jogger.motionStream.joints.map((l) => {
2126
+ var h, g, p;
2127
+ const s = (p = (g = (h = e.motionGroupDescription.operation_limits.auto_limits) == null ? void 0 : h.joints) == null ? void 0 : g[l.index]) == null ? void 0 : p.position;
2128
+ return /* @__PURE__ */ S(
2129
+ w,
2130
+ {
2131
+ "data-testid": `jogging-joint-value-control-${l.index}`,
2132
+ "aria-label": `jogging-joint-value-control-${l.index}`,
2133
+ direction: "row",
2134
+ alignItems: "center",
2135
+ justifyContent: "center",
2136
+ spacing: 1.5,
2137
+ width: "100%",
2138
+ children: [
2139
+ e.showJointsLegend && /* @__PURE__ */ r(
2140
+ j,
2141
+ {
2142
+ color: e.isLocked ? o.palette.text.disabled : o.palette.text.secondary,
2143
+ children: `G${l.index + 1}`
2144
+ }
2145
+ ),
2146
+ /* @__PURE__ */ r(
2147
+ xe,
2148
+ {
2149
+ disabled: e.isLocked,
2150
+ lowerLimit: s == null ? void 0 : s.lower_limit,
2151
+ upperLimit: s == null ? void 0 : s.upper_limit,
2152
+ useDegree: e.jointType === A.RevoluteJoint,
2153
+ getValue: () => {
2154
+ const m = e.jogger.motionStream.rapidlyChangingMotionState.joint_position[l.index];
2155
+ return m !== void 0 ? m : void 0;
2156
+ },
2157
+ startJogging: (m) => n({
2158
+ joint: l.index,
2159
+ direction: m
2160
+ }),
2161
+ stopJogging: a
2162
+ }
2163
+ )
2164
+ ]
2165
+ },
2166
+ `joint-${l.index}`
2167
+ );
2168
+ })
2169
+ }
2170
+ )
2171
+ }
2172
+ ),
2173
+ /* @__PURE__ */ r(Ot, { store: e }),
2174
+ /* @__PURE__ */ r(F, {}),
2175
+ /* @__PURE__ */ r(At, { store: e }),
2176
+ t && /* @__PURE__ */ r(F, {}),
2177
+ t
2178
+ ]
2179
+ }
2180
+ );
2181
+ }
2182
+ ), qo = Z(
2183
+ k((e) => {
2184
+ const t = jt(() => ({
2185
+ joggingStore: null,
2186
+ loadingError: null
2187
+ }));
2188
+ return ot(() => {
2189
+ let o = !1, i;
2190
+ async function n() {
2191
+ x(() => {
2192
+ t.loadingError = null, t.joggingStore = null;
2193
+ });
2194
+ try {
2195
+ let a = e.store;
2196
+ if (!a) {
2197
+ const l = await ut.open(
2198
+ e.nova,
2199
+ e.motionGroupId,
2200
+ {
2201
+ cellId: e.cellId
2202
+ }
2203
+ );
2204
+ if (o) {
2205
+ l.dispose();
2206
+ return;
2207
+ }
2208
+ try {
2209
+ a = await pt.loadFor(l);
2210
+ } catch (s) {
2211
+ throw l.dispose(), s;
2212
+ }
2213
+ if (i = a, o) {
2214
+ a.dispose();
2215
+ return;
2216
+ }
2217
+ }
2218
+ x(() => {
2219
+ t.joggingStore = a;
2220
+ }), e.onSetup && e.onSetup(a);
2221
+ } catch (a) {
2222
+ if (o) return;
2223
+ x(() => {
2224
+ t.loadingError = a;
2225
+ });
2226
+ }
2227
+ }
2228
+ return n(), () => {
2229
+ o = !0, i == null || i.dispose();
2230
+ };
2231
+ }, [e.store, e.nova, e.motionGroupId, e.cellId]), ot(() => {
2232
+ const o = t.joggingStore;
2233
+ o && (e.locked ? o.lock("external") : o.unlock("external"));
2234
+ }, [t.joggingStore, e.locked]), /* @__PURE__ */ r(
2235
+ w,
2236
+ {
2237
+ "data-testid": "jogging-panel",
2238
+ "aria-label": "jogging-panel",
2239
+ sx: {
2240
+ maxWidth: "460px",
2241
+ minWidth: "320px",
2242
+ position: "relative",
2243
+ ...e.sx
2244
+ },
2245
+ children: t.joggingStore ? /* @__PURE__ */ r(ze, { store: t.joggingStore, children: e.children }) : /* @__PURE__ */ r(Ie, { message: "Loading jogging", error: t.loadingError })
2246
+ }
2247
+ );
2248
+ })
2249
+ ), ze = k(
2250
+ ({
2251
+ store: e,
2252
+ children: t
2253
+ }) => {
2254
+ const { t: o } = D();
2255
+ function i() {
2256
+ if (e.currentTab.id === "cartesian")
2257
+ return /* @__PURE__ */ r(Fe, { store: e, children: t });
2258
+ if (e.currentTab.id === "joint")
2259
+ return /* @__PURE__ */ r(Ne, { store: e, children: t });
2260
+ }
2261
+ return /* @__PURE__ */ S(w, { flexGrow: 1, sx: { overflow: "hidden" }, children: [
2262
+ /* @__PURE__ */ r(
2263
+ Ht,
2264
+ {
2265
+ "data-testid": "jogging-tabs",
2266
+ "aria-label": "jogging-tabs",
2267
+ value: e.tabIndex,
2268
+ onChange: e.onTabChange,
2269
+ variant: "fullWidth",
2270
+ children: e.tabs.map((n) => {
2271
+ const a = n.label === "Cartesian" ? o("Jogging.Cartesian.bt") : o("Jogging.Joints.bt"), l = n.label === "cartesian" ? /* @__PURE__ */ r(Gt, { fontSize: "small", sx: { mr: 1 } }) : /* @__PURE__ */ r(Ut, { fontSize: "small", sx: { mr: 1 } });
2272
+ return /* @__PURE__ */ r(
2273
+ Wt,
2274
+ {
2275
+ "data-testid": `jogging-tab-${n.id}`,
2276
+ "aria-label": `jogging-tab-${n.id}`,
2277
+ label: e.showTabIcons ? /* @__PURE__ */ S(w, { direction: "row", alignItems: "center", children: [
2278
+ l,
2279
+ a
2280
+ ] }) : a,
2281
+ id: `jogging-tab-${n.id}`,
2282
+ "aria-controls": `jogging-tab-${n.id}`
2283
+ },
2284
+ n.id
2285
+ );
2286
+ })
2287
+ }
2288
+ ),
2289
+ /* @__PURE__ */ r(
2290
+ w,
2291
+ {
2292
+ flexGrow: 1,
2293
+ position: "relative",
2294
+ sx: { overflowY: "auto", overflowX: "hidden" },
2295
+ children: i()
2296
+ }
2297
+ ),
2298
+ e.blocked && /* @__PURE__ */ r(je, { store: e })
2299
+ ] });
2300
+ }
2301
+ );
2302
+ function Ge() {
2303
+ const e = window.location.href;
2304
+ return e.substring(
2305
+ 0,
2306
+ e.indexOf("/", e.indexOf("//") + 2)
2307
+ );
2308
+ }
2309
+ function Yo({
2310
+ baseUrl: e = Ge(),
2311
+ ...t
2312
+ }) {
2313
+ return /* @__PURE__ */ S(
2314
+ he,
2315
+ {
2316
+ "aria-labelledby": "no-motion-group-modal-title",
2317
+ open: !0,
2318
+ fullWidth: !0,
2319
+ sx: {
2320
+ "& .MuiModal-backdrop": {
2321
+ backdropFilter: "blur(10px)"
2322
+ },
2323
+ "& .MuiDialog-paper": {
2324
+ "::before": {
2325
+ content: '""',
2326
+ height: "8px",
2327
+ width: "100%",
2328
+ background: "linear-gradient(90deg, #FF0E65 0%, #47D3FF 100%)"
2329
+ },
2330
+ background: "#101629"
2331
+ }
2332
+ },
2333
+ children: [
2334
+ /* @__PURE__ */ r(pe, { id: "no-motion-group-modal-title", children: "No motion group found" }),
2335
+ /* @__PURE__ */ S(
2336
+ ue,
2337
+ {
2338
+ sx: {
2339
+ marginTop: "3rem",
2340
+ marginBottom: "1.5rem",
2341
+ textAlign: "center"
2342
+ },
2343
+ children: [
2344
+ /* @__PURE__ */ r(j, { color: "#fff", children: "Found no devices to connect to." }),
2345
+ /* @__PURE__ */ r(j, { color: "#fff", children: "Please ensure a motion group has been created." })
2346
+ ]
2347
+ }
2348
+ ),
2349
+ /* @__PURE__ */ r(me, { children: /* @__PURE__ */ S(w, { width: "100%", maxWidth: "300px", margin: "auto", marginBottom: "2rem", children: [
2350
+ /* @__PURE__ */ r(
2351
+ lt,
2352
+ {
2353
+ href: `${e}/settings`,
2354
+ variant: "contained",
2355
+ sx: {
2356
+ borderRadius: "8px",
2357
+ width: "100%"
2358
+ },
2359
+ children: "Go to settings app"
2360
+ }
2361
+ ),
2362
+ /* @__PURE__ */ r(
2363
+ lt,
2364
+ {
2365
+ href: `${e}`,
2366
+ variant: "text",
2367
+ sx: {
2368
+ marginTop: "1rem",
2369
+ color: "#fff",
2370
+ textDecoration: "underline",
2371
+ fontSize: "0.75rem"
2372
+ },
2373
+ children: "Back to Homescreen"
2374
+ }
2375
+ )
2376
+ ] }) })
2377
+ ]
2378
+ }
2379
+ );
2380
+ }
2381
+ const It = 1e-4, Ue = {
2382
+ a: 0,
2383
+ d: 0,
2384
+ alpha: 0,
2385
+ theta: 0,
2386
+ reverse_rotation_direction: !1
2387
+ };
2388
+ class gt {
2389
+ constructor(t, o, i, n, a, l, s, h, g, p, m = "cell") {
2390
+ this.controller = o, this.motionGroup = i, this.initialMotionState = n, this.motionStateSocket = a, this.isVirtual = l, this.tcps = s, this.description = h, this.initialControllerState = g, this.controllerStateSocket = p, this.cellId = m, this.connectedJoggingSocket = null, this.joggingVelocity = 10, this.activationState = "inactive", this.nova = H(t), this.rapidlyChangingMotionState = n, this.controllerState = g, p.addEventListener("message", (d) => {
2391
+ var f;
2392
+ const c = (f = P(d.data)) == null ? void 0 : f.result;
2393
+ c && x(() => {
2394
+ this.controllerState = c;
2395
+ });
2396
+ }), a.addEventListener("message", (d) => {
2397
+ var f;
2398
+ const c = (f = P(d.data)) == null ? void 0 : f.result;
2399
+ if (!c)
2400
+ throw new Error(
2401
+ `Failed to get motion state for ${this.motionGroupId}: ${d.data}`
2402
+ );
2403
+ Jt(
2404
+ this.rapidlyChangingMotionState.joint_position,
2405
+ c.joint_position,
2406
+ It
2407
+ ) || x(() => {
2408
+ this.rapidlyChangingMotionState.joint_position = c.joint_position;
2409
+ }), Rt(
2410
+ this.rapidlyChangingMotionState,
2411
+ c,
2412
+ It
2413
+ ) || x(() => {
2414
+ this.rapidlyChangingMotionState.tcp_pose = c.tcp_pose;
2415
+ }), c.tcp !== void 0 && this.rapidlyChangingMotionState.tcp !== c.tcp && x(() => {
2416
+ this.rapidlyChangingMotionState.tcp = c.tcp;
2417
+ }), this.rapidlyChangingMotionState.standstill !== c.standstill && x(() => {
2418
+ this.rapidlyChangingMotionState.standstill = c.standstill;
2419
+ });
2420
+ }), dt(this);
2421
+ }
2422
+ static async connectMultiple(t, o, i = {}) {
2423
+ const n = H(t), a = i.cellId ?? st(t);
2424
+ return Promise.all(
2425
+ o.map(
2426
+ (l) => gt.connect(n, l, {
2427
+ ...i,
2428
+ cellId: a
2429
+ })
2430
+ )
2431
+ );
2432
+ }
2433
+ static async connect(t, o, i = {}) {
2434
+ var _, J;
2435
+ const n = H(t), a = i.cellId ?? st(t) ?? "cell", [l, s] = o.split("@"), h = await n.api.controller.getCurrentRobotControllerState(
2436
+ a,
2437
+ s
2438
+ ), g = h == null ? void 0 : h.motion_groups.find(
2439
+ (E) => E.motion_group === o
2440
+ );
2441
+ if (!h || !g)
2442
+ throw new Error(
2443
+ `Controller ${s} or motion group ${o} not found`
2444
+ );
2445
+ const p = n.openReconnectingWebsocket(
2446
+ `/cells/${a}/controllers/${s}/motion-groups/${o}/state-stream`
2447
+ ), m = await p.firstMessage(), d = (_ = P(m.data)) == null ? void 0 : _.result;
2448
+ if (!d)
2449
+ throw new Error(
2450
+ `Unable to parse initial motion state message ${m.data}`
2451
+ );
2452
+ console.log(
2453
+ `Connected motion state websocket to motion group ${g.motion_group}. Initial state:
2454
+ `,
2455
+ d
2456
+ );
2457
+ const f = (await n.api.controller.getRobotController(
2458
+ a,
2459
+ h.controller
2460
+ )).configuration.kind === "VirtualController", y = await n.api.motionGroup.getMotionGroupDescription(
2461
+ a,
2462
+ s,
2463
+ g.motion_group
2464
+ ), u = Object.entries(y.tcps || {}).map(
2465
+ ([E, R]) => ({
2466
+ id: E,
2467
+ readable_name: R.name,
2468
+ position: R.pose.position,
2469
+ orientation: R.pose.orientation
2470
+ })
2471
+ ), b = n.openReconnectingWebsocket(
2472
+ `/cells/${a}/controllers/${h.controller}/state-stream?response_rate=1000`
2473
+ ), I = await b.firstMessage(), M = (J = P(I.data)) == null ? void 0 : J.result;
2474
+ if (!M)
2475
+ throw new Error(
2476
+ `Unable to parse initial controller state message ${I.data}`
2477
+ );
2478
+ return console.log(
2479
+ `Connected controller state websocket to controller ${h.controller}. Initial state:
2480
+ `,
2481
+ M
2482
+ ), new gt(
2483
+ n,
2484
+ h,
2485
+ g,
2486
+ d,
2487
+ p,
2488
+ f,
2489
+ u,
2490
+ y,
2491
+ M,
2492
+ b,
2493
+ a
2494
+ );
2495
+ }
2496
+ get motionGroupId() {
2497
+ return this.motionGroup.motion_group;
2498
+ }
2499
+ get controllerId() {
2500
+ return this.controller.controller;
2501
+ }
2502
+ get modelFromController() {
2503
+ return this.description.motion_group_model;
2504
+ }
2505
+ /** Jogging velocity in radians for rotation and joint movement */
2506
+ get joggingVelocityRads() {
2507
+ return this.joggingVelocity * Math.PI / 180;
2508
+ }
2509
+ get joints() {
2510
+ return this.initialMotionState.joint_position.map((t, o) => ({
2511
+ index: o
2512
+ }));
2513
+ }
2514
+ // Please note that API v2 omits 0 values
2515
+ get dhParameters() {
2516
+ if (this.description.dh_parameters !== void 0)
2517
+ return this.description.dh_parameters.map((t) => ({
2518
+ ...Ue,
2519
+ ...t
2520
+ }));
2521
+ }
2522
+ get safetyZones() {
2523
+ return this.description.safety_zones;
2524
+ }
2525
+ /** Gets the robot mounting position offset in 3D viz coordinates */
2526
+ get mountingPosition() {
2527
+ var t, o, i;
2528
+ return this.description.mounting ? [
2529
+ (((t = this.description.mounting.position) == null ? void 0 : t[0]) || 0) / 1e3,
2530
+ (((o = this.description.mounting.position) == null ? void 0 : o[1]) || 0) / 1e3,
2531
+ (((i = this.description.mounting.position) == null ? void 0 : i[2]) || 0) / 1e3
2532
+ ] : [0, 0, 0];
2533
+ }
2534
+ /** Gets the robot mounting position rotation in 3D viz coordinates */
2535
+ get mountingQuaternion() {
2536
+ var n, a, l, s, h, g;
2537
+ const t = new bt.Vector3(
2538
+ ((a = (n = this.description.mounting) == null ? void 0 : n.orientation) == null ? void 0 : a[0]) || 0,
2539
+ ((s = (l = this.description.mounting) == null ? void 0 : l.orientation) == null ? void 0 : s[1]) || 0,
2540
+ ((g = (h = this.description.mounting) == null ? void 0 : h.orientation) == null ? void 0 : g[2]) || 0
2541
+ ), o = t.length(), i = t.normalize();
2542
+ return new bt.Quaternion().setFromAxisAngle(i, o);
2543
+ }
2544
+ /**
2545
+ * Whether the controller is currently in a safety state
2546
+ * corresponding to an emergency stop
2547
+ */
2548
+ get isEstopActive() {
2549
+ return [
2550
+ "SAFETY_STATE_ROBOT_EMERGENCY_STOP",
2551
+ "SAFETY_STATE_DEVICE_EMERGENCY_STOP"
2552
+ ].includes(this.controllerState.safety_state);
2553
+ }
2554
+ /**
2555
+ * Whether the controller is in a safety state
2556
+ * that may be non-functional for robot pad purposes
2557
+ */
2558
+ get isMoveableSafetyState() {
2559
+ return [
2560
+ "SAFETY_STATE_NORMAL",
2561
+ "SAFETY_STATE_REDUCED"
2562
+ ].includes(this.controllerState.safety_state);
2563
+ }
2564
+ /**
2565
+ * Whether the controller is in an operation mode that allows movement
2566
+ */
2567
+ get isMoveableOperationMode() {
2568
+ return [
2569
+ "OPERATION_MODE_AUTO",
2570
+ "OPERATION_MODE_MANUAL",
2571
+ "OPERATION_MODE_MANUAL_T1",
2572
+ "OPERATION_MODE_MANUAL_T2"
2573
+ ].includes(this.controllerState.operation_mode);
2574
+ }
2575
+ /**
2576
+ * Whether the robot is currently active and can be moved, based on the
2577
+ * safety state, operation mode and servo toggle activation state.
2578
+ */
2579
+ get canBeMoved() {
2580
+ return this.isMoveableSafetyState && this.isMoveableOperationMode && this.activationState === "active";
2581
+ }
2582
+ async deactivate() {
2583
+ if (this.activationState !== "active") {
2584
+ console.error("Tried to deactivate while already deactivating");
2585
+ return;
2586
+ }
2587
+ x(() => {
2588
+ this.activationState = "deactivating";
2589
+ });
2590
+ try {
2591
+ await this.nova.api.controller.setDefaultMode(
2592
+ this.cellId,
2593
+ this.controllerId,
2594
+ "ROBOT_SYSTEM_MODE_MONITOR"
2595
+ ), x(() => {
2596
+ this.activationState = "inactive";
2597
+ });
2598
+ } catch (t) {
2599
+ throw x(() => {
2600
+ this.activationState = "active";
2601
+ }), t;
2602
+ }
2603
+ }
2604
+ async activate() {
2605
+ if (this.activationState !== "inactive") {
2606
+ console.error("Tried to activate while already activating");
2607
+ return;
2608
+ }
2609
+ x(() => {
2610
+ this.activationState = "activating";
2611
+ });
2612
+ try {
2613
+ await this.nova.api.controller.setDefaultMode(
2614
+ this.cellId,
2615
+ this.controllerId,
2616
+ "ROBOT_SYSTEM_MODE_CONTROL"
2617
+ ), x(() => {
2618
+ this.activationState = "active";
2619
+ });
2620
+ } catch (t) {
2621
+ throw x(() => {
2622
+ this.activationState = "inactive";
2623
+ }), t;
2624
+ }
2625
+ }
2626
+ toggleActivation() {
2627
+ this.activationState === "inactive" ? this.activate() : this.activationState === "active" && this.deactivate();
2628
+ }
2629
+ dispose() {
2630
+ this.motionStateSocket.close(), this.controllerStateSocket.close(), this.connectedJoggingSocket && this.connectedJoggingSocket.close();
2631
+ }
2632
+ setJoggingVelocity(t) {
2633
+ this.joggingVelocity = t;
2634
+ }
2635
+ }
2636
+ export {
2637
+ Ho as A,
2638
+ gt as C,
2639
+ ut as J,
2640
+ Ie as L,
2641
+ mt as M,
2642
+ Yo as N,
2643
+ $e as V,
2644
+ vt as a,
2645
+ xe as b,
2646
+ qo as c,
2647
+ pt as d,
2648
+ Me as e,
2649
+ Pt as f,
2650
+ Jt as j,
2651
+ Ce as p,
2652
+ Rt as t,
2653
+ we as u
2654
+ };