@attraccess/plugin-wago 0.1.0-nightly.925.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,1489 @@
1
+ import { r as importShared } from "./_virtual___federation_fn_import-BXODRNto.js";
2
+ import { t as require_jsx_runtime } from "./jsx-runtime-B9Qmn8k7.js";
3
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/subscribable.js
4
+ var Subscribable = class {
5
+ constructor() {
6
+ this.listeners = /* @__PURE__ */ new Set();
7
+ this.subscribe = this.subscribe.bind(this);
8
+ }
9
+ subscribe(listener) {
10
+ this.listeners.add(listener);
11
+ this.onSubscribe();
12
+ return () => {
13
+ this.listeners.delete(listener);
14
+ this.onUnsubscribe();
15
+ };
16
+ }
17
+ hasListeners() {
18
+ return this.listeners.size > 0;
19
+ }
20
+ onSubscribe() {}
21
+ onUnsubscribe() {}
22
+ };
23
+ //#endregion
24
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/focusManager.js
25
+ var FocusManager = class extends Subscribable {
26
+ #focused;
27
+ #cleanup;
28
+ #setup;
29
+ constructor() {
30
+ super();
31
+ this.#setup = (onFocus) => {
32
+ if (typeof window !== "undefined" && window.addEventListener) {
33
+ const listener = () => onFocus();
34
+ window.addEventListener("visibilitychange", listener, false);
35
+ return () => {
36
+ window.removeEventListener("visibilitychange", listener);
37
+ };
38
+ }
39
+ };
40
+ }
41
+ onSubscribe() {
42
+ if (!this.#cleanup) this.setEventListener(this.#setup);
43
+ }
44
+ onUnsubscribe() {
45
+ if (!this.hasListeners()) {
46
+ this.#cleanup?.();
47
+ this.#cleanup = void 0;
48
+ }
49
+ }
50
+ setEventListener(setup) {
51
+ this.#setup = setup;
52
+ this.#cleanup?.();
53
+ this.#cleanup = setup((focused) => {
54
+ if (typeof focused === "boolean") this.setFocused(focused);
55
+ else this.onFocus();
56
+ });
57
+ }
58
+ setFocused(focused) {
59
+ if (this.#focused !== focused) {
60
+ this.#focused = focused;
61
+ this.onFocus();
62
+ }
63
+ }
64
+ onFocus() {
65
+ const isFocused = this.isFocused();
66
+ this.listeners.forEach((listener) => {
67
+ listener(isFocused);
68
+ });
69
+ }
70
+ isFocused() {
71
+ if (typeof this.#focused === "boolean") return this.#focused;
72
+ return globalThis.document?.visibilityState !== "hidden";
73
+ }
74
+ };
75
+ var focusManager = new FocusManager();
76
+ //#endregion
77
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
78
+ var defaultTimeoutProvider = {
79
+ setTimeout: (callback, delay) => setTimeout(callback, delay),
80
+ clearTimeout: (timeoutId) => clearTimeout(timeoutId),
81
+ setInterval: (callback, delay) => setInterval(callback, delay),
82
+ clearInterval: (intervalId) => clearInterval(intervalId)
83
+ };
84
+ var TimeoutManager = class {
85
+ #provider = defaultTimeoutProvider;
86
+ #providerCalled = false;
87
+ setTimeoutProvider(provider) {
88
+ this.#provider = provider;
89
+ }
90
+ setTimeout(callback, delay) {
91
+ return this.#provider.setTimeout(callback, delay);
92
+ }
93
+ clearTimeout(timeoutId) {
94
+ this.#provider.clearTimeout(timeoutId);
95
+ }
96
+ setInterval(callback, delay) {
97
+ return this.#provider.setInterval(callback, delay);
98
+ }
99
+ clearInterval(intervalId) {
100
+ this.#provider.clearInterval(intervalId);
101
+ }
102
+ };
103
+ var timeoutManager = new TimeoutManager();
104
+ function systemSetTimeoutZero(callback) {
105
+ setTimeout(callback, 0);
106
+ }
107
+ //#endregion
108
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/utils.js
109
+ var isServer = typeof window === "undefined" || "Deno" in globalThis;
110
+ function noop() {}
111
+ function isValidTimeout(value) {
112
+ return typeof value === "number" && value >= 0 && value !== Infinity;
113
+ }
114
+ function timeUntilStale(updatedAt, staleTime) {
115
+ return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
116
+ }
117
+ function resolveStaleTime(staleTime, query) {
118
+ return typeof staleTime === "function" ? staleTime(query) : staleTime;
119
+ }
120
+ function resolveQueryBoolean(option, query) {
121
+ return typeof option === "function" ? option(query) : option;
122
+ }
123
+ function hashKey(queryKey) {
124
+ return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
125
+ result[key] = val[key];
126
+ return result;
127
+ }, {}) : val);
128
+ }
129
+ var hasOwn = Object.prototype.hasOwnProperty;
130
+ function replaceEqualDeep(a, b, depth = 0) {
131
+ if (a === b) return a;
132
+ if (depth > 500) return b;
133
+ const array = isPlainArray(a) && isPlainArray(b);
134
+ if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
135
+ const aSize = (array ? a : Object.keys(a)).length;
136
+ const bItems = array ? b : Object.keys(b);
137
+ const bSize = bItems.length;
138
+ const copy = array ? new Array(bSize) : {};
139
+ let equalItems = 0;
140
+ for (let i = 0; i < bSize; i++) {
141
+ const key = array ? i : bItems[i];
142
+ const aItem = a[key];
143
+ const bItem = b[key];
144
+ if (aItem === bItem) {
145
+ copy[key] = aItem;
146
+ if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
147
+ continue;
148
+ }
149
+ if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
150
+ copy[key] = bItem;
151
+ continue;
152
+ }
153
+ const v = replaceEqualDeep(aItem, bItem, depth + 1);
154
+ copy[key] = v;
155
+ if (v === aItem) equalItems++;
156
+ }
157
+ return aSize === bSize && equalItems === aSize ? a : copy;
158
+ }
159
+ function shallowEqualObjects(a, b) {
160
+ if (!b || Object.keys(a).length !== Object.keys(b).length) return false;
161
+ for (const key in a) if (a[key] !== b[key]) return false;
162
+ return true;
163
+ }
164
+ function isPlainArray(value) {
165
+ return Array.isArray(value) && value.length === Object.keys(value).length;
166
+ }
167
+ function isPlainObject(o) {
168
+ if (!hasObjectPrototype(o)) return false;
169
+ const ctor = o.constructor;
170
+ if (ctor === void 0) return true;
171
+ const prot = ctor.prototype;
172
+ if (!hasObjectPrototype(prot)) return false;
173
+ if (!prot.hasOwnProperty("isPrototypeOf")) return false;
174
+ if (Object.getPrototypeOf(o) !== Object.prototype) return false;
175
+ return true;
176
+ }
177
+ function hasObjectPrototype(o) {
178
+ return Object.prototype.toString.call(o) === "[object Object]";
179
+ }
180
+ function replaceData(prevData, data, options) {
181
+ if (typeof options.structuralSharing === "function") return options.structuralSharing(prevData, data);
182
+ else if (options.structuralSharing !== false) return replaceEqualDeep(prevData, data);
183
+ return data;
184
+ }
185
+ function shouldThrowError(throwOnError, params) {
186
+ if (typeof throwOnError === "function") return throwOnError(...params);
187
+ return !!throwOnError;
188
+ }
189
+ //#endregion
190
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/environmentManager.js
191
+ var environmentManager = /* @__PURE__ */ (() => {
192
+ let isServerFn = () => isServer;
193
+ return {
194
+ /**
195
+ * Returns whether the current runtime should be treated as a server environment.
196
+ */
197
+ isServer() {
198
+ return isServerFn();
199
+ },
200
+ /**
201
+ * Overrides the server check globally.
202
+ */
203
+ setIsServer(isServerValue) {
204
+ isServerFn = isServerValue;
205
+ }
206
+ };
207
+ })();
208
+ //#endregion
209
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/thenable.js
210
+ function pendingThenable() {
211
+ let resolve;
212
+ let reject;
213
+ const thenable = new Promise((_resolve, _reject) => {
214
+ resolve = _resolve;
215
+ reject = _reject;
216
+ });
217
+ thenable.status = "pending";
218
+ thenable.catch(() => {});
219
+ function finalize(data) {
220
+ Object.assign(thenable, data);
221
+ delete thenable.resolve;
222
+ delete thenable.reject;
223
+ }
224
+ thenable.resolve = (value) => {
225
+ finalize({
226
+ status: "fulfilled",
227
+ value
228
+ });
229
+ resolve(value);
230
+ };
231
+ thenable.reject = (reason) => {
232
+ finalize({
233
+ status: "rejected",
234
+ reason
235
+ });
236
+ reject(reason);
237
+ };
238
+ return thenable;
239
+ }
240
+ //#endregion
241
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/notifyManager.js
242
+ var defaultScheduler = systemSetTimeoutZero;
243
+ function createNotifyManager() {
244
+ let queue = [];
245
+ let transactions = 0;
246
+ let notifyFn = (callback) => {
247
+ callback();
248
+ };
249
+ let batchNotifyFn = (callback) => {
250
+ callback();
251
+ };
252
+ let scheduleFn = defaultScheduler;
253
+ const schedule = (callback) => {
254
+ if (transactions) queue.push(callback);
255
+ else scheduleFn(() => {
256
+ notifyFn(callback);
257
+ });
258
+ };
259
+ const flush = () => {
260
+ const originalQueue = queue;
261
+ queue = [];
262
+ if (originalQueue.length) scheduleFn(() => {
263
+ batchNotifyFn(() => {
264
+ originalQueue.forEach((callback) => {
265
+ notifyFn(callback);
266
+ });
267
+ });
268
+ });
269
+ };
270
+ return {
271
+ batch: (callback) => {
272
+ let result;
273
+ transactions++;
274
+ try {
275
+ result = callback();
276
+ } finally {
277
+ transactions--;
278
+ if (!transactions) flush();
279
+ }
280
+ return result;
281
+ },
282
+ /**
283
+ * All calls to the wrapped function will be batched.
284
+ */
285
+ batchCalls: (callback) => {
286
+ return (...args) => {
287
+ schedule(() => {
288
+ callback(...args);
289
+ });
290
+ };
291
+ },
292
+ schedule,
293
+ /**
294
+ * Use this method to set a custom notify function.
295
+ * This can be used to for example wrap notifications with `React.act` while running tests.
296
+ */
297
+ setNotifyFunction: (fn) => {
298
+ notifyFn = fn;
299
+ },
300
+ /**
301
+ * Use this method to set a custom function to batch notifications together into a single tick.
302
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
303
+ */
304
+ setBatchNotifyFunction: (fn) => {
305
+ batchNotifyFn = fn;
306
+ },
307
+ setScheduler: (fn) => {
308
+ scheduleFn = fn;
309
+ }
310
+ };
311
+ }
312
+ var notifyManager = createNotifyManager();
313
+ //#endregion
314
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/onlineManager.js
315
+ var OnlineManager = class extends Subscribable {
316
+ #online = true;
317
+ #cleanup;
318
+ #setup;
319
+ constructor() {
320
+ super();
321
+ this.#setup = (onOnline) => {
322
+ if (typeof window !== "undefined" && window.addEventListener) {
323
+ const onlineListener = () => onOnline(true);
324
+ const offlineListener = () => onOnline(false);
325
+ window.addEventListener("online", onlineListener, false);
326
+ window.addEventListener("offline", offlineListener, false);
327
+ return () => {
328
+ window.removeEventListener("online", onlineListener);
329
+ window.removeEventListener("offline", offlineListener);
330
+ };
331
+ }
332
+ };
333
+ }
334
+ onSubscribe() {
335
+ if (!this.#cleanup) this.setEventListener(this.#setup);
336
+ }
337
+ onUnsubscribe() {
338
+ if (!this.hasListeners()) {
339
+ this.#cleanup?.();
340
+ this.#cleanup = void 0;
341
+ }
342
+ }
343
+ setEventListener(setup) {
344
+ this.#setup = setup;
345
+ this.#cleanup?.();
346
+ this.#cleanup = setup(this.setOnline.bind(this));
347
+ }
348
+ setOnline(online) {
349
+ if (this.#online !== online) {
350
+ this.#online = online;
351
+ this.listeners.forEach((listener) => {
352
+ listener(online);
353
+ });
354
+ }
355
+ }
356
+ isOnline() {
357
+ return this.#online;
358
+ }
359
+ };
360
+ var onlineManager = new OnlineManager();
361
+ //#endregion
362
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/retryer.js
363
+ function canFetch(networkMode) {
364
+ return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
365
+ }
366
+ //#endregion
367
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/query.js
368
+ function fetchState(data, options) {
369
+ return {
370
+ fetchFailureCount: 0,
371
+ fetchFailureReason: null,
372
+ fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
373
+ ...data === void 0 && {
374
+ error: null,
375
+ status: "pending"
376
+ }
377
+ };
378
+ }
379
+ //#endregion
380
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/queryObserver.js
381
+ var QueryObserver = class extends Subscribable {
382
+ constructor(client, options) {
383
+ super();
384
+ this.options = options;
385
+ this.#client = client;
386
+ this.#selectError = null;
387
+ this.#currentThenable = pendingThenable();
388
+ this.bindMethods();
389
+ this.setOptions(options);
390
+ }
391
+ #client;
392
+ #currentQuery = void 0;
393
+ #currentQueryInitialState = void 0;
394
+ #currentResult = void 0;
395
+ #currentResultState;
396
+ #currentResultOptions;
397
+ #currentThenable;
398
+ #selectError;
399
+ #selectFn;
400
+ #selectResult;
401
+ #lastQueryWithDefinedData;
402
+ #staleTimeoutId;
403
+ #refetchIntervalId;
404
+ #currentRefetchInterval;
405
+ #trackedProps = /* @__PURE__ */ new Set();
406
+ bindMethods() {
407
+ this.refetch = this.refetch.bind(this);
408
+ }
409
+ onSubscribe() {
410
+ if (this.listeners.size === 1) {
411
+ this.#currentQuery.addObserver(this);
412
+ if (shouldFetchOnMount(this.#currentQuery, this.options)) this.#executeFetch();
413
+ else this.updateResult();
414
+ this.#updateTimers();
415
+ }
416
+ }
417
+ onUnsubscribe() {
418
+ if (!this.hasListeners()) this.destroy();
419
+ }
420
+ shouldFetchOnReconnect() {
421
+ return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
422
+ }
423
+ shouldFetchOnWindowFocus() {
424
+ return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
425
+ }
426
+ destroy() {
427
+ this.listeners = /* @__PURE__ */ new Set();
428
+ this.#clearStaleTimeout();
429
+ this.#clearRefetchInterval();
430
+ this.#currentQuery.removeObserver(this);
431
+ }
432
+ setOptions(options) {
433
+ const prevOptions = this.options;
434
+ const prevQuery = this.#currentQuery;
435
+ this.options = this.#client.defaultQueryOptions(options);
436
+ if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
437
+ this.#updateQuery();
438
+ this.#currentQuery.setOptions(this.options);
439
+ if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({
440
+ type: "observerOptionsUpdated",
441
+ query: this.#currentQuery,
442
+ observer: this
443
+ });
444
+ const mounted = this.hasListeners();
445
+ if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch();
446
+ this.updateResult();
447
+ if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
448
+ const nextRefetchInterval = this.#computeRefetchInterval();
449
+ if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
450
+ }
451
+ getOptimisticResult(options) {
452
+ const query = this.#client.getQueryCache().build(this.#client, options);
453
+ const result = this.createResult(query, options);
454
+ if (shouldAssignObserverCurrentProperties(this, result)) {
455
+ this.#currentResult = result;
456
+ this.#currentResultOptions = this.options;
457
+ this.#currentResultState = this.#currentQuery.state;
458
+ }
459
+ return result;
460
+ }
461
+ getCurrentResult() {
462
+ return this.#currentResult;
463
+ }
464
+ trackResult(result, onPropTracked) {
465
+ return new Proxy(result, { get: (target, key) => {
466
+ this.trackProp(key);
467
+ onPropTracked?.(key);
468
+ if (key === "promise") {
469
+ this.trackProp("data");
470
+ if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") this.#currentThenable.reject(/* @__PURE__ */ new Error("experimental_prefetchInRender feature flag is not enabled"));
471
+ }
472
+ return Reflect.get(target, key);
473
+ } });
474
+ }
475
+ trackProp(key) {
476
+ this.#trackedProps.add(key);
477
+ }
478
+ getCurrentQuery() {
479
+ return this.#currentQuery;
480
+ }
481
+ refetch({ ...options } = {}) {
482
+ return this.fetch({ ...options });
483
+ }
484
+ fetchOptimistic(options) {
485
+ const defaultedOptions = this.#client.defaultQueryOptions(options);
486
+ const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
487
+ return query.fetch().then(() => this.createResult(query, defaultedOptions));
488
+ }
489
+ fetch(fetchOptions) {
490
+ return this.#executeFetch({
491
+ ...fetchOptions,
492
+ cancelRefetch: fetchOptions.cancelRefetch ?? true
493
+ }).then(() => {
494
+ this.updateResult();
495
+ return this.#currentResult;
496
+ });
497
+ }
498
+ #executeFetch(fetchOptions) {
499
+ this.#updateQuery();
500
+ let promise = this.#currentQuery.fetch(this.options, fetchOptions);
501
+ if (!fetchOptions?.throwOnError) promise = promise.catch(noop);
502
+ return promise;
503
+ }
504
+ #updateStaleTimeout() {
505
+ this.#clearStaleTimeout();
506
+ const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery);
507
+ if (environmentManager.isServer() || this.#currentResult.isStale || !isValidTimeout(staleTime)) return;
508
+ const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1;
509
+ this.#staleTimeoutId = timeoutManager.setTimeout(() => {
510
+ if (!this.#currentResult.isStale) this.updateResult();
511
+ }, timeout);
512
+ }
513
+ #computeRefetchInterval() {
514
+ return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
515
+ }
516
+ #updateRefetchInterval(nextInterval) {
517
+ this.#clearRefetchInterval();
518
+ this.#currentRefetchInterval = nextInterval;
519
+ if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) return;
520
+ this.#refetchIntervalId = timeoutManager.setInterval(() => {
521
+ if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch();
522
+ }, this.#currentRefetchInterval);
523
+ }
524
+ #updateTimers() {
525
+ this.#updateStaleTimeout();
526
+ this.#updateRefetchInterval(this.#computeRefetchInterval());
527
+ }
528
+ #clearStaleTimeout() {
529
+ if (this.#staleTimeoutId !== void 0) {
530
+ timeoutManager.clearTimeout(this.#staleTimeoutId);
531
+ this.#staleTimeoutId = void 0;
532
+ }
533
+ }
534
+ #clearRefetchInterval() {
535
+ if (this.#refetchIntervalId !== void 0) {
536
+ timeoutManager.clearInterval(this.#refetchIntervalId);
537
+ this.#refetchIntervalId = void 0;
538
+ }
539
+ }
540
+ createResult(query, options) {
541
+ const prevQuery = this.#currentQuery;
542
+ const prevOptions = this.options;
543
+ const prevResult = this.#currentResult;
544
+ const prevResultState = this.#currentResultState;
545
+ const prevResultOptions = this.#currentResultOptions;
546
+ const queryInitialState = query !== prevQuery ? query.state : this.#currentQueryInitialState;
547
+ const { state } = query;
548
+ let newState = { ...state };
549
+ let isPlaceholderData = false;
550
+ let data;
551
+ if (options._optimisticResults) {
552
+ const mounted = this.hasListeners();
553
+ const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
554
+ const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
555
+ if (fetchOnMount || fetchOptionally) newState = {
556
+ ...newState,
557
+ ...fetchState(state.data, query.options)
558
+ };
559
+ if (options._optimisticResults === "isRestoring") newState.fetchStatus = "idle";
560
+ }
561
+ let { error, errorUpdatedAt, status } = newState;
562
+ data = newState.data;
563
+ let skipSelect = false;
564
+ if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
565
+ let placeholderData;
566
+ if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
567
+ placeholderData = prevResult.data;
568
+ skipSelect = true;
569
+ } else placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(this.#lastQueryWithDefinedData?.state.data, this.#lastQueryWithDefinedData) : options.placeholderData;
570
+ if (placeholderData !== void 0) {
571
+ status = "success";
572
+ data = replaceData(prevResult?.data, placeholderData, options);
573
+ isPlaceholderData = true;
574
+ }
575
+ }
576
+ if (options.select && data !== void 0 && !skipSelect) {
577
+ if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) data = this.#selectResult;
578
+ else try {
579
+ this.#selectFn = options.select;
580
+ data = options.select(data);
581
+ data = replaceData(prevResult?.data, data, options);
582
+ this.#selectResult = data;
583
+ this.#selectError = null;
584
+ } catch (selectError) {
585
+ this.#selectError = selectError;
586
+ }
587
+ }
588
+ if (this.#selectError) {
589
+ error = this.#selectError;
590
+ data = this.#selectResult;
591
+ errorUpdatedAt = Date.now();
592
+ status = "error";
593
+ }
594
+ const isFetching = newState.fetchStatus === "fetching";
595
+ const isPending = status === "pending";
596
+ const isError = status === "error";
597
+ const isLoading = isPending && isFetching;
598
+ const hasData = data !== void 0;
599
+ const nextResult = {
600
+ status,
601
+ fetchStatus: newState.fetchStatus,
602
+ isPending,
603
+ isSuccess: status === "success",
604
+ isError,
605
+ isInitialLoading: isLoading,
606
+ isLoading,
607
+ data,
608
+ dataUpdatedAt: newState.dataUpdatedAt,
609
+ error,
610
+ errorUpdatedAt,
611
+ failureCount: newState.fetchFailureCount,
612
+ failureReason: newState.fetchFailureReason,
613
+ errorUpdateCount: newState.errorUpdateCount,
614
+ isFetched: query.isFetched(),
615
+ isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
616
+ isFetching,
617
+ isRefetching: isFetching && !isPending,
618
+ isLoadingError: isError && !hasData,
619
+ isPaused: newState.fetchStatus === "paused",
620
+ isPlaceholderData,
621
+ isRefetchError: isError && hasData,
622
+ isStale: isStale(query, options),
623
+ refetch: this.refetch,
624
+ promise: this.#currentThenable,
625
+ isEnabled: resolveQueryBoolean(options.enabled, query) !== false
626
+ };
627
+ if (this.options.experimental_prefetchInRender) {
628
+ const hasResultData = nextResult.data !== void 0;
629
+ const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
630
+ const finalizeThenableIfPossible = (thenable) => {
631
+ if (isErrorWithoutData) thenable.reject(nextResult.error);
632
+ else if (hasResultData) thenable.resolve(nextResult.data);
633
+ };
634
+ const recreateThenable = () => {
635
+ const pending = this.#currentThenable = nextResult.promise = pendingThenable();
636
+ finalizeThenableIfPossible(pending);
637
+ };
638
+ const prevThenable = this.#currentThenable;
639
+ switch (prevThenable.status) {
640
+ case "pending":
641
+ if (query.queryHash === prevQuery.queryHash) finalizeThenableIfPossible(prevThenable);
642
+ break;
643
+ case "fulfilled":
644
+ if (isErrorWithoutData || nextResult.data !== prevThenable.value) recreateThenable();
645
+ break;
646
+ case "rejected": if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) recreateThenable();
647
+ }
648
+ }
649
+ return nextResult;
650
+ }
651
+ updateResult() {
652
+ const prevResult = this.#currentResult;
653
+ const nextResult = this.createResult(this.#currentQuery, this.options);
654
+ this.#currentResultState = this.#currentQuery.state;
655
+ this.#currentResultOptions = this.options;
656
+ if (this.#currentResultState.data !== void 0) this.#lastQueryWithDefinedData = this.#currentQuery;
657
+ if (shallowEqualObjects(nextResult, prevResult)) return;
658
+ this.#currentResult = nextResult;
659
+ const shouldNotifyListeners = () => {
660
+ if (!prevResult) return true;
661
+ const { notifyOnChangeProps } = this.options;
662
+ const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
663
+ if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) return true;
664
+ const includedProps = new Set(notifyOnChangePropsValue ?? this.#trackedProps);
665
+ if (this.options.throwOnError) includedProps.add("error");
666
+ return Object.keys(this.#currentResult).some((key) => {
667
+ const typedKey = key;
668
+ return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
669
+ });
670
+ };
671
+ this.#notify({ listeners: shouldNotifyListeners() });
672
+ }
673
+ #updateQuery() {
674
+ const query = this.#client.getQueryCache().build(this.#client, this.options);
675
+ if (query === this.#currentQuery) return;
676
+ const prevQuery = this.#currentQuery;
677
+ this.#currentQuery = query;
678
+ this.#currentQueryInitialState = query.state;
679
+ if (this.hasListeners()) {
680
+ prevQuery?.removeObserver(this);
681
+ query.addObserver(this);
682
+ }
683
+ }
684
+ onQueryUpdate() {
685
+ this.updateResult();
686
+ if (this.hasListeners()) this.#updateTimers();
687
+ }
688
+ #notify(notifyOptions) {
689
+ notifyManager.batch(() => {
690
+ if (notifyOptions.listeners) this.listeners.forEach((listener) => {
691
+ listener(this.#currentResult);
692
+ });
693
+ this.#client.getQueryCache().notify({
694
+ query: this.#currentQuery,
695
+ type: "observerResultsUpdated"
696
+ });
697
+ });
698
+ }
699
+ };
700
+ function shouldLoadOnMount(query, options) {
701
+ return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false);
702
+ }
703
+ function shouldFetchOnMount(query, options) {
704
+ return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
705
+ }
706
+ function shouldFetchOn(query, options, field) {
707
+ if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
708
+ const value = typeof field === "function" ? field(query) : field;
709
+ return value === "always" || value !== false && isStale(query, options);
710
+ }
711
+ return false;
712
+ }
713
+ function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
714
+ return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
715
+ }
716
+ function isStale(query, options) {
717
+ return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
718
+ }
719
+ function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
720
+ if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) return true;
721
+ return false;
722
+ }
723
+ //#endregion
724
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/mutation.js
725
+ function getDefaultState() {
726
+ return {
727
+ context: void 0,
728
+ data: void 0,
729
+ error: null,
730
+ failureCount: 0,
731
+ failureReason: null,
732
+ isPaused: false,
733
+ status: "idle",
734
+ variables: void 0,
735
+ submittedAt: 0
736
+ };
737
+ }
738
+ //#endregion
739
+ //#region ../../../node_modules/.pnpm/@tanstack+query-core@5.101.4/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
740
+ var MutationObserver = class extends Subscribable {
741
+ #client;
742
+ #currentResult = void 0;
743
+ #currentMutation;
744
+ #mutateOptions;
745
+ constructor(client, options) {
746
+ super();
747
+ this.#client = client;
748
+ this.setOptions(options);
749
+ this.bindMethods();
750
+ this.#updateResult();
751
+ }
752
+ bindMethods() {
753
+ this.mutate = this.mutate.bind(this);
754
+ this.reset = this.reset.bind(this);
755
+ }
756
+ setOptions(options) {
757
+ const prevOptions = this.options;
758
+ this.options = this.#client.defaultMutationOptions(options);
759
+ if (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({
760
+ type: "observerOptionsUpdated",
761
+ mutation: this.#currentMutation,
762
+ observer: this
763
+ });
764
+ if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();
765
+ else if (this.#currentMutation?.state.status === "pending") this.#currentMutation.setOptions(this.options);
766
+ }
767
+ onUnsubscribe() {
768
+ if (!this.hasListeners()) this.#currentMutation?.removeObserver(this);
769
+ }
770
+ onMutationUpdate(action) {
771
+ this.#updateResult();
772
+ this.#notify(action);
773
+ }
774
+ getCurrentResult() {
775
+ return this.#currentResult;
776
+ }
777
+ reset() {
778
+ this.#currentMutation?.removeObserver(this);
779
+ this.#currentMutation = void 0;
780
+ this.#updateResult();
781
+ this.#notify();
782
+ }
783
+ mutate(variables, options) {
784
+ this.#mutateOptions = options;
785
+ this.#currentMutation?.removeObserver(this);
786
+ this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);
787
+ this.#currentMutation.addObserver(this);
788
+ return this.#currentMutation.execute(variables);
789
+ }
790
+ #updateResult() {
791
+ const state = this.#currentMutation?.state ?? getDefaultState();
792
+ this.#currentResult = {
793
+ ...state,
794
+ isPending: state.status === "pending",
795
+ isSuccess: state.status === "success",
796
+ isError: state.status === "error",
797
+ isIdle: state.status === "idle",
798
+ mutate: this.mutate,
799
+ reset: this.reset
800
+ };
801
+ }
802
+ #notify(action) {
803
+ notifyManager.batch(() => {
804
+ if (this.#mutateOptions && this.hasListeners()) {
805
+ const variables = this.#currentResult.variables;
806
+ const onMutateResult = this.#currentResult.context;
807
+ const context = {
808
+ client: this.#client,
809
+ meta: this.options.meta,
810
+ mutationKey: this.options.mutationKey
811
+ };
812
+ if (action?.type === "success") {
813
+ try {
814
+ this.#mutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);
815
+ } catch (e) {
816
+ Promise.reject(e);
817
+ }
818
+ try {
819
+ this.#mutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);
820
+ } catch (e) {
821
+ Promise.reject(e);
822
+ }
823
+ } else if (action?.type === "error") {
824
+ try {
825
+ this.#mutateOptions.onError?.(action.error, variables, onMutateResult, context);
826
+ } catch (e) {
827
+ Promise.reject(e);
828
+ }
829
+ try {
830
+ this.#mutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);
831
+ } catch (e) {
832
+ Promise.reject(e);
833
+ }
834
+ }
835
+ }
836
+ this.listeners.forEach((listener) => {
837
+ listener(this.#currentResult);
838
+ });
839
+ });
840
+ }
841
+ };
842
+ //#endregion
843
+ //#region ../../../node_modules/.pnpm/@tanstack+react-query@5.101.4_react@19.2.8/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
844
+ var import_jsx_runtime = require_jsx_runtime();
845
+ var React$5 = await importShared("react");
846
+ var QueryClientContext = React$5.createContext(void 0);
847
+ var useQueryClient = (queryClient) => {
848
+ const client = React$5.useContext(QueryClientContext);
849
+ if (queryClient) return queryClient;
850
+ if (!client) throw new Error("No QueryClient set, use QueryClientProvider to set one");
851
+ return client;
852
+ };
853
+ //#endregion
854
+ //#region ../../../node_modules/.pnpm/@tanstack+react-query@5.101.4_react@19.2.8/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
855
+ var React$4 = await importShared("react");
856
+ var IsRestoringContext = React$4.createContext(false);
857
+ var useIsRestoring = () => React$4.useContext(IsRestoringContext);
858
+ IsRestoringContext.Provider;
859
+ //#endregion
860
+ //#region ../../../node_modules/.pnpm/@tanstack+react-query@5.101.4_react@19.2.8/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
861
+ var React$3 = await importShared("react");
862
+ function createValue() {
863
+ let isReset = false;
864
+ return {
865
+ clearReset: () => {
866
+ isReset = false;
867
+ },
868
+ reset: () => {
869
+ isReset = true;
870
+ },
871
+ isReset: () => {
872
+ return isReset;
873
+ }
874
+ };
875
+ }
876
+ var QueryErrorResetBoundaryContext = React$3.createContext(createValue());
877
+ var useQueryErrorResetBoundary = () => React$3.useContext(QueryErrorResetBoundaryContext);
878
+ //#endregion
879
+ //#region ../../../node_modules/.pnpm/@tanstack+react-query@5.101.4_react@19.2.8/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
880
+ var React$2 = await importShared("react");
881
+ var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
882
+ const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
883
+ if (options.suspense || options.experimental_prefetchInRender || throwOnError) {
884
+ if (!errorResetBoundary.isReset()) options.retryOnMount = false;
885
+ }
886
+ };
887
+ var useClearResetErrorBoundary = (errorResetBoundary) => {
888
+ React$2.useEffect(() => {
889
+ errorResetBoundary.clearReset();
890
+ }, [errorResetBoundary]);
891
+ };
892
+ var getHasError = ({ result, errorResetBoundary, throwOnError, query, suspense }) => {
893
+ return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
894
+ };
895
+ //#endregion
896
+ //#region ../../../node_modules/.pnpm/@tanstack+react-query@5.101.4_react@19.2.8/node_modules/@tanstack/react-query/build/modern/suspense.js
897
+ var ensureSuspenseTimers = (defaultedOptions) => {
898
+ if (defaultedOptions.suspense) {
899
+ const MIN_SUSPENSE_TIME_MS = 1e3;
900
+ const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
901
+ const originalStaleTime = defaultedOptions.staleTime;
902
+ defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
903
+ if (typeof defaultedOptions.gcTime === "number") defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, MIN_SUSPENSE_TIME_MS);
904
+ }
905
+ };
906
+ var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
907
+ var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
908
+ var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
909
+ errorResetBoundary.clearReset();
910
+ });
911
+ //#endregion
912
+ //#region ../../../node_modules/.pnpm/@tanstack+react-query@5.101.4_react@19.2.8/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
913
+ var React$1 = await importShared("react");
914
+ function useBaseQuery(options, Observer, queryClient) {
915
+ const isRestoring = useIsRestoring();
916
+ const errorResetBoundary = useQueryErrorResetBoundary();
917
+ const client = useQueryClient(queryClient);
918
+ const defaultedOptions = client.defaultQueryOptions(options);
919
+ client.getDefaultOptions().queries?._experimental_beforeQuery?.(defaultedOptions);
920
+ const query = client.getQueryCache().get(defaultedOptions.queryHash);
921
+ const subscribed = options.subscribed !== false;
922
+ defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : subscribed ? "optimistic" : void 0;
923
+ ensureSuspenseTimers(defaultedOptions);
924
+ ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
925
+ useClearResetErrorBoundary(errorResetBoundary);
926
+ const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
927
+ const [observer] = React$1.useState(() => new Observer(client, defaultedOptions));
928
+ const result = observer.getOptimisticResult(defaultedOptions);
929
+ const shouldSubscribe = !isRestoring && subscribed;
930
+ React$1.useSyncExternalStore(React$1.useCallback((onStoreChange) => {
931
+ const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
932
+ observer.updateResult();
933
+ return unsubscribe;
934
+ }, [observer, shouldSubscribe]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
935
+ React$1.useEffect(() => {
936
+ observer.setOptions(defaultedOptions);
937
+ }, [defaultedOptions, observer]);
938
+ if (shouldSuspend(defaultedOptions, result)) throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
939
+ if (getHasError({
940
+ result,
941
+ errorResetBoundary,
942
+ throwOnError: defaultedOptions.throwOnError,
943
+ query,
944
+ suspense: defaultedOptions.suspense
945
+ })) throw result.error;
946
+ client.getDefaultOptions().queries?._experimental_afterQuery?.(defaultedOptions, result);
947
+ if (defaultedOptions.experimental_prefetchInRender && !environmentManager.isServer() && willFetch(result, isRestoring)) (isNewCacheEntry ? fetchOptimistic(defaultedOptions, observer, errorResetBoundary) : query?.promise)?.catch(noop).finally(() => {
948
+ observer.updateResult();
949
+ });
950
+ return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
951
+ }
952
+ //#endregion
953
+ //#region ../../../node_modules/.pnpm/@tanstack+react-query@5.101.4_react@19.2.8/node_modules/@tanstack/react-query/build/modern/useQuery.js
954
+ function useQuery(options, queryClient) {
955
+ return useBaseQuery(options, QueryObserver, queryClient);
956
+ }
957
+ //#endregion
958
+ //#region ../../../node_modules/.pnpm/@tanstack+react-query@5.101.4_react@19.2.8/node_modules/@tanstack/react-query/build/modern/useMutation.js
959
+ var React = await importShared("react");
960
+ function useMutation(options, queryClient) {
961
+ const client = useQueryClient(queryClient);
962
+ const [observer] = React.useState(() => new MutationObserver(client, options));
963
+ React.useEffect(() => {
964
+ observer.setOptions(options);
965
+ }, [observer, options]);
966
+ const result = React.useSyncExternalStore(React.useCallback((onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
967
+ const mutate = React.useCallback((variables, mutateOptions) => {
968
+ observer.mutate(variables, mutateOptions).catch(noop);
969
+ }, [observer]);
970
+ if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) throw result.error;
971
+ return {
972
+ ...result,
973
+ mutate,
974
+ mutateAsync: result.mutate
975
+ };
976
+ }
977
+ //#endregion
978
+ //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.api-client.ts
979
+ var BASE_URL_GLOBAL = "__ATTRACCESS_API_BASE_URL__";
980
+ /** The API origin the host is talking to. Falls back to the current origin. */
981
+ function getApiBaseUrl() {
982
+ return window[BASE_URL_GLOBAL] ?? window.location.origin;
983
+ }
984
+ /** Thrown for any non-2xx response, carrying the status for callers that branch on it. */
985
+ var PluginApiError = class extends Error {
986
+ constructor(message, status) {
987
+ super(message);
988
+ this.status = status;
989
+ this.name = "PluginApiError";
990
+ }
991
+ };
992
+ async function toError(res) {
993
+ try {
994
+ const body = await res.json();
995
+ const message = Array.isArray(body.message) ? body.message.join(", ") : body.message;
996
+ if (message) return new PluginApiError(message, res.status);
997
+ } catch {}
998
+ return new PluginApiError(`Request failed (HTTP ${res.status}).`, res.status);
999
+ }
1000
+ /**
1001
+ * Creates a client bound to `basePath`, which is resolved against the host's
1002
+ * API origin. Plugin routes are mounted under `/api/<plugin-name>`, so that is
1003
+ * the usual argument; pass nothing to address the host API directly.
1004
+ */
1005
+ function createPluginApiClient(basePath = "") {
1006
+ const url = (path, query) => {
1007
+ const target = new URL(`${basePath}${path}`, getApiBaseUrl());
1008
+ Object.entries(query ?? {}).forEach(([key, value]) => {
1009
+ if (value !== void 0 && value !== null) target.searchParams.set(key, String(value));
1010
+ });
1011
+ return target.toString();
1012
+ };
1013
+ const doFetch = (path, init) => fetch(url(path), {
1014
+ credentials: "include",
1015
+ ...init
1016
+ });
1017
+ return {
1018
+ url,
1019
+ fetch: doFetch,
1020
+ async request(path, options = {}) {
1021
+ const { body, query, headers, ...init } = options;
1022
+ const res = await fetch(url(path, query), {
1023
+ credentials: "include",
1024
+ ...init,
1025
+ headers: body === void 0 ? headers : {
1026
+ "Content-Type": "application/json",
1027
+ ...headers
1028
+ },
1029
+ body: body === void 0 ? void 0 : JSON.stringify(body)
1030
+ });
1031
+ if (!res.ok) throw await toError(res);
1032
+ const text = await res.text();
1033
+ return text.length > 0 ? JSON.parse(text) : null;
1034
+ }
1035
+ };
1036
+ }
1037
+ //#endregion
1038
+ //#region frontend/src/api.ts
1039
+ var api = createPluginApiClient("/api/wago");
1040
+ var listControllers = () => api.request("/controllers");
1041
+ var getSettings = () => api.request("/settings");
1042
+ var setSettings = (defaultMqttServerId) => api.request("/settings", {
1043
+ method: "POST",
1044
+ body: { defaultMqttServerId }
1045
+ });
1046
+ var claimController = (id, input) => api.request(`/controllers/${id}/claim`, {
1047
+ method: "POST",
1048
+ body: input
1049
+ });
1050
+ var createEnrollment = (input) => api.request("/enrollments", {
1051
+ method: "POST",
1052
+ body: input
1053
+ });
1054
+ //#endregion
1055
+ //#region frontend/src/queries.ts
1056
+ var queryKeys = {
1057
+ controllers: ["wago", "controllers"],
1058
+ settings: ["wago", "settings"]
1059
+ };
1060
+ function useControllersQuery() {
1061
+ return useQuery({
1062
+ queryKey: queryKeys.controllers,
1063
+ queryFn: listControllers,
1064
+ refetchInterval: 1e4
1065
+ });
1066
+ }
1067
+ function useSettingsQuery() {
1068
+ return useQuery({
1069
+ queryKey: queryKeys.settings,
1070
+ queryFn: getSettings
1071
+ });
1072
+ }
1073
+ function useUpdateSettingsMutation() {
1074
+ const queryClient = useQueryClient();
1075
+ return useMutation({
1076
+ mutationFn: setSettings,
1077
+ onSuccess: async () => {
1078
+ await queryClient.invalidateQueries({ queryKey: queryKeys.settings });
1079
+ }
1080
+ });
1081
+ }
1082
+ function useClaimControllerMutation() {
1083
+ const queryClient = useQueryClient();
1084
+ return useMutation({
1085
+ mutationFn: ({ id, input }) => claimController(id, input),
1086
+ onSuccess: async () => {
1087
+ await queryClient.invalidateQueries({ queryKey: queryKeys.controllers });
1088
+ }
1089
+ });
1090
+ }
1091
+ function useCreateEnrollmentMutation() {
1092
+ return useMutation({ mutationFn: (input) => createEnrollment(input) });
1093
+ }
1094
+ //#endregion
1095
+ //#region frontend/src/ClaimControllerModal.tsx
1096
+ var { Alert: Alert$3, Button: Button$4, Form: Form$2, Input: Input$2, Label: Label$2, Modal, ModalBackdrop, ModalBody, ModalContainer, ModalDialog, ModalFooter, ModalHeader, ModalHeading, TextField: TextField$2 } = await importShared("@heroui/react");
1097
+ var { useEffectEvent, useState: useState$3 } = await importShared("react");
1098
+ function ClaimControllerModal({ controllerId, onOpenChange }) {
1099
+ const claimMutation = useClaimControllerMutation();
1100
+ const [name, setName] = useState$3("");
1101
+ const [verifier, setVerifier] = useState$3("");
1102
+ function close() {
1103
+ setName("");
1104
+ setVerifier("");
1105
+ claimMutation.reset();
1106
+ onOpenChange(false);
1107
+ }
1108
+ const closeClaimedController = useEffectEvent((claimedControllerId) => {
1109
+ if (controllerId === claimedControllerId) close();
1110
+ });
1111
+ function submitClaim() {
1112
+ if (controllerId === null) return;
1113
+ const claimedControllerId = controllerId;
1114
+ claimMutation.mutate({
1115
+ id: claimedControllerId,
1116
+ input: {
1117
+ name,
1118
+ verifier
1119
+ }
1120
+ }, { onSuccess: () => closeClaimedController(claimedControllerId) });
1121
+ }
1122
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Modal, {
1123
+ isOpen: controllerId !== null,
1124
+ onOpenChange: (isOpen) => {
1125
+ if (!isOpen) close();
1126
+ },
1127
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalBackdrop, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalContainer, {
1128
+ size: "sm",
1129
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalDialog, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeading, { children: "Claim controller" }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Form$2, {
1130
+ onSubmit: (event) => {
1131
+ event.preventDefault();
1132
+ submitClaim();
1133
+ },
1134
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalBody, { children: [
1135
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1136
+ className: "wg:text-sm wg:text-muted",
1137
+ children: "Verify physical access to this controller before it can receive commands."
1138
+ }),
1139
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$2, {
1140
+ isRequired: true,
1141
+ name: "name",
1142
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$2, { children: "Controller name" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$2, {
1143
+ value: name,
1144
+ onChange: (event) => setName(event.target.value)
1145
+ })]
1146
+ }),
1147
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$2, {
1148
+ isRequired: true,
1149
+ name: "verifier",
1150
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$2, { children: "Physical pairing code or fingerprint" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$2, {
1151
+ value: verifier,
1152
+ onChange: (event) => setVerifier(event.target.value)
1153
+ })]
1154
+ }),
1155
+ claimMutation.isError && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert$3, {
1156
+ status: "danger",
1157
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$3.Indicator, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$3.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$3.Description, { children: getErrorMessage$3(claimMutation.error) }) })]
1158
+ })
1159
+ ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalFooter, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
1160
+ variant: "secondary",
1161
+ onPress: close,
1162
+ children: "Cancel"
1163
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
1164
+ type: "submit",
1165
+ isPending: claimMutation.isPending,
1166
+ children: "Verify and claim"
1167
+ })] })]
1168
+ })] })
1169
+ }) })
1170
+ });
1171
+ }
1172
+ function getErrorMessage$3(error) {
1173
+ return error instanceof Error ? error.message : "Please try again.";
1174
+ }
1175
+ //#endregion
1176
+ //#region frontend/src/CreateEnrollmentCard.tsx
1177
+ var { Alert: Alert$2, Button: Button$3, Form: Form$1, Input: Input$1, Label: Label$1, TextField: TextField$1 } = await importShared("@heroui/react");
1178
+ var { useState: useState$2 } = await importShared("react");
1179
+ function CreateEnrollmentCard() {
1180
+ const createEnrollmentMutation = useCreateEnrollmentMutation();
1181
+ const [hardwareId, setHardwareId] = useState$2("");
1182
+ const [manualUsername, setManualUsername] = useState$2("");
1183
+ const [manualPassword, setManualPassword] = useState$2("");
1184
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1185
+ className: "wg:max-w-xl",
1186
+ children: [
1187
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
1188
+ className: "wg:mb-4",
1189
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
1190
+ className: "wg:text-lg wg:font-semibold",
1191
+ children: "Enrollment package"
1192
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1193
+ className: "wg:mt-1 wg:text-sm wg:text-muted",
1194
+ children: "Manual credentials must be restricted to this controller's discovery and claim topics."
1195
+ })]
1196
+ }),
1197
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Form$1, {
1198
+ onSubmit: (event) => {
1199
+ event.preventDefault();
1200
+ createEnrollmentMutation.mutate({
1201
+ hardwareId,
1202
+ manualUsername: manualUsername || void 0,
1203
+ manualPassword: manualPassword || void 0
1204
+ });
1205
+ },
1206
+ children: [
1207
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$1, {
1208
+ name: "hardwareId",
1209
+ isRequired: true,
1210
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$1, { children: "Controller hardware ID" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$1, {
1211
+ value: hardwareId,
1212
+ onChange: (event) => setHardwareId(event.target.value)
1213
+ })]
1214
+ }),
1215
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$1, {
1216
+ name: "manualUsername",
1217
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$1, { children: "Manual discovery username (fallback)" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$1, {
1218
+ value: manualUsername,
1219
+ onChange: (event) => setManualUsername(event.target.value)
1220
+ })]
1221
+ }),
1222
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$1, {
1223
+ name: "manualPassword",
1224
+ type: "password",
1225
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$1, { children: "Manual discovery password (fallback)" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$1, {
1226
+ value: manualPassword,
1227
+ onChange: (event) => setManualPassword(event.target.value)
1228
+ })]
1229
+ }),
1230
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
1231
+ type: "submit",
1232
+ isPending: createEnrollmentMutation.isPending,
1233
+ children: "Create package"
1234
+ })
1235
+ ]
1236
+ }),
1237
+ createEnrollmentMutation.isError && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert$2, {
1238
+ className: "wg:mt-4",
1239
+ status: "danger",
1240
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$2.Indicator, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$2.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$2.Description, { children: getErrorMessage$2(createEnrollmentMutation.error) }) })]
1241
+ }),
1242
+ createEnrollmentMutation.data && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
1243
+ className: "wg:mt-4 wg:overflow-x-auto wg:rounded-medium wg:bg-default-100 wg:p-4 wg:text-xs",
1244
+ children: JSON.stringify(createEnrollmentMutation.data, null, 2)
1245
+ })
1246
+ ]
1247
+ });
1248
+ }
1249
+ function getErrorMessage$2(error) {
1250
+ return error instanceof Error ? error.message : "Please try again.";
1251
+ }
1252
+ //#endregion
1253
+ //#region frontend/src/ControllersTable.tsx
1254
+ var { Button: Button$2, Chip, Table, TableBody, TableCell, TableColumn, TableContent, TableHeader, TableRow, TableScrollContainer } = await importShared("@heroui/react");
1255
+ function ControllersTable({ controllers, onClaim }) {
1256
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Table, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableScrollContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableContent, {
1257
+ "aria-label": "WAGO controllers",
1258
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableHeader, { children: [
1259
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1260
+ isRowHeader: true,
1261
+ children: "Controller"
1262
+ }),
1263
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, { children: "Trust" }),
1264
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, { children: "Connection" }),
1265
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1266
+ className: "wg:hidden wg:md:table-cell",
1267
+ children: "Runtime"
1268
+ }),
1269
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1270
+ className: "wg:hidden wg:lg:table-cell",
1271
+ children: "Last heartbeat"
1272
+ }),
1273
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableColumn, {
1274
+ className: "wg:text-end",
1275
+ children: "Actions"
1276
+ })
1277
+ ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableBody, {
1278
+ items: controllers,
1279
+ renderEmptyState: EmptyControllers,
1280
+ children: (controller) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableRow, {
1281
+ id: controller.id,
1282
+ children: [
1283
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1284
+ className: "wg:flex wg:flex-col",
1285
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1286
+ className: "wg:font-medium",
1287
+ children: controller.name ?? controller.hardwareId
1288
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1289
+ className: "wg:text-xs wg:text-muted",
1290
+ children: controller.hardwareId
1291
+ })]
1292
+ }) }),
1293
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TrustChip, { trustState: controller.trustState }) }),
1294
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectivityChip, { connectivity: controller.connectivity }) }),
1295
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableCell, {
1296
+ className: "wg:hidden wg:md:table-cell",
1297
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
1298
+ controller.protocolVersion,
1299
+ " / ",
1300
+ controller.runtimeVersion
1301
+ ] }), controller.compatibilityError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1302
+ className: "wg:mt-1 wg:text-xs wg:text-danger",
1303
+ children: controller.compatibilityError
1304
+ })]
1305
+ }),
1306
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, {
1307
+ className: "wg:hidden wg:lg:table-cell",
1308
+ children: formatHeartbeat(controller.lastHeartbeatAt)
1309
+ }),
1310
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { children: controller.trustState === "untrusted" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
1311
+ size: "sm",
1312
+ onPress: () => onClaim(controller.id),
1313
+ children: "Claim"
1314
+ }) })
1315
+ ]
1316
+ }, controller.id)
1317
+ })]
1318
+ }) }) });
1319
+ }
1320
+ function EmptyControllers() {
1321
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1322
+ className: "wg:px-4 wg:py-12 wg:text-center wg:text-sm wg:text-muted",
1323
+ children: "No candidates yet. Configure a default MQTT server, then start the enrolled controller."
1324
+ });
1325
+ }
1326
+ function TrustChip({ trustState }) {
1327
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip, {
1328
+ color: trustState === "claimed" ? "success" : "warning",
1329
+ size: "sm",
1330
+ variant: "soft",
1331
+ children: trustState
1332
+ });
1333
+ }
1334
+ function ConnectivityChip({ connectivity }) {
1335
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip, {
1336
+ color: connectivity === "online" ? "success" : connectivity === "stale" ? "warning" : "default",
1337
+ size: "sm",
1338
+ variant: "soft",
1339
+ children: connectivity
1340
+ });
1341
+ }
1342
+ function formatHeartbeat(lastHeartbeatAt) {
1343
+ return lastHeartbeatAt ? new Date(lastHeartbeatAt).toLocaleString() : "Never";
1344
+ }
1345
+ //#endregion
1346
+ //#region frontend/src/MqttSettingsCard.tsx
1347
+ var { Alert: Alert$1, Button: Button$1, Form, Input, Label, Spinner: Spinner$1, TextField } = await importShared("@heroui/react");
1348
+ var { useEffect, useState: useState$1 } = await importShared("react");
1349
+ function MqttSettingsCard() {
1350
+ const settingsQuery = useSettingsQuery();
1351
+ const updateSettingsMutation = useUpdateSettingsMutation();
1352
+ const [defaultServerId, setDefaultServerId] = useState$1("");
1353
+ useEffect(() => {
1354
+ setDefaultServerId(settingsQuery.data?.defaultMqttServerId?.toString() ?? "");
1355
+ }, [settingsQuery.data]);
1356
+ if (settingsQuery.isPending) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner$1, {
1357
+ color: "accent",
1358
+ size: "sm"
1359
+ });
1360
+ if (settingsQuery.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert$1, {
1361
+ status: "danger",
1362
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$1.Indicator, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert$1.Content, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$1.Title, { children: "Could not load MQTT settings" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$1.Description, { children: getErrorMessage$1(settingsQuery.error) })] })]
1363
+ });
1364
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1365
+ className: "wg:max-w-xl",
1366
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
1367
+ className: "wg:mb-4",
1368
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
1369
+ className: "wg:text-lg wg:font-semibold",
1370
+ children: "MQTT settings"
1371
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1372
+ className: "wg:mt-1 wg:text-sm wg:text-muted",
1373
+ children: "Select the MQTT server used when claiming controllers."
1374
+ })]
1375
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Form, {
1376
+ onSubmit: (event) => {
1377
+ event.preventDefault();
1378
+ updateSettingsMutation.mutate(defaultServerId ? Number(defaultServerId) : null);
1379
+ },
1380
+ children: [
1381
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField, {
1382
+ name: "defaultMqttServerId",
1383
+ type: "number",
1384
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { children: "Default MQTT server ID" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
1385
+ min: "1",
1386
+ value: defaultServerId,
1387
+ onChange: (event) => setDefaultServerId(event.target.value)
1388
+ })]
1389
+ }),
1390
+ updateSettingsMutation.isError && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert$1, {
1391
+ className: "wg:mt-4",
1392
+ status: "danger",
1393
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$1.Indicator, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$1.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert$1.Description, { children: getErrorMessage$1(updateSettingsMutation.error) }) })]
1394
+ }),
1395
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
1396
+ type: "submit",
1397
+ isPending: updateSettingsMutation.isPending,
1398
+ children: "Save"
1399
+ })
1400
+ ]
1401
+ })]
1402
+ });
1403
+ }
1404
+ function getErrorMessage$1(error) {
1405
+ return error instanceof Error ? error.message : "Please try again.";
1406
+ }
1407
+ //#endregion
1408
+ //#region frontend/src/ControllersPage.tsx
1409
+ var { Alert, Button, Spinner } = await importShared("@heroui/react");
1410
+ var { RefreshCwIcon } = await importShared("lucide-react");
1411
+ var { useState } = await importShared("react");
1412
+ function ControllersPage() {
1413
+ const controllersQuery = useControllersQuery();
1414
+ const [claimControllerId, setClaimControllerId] = useState(null);
1415
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", {
1416
+ className: "wg:mx-auto wg:flex wg:w-full wg:max-w-6xl wg:flex-col wg:gap-6 wg:p-4 wg:md:p-6",
1417
+ children: [
1418
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
1419
+ className: "wg:flex wg:flex-wrap wg:items-center wg:justify-between wg:gap-4",
1420
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
1421
+ className: "wg:text-2xl wg:font-semibold",
1422
+ children: "WAGO controllers"
1423
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1424
+ className: "wg:mt-1 wg:text-sm wg:text-muted",
1425
+ children: "Discovery candidates cannot receive commands until physically claimed."
1426
+ })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button, {
1427
+ variant: "secondary",
1428
+ isPending: controllersQuery.isFetching,
1429
+ onPress: () => void controllersQuery.refetch(),
1430
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RefreshCwIcon, { className: "wg:h-4 wg:w-4" }), " Refresh"]
1431
+ })]
1432
+ }),
1433
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MqttSettingsCard, {}),
1434
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CreateEnrollmentCard, {}),
1435
+ controllersQuery.isError && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert, {
1436
+ status: "danger",
1437
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert.Indicator, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert.Content, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert.Title, { children: "Could not load WAGO controllers" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert.Description, { children: getErrorMessage(controllersQuery.error) })] })]
1438
+ }),
1439
+ controllersQuery.isPending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1440
+ className: "wg:flex wg:justify-center wg:p-6",
1441
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { color: "accent" })
1442
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControllersTable, {
1443
+ controllers: controllersQuery.data ?? [],
1444
+ onClaim: setClaimControllerId
1445
+ }),
1446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClaimControllerModal, {
1447
+ controllerId: claimControllerId,
1448
+ onOpenChange: (isOpen) => {
1449
+ if (!isOpen) setClaimControllerId(null);
1450
+ }
1451
+ })
1452
+ ]
1453
+ });
1454
+ }
1455
+ function getErrorMessage(error) {
1456
+ return error instanceof Error ? error.message : "Please try again.";
1457
+ }
1458
+ //#endregion
1459
+ //#region frontend/src/plugin.tsx
1460
+ var { CpuIcon } = await importShared("lucide-react");
1461
+ var WagoPlugin = class {
1462
+ getPluginName() {
1463
+ return "wago-plugin@0.1.0";
1464
+ }
1465
+ getDependencies() {
1466
+ return [];
1467
+ }
1468
+ init(store) {}
1469
+ activate() {}
1470
+ deactivate() {}
1471
+ onApiAuthStateChange(authData) {}
1472
+ onApiEndpointChange(endpoint) {}
1473
+ getRoutes() {
1474
+ return [{
1475
+ path: "/wago",
1476
+ authRequired: "resources.update",
1477
+ element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControllersPage, {})
1478
+ }];
1479
+ }
1480
+ getSidebarItems() {
1481
+ return [{
1482
+ label: "WAGO",
1483
+ path: "/wago",
1484
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CpuIcon, { className: "wg:w-5 wg:h-5" })
1485
+ }];
1486
+ }
1487
+ };
1488
+ //#endregion
1489
+ export { WagoPlugin as default };