@esrf/daiquiri-lib 0.0.2-alpha.1 → 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.
@@ -0,0 +1,913 @@
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) {
8
+ const {
9
+ activeMessage: t = "Online",
10
+ inactiveMessage: r = "Offline",
11
+ message: a = "This device is"
12
+ } = e;
13
+ return /* @__PURE__ */ n(
14
+ "div",
15
+ {
16
+ className: `dot-indicator small bg-${e.online ? "success" : "danger"}`,
17
+ title: `${a} ${e.online ? t : r}`
18
+ }
19
+ );
20
+ }
21
+ function I(e) {
22
+ const { name: t, icon: r } = e;
23
+ return /* @__PURE__ */ l("div", { className: "icon", title: t, children: [
24
+ /* @__PURE__ */ n("i", { className: `fa ${r}` }),
25
+ /* @__PURE__ */ n(Y, { ...e })
26
+ ] });
27
+ }
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) {
198
+ const { headerMode: t, hardware: r } = e;
199
+ function a() {
200
+ return r.alias ? r.alias : r.name ? r.name : r.id;
201
+ }
202
+ const o = a();
203
+ switch (t) {
204
+ case "front":
205
+ return /* @__PURE__ */ n("div", { className: "hw-component", children: /* @__PURE__ */ l("div", { className: "hw-single", children: [
206
+ e.widgetIcon,
207
+ /* @__PURE__ */ n("div", { className: "name", children: o }),
208
+ /* @__PURE__ */ n("div", { className: "d-inline-block", children: e.widgetContent })
209
+ ] }) });
210
+ case "none":
211
+ return /* @__PURE__ */ n("div", { className: "hw-component", children: /* @__PURE__ */ n("div", { className: "hw-single", children: e.widgetContent }) });
212
+ case "state":
213
+ return e.widgetState;
214
+ default:
215
+ return /* @__PURE__ */ l("div", { className: "hw-component", children: [
216
+ /* @__PURE__ */ l("div", { className: "hw-head", children: [
217
+ e.widgetIcon,
218
+ /* @__PURE__ */ n("div", { className: "name", children: /* @__PURE__ */ n(N.Label, { htmlFor: r.id, children: o }) }),
219
+ e.widgetState,
220
+ e.hardware.errors && e.hardware.errors.length > 0 && /* @__PURE__ */ n(
221
+ F,
222
+ {
223
+ trigger: "click",
224
+ placement: "bottom",
225
+ rootClose: !0,
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: [
229
+ "There were errors with properties on this device:",
230
+ /* @__PURE__ */ n("ul", { children: e.hardware.errors.map((i) => /* @__PURE__ */ l("li", { children: [
231
+ i.property,
232
+ ":",
233
+ /* @__PURE__ */ l("span", { className: "stack-trace", children: [
234
+ i.traceback,
235
+ /* @__PURE__ */ n("br", {}),
236
+ i.exception
237
+ ] })
238
+ ] })) })
239
+ ] })
240
+ ] }),
241
+ children: /* @__PURE__ */ n(m, { variant: "danger", size: "sm", children: /* @__PURE__ */ n("i", { className: "fa fa-exclamation-triangle" }) })
242
+ }
243
+ )
244
+ ] }),
245
+ /* @__PURE__ */ n("div", { className: "hw-content", children: e.widgetContent })
246
+ ] });
247
+ }
248
+ }
249
+ function q(e) {
250
+ const t = {
251
+ display: "inline-block",
252
+ minWidth: ""
253
+ };
254
+ return e.minWidth && (t.minWidth = `${e.minWidth}em`), /* @__PURE__ */ n("div", { style: t, children: /* @__PURE__ */ n(C, { bg: e.variant, children: e.state }) });
255
+ }
256
+ function W(e) {
257
+ const { hardware: t } = e;
258
+ function r() {
259
+ if (!t.online)
260
+ return "OFFLINE";
261
+ let o = "UNKNOWN";
262
+ return e.hardware.properties.state && ([o] = e.hardware.properties.state), o;
263
+ }
264
+ const a = r();
265
+ return /* @__PURE__ */ n(
266
+ q,
267
+ {
268
+ state: a,
269
+ minWidth: 6,
270
+ variant: a === "READY" ? "success" : "warning"
271
+ }
272
+ );
273
+ }
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;
313
+ if (r.current === null)
314
+ return;
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
319
+ });
320
+ }, {
321
+ onStep: u,
322
+ step: d,
323
+ overlay: g,
324
+ incIcon: w,
325
+ decIcon: s,
326
+ swapIncDec: c,
327
+ onKeyDown: f,
328
+ horizontalArrows: y,
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);
333
+ };
334
+ if (!e.step)
335
+ return /* @__PURE__ */ n(
336
+ N.Control,
337
+ {
338
+ ref: t,
339
+ type: "number",
340
+ step: "any",
341
+ onKeyDown: T,
342
+ ...b
343
+ }
344
+ );
345
+ const j = E(e.steps || [e.step], (h) => /* @__PURE__ */ n("option", { value: h, children: h }, h));
346
+ return /* @__PURE__ */ n(
347
+ "div",
348
+ {
349
+ className: x("numeric-step", {
350
+ "numeric-step-large": V,
351
+ "numeric-step-horizontal": y
352
+ }),
353
+ children: /* @__PURE__ */ l(p, { children: [
354
+ /* @__PURE__ */ n(
355
+ N.Control,
356
+ {
357
+ onKeyDown: T,
358
+ ref: t,
359
+ type: "number",
360
+ step: "any",
361
+ ...b
362
+ }
363
+ ),
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,
369
+ {
370
+ ref: r,
371
+ as: "select",
372
+ className: "step-size",
373
+ defaultValue: a,
374
+ onChange: (h) => o(Number.parseFloat(h.target.value)),
375
+ children: j
376
+ }
377
+ ),
378
+ e.unit && /* @__PURE__ */ n("div", { children: e.unit }),
379
+ !w && !s && /* @__PURE__ */ l(S, { children: [
380
+ /* @__PURE__ */ n(
381
+ m,
382
+ {
383
+ className: "step step-up",
384
+ disabled: e.disabled,
385
+ onClick: (h) => i(!0)
386
+ }
387
+ ),
388
+ /* @__PURE__ */ n(
389
+ m,
390
+ {
391
+ className: "step step-down",
392
+ disabled: e.disabled,
393
+ onClick: (h) => i(!1)
394
+ }
395
+ )
396
+ ] })
397
+ ] }),
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}` }) })
401
+ ] })
402
+ ] })
403
+ }
404
+ );
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));
410
+ }, [e.hardwareValue]);
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);
414
+ }
415
+ function d() {
416
+ r && setTimeout(() => {
417
+ u(e.hardwareValue), a(!1);
418
+ }, 3e3);
419
+ }
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));
422
+ }
423
+ function w(c) {
424
+ a(!1), e.onMoveRequested(c.target.value);
425
+ }
426
+ function s(c) {
427
+ switch (c.key) {
428
+ case "Enter":
429
+ {
430
+ a(!1);
431
+ const f = Number.parseFloat(c.target.value), y = e.onMoveRequested(f);
432
+ y && y.catch(() => {
433
+ i(!0), setTimeout(() => {
434
+ u(e.hardwareValue), i(!1);
435
+ }, 2e3);
436
+ });
437
+ }
438
+ c.preventDefault(), c.stopPropagation();
439
+ break;
440
+ case "Esc":
441
+ case "Escape":
442
+ r && (i(!1), a(!1), u(e.hardwareValue)), c.target.blur(), c.preventDefault(), c.stopPropagation();
443
+ break;
444
+ }
445
+ }
446
+ return /* @__PURE__ */ n(
447
+ ne,
448
+ {
449
+ id: e.id,
450
+ className: x({
451
+ "form-control-edited": r,
452
+ "form-control-error": o,
453
+ "hw-moving": e.hardwareIsMoving
454
+ }),
455
+ type: e.readOnly ? "text" : "number",
456
+ ref: t,
457
+ precision: e.precision,
458
+ onChange: g,
459
+ onBlur: d,
460
+ onStep: w,
461
+ onKeyDown: s,
462
+ disabled: e.hardwareIsDisabled || e.readOnly || !e.hardwareIsReady,
463
+ step: e.step,
464
+ steps: e.steps,
465
+ incIcon: e.incIcon,
466
+ decIcon: e.decIcon,
467
+ swapIncDec: e.swapIncDec,
468
+ horizontalArrows: e.horizontalArrows,
469
+ largeArrows: e.largeArrows,
470
+ overlay: e.hardwareIsMoving && !e.hardwareIsDisabled ? /* @__PURE__ */ n(m, { variant: "danger", onClick: e.onAbortRequested, children: /* @__PURE__ */ n("i", { className: "fa fa-times" }) }) : null
471
+ }
472
+ );
473
+ }
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;
478
+ }
479
+ k(() => {
480
+ var s;
481
+ t.current && (t.current.value = u((s = e.hardwareValue) == null ? void 0 : s.toString()), a(!1));
482
+ }, [e.hardwareValue, e.precision]);
483
+ function d(s) {
484
+ const c = u(s);
485
+ t != null && t.current && (t.current.value = c);
486
+ }
487
+ function g(s) {
488
+ switch (s.key) {
489
+ case "Enter": {
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);
495
+ }, 2e3);
496
+ }), s.preventDefault(), s.stopPropagation();
497
+ break;
498
+ }
499
+ case "Esc":
500
+ case "Escape":
501
+ r && (i(!1), a(!1), d(e.hardwareValue)), s.target.blur(), s.preventDefault(), s.stopPropagation();
502
+ break;
503
+ }
504
+ }
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);
507
+ }
508
+ return /* @__PURE__ */ n(
509
+ N.Control,
510
+ {
511
+ className: x({
512
+ "form-control-edited": r,
513
+ "form-control-error": o,
514
+ "hw-moving": e.hardwareIsMoving
515
+ }),
516
+ type: "number",
517
+ ref: t,
518
+ onChange: w,
519
+ onKeyDown: g,
520
+ disabled: e.readOnly || e.hardwareIsMoving || e.hardwareIsDisabled,
521
+ step: e.step
522
+ }
523
+ );
524
+ }
525
+ function ae(e) {
526
+ function t(o) {
527
+ return e.hardware.requestChange({
528
+ property: "velocity",
529
+ value: o
530
+ });
531
+ }
532
+ function r(o) {
533
+ return e.hardware.requestChange({
534
+ property: "acceleration",
535
+ value: o
536
+ });
537
+ }
538
+ let a = "UNKNOWN";
539
+ return e.hardware.properties.state && ([a] = e.hardware.properties.state), /* @__PURE__ */ n(
540
+ F,
541
+ {
542
+ trigger: "click",
543
+ rootClose: !0,
544
+ overlay: /* @__PURE__ */ l(v, { id: "popid", children: [
545
+ /* @__PURE__ */ l(v.Header, { children: [
546
+ e.hardware.name,
547
+ " details"
548
+ ] }),
549
+ /* @__PURE__ */ l(v.Body, { children: [
550
+ /* @__PURE__ */ l(N.Group, { children: [
551
+ /* @__PURE__ */ n(N.Label, { children: "Velocity" }),
552
+ /* @__PURE__ */ n(
553
+ G,
554
+ {
555
+ hardwareValue: e.hardware.properties.velocity,
556
+ onMoveRequested: t,
557
+ hardwareIsDisabled: e.disabled,
558
+ hardwareIsReady: a === "READY",
559
+ hardwareIsMoving: a === "MOVING",
560
+ readOnly: e.readOnly
561
+ }
562
+ )
563
+ ] }),
564
+ /* @__PURE__ */ l(N.Group, { children: [
565
+ /* @__PURE__ */ n(N.Label, { children: "Acceleration" }),
566
+ /* @__PURE__ */ n(
567
+ G,
568
+ {
569
+ hardwareValue: e.hardware.properties.acceleration,
570
+ onMoveRequested: r,
571
+ hardwareIsDisabled: e.disabled,
572
+ hardwareIsReady: a === "READY",
573
+ hardwareIsMoving: a === "MOVING",
574
+ readOnly: e.readOnly
575
+ }
576
+ )
577
+ ] })
578
+ ] })
579
+ ] }),
580
+ children: /* @__PURE__ */ n(m, { children: /* @__PURE__ */ n("i", { className: "fa fa-ellipsis-h" }) })
581
+ }
582
+ );
583
+ }
584
+ function Ne(e) {
585
+ const { hardware: t, options: r = {} } = e;
586
+ function a() {
587
+ t.requestChange({
588
+ function: "stop"
589
+ });
590
+ }
591
+ function o(w) {
592
+ return t.requestChange({
593
+ property: "position",
594
+ value: w,
595
+ function: "move"
596
+ });
597
+ }
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,
603
+ {
604
+ hardware: t,
605
+ widgetIcon: u,
606
+ widgetState: d,
607
+ widgetContent: /* @__PURE__ */ l(p, { children: [
608
+ /* @__PURE__ */ n(
609
+ re,
610
+ {
611
+ id: t.id,
612
+ hardwareValue: t.properties.position,
613
+ hardwareIsDisabled: e.disabled,
614
+ hardwareIsReady: i === "READY",
615
+ hardwareIsMoving: i === "MOVING",
616
+ onMoveRequested: o,
617
+ onAbortRequested: a,
618
+ precision: r.precision,
619
+ readOnly: r.readOnly,
620
+ step: r.step,
621
+ steps: r.steps,
622
+ incIcon: r.incicon,
623
+ decIcon: r.decicon,
624
+ swapIncDec: r.swapincdec,
625
+ horizontalArrows: r.horizontalarrows,
626
+ largeArrows: r.largearrows
627
+ }
628
+ ),
629
+ t.properties.unit && /* @__PURE__ */ n(p.Text, { children: t.properties.unit }),
630
+ i !== "MOVING" && r.extended && /* @__PURE__ */ n(
631
+ ae,
632
+ {
633
+ hardware: t,
634
+ disabled: e.disabled,
635
+ readOnly: r.readOnly
636
+ }
637
+ ),
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
+ ] })
801
+ ] }),
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
+ )
886
+ }
887
+ );
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" }));
894
+ export {
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
912
+ };
913
+ //# sourceMappingURL=index.esm.js.map