@nice2dev/ui-iot 1.0.10

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.mjs ADDED
@@ -0,0 +1,1727 @@
1
+ import { jsxs as i, jsx as e, Fragment as P } from "react/jsx-runtime";
2
+ import { useState as p, useCallback as v } from "react";
3
+ const $ = [
4
+ { type: "device-list", label: "Device List", icon: "πŸ“‹" },
5
+ { type: "device-status", label: "Device Status", icon: "🟒" },
6
+ { type: "telemetry-chart", label: "Telemetry Chart", icon: "πŸ“ˆ" },
7
+ { type: "gauge", label: "Gauge", icon: "⏱️" },
8
+ { type: "map", label: "Device Map", icon: "πŸ—ΊοΈ" },
9
+ { type: "alarms", label: "Alarms", icon: "🚨" },
10
+ { type: "control-panel", label: "Control Panel", icon: "πŸŽ›οΈ" },
11
+ { type: "topology", label: "Network Topology", icon: "πŸ”—" },
12
+ { type: "kpi", label: "KPI Card", icon: "🎯" },
13
+ { type: "camera-feed", label: "Camera Feed", icon: "πŸ“Ή" }
14
+ ];
15
+ function re({
16
+ devices: a = [],
17
+ widgets: c = [],
18
+ alarms: n = [],
19
+ onDeviceSelect: r,
20
+ onWidgetChange: l,
21
+ onCommand: t,
22
+ onAlarmAcknowledge: d,
23
+ fetchTelemetry: o,
24
+ className: T = ""
25
+ }) {
26
+ const [u, D] = p(c), [g, f] = p(null), [m, w] = p("dashboard"), [_, k] = p(!1), [b, M] = p(""), h = v(
27
+ (s) => {
28
+ D((N) => {
29
+ const y = s(N);
30
+ return l == null || l(y), y;
31
+ });
32
+ },
33
+ [l]
34
+ ), C = v(
35
+ (s) => {
36
+ var y;
37
+ const N = {
38
+ id: crypto.randomUUID(),
39
+ type: s,
40
+ title: ((y = $.find((L) => L.type === s)) == null ? void 0 : y.label) || s,
41
+ position: { x: 0, y: Q(u), width: 4, height: 3 },
42
+ config: {}
43
+ };
44
+ h((L) => [...L, N]);
45
+ },
46
+ [u, h]
47
+ ), A = v(
48
+ (s) => {
49
+ f(s), r == null || r(s);
50
+ },
51
+ [r]
52
+ ), S = v(
53
+ (s) => {
54
+ d == null || d(s);
55
+ },
56
+ [d]
57
+ ), G = a.filter(
58
+ (s) => !b || s.name.toLowerCase().includes(b.toLowerCase()) || s.type.toLowerCase().includes(b.toLowerCase())
59
+ ), I = n.filter((s) => !s.cleared), E = I.filter(
60
+ (s) => s.severity === "critical" || s.severity === "high"
61
+ );
62
+ return /* @__PURE__ */ i("div", { className: `nice-iot-dashboard ${T}`, children: [
63
+ /* @__PURE__ */ i("header", { className: "nice-iot-dashboard__header", children: [
64
+ /* @__PURE__ */ e("h1", { children: "IoT Dashboard" }),
65
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__stats", children: [
66
+ /* @__PURE__ */ i("span", { className: "nice-iot-dashboard__stat", children: [
67
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__stat-icon", children: "πŸ“±" }),
68
+ a.length,
69
+ " Devices"
70
+ ] }),
71
+ /* @__PURE__ */ i("span", { className: "nice-iot-dashboard__stat nice-iot-dashboard__stat--online", children: [
72
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__stat-icon", children: "🟒" }),
73
+ a.filter((s) => s.status === "online").length,
74
+ " Online"
75
+ ] }),
76
+ /* @__PURE__ */ i("span", { className: "nice-iot-dashboard__stat nice-iot-dashboard__stat--offline", children: [
77
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__stat-icon", children: "⚫" }),
78
+ a.filter((s) => s.status === "offline").length,
79
+ " Offline"
80
+ ] }),
81
+ E.length > 0 && /* @__PURE__ */ i("span", { className: "nice-iot-dashboard__stat nice-iot-dashboard__stat--alarms", children: [
82
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__stat-icon", children: "🚨" }),
83
+ E.length,
84
+ " Alarms"
85
+ ] })
86
+ ] }),
87
+ /* @__PURE__ */ i("nav", { className: "nice-iot-dashboard__nav", children: [
88
+ /* @__PURE__ */ e(
89
+ "button",
90
+ {
91
+ className: m === "dashboard" ? "active" : "",
92
+ onClick: () => w("dashboard"),
93
+ children: "Dashboard"
94
+ }
95
+ ),
96
+ /* @__PURE__ */ e("button", { className: m === "devices" ? "active" : "", onClick: () => w("devices"), children: "Devices" }),
97
+ /* @__PURE__ */ i("button", { className: m === "alarms" ? "active" : "", onClick: () => w("alarms"), children: [
98
+ "Alarms ",
99
+ I.length > 0 && `(${I.length})`
100
+ ] })
101
+ ] }),
102
+ /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__actions", children: m === "dashboard" && /* @__PURE__ */ e("button", { onClick: () => k(!_), children: _ ? "βœ“ Done" : "✏️ Edit" }) })
103
+ ] }),
104
+ m === "dashboard" && /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__main", children: [
105
+ _ && /* @__PURE__ */ i("aside", { className: "nice-iot-dashboard__palette", children: [
106
+ /* @__PURE__ */ e("h4", { children: "Add Widget" }),
107
+ $.map((s) => /* @__PURE__ */ i(
108
+ "button",
109
+ {
110
+ className: "nice-iot-dashboard__palette-item",
111
+ onClick: () => C(s.type),
112
+ children: [
113
+ /* @__PURE__ */ e("span", { children: s.icon }),
114
+ /* @__PURE__ */ e("span", { children: s.label })
115
+ ]
116
+ },
117
+ s.type
118
+ ))
119
+ ] }),
120
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__grid", children: [
121
+ u.map((s) => /* @__PURE__ */ e(
122
+ W,
123
+ {
124
+ widget: s,
125
+ devices: a,
126
+ alarms: n,
127
+ isEditing: _,
128
+ onCommand: t,
129
+ onDelete: () => h((N) => N.filter((y) => y.id !== s.id))
130
+ },
131
+ s.id
132
+ )),
133
+ u.length === 0 && /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__empty", children: _ ? "Add widgets from the palette" : "No widgets configured. Click Edit to add widgets." })
134
+ ] })
135
+ ] }),
136
+ m === "devices" && /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__devices", children: [
137
+ /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__devices-toolbar", children: /* @__PURE__ */ e(
138
+ "input",
139
+ {
140
+ type: "search",
141
+ placeholder: "Search devices...",
142
+ value: b,
143
+ onChange: (s) => M(s.target.value)
144
+ }
145
+ ) }),
146
+ /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__device-grid", children: G.map((s) => /* @__PURE__ */ e(
147
+ j,
148
+ {
149
+ device: s,
150
+ isSelected: (g == null ? void 0 : g.id) === s.id,
151
+ onSelect: () => A(s)
152
+ },
153
+ s.id
154
+ )) }),
155
+ g && /* @__PURE__ */ e(
156
+ H,
157
+ {
158
+ device: g,
159
+ onCommand: t,
160
+ onClose: () => f(null)
161
+ }
162
+ )
163
+ ] }),
164
+ m === "alarms" && /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__alarms", children: /* @__PURE__ */ i("table", { className: "nice-iot-dashboard__alarm-table", children: [
165
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { children: [
166
+ /* @__PURE__ */ e("th", { children: "Severity" }),
167
+ /* @__PURE__ */ e("th", { children: "Device" }),
168
+ /* @__PURE__ */ e("th", { children: "Message" }),
169
+ /* @__PURE__ */ e("th", { children: "Time" }),
170
+ /* @__PURE__ */ e("th", { children: "Status" }),
171
+ /* @__PURE__ */ e("th", { children: "Actions" })
172
+ ] }) }),
173
+ /* @__PURE__ */ e("tbody", { children: I.length === 0 ? /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: 6, className: "nice-iot-dashboard__no-alarms", children: "No active alarms" }) }) : I.map((s) => {
174
+ const N = a.find((y) => y.id === s.deviceId);
175
+ return /* @__PURE__ */ i(
176
+ "tr",
177
+ {
178
+ className: `nice-iot-dashboard__alarm-row nice-iot-dashboard__alarm-row--${s.severity}`,
179
+ children: [
180
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
181
+ "span",
182
+ {
183
+ className: `nice-iot-dashboard__severity nice-iot-dashboard__severity--${s.severity}`,
184
+ children: s.severity
185
+ }
186
+ ) }),
187
+ /* @__PURE__ */ e("td", { children: (N == null ? void 0 : N.name) || s.deviceId }),
188
+ /* @__PURE__ */ e("td", { children: s.message }),
189
+ /* @__PURE__ */ e("td", { children: s.timestamp.toLocaleString() }),
190
+ /* @__PURE__ */ e("td", { children: s.acknowledged ? "Acknowledged" : "Active" }),
191
+ /* @__PURE__ */ e("td", { children: !s.acknowledged && /* @__PURE__ */ e("button", { onClick: () => S(s.id), children: "Acknowledge" }) })
192
+ ]
193
+ },
194
+ s.id
195
+ );
196
+ }) })
197
+ ] }) })
198
+ ] });
199
+ }
200
+ function Q(a) {
201
+ return a.length === 0 ? 0 : Math.max(...a.map((c) => c.position.y + c.position.height));
202
+ }
203
+ function U(a) {
204
+ switch (a) {
205
+ case "online":
206
+ return "#28a745";
207
+ case "offline":
208
+ return "#6c757d";
209
+ case "warning":
210
+ return "#ffc107";
211
+ case "error":
212
+ return "#dc3545";
213
+ case "maintenance":
214
+ return "#17a2b8";
215
+ default:
216
+ return "#6c757d";
217
+ }
218
+ }
219
+ function W({
220
+ widget: a,
221
+ devices: c,
222
+ alarms: n,
223
+ isEditing: r,
224
+ onCommand: l,
225
+ onDelete: t
226
+ }) {
227
+ const d = $.find((o) => o.type === a.type);
228
+ return /* @__PURE__ */ i(
229
+ "div",
230
+ {
231
+ className: `nice-iot-dashboard__widget nice-iot-dashboard__widget--${a.type}`,
232
+ style: {
233
+ gridColumn: `span ${a.position.width}`,
234
+ gridRow: `span ${a.position.height}`
235
+ },
236
+ children: [
237
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__widget-header", children: [
238
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__widget-icon", children: d == null ? void 0 : d.icon }),
239
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__widget-title", children: a.title }),
240
+ r && /* @__PURE__ */ e("button", { className: "nice-iot-dashboard__widget-delete", onClick: t, children: "Γ—" })
241
+ ] }),
242
+ /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__widget-content", children: /* @__PURE__ */ e(V, { widget: a, devices: c, alarms: n, onCommand: l }) })
243
+ ]
244
+ }
245
+ );
246
+ }
247
+ function V({
248
+ widget: a,
249
+ devices: c,
250
+ alarms: n,
251
+ onCommand: r
252
+ }) {
253
+ switch (a.type) {
254
+ case "device-list":
255
+ return /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__device-list", children: c.slice(0, 10).map((t) => /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__device-list-item", children: [
256
+ /* @__PURE__ */ e(
257
+ "span",
258
+ {
259
+ className: "nice-iot-dashboard__device-status",
260
+ style: { background: U(t.status) }
261
+ }
262
+ ),
263
+ /* @__PURE__ */ e("span", { children: t.name }),
264
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__device-type", children: t.type })
265
+ ] }, t.id)) });
266
+ case "device-status":
267
+ return /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__status-grid", children: ["online", "offline", "warning", "error"].map((t) => {
268
+ const d = c.filter((o) => o.status === t).length;
269
+ return /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__status-card", children: [
270
+ /* @__PURE__ */ e(
271
+ "span",
272
+ {
273
+ className: "nice-iot-dashboard__status-indicator",
274
+ style: { background: U(t) }
275
+ }
276
+ ),
277
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__status-count", children: d }),
278
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__status-label", children: t })
279
+ ] }, t);
280
+ }) });
281
+ case "telemetry-chart":
282
+ return /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__chart-placeholder", children: [
283
+ /* @__PURE__ */ e("span", { children: "πŸ“ˆ" }),
284
+ /* @__PURE__ */ e("span", { children: "Telemetry Chart" }),
285
+ /* @__PURE__ */ e("small", { children: "Configure device and capability" })
286
+ ] });
287
+ case "gauge":
288
+ return /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__gauge", children: /* @__PURE__ */ i("svg", { viewBox: "0 0 100 60", children: [
289
+ /* @__PURE__ */ e("path", { d: "M 10 55 A 40 40 0 0 1 90 55", fill: "none", stroke: "#e0e0e0", strokeWidth: "8" }),
290
+ /* @__PURE__ */ e(
291
+ "path",
292
+ {
293
+ d: "M 10 55 A 40 40 0 0 1 90 55",
294
+ fill: "none",
295
+ stroke: "#0066cc",
296
+ strokeWidth: "8",
297
+ strokeDasharray: "63 126"
298
+ }
299
+ ),
300
+ /* @__PURE__ */ e("text", { x: "50", y: "50", textAnchor: "middle", fontSize: "14", fontWeight: "bold", children: "50%" })
301
+ ] }) });
302
+ case "map":
303
+ return /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__map-placeholder", children: [
304
+ /* @__PURE__ */ e("span", { children: "πŸ—ΊοΈ" }),
305
+ /* @__PURE__ */ e("span", { children: "Device Map" }),
306
+ /* @__PURE__ */ i("small", { children: [
307
+ c.filter((t) => t.location).length,
308
+ " devices with location"
309
+ ] })
310
+ ] });
311
+ case "alarms":
312
+ const l = n.filter((t) => !t.cleared).slice(0, 5);
313
+ return /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__alarm-list", children: l.length === 0 ? /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__alarm-empty", children: "No active alarms" }) : l.map((t) => /* @__PURE__ */ i(
314
+ "div",
315
+ {
316
+ className: `nice-iot-dashboard__alarm-item nice-iot-dashboard__alarm-item--${t.severity}`,
317
+ children: [
318
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__alarm-severity", children: t.severity }),
319
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__alarm-message", children: t.message })
320
+ ]
321
+ },
322
+ t.id
323
+ )) });
324
+ case "control-panel":
325
+ return /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__control-placeholder", children: [
326
+ /* @__PURE__ */ e("span", { children: "πŸŽ›οΈ" }),
327
+ /* @__PURE__ */ e("span", { children: "Control Panel" }),
328
+ /* @__PURE__ */ e("small", { children: "Configure device controls" })
329
+ ] });
330
+ case "kpi":
331
+ return /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__kpi", children: [
332
+ /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__kpi-value", children: c.length }),
333
+ /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__kpi-label", children: "Total Devices" })
334
+ ] });
335
+ default:
336
+ return /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__widget-placeholder", children: a.type });
337
+ }
338
+ }
339
+ function j({ device: a, isSelected: c, onSelect: n }) {
340
+ return /* @__PURE__ */ i(
341
+ "div",
342
+ {
343
+ className: `nice-iot-dashboard__device-card ${c ? "nice-iot-dashboard__device-card--selected" : ""}`,
344
+ onClick: n,
345
+ children: [
346
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__device-card-header", children: [
347
+ /* @__PURE__ */ e(
348
+ "span",
349
+ {
350
+ className: "nice-iot-dashboard__device-status",
351
+ style: { background: U(a.status) }
352
+ }
353
+ ),
354
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__device-name", children: a.name })
355
+ ] }),
356
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__device-card-body", children: [
357
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__device-info", children: [
358
+ /* @__PURE__ */ i("span", { children: [
359
+ "Type: ",
360
+ a.type
361
+ ] }),
362
+ /* @__PURE__ */ i("span", { children: [
363
+ "Protocol: ",
364
+ a.protocol
365
+ ] })
366
+ ] }),
367
+ a.lastSeen && /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__device-lastseen", children: [
368
+ "Last seen: ",
369
+ a.lastSeen.toLocaleString()
370
+ ] }),
371
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__device-capabilities", children: [
372
+ a.capabilities.slice(0, 3).map((r) => /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__capability-badge", children: r.name }, r.id)),
373
+ a.capabilities.length > 3 && /* @__PURE__ */ i("span", { className: "nice-iot-dashboard__capability-more", children: [
374
+ "+",
375
+ a.capabilities.length - 3
376
+ ] })
377
+ ] })
378
+ ] })
379
+ ]
380
+ }
381
+ );
382
+ }
383
+ function H({
384
+ device: a,
385
+ onCommand: c,
386
+ onClose: n
387
+ }) {
388
+ return /* @__PURE__ */ i("aside", { className: "nice-iot-dashboard__device-detail", children: [
389
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__device-detail-header", children: [
390
+ /* @__PURE__ */ e("h3", { children: a.name }),
391
+ /* @__PURE__ */ e("button", { onClick: n, children: "Γ—" })
392
+ ] }),
393
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__device-detail-content", children: [
394
+ /* @__PURE__ */ i("section", { children: [
395
+ /* @__PURE__ */ e("h4", { children: "Status" }),
396
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__detail-row", children: [
397
+ /* @__PURE__ */ e("span", { children: "Status:" }),
398
+ /* @__PURE__ */ e(
399
+ "span",
400
+ {
401
+ className: "nice-iot-dashboard__status-badge",
402
+ style: { background: U(a.status) },
403
+ children: a.status
404
+ }
405
+ )
406
+ ] }),
407
+ a.lastSeen && /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__detail-row", children: [
408
+ /* @__PURE__ */ e("span", { children: "Last Seen:" }),
409
+ /* @__PURE__ */ e("span", { children: a.lastSeen.toLocaleString() })
410
+ ] })
411
+ ] }),
412
+ /* @__PURE__ */ i("section", { children: [
413
+ /* @__PURE__ */ e("h4", { children: "Connection" }),
414
+ /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__detail-row", children: [
415
+ /* @__PURE__ */ e("span", { children: "Protocol:" }),
416
+ /* @__PURE__ */ e("span", { children: a.protocol })
417
+ ] }),
418
+ a.connectionInfo.host && /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__detail-row", children: [
419
+ /* @__PURE__ */ e("span", { children: "Host:" }),
420
+ /* @__PURE__ */ i("span", { children: [
421
+ a.connectionInfo.host,
422
+ ":",
423
+ a.connectionInfo.port
424
+ ] })
425
+ ] })
426
+ ] }),
427
+ a.metadata && /* @__PURE__ */ i("section", { children: [
428
+ /* @__PURE__ */ e("h4", { children: "Metadata" }),
429
+ a.metadata.manufacturer && /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__detail-row", children: [
430
+ /* @__PURE__ */ e("span", { children: "Manufacturer:" }),
431
+ /* @__PURE__ */ e("span", { children: a.metadata.manufacturer })
432
+ ] }),
433
+ a.metadata.model && /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__detail-row", children: [
434
+ /* @__PURE__ */ e("span", { children: "Model:" }),
435
+ /* @__PURE__ */ e("span", { children: a.metadata.model })
436
+ ] })
437
+ ] }),
438
+ /* @__PURE__ */ i("section", { children: [
439
+ /* @__PURE__ */ e("h4", { children: "Capabilities" }),
440
+ /* @__PURE__ */ e("div", { className: "nice-iot-dashboard__capabilities-list", children: a.capabilities.map((r) => /* @__PURE__ */ i("div", { className: "nice-iot-dashboard__capability-item", children: [
441
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__capability-name", children: r.name }),
442
+ /* @__PURE__ */ e("span", { className: "nice-iot-dashboard__capability-type", children: r.type }),
443
+ r.writable && c && /* @__PURE__ */ e(
444
+ "button",
445
+ {
446
+ className: "nice-iot-dashboard__capability-control",
447
+ onClick: () => c(a.id, r.id, !0),
448
+ children: "Control"
449
+ }
450
+ )
451
+ ] }, r.id)) })
452
+ ] })
453
+ ] })
454
+ ] });
455
+ }
456
+ const K = [
457
+ { name: "MQTT Broker", image: "eclipse-mosquitto:latest" },
458
+ { name: "Node-RED", image: "nodered/node-red:latest" },
459
+ { name: "InfluxDB", image: "influxdb:latest" },
460
+ { name: "Grafana", image: "grafana/grafana:latest" },
461
+ { name: "Telegraf", image: "telegraf:latest" },
462
+ { name: "Protocol Adapter", image: "nice2dev/protocol-adapter:latest" }
463
+ ];
464
+ function le({
465
+ nodes: a = [],
466
+ modules: c = [],
467
+ onNodeSelect: n,
468
+ onModuleDeploy: r,
469
+ onModuleAction: l,
470
+ onNodeSync: t,
471
+ className: d = ""
472
+ }) {
473
+ const [o, T] = p(null), [u, D] = p("nodes"), [g, f] = p(!1), [m, w] = p({
474
+ name: "",
475
+ image: "",
476
+ status: "pending"
477
+ }), _ = v(
478
+ (h) => {
479
+ T(h), n == null || n(h);
480
+ },
481
+ [n]
482
+ ), k = v(async () => {
483
+ !o || !m.name || !m.image || (await (r == null ? void 0 : r(o.id, m)), f(!1), w({ name: "", image: "", status: "pending" }));
484
+ }, [o, m, r]), b = v(
485
+ async (h, C) => {
486
+ o && await (l == null ? void 0 : l(o.id, h, C));
487
+ },
488
+ [o, l]
489
+ ), M = v(async () => {
490
+ o && await (t == null ? void 0 : t(o.id));
491
+ }, [o, t]);
492
+ return /* @__PURE__ */ i("div", { className: `nice-edge-manager ${d}`, children: [
493
+ /* @__PURE__ */ i("header", { className: "nice-edge-manager__header", children: [
494
+ /* @__PURE__ */ e("h1", { children: "Edge Manager" }),
495
+ /* @__PURE__ */ i("nav", { className: "nice-edge-manager__nav", children: [
496
+ /* @__PURE__ */ i("button", { className: u === "nodes" ? "active" : "", onClick: () => D("nodes"), children: [
497
+ "Nodes (",
498
+ a.length,
499
+ ")"
500
+ ] }),
501
+ /* @__PURE__ */ e("button", { className: u === "modules" ? "active" : "", onClick: () => D("modules"), children: "Modules" })
502
+ ] })
503
+ ] }),
504
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__main", children: [
505
+ u === "nodes" && /* @__PURE__ */ e("div", { className: "nice-edge-manager__nodes", children: /* @__PURE__ */ i("div", { className: "nice-edge-manager__node-grid", children: [
506
+ a.map((h) => /* @__PURE__ */ e(
507
+ z,
508
+ {
509
+ node: h,
510
+ isSelected: (o == null ? void 0 : o.id) === h.id,
511
+ onSelect: () => _(h)
512
+ },
513
+ h.id
514
+ )),
515
+ a.length === 0 && /* @__PURE__ */ e("div", { className: "nice-edge-manager__empty", children: "No edge nodes configured" })
516
+ ] }) }),
517
+ u === "modules" && o && /* @__PURE__ */ i("div", { className: "nice-edge-manager__modules", children: [
518
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__modules-header", children: [
519
+ /* @__PURE__ */ i("h3", { children: [
520
+ "Modules on ",
521
+ o.name
522
+ ] }),
523
+ /* @__PURE__ */ e(
524
+ "button",
525
+ {
526
+ className: "nice-edge-manager__deploy-btn",
527
+ onClick: () => f(!0),
528
+ children: "+ Deploy Module"
529
+ }
530
+ )
531
+ ] }),
532
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__module-grid", children: [
533
+ o.deployedModules.map((h) => /* @__PURE__ */ e(
534
+ J,
535
+ {
536
+ module: h,
537
+ onAction: (C) => b(h.id, C)
538
+ },
539
+ h.id
540
+ )),
541
+ o.deployedModules.length === 0 && /* @__PURE__ */ e("div", { className: "nice-edge-manager__empty", children: "No modules deployed on this node" })
542
+ ] })
543
+ ] }),
544
+ u === "modules" && !o && /* @__PURE__ */ e("div", { className: "nice-edge-manager__no-selection", children: "Select a node from the Nodes tab to manage modules" }),
545
+ o && /* @__PURE__ */ e(
546
+ X,
547
+ {
548
+ node: o,
549
+ onSync: M,
550
+ onClose: () => T(null)
551
+ }
552
+ )
553
+ ] }),
554
+ g && /* @__PURE__ */ e(
555
+ Z,
556
+ {
557
+ config: m,
558
+ templates: K,
559
+ onChange: w,
560
+ onDeploy: k,
561
+ onClose: () => f(!1)
562
+ }
563
+ )
564
+ ] });
565
+ }
566
+ function q(a) {
567
+ switch (a) {
568
+ case "running":
569
+ return "#28a745";
570
+ case "stopped":
571
+ return "#6c757d";
572
+ case "updating":
573
+ return "#ffc107";
574
+ case "error":
575
+ return "#dc3545";
576
+ case "unreachable":
577
+ return "#868e96";
578
+ default:
579
+ return "#6c757d";
580
+ }
581
+ }
582
+ function B(a) {
583
+ return a < 1024 ? `${a} B` : a < 1024 * 1024 ? `${(a / 1024).toFixed(1)} KB` : a < 1024 * 1024 * 1024 ? `${(a / 1024 / 1024).toFixed(1)} MB` : `${(a / 1024 / 1024 / 1024).toFixed(2)} GB`;
584
+ }
585
+ function Y(a) {
586
+ const c = Math.floor(a / 86400), n = Math.floor(a % 86400 / 3600), r = Math.floor(a % 3600 / 60);
587
+ return c > 0 ? `${c}d ${n}h` : n > 0 ? `${n}h ${r}m` : `${r}m`;
588
+ }
589
+ function z({ node: a, isSelected: c, onSelect: n }) {
590
+ return /* @__PURE__ */ i(
591
+ "div",
592
+ {
593
+ className: `nice-edge-manager__node-card ${c ? "nice-edge-manager__node-card--selected" : ""}`,
594
+ onClick: n,
595
+ children: [
596
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__node-header", children: [
597
+ /* @__PURE__ */ e(
598
+ "span",
599
+ {
600
+ className: "nice-edge-manager__node-status",
601
+ style: { background: q(a.status) }
602
+ }
603
+ ),
604
+ /* @__PURE__ */ e("span", { className: "nice-edge-manager__node-name", children: a.name }),
605
+ /* @__PURE__ */ e("span", { className: "nice-edge-manager__node-type", children: a.type })
606
+ ] }),
607
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__node-body", children: [
608
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__node-info", children: [
609
+ /* @__PURE__ */ i("span", { children: [
610
+ "πŸ–₯️ ",
611
+ a.hardware.cpu
612
+ ] }),
613
+ /* @__PURE__ */ i("span", { children: [
614
+ "πŸ’Ύ ",
615
+ (a.hardware.memoryMB / 1024).toFixed(1),
616
+ " GB"
617
+ ] })
618
+ ] }),
619
+ /* @__PURE__ */ e("div", { className: "nice-edge-manager__node-metrics", children: a.metrics && /* @__PURE__ */ i(P, { children: [
620
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__metric", children: [
621
+ /* @__PURE__ */ e("span", { className: "nice-edge-manager__metric-label", children: "CPU" }),
622
+ /* @__PURE__ */ e("div", { className: "nice-edge-manager__metric-bar", children: /* @__PURE__ */ e(
623
+ "div",
624
+ {
625
+ className: "nice-edge-manager__metric-fill",
626
+ style: { width: `${a.metrics.cpuUsage}%` }
627
+ }
628
+ ) }),
629
+ /* @__PURE__ */ i("span", { className: "nice-edge-manager__metric-value", children: [
630
+ a.metrics.cpuUsage.toFixed(0),
631
+ "%"
632
+ ] })
633
+ ] }),
634
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__metric", children: [
635
+ /* @__PURE__ */ e("span", { className: "nice-edge-manager__metric-label", children: "MEM" }),
636
+ /* @__PURE__ */ e("div", { className: "nice-edge-manager__metric-bar", children: /* @__PURE__ */ e(
637
+ "div",
638
+ {
639
+ className: "nice-edge-manager__metric-fill",
640
+ style: { width: `${a.metrics.memoryUsage}%` }
641
+ }
642
+ ) }),
643
+ /* @__PURE__ */ i("span", { className: "nice-edge-manager__metric-value", children: [
644
+ a.metrics.memoryUsage.toFixed(0),
645
+ "%"
646
+ ] })
647
+ ] })
648
+ ] }) }),
649
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__node-modules", children: [
650
+ a.deployedModules.length,
651
+ " modules deployed"
652
+ ] })
653
+ ] })
654
+ ]
655
+ }
656
+ );
657
+ }
658
+ function J({ module: a, onAction: c }) {
659
+ return /* @__PURE__ */ i("div", { className: "nice-edge-manager__module-card", children: [
660
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__module-header", children: [
661
+ /* @__PURE__ */ e(
662
+ "span",
663
+ {
664
+ className: "nice-edge-manager__module-status",
665
+ style: { background: {
666
+ running: "#28a745",
667
+ stopped: "#6c757d",
668
+ error: "#dc3545",
669
+ pending: "#ffc107"
670
+ }[a.status] || "#6c757d" }
671
+ }
672
+ ),
673
+ /* @__PURE__ */ e("span", { className: "nice-edge-manager__module-name", children: a.name }),
674
+ /* @__PURE__ */ i("span", { className: "nice-edge-manager__module-version", children: [
675
+ "v",
676
+ a.version
677
+ ] })
678
+ ] }),
679
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__module-body", children: [
680
+ /* @__PURE__ */ e("div", { className: "nice-edge-manager__module-image", children: a.image }),
681
+ a.resources && /* @__PURE__ */ i("div", { className: "nice-edge-manager__module-resources", children: [
682
+ a.resources.cpuLimit && /* @__PURE__ */ i("span", { children: [
683
+ "CPU: ",
684
+ a.resources.cpuLimit
685
+ ] }),
686
+ a.resources.memoryLimitMB && /* @__PURE__ */ i("span", { children: [
687
+ "RAM: ",
688
+ a.resources.memoryLimitMB,
689
+ " MB"
690
+ ] })
691
+ ] }),
692
+ a.ports && a.ports.length > 0 && /* @__PURE__ */ i("div", { className: "nice-edge-manager__module-ports", children: [
693
+ "Ports: ",
694
+ a.ports.map((r) => `${r.host}:${r.container}`).join(", ")
695
+ ] })
696
+ ] }),
697
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__module-actions", children: [
698
+ a.status === "running" && /* @__PURE__ */ i(P, { children: [
699
+ /* @__PURE__ */ e("button", { onClick: () => c("stop"), children: "Stop" }),
700
+ /* @__PURE__ */ e("button", { onClick: () => c("restart"), children: "Restart" })
701
+ ] }),
702
+ a.status === "stopped" && /* @__PURE__ */ e("button", { onClick: () => c("start"), children: "Start" }),
703
+ /* @__PURE__ */ e("button", { className: "nice-edge-manager__module-remove", onClick: () => c("remove"), children: "Remove" })
704
+ ] })
705
+ ] });
706
+ }
707
+ function X({ node: a, onSync: c, onClose: n }) {
708
+ return /* @__PURE__ */ i("aside", { className: "nice-edge-manager__detail", children: [
709
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-header", children: [
710
+ /* @__PURE__ */ e("h3", { children: a.name }),
711
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-actions", children: [
712
+ /* @__PURE__ */ e("button", { onClick: c, children: "πŸ”„ Sync" }),
713
+ /* @__PURE__ */ e("button", { onClick: n, children: "Γ—" })
714
+ ] })
715
+ ] }),
716
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-content", children: [
717
+ /* @__PURE__ */ i("section", { children: [
718
+ /* @__PURE__ */ e("h4", { children: "Status" }),
719
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
720
+ /* @__PURE__ */ e("span", { children: "Status:" }),
721
+ /* @__PURE__ */ e(
722
+ "span",
723
+ {
724
+ className: "nice-edge-manager__status-badge",
725
+ style: { background: q(a.status) },
726
+ children: a.status
727
+ }
728
+ )
729
+ ] }),
730
+ a.metrics && /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
731
+ /* @__PURE__ */ e("span", { children: "Uptime:" }),
732
+ /* @__PURE__ */ e("span", { children: Y(a.metrics.uptime) })
733
+ ] })
734
+ ] }),
735
+ /* @__PURE__ */ i("section", { children: [
736
+ /* @__PURE__ */ e("h4", { children: "Hardware" }),
737
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
738
+ /* @__PURE__ */ e("span", { children: "CPU:" }),
739
+ /* @__PURE__ */ i("span", { children: [
740
+ a.hardware.cpu,
741
+ " (",
742
+ a.hardware.cores,
743
+ " cores)"
744
+ ] })
745
+ ] }),
746
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
747
+ /* @__PURE__ */ e("span", { children: "Memory:" }),
748
+ /* @__PURE__ */ i("span", { children: [
749
+ (a.hardware.memoryMB / 1024).toFixed(1),
750
+ " GB"
751
+ ] })
752
+ ] }),
753
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
754
+ /* @__PURE__ */ e("span", { children: "Storage:" }),
755
+ /* @__PURE__ */ i("span", { children: [
756
+ (a.hardware.storageMB / 1024).toFixed(1),
757
+ " GB"
758
+ ] })
759
+ ] }),
760
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
761
+ /* @__PURE__ */ e("span", { children: "Architecture:" }),
762
+ /* @__PURE__ */ e("span", { children: a.hardware.architecture })
763
+ ] })
764
+ ] }),
765
+ /* @__PURE__ */ i("section", { children: [
766
+ /* @__PURE__ */ e("h4", { children: "Software" }),
767
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
768
+ /* @__PURE__ */ e("span", { children: "OS:" }),
769
+ /* @__PURE__ */ i("span", { children: [
770
+ a.software.os,
771
+ " ",
772
+ a.software.osVersion
773
+ ] })
774
+ ] }),
775
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
776
+ /* @__PURE__ */ e("span", { children: "Runtime:" }),
777
+ /* @__PURE__ */ i("span", { children: [
778
+ a.software.runtime,
779
+ " ",
780
+ a.software.runtimeVersion
781
+ ] })
782
+ ] }),
783
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
784
+ /* @__PURE__ */ e("span", { children: "Agent:" }),
785
+ /* @__PURE__ */ i("span", { children: [
786
+ a.software.agent,
787
+ " v",
788
+ a.software.agentVersion
789
+ ] })
790
+ ] })
791
+ ] }),
792
+ /* @__PURE__ */ i("section", { children: [
793
+ /* @__PURE__ */ e("h4", { children: "Connectivity" }),
794
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
795
+ /* @__PURE__ */ e("span", { children: "Cloud:" }),
796
+ /* @__PURE__ */ e("span", { children: a.connectivity.cloudConnected ? "βœ“ Connected" : "βœ— Disconnected" })
797
+ ] }),
798
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
799
+ /* @__PURE__ */ e("span", { children: "Network:" }),
800
+ /* @__PURE__ */ e("span", { children: a.connectivity.localNetwork })
801
+ ] }),
802
+ a.connectivity.publicIP && /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
803
+ /* @__PURE__ */ e("span", { children: "Public IP:" }),
804
+ /* @__PURE__ */ e("span", { children: a.connectivity.publicIP })
805
+ ] }),
806
+ a.connectivity.lastSync && /* @__PURE__ */ i("div", { className: "nice-edge-manager__detail-row", children: [
807
+ /* @__PURE__ */ e("span", { children: "Last Sync:" }),
808
+ /* @__PURE__ */ e("span", { children: a.connectivity.lastSync.toLocaleString() })
809
+ ] })
810
+ ] }),
811
+ a.metrics && /* @__PURE__ */ i("section", { children: [
812
+ /* @__PURE__ */ e("h4", { children: "Resource Usage" }),
813
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__resource-chart", children: [
814
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__resource-item", children: [
815
+ /* @__PURE__ */ e("span", { children: "CPU" }),
816
+ /* @__PURE__ */ e("div", { className: "nice-edge-manager__resource-bar", children: /* @__PURE__ */ e(
817
+ "div",
818
+ {
819
+ className: "nice-edge-manager__resource-fill",
820
+ style: { width: `${a.metrics.cpuUsage}%` }
821
+ }
822
+ ) }),
823
+ /* @__PURE__ */ i("span", { children: [
824
+ a.metrics.cpuUsage.toFixed(1),
825
+ "%"
826
+ ] })
827
+ ] }),
828
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__resource-item", children: [
829
+ /* @__PURE__ */ e("span", { children: "Memory" }),
830
+ /* @__PURE__ */ e("div", { className: "nice-edge-manager__resource-bar", children: /* @__PURE__ */ e(
831
+ "div",
832
+ {
833
+ className: "nice-edge-manager__resource-fill",
834
+ style: { width: `${a.metrics.memoryUsage}%` }
835
+ }
836
+ ) }),
837
+ /* @__PURE__ */ i("span", { children: [
838
+ a.metrics.memoryUsage.toFixed(1),
839
+ "%"
840
+ ] })
841
+ ] }),
842
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__resource-item", children: [
843
+ /* @__PURE__ */ e("span", { children: "Disk" }),
844
+ /* @__PURE__ */ e("div", { className: "nice-edge-manager__resource-bar", children: /* @__PURE__ */ e(
845
+ "div",
846
+ {
847
+ className: "nice-edge-manager__resource-fill",
848
+ style: { width: `${a.metrics.diskUsage}%` }
849
+ }
850
+ ) }),
851
+ /* @__PURE__ */ i("span", { children: [
852
+ a.metrics.diskUsage.toFixed(1),
853
+ "%"
854
+ ] })
855
+ ] })
856
+ ] }),
857
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__network-stats", children: [
858
+ /* @__PURE__ */ i("span", { children: [
859
+ "↓ ",
860
+ B(a.metrics.networkIn)
861
+ ] }),
862
+ /* @__PURE__ */ i("span", { children: [
863
+ "↑ ",
864
+ B(a.metrics.networkOut)
865
+ ] })
866
+ ] })
867
+ ] })
868
+ ] })
869
+ ] });
870
+ }
871
+ function Z({
872
+ config: a,
873
+ templates: c,
874
+ onChange: n,
875
+ onDeploy: r,
876
+ onClose: l
877
+ }) {
878
+ return /* @__PURE__ */ e("div", { className: "nice-edge-manager__dialog-overlay", children: /* @__PURE__ */ i("div", { className: "nice-edge-manager__dialog", children: [
879
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__dialog-header", children: [
880
+ /* @__PURE__ */ e("h3", { children: "Deploy Module" }),
881
+ /* @__PURE__ */ e("button", { onClick: l, children: "Γ—" })
882
+ ] }),
883
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__dialog-content", children: [
884
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__field", children: [
885
+ /* @__PURE__ */ e("label", { children: "Template (optional)" }),
886
+ /* @__PURE__ */ i(
887
+ "select",
888
+ {
889
+ value: "",
890
+ onChange: (t) => {
891
+ const d = c.find((o) => o.image === t.target.value);
892
+ d && n({
893
+ ...a,
894
+ name: d.name,
895
+ image: d.image
896
+ });
897
+ },
898
+ children: [
899
+ /* @__PURE__ */ e("option", { value: "", children: "Select a template..." }),
900
+ c.map((t) => /* @__PURE__ */ e("option", { value: t.image, children: t.name }, t.image))
901
+ ]
902
+ }
903
+ )
904
+ ] }),
905
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__field", children: [
906
+ /* @__PURE__ */ e("label", { children: "Module Name" }),
907
+ /* @__PURE__ */ e(
908
+ "input",
909
+ {
910
+ type: "text",
911
+ value: a.name || "",
912
+ onChange: (t) => n({ ...a, name: t.target.value }),
913
+ placeholder: "e.g., my-module"
914
+ }
915
+ )
916
+ ] }),
917
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__field", children: [
918
+ /* @__PURE__ */ e("label", { children: "Container Image" }),
919
+ /* @__PURE__ */ e(
920
+ "input",
921
+ {
922
+ type: "text",
923
+ value: a.image || "",
924
+ onChange: (t) => n({ ...a, image: t.target.value }),
925
+ placeholder: "e.g., nginx:latest"
926
+ }
927
+ )
928
+ ] }),
929
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__field", children: [
930
+ /* @__PURE__ */ e("label", { children: "Version" }),
931
+ /* @__PURE__ */ e(
932
+ "input",
933
+ {
934
+ type: "text",
935
+ value: a.version || "1.0.0",
936
+ onChange: (t) => n({ ...a, version: t.target.value })
937
+ }
938
+ )
939
+ ] })
940
+ ] }),
941
+ /* @__PURE__ */ i("div", { className: "nice-edge-manager__dialog-footer", children: [
942
+ /* @__PURE__ */ e("button", { onClick: l, children: "Cancel" }),
943
+ /* @__PURE__ */ e("button", { className: "nice-edge-manager__deploy-confirm", onClick: r, children: "Deploy" })
944
+ ] })
945
+ ] }) });
946
+ }
947
+ const x = {
948
+ broker: "localhost",
949
+ port: 1883,
950
+ clientId: `nice2dev-${Date.now()}`,
951
+ useTLS: !1,
952
+ keepAlive: 60,
953
+ cleanSession: !0,
954
+ topics: []
955
+ }, F = {
956
+ host: "localhost",
957
+ port: 5683,
958
+ useDTLS: !1,
959
+ resources: []
960
+ }, R = {
961
+ type: "tcp",
962
+ host: "localhost",
963
+ port: 502,
964
+ slaveId: 1,
965
+ timeout: 1e3,
966
+ registers: []
967
+ }, O = {
968
+ endpointUrl: "opc.tcp://localhost:4840",
969
+ securityMode: "None",
970
+ authentication: "anonymous",
971
+ applicationName: "Nice2Dev IoT Client",
972
+ nodes: []
973
+ };
974
+ function se({
975
+ protocol: a = "mqtt",
976
+ config: c,
977
+ onSave: n,
978
+ onTest: r,
979
+ className: l = ""
980
+ }) {
981
+ const [t, d] = p(a), [o, T] = p(
982
+ (c == null ? void 0 : c.type) === "mqtt" ? { ...x, ...c.config } : x
983
+ ), [u, D] = p(
984
+ (c == null ? void 0 : c.type) === "coap" ? { ...F, ...c.config } : F
985
+ ), [g, f] = p(
986
+ (c == null ? void 0 : c.type) === "modbus" ? { ...R, ...c.config } : R
987
+ ), [m, w] = p(
988
+ (c == null ? void 0 : c.type) === "opcua" ? { ...O, ...c.config } : O
989
+ ), [_, k] = p(null), [b, M] = p(!1), h = v(() => {
990
+ switch (t) {
991
+ case "mqtt":
992
+ return o;
993
+ case "coap":
994
+ return u;
995
+ case "modbus-tcp":
996
+ case "modbus-rtu":
997
+ return g;
998
+ case "opcua":
999
+ return m;
1000
+ default:
1001
+ return o;
1002
+ }
1003
+ }, [t, o, u, g, m]), C = v(() => {
1004
+ n == null || n(h());
1005
+ }, [h, n]), A = v(async () => {
1006
+ if (r) {
1007
+ M(!0), k(null);
1008
+ try {
1009
+ const S = await r(h());
1010
+ k(S);
1011
+ } catch (S) {
1012
+ k({ success: !1, message: String(S) });
1013
+ } finally {
1014
+ M(!1);
1015
+ }
1016
+ }
1017
+ }, [h, r]);
1018
+ return /* @__PURE__ */ i("div", { className: `nice-protocol-config ${l}`, children: [
1019
+ /* @__PURE__ */ i("header", { className: "nice-protocol-config__header", children: [
1020
+ /* @__PURE__ */ e("h2", { children: "Protocol Configuration" }),
1021
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__protocol-selector", children: [
1022
+ /* @__PURE__ */ e("label", { children: "Protocol:" }),
1023
+ /* @__PURE__ */ i("select", { value: t, onChange: (S) => d(S.target.value), children: [
1024
+ /* @__PURE__ */ e("option", { value: "mqtt", children: "MQTT" }),
1025
+ /* @__PURE__ */ e("option", { value: "coap", children: "CoAP" }),
1026
+ /* @__PURE__ */ e("option", { value: "modbus-tcp", children: "Modbus TCP" }),
1027
+ /* @__PURE__ */ e("option", { value: "modbus-rtu", children: "Modbus RTU" }),
1028
+ /* @__PURE__ */ e("option", { value: "opcua", children: "OPC-UA" })
1029
+ ] })
1030
+ ] })
1031
+ ] }),
1032
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__content", children: [
1033
+ t === "mqtt" && /* @__PURE__ */ e(ee, { config: o, onChange: T }),
1034
+ t === "coap" && /* @__PURE__ */ e(ae, { config: u, onChange: D }),
1035
+ (t === "modbus-tcp" || t === "modbus-rtu") && /* @__PURE__ */ e(
1036
+ ie,
1037
+ {
1038
+ config: g,
1039
+ type: t === "modbus-rtu" ? "rtu" : "tcp",
1040
+ onChange: f
1041
+ }
1042
+ ),
1043
+ t === "opcua" && /* @__PURE__ */ e(ne, { config: m, onChange: w })
1044
+ ] }),
1045
+ _ && /* @__PURE__ */ i(
1046
+ "div",
1047
+ {
1048
+ className: `nice-protocol-config__test-result nice-protocol-config__test-result--${_.success ? "success" : "error"}`,
1049
+ children: [
1050
+ _.success ? "βœ“" : "βœ—",
1051
+ " ",
1052
+ _.message
1053
+ ]
1054
+ }
1055
+ ),
1056
+ /* @__PURE__ */ i("footer", { className: "nice-protocol-config__footer", children: [
1057
+ /* @__PURE__ */ e(
1058
+ "button",
1059
+ {
1060
+ className: "nice-protocol-config__test-btn",
1061
+ onClick: A,
1062
+ disabled: b || !r,
1063
+ children: b ? "Testing..." : "πŸ”Œ Test Connection"
1064
+ }
1065
+ ),
1066
+ /* @__PURE__ */ e("button", { className: "nice-protocol-config__save-btn", onClick: C, children: "πŸ’Ύ Save" })
1067
+ ] })
1068
+ ] });
1069
+ }
1070
+ function ee({ config: a, onChange: c }) {
1071
+ return /* @__PURE__ */ i("div", { className: "nice-protocol-config__section", children: [
1072
+ /* @__PURE__ */ e("h3", { children: "MQTT Configuration" }),
1073
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__grid", children: [
1074
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1075
+ /* @__PURE__ */ e("label", { children: "Broker" }),
1076
+ /* @__PURE__ */ e(
1077
+ "input",
1078
+ {
1079
+ type: "text",
1080
+ value: a.broker,
1081
+ onChange: (n) => c({ ...a, broker: n.target.value }),
1082
+ placeholder: "localhost"
1083
+ }
1084
+ )
1085
+ ] }),
1086
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1087
+ /* @__PURE__ */ e("label", { children: "Port" }),
1088
+ /* @__PURE__ */ e(
1089
+ "input",
1090
+ {
1091
+ type: "number",
1092
+ value: a.port,
1093
+ onChange: (n) => c({ ...a, port: parseInt(n.target.value, 10) || 1883 })
1094
+ }
1095
+ )
1096
+ ] }),
1097
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1098
+ /* @__PURE__ */ e("label", { children: "Client ID" }),
1099
+ /* @__PURE__ */ e(
1100
+ "input",
1101
+ {
1102
+ type: "text",
1103
+ value: a.clientId,
1104
+ onChange: (n) => c({ ...a, clientId: n.target.value })
1105
+ }
1106
+ )
1107
+ ] }),
1108
+ /* @__PURE__ */ e("div", { className: "nice-protocol-config__field", children: /* @__PURE__ */ i("label", { children: [
1109
+ /* @__PURE__ */ e(
1110
+ "input",
1111
+ {
1112
+ type: "checkbox",
1113
+ checked: a.useTLS,
1114
+ onChange: (n) => c({ ...a, useTLS: n.target.checked })
1115
+ }
1116
+ ),
1117
+ "Use TLS"
1118
+ ] }) }),
1119
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1120
+ /* @__PURE__ */ e("label", { children: "Username" }),
1121
+ /* @__PURE__ */ e(
1122
+ "input",
1123
+ {
1124
+ type: "text",
1125
+ value: a.username || "",
1126
+ onChange: (n) => c({ ...a, username: n.target.value })
1127
+ }
1128
+ )
1129
+ ] }),
1130
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1131
+ /* @__PURE__ */ e("label", { children: "Password" }),
1132
+ /* @__PURE__ */ e(
1133
+ "input",
1134
+ {
1135
+ type: "password",
1136
+ value: a.password || "",
1137
+ onChange: (n) => c({ ...a, password: n.target.value })
1138
+ }
1139
+ )
1140
+ ] }),
1141
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1142
+ /* @__PURE__ */ e("label", { children: "Keep Alive (seconds)" }),
1143
+ /* @__PURE__ */ e(
1144
+ "input",
1145
+ {
1146
+ type: "number",
1147
+ value: a.keepAlive,
1148
+ onChange: (n) => c({ ...a, keepAlive: parseInt(n.target.value, 10) || 60 })
1149
+ }
1150
+ )
1151
+ ] }),
1152
+ /* @__PURE__ */ e("div", { className: "nice-protocol-config__field", children: /* @__PURE__ */ i("label", { children: [
1153
+ /* @__PURE__ */ e(
1154
+ "input",
1155
+ {
1156
+ type: "checkbox",
1157
+ checked: a.cleanSession,
1158
+ onChange: (n) => c({ ...a, cleanSession: n.target.checked })
1159
+ }
1160
+ ),
1161
+ "Clean Session"
1162
+ ] }) })
1163
+ ] }),
1164
+ /* @__PURE__ */ e("h4", { children: "Topics" }),
1165
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__topics", children: [
1166
+ a.topics.map((n, r) => /* @__PURE__ */ i("div", { className: "nice-protocol-config__topic-row", children: [
1167
+ /* @__PURE__ */ e(
1168
+ "input",
1169
+ {
1170
+ type: "text",
1171
+ value: n.pattern,
1172
+ onChange: (l) => {
1173
+ const t = [...a.topics];
1174
+ t[r] = { ...t[r], pattern: l.target.value }, c({ ...a, topics: t });
1175
+ },
1176
+ placeholder: "e.g., sensors/+/data"
1177
+ }
1178
+ ),
1179
+ /* @__PURE__ */ i(
1180
+ "select",
1181
+ {
1182
+ value: n.qos,
1183
+ onChange: (l) => {
1184
+ const t = [...a.topics];
1185
+ t[r] = { ...t[r], qos: parseInt(l.target.value, 10) }, c({ ...a, topics: t });
1186
+ },
1187
+ children: [
1188
+ /* @__PURE__ */ e("option", { value: 0, children: "QoS 0" }),
1189
+ /* @__PURE__ */ e("option", { value: 1, children: "QoS 1" }),
1190
+ /* @__PURE__ */ e("option", { value: 2, children: "QoS 2" })
1191
+ ]
1192
+ }
1193
+ ),
1194
+ /* @__PURE__ */ i(
1195
+ "select",
1196
+ {
1197
+ value: n.direction,
1198
+ onChange: (l) => {
1199
+ const t = [...a.topics];
1200
+ t[r] = {
1201
+ ...t[r],
1202
+ direction: l.target.value
1203
+ }, c({ ...a, topics: t });
1204
+ },
1205
+ children: [
1206
+ /* @__PURE__ */ e("option", { value: "subscribe", children: "Subscribe" }),
1207
+ /* @__PURE__ */ e("option", { value: "publish", children: "Publish" }),
1208
+ /* @__PURE__ */ e("option", { value: "both", children: "Both" })
1209
+ ]
1210
+ }
1211
+ ),
1212
+ /* @__PURE__ */ e(
1213
+ "button",
1214
+ {
1215
+ onClick: () => {
1216
+ const l = a.topics.filter((t, d) => d !== r);
1217
+ c({ ...a, topics: l });
1218
+ },
1219
+ children: "Γ—"
1220
+ }
1221
+ )
1222
+ ] }, r)),
1223
+ /* @__PURE__ */ e(
1224
+ "button",
1225
+ {
1226
+ onClick: () => {
1227
+ c({
1228
+ ...a,
1229
+ topics: [
1230
+ ...a.topics,
1231
+ { pattern: "", qos: 0, direction: "subscribe", payloadFormat: "json" }
1232
+ ]
1233
+ });
1234
+ },
1235
+ children: "+ Add Topic"
1236
+ }
1237
+ )
1238
+ ] })
1239
+ ] });
1240
+ }
1241
+ function ae({ config: a, onChange: c }) {
1242
+ return /* @__PURE__ */ i("div", { className: "nice-protocol-config__section", children: [
1243
+ /* @__PURE__ */ e("h3", { children: "CoAP Configuration" }),
1244
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__grid", children: [
1245
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1246
+ /* @__PURE__ */ e("label", { children: "Host" }),
1247
+ /* @__PURE__ */ e(
1248
+ "input",
1249
+ {
1250
+ type: "text",
1251
+ value: a.host,
1252
+ onChange: (n) => c({ ...a, host: n.target.value })
1253
+ }
1254
+ )
1255
+ ] }),
1256
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1257
+ /* @__PURE__ */ e("label", { children: "Port" }),
1258
+ /* @__PURE__ */ e(
1259
+ "input",
1260
+ {
1261
+ type: "number",
1262
+ value: a.port,
1263
+ onChange: (n) => c({ ...a, port: parseInt(n.target.value, 10) || 5683 })
1264
+ }
1265
+ )
1266
+ ] }),
1267
+ /* @__PURE__ */ e("div", { className: "nice-protocol-config__field", children: /* @__PURE__ */ i("label", { children: [
1268
+ /* @__PURE__ */ e(
1269
+ "input",
1270
+ {
1271
+ type: "checkbox",
1272
+ checked: a.useDTLS,
1273
+ onChange: (n) => c({ ...a, useDTLS: n.target.checked })
1274
+ }
1275
+ ),
1276
+ "Use DTLS"
1277
+ ] }) }),
1278
+ /* @__PURE__ */ e("div", { className: "nice-protocol-config__field", children: /* @__PURE__ */ i("label", { children: [
1279
+ /* @__PURE__ */ e(
1280
+ "input",
1281
+ {
1282
+ type: "checkbox",
1283
+ checked: a.observe || !1,
1284
+ onChange: (n) => c({ ...a, observe: n.target.checked })
1285
+ }
1286
+ ),
1287
+ "Enable Observe"
1288
+ ] }) })
1289
+ ] }),
1290
+ /* @__PURE__ */ e("h4", { children: "Resources" }),
1291
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__resources", children: [
1292
+ a.resources.map((n, r) => /* @__PURE__ */ i("div", { className: "nice-protocol-config__resource-row", children: [
1293
+ /* @__PURE__ */ e(
1294
+ "input",
1295
+ {
1296
+ type: "text",
1297
+ value: n.path,
1298
+ onChange: (l) => {
1299
+ const t = [...a.resources];
1300
+ t[r] = { ...t[r], path: l.target.value }, c({ ...a, resources: t });
1301
+ },
1302
+ placeholder: "/sensors/temperature"
1303
+ }
1304
+ ),
1305
+ /* @__PURE__ */ e(
1306
+ "button",
1307
+ {
1308
+ onClick: () => {
1309
+ const l = a.resources.filter((t, d) => d !== r);
1310
+ c({ ...a, resources: l });
1311
+ },
1312
+ children: "Γ—"
1313
+ }
1314
+ )
1315
+ ] }, r)),
1316
+ /* @__PURE__ */ e(
1317
+ "button",
1318
+ {
1319
+ onClick: () => {
1320
+ c({
1321
+ ...a,
1322
+ resources: [
1323
+ ...a.resources,
1324
+ { path: "", methods: ["GET"], mediaType: "application/json", observable: !1 }
1325
+ ]
1326
+ });
1327
+ },
1328
+ children: "+ Add Resource"
1329
+ }
1330
+ )
1331
+ ] })
1332
+ ] });
1333
+ }
1334
+ function ie({
1335
+ config: a,
1336
+ type: c,
1337
+ onChange: n
1338
+ }) {
1339
+ return /* @__PURE__ */ i("div", { className: "nice-protocol-config__section", children: [
1340
+ /* @__PURE__ */ i("h3", { children: [
1341
+ "Modbus ",
1342
+ c.toUpperCase(),
1343
+ " Configuration"
1344
+ ] }),
1345
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__grid", children: [
1346
+ c === "tcp" && /* @__PURE__ */ i(P, { children: [
1347
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1348
+ /* @__PURE__ */ e("label", { children: "Host" }),
1349
+ /* @__PURE__ */ e(
1350
+ "input",
1351
+ {
1352
+ type: "text",
1353
+ value: a.host || "",
1354
+ onChange: (r) => n({ ...a, host: r.target.value })
1355
+ }
1356
+ )
1357
+ ] }),
1358
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1359
+ /* @__PURE__ */ e("label", { children: "Port" }),
1360
+ /* @__PURE__ */ e(
1361
+ "input",
1362
+ {
1363
+ type: "number",
1364
+ value: a.port || 502,
1365
+ onChange: (r) => n({ ...a, port: parseInt(r.target.value, 10) || 502 })
1366
+ }
1367
+ )
1368
+ ] })
1369
+ ] }),
1370
+ c === "rtu" && /* @__PURE__ */ i(P, { children: [
1371
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1372
+ /* @__PURE__ */ e("label", { children: "Serial Port" }),
1373
+ /* @__PURE__ */ e(
1374
+ "input",
1375
+ {
1376
+ type: "text",
1377
+ value: a.serialPort || "",
1378
+ onChange: (r) => n({ ...a, serialPort: r.target.value }),
1379
+ placeholder: "COM1 or /dev/ttyUSB0"
1380
+ }
1381
+ )
1382
+ ] }),
1383
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1384
+ /* @__PURE__ */ e("label", { children: "Baud Rate" }),
1385
+ /* @__PURE__ */ i(
1386
+ "select",
1387
+ {
1388
+ value: a.baudRate || 9600,
1389
+ onChange: (r) => n({ ...a, baudRate: parseInt(r.target.value, 10) }),
1390
+ children: [
1391
+ /* @__PURE__ */ e("option", { value: 9600, children: "9600" }),
1392
+ /* @__PURE__ */ e("option", { value: 19200, children: "19200" }),
1393
+ /* @__PURE__ */ e("option", { value: 38400, children: "38400" }),
1394
+ /* @__PURE__ */ e("option", { value: 57600, children: "57600" }),
1395
+ /* @__PURE__ */ e("option", { value: 115200, children: "115200" })
1396
+ ]
1397
+ }
1398
+ )
1399
+ ] }),
1400
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1401
+ /* @__PURE__ */ e("label", { children: "Parity" }),
1402
+ /* @__PURE__ */ i(
1403
+ "select",
1404
+ {
1405
+ value: a.parity || "none",
1406
+ onChange: (r) => n({ ...a, parity: r.target.value }),
1407
+ children: [
1408
+ /* @__PURE__ */ e("option", { value: "none", children: "None" }),
1409
+ /* @__PURE__ */ e("option", { value: "even", children: "Even" }),
1410
+ /* @__PURE__ */ e("option", { value: "odd", children: "Odd" })
1411
+ ]
1412
+ }
1413
+ )
1414
+ ] })
1415
+ ] }),
1416
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1417
+ /* @__PURE__ */ e("label", { children: "Slave ID" }),
1418
+ /* @__PURE__ */ e(
1419
+ "input",
1420
+ {
1421
+ type: "number",
1422
+ value: a.slaveId,
1423
+ onChange: (r) => n({ ...a, slaveId: parseInt(r.target.value, 10) || 1 }),
1424
+ min: 1,
1425
+ max: 247
1426
+ }
1427
+ )
1428
+ ] }),
1429
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1430
+ /* @__PURE__ */ e("label", { children: "Timeout (ms)" }),
1431
+ /* @__PURE__ */ e(
1432
+ "input",
1433
+ {
1434
+ type: "number",
1435
+ value: a.timeout,
1436
+ onChange: (r) => n({ ...a, timeout: parseInt(r.target.value, 10) || 1e3 })
1437
+ }
1438
+ )
1439
+ ] })
1440
+ ] }),
1441
+ /* @__PURE__ */ e("h4", { children: "Registers" }),
1442
+ /* @__PURE__ */ i("table", { className: "nice-protocol-config__registers-table", children: [
1443
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { children: [
1444
+ /* @__PURE__ */ e("th", { children: "Name" }),
1445
+ /* @__PURE__ */ e("th", { children: "Address" }),
1446
+ /* @__PURE__ */ e("th", { children: "Type" }),
1447
+ /* @__PURE__ */ e("th", { children: "Data Type" }),
1448
+ /* @__PURE__ */ e("th", { children: "R/W" }),
1449
+ /* @__PURE__ */ e("th", {})
1450
+ ] }) }),
1451
+ /* @__PURE__ */ e("tbody", { children: a.registers.map((r, l) => /* @__PURE__ */ i("tr", { children: [
1452
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
1453
+ "input",
1454
+ {
1455
+ type: "text",
1456
+ value: r.name,
1457
+ onChange: (t) => {
1458
+ const d = [...a.registers];
1459
+ d[l] = { ...d[l], name: t.target.value }, n({ ...a, registers: d });
1460
+ }
1461
+ }
1462
+ ) }),
1463
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
1464
+ "input",
1465
+ {
1466
+ type: "number",
1467
+ value: r.address,
1468
+ onChange: (t) => {
1469
+ const d = [...a.registers];
1470
+ d[l] = {
1471
+ ...d[l],
1472
+ address: parseInt(t.target.value, 10) || 0
1473
+ }, n({ ...a, registers: d });
1474
+ }
1475
+ }
1476
+ ) }),
1477
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ i(
1478
+ "select",
1479
+ {
1480
+ value: r.type,
1481
+ onChange: (t) => {
1482
+ const d = [...a.registers];
1483
+ d[l] = {
1484
+ ...d[l],
1485
+ type: t.target.value
1486
+ }, n({ ...a, registers: d });
1487
+ },
1488
+ children: [
1489
+ /* @__PURE__ */ e("option", { value: "coil", children: "Coil" }),
1490
+ /* @__PURE__ */ e("option", { value: "discrete", children: "Discrete" }),
1491
+ /* @__PURE__ */ e("option", { value: "holding", children: "Holding" }),
1492
+ /* @__PURE__ */ e("option", { value: "input", children: "Input" })
1493
+ ]
1494
+ }
1495
+ ) }),
1496
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ i(
1497
+ "select",
1498
+ {
1499
+ value: r.dataType,
1500
+ onChange: (t) => {
1501
+ const d = [...a.registers];
1502
+ d[l] = {
1503
+ ...d[l],
1504
+ dataType: t.target.value
1505
+ }, n({ ...a, registers: d });
1506
+ },
1507
+ children: [
1508
+ /* @__PURE__ */ e("option", { value: "bool", children: "Bool" }),
1509
+ /* @__PURE__ */ e("option", { value: "int16", children: "Int16" }),
1510
+ /* @__PURE__ */ e("option", { value: "uint16", children: "UInt16" }),
1511
+ /* @__PURE__ */ e("option", { value: "int32", children: "Int32" }),
1512
+ /* @__PURE__ */ e("option", { value: "uint32", children: "UInt32" }),
1513
+ /* @__PURE__ */ e("option", { value: "float32", children: "Float32" })
1514
+ ]
1515
+ }
1516
+ ) }),
1517
+ /* @__PURE__ */ i("td", { children: [
1518
+ /* @__PURE__ */ e(
1519
+ "input",
1520
+ {
1521
+ type: "checkbox",
1522
+ checked: r.readable,
1523
+ onChange: (t) => {
1524
+ const d = [...a.registers];
1525
+ d[l] = { ...d[l], readable: t.target.checked }, n({ ...a, registers: d });
1526
+ },
1527
+ title: "Readable"
1528
+ }
1529
+ ),
1530
+ /* @__PURE__ */ e(
1531
+ "input",
1532
+ {
1533
+ type: "checkbox",
1534
+ checked: r.writable,
1535
+ onChange: (t) => {
1536
+ const d = [...a.registers];
1537
+ d[l] = { ...d[l], writable: t.target.checked }, n({ ...a, registers: d });
1538
+ },
1539
+ title: "Writable"
1540
+ }
1541
+ )
1542
+ ] }),
1543
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(
1544
+ "button",
1545
+ {
1546
+ onClick: () => {
1547
+ const t = a.registers.filter((d, o) => o !== l);
1548
+ n({ ...a, registers: t });
1549
+ },
1550
+ children: "Γ—"
1551
+ }
1552
+ ) })
1553
+ ] }, l)) })
1554
+ ] }),
1555
+ /* @__PURE__ */ e(
1556
+ "button",
1557
+ {
1558
+ onClick: () => {
1559
+ n({
1560
+ ...a,
1561
+ registers: [
1562
+ ...a.registers,
1563
+ {
1564
+ name: "",
1565
+ address: 0,
1566
+ type: "holding",
1567
+ dataType: "uint16",
1568
+ readable: !0,
1569
+ writable: !1
1570
+ }
1571
+ ]
1572
+ });
1573
+ },
1574
+ children: "+ Add Register"
1575
+ }
1576
+ )
1577
+ ] });
1578
+ }
1579
+ function ne({ config: a, onChange: c }) {
1580
+ return /* @__PURE__ */ i("div", { className: "nice-protocol-config__section", children: [
1581
+ /* @__PURE__ */ e("h3", { children: "OPC-UA Configuration" }),
1582
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__grid", children: [
1583
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field nice-protocol-config__field--full", children: [
1584
+ /* @__PURE__ */ e("label", { children: "Endpoint URL" }),
1585
+ /* @__PURE__ */ e(
1586
+ "input",
1587
+ {
1588
+ type: "text",
1589
+ value: a.endpointUrl,
1590
+ onChange: (n) => c({ ...a, endpointUrl: n.target.value }),
1591
+ placeholder: "opc.tcp://localhost:4840"
1592
+ }
1593
+ )
1594
+ ] }),
1595
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1596
+ /* @__PURE__ */ e("label", { children: "Security Mode" }),
1597
+ /* @__PURE__ */ i(
1598
+ "select",
1599
+ {
1600
+ value: a.securityMode,
1601
+ onChange: (n) => c({
1602
+ ...a,
1603
+ securityMode: n.target.value
1604
+ }),
1605
+ children: [
1606
+ /* @__PURE__ */ e("option", { value: "None", children: "None" }),
1607
+ /* @__PURE__ */ e("option", { value: "Sign", children: "Sign" }),
1608
+ /* @__PURE__ */ e("option", { value: "SignAndEncrypt", children: "Sign and Encrypt" })
1609
+ ]
1610
+ }
1611
+ )
1612
+ ] }),
1613
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1614
+ /* @__PURE__ */ e("label", { children: "Authentication" }),
1615
+ /* @__PURE__ */ i(
1616
+ "select",
1617
+ {
1618
+ value: a.authentication,
1619
+ onChange: (n) => c({
1620
+ ...a,
1621
+ authentication: n.target.value
1622
+ }),
1623
+ children: [
1624
+ /* @__PURE__ */ e("option", { value: "anonymous", children: "Anonymous" }),
1625
+ /* @__PURE__ */ e("option", { value: "username", children: "Username/Password" }),
1626
+ /* @__PURE__ */ e("option", { value: "certificate", children: "Certificate" })
1627
+ ]
1628
+ }
1629
+ )
1630
+ ] }),
1631
+ a.authentication === "username" && /* @__PURE__ */ i(P, { children: [
1632
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1633
+ /* @__PURE__ */ e("label", { children: "Username" }),
1634
+ /* @__PURE__ */ e(
1635
+ "input",
1636
+ {
1637
+ type: "text",
1638
+ value: a.username || "",
1639
+ onChange: (n) => c({ ...a, username: n.target.value })
1640
+ }
1641
+ )
1642
+ ] }),
1643
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field", children: [
1644
+ /* @__PURE__ */ e("label", { children: "Password" }),
1645
+ /* @__PURE__ */ e(
1646
+ "input",
1647
+ {
1648
+ type: "password",
1649
+ value: a.password || "",
1650
+ onChange: (n) => c({ ...a, password: n.target.value })
1651
+ }
1652
+ )
1653
+ ] })
1654
+ ] }),
1655
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__field nice-protocol-config__field--full", children: [
1656
+ /* @__PURE__ */ e("label", { children: "Application Name" }),
1657
+ /* @__PURE__ */ e(
1658
+ "input",
1659
+ {
1660
+ type: "text",
1661
+ value: a.applicationName,
1662
+ onChange: (n) => c({ ...a, applicationName: n.target.value })
1663
+ }
1664
+ )
1665
+ ] })
1666
+ ] }),
1667
+ /* @__PURE__ */ e("h4", { children: "Nodes" }),
1668
+ /* @__PURE__ */ i("div", { className: "nice-protocol-config__nodes", children: [
1669
+ a.nodes.map((n, r) => /* @__PURE__ */ i("div", { className: "nice-protocol-config__node-row", children: [
1670
+ /* @__PURE__ */ e(
1671
+ "input",
1672
+ {
1673
+ type: "text",
1674
+ value: n.nodeId,
1675
+ onChange: (l) => {
1676
+ const t = [...a.nodes];
1677
+ t[r] = { ...t[r], nodeId: l.target.value }, c({ ...a, nodes: t });
1678
+ },
1679
+ placeholder: "ns=2;s=Temperature"
1680
+ }
1681
+ ),
1682
+ /* @__PURE__ */ e(
1683
+ "input",
1684
+ {
1685
+ type: "text",
1686
+ value: n.displayName,
1687
+ onChange: (l) => {
1688
+ const t = [...a.nodes];
1689
+ t[r] = { ...t[r], displayName: l.target.value }, c({ ...a, nodes: t });
1690
+ },
1691
+ placeholder: "Display Name"
1692
+ }
1693
+ ),
1694
+ /* @__PURE__ */ e(
1695
+ "button",
1696
+ {
1697
+ onClick: () => {
1698
+ const l = a.nodes.filter((t, d) => d !== r);
1699
+ c({ ...a, nodes: l });
1700
+ },
1701
+ children: "Γ—"
1702
+ }
1703
+ )
1704
+ ] }, r)),
1705
+ /* @__PURE__ */ e(
1706
+ "button",
1707
+ {
1708
+ onClick: () => {
1709
+ c({
1710
+ ...a,
1711
+ nodes: [
1712
+ ...a.nodes,
1713
+ { nodeId: "", displayName: "", dataType: "Double", read: !0 }
1714
+ ]
1715
+ });
1716
+ },
1717
+ children: "+ Add Node"
1718
+ }
1719
+ )
1720
+ ] })
1721
+ ] });
1722
+ }
1723
+ export {
1724
+ le as NiceEdgeManager,
1725
+ re as NiceIoTDashboard,
1726
+ se as NiceProtocolConfig
1727
+ };