@esrf/daiquiri-lib 0.0.1-alpha.2 → 0.0.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,231 +1,437 @@
1
- import { jsxs as o, jsx as a, Fragment as A } from "react/jsx-runtime";
2
- import { Form as m, OverlayTrigger as E, Popover as b, Button as w, Badge as z, InputGroup as I } from "react-bootstrap";
3
- import { forwardRef as T, useRef as M, useState as N, useEffect as q } from "react";
4
- import V from "classnames";
5
- import { map as $ } from "lodash";
6
- function K(e) {
1
+ import { jsxs as l, jsx as n, Fragment as S } from "react/jsx-runtime";
2
+ import { map as E } from "lodash";
3
+ import { Badge as C, ButtonGroup as _, Button as m, OverlayTrigger as F, Popover as v, Container as z, Row as L, Col as D, Form as N, InputGroup as p } from "react-bootstrap";
4
+ import { forwardRef as H, useRef as M, useState as O, useEffect as k } from "react";
5
+ import x from "classnames";
6
+ import K from "debug";
7
+ function Y(e) {
7
8
  const {
8
9
  activeMessage: t = "Online",
9
10
  inactiveMessage: r = "Offline",
10
- message: n = "This device is"
11
+ message: a = "This device is"
11
12
  } = e;
12
- return /* @__PURE__ */ a(
13
+ return /* @__PURE__ */ n(
13
14
  "div",
14
15
  {
15
16
  className: `dot-indicator small bg-${e.online ? "success" : "danger"}`,
16
- title: `${n} ${e.online ? t : r}`
17
+ title: `${a} ${e.online ? t : r}`
17
18
  }
18
19
  );
19
20
  }
20
- function W(e) {
21
+ function I(e) {
21
22
  const { name: t, icon: r } = e;
22
- return /* @__PURE__ */ o("div", { className: "icon", title: t, children: [
23
- /* @__PURE__ */ a("i", { className: `fa ${r}` }),
24
- /* @__PURE__ */ a(K, { ...e })
23
+ return /* @__PURE__ */ l("div", { className: "icon", title: t, children: [
24
+ /* @__PURE__ */ n("i", { className: `fa ${r}` }),
25
+ /* @__PURE__ */ n(Y, { ...e })
25
26
  ] });
26
27
  }
27
- function G(e) {
28
+ function Z(e) {
29
+ const t = {
30
+ 24: "Y",
31
+ 21: "Z",
32
+ 18: "E",
33
+ 15: "P",
34
+ 12: "T",
35
+ 9: "G",
36
+ 6: "M",
37
+ 3: "k",
38
+ "-3": "m",
39
+ "-6": "µ",
40
+ "-9": "n",
41
+ "-12": "p",
42
+ "-15": "f",
43
+ "-18": "a",
44
+ "-21": "z",
45
+ "-24": "y"
46
+ }, r = Math.log(e) / Math.log(1e3), a = !Number.isInteger(r), o = 3 * Math.ceil(r - (a ? 1 : 0)), i = o === 0 ? "" : t[o];
47
+ return {
48
+ scalar: e * 10 ** -o,
49
+ prefix: i,
50
+ multiplier: 10 ** -o
51
+ };
52
+ }
53
+ function J(e) {
54
+ return e.charAt(0).toUpperCase() + e.slice(1);
55
+ }
56
+ function U(e) {
57
+ if (e < 60)
58
+ return `${Math.round(e)} sec`;
59
+ const t = Math.round(e / 60), r = t % 60, a = Math.floor(t / 60);
60
+ return a ? `${a} hr ${r} min` : `${r} min`;
61
+ }
62
+ function Q(e) {
63
+ return e > 0 ? (662607004e-42 * 299792458 / (e * 1e-10) / 160218e-24 * 1e-3).toFixed(4) : 0;
64
+ }
65
+ function X(e, t) {
66
+ return Number.parseFloat(e.toFixed(t));
67
+ }
68
+ const me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
69
+ __proto__: null,
70
+ formatEng: Z,
71
+ round: X,
72
+ toEnergy: Q,
73
+ toHoursMins: U,
74
+ ucfirst: J
75
+ }, Symbol.toStringTag, { value: "Module" }));
76
+ function ee(e) {
77
+ const { hardware: t } = e;
78
+ function r(u) {
79
+ t.requestChange({
80
+ function: "reset"
81
+ });
82
+ }
83
+ const a = {
84
+ "Front End": "feitlk",
85
+ Experimental: "expitlk",
86
+ PSS: "pssitlk"
87
+ }, o = {
88
+ Current: `${t.properties.current.toFixed(1)} mA`,
89
+ Mode: t.properties.mode,
90
+ Refill: U(t.properties.refill),
91
+ Message: /* @__PURE__ */ n("pre", { children: t.properties.message })
92
+ };
93
+ function i(u) {
94
+ if (!(u in t.properties))
95
+ return "UNKNOWN";
96
+ const d = t.properties[u];
97
+ return !d || typeof d != "string" ? "UNKNOWN" : d;
98
+ }
99
+ return /* @__PURE__ */ n(
100
+ F,
101
+ {
102
+ trigger: "click",
103
+ rootClose: !0,
104
+ overlay: /* @__PURE__ */ l(v, { id: "popid", children: [
105
+ /* @__PURE__ */ l(v.Header, { children: [
106
+ t.name,
107
+ " Details"
108
+ ] }),
109
+ /* @__PURE__ */ l(v.Body, { children: [
110
+ /* @__PURE__ */ n("h6", { children: "Status" }),
111
+ /* @__PURE__ */ n("pre", { children: t.properties.status }),
112
+ /* @__PURE__ */ n("h6", { children: "Interlocks" }),
113
+ /* @__PURE__ */ n(z, { children: E(a, (u, d) => /* @__PURE__ */ l(L, { children: [
114
+ /* @__PURE__ */ l(D, { children: [
115
+ d,
116
+ ":"
117
+ ] }),
118
+ /* @__PURE__ */ n(D, { children: /* @__PURE__ */ n(
119
+ C,
120
+ {
121
+ bg: i(u) === "ON" ? "success" : "danger",
122
+ children: i(u)
123
+ }
124
+ ) })
125
+ ] }, d)) }),
126
+ /* @__PURE__ */ n("h6", { children: "Ring Status" }),
127
+ /* @__PURE__ */ n(z, { children: E(o, (u, d) => /* @__PURE__ */ l(L, { children: [
128
+ /* @__PURE__ */ l(D, { children: [
129
+ d,
130
+ ":"
131
+ ] }),
132
+ /* @__PURE__ */ n(D, { children: u })
133
+ ] }, d)) }),
134
+ /* @__PURE__ */ n("div", { className: "d-grid gap-2", children: /* @__PURE__ */ n(m, { disabled: e.disabled, onClick: r, children: "Reset" }) })
135
+ ] })
136
+ ] }),
137
+ children: /* @__PURE__ */ n(m, { className: "flex-grow-0", title: "Shutter Details", children: /* @__PURE__ */ n("i", { className: "fa fa-ellipsis-h" }) })
138
+ }
139
+ );
140
+ }
141
+ function we(e) {
142
+ const { hardware: t, options: r = {} } = e;
143
+ function a(o) {
144
+ t.requestChange({
145
+ function: t.properties.frontend === "FE open" ? "close" : "open"
146
+ });
147
+ }
148
+ return /* @__PURE__ */ l("div", { className: "hw-component", children: [
149
+ /* @__PURE__ */ l("div", { className: "hw-head", children: [
150
+ /* @__PURE__ */ n(
151
+ I,
152
+ {
153
+ name: "Frontend",
154
+ icon: "fam-hardware-frontend",
155
+ online: t.online
156
+ }
157
+ ),
158
+ /* @__PURE__ */ n("div", { className: "name", children: t.name }),
159
+ /* @__PURE__ */ n(
160
+ C,
161
+ {
162
+ bg: t.properties.state === "OPEN" || t.properties.state === "RUNNING" ? "success" : "danger",
163
+ children: t.properties.state
164
+ }
165
+ )
166
+ ] }),
167
+ /* @__PURE__ */ n("div", { className: "hw-content", children: /* @__PURE__ */ l(_, { className: "d-flex", children: [
168
+ /* @__PURE__ */ n(
169
+ m,
170
+ {
171
+ variant: t.properties.frontend === "FE open" ? "danger" : "success",
172
+ onClick: a,
173
+ disabled: e.disabled,
174
+ children: t.properties.frontend === "FE open" ? "Close" : "Open"
175
+ }
176
+ ),
177
+ /* @__PURE__ */ n(ee, { ...e })
178
+ ] }) })
179
+ ] });
180
+ }
181
+ function ge(e) {
182
+ const { hardware: t, options: r = {} } = e;
183
+ function a() {
184
+ const o = r.property;
185
+ if (o === void 0)
186
+ return "property is not set";
187
+ if (o === null)
188
+ return "property is null";
189
+ let i = t;
190
+ for (const u of o.split("/"))
191
+ if (i = i[u], i === void 0)
192
+ return `property '${o}' not found`;
193
+ return `${i}`;
194
+ }
195
+ return /* @__PURE__ */ n(S, { children: a() });
196
+ }
197
+ function A(e) {
28
198
  const { headerMode: t, hardware: r } = e;
29
- function n() {
199
+ function a() {
30
200
  return r.alias ? r.alias : r.name ? r.name : r.id;
31
201
  }
32
- const s = n();
202
+ const o = a();
33
203
  switch (t) {
34
204
  case "front":
35
- return /* @__PURE__ */ a("div", { className: "hw-component", children: /* @__PURE__ */ o("div", { className: "hw-single", children: [
205
+ return /* @__PURE__ */ n("div", { className: "hw-component", children: /* @__PURE__ */ l("div", { className: "hw-single", children: [
36
206
  e.widgetIcon,
37
- /* @__PURE__ */ a("div", { className: "name", children: s }),
38
- /* @__PURE__ */ a("div", { className: "d-inline-block", children: e.widgetContent })
207
+ /* @__PURE__ */ n("div", { className: "name", children: o }),
208
+ /* @__PURE__ */ n("div", { className: "d-inline-block", children: e.widgetContent })
39
209
  ] }) });
40
210
  case "none":
41
- return /* @__PURE__ */ a("div", { className: "hw-component", children: /* @__PURE__ */ a("div", { className: "hw-single", children: e.widgetContent }) });
211
+ return /* @__PURE__ */ n("div", { className: "hw-component", children: /* @__PURE__ */ n("div", { className: "hw-single", children: e.widgetContent }) });
42
212
  case "state":
43
213
  return e.widgetState;
44
214
  default:
45
- return /* @__PURE__ */ o("div", { className: "hw-component", children: [
46
- /* @__PURE__ */ o("div", { className: "hw-head", children: [
215
+ return /* @__PURE__ */ l("div", { className: "hw-component", children: [
216
+ /* @__PURE__ */ l("div", { className: "hw-head", children: [
47
217
  e.widgetIcon,
48
- /* @__PURE__ */ a("div", { className: "name", children: /* @__PURE__ */ a(m.Label, { htmlFor: r.id, children: s }) }),
218
+ /* @__PURE__ */ n("div", { className: "name", children: /* @__PURE__ */ n(N.Label, { htmlFor: r.id, children: o }) }),
49
219
  e.widgetState,
50
- e.hardware.errors && e.hardware.errors.length > 0 && /* @__PURE__ */ a(
51
- E,
220
+ e.hardware.errors && e.hardware.errors.length > 0 && /* @__PURE__ */ n(
221
+ F,
52
222
  {
53
223
  trigger: "click",
54
224
  placement: "bottom",
55
225
  rootClose: !0,
56
- overlay: /* @__PURE__ */ o(b, { id: e.hardware.id, style: { maxWidth: 500 }, children: [
57
- /* @__PURE__ */ a(b.Header, { children: "Device Errors" }),
58
- /* @__PURE__ */ o(b.Body, { children: [
226
+ overlay: /* @__PURE__ */ l(v, { id: e.hardware.id, style: { maxWidth: 500 }, children: [
227
+ /* @__PURE__ */ n(v.Header, { children: "Device Errors" }),
228
+ /* @__PURE__ */ l(v.Body, { children: [
59
229
  "There were errors with properties on this device:",
60
- /* @__PURE__ */ a("ul", { children: e.hardware.errors.map((l) => /* @__PURE__ */ o("li", { children: [
61
- l.property,
230
+ /* @__PURE__ */ n("ul", { children: e.hardware.errors.map((i) => /* @__PURE__ */ l("li", { children: [
231
+ i.property,
62
232
  ":",
63
- /* @__PURE__ */ o("span", { className: "stack-trace", children: [
64
- l.traceback,
65
- /* @__PURE__ */ a("br", {}),
66
- l.exception
233
+ /* @__PURE__ */ l("span", { className: "stack-trace", children: [
234
+ i.traceback,
235
+ /* @__PURE__ */ n("br", {}),
236
+ i.exception
67
237
  ] })
68
238
  ] })) })
69
239
  ] })
70
240
  ] }),
71
- children: /* @__PURE__ */ a(w, { variant: "danger", size: "sm", children: /* @__PURE__ */ a("i", { className: "fa fa-exclamation-triangle" }) })
241
+ children: /* @__PURE__ */ n(m, { variant: "danger", size: "sm", children: /* @__PURE__ */ n("i", { className: "fa fa-exclamation-triangle" }) })
72
242
  }
73
243
  )
74
244
  ] }),
75
- /* @__PURE__ */ a("div", { className: "hw-content", children: e.widgetContent })
245
+ /* @__PURE__ */ n("div", { className: "hw-content", children: e.widgetContent })
76
246
  ] });
77
247
  }
78
248
  }
79
- function P(e) {
249
+ function q(e) {
80
250
  const t = {
81
251
  display: "inline-block",
82
252
  minWidth: ""
83
253
  };
84
- return e.minWidth && (t.minWidth = `${e.minWidth}em`), /* @__PURE__ */ a("div", { style: t, children: /* @__PURE__ */ a(z, { bg: e.variant, children: e.state }) });
254
+ return e.minWidth && (t.minWidth = `${e.minWidth}em`), /* @__PURE__ */ n("div", { style: t, children: /* @__PURE__ */ n(C, { bg: e.variant, children: e.state }) });
85
255
  }
86
- function H(e) {
256
+ function W(e) {
87
257
  const { hardware: t } = e;
88
258
  function r() {
89
259
  if (!t.online)
90
260
  return "OFFLINE";
91
- let s = "UNKNOWN";
92
- return e.hardware.properties.state && ([s] = e.hardware.properties.state), s;
261
+ let o = "UNKNOWN";
262
+ return e.hardware.properties.state && ([o] = e.hardware.properties.state), o;
93
263
  }
94
- const n = r();
95
- return /* @__PURE__ */ a(
96
- P,
264
+ const a = r();
265
+ return /* @__PURE__ */ n(
266
+ q,
97
267
  {
98
- state: n,
268
+ state: a,
99
269
  minWidth: 6,
100
- variant: n === "READY" ? "success" : "warning"
270
+ variant: a === "READY" ? "success" : "warning"
101
271
  }
102
272
  );
103
273
  }
104
- const B = T((e, t) => {
105
- const r = M(null), [n, s] = N(e.step), l = (d) => {
106
- const D = t;
274
+ function B(e) {
275
+ const { hardware: t } = e;
276
+ function r() {
277
+ if (!t.online)
278
+ return "OFFLINE";
279
+ const i = t.properties.state;
280
+ return e.useReadyState && (i === "OPEN" || i === "CLOSED") ? "READY" : i;
281
+ }
282
+ const a = r();
283
+ function o() {
284
+ switch (a) {
285
+ case "READY":
286
+ return "success";
287
+ case "OPEN":
288
+ return "success";
289
+ case "CLOSED":
290
+ return "danger";
291
+ case "DISABLED":
292
+ return "secondary";
293
+ case "MOVING":
294
+ case "STANDBY":
295
+ case "OFFLINE":
296
+ return "warning";
297
+ case "FAULT":
298
+ return "fatal";
299
+ default:
300
+ return "fatal";
301
+ }
302
+ }
303
+ return /* @__PURE__ */ n(q, { state: a, minWidth: 6, variant: o() });
304
+ }
305
+ const ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
306
+ __proto__: null,
307
+ HardwareState: q,
308
+ MotorState: W,
309
+ ShutterState: B
310
+ }, Symbol.toStringTag, { value: "Module" })), te = H((e, t) => {
311
+ const r = M(null), [a, o] = O(e.step), i = (h) => {
312
+ const R = t;
107
313
  if (r.current === null)
108
314
  return;
109
- let S = Number.parseFloat(D.current.value);
110
- const k = Number.parseFloat(r.current.value);
111
- S += d ? k : -k, D.current.value = `${S}`, e.onStep && e.onStep({
112
- target: D.current
315
+ let $ = Number.parseFloat(R.current.value);
316
+ const P = Number.parseFloat(r.current.value);
317
+ $ += h ? P : -P, R.current.value = `${$}`, e.onStep && e.onStep({
318
+ target: R.current
113
319
  });
114
320
  }, {
115
- onStep: h,
116
- step: g,
117
- overlay: v,
118
- incIcon: f,
119
- decIcon: i,
321
+ onStep: u,
322
+ step: d,
323
+ overlay: g,
324
+ incIcon: w,
325
+ decIcon: s,
120
326
  swapIncDec: c,
121
- onKeyDown: u,
327
+ onKeyDown: f,
122
328
  horizontalArrows: y,
123
- largeArrows: x,
124
- ...C
125
- } = e, O = (d) => {
126
- d.key === "ArrowUp" ? (d.preventDefault(), l(!0)) : d.key === "ArrowDown" ? (d.preventDefault(), l(!1)) : u && u(d);
329
+ largeArrows: V,
330
+ ...b
331
+ } = e, T = (h) => {
332
+ h.key === "ArrowUp" ? (h.preventDefault(), i(!0)) : h.key === "ArrowDown" ? (h.preventDefault(), i(!1)) : f && f(h);
127
333
  };
128
334
  if (!e.step)
129
- return /* @__PURE__ */ a(
130
- m.Control,
335
+ return /* @__PURE__ */ n(
336
+ N.Control,
131
337
  {
132
338
  ref: t,
133
339
  type: "number",
134
340
  step: "any",
135
- onKeyDown: O,
136
- ...C
341
+ onKeyDown: T,
342
+ ...b
137
343
  }
138
344
  );
139
- const F = $(e.steps || [e.step], (d) => /* @__PURE__ */ a("option", { value: d, children: d }, d));
140
- return /* @__PURE__ */ a(
345
+ const j = E(e.steps || [e.step], (h) => /* @__PURE__ */ n("option", { value: h, children: h }, h));
346
+ return /* @__PURE__ */ n(
141
347
  "div",
142
348
  {
143
- className: V("numeric-step", {
144
- "numeric-step-large": x,
349
+ className: x("numeric-step", {
350
+ "numeric-step-large": V,
145
351
  "numeric-step-horizontal": y
146
352
  }),
147
- children: /* @__PURE__ */ o(I, { children: [
148
- /* @__PURE__ */ a(
149
- m.Control,
353
+ children: /* @__PURE__ */ l(p, { children: [
354
+ /* @__PURE__ */ n(
355
+ N.Control,
150
356
  {
151
- onKeyDown: O,
357
+ onKeyDown: T,
152
358
  ref: t,
153
359
  type: "number",
154
360
  step: "any",
155
- ...C
361
+ ...b
156
362
  }
157
363
  ),
158
- /* @__PURE__ */ o(A, { children: [
159
- v,
160
- !v && /* @__PURE__ */ o(I.Text, { className: "d-flex flex-column", children: [
161
- /* @__PURE__ */ a(
162
- m.Control,
364
+ /* @__PURE__ */ l(S, { children: [
365
+ g,
366
+ !g && /* @__PURE__ */ l(p.Text, { className: "d-flex flex-column", children: [
367
+ /* @__PURE__ */ n(
368
+ N.Control,
163
369
  {
164
370
  ref: r,
165
371
  as: "select",
166
372
  className: "step-size",
167
- defaultValue: n,
168
- onChange: (d) => s(Number.parseFloat(d.target.value)),
169
- children: F
373
+ defaultValue: a,
374
+ onChange: (h) => o(Number.parseFloat(h.target.value)),
375
+ children: j
170
376
  }
171
377
  ),
172
- e.unit && /* @__PURE__ */ a("div", { children: e.unit }),
173
- !f && !i && /* @__PURE__ */ o(A, { children: [
174
- /* @__PURE__ */ a(
175
- w,
378
+ e.unit && /* @__PURE__ */ n("div", { children: e.unit }),
379
+ !w && !s && /* @__PURE__ */ l(S, { children: [
380
+ /* @__PURE__ */ n(
381
+ m,
176
382
  {
177
383
  className: "step step-up",
178
384
  disabled: e.disabled,
179
- onClick: (d) => l(!0)
385
+ onClick: (h) => i(!0)
180
386
  }
181
387
  ),
182
- /* @__PURE__ */ a(
183
- w,
388
+ /* @__PURE__ */ n(
389
+ m,
184
390
  {
185
391
  className: "step step-down",
186
392
  disabled: e.disabled,
187
- onClick: (d) => l(!1)
393
+ onClick: (h) => i(!1)
188
394
  }
189
395
  )
190
396
  ] })
191
397
  ] }),
192
- i && c && /* @__PURE__ */ a(w, { disabled: e.disabled, onClick: (d) => l(!1), children: /* @__PURE__ */ a("i", { className: `fa fa-fw fa-${i}` }) }),
193
- f && /* @__PURE__ */ a(w, { disabled: e.disabled, onClick: (d) => l(!0), children: /* @__PURE__ */ a("i", { className: `fa fa-fw fa-${f}` }) }),
194
- i && !c && /* @__PURE__ */ a(w, { disabled: e.disabled, onClick: (d) => l(!1), children: /* @__PURE__ */ a("i", { className: `fa fa-fw fa-${i}` }) })
398
+ s && c && /* @__PURE__ */ n(m, { disabled: e.disabled, onClick: (h) => i(!1), children: /* @__PURE__ */ n("i", { className: `fa fa-fw fa-${s}` }) }),
399
+ w && /* @__PURE__ */ n(m, { disabled: e.disabled, onClick: (h) => i(!0), children: /* @__PURE__ */ n("i", { className: `fa fa-fw fa-${w}` }) }),
400
+ s && !c && /* @__PURE__ */ n(m, { disabled: e.disabled, onClick: (h) => i(!1), children: /* @__PURE__ */ n("i", { className: `fa fa-fw fa-${s}` }) })
195
401
  ] })
196
402
  ] })
197
403
  }
198
404
  );
199
- }), L = B;
200
- function U(e) {
201
- const t = M(null), [r, n] = N(!1), [s, l] = N(!1);
202
- q(() => {
203
- t.current && (e.hardwareValue === null ? t.current.value = "" : t.current.value = e.hardwareValue.toString(), n(!1));
405
+ }), ne = te;
406
+ function re(e) {
407
+ const t = M(null), [r, a] = O(!1), [o, i] = O(!1);
408
+ k(() => {
409
+ t.current && (e.hardwareValue === null ? t.current.value = "" : t.current.value = e.hardwareValue.toString(), a(!1));
204
410
  }, [e.hardwareValue]);
205
- function h(c) {
206
- let u = c;
207
- e.precision !== void 0 && (u = Number.parseFloat(u).toFixed(e.precision)), t != null && t.current && (t.current.value = u);
411
+ function u(c) {
412
+ let f = c;
413
+ e.precision !== void 0 && (f = Number.parseFloat(f).toFixed(e.precision)), t != null && t.current && (t.current.value = f);
208
414
  }
209
- function g() {
415
+ function d() {
210
416
  r && setTimeout(() => {
211
- h(e.hardwareValue), n(!1);
417
+ u(e.hardwareValue), a(!1);
212
418
  }, 3e3);
213
419
  }
214
- function v(c) {
215
- e.hardwareValue !== null && (n(!0), t != null && t.current && (t.current.value = c.target.value), c.target.value === e.hardwareValue.toString() && n(!1));
420
+ function g(c) {
421
+ e.hardwareValue !== null && (a(!0), t != null && t.current && (t.current.value = c.target.value), c.target.value === e.hardwareValue.toString() && a(!1));
216
422
  }
217
- function f(c) {
218
- n(!1), e.onMoveRequested(c.target.value);
423
+ function w(c) {
424
+ a(!1), e.onMoveRequested(c.target.value);
219
425
  }
220
- function i(c) {
426
+ function s(c) {
221
427
  switch (c.key) {
222
428
  case "Enter":
223
429
  {
224
- n(!1);
225
- const u = Number.parseFloat(c.target.value), y = e.onMoveRequested(u);
430
+ a(!1);
431
+ const f = Number.parseFloat(c.target.value), y = e.onMoveRequested(f);
226
432
  y && y.catch(() => {
227
- l(!0), setTimeout(() => {
228
- h(e.hardwareValue), l(!1);
433
+ i(!0), setTimeout(() => {
434
+ u(e.hardwareValue), i(!1);
229
435
  }, 2e3);
230
436
  });
231
437
  }
@@ -233,26 +439,26 @@ function U(e) {
233
439
  break;
234
440
  case "Esc":
235
441
  case "Escape":
236
- r && (l(!1), n(!1), h(e.hardwareValue)), c.target.blur(), c.preventDefault(), c.stopPropagation();
442
+ r && (i(!1), a(!1), u(e.hardwareValue)), c.target.blur(), c.preventDefault(), c.stopPropagation();
237
443
  break;
238
444
  }
239
445
  }
240
- return /* @__PURE__ */ a(
241
- L,
446
+ return /* @__PURE__ */ n(
447
+ ne,
242
448
  {
243
449
  id: e.id,
244
- className: V({
450
+ className: x({
245
451
  "form-control-edited": r,
246
- "form-control-error": s,
452
+ "form-control-error": o,
247
453
  "hw-moving": e.hardwareIsMoving
248
454
  }),
249
455
  type: e.readOnly ? "text" : "number",
250
456
  ref: t,
251
457
  precision: e.precision,
252
- onChange: v,
253
- onBlur: g,
254
- onStep: f,
255
- onKeyDown: i,
458
+ onChange: g,
459
+ onBlur: d,
460
+ onStep: w,
461
+ onKeyDown: s,
256
462
  disabled: e.hardwareIsDisabled || e.readOnly || !e.hardwareIsReady,
257
463
  step: e.step,
258
464
  steps: e.steps,
@@ -261,154 +467,154 @@ function U(e) {
261
467
  swapIncDec: e.swapIncDec,
262
468
  horizontalArrows: e.horizontalArrows,
263
469
  largeArrows: e.largeArrows,
264
- overlay: e.hardwareIsMoving && !e.hardwareIsDisabled ? /* @__PURE__ */ a(w, { variant: "danger", onClick: e.onAbortRequested, children: /* @__PURE__ */ a("i", { className: "fa fa-times" }) }) : null
470
+ overlay: e.hardwareIsMoving && !e.hardwareIsDisabled ? /* @__PURE__ */ n(m, { variant: "danger", onClick: e.onAbortRequested, children: /* @__PURE__ */ n("i", { className: "fa fa-times" }) }) : null
265
471
  }
266
472
  );
267
473
  }
268
- function R(e) {
269
- const t = M(null), [r, n] = N(!1), [s, l] = N(!1);
270
- function h(i) {
271
- return e.precision !== void 0 ? Number.parseFloat(i).toFixed(e.precision) : i;
474
+ function G(e) {
475
+ const t = M(null), [r, a] = O(!1), [o, i] = O(!1);
476
+ function u(s) {
477
+ return e.precision !== void 0 ? Number.parseFloat(s).toFixed(e.precision) : s;
272
478
  }
273
- q(() => {
274
- var i;
275
- t.current && (t.current.value = h((i = e.hardwareValue) == null ? void 0 : i.toString()), n(!1));
479
+ k(() => {
480
+ var s;
481
+ t.current && (t.current.value = u((s = e.hardwareValue) == null ? void 0 : s.toString()), a(!1));
276
482
  }, [e.hardwareValue, e.precision]);
277
- function g(i) {
278
- const c = h(i);
483
+ function d(s) {
484
+ const c = u(s);
279
485
  t != null && t.current && (t.current.value = c);
280
486
  }
281
- function v(i) {
282
- switch (i.key) {
487
+ function g(s) {
488
+ switch (s.key) {
283
489
  case "Enter": {
284
- n(!1);
285
- const c = Number.parseFloat(i.target.value), u = e.onMoveRequested(c);
286
- u && u.catch(() => {
287
- l(!0), setTimeout(() => {
288
- g(e.hardwareValue), l(!1);
490
+ a(!1);
491
+ const c = Number.parseFloat(s.target.value), f = e.onMoveRequested(c);
492
+ f && f.catch(() => {
493
+ i(!0), setTimeout(() => {
494
+ d(e.hardwareValue), i(!1);
289
495
  }, 2e3);
290
- }), i.preventDefault(), i.stopPropagation();
496
+ }), s.preventDefault(), s.stopPropagation();
291
497
  break;
292
498
  }
293
499
  case "Esc":
294
500
  case "Escape":
295
- r && (l(!1), n(!1), g(e.hardwareValue)), i.target.blur(), i.preventDefault(), i.stopPropagation();
501
+ r && (i(!1), a(!1), d(e.hardwareValue)), s.target.blur(), s.preventDefault(), s.stopPropagation();
296
502
  break;
297
503
  }
298
504
  }
299
- function f(i) {
300
- n(!0), i.target, t != null && t.current && (t.current.value = i.target.value), i.target.value === e.hardwareValue.toString() && n(!1);
505
+ function w(s) {
506
+ a(!0), s.target, t != null && t.current && (t.current.value = s.target.value), s.target.value === e.hardwareValue.toString() && a(!1);
301
507
  }
302
- return /* @__PURE__ */ a(
303
- m.Control,
508
+ return /* @__PURE__ */ n(
509
+ N.Control,
304
510
  {
305
- className: V({
511
+ className: x({
306
512
  "form-control-edited": r,
307
- "form-control-error": s,
513
+ "form-control-error": o,
308
514
  "hw-moving": e.hardwareIsMoving
309
515
  }),
310
516
  type: "number",
311
517
  ref: t,
312
- onChange: f,
313
- onKeyDown: v,
518
+ onChange: w,
519
+ onKeyDown: g,
314
520
  disabled: e.readOnly || e.hardwareIsMoving || e.hardwareIsDisabled,
315
521
  step: e.step
316
522
  }
317
523
  );
318
524
  }
319
- function Y(e) {
320
- function t(s) {
525
+ function ae(e) {
526
+ function t(o) {
321
527
  return e.hardware.requestChange({
322
528
  property: "velocity",
323
- value: s
529
+ value: o
324
530
  });
325
531
  }
326
- function r(s) {
532
+ function r(o) {
327
533
  return e.hardware.requestChange({
328
534
  property: "acceleration",
329
- value: s
535
+ value: o
330
536
  });
331
537
  }
332
- let n = "UNKNOWN";
333
- return e.hardware.properties.state && ([n] = e.hardware.properties.state), /* @__PURE__ */ a(
334
- E,
538
+ let a = "UNKNOWN";
539
+ return e.hardware.properties.state && ([a] = e.hardware.properties.state), /* @__PURE__ */ n(
540
+ F,
335
541
  {
336
542
  trigger: "click",
337
543
  rootClose: !0,
338
- overlay: /* @__PURE__ */ o(b, { id: "popid", children: [
339
- /* @__PURE__ */ o(b.Header, { children: [
544
+ overlay: /* @__PURE__ */ l(v, { id: "popid", children: [
545
+ /* @__PURE__ */ l(v.Header, { children: [
340
546
  e.hardware.name,
341
547
  " details"
342
548
  ] }),
343
- /* @__PURE__ */ o(b.Body, { children: [
344
- /* @__PURE__ */ o(m.Group, { children: [
345
- /* @__PURE__ */ a(m.Label, { children: "Velocity" }),
346
- /* @__PURE__ */ a(
347
- R,
549
+ /* @__PURE__ */ l(v.Body, { children: [
550
+ /* @__PURE__ */ l(N.Group, { children: [
551
+ /* @__PURE__ */ n(N.Label, { children: "Velocity" }),
552
+ /* @__PURE__ */ n(
553
+ G,
348
554
  {
349
555
  hardwareValue: e.hardware.properties.velocity,
350
556
  onMoveRequested: t,
351
557
  hardwareIsDisabled: e.disabled,
352
- hardwareIsReady: n === "READY",
353
- hardwareIsMoving: n === "MOVING",
558
+ hardwareIsReady: a === "READY",
559
+ hardwareIsMoving: a === "MOVING",
354
560
  readOnly: e.readOnly
355
561
  }
356
562
  )
357
563
  ] }),
358
- /* @__PURE__ */ o(m.Group, { children: [
359
- /* @__PURE__ */ a(m.Label, { children: "Acceleration" }),
360
- /* @__PURE__ */ a(
361
- R,
564
+ /* @__PURE__ */ l(N.Group, { children: [
565
+ /* @__PURE__ */ n(N.Label, { children: "Acceleration" }),
566
+ /* @__PURE__ */ n(
567
+ G,
362
568
  {
363
569
  hardwareValue: e.hardware.properties.acceleration,
364
570
  onMoveRequested: r,
365
571
  hardwareIsDisabled: e.disabled,
366
- hardwareIsReady: n === "READY",
367
- hardwareIsMoving: n === "MOVING",
572
+ hardwareIsReady: a === "READY",
573
+ hardwareIsMoving: a === "MOVING",
368
574
  readOnly: e.readOnly
369
575
  }
370
576
  )
371
577
  ] })
372
578
  ] })
373
579
  ] }),
374
- children: /* @__PURE__ */ a(w, { children: /* @__PURE__ */ a("i", { className: "fa fa-ellipsis-h" }) })
580
+ children: /* @__PURE__ */ n(m, { children: /* @__PURE__ */ n("i", { className: "fa fa-ellipsis-h" }) })
375
581
  }
376
582
  );
377
583
  }
378
- function _(e) {
584
+ function Ne(e) {
379
585
  const { hardware: t, options: r = {} } = e;
380
- function n() {
586
+ function a() {
381
587
  t.requestChange({
382
588
  function: "stop"
383
589
  });
384
590
  }
385
- function s(f) {
591
+ function o(w) {
386
592
  return t.requestChange({
387
593
  property: "position",
388
- value: f,
594
+ value: w,
389
595
  function: "move"
390
596
  });
391
597
  }
392
- let l = "UNKNOWN";
393
- e.hardware.properties.state && ([l] = e.hardware.properties.state);
394
- const h = /* @__PURE__ */ a(W, { name: "Motor", icon: "fam-hardware-motor", online: t.online }), g = /* @__PURE__ */ a(H, { hardware: t }), v = e.options ? e.options.header : "top";
395
- return /* @__PURE__ */ a(
396
- G,
598
+ let i = "UNKNOWN";
599
+ e.hardware.properties.state && ([i] = e.hardware.properties.state);
600
+ const u = /* @__PURE__ */ n(I, { name: "Motor", icon: "fam-hardware-motor", online: t.online }), d = /* @__PURE__ */ n(W, { hardware: t }), g = e.options ? e.options.header : "top";
601
+ return /* @__PURE__ */ n(
602
+ A,
397
603
  {
398
604
  hardware: t,
399
- widgetIcon: h,
400
- widgetState: g,
401
- widgetContent: /* @__PURE__ */ o(I, { children: [
402
- /* @__PURE__ */ a(
403
- U,
605
+ widgetIcon: u,
606
+ widgetState: d,
607
+ widgetContent: /* @__PURE__ */ l(p, { children: [
608
+ /* @__PURE__ */ n(
609
+ re,
404
610
  {
405
611
  id: t.id,
406
612
  hardwareValue: t.properties.position,
407
613
  hardwareIsDisabled: e.disabled,
408
- hardwareIsReady: l === "READY",
409
- hardwareIsMoving: l === "MOVING",
410
- onMoveRequested: s,
411
- onAbortRequested: n,
614
+ hardwareIsReady: i === "READY",
615
+ hardwareIsMoving: i === "MOVING",
616
+ onMoveRequested: o,
617
+ onAbortRequested: a,
412
618
  precision: r.precision,
413
619
  readOnly: r.readOnly,
414
620
  step: r.step,
@@ -420,22 +626,288 @@ function _(e) {
420
626
  largeArrows: r.largearrows
421
627
  }
422
628
  ),
423
- t.properties.unit && /* @__PURE__ */ a(I.Text, { children: t.properties.unit }),
424
- l !== "MOVING" && r.extended && /* @__PURE__ */ a(
425
- Y,
629
+ t.properties.unit && /* @__PURE__ */ n(p.Text, { children: t.properties.unit }),
630
+ i !== "MOVING" && r.extended && /* @__PURE__ */ n(
631
+ ae,
426
632
  {
427
633
  hardware: t,
428
634
  disabled: e.disabled,
429
635
  readOnly: r.readOnly
430
636
  }
431
637
  ),
432
- l === "MOVING" && !e.disabled && !r.step && /* @__PURE__ */ a(w, { variant: "danger", onClick: n, children: /* @__PURE__ */ a("i", { className: "fa fa-times" }) })
638
+ i === "MOVING" && !e.disabled && !r.step && /* @__PURE__ */ n(m, { variant: "danger", onClick: a, children: /* @__PURE__ */ n("i", { className: "fa fa-times" }) })
639
+ ] }),
640
+ headerMode: g
641
+ }
642
+ );
643
+ }
644
+ function be(e) {
645
+ const { hardware: t, options: r = {} } = e, a = M(null);
646
+ k(() => {
647
+ if (!a.current) {
648
+ console.error("selectionRef ref is unset");
649
+ return;
650
+ }
651
+ a.current.value = t.properties.position;
652
+ }, [t.properties.position]);
653
+ function o(d) {
654
+ if (console.debug("change", d), !a || !a.current) {
655
+ console.error("selection ref is unset");
656
+ return;
657
+ }
658
+ t.requestChange({
659
+ value: a.current.value,
660
+ function: "move"
661
+ });
662
+ }
663
+ function i(d) {
664
+ t.requestChange({
665
+ function: "stop"
666
+ });
667
+ }
668
+ const u = E(t.properties.positions, (d) => /* @__PURE__ */ n("option", { title: d.description, children: d.position }, d.position));
669
+ return /* @__PURE__ */ l("div", { className: "hw-component", children: [
670
+ /* @__PURE__ */ l("div", { className: "hw-head", children: [
671
+ /* @__PURE__ */ n(
672
+ I,
673
+ {
674
+ name: "Multiposition",
675
+ icon: "fam-hardware-multiposition",
676
+ online: t.online
677
+ }
678
+ ),
679
+ /* @__PURE__ */ n("div", { className: "name", children: t.name }),
680
+ /* @__PURE__ */ n(
681
+ C,
682
+ {
683
+ bg: t.properties.state === "READY" ? "success" : "warning",
684
+ children: t.properties.state
685
+ }
686
+ )
687
+ ] }),
688
+ /* @__PURE__ */ n("div", { className: "hw-content", children: /* @__PURE__ */ l(p, { children: [
689
+ /* @__PURE__ */ l(
690
+ N.Control,
691
+ {
692
+ className: "custom-select",
693
+ as: "select",
694
+ ref: a,
695
+ disabled: e.disabled,
696
+ defaultValue: t.properties.position,
697
+ children: [
698
+ /* @__PURE__ */ n("option", { disabled: !0, children: "unknown" }),
699
+ u
700
+ ]
701
+ }
702
+ ),
703
+ t.properties.state !== "MOVING" && /* @__PURE__ */ n(m, { onClick: o, disabled: e.disabled, children: "Move" }),
704
+ t.properties.state === "MOVING" && !e.disabled && /* @__PURE__ */ n(m, { variant: "danger", onClick: i, children: /* @__PURE__ */ n("i", { className: "fa fa-times" }) })
705
+ ] }) })
706
+ ] });
707
+ }
708
+ const ie = K("daiquiri.components.hardware.NoObject");
709
+ function pe(e) {
710
+ if (e.options.emptyifnone)
711
+ return ie(
712
+ 'Component id:"%s" name:"%s" not displayed cause setup with emptyifnone.',
713
+ e.id,
714
+ e.name
715
+ ), /* @__PURE__ */ n(S, {});
716
+ const t = /* @__PURE__ */ n(I, { name: "NoObject", icon: "fam-hardware-any", online: !1 }), r = /* @__PURE__ */ n(S, {}), a = /* @__PURE__ */ n(S, { children: "Missing" }), o = e.options ? e.options.header : "top", i = {
717
+ id: e.id,
718
+ name: e.name ?? "",
719
+ alias: null,
720
+ online: !1,
721
+ properties: {},
722
+ type: ""
723
+ };
724
+ return /* @__PURE__ */ n(
725
+ A,
726
+ {
727
+ hardware: i,
728
+ widgetIcon: t,
729
+ widgetState: r,
730
+ widgetContent: a,
731
+ headerMode: o
732
+ }
733
+ );
734
+ }
735
+ function oe(e) {
736
+ const t = e.online ? "READY" : "OFFLINE";
737
+ return /* @__PURE__ */ n(C, { bg: t === "READY" ? "success" : "warning", children: t });
738
+ }
739
+ function ye(e) {
740
+ const { hardware: t, options: r = {} } = e, a = /* @__PURE__ */ n(I, { name: "Optic", icon: "fa-cog", online: t.online }), o = /* @__PURE__ */ n(oe, { ...t });
741
+ function i() {
742
+ const s = r.property;
743
+ if (s === void 0)
744
+ return "property is not set";
745
+ if (s === null)
746
+ return "property is null";
747
+ let c = t;
748
+ for (const f of s.split("/"))
749
+ if (c = c[f], c === void 0)
750
+ return `property '${s}' not found`;
751
+ return `${c}`;
752
+ }
753
+ function u() {
754
+ const s = r.unit;
755
+ if (!s)
756
+ return null;
757
+ if (!s.includes("properties"))
758
+ return s;
759
+ let c = e;
760
+ for (const f of s.split("/"))
761
+ if (c = c[f], c === void 0)
762
+ return null;
763
+ return `${c}`;
764
+ }
765
+ const d = u(), g = /* @__PURE__ */ l(p, { children: [
766
+ /* @__PURE__ */ n(N.Control, { value: i(), readOnly: !0 }),
767
+ d && /* @__PURE__ */ n(p.Text, { children: d })
768
+ ] }), w = e.options.header || "top";
769
+ return /* @__PURE__ */ n(
770
+ A,
771
+ {
772
+ hardware: t,
773
+ widgetIcon: a,
774
+ widgetState: o,
775
+ widgetContent: g,
776
+ headerMode: w
777
+ }
778
+ );
779
+ }
780
+ function se(e) {
781
+ const { hardware: t } = e, r = () => {
782
+ t.requestChange({
783
+ function: "reset"
784
+ });
785
+ };
786
+ return /* @__PURE__ */ n(
787
+ F,
788
+ {
789
+ trigger: "click",
790
+ rootClose: !0,
791
+ overlay: /* @__PURE__ */ l(v, { id: "popid", children: [
792
+ /* @__PURE__ */ l(v.Header, { children: [
793
+ t.name,
794
+ " Details"
795
+ ] }),
796
+ /* @__PURE__ */ l(v.Body, { children: [
797
+ /* @__PURE__ */ n("h6", { children: "Status" }),
798
+ /* @__PURE__ */ n("pre", { children: t.properties.status }),
799
+ /* @__PURE__ */ n("div", { className: "d-grid gap-2", children: /* @__PURE__ */ n(m, { onClick: r, disabled: e.disabled, children: "Reset" }) })
800
+ ] })
433
801
  ] }),
434
- headerMode: v
802
+ children: /* @__PURE__ */ n(m, { className: "flex-grow-0", title: "Shutter Details", children: /* @__PURE__ */ n("i", { className: "fa fa-ellipsis-h" }) })
803
+ }
804
+ );
805
+ }
806
+ function Se(e) {
807
+ const { hardware: t, options: r = {} } = e, a = /* @__PURE__ */ n(
808
+ I,
809
+ {
810
+ name: "Shutter",
811
+ icon: "fam-hardware-shutter",
812
+ online: t.online
813
+ }
814
+ ), o = /* @__PURE__ */ n(B, { hardware: t });
815
+ function i() {
816
+ return t.properties ? t.properties.state : "UNKNOWN";
817
+ }
818
+ function u(b) {
819
+ return b === "OPEN" ? ["Close", "close"] : b === "CLOSED" ? ["Open", "open"] : b === "DISABLED" || b === "STANDBY" || b === "FAULT" ? ["Closed", ""] : b === "MOVING" ? ["...", ""] : ["Unknown", ""];
820
+ }
821
+ const d = i(), [g, w] = u(d), c = {
822
+ OPEN: "danger",
823
+ CLOSED: "success",
824
+ MOVING: "warning",
825
+ DISABLED: "secondary",
826
+ STANDBY: "danger",
827
+ FAULT: "fatal",
828
+ UNKNOWN: "warning"
829
+ }[d] || "danger";
830
+ function f() {
831
+ t.requestChange({
832
+ function: w
833
+ });
834
+ }
835
+ const y = /* @__PURE__ */ l(_, { className: "d-flex flex-nowrap", children: [
836
+ /* @__PURE__ */ n(
837
+ m,
838
+ {
839
+ variant: c,
840
+ onClick: f,
841
+ disabled: e.disabled || w === "",
842
+ children: g
843
+ }
844
+ ),
845
+ r.extended && /* @__PURE__ */ n(se, { ...e })
846
+ ] }), V = e.options.header || "top";
847
+ return /* @__PURE__ */ n(
848
+ A,
849
+ {
850
+ hardware: t,
851
+ widgetIcon: a,
852
+ widgetState: o,
853
+ widgetContent: y,
854
+ headerMode: V
855
+ }
856
+ );
857
+ }
858
+ function Oe(e) {
859
+ const [t, r] = O({}), a = M(null);
860
+ return k(() => {
861
+ if (a.current) {
862
+ const o = a.current;
863
+ r({
864
+ width: o.clientWidth,
865
+ height: o.clientHeight
866
+ });
867
+ }
868
+ }, []), /* @__PURE__ */ n(
869
+ "div",
870
+ {
871
+ ref: a,
872
+ style: { width: "100%", height: "100%" },
873
+ className: e.className,
874
+ children: t.width > 0 && /* @__PURE__ */ n(
875
+ "div",
876
+ {
877
+ className: "full-sizer",
878
+ style: {
879
+ width: `${t.width}px`,
880
+ height: `${t.height}px`,
881
+ overflow: "scroll"
882
+ },
883
+ children: e.children
884
+ }
885
+ )
435
886
  }
436
887
  );
437
888
  }
889
+ const Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
890
+ __proto__: null
891
+ }, Symbol.toStringTag, { value: "Module" })), Ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
892
+ __proto__: null
893
+ }, Symbol.toStringTag, { value: "Module" }));
438
894
  export {
439
- _ as MotorDefault
895
+ me as Formatting,
896
+ we as Frontend,
897
+ Oe as FullSizer,
898
+ G as HardwareInputNumber,
899
+ re as HardwareNumericStep,
900
+ Ce as HardwareSchema,
901
+ ve as HardwareState,
902
+ A as HardwareTemplate,
903
+ Ie as HardwareTypes,
904
+ ge as Info,
905
+ Ne as MotorDefault,
906
+ be as Multiposition,
907
+ pe as NoObject,
908
+ ne as NumericStep,
909
+ ye as Property,
910
+ Se as ShutterDefault,
911
+ I as TypeIcon
440
912
  };
441
913
  //# sourceMappingURL=index.esm.js.map