@attraccess/plugin-reservations 0.0.0-stage → 0.1.0-alpha.0

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,3788 @@
1
+ import { r as importShared } from "./_virtual___federation_fn_import-BXODRNto.js";
2
+ //#region \0rolldown/runtime.js
3
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
4
+ //#endregion
5
+ //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.api-client.ts
6
+ var BASE_URL_GLOBAL = "__ATTRACCESS_API_BASE_URL__";
7
+ /** The API origin the host is talking to. Falls back to the current origin. */
8
+ function getApiBaseUrl() {
9
+ return window[BASE_URL_GLOBAL] ?? window.location.origin;
10
+ }
11
+ /** Thrown for any non-2xx response, carrying the status for callers that branch on it. */
12
+ var PluginApiError = class extends Error {
13
+ constructor(message, status) {
14
+ super(message);
15
+ this.status = status;
16
+ this.name = "PluginApiError";
17
+ }
18
+ };
19
+ async function toError(res) {
20
+ try {
21
+ const body = await res.json();
22
+ const message = Array.isArray(body.message) ? body.message.join(", ") : body.message;
23
+ if (message) return new PluginApiError(message, res.status);
24
+ } catch {}
25
+ return new PluginApiError(`Request failed (HTTP ${res.status}).`, res.status);
26
+ }
27
+ /**
28
+ * Creates a client bound to `basePath`, which is resolved against the host's
29
+ * API origin. Plugin routes are mounted under `/api/<plugin-name>`, so that is
30
+ * the usual argument; pass nothing to address the host API directly.
31
+ */
32
+ function createPluginApiClient(basePath = "") {
33
+ const url = (path, query) => {
34
+ const target = new URL(`${basePath}${path}`, getApiBaseUrl());
35
+ Object.entries(query ?? {}).forEach(([key, value]) => {
36
+ if (value !== void 0 && value !== null) target.searchParams.set(key, String(value));
37
+ });
38
+ return target.toString();
39
+ };
40
+ const doFetch = (path, init) => fetch(url(path), {
41
+ credentials: "include",
42
+ ...init
43
+ });
44
+ return {
45
+ url,
46
+ fetch: doFetch,
47
+ async request(path, options = {}) {
48
+ const { body, query, headers, ...init } = options;
49
+ const res = await fetch(url(path, query), {
50
+ credentials: "include",
51
+ ...init,
52
+ headers: body === void 0 ? headers : {
53
+ "Content-Type": "application/json",
54
+ ...headers
55
+ },
56
+ body: body === void 0 ? void 0 : JSON.stringify(body)
57
+ });
58
+ if (!res.ok) throw await toError(res);
59
+ const text = await res.text();
60
+ return text.length > 0 ? JSON.parse(text) : null;
61
+ }
62
+ };
63
+ }
64
+ //#endregion
65
+ //#region ../../../node_modules/.pnpm/react@19.2.8/node_modules/react/cjs/react-jsx-runtime.production.js
66
+ /**
67
+ * @license React
68
+ * react-jsx-runtime.production.js
69
+ *
70
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
71
+ *
72
+ * This source code is licensed under the MIT license found in the
73
+ * LICENSE file in the root directory of this source tree.
74
+ */
75
+ var require_react_jsx_runtime_production = /* @__PURE__ */ __commonJSMin(((exports) => {
76
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
77
+ var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
78
+ function jsxProd(type, config, maybeKey) {
79
+ var key = null;
80
+ void 0 !== maybeKey && (key = "" + maybeKey);
81
+ void 0 !== config.key && (key = "" + config.key);
82
+ if ("key" in config) {
83
+ maybeKey = {};
84
+ for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
85
+ } else maybeKey = config;
86
+ config = maybeKey.ref;
87
+ return {
88
+ $$typeof: REACT_ELEMENT_TYPE,
89
+ type,
90
+ key,
91
+ ref: void 0 !== config ? config : null,
92
+ props: maybeKey
93
+ };
94
+ }
95
+ exports.Fragment = REACT_FRAGMENT_TYPE;
96
+ exports.jsx = jsxProd;
97
+ exports.jsxs = jsxProd;
98
+ }));
99
+ //#endregion
100
+ //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.live-updates.tsx
101
+ var import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
102
+ module.exports = require_react_jsx_runtime_production();
103
+ })))();
104
+ var { createContext, useCallback: useCallback$1, useContext, useEffect: useEffect$7, useRef: useRef$1 } = await importShared("react");
105
+ var contextKey = Symbol.for("attraccess.plugin.live-updates.context");
106
+ var contexts = globalThis;
107
+ contexts[contextKey] ??= createContext(null);
108
+ var identityKey = Symbol.for("attraccess.plugin.live-updates.identity");
109
+ var identities = globalThis;
110
+ identities[identityKey] ??= createContext(null);
111
+ //#endregion
112
+ //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.slots.ts
113
+ var RESOURCE_OVERVIEW_SLOT = "resource.overview";
114
+ var RESOURCE_SETTINGS_SLOT = "resource.settings";
115
+ var USER_ACCOUNT_SLOT = "user.account";
116
+ var ADMIN_SETTINGS_SLOT = "admin.settings";
117
+ //#endregion
118
+ //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-drawer.tsx
119
+ var { StandardDrawer: SharedStandardDrawer } = await importShared("@attraccess/plugins-frontend-ui");
120
+ //#endregion
121
+ //#region ../../../libs/plugins-frontend-sdk/src/lib/frontend.standard-modal.tsx
122
+ var { StandardModal: SharedStandardModal } = await importShared("@attraccess/plugins-frontend-ui");
123
+ //#endregion
124
+ //#region frontend/src/api.ts
125
+ var api = createPluginApiClient("/api/reservations");
126
+ var hostApi$1 = createPluginApiClient("");
127
+ var ReservationsApiError = class extends Error {
128
+ constructor(message, status, code, count, fieldErrors) {
129
+ super(message);
130
+ this.status = status;
131
+ this.code = code;
132
+ this.count = count;
133
+ this.fieldErrors = fieldErrors;
134
+ this.name = "ReservationsApiError";
135
+ }
136
+ };
137
+ function withQuery(path, query) {
138
+ const params = new URLSearchParams();
139
+ Object.entries(query ?? {}).forEach(([key, value]) => {
140
+ if (value !== void 0 && value !== null && value !== "") params.set(key, String(value));
141
+ });
142
+ const text = params.toString();
143
+ return text ? `${path}?${text}` : path;
144
+ }
145
+ async function call(client, path, options) {
146
+ const response = await client.fetch(withQuery(path, options.query), {
147
+ method: options.method,
148
+ signal: options.signal,
149
+ headers: options.body === void 0 ? void 0 : { "Content-Type": "application/json" },
150
+ body: options.body === void 0 ? void 0 : JSON.stringify(options.body)
151
+ });
152
+ const text = await response.text();
153
+ let parsed = null;
154
+ try {
155
+ parsed = text ? JSON.parse(text) : null;
156
+ } catch {
157
+ parsed = null;
158
+ }
159
+ if (!response.ok) {
160
+ const body = parsed ?? {};
161
+ throw new ReservationsApiError((Array.isArray(body.message) ? body.message.join(", ") : body.message) ?? `Request failed (HTTP ${response.status}).`, response.status, body.code, body.count, body.errors);
162
+ }
163
+ return parsed;
164
+ }
165
+ var request = (path, options = {}) => call(api, path, options);
166
+ var getAvailability = (resourceId, from, to, signal) => request(`/resources/${resourceId}/availability`, {
167
+ query: {
168
+ from: from.toISOString(),
169
+ to: to.toISOString()
170
+ },
171
+ signal
172
+ });
173
+ var listMine = (scope, status) => request("/mine", { query: {
174
+ scope,
175
+ status
176
+ } });
177
+ var listManaged = (filter) => request("/manage", { query: { ...filter } });
178
+ var manageAccessInFlight = null;
179
+ /**
180
+ * Whether the caller manages any resource. Concurrent callers (the sidebar probe on an auth change
181
+ * and the pages' query) share one request; {@link resetManageAccess} drops it when the user changes.
182
+ */
183
+ function getManageAccess() {
184
+ manageAccessInFlight ??= request("/manage/access").finally(() => {
185
+ manageAccessInFlight = null;
186
+ });
187
+ return manageAccessInFlight;
188
+ }
189
+ /** Forget a probe still in flight, so a new user never receives the previous user's answer. */
190
+ function resetManageAccess() {
191
+ manageAccessInFlight = null;
192
+ }
193
+ var getReservation = (id) => request(`/${id}`);
194
+ var createReservation = (input) => request("", {
195
+ method: "POST",
196
+ body: input
197
+ });
198
+ var reservationAction = (id, action, reason) => request(`/${id}/${action}`, {
199
+ method: "POST",
200
+ body: action === "cancel" || action === "approve" || action === "reject" ? { reason: reason || void 0 } : void 0
201
+ });
202
+ var getPendingDecision = (resourceId, signal) => request(`/resources/${resourceId}/pending-decision`, { signal });
203
+ var getResourceSettings = (resourceId) => request(`/resources/${resourceId}/settings`);
204
+ var getFutureBookingsCount = (resourceId) => request(`/resources/${resourceId}/settings/future-bookings-count`);
205
+ var updateResourceSettings = (resourceId, values) => request(`/resources/${resourceId}/settings`, {
206
+ method: "PUT",
207
+ body: values
208
+ });
209
+ var getGlobalSettings = () => request("/settings/global");
210
+ var updateGlobalSettings = (timezone) => request("/settings/global", {
211
+ method: "PUT",
212
+ body: { timezone }
213
+ });
214
+ var listFeeds = () => request("/ical/feeds");
215
+ var createFeed = (input) => request("/ical/feeds", {
216
+ method: "POST",
217
+ body: input
218
+ });
219
+ var updateFeed = (id, input) => request(`/ical/feeds/${id}`, {
220
+ method: "PATCH",
221
+ body: input
222
+ });
223
+ var regenerateFeed = (id) => request(`/ical/feeds/${id}/regenerate`, { method: "POST" });
224
+ var revokeFeed = (id) => request(`/ical/feeds/${id}`, { method: "DELETE" });
225
+ async function searchHostResources(search) {
226
+ return (await call(hostApi$1, "/api/resources", { query: {
227
+ limit: 50,
228
+ page: 1,
229
+ search
230
+ } })).data;
231
+ }
232
+ var listHostGroups = () => call(hostApi$1, "/api/resource-groups", {});
233
+ var de_default = {
234
+ title: "Reservierungen",
235
+ sidebar: {
236
+ "my": "Meine Reservierungen",
237
+ "manage": "Reservierungen verwalten"
238
+ },
239
+ slots: {
240
+ "settings": "Reservierungen",
241
+ "admin": "Reservierungen",
242
+ "account": "Kalender-Feeds (iCal)"
243
+ },
244
+ common: {
245
+ "cancel": "Abbrechen",
246
+ "close": "Schließen",
247
+ "back": "Zurück",
248
+ "save": "Speichern",
249
+ "edit": "Bearbeiten",
250
+ "done": "Fertig",
251
+ "retry": "Erneut versuchen",
252
+ "loading": "Wird geladen",
253
+ "timesIn": "Zeiten in {{timezone}}",
254
+ "pagination": "Seiten",
255
+ "previousPage": "Vorherige Seite",
256
+ "nextPage": "Nächste Seite"
257
+ },
258
+ weekdays: {
259
+ "mon": "Montag",
260
+ "tue": "Dienstag",
261
+ "wed": "Mittwoch",
262
+ "thu": "Donnerstag",
263
+ "fri": "Freitag",
264
+ "sat": "Samstag",
265
+ "sun": "Sonntag"
266
+ },
267
+ status: {
268
+ "pending": "Wartet auf Genehmigung",
269
+ "confirmed": "Bestätigt",
270
+ "rejected": "Abgelehnt",
271
+ "cancelled": "Storniert",
272
+ "expired": "Abgelaufen",
273
+ "no_show": "Nicht erschienen",
274
+ "completed": "Abgeschlossen"
275
+ },
276
+ errors: {
277
+ "generic": "Etwas ist schiefgelaufen. Bitte versuche es erneut.",
278
+ "NOT_FOUND": "Diese Reservierung oder Ressource existiert nicht.",
279
+ "RESERVATIONS_DISABLED": "Für diese Ressource sind Reservierungen nicht aktiviert.",
280
+ "NOT_ALLOWED_TO_BOOK": "Du darfst diese Ressource nicht buchen.",
281
+ "IN_THE_PAST": "Die Buchung würde in der Vergangenheit beginnen.",
282
+ "OFF_TIME_STEP": "Start und Dauer müssen zum Buchungsraster passen.",
283
+ "DURATION_TOO_SHORT": "Die Buchung ist kürzer als die Mindestdauer.",
284
+ "DURATION_TOO_LONG": "Die Buchung ist länger als die Höchstdauer.",
285
+ "BEYOND_MAX_ADVANCE": "Das liegt zu weit in der Zukunft, um es zu buchen.",
286
+ "LEAD_TIME_TOO_SHORT": "Für diesen Zeitraum ist es zu spät zum Buchen.",
287
+ "OUTSIDE_BOOKABLE_HOURS": "Der Zeitraum liegt außerhalb der buchbaren Zeiten.",
288
+ "USER_BOOKING_LIMIT": "Du hast die maximale Anzahl aktiver Buchungen für diese Ressource erreicht.",
289
+ "OVERLAP": "Der Zeitraum überschneidet sich mit einer anderen Buchung. Bitte wähle eine andere Zeit.",
290
+ "MAINTENANCE": "Die Ressource ist in dieser Zeit in Wartung.",
291
+ "NOT_PENDING": "Diese Buchung wartet nicht mehr auf Genehmigung.",
292
+ "NOT_ACTIVE": "Diese Buchung ist nicht aktiv.",
293
+ "NOT_CANCELLABLE": "Diese Buchung kann nicht mehr storniert werden.",
294
+ "ALREADY_STARTED": "Diese Buchung hat bereits begonnen.",
295
+ "ALREADY_FINISHED": "Diese Buchung ist bereits beendet.",
296
+ "FUTURE_BOOKINGS_EXIST": {
297
+ "one": "Es gibt {{count}} kommende Buchung.",
298
+ "many": "Es gibt {{count}} kommende Buchungen."
299
+ },
300
+ "INVALID_RANGE": "Der gewählte Zeitraum ist ungültig.",
301
+ "INVALID_SETTINGS": "Einige Einstellungen sind ungültig.",
302
+ "INVALID_TIMEZONE": "Diese Zeitzone ist ungültig.",
303
+ "RANGE_TOO_LARGE": "Der angefragte Zeitraum ist zu groß.",
304
+ "FORBIDDEN": "Dazu hast du keine Berechtigung.",
305
+ "RESERVATION_NOT_FOUND": "Diese Reservierung existiert nicht.",
306
+ "RESOURCE_NOT_FOUND": "Diese Ressource existiert nicht.",
307
+ "FEED_LIMIT": "Du hast die maximale Anzahl an Kalender-Feeds erreicht. Widerrufe zuerst einen nicht mehr genutzten Feed.",
308
+ "FEED_NOT_FOUND": "Dieser Kalender-Feed existiert nicht oder wurde widerrufen.",
309
+ "INVALID_FEED": "Wähle mindestens eine Quelle für den Kalender-Feed."
310
+ },
311
+ card: {
312
+ "title": "Reservierungen",
313
+ "reserve": "Reservieren",
314
+ "cannotBook": "Buchen ist nicht möglich",
315
+ "view": "Ansicht",
316
+ "managerHint": "Als verwaltende Person siehst du bei jeder Buchung, wer sie hält, und ihre Notizen und Gründe.",
317
+ "next": "Deine nächste Buchung",
318
+ "current": "Aktuelle Buchung",
319
+ "loadFailed": "Reservierungen konnten nicht geladen werden",
320
+ "day": "Tag",
321
+ "week": "Woche",
322
+ "previous": "Früher",
323
+ "nextRange": "Später",
324
+ "dayBarLabel": "Gebuchte Zeiten des Tages",
325
+ "free": "Keine Buchungen",
326
+ "reserved": "Reserviert",
327
+ "reservedPending": "Reserviert (wartet auf Genehmigung)",
328
+ "yours": "Deine Buchung",
329
+ "maintenance": "Wartung",
330
+ "openEnd": "offenes Ende"
331
+ },
332
+ booking: {
333
+ "title": "{{resource}} reservieren",
334
+ "titleGeneric": "Ressource reservieren",
335
+ "date": "Datum",
336
+ "timezoneHint": "Zeiten in {{timezone}}",
337
+ "start": "Beginn",
338
+ "duration": "Dauer",
339
+ "durationHint": "In Schritten von {{step}} Min., von {{min}} bis {{max}}",
340
+ "note": "Notiz (optional)",
341
+ "noSlots": "An diesem Tag gibt es keine freien Startzeiten.",
342
+ "approvalNeeded": "Eine verwaltende Person muss diese Buchung genehmigen, bevor sie gültig wird.",
343
+ "instantNote": "Deine Buchung wird sofort bestätigt.",
344
+ "submit": "Reservieren",
345
+ "requestSubmit": "Reservierung anfragen",
346
+ "failedTitle": "Reservierung fehlgeschlagen",
347
+ "bookedTitle": "Reservierung bestätigt",
348
+ "bookedBody": "Deine Buchung für {{range}} ist bestätigt.",
349
+ "requestedTitle": "Reservierung angefragt",
350
+ "requestedBody": "Deine Anfrage für {{range}} wartet auf Genehmigung."
351
+ },
352
+ checkIn: {
353
+ "required": "Einchecken durch Starten der Ressource: ab {{early}} Min. vor Beginn bis {{grace}} Min. nach Beginn. Ohne Check-in wird die Buchung freigegeben.",
354
+ "requiredFromStart": "Einchecken durch Starten der Ressource: ab Beginn bis {{grace}} Min. nach Beginn. Ohne Check-in wird die Buchung freigegeben.",
355
+ "notRequired": "Ein Check-in ist nicht nötig; die Buchung bleibt bis zum Ende bestehen."
356
+ },
357
+ keepFree: {
358
+ "title": "Deine Buchung läuft bis {{until}}. Behalten oder den Rest freigeben?",
359
+ "body": "Du hast die Ressource beendet, bevor deine Buchung abgelaufen ist. Möchtest du den Rest der Buchung behalten oder für andere freigeben?",
360
+ "keep": "Behalten",
361
+ "free": "Rest freigeben"
362
+ },
363
+ actions: {
364
+ "reasonLabel": "Grund (optional)",
365
+ "commentLabel": "Kommentar (optional)",
366
+ "failedTitle": "Aktion fehlgeschlagen",
367
+ "cancel": {
368
+ "label": "Stornieren",
369
+ "title": "Diese Buchung stornieren?",
370
+ "body": "Die Buchung {{range}} für {{resource}} wird storniert und der Zeitraum freigegeben.",
371
+ "confirm": "Buchung stornieren"
372
+ },
373
+ "end-early": {
374
+ "label": "Vorzeitig beenden",
375
+ "title": "Diese Buchung vorzeitig beenden?",
376
+ "body": "Die Buchung für {{resource}} endet jetzt und der Rest (bis {{until}}) wird freigegeben.",
377
+ "confirm": "Buchung beenden"
378
+ },
379
+ "keep": {
380
+ "label": "Behalten",
381
+ "title": "Diese Buchung behalten?",
382
+ "body": "Die Buchung {{range}} für {{resource}} bleibt unverändert bestehen.",
383
+ "confirm": "Buchung behalten"
384
+ },
385
+ "approve": {
386
+ "label": "Genehmigen",
387
+ "title": "Diese Buchung genehmigen?",
388
+ "body": "Die Buchung {{range}} für {{resource}} wird bestätigt.",
389
+ "confirm": "Genehmigen"
390
+ },
391
+ "reject": {
392
+ "label": "Ablehnen",
393
+ "title": "Diese Buchung ablehnen?",
394
+ "body": "Die Buchung {{range}} für {{resource}} wird abgelehnt und der Inhaber benachrichtigt.",
395
+ "confirm": "Ablehnen"
396
+ }
397
+ },
398
+ table: {
399
+ "empty": "Keine Buchungen",
400
+ "loadFailed": "Buchungen konnten nicht geladen werden",
401
+ "reason": "Grund: {{reason}}"
402
+ },
403
+ my: {
404
+ "title": "Meine Reservierungen",
405
+ "subtitle": "Deine kommenden und vergangenen Buchungen",
406
+ "upcoming": "Kommend",
407
+ "past": "Vergangen",
408
+ "manageLink": "Reservierungen verwalten"
409
+ },
410
+ manage: {
411
+ "denied": "Du verwaltest keine Ressource, deshalb gibt es hier nichts anzuzeigen.",
412
+ "title": "Reservierungen verwalten",
413
+ "subtitle": "Anfragen genehmigen und alle Buchungen deiner Ressourcen im Blick behalten",
414
+ "pending": "Wartet auf Genehmigung",
415
+ "pendingHint": "Anfragen genehmigen oder ablehnen; die buchende Person wird benachrichtigt.",
416
+ "all": "Alle Buchungen",
417
+ "filters": {
418
+ "resource": "Ressource",
419
+ "allResources": "Alle Ressourcen",
420
+ "searchResources": "Ressourcen suchen",
421
+ "status": "Status",
422
+ "allStatuses": "Alle Status",
423
+ "from": "Von",
424
+ "to": "Bis"
425
+ }
426
+ },
427
+ detail: {
428
+ "title": "Reservierung",
429
+ "loadFailed": "Die Reservierung konnte nicht geladen werden",
430
+ "holder": "Gebucht von {{name}}",
431
+ "cannotKeep": "Diese Buchung kann nicht mehr behalten werden.",
432
+ "cannotCancel": "Diese Buchung kann nicht mehr storniert werden."
433
+ },
434
+ settings: {
435
+ "loadFailed": "Die Reservierungs-Einstellungen konnten nicht geladen werden",
436
+ "enabled": "Reservierungen für diese Ressource aktivieren",
437
+ "approvalRequired": "Buchungen müssen von einer verwaltenden Person genehmigt werden",
438
+ "checkInEnabled": "Check-in verlangen (Ressource innerhalb der Karenzzeit starten)",
439
+ "failed": "Die Einstellungen konnten nicht gespeichert werden",
440
+ "whoCanBook": {
441
+ "label": "Wer darf buchen",
442
+ "can-start": "Alle, die die Ressource starten dürfen",
443
+ "managers-only": "Nur verwaltende Personen",
444
+ "any-user": "Jeder angemeldete Nutzer"
445
+ },
446
+ "groups": {
447
+ "rules": "Buchungsregeln",
448
+ "limits": "Puffer und Limits",
449
+ "checkIn": "Check-in und Erinnerungen",
450
+ "hours": "Buchbare Zeiten"
451
+ },
452
+ "fields": {
453
+ "timeStepMinutes": "Zeitraster (Minuten)",
454
+ "minDurationMinutes": "Mindestdauer (Minuten)",
455
+ "maxDurationMinutes": "Höchstdauer (Minuten)",
456
+ "maxAdvanceDays": "Höchstens so viele Tage im Voraus buchen",
457
+ "minLeadMinutes": "Späteste Buchung vor Beginn (Minuten)",
458
+ "bufferBeforeMinutes": "Puffer vor einer Buchung (Minuten)",
459
+ "bufferAfterMinutes": "Puffer nach einer Buchung (Minuten)",
460
+ "maxActiveBookingsPerUser": "Aktive Buchungen pro Nutzer",
461
+ "confirmWindowMinutes": "Bestätigung zum Starten so lange vor einer Reservierung (Minuten)",
462
+ "checkInGraceMinutes": "Karenzzeit für den Check-in (Minuten)",
463
+ "earlyCheckInMinutes": "Frühes Einchecken (Minuten)",
464
+ "handoverReminderMinutes": "Übergabe-Erinnerung vor einer Reservierung (Minuten)"
465
+ },
466
+ "hints": {
467
+ "timeStepMinutes": "Beginn und Dauer rasten auf diesem Raster ein; {{min}} bis {{max}}, muss 1440 teilen.",
468
+ "minDurationMinutes": "Kürzeste Buchung, ein Vielfaches des Rasters.",
469
+ "maxDurationMinutes": "Längste Buchung, ein Vielfaches des Rasters.",
470
+ "maxAdvanceDays": "{{min}} bis {{max}} Tage.",
471
+ "minLeadMinutes": "0 erlaubt Buchungen bis zum Beginn.",
472
+ "bufferBeforeMinutes": "Wird vor jeder Buchung freigehalten.",
473
+ "bufferAfterMinutes": "Wird nach jeder Buchung freigehalten.",
474
+ "maxActiveBookingsPerUser": "0 bedeutet unbegrenzt.",
475
+ "confirmWindowMinutes": "0 fragt nie. Höchstens {{max}}.",
476
+ "checkInGraceMinutes": "{{min}} bis {{max}} Minuten nach dem Beginn.",
477
+ "earlyCheckInMinutes": "Wie früh der Inhaber starten darf. {{min}} bis {{max}}.",
478
+ "handoverReminderMinutes": "Benachrichtigt den aktuellen Nutzer. 0 schaltet es aus."
479
+ },
480
+ "validation": {
481
+ "range": "Gib eine ganze Zahl von {{min}} bis {{max}} ein.",
482
+ "stepDividesDay": "Das Raster muss 1440 Minuten ohne Rest teilen.",
483
+ "multipleOfStep": "Muss ein Vielfaches von {{step}} Minuten sein.",
484
+ "maxBelowMin": "Darf nicht kürzer als die Mindestdauer sein.",
485
+ "tooManyRanges": "Höchstens 8 Zeiträume pro Tag.",
486
+ "timeFormat": "Format HH:mm, zum Beispiel 09:00. Das Ende darf 24:00 sein.",
487
+ "endAfterStart": "Das Ende muss nach dem Beginn liegen.",
488
+ "overlap": "Zeiträume dürfen sich nicht überschneiden."
489
+ },
490
+ "hours": {
491
+ "description": "Buchungen müssen vollständig in diesen Zeiten liegen. Ein Tag ohne Zeitraum ist geschlossen, sobald ein anderer Tag Zeiträume hat; ganz ohne Zeiträume ist die Ressource rund um die Uhr buchbar.",
492
+ "allDay": "Kein Zeitraum festgelegt",
493
+ "addRange": "Zeitraum hinzufügen",
494
+ "addRangeTo": "Zeitraum für {{day}} hinzufügen",
495
+ "removeRange": "Zeitraum {{index}} am {{day}} entfernen",
496
+ "from": "Von",
497
+ "to": "Bis",
498
+ "fromLabel": "Von ({{day}}, Zeitraum {{index}})",
499
+ "toLabel": "Bis ({{day}}, Zeitraum {{index}})"
500
+ },
501
+ "disableWarning": {
502
+ "title": "Reservierungen deaktivieren?",
503
+ "body": {
504
+ "one": "Es gibt {{count}} kommende Buchung. Beim Deaktivieren wird sie storniert und der Inhaber benachrichtigt.",
505
+ "many": "Es gibt {{count}} kommende Buchungen. Beim Deaktivieren werden sie storniert und die Inhaber benachrichtigt."
506
+ },
507
+ "confirm": {
508
+ "one": "Deaktivieren und {{count}} Buchung stornieren",
509
+ "many": "Deaktivieren und {{count}} Buchungen stornieren"
510
+ }
511
+ },
512
+ "saved": {
513
+ "title": "Einstellungen gespeichert",
514
+ "body": "Die Reservierungseinstellungen wurden gespeichert. Sie gelten für neue Buchungen.",
515
+ "bodyCancelled": {
516
+ "one": "Die Einstellungen wurden gespeichert und {{count}} kommende Buchung storniert.",
517
+ "many": "Die Einstellungen wurden gespeichert und {{count}} kommende Buchungen storniert."
518
+ }
519
+ }
520
+ },
521
+ admin: {
522
+ "description": "Die Zeitzone für buchbare Zeiten, das Buchungsraster, Benachrichtigungen und Kalender-Feeds.",
523
+ "loadFailed": "Die Zeitzonen-Einstellung konnte nicht geladen werden",
524
+ "current": "Zeitzone",
525
+ "default": "Server-Standard: {{timezone}}",
526
+ "search": "Zeitzonen suchen",
527
+ "searchPlaceholder": "z. B. Europe/Berlin",
528
+ "matches": "{{count}} Treffer",
529
+ "matchesTruncated": "{{total}} Treffer, die ersten {{shown}} werden angezeigt. Zum Eingrenzen tippen.",
530
+ "list": "Zeitzonen",
531
+ "saved": "Zeitzone gespeichert",
532
+ "savedBody": "Reservierungen verwenden jetzt {{timezone}}.",
533
+ "failed": "Die Zeitzone konnte nicht gespeichert werden"
534
+ },
535
+ feeds: {
536
+ "title": "Kalender-Feeds",
537
+ "description": "Abonniere Reservierungen in deiner Kalender-App. Jeder Feed hat einen eigenen geheimen Link; wer den Link kennt, kann den Feed lesen.",
538
+ "create": "Neuer Feed",
539
+ "empty": "Noch keine Feeds",
540
+ "revoked": "Widerrufen",
541
+ "revokedAt": "Widerrufen am {{date}}",
542
+ "lastUsed": "Zuletzt genutzt {{date}}",
543
+ "neverUsed": "Nie genutzt",
544
+ "failed": "Aktion fehlgeschlagen",
545
+ "loadFailed": "Kalender-Feeds konnten nicht geladen werden",
546
+ "selection": {
547
+ "ownOnly": "Nur meine eigenen Buchungen",
548
+ "introduced": "Ressourcen, in die ich eingewiesen bin",
549
+ "maintained": "Ressourcen, die ich betreue",
550
+ "groups": {
551
+ "one": "{{count}} Gruppe",
552
+ "many": "{{count}} Gruppen"
553
+ },
554
+ "resources": {
555
+ "one": "{{count}} Ressource",
556
+ "many": "{{count}} Ressourcen"
557
+ }
558
+ },
559
+ "form": {
560
+ "createTitle": "Neuer Kalender-Feed",
561
+ "editTitle": "Kalender-Feed bearbeiten",
562
+ "name": "Name",
563
+ "ownOnly": "Nur meine eigenen Buchungen",
564
+ "introduced": "Alle Ressourcen, in die ich eingewiesen bin",
565
+ "maintained": "Alle Ressourcen, die ich betreue",
566
+ "groups": "Ressourcengruppen",
567
+ "noGroups": "Keine Gruppen verfügbar",
568
+ "resources": "Bestimmte Ressourcen",
569
+ "searchResources": "Ressourcen suchen",
570
+ "selectedCount": "{{count}} ausgewählt",
571
+ "needSelection": "Wähle mindestens eine Quelle für diesen Feed.",
572
+ "create": "Feed erstellen"
573
+ },
574
+ "secret": {
575
+ "title": "Feed „{{name}}“ ist bereit",
576
+ "body": "Kopiere diesen Link jetzt. Aus Sicherheitsgründen wird er nur einmal angezeigt; falls du ihn verlierst, erzeuge den Feed neu.",
577
+ "url": "Feed-Link",
578
+ "copy": "Link kopieren",
579
+ "copied": "Kopiert"
580
+ },
581
+ "regenerate": {
582
+ "label": "Neu erzeugen",
583
+ "title": "„{{name}}“ neu erzeugen?",
584
+ "body": "Es wird ein neuer Link erstellt und der alte funktioniert sofort nicht mehr. Kalender mit dem alten Link verlieren den Zugriff.",
585
+ "confirm": "Neu erzeugen"
586
+ },
587
+ "revoke": {
588
+ "label": "Widerrufen",
589
+ "title": "„{{name}}“ widerrufen?",
590
+ "body": "Der Link funktioniert dauerhaft nicht mehr. Das lässt sich nicht rückgängig machen.",
591
+ "confirm": "Widerrufen"
592
+ }
593
+ }
594
+ };
595
+ var en_default = {
596
+ title: "Reservations",
597
+ sidebar: {
598
+ "my": "My reservations",
599
+ "manage": "Manage reservations"
600
+ },
601
+ slots: {
602
+ "settings": "Reservations",
603
+ "admin": "Reservations",
604
+ "account": "Calendar feeds (iCal)"
605
+ },
606
+ common: {
607
+ "cancel": "Cancel",
608
+ "close": "Close",
609
+ "back": "Back",
610
+ "save": "Save",
611
+ "edit": "Edit",
612
+ "done": "Done",
613
+ "retry": "Retry",
614
+ "loading": "Loading",
615
+ "timesIn": "Times in {{timezone}}",
616
+ "pagination": "Pages",
617
+ "previousPage": "Previous page",
618
+ "nextPage": "Next page"
619
+ },
620
+ weekdays: {
621
+ "mon": "Monday",
622
+ "tue": "Tuesday",
623
+ "wed": "Wednesday",
624
+ "thu": "Thursday",
625
+ "fri": "Friday",
626
+ "sat": "Saturday",
627
+ "sun": "Sunday"
628
+ },
629
+ status: {
630
+ "pending": "Pending approval",
631
+ "confirmed": "Confirmed",
632
+ "rejected": "Rejected",
633
+ "cancelled": "Cancelled",
634
+ "expired": "Expired",
635
+ "no_show": "No show",
636
+ "completed": "Completed"
637
+ },
638
+ errors: {
639
+ "generic": "Something went wrong. Please try again.",
640
+ "NOT_FOUND": "This reservation or resource does not exist.",
641
+ "RESERVATIONS_DISABLED": "Reservations are not enabled for this resource.",
642
+ "NOT_ALLOWED_TO_BOOK": "You are not allowed to book this resource.",
643
+ "IN_THE_PAST": "The booking would start in the past.",
644
+ "OFF_TIME_STEP": "Start and duration must fit the booking time step.",
645
+ "DURATION_TOO_SHORT": "The booking is shorter than the minimum duration.",
646
+ "DURATION_TOO_LONG": "The booking is longer than the maximum duration.",
647
+ "BEYOND_MAX_ADVANCE": "This is too far in the future to book.",
648
+ "LEAD_TIME_TOO_SHORT": "It is too late to book this slot.",
649
+ "OUTSIDE_BOOKABLE_HOURS": "The slot is outside the bookable hours.",
650
+ "USER_BOOKING_LIMIT": "You have reached the maximum number of active bookings for this resource.",
651
+ "OVERLAP": "The slot overlaps another booking. Please choose a different time.",
652
+ "MAINTENANCE": "The resource is in maintenance during this time.",
653
+ "NOT_PENDING": "This booking is no longer waiting for approval.",
654
+ "NOT_ACTIVE": "This booking is not active.",
655
+ "NOT_CANCELLABLE": "This booking can no longer be cancelled.",
656
+ "ALREADY_STARTED": "This booking has already started.",
657
+ "ALREADY_FINISHED": "This booking has already finished.",
658
+ "FUTURE_BOOKINGS_EXIST": {
659
+ "one": "There is {{count}} upcoming booking.",
660
+ "many": "There are {{count}} upcoming bookings."
661
+ },
662
+ "INVALID_RANGE": "The selected time range is not valid.",
663
+ "INVALID_SETTINGS": "Some settings are not valid.",
664
+ "INVALID_TIMEZONE": "This timezone is not valid.",
665
+ "RANGE_TOO_LARGE": "The requested time range is too large.",
666
+ "FORBIDDEN": "You are not allowed to do this.",
667
+ "RESERVATION_NOT_FOUND": "This reservation does not exist.",
668
+ "RESOURCE_NOT_FOUND": "This resource does not exist.",
669
+ "FEED_LIMIT": "You have reached the maximum number of calendar feeds. Revoke one you no longer use first.",
670
+ "FEED_NOT_FOUND": "This calendar feed does not exist or was revoked.",
671
+ "INVALID_FEED": "Choose at least one source for the calendar feed."
672
+ },
673
+ card: {
674
+ "title": "Reservations",
675
+ "reserve": "Reserve",
676
+ "cannotBook": "Booking is not available",
677
+ "view": "View",
678
+ "managerHint": "As a manager you see the holder, notes and reasons of every booking.",
679
+ "next": "Your next booking",
680
+ "current": "Current booking",
681
+ "loadFailed": "Reservations could not be loaded",
682
+ "day": "Day",
683
+ "week": "Week",
684
+ "previous": "Earlier",
685
+ "nextRange": "Later",
686
+ "dayBarLabel": "Booked times of the day",
687
+ "free": "No bookings",
688
+ "reserved": "Reserved",
689
+ "reservedPending": "Reserved (pending approval)",
690
+ "yours": "Your booking",
691
+ "maintenance": "Maintenance",
692
+ "openEnd": "open end"
693
+ },
694
+ booking: {
695
+ "title": "Reserve {{resource}}",
696
+ "titleGeneric": "Reserve resource",
697
+ "date": "Date",
698
+ "timezoneHint": "Times are in {{timezone}}",
699
+ "start": "Start",
700
+ "duration": "Duration",
701
+ "durationHint": "In steps of {{step}} min, from {{min}} to {{max}}",
702
+ "note": "Note (optional)",
703
+ "noSlots": "No free start times on this day.",
704
+ "approvalNeeded": "A manager has to approve this booking before it becomes valid.",
705
+ "instantNote": "Your booking is confirmed immediately.",
706
+ "submit": "Reserve",
707
+ "requestSubmit": "Request reservation",
708
+ "failedTitle": "Reservation failed",
709
+ "bookedTitle": "Reservation confirmed",
710
+ "bookedBody": "Your booking for {{range}} is confirmed.",
711
+ "requestedTitle": "Reservation requested",
712
+ "requestedBody": "Your request for {{range}} is waiting for approval."
713
+ },
714
+ checkIn: {
715
+ "required": "Check in by starting the resource: from {{early}} min before the start until {{grace}} min after it. Without check-in the booking is released.",
716
+ "requiredFromStart": "Check in by starting the resource: from the start until {{grace}} min after it. Without check-in the booking is released.",
717
+ "notRequired": "No check-in is required; the booking stays until it ends."
718
+ },
719
+ keepFree: {
720
+ "title": "Your booking runs until {{until}}. Keep it or free the rest?",
721
+ "body": "You stopped using the resource before your booking ended. Keep the rest of the booking, or release it for others?",
722
+ "keep": "Keep",
723
+ "free": "Free rest"
724
+ },
725
+ actions: {
726
+ "reasonLabel": "Reason (optional)",
727
+ "commentLabel": "Comment (optional)",
728
+ "failedTitle": "Action failed",
729
+ "cancel": {
730
+ "label": "Cancel",
731
+ "title": "Cancel this booking?",
732
+ "body": "The booking {{range}} for {{resource}} will be cancelled and the slot freed.",
733
+ "confirm": "Cancel booking"
734
+ },
735
+ "end-early": {
736
+ "label": "End early",
737
+ "title": "End this booking early?",
738
+ "body": "The booking for {{resource}} ends now and the rest of the slot (until {{until}}) is freed.",
739
+ "confirm": "End booking"
740
+ },
741
+ "keep": {
742
+ "label": "Keep",
743
+ "title": "Keep this booking?",
744
+ "body": "The booking {{range}} for {{resource}} stays as it is.",
745
+ "confirm": "Keep booking"
746
+ },
747
+ "approve": {
748
+ "label": "Approve",
749
+ "title": "Approve this booking?",
750
+ "body": "The booking {{range}} for {{resource}} will be confirmed.",
751
+ "confirm": "Approve"
752
+ },
753
+ "reject": {
754
+ "label": "Reject",
755
+ "title": "Reject this booking?",
756
+ "body": "The booking {{range}} for {{resource}} will be rejected and the holder notified.",
757
+ "confirm": "Reject"
758
+ }
759
+ },
760
+ table: {
761
+ "empty": "No bookings",
762
+ "loadFailed": "Bookings could not be loaded",
763
+ "reason": "Reason: {{reason}}"
764
+ },
765
+ my: {
766
+ "title": "My reservations",
767
+ "subtitle": "Your upcoming and past bookings",
768
+ "upcoming": "Upcoming",
769
+ "past": "Past",
770
+ "manageLink": "Manage reservations"
771
+ },
772
+ manage: {
773
+ "denied": "You do not manage any resource, so there is nothing to show here.",
774
+ "title": "Manage reservations",
775
+ "subtitle": "Approve requests and oversee all bookings of your resources",
776
+ "pending": "Waiting for approval",
777
+ "pendingHint": "Approve or reject requests; the holder is notified.",
778
+ "all": "All bookings",
779
+ "filters": {
780
+ "resource": "Resource",
781
+ "allResources": "All resources",
782
+ "searchResources": "Search resources",
783
+ "status": "Status",
784
+ "allStatuses": "All statuses",
785
+ "from": "From",
786
+ "to": "To"
787
+ }
788
+ },
789
+ detail: {
790
+ "title": "Reservation",
791
+ "loadFailed": "The reservation could not be loaded",
792
+ "holder": "Booked by {{name}}",
793
+ "cannotKeep": "This booking can no longer be kept.",
794
+ "cannotCancel": "This booking can no longer be cancelled."
795
+ },
796
+ settings: {
797
+ "loadFailed": "The reservation settings could not be loaded",
798
+ "enabled": "Enable reservations for this resource",
799
+ "approvalRequired": "Bookings need approval by a manager",
800
+ "checkInEnabled": "Require check-in (start the resource within the grace period)",
801
+ "failed": "Settings could not be saved",
802
+ "whoCanBook": {
803
+ "label": "Who can book",
804
+ "can-start": "Everyone who can start the resource",
805
+ "managers-only": "Managers only",
806
+ "any-user": "Any signed-in user"
807
+ },
808
+ "groups": {
809
+ "rules": "Booking rules",
810
+ "limits": "Buffers and limits",
811
+ "checkIn": "Check-in and reminders",
812
+ "hours": "Bookable hours"
813
+ },
814
+ "fields": {
815
+ "timeStepMinutes": "Time step (minutes)",
816
+ "minDurationMinutes": "Minimum duration (minutes)",
817
+ "maxDurationMinutes": "Maximum duration (minutes)",
818
+ "maxAdvanceDays": "Book at most this many days ahead",
819
+ "minLeadMinutes": "Latest booking before start (minutes)",
820
+ "bufferBeforeMinutes": "Buffer before a booking (minutes)",
821
+ "bufferAfterMinutes": "Buffer after a booking (minutes)",
822
+ "maxActiveBookingsPerUser": "Active bookings per user",
823
+ "confirmWindowMinutes": "Ask to confirm starting this long before a reservation (minutes)",
824
+ "checkInGraceMinutes": "Check-in grace period (minutes)",
825
+ "earlyCheckInMinutes": "Early check-in window (minutes)",
826
+ "handoverReminderMinutes": "Handover reminder before a reservation (minutes)"
827
+ },
828
+ "hints": {
829
+ "timeStepMinutes": "Starts and durations snap to this step; {{min}} to {{max}}, must divide 1440.",
830
+ "minDurationMinutes": "Shortest booking, a multiple of the step.",
831
+ "maxDurationMinutes": "Longest booking, a multiple of the step.",
832
+ "maxAdvanceDays": "{{min}} to {{max}} days.",
833
+ "minLeadMinutes": "0 allows booking right up to the start.",
834
+ "bufferBeforeMinutes": "Kept free before each booking.",
835
+ "bufferAfterMinutes": "Kept free after each booking.",
836
+ "maxActiveBookingsPerUser": "0 means unlimited.",
837
+ "confirmWindowMinutes": "0 never asks. Maximum {{max}}.",
838
+ "checkInGraceMinutes": "{{min}} to {{max}} minutes after the start.",
839
+ "earlyCheckInMinutes": "How early the holder may start. {{min}} to {{max}}.",
840
+ "handoverReminderMinutes": "Notifies the current user. 0 turns it off."
841
+ },
842
+ "validation": {
843
+ "range": "Enter a whole number from {{min}} to {{max}}.",
844
+ "stepDividesDay": "The step must divide 1440 minutes evenly.",
845
+ "multipleOfStep": "Must be a multiple of {{step}} minutes.",
846
+ "maxBelowMin": "Must not be shorter than the minimum duration.",
847
+ "tooManyRanges": "At most 8 ranges per day.",
848
+ "timeFormat": "Use HH:mm, for example 09:00. The end may be 24:00.",
849
+ "endAfterStart": "The end must be after the start.",
850
+ "overlap": "Ranges must not overlap."
851
+ },
852
+ "hours": {
853
+ "description": "Bookings must lie fully inside these hours. A day without ranges is closed once any other day has ranges; with no ranges at all the resource is bookable around the clock.",
854
+ "allDay": "No range set",
855
+ "addRange": "Add range",
856
+ "addRangeTo": "Add range on {{day}}",
857
+ "removeRange": "Remove range {{index}} on {{day}}",
858
+ "from": "From",
859
+ "to": "Until",
860
+ "fromLabel": "From ({{day}}, range {{index}})",
861
+ "toLabel": "Until ({{day}}, range {{index}})"
862
+ },
863
+ "disableWarning": {
864
+ "title": "Disable reservations?",
865
+ "body": {
866
+ "one": "{{count}} upcoming booking exists. Disabling reservations cancels it and notifies the holder.",
867
+ "many": "{{count}} upcoming bookings exist. Disabling reservations cancels them and notifies the holders."
868
+ },
869
+ "confirm": {
870
+ "one": "Disable and cancel {{count}} booking",
871
+ "many": "Disable and cancel {{count}} bookings"
872
+ }
873
+ },
874
+ "saved": {
875
+ "title": "Settings saved",
876
+ "body": "The reservation settings were saved. They apply to new bookings.",
877
+ "bodyCancelled": {
878
+ "one": "The settings were saved and {{count}} upcoming booking was cancelled.",
879
+ "many": "The settings were saved and {{count}} upcoming bookings were cancelled."
880
+ }
881
+ }
882
+ },
883
+ admin: {
884
+ "description": "The timezone used for bookable hours, the booking time grid, notifications and calendar feeds.",
885
+ "loadFailed": "The timezone setting could not be loaded",
886
+ "current": "Timezone",
887
+ "default": "server default: {{timezone}}",
888
+ "search": "Search timezones",
889
+ "searchPlaceholder": "e.g. Europe/Berlin",
890
+ "matches": "{{count}} matching",
891
+ "matchesTruncated": "{{total}} matching, showing the first {{shown}}. Type to narrow the list.",
892
+ "list": "Timezones",
893
+ "saved": "Timezone saved",
894
+ "savedBody": "Reservations now use {{timezone}}.",
895
+ "failed": "Timezone could not be saved"
896
+ },
897
+ feeds: {
898
+ "title": "Calendar feeds",
899
+ "description": "Subscribe to reservations in your calendar app. Each feed has its own secret link; anyone with the link can read the feed.",
900
+ "create": "New feed",
901
+ "empty": "No feeds yet",
902
+ "revoked": "Revoked",
903
+ "revokedAt": "Revoked on {{date}}",
904
+ "lastUsed": "Last used {{date}}",
905
+ "neverUsed": "Never used",
906
+ "failed": "Action failed",
907
+ "loadFailed": "Calendar feeds could not be loaded",
908
+ "selection": {
909
+ "ownOnly": "Only my own bookings",
910
+ "introduced": "Resources I am introduced to",
911
+ "maintained": "Resources I maintain",
912
+ "groups": {
913
+ "one": "{{count}} group",
914
+ "many": "{{count}} groups"
915
+ },
916
+ "resources": {
917
+ "one": "{{count}} resource",
918
+ "many": "{{count}} resources"
919
+ }
920
+ },
921
+ "form": {
922
+ "createTitle": "New calendar feed",
923
+ "editTitle": "Edit calendar feed",
924
+ "name": "Name",
925
+ "ownOnly": "Only my own bookings",
926
+ "introduced": "All resources I am introduced to",
927
+ "maintained": "All resources I maintain",
928
+ "groups": "Resource groups",
929
+ "noGroups": "No groups available",
930
+ "resources": "Specific resources",
931
+ "searchResources": "Search resources",
932
+ "selectedCount": "{{count}} selected",
933
+ "needSelection": "Choose at least one source for this feed.",
934
+ "create": "Create feed"
935
+ },
936
+ "secret": {
937
+ "title": "Feed \"{{name}}\" is ready",
938
+ "body": "Copy this link now. For security it is shown only once; if you lose it, regenerate the feed.",
939
+ "url": "Feed link",
940
+ "copy": "Copy link",
941
+ "copied": "Copied"
942
+ },
943
+ "regenerate": {
944
+ "label": "Regenerate",
945
+ "title": "Regenerate \"{{name}}\"?",
946
+ "body": "A new link is created and the old one stops working immediately. Calendars using the old link lose access.",
947
+ "confirm": "Regenerate"
948
+ },
949
+ "revoke": {
950
+ "label": "Revoke",
951
+ "title": "Revoke \"{{name}}\"?",
952
+ "body": "The link stops working for good. This cannot be undone.",
953
+ "confirm": "Revoke"
954
+ }
955
+ }
956
+ };
957
+ //#endregion
958
+ //#region frontend/src/i18n.ts
959
+ var { useTranslations } = await importShared("@attraccess/plugins-frontend-ui");
960
+ var useReservationsTranslations = () => useTranslations({
961
+ en: en_default,
962
+ de: de_default
963
+ }, { escapeValues: false });
964
+ //#endregion
965
+ //#region frontend/src/lib/errors.ts
966
+ var KNOWN_CODES = /* @__PURE__ */ new Set([
967
+ "RESERVATIONS_DISABLED",
968
+ "NOT_ALLOWED_TO_BOOK",
969
+ "IN_THE_PAST",
970
+ "OFF_TIME_STEP",
971
+ "DURATION_TOO_SHORT",
972
+ "DURATION_TOO_LONG",
973
+ "BEYOND_MAX_ADVANCE",
974
+ "LEAD_TIME_TOO_SHORT",
975
+ "OUTSIDE_BOOKABLE_HOURS",
976
+ "USER_BOOKING_LIMIT",
977
+ "OVERLAP",
978
+ "MAINTENANCE",
979
+ "NOT_PENDING",
980
+ "NOT_ACTIVE",
981
+ "NOT_CANCELLABLE",
982
+ "ALREADY_STARTED",
983
+ "ALREADY_FINISHED",
984
+ "FUTURE_BOOKINGS_EXIST",
985
+ "INVALID_RANGE",
986
+ "INVALID_SETTINGS",
987
+ "INVALID_TIMEZONE",
988
+ "RANGE_TOO_LARGE",
989
+ "FORBIDDEN",
990
+ "RESERVATION_NOT_FOUND",
991
+ "RESOURCE_NOT_FOUND",
992
+ "FEED_LIMIT",
993
+ "FEED_NOT_FOUND",
994
+ "INVALID_FEED"
995
+ ]);
996
+ /** Localised text for a known error code (e.g. the reason a booking is not possible), else the raw text. */
997
+ function describeCode(code, t) {
998
+ return KNOWN_CODES.has(code) ? t(`errors.${code}`, { count: 0 }) : code;
999
+ }
1000
+ /** Localised text for an API failure: a typed code wins, then the HTTP status, then the raw message. */
1001
+ function describeError(error, t) {
1002
+ if (error instanceof ReservationsApiError) {
1003
+ if (error.code && KNOWN_CODES.has(error.code)) return t(`errors.${error.code}`, { count: error.count ?? 0 });
1004
+ if (error.status === 403) return t("errors.FORBIDDEN");
1005
+ if (error.status === 404) return t("errors.NOT_FOUND");
1006
+ return error.message || t("errors.generic");
1007
+ }
1008
+ return error instanceof Error && error.message ? error.message : t("errors.generic");
1009
+ }
1010
+ //#endregion
1011
+ //#region frontend/src/lib/time.ts
1012
+ var { detectLanguage } = await importShared("@attraccess/plugins-frontend-ui");
1013
+ var DAY_MS$2 = 864e5;
1014
+ var formatters = /* @__PURE__ */ new Map();
1015
+ function formatterFor(timeZone) {
1016
+ let formatter = formatters.get(timeZone);
1017
+ if (!formatter) {
1018
+ formatter = new Intl.DateTimeFormat("en-US", {
1019
+ timeZone,
1020
+ hourCycle: "h23",
1021
+ year: "numeric",
1022
+ month: "numeric",
1023
+ day: "numeric",
1024
+ hour: "numeric",
1025
+ minute: "numeric",
1026
+ second: "numeric"
1027
+ });
1028
+ formatters.set(timeZone, formatter);
1029
+ }
1030
+ return formatter;
1031
+ }
1032
+ function isValidTimeZone(timeZone) {
1033
+ try {
1034
+ new Intl.DateTimeFormat("en-US", { timeZone });
1035
+ return true;
1036
+ } catch {
1037
+ return false;
1038
+ }
1039
+ }
1040
+ function getWallClock(date, timeZone) {
1041
+ const parts = formatterFor(timeZone).formatToParts(date);
1042
+ const read = (type) => Number(parts.find((part) => part.type === type)?.value ?? 0);
1043
+ return {
1044
+ year: read("year"),
1045
+ month: read("month"),
1046
+ day: read("day"),
1047
+ hour: read("hour") % 24,
1048
+ minute: read("minute"),
1049
+ second: read("second")
1050
+ };
1051
+ }
1052
+ function wallOf(date, timeZone) {
1053
+ const wall = getWallClock(date, timeZone);
1054
+ return Date.UTC(wall.year, wall.month - 1, wall.day, wall.hour, wall.minute, wall.second);
1055
+ }
1056
+ function offsetMs(date, timeZone) {
1057
+ return wallOf(date, timeZone) - Math.floor(date.getTime() / 1e3) * 1e3;
1058
+ }
1059
+ /** Local wall clock -> UTC instant. Ambiguous times take the first occurrence, gaps shift forward. */
1060
+ function wallClockToDate(local, timeZone) {
1061
+ const target = Date.UTC(local.year, local.month - 1, local.day, local.hour ?? 0, local.minute ?? 0, local.second ?? 0);
1062
+ const before = offsetMs(/* @__PURE__ */ new Date(target - DAY_MS$2), timeZone);
1063
+ const after = offsetMs(new Date(target + DAY_MS$2), timeZone);
1064
+ const first = target - before;
1065
+ if (before === after || wallOf(new Date(first), timeZone) === target) return new Date(first);
1066
+ const second = target - after;
1067
+ if (wallOf(new Date(second), timeZone) === target) return new Date(second);
1068
+ return new Date(first);
1069
+ }
1070
+ function localDateOf(date, timeZone) {
1071
+ const { year, month, day } = getWallClock(date, timeZone);
1072
+ return {
1073
+ year,
1074
+ month,
1075
+ day
1076
+ };
1077
+ }
1078
+ function addLocalDays(date, days) {
1079
+ const moved = new Date(Date.UTC(date.year, date.month - 1, date.day + days));
1080
+ return {
1081
+ year: moved.getUTCFullYear(),
1082
+ month: moved.getUTCMonth() + 1,
1083
+ day: moved.getUTCDate()
1084
+ };
1085
+ }
1086
+ function weekdayOf(date) {
1087
+ return new Date(Date.UTC(date.year, date.month - 1, date.day)).getUTCDay();
1088
+ }
1089
+ function localMinutesOfDay(date, timeZone) {
1090
+ const wall = getWallClock(date, timeZone);
1091
+ return wall.hour * 60 + wall.minute;
1092
+ }
1093
+ var pad = (value) => String(value).padStart(2, "0");
1094
+ /** `YYYY-MM-DD`, the value format of `<input type="date">`. */
1095
+ function toDateKey(date) {
1096
+ return `${date.year}-${pad(date.month)}-${pad(date.day)}`;
1097
+ }
1098
+ function fromDateKey(key) {
1099
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(key);
1100
+ if (!match) return null;
1101
+ return {
1102
+ year: Number(match[1]),
1103
+ month: Number(match[2]),
1104
+ day: Number(match[3])
1105
+ };
1106
+ }
1107
+ function startOfLocalDay(date, timeZone) {
1108
+ return wallClockToDate(date, timeZone);
1109
+ }
1110
+ var WEEKDAYS = [
1111
+ "sun",
1112
+ "mon",
1113
+ "tue",
1114
+ "wed",
1115
+ "thu",
1116
+ "fri",
1117
+ "sat"
1118
+ ];
1119
+ var parseHm = (value) => {
1120
+ const [hours, minutes] = value.split(":").map(Number);
1121
+ return hours * 60 + minutes;
1122
+ };
1123
+ function hasRestrictions(hours) {
1124
+ return WEEKDAYS.some((day) => (hours[day]?.length ?? 0) > 0);
1125
+ }
1126
+ /**
1127
+ * Bookable UTC intervals around [from, to]: one per configured range and day, like the backend.
1128
+ * Ranges never merge, not even when they touch on the same day (08:00-12:00 and 12:00-16:00 stay
1129
+ * two ranges); the one exception is a range ending at 24:00, which joins the next local day's
1130
+ * range starting at 00:00.
1131
+ */
1132
+ function bookableIntervals(hours, timeZone, from, to) {
1133
+ const first = addLocalDays(localDateOf(from, timeZone), -1);
1134
+ const last = addLocalDays(localDateOf(to, timeZone), 1);
1135
+ const key = (d) => d.year * 1e4 + d.month * 100 + d.day;
1136
+ const at = (day, minutes) => wallClockToDate({
1137
+ ...day,
1138
+ hour: Math.floor(minutes / 60),
1139
+ minute: minutes % 60
1140
+ }, timeZone).getTime();
1141
+ const raw = [];
1142
+ for (let day = first; key(day) <= key(last); day = addLocalDays(day, 1)) for (const range of hours[WEEKDAYS[weekdayOf(day)]] ?? []) {
1143
+ const toMidnight = range.end === "24:00";
1144
+ raw.push({
1145
+ start: at(day, parseHm(range.start)),
1146
+ end: toMidnight ? wallClockToDate(addLocalDays(day, 1), timeZone).getTime() : at(day, parseHm(range.end)),
1147
+ fromMidnight: parseHm(range.start) === 0,
1148
+ toMidnight
1149
+ });
1150
+ }
1151
+ raw.sort((a, b) => a.start - b.start);
1152
+ const joined = [];
1153
+ for (const interval of raw) {
1154
+ const previous = joined[joined.length - 1];
1155
+ if (previous?.toMidnight && interval.fromMidnight && interval.start === previous.end) {
1156
+ previous.end = interval.end;
1157
+ previous.toMidnight = interval.toMidnight;
1158
+ } else joined.push({ ...interval });
1159
+ }
1160
+ return joined.map(({ start, end }) => ({
1161
+ start,
1162
+ end
1163
+ }));
1164
+ }
1165
+ /** Whether [start, end] lies fully inside one bookable range (or a 24:00/00:00 chain); unrestricted = always. */
1166
+ function isWithinBookableHours(hours, timeZone, start, end) {
1167
+ if (!hasRestrictions(hours)) return true;
1168
+ return bookableIntervals(hours, timeZone, start, end).some((interval) => interval.start <= start.getTime() && end.getTime() <= interval.end);
1169
+ }
1170
+ function formatTime(date, timeZone, locale) {
1171
+ return new Intl.DateTimeFormat(locale, {
1172
+ timeZone,
1173
+ hour: "2-digit",
1174
+ minute: "2-digit"
1175
+ }).format(new Date(date));
1176
+ }
1177
+ function formatDate(date, timeZone, locale) {
1178
+ return new Intl.DateTimeFormat(locale, {
1179
+ timeZone,
1180
+ weekday: "short",
1181
+ day: "2-digit",
1182
+ month: "2-digit"
1183
+ }).format(new Date(date));
1184
+ }
1185
+ function formatDateTime(date, timeZone, locale) {
1186
+ return new Intl.DateTimeFormat(locale, {
1187
+ timeZone,
1188
+ day: "2-digit",
1189
+ month: "2-digit",
1190
+ year: "numeric",
1191
+ hour: "2-digit",
1192
+ minute: "2-digit"
1193
+ }).format(new Date(date));
1194
+ }
1195
+ function formatDayHeading(date, timeZone, locale) {
1196
+ return new Intl.DateTimeFormat(locale, {
1197
+ timeZone,
1198
+ weekday: "long",
1199
+ day: "2-digit",
1200
+ month: "long"
1201
+ }).format(wallClockToDate({
1202
+ ...date,
1203
+ hour: 12
1204
+ }, timeZone));
1205
+ }
1206
+ /** "1 h 15 min" in the UI language ("1 Std. 15 Min." in German). */
1207
+ function formatDuration(minutes, locale = detectLanguage()) {
1208
+ const unit = (value, name) => new Intl.NumberFormat(locale, {
1209
+ style: "unit",
1210
+ unit: name,
1211
+ unitDisplay: "short"
1212
+ }).format(value);
1213
+ const hours = Math.floor(minutes / 60);
1214
+ const rest = minutes % 60;
1215
+ if (hours === 0) return unit(rest, "minute");
1216
+ return rest === 0 ? unit(hours, "hour") : `${unit(hours, "hour")} ${unit(rest, "minute")}`;
1217
+ }
1218
+ function browserTimeZone() {
1219
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
1220
+ }
1221
+ //#endregion
1222
+ //#region frontend/src/lib/queries.ts
1223
+ var { keepPreviousData, useQuery: useQuery$4, useQueryClient } = await importShared("@tanstack/react-query");
1224
+ var { useCallback, useMemo: useMemo$8 } = await importShared("react");
1225
+ var ROOT_KEY = "reservations";
1226
+ var keys = {
1227
+ availability: (resourceId, from, to) => [
1228
+ ROOT_KEY,
1229
+ "availability",
1230
+ resourceId,
1231
+ from,
1232
+ to
1233
+ ],
1234
+ pending: (resourceId) => [
1235
+ ROOT_KEY,
1236
+ "pending-decision",
1237
+ resourceId
1238
+ ],
1239
+ mine: (scope, status) => [
1240
+ ROOT_KEY,
1241
+ "mine",
1242
+ scope,
1243
+ status ?? "all"
1244
+ ],
1245
+ managed: (filter) => [
1246
+ ROOT_KEY,
1247
+ "managed",
1248
+ filter
1249
+ ],
1250
+ reservation: (id) => [
1251
+ ROOT_KEY,
1252
+ "reservation",
1253
+ id
1254
+ ],
1255
+ feeds: () => [ROOT_KEY, "feeds"],
1256
+ managerAccess: (resourceId) => [
1257
+ ROOT_KEY,
1258
+ "manager-access",
1259
+ resourceId
1260
+ ]
1261
+ };
1262
+ /** Refreshes every reservation-related query after a change. */
1263
+ function useInvalidateReservations() {
1264
+ const client = useQueryClient();
1265
+ return useCallback(() => client.invalidateQueries({ queryKey: [ROOT_KEY] }), [client]);
1266
+ }
1267
+ /** `keepPrevious` keeps showing the last range while the next one loads (day/week navigation). */
1268
+ function useAvailability(resourceId, from, to, enabled = true, keepPrevious = false) {
1269
+ const fromIso = from.toISOString();
1270
+ const toIso = to.toISOString();
1271
+ return useQuery$4({
1272
+ queryKey: keys.availability(resourceId, fromIso, toIso),
1273
+ queryFn: ({ signal }) => getAvailability(resourceId, new Date(fromIso), new Date(toIso), signal),
1274
+ staleTime: 15e3,
1275
+ retry: false,
1276
+ enabled,
1277
+ placeholderData: keepPrevious ? keepPreviousData : void 0
1278
+ });
1279
+ }
1280
+ var hostApi = createPluginApiClient("");
1281
+ /** The resource's display name from the host API; undefined until known (or when it cannot be read). */
1282
+ function useResourceName(resourceId) {
1283
+ return useQuery$4({
1284
+ queryKey: [
1285
+ "reservations",
1286
+ "resource-name",
1287
+ resourceId
1288
+ ],
1289
+ queryFn: async ({ signal }) => {
1290
+ const response = await hostApi.fetch(`/api/resources/${resourceId}`, { signal });
1291
+ if (!response.ok) throw new Error(`Request failed (HTTP ${response.status}).`);
1292
+ return JSON.parse(await response.text()).name ?? null;
1293
+ },
1294
+ staleTime: 3e5,
1295
+ retry: false
1296
+ }).data ?? void 0;
1297
+ }
1298
+ /**
1299
+ * The keep-or-free question after the holder's session ended during an active booking. Callers
1300
+ * enable it only while the viewer holds a booking of this resource that runs right now (the only
1301
+ * time the server can hold such a question); then one tiny GET every 5 s while the tab is
1302
+ * visible, plus a refetch on focus, so the question appears within seconds of stopping.
1303
+ */
1304
+ function usePendingDecision(resourceId, enabled) {
1305
+ return useQuery$4({
1306
+ queryKey: keys.pending(resourceId),
1307
+ queryFn: ({ signal }) => getPendingDecision(resourceId, signal),
1308
+ enabled,
1309
+ refetchInterval: enabled ? 5e3 : false,
1310
+ refetchIntervalInBackground: false,
1311
+ refetchOnWindowFocus: true,
1312
+ staleTime: 5e3,
1313
+ retry: false
1314
+ });
1315
+ }
1316
+ function useMyReservations(scope, status) {
1317
+ return useQuery$4({
1318
+ queryKey: keys.mine(scope, status),
1319
+ queryFn: () => listMine(scope, status),
1320
+ retry: false
1321
+ });
1322
+ }
1323
+ function useManagedReservations(filter) {
1324
+ const stable = useMemo$8(() => filter, [filter]);
1325
+ return useQuery$4({
1326
+ queryKey: keys.managed(stable),
1327
+ queryFn: () => listManaged(stable),
1328
+ retry: false,
1329
+ placeholderData: (previous) => previous
1330
+ });
1331
+ }
1332
+ function useReservation(id) {
1333
+ return useQuery$4({
1334
+ queryKey: keys.reservation(id),
1335
+ queryFn: () => getReservation(id),
1336
+ enabled: Number.isInteger(id) && id > 0,
1337
+ retry: false
1338
+ });
1339
+ }
1340
+ function useFeeds() {
1341
+ return useQuery$4({
1342
+ queryKey: keys.feeds(),
1343
+ queryFn: listFeeds,
1344
+ retry: false
1345
+ });
1346
+ }
1347
+ /**
1348
+ * The plugin timezone for pages that list reservations without an availability payload. Null while
1349
+ * it loads, so callers can wait instead of formatting in another zone; the browser's zone if it
1350
+ * cannot be read.
1351
+ */
1352
+ function usePluginTimezone() {
1353
+ const query = useQuery$4({
1354
+ queryKey: [ROOT_KEY, "global-settings"],
1355
+ queryFn: getGlobalSettings,
1356
+ staleTime: 3e5,
1357
+ retry: false
1358
+ });
1359
+ if (query.data) return query.data.timezone;
1360
+ return query.isError ? browserTimeZone() : null;
1361
+ }
1362
+ /** True when the user may manage reservations of at least one resource. */
1363
+ function useIsManagerAnywhere() {
1364
+ return useQuery$4({
1365
+ queryKey: [ROOT_KEY, "manage-access"],
1366
+ queryFn: getManageAccess,
1367
+ staleTime: 3e5,
1368
+ retry: false
1369
+ }).data?.isManager === true;
1370
+ }
1371
+ //#endregion
1372
+ //#region frontend/src/lib/useFormatters.ts
1373
+ var { useMemo: useMemo$7 } = await importShared("react");
1374
+ /** Date/time formatting in the plugin timezone (falls back to the browser's) and the UI language. */
1375
+ function useFormatters(timezone) {
1376
+ const { language } = useReservationsTranslations();
1377
+ return useMemo$7(() => {
1378
+ const zone = timezone || browserTimeZone();
1379
+ return {
1380
+ zone,
1381
+ locale: language,
1382
+ time: (value) => formatTime(value, zone, language),
1383
+ date: (value) => formatDate(value, zone, language),
1384
+ dateTime: (value) => formatDateTime(value, zone, language),
1385
+ duration: (minutes) => formatDuration(minutes, language),
1386
+ range: (start, end) => `${formatDateTime(start, zone, language)} – ${formatTime(end, zone, language)}`
1387
+ };
1388
+ }, [timezone, language]);
1389
+ }
1390
+ //#endregion
1391
+ //#region frontend/src/shared/queryState.ts
1392
+ /**
1393
+ * Loading, error and retry props for `ReservationsTable`; a retry shows the spinner again, not the
1394
+ * empty state. Pass the plugin timezone so the list waits for it instead of formatting in another zone.
1395
+ */
1396
+ function listState(query, timezone) {
1397
+ return {
1398
+ isPending: query.isPending || query.isError && query.isFetching || timezone === null,
1399
+ error: query.isError && !query.isFetching ? query.error : void 0,
1400
+ onRetry: () => void query.refetch()
1401
+ };
1402
+ }
1403
+ //#endregion
1404
+ //#region frontend/src/shared/fields.tsx
1405
+ var { Description: Description$1, FieldError, Input: Input$2, Label: Label$4, ListBox: ListBox$2, ListBoxItem: ListBoxItem$1, NumberField, NumberFieldDecrementButton, NumberFieldGroup, NumberFieldIncrementButton, NumberFieldInput, Select: HeroSelect, SelectIndicator, SelectPopover, SelectTrigger, SelectValue, TextField: TextField$3 } = await importShared("@heroui/react");
1406
+ function SelectField(props) {
1407
+ const { label, value, onChange, options, description, isDisabled, isInvalid, className } = props;
1408
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(HeroSelect, {
1409
+ value,
1410
+ onChange: (key) => onChange(String(key)),
1411
+ isDisabled,
1412
+ isInvalid,
1413
+ className,
1414
+ placeholder: label,
1415
+ "data-cy": props["data-cy"],
1416
+ children: [
1417
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$4, { children: label }),
1418
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SelectTrigger, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectIndicator, {})] }),
1419
+ description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description$1, { children: description }),
1420
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectPopover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListBox$2, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListBoxItem$1, {
1421
+ id: option.key,
1422
+ textValue: option.label,
1423
+ children: option.label
1424
+ }, option.key)) }) })
1425
+ ]
1426
+ });
1427
+ }
1428
+ function NumberInput(props) {
1429
+ const { label, value, onChange, min, max, step, description, errorMessage } = props;
1430
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(NumberField, {
1431
+ value: Number.isFinite(value) ? value : void 0,
1432
+ onChange,
1433
+ minValue: min,
1434
+ maxValue: max,
1435
+ step,
1436
+ isInvalid: Boolean(errorMessage),
1437
+ "data-cy": props["data-cy"],
1438
+ children: [
1439
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$4, { children: label }),
1440
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(NumberFieldGroup, { children: [
1441
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberFieldDecrementButton, { children: "-" }),
1442
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberFieldInput, {}),
1443
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberFieldIncrementButton, { children: "+" })
1444
+ ] }),
1445
+ description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description$1, { children: description }),
1446
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FieldError, { children: errorMessage })
1447
+ ]
1448
+ });
1449
+ }
1450
+ function TextInput(props) {
1451
+ const { label, value, onChange, type, placeholder, maxLength, min, max, isRequired, description } = props;
1452
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$3, {
1453
+ value,
1454
+ onChange,
1455
+ isRequired,
1456
+ type,
1457
+ children: [
1458
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$4, { children: label }),
1459
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$2, {
1460
+ placeholder,
1461
+ maxLength,
1462
+ min,
1463
+ max,
1464
+ "data-cy": props["data-cy"],
1465
+ autoComplete: "off"
1466
+ }),
1467
+ description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description$1, { children: description })
1468
+ ]
1469
+ });
1470
+ }
1471
+ //#endregion
1472
+ //#region frontend/src/ical/FeedFormModal.tsx
1473
+ var { Button: Button$10, LabeledSwitch: LabeledSwitch$1, ResourceSelector, StandardModal: StandardModal$1, StatusDialog: StatusDialog$8 } = await importShared("@attraccess/plugins-frontend-ui");
1474
+ var { Description, Fieldset: Fieldset$1, ModalBody: ModalBody$1, ModalFooter: ModalFooter$1, ModalHeader: ModalHeader$1, ModalHeading: ModalHeading$1 } = await importShared("@heroui/react");
1475
+ var { useMutation: useMutation$6, useQuery: useQuery$3 } = await importShared("@tanstack/react-query");
1476
+ var { useEffect: useEffect$6, useState: useState$11 } = await importShared("react");
1477
+ var EMPTY = {
1478
+ resourceIds: [],
1479
+ groupIds: [],
1480
+ introduced: false,
1481
+ maintained: false,
1482
+ ownOnly: false
1483
+ };
1484
+ var toggle = (list, id) => list.includes(id) ? list.filter((entry) => entry !== id) : [...list, id];
1485
+ function FeedFormModal({ isOpen, feed, onOpenChange, onSaved }) {
1486
+ const { t } = useReservationsTranslations();
1487
+ const [name, setName] = useState$11("");
1488
+ const [selection, setSelection] = useState$11(EMPTY);
1489
+ const [error, setError] = useState$11(null);
1490
+ useEffect$6(() => {
1491
+ if (!isOpen) return;
1492
+ setName(feed?.name ?? "");
1493
+ setSelection(feed?.selection ?? EMPTY);
1494
+ }, [isOpen, feed]);
1495
+ const groups = useQuery$3({
1496
+ queryKey: ["reservations", "host-groups"],
1497
+ queryFn: listHostGroups,
1498
+ enabled: isOpen && !selection.ownOnly,
1499
+ staleTime: 6e4
1500
+ });
1501
+ const save = useMutation$6({
1502
+ mutationFn: async () => {
1503
+ const body = {
1504
+ name: name.trim(),
1505
+ selection
1506
+ };
1507
+ if (feed) {
1508
+ await updateFeed(feed.id, body);
1509
+ return null;
1510
+ }
1511
+ return createFeed(body);
1512
+ },
1513
+ onSuccess: (secret) => {
1514
+ onSaved(secret);
1515
+ onOpenChange(false);
1516
+ },
1517
+ onError: (failure) => setError(describeError(failure, t))
1518
+ });
1519
+ const hasSelection = selection.ownOnly || selection.introduced || selection.maintained || selection.resourceIds.length > 0 || selection.groupIds.length > 0;
1520
+ const canSave = name.trim().length > 0 && hasSelection;
1521
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardModal$1, {
1522
+ isOpen,
1523
+ onOpenChange,
1524
+ size: "md",
1525
+ "data-cy": "reservations-feed-form",
1526
+ children: [
1527
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeader$1, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeading$1, { children: feed ? t("feeds.form.editTitle") : t("feeds.form.createTitle") }) }),
1528
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalBody$1, {
1529
+ className: "rv:flex rv:flex-col rv:gap-4 rv:p-1",
1530
+ children: [
1531
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextInput, {
1532
+ label: t("feeds.form.name"),
1533
+ value: name,
1534
+ onChange: setName,
1535
+ maxLength: 100,
1536
+ isRequired: true
1537
+ }),
1538
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabeledSwitch$1, {
1539
+ isSelected: selection.ownOnly,
1540
+ onChange: (ownOnly) => setSelection({
1541
+ ...selection,
1542
+ ownOnly
1543
+ }),
1544
+ children: t("feeds.form.ownOnly")
1545
+ }),
1546
+ !selection.ownOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1547
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabeledSwitch$1, {
1548
+ isSelected: selection.introduced,
1549
+ onChange: (introduced) => setSelection({
1550
+ ...selection,
1551
+ introduced
1552
+ }),
1553
+ children: t("feeds.form.introduced")
1554
+ }),
1555
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabeledSwitch$1, {
1556
+ isSelected: selection.maintained,
1557
+ onChange: (maintained) => setSelection({
1558
+ ...selection,
1559
+ maintained
1560
+ }),
1561
+ children: t("feeds.form.maintained")
1562
+ }),
1563
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Fieldset$1, { children: [
1564
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fieldset$1.Legend, { children: t("feeds.form.groups") }),
1565
+ (groups.data ?? []).map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabeledSwitch$1, {
1566
+ isSelected: selection.groupIds.includes(group.id),
1567
+ onChange: () => setSelection({
1568
+ ...selection,
1569
+ groupIds: toggle(selection.groupIds, group.id)
1570
+ }),
1571
+ children: group.name
1572
+ }, group.id)),
1573
+ groups.data?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1574
+ className: "rv:text-sm rv:text-muted",
1575
+ children: t("feeds.form.noGroups")
1576
+ })
1577
+ ] }),
1578
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Fieldset$1, { children: [
1579
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fieldset$1.Legend, { children: t("feeds.form.resources") }),
1580
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResourceSelector, {
1581
+ selection: selection.resourceIds,
1582
+ onSelectionChange: (resourceIds) => setSelection({
1583
+ ...selection,
1584
+ resourceIds
1585
+ })
1586
+ }),
1587
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, { children: t("feeds.form.selectedCount", { count: selection.resourceIds.length }) })
1588
+ ] })
1589
+ ] }),
1590
+ !hasSelection && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1591
+ className: "rv:text-sm rv:text-muted",
1592
+ children: t("feeds.form.needSelection")
1593
+ })
1594
+ ]
1595
+ }),
1596
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalFooter$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$10, {
1597
+ variant: "tertiary",
1598
+ onPress: () => onOpenChange(false),
1599
+ children: t("common.cancel")
1600
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$10, {
1601
+ variant: "primary",
1602
+ isDisabled: !canSave,
1603
+ isPending: save.isPending,
1604
+ onPress: () => save.mutate(),
1605
+ "data-cy": "reservations-feed-save",
1606
+ children: feed ? t("common.save") : t("feeds.form.create")
1607
+ })] })
1608
+ ]
1609
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$8, {
1610
+ isOpen: error !== null,
1611
+ onClose: () => setError(null),
1612
+ status: "error",
1613
+ title: t("feeds.failed"),
1614
+ children: error ?? ""
1615
+ })] });
1616
+ }
1617
+ //#endregion
1618
+ //#region frontend/src/ical/FeedSecretDialog.tsx
1619
+ var { Button: Button$9, StatusDialog: StatusDialog$7 } = await importShared("@attraccess/plugins-frontend-ui");
1620
+ var { Input: Input$1 } = await importShared("@heroui/react");
1621
+ var { CheckIcon, CopyIcon } = await importShared("lucide-react");
1622
+ var { useEffect: useEffect$5, useState: useState$10 } = await importShared("react");
1623
+ /** Shows a feed URL exactly once, right after it was created or regenerated. */
1624
+ function FeedSecretDialog(props) {
1625
+ const { t } = useReservationsTranslations();
1626
+ const [copied, setCopied] = useState$10(false);
1627
+ const { secret } = props;
1628
+ useEffect$5(() => {
1629
+ if (!copied) return;
1630
+ const timer = setTimeout(() => setCopied(false), 3e3);
1631
+ return () => clearTimeout(timer);
1632
+ }, [copied]);
1633
+ const copy = async () => {
1634
+ if (!secret) return;
1635
+ try {
1636
+ await navigator.clipboard.writeText(secret.url);
1637
+ setCopied(true);
1638
+ } catch {
1639
+ setCopied(false);
1640
+ }
1641
+ };
1642
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$7, {
1643
+ isOpen: secret !== null,
1644
+ onClose: () => {
1645
+ setCopied(false);
1646
+ props.onClose();
1647
+ },
1648
+ status: "success",
1649
+ title: t("feeds.secret.title", { name: secret?.feed.name ?? "" }),
1650
+ closeLabel: t("common.done"),
1651
+ "data-cy": "reservations-feed-secret",
1652
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1653
+ className: "rv:flex rv:flex-col rv:gap-3",
1654
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t("feeds.secret.body") }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1655
+ className: "rv:flex rv:items-center rv:gap-2",
1656
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input$1, {
1657
+ readOnly: true,
1658
+ fullWidth: true,
1659
+ value: secret?.url ?? "",
1660
+ "aria-label": t("feeds.secret.url"),
1661
+ onFocus: (event) => event.currentTarget.select(),
1662
+ "data-cy": "reservations-feed-url"
1663
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$9, {
1664
+ variant: "secondary",
1665
+ className: "rv:shrink-0",
1666
+ onPress: () => void copy(),
1667
+ "data-cy": "reservations-feed-copy",
1668
+ children: [copied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckIcon, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyIcon, { size: 16 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1669
+ "aria-live": "polite",
1670
+ children: copied ? t("feeds.secret.copied") : t("feeds.secret.copy")
1671
+ })]
1672
+ })]
1673
+ })]
1674
+ })
1675
+ });
1676
+ }
1677
+ //#endregion
1678
+ //#region frontend/src/ical/IcalFeeds.tsx
1679
+ var { Button: Button$8, EmptyState: EmptyState$1, StatusAlert: StatusAlert$7, StatusDialog: StatusDialog$6, TableDataLoadingIndicator: TableDataLoadingIndicator$2 } = await importShared("@attraccess/plugins-frontend-ui");
1680
+ var { Chip: Chip$3 } = await importShared("@heroui/react");
1681
+ var { useMutation: useMutation$5 } = await importShared("@tanstack/react-query");
1682
+ var { PlusIcon: PlusIcon$1 } = await importShared("lucide-react");
1683
+ var { useState: useState$9 } = await importShared("react");
1684
+ /**
1685
+ * iCal feed management: list, create, rename/re-scope, regenerate and revoke. Used by the account
1686
+ * slot and page. Dates are shown in the plugin timezone, like every other reservation time.
1687
+ */
1688
+ function IcalFeeds() {
1689
+ const { t } = useReservationsTranslations();
1690
+ const timezone = usePluginTimezone();
1691
+ const format = useFormatters(timezone);
1692
+ const feeds = useFeeds();
1693
+ const state = listState(feeds, timezone);
1694
+ const invalidate = useInvalidateReservations();
1695
+ const [formFeed, setFormFeed] = useState$9(null);
1696
+ const [formOpen, setFormOpen] = useState$9(false);
1697
+ const [secret, setSecret] = useState$9(null);
1698
+ const [confirm, setConfirm] = useState$9(null);
1699
+ const [error, setError] = useState$9(null);
1700
+ const run = useMutation$5({
1701
+ mutationFn: async (current) => current.kind === "regenerate" ? regenerateFeed(current.feed.id) : (await revokeFeed(current.feed.id), null),
1702
+ onSuccess: async (result) => {
1703
+ setConfirm(null);
1704
+ if (result) setSecret(result);
1705
+ await invalidate();
1706
+ },
1707
+ onError: (failure) => {
1708
+ setConfirm(null);
1709
+ setError(describeError(failure, t));
1710
+ }
1711
+ });
1712
+ const describeSelection = (feed) => {
1713
+ const { selection } = feed;
1714
+ if (selection.ownOnly) return t("feeds.selection.ownOnly");
1715
+ const parts = [];
1716
+ if (selection.introduced) parts.push(t("feeds.selection.introduced"));
1717
+ if (selection.maintained) parts.push(t("feeds.selection.maintained"));
1718
+ if (selection.groupIds.length) parts.push(t("feeds.selection.groups", { count: selection.groupIds.length }));
1719
+ if (selection.resourceIds.length) parts.push(t("feeds.selection.resources", { count: selection.resourceIds.length }));
1720
+ return parts.join(", ");
1721
+ };
1722
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1723
+ className: "rv:flex rv:flex-col rv:gap-4",
1724
+ "data-cy": "reservations-feeds",
1725
+ children: [
1726
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1727
+ className: "rv:text-sm rv:text-muted",
1728
+ children: t("feeds.description")
1729
+ }),
1730
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$8, {
1731
+ variant: "secondary",
1732
+ onPress: () => {
1733
+ setFormFeed(null);
1734
+ setFormOpen(true);
1735
+ },
1736
+ "data-cy": "reservations-feed-create",
1737
+ children: [
1738
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon$1, { size: 16 }),
1739
+ " ",
1740
+ t("feeds.create")
1741
+ ]
1742
+ }) }),
1743
+ state.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1744
+ className: "rv:flex rv:flex-col rv:items-start rv:gap-3",
1745
+ "data-cy": "reservations-feeds-error",
1746
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$7, {
1747
+ status: "danger",
1748
+ title: t("feeds.loadFailed"),
1749
+ children: describeError(state.error, t)
1750
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$8, {
1751
+ size: "sm",
1752
+ variant: "secondary",
1753
+ onPress: state.onRetry,
1754
+ children: t("common.retry")
1755
+ })]
1756
+ }) : null,
1757
+ state.isPending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableDataLoadingIndicator$2, { label: t("common.loading") }),
1758
+ !state.isPending && feeds.data?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState$1, { message: t("feeds.empty") }),
1759
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
1760
+ className: "rv:flex rv:flex-col rv:gap-3",
1761
+ children: (state.isPending ? [] : feeds.data ?? []).map((feed) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
1762
+ className: "rv:flex rv:flex-wrap rv:items-center rv:justify-between rv:gap-3",
1763
+ "data-cy": `reservations-feed-${feed.id}`,
1764
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1765
+ className: "rv:flex rv:min-w-0 rv:flex-col rv:gap-1",
1766
+ children: [
1767
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1768
+ className: "rv:flex rv:items-center rv:gap-2 rv:font-medium",
1769
+ children: [feed.name, feed.revokedAt && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$3, {
1770
+ size: "sm",
1771
+ color: "danger",
1772
+ children: t("feeds.revoked")
1773
+ })]
1774
+ }),
1775
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1776
+ className: "rv:text-sm rv:text-muted",
1777
+ children: describeSelection(feed)
1778
+ }),
1779
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1780
+ className: "rv:text-xs rv:text-muted",
1781
+ children: [
1782
+ feed.revokedAt ? t("feeds.revokedAt", { date: format.dateTime(feed.revokedAt) }) : feed.lastUsedAt ? t("feeds.lastUsed", { date: format.dateTime(feed.lastUsedAt) }) : t("feeds.neverUsed"),
1783
+ " · ",
1784
+ feed.tokenPrefix.slice(0, 4),
1785
+ "…"
1786
+ ]
1787
+ })
1788
+ ]
1789
+ }), !feed.revokedAt && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1790
+ className: "rv:flex rv:gap-2",
1791
+ children: [
1792
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$8, {
1793
+ size: "sm",
1794
+ variant: "tertiary",
1795
+ onPress: () => {
1796
+ setFormFeed(feed);
1797
+ setFormOpen(true);
1798
+ },
1799
+ children: t("common.edit")
1800
+ }),
1801
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$8, {
1802
+ size: "sm",
1803
+ variant: "secondary",
1804
+ onPress: () => setConfirm({
1805
+ kind: "regenerate",
1806
+ feed
1807
+ }),
1808
+ children: t("feeds.regenerate.label")
1809
+ }),
1810
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$8, {
1811
+ size: "sm",
1812
+ variant: "secondary",
1813
+ onPress: () => setConfirm({
1814
+ kind: "revoke",
1815
+ feed
1816
+ }),
1817
+ children: t("feeds.revoke.label")
1818
+ })
1819
+ ]
1820
+ })]
1821
+ }, feed.id))
1822
+ }),
1823
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedFormModal, {
1824
+ isOpen: formOpen,
1825
+ feed: formFeed,
1826
+ onOpenChange: setFormOpen,
1827
+ onSaved: (created) => {
1828
+ if (created) setSecret(created);
1829
+ invalidate();
1830
+ }
1831
+ }),
1832
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedSecretDialog, {
1833
+ secret,
1834
+ onClose: () => setSecret(null)
1835
+ }),
1836
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$6, {
1837
+ isOpen: confirm !== null,
1838
+ onClose: () => !run.isPending && setConfirm(null),
1839
+ status: "warning",
1840
+ title: confirm ? t(`feeds.${confirm.kind}.title`, { name: confirm.feed.name }) : "",
1841
+ action: {
1842
+ label: confirm ? t(`feeds.${confirm.kind}.confirm`) : "",
1843
+ onPress: () => confirm && run.mutate(confirm),
1844
+ isPending: run.isPending
1845
+ },
1846
+ "data-cy": "reservations-feed-confirm",
1847
+ children: confirm ? t(`feeds.${confirm.kind}.body`) : ""
1848
+ }),
1849
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$6, {
1850
+ isOpen: error !== null,
1851
+ onClose: () => setError(null),
1852
+ status: "error",
1853
+ title: t("feeds.failed"),
1854
+ children: error ?? ""
1855
+ })
1856
+ ]
1857
+ });
1858
+ }
1859
+ //#endregion
1860
+ //#region frontend/src/shared/TimezoneHint.tsx
1861
+ /** "Times in Europe/Berlin": every list that shows booking times names the zone they are in. */
1862
+ function TimezoneHint({ timezone }) {
1863
+ const { t } = useReservationsTranslations();
1864
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1865
+ className: "rv:text-xs rv:text-muted",
1866
+ "data-cy": "reservations-timezone-hint",
1867
+ children: t("common.timesIn", { timezone })
1868
+ });
1869
+ }
1870
+ //#endregion
1871
+ //#region frontend/src/shared/useReservationActions.tsx
1872
+ var { StatusDialog: StatusDialog$5 } = await importShared("@attraccess/plugins-frontend-ui");
1873
+ var { Label: Label$3, TextArea: TextArea$1, TextField: TextField$2 } = await importShared("@heroui/react");
1874
+ var { useMutation: useMutation$4 } = await importShared("@tanstack/react-query");
1875
+ var { useState: useState$8 } = await importShared("react");
1876
+ var WITH_REASON = /* @__PURE__ */ new Set(["approve", "reject"]);
1877
+ /**
1878
+ * Confirmation flow for every state-changing reservation action. Nothing is sent before the
1879
+ * user confirms in a StatusDialog; failures show a localised error dialog.
1880
+ */
1881
+ function useReservationActions(options = {}) {
1882
+ const { t } = useReservationsTranslations();
1883
+ const format = useFormatters(options.timezone);
1884
+ const invalidate = useInvalidateReservations();
1885
+ const [pending, setPending] = useState$8(null);
1886
+ const [reason, setReason] = useState$8("");
1887
+ const [error, setError] = useState$8(null);
1888
+ const mutation = useMutation$4({
1889
+ mutationFn: ({ action, reservation }) => reservationAction(reservation.id, action, reason.trim()),
1890
+ onSuccess: async () => {
1891
+ setPending(null);
1892
+ setReason("");
1893
+ await invalidate();
1894
+ options.onDone?.();
1895
+ },
1896
+ onError: (failure) => {
1897
+ setPending(null);
1898
+ setError(describeError(failure, t));
1899
+ invalidate();
1900
+ }
1901
+ });
1902
+ const ask = (action, reservation) => {
1903
+ setReason("");
1904
+ setPending({
1905
+ action,
1906
+ reservation
1907
+ });
1908
+ };
1909
+ const close = () => {
1910
+ if (!mutation.isPending) setPending(null);
1911
+ };
1912
+ const reasonAllowed = (current) => WITH_REASON.has(current.action) || current.action === "cancel" && !current.reservation.mine;
1913
+ const status = pending?.action === "keep" || pending?.action === "approve" ? "info" : "warning";
1914
+ return {
1915
+ ask,
1916
+ dialogs: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$5, {
1917
+ isOpen: pending !== null,
1918
+ onClose: close,
1919
+ status,
1920
+ title: pending ? t(`actions.${pending.action}.title`) : "",
1921
+ action: {
1922
+ label: pending ? t(`actions.${pending.action}.confirm`) : "",
1923
+ onPress: () => pending && mutation.mutate(pending),
1924
+ isPending: mutation.isPending
1925
+ },
1926
+ closeLabel: t("common.back"),
1927
+ "data-cy": "reservations-action-dialog",
1928
+ children: pending && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1929
+ className: "rv:flex rv:flex-col rv:gap-3",
1930
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t(`actions.${pending.action}.body`, {
1931
+ resource: pending.reservation.resourceName ?? "",
1932
+ range: format.range(pending.reservation.startTime, pending.reservation.endTime),
1933
+ until: format.time(pending.reservation.endTime)
1934
+ }) }), reasonAllowed(pending) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$2, {
1935
+ value: reason,
1936
+ onChange: setReason,
1937
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$3, { children: t(pending.action === "approve" ? "actions.commentLabel" : "actions.reasonLabel") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextArea$1, {
1938
+ maxLength: 500,
1939
+ rows: 2
1940
+ })]
1941
+ })]
1942
+ })
1943
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$5, {
1944
+ isOpen: error !== null,
1945
+ onClose: () => setError(null),
1946
+ status: "error",
1947
+ title: t("actions.failedTitle"),
1948
+ "data-cy": "reservations-action-error",
1949
+ children: error ?? ""
1950
+ })] }),
1951
+ isPending: mutation.isPending
1952
+ };
1953
+ }
1954
+ //#endregion
1955
+ //#region frontend/src/shared/StatusChip.tsx
1956
+ var { Chip: Chip$2 } = await importShared("@heroui/react");
1957
+ var COLOR = {
1958
+ pending: "warning",
1959
+ confirmed: "success",
1960
+ rejected: "danger",
1961
+ cancelled: "default",
1962
+ expired: "default",
1963
+ no_show: "danger",
1964
+ completed: "default"
1965
+ };
1966
+ function StatusChip({ status }) {
1967
+ const { t } = useReservationsTranslations();
1968
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$2, {
1969
+ size: "sm",
1970
+ color: COLOR[status],
1971
+ className: "rv:whitespace-nowrap",
1972
+ children: t(`status.${status}`)
1973
+ });
1974
+ }
1975
+ //#endregion
1976
+ //#region frontend/src/overview/AvailabilityTimeline.tsx
1977
+ var { Chip: Chip$1 } = await importShared("@heroui/react");
1978
+ var BAR_CLASS = {
1979
+ mine: "rv:bg-accent",
1980
+ other: "rv:bg-muted",
1981
+ pending: "rv:bg-warning",
1982
+ maintenance: "rv:bg-danger"
1983
+ };
1984
+ var visible = (reservation) => reservation.status === "pending" || reservation.status === "confirmed";
1985
+ function entriesOf(availability) {
1986
+ const reservations = availability.reservations.filter(visible).map((reservation) => ({
1987
+ key: `r${reservation.id}`,
1988
+ start: new Date(reservation.startTime).getTime(),
1989
+ end: new Date(reservation.endTime).getTime(),
1990
+ kind: reservation.status === "pending" ? "pending" : reservation.mine ? "mine" : "other",
1991
+ reservation
1992
+ }));
1993
+ const maintenance = availability.maintenance.map((span, index) => ({
1994
+ key: `m${index}`,
1995
+ start: new Date(span.startTime).getTime(),
1996
+ end: span.endTime ? new Date(span.endTime).getTime() : Number.MAX_SAFE_INTEGER,
1997
+ kind: "maintenance"
1998
+ }));
1999
+ return [...reservations, ...maintenance].sort((a, b) => a.start - b.start);
2000
+ }
2001
+ function AvailabilityTimeline(props) {
2002
+ const { availability, days } = props;
2003
+ const { t } = useReservationsTranslations();
2004
+ const format = useFormatters(availability.timezone);
2005
+ const zone = availability.timezone;
2006
+ const entries = entriesOf(availability);
2007
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2008
+ className: "rv:flex rv:flex-col rv:gap-4",
2009
+ "data-cy": "reservations-timeline",
2010
+ children: days.map((day) => {
2011
+ const dayStart = startOfLocalDay(day, zone).getTime();
2012
+ const dayEnd = startOfLocalDay(addLocalDays(day, 1), zone).getTime();
2013
+ const dayEntries = entries.filter((entry) => entry.start < dayEnd && entry.end > dayStart);
2014
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2015
+ className: "rv:flex rv:flex-col rv:gap-2",
2016
+ children: [
2017
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", {
2018
+ className: "rv:text-sm rv:font-semibold",
2019
+ children: formatDayHeading(day, zone, format.locale)
2020
+ }),
2021
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2022
+ className: "rv:relative rv:h-3 rv:overflow-hidden rv:rounded-full rv:bg-surface-secondary",
2023
+ role: "img",
2024
+ "aria-label": t("card.dayBarLabel"),
2025
+ children: dayEntries.map((entry) => {
2026
+ const left = (Math.max(entry.start, dayStart) - dayStart) / (dayEnd - dayStart) * 100;
2027
+ const width = (Math.min(entry.end, dayEnd) - Math.max(entry.start, dayStart)) / (dayEnd - dayStart) * 100;
2028
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2029
+ className: `rv:absolute rv:top-0 rv:h-full ${BAR_CLASS[entry.kind]}`,
2030
+ style: {
2031
+ left: `${left}%`,
2032
+ width: `${Math.max(width, .8)}%`
2033
+ }
2034
+ }, entry.key);
2035
+ })
2036
+ }),
2037
+ dayEntries.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2038
+ className: "rv:text-sm rv:text-muted",
2039
+ children: t("card.free")
2040
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
2041
+ className: "rv:flex rv:flex-col rv:gap-1",
2042
+ children: dayEntries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
2043
+ className: "rv:flex rv:flex-wrap rv:items-center rv:gap-2 rv:text-sm",
2044
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2045
+ className: "rv:tabular-nums",
2046
+ children: [
2047
+ format.time(new Date(entry.start)),
2048
+ " –",
2049
+ " ",
2050
+ entry.end === Number.MAX_SAFE_INTEGER ? t("card.openEnd") : format.time(new Date(entry.end))
2051
+ ]
2052
+ }), entry.kind === "maintenance" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip$1, {
2053
+ size: "sm",
2054
+ color: "danger",
2055
+ children: t("card.maintenance")
2056
+ }) : entry.reservation && (entry.reservation.mine || entry.reservation.userName) ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: entry.reservation.mine ? t("card.yours") : entry.reservation.userName }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusChip, { status: entry.reservation.status })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: entry.kind === "pending" ? t("card.reservedPending") : t("card.reserved") })]
2057
+ }, entry.key))
2058
+ })
2059
+ ]
2060
+ }, `${day.year}-${day.month}-${day.day}`);
2061
+ })
2062
+ });
2063
+ }
2064
+ //#endregion
2065
+ //#region frontend/src/lib/slots.ts
2066
+ var MINUTE_MS = 6e4;
2067
+ var DAY_MS$1 = 864e5;
2068
+ var blocksSlot = (reservation) => reservation.status === "pending" || reservation.status === "confirmed";
2069
+ function checkWindow(context, start, end) {
2070
+ const { rules, timezone, now } = context;
2071
+ const durationMinutes = (end.getTime() - start.getTime()) / MINUTE_MS;
2072
+ if (start.getTime() < now.getTime()) return "IN_THE_PAST";
2073
+ if (localMinutesOfDay(start, timezone) % rules.timeStepMinutes !== 0 || durationMinutes % rules.timeStepMinutes !== 0) return "OFF_TIME_STEP";
2074
+ if (durationMinutes < rules.minDurationMinutes) return "DURATION_TOO_SHORT";
2075
+ if (durationMinutes > rules.maxDurationMinutes) return "DURATION_TOO_LONG";
2076
+ if (start.getTime() > now.getTime() + rules.maxAdvanceDays * DAY_MS$1) return "BEYOND_MAX_ADVANCE";
2077
+ if (start.getTime() < now.getTime() + rules.minLeadMinutes * MINUTE_MS) return "LEAD_TIME_TOO_SHORT";
2078
+ const spanStart = /* @__PURE__ */ new Date(start.getTime() - rules.bufferBeforeMinutes * MINUTE_MS);
2079
+ const spanEnd = new Date(end.getTime() + rules.bufferAfterMinutes * MINUTE_MS);
2080
+ if (!isWithinBookableHours(rules.bookableHours, timezone, spanStart, spanEnd)) return "OUTSIDE_BOOKABLE_HOURS";
2081
+ if (context.reservations.some((reservation) => {
2082
+ if (!blocksSlot(reservation)) return false;
2083
+ const otherStart = new Date(reservation.startTime).getTime() - reservation.bufferBeforeMinutes * MINUTE_MS;
2084
+ const otherEnd = new Date(reservation.endTime).getTime() + reservation.bufferAfterMinutes * MINUTE_MS;
2085
+ return spanStart.getTime() < otherEnd && otherStart < spanEnd.getTime();
2086
+ })) return "OVERLAP";
2087
+ return context.maintenance.some((span) => spanStart.getTime() < (span.endTime ? new Date(span.endTime).getTime() : Infinity) && new Date(span.startTime).getTime() < spanEnd.getTime()) ? "MAINTENANCE" : null;
2088
+ }
2089
+ /** Start times of one local day that allow at least the minimum duration. */
2090
+ function validStarts(context, day) {
2091
+ const { timeStepMinutes, minDurationMinutes } = context.rules;
2092
+ const dayStart = wallClockToDate(day, context.timezone);
2093
+ const nextDayStart = wallClockToDate(addLocalDays(day, 1), context.timezone);
2094
+ const result = [];
2095
+ for (let minutes = 0; minutes < 1440; minutes += timeStepMinutes) {
2096
+ const start = wallClockToDate({
2097
+ ...day,
2098
+ hour: Math.floor(minutes / 60),
2099
+ minute: minutes % 60
2100
+ }, context.timezone);
2101
+ if (start.getTime() < dayStart.getTime() || start.getTime() >= nextDayStart.getTime()) continue;
2102
+ if (result.length && start.getTime() <= result[result.length - 1].getTime()) continue;
2103
+ if (checkWindow(context, start, new Date(start.getTime() + minDurationMinutes * MINUTE_MS)) === null) result.push(start);
2104
+ }
2105
+ return result;
2106
+ }
2107
+ /**
2108
+ * Durations (minutes) bookable from `start`. Once a longer window collides with a booking,
2109
+ * maintenance or the bookable hours, every longer one does as well, so scanning stops there.
2110
+ */
2111
+ function validDurations(context, start) {
2112
+ const { timeStepMinutes, minDurationMinutes, maxDurationMinutes } = context.rules;
2113
+ const result = [];
2114
+ for (let minutes = minDurationMinutes; minutes <= maxDurationMinutes; minutes += timeStepMinutes) {
2115
+ if (checkWindow(context, start, new Date(start.getTime() + minutes * MINUTE_MS)) !== null) break;
2116
+ result.push(minutes);
2117
+ }
2118
+ return result;
2119
+ }
2120
+ //#endregion
2121
+ //#region frontend/src/overview/CheckInRules.tsx
2122
+ /** Plain-language summary of the check-in rules a booking is subject to. */
2123
+ function CheckInRules({ rules }) {
2124
+ const { t } = useReservationsTranslations();
2125
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2126
+ className: "rv:text-sm rv:text-muted",
2127
+ "data-cy": "reservations-checkin-rules",
2128
+ children: !rules.checkInEnabled ? t("checkIn.notRequired") : rules.earlyCheckInMinutes > 0 ? t("checkIn.required", {
2129
+ grace: rules.checkInGraceMinutes,
2130
+ early: rules.earlyCheckInMinutes
2131
+ }) : t("checkIn.requiredFromStart", { grace: rules.checkInGraceMinutes })
2132
+ });
2133
+ }
2134
+ //#endregion
2135
+ //#region frontend/src/overview/BookingModal.tsx
2136
+ var { Button: Button$7, StandardModal, StatusAlert: StatusAlert$6, StatusDialog: StatusDialog$4 } = await importShared("@attraccess/plugins-frontend-ui");
2137
+ var { Label: Label$2, ModalBody, ModalCloseTrigger, ModalFooter, ModalHeader, ModalHeading, TextArea, TextField: TextField$1 } = await importShared("@heroui/react");
2138
+ var { useMutation: useMutation$3 } = await importShared("@tanstack/react-query");
2139
+ var { useMemo: useMemo$6, useState: useState$7 } = await importShared("react");
2140
+ var DAY_MS = 864e5;
2141
+ function BookingModal(props) {
2142
+ const { resourceId, availability, isOpen, onOpenChange, onBooked } = props;
2143
+ const { t } = useReservationsTranslations();
2144
+ const format = useFormatters(availability.timezone);
2145
+ const invalidate = useInvalidateReservations();
2146
+ const zone = availability.timezone;
2147
+ const today = () => toDateKey(localDateOf(/* @__PURE__ */ new Date(), zone));
2148
+ const lastDay = toDateKey(localDateOf(new Date(Date.now() + availability.rules.maxAdvanceDays * DAY_MS), zone));
2149
+ const [dateKey, setDateKey] = useState$7(today);
2150
+ const [startIso, setStartIso] = useState$7("");
2151
+ const [duration, setDuration] = useState$7("");
2152
+ const [note, setNote] = useState$7("");
2153
+ const [error, setError] = useState$7(null);
2154
+ const day = useMemo$6(() => fromDateKey(dateKey), [dateKey]);
2155
+ const range = useMemo$6(() => {
2156
+ const base = day ?? localDateOf(/* @__PURE__ */ new Date(), zone);
2157
+ return {
2158
+ from: startOfLocalDay(addLocalDays(base, -1), zone),
2159
+ to: startOfLocalDay(addLocalDays(base, 2), zone)
2160
+ };
2161
+ }, [day, zone]);
2162
+ const dayAvailability = useAvailability(resourceId, range.from, range.to, isOpen && day !== null);
2163
+ const context = useMemo$6(() => ({
2164
+ rules: availability.rules,
2165
+ timezone: zone,
2166
+ reservations: dayAvailability.data?.reservations ?? [],
2167
+ maintenance: dayAvailability.data?.maintenance ?? [],
2168
+ now: /* @__PURE__ */ new Date()
2169
+ }), [
2170
+ availability.rules,
2171
+ zone,
2172
+ dayAvailability.data
2173
+ ]);
2174
+ const starts = useMemo$6(() => day && dayAvailability.data ? validStarts(context, day) : [], [
2175
+ context,
2176
+ day,
2177
+ dayAvailability.data
2178
+ ]);
2179
+ const selectedStart = starts.find((start) => start.toISOString() === startIso) ?? null;
2180
+ const durations = useMemo$6(() => selectedStart ? validDurations(context, selectedStart) : [], [context, selectedStart]);
2181
+ const durationValue = durations.includes(Number(duration)) ? duration : "";
2182
+ const setOpen = (open) => {
2183
+ if (!open) {
2184
+ setDateKey(today());
2185
+ setStartIso("");
2186
+ setDuration("");
2187
+ setNote("");
2188
+ }
2189
+ onOpenChange(open);
2190
+ };
2191
+ const mutation = useMutation$3({
2192
+ mutationFn: () => createReservation({
2193
+ resourceId,
2194
+ startTime: selectedStart?.toISOString() ?? "",
2195
+ durationMinutes: Number(durationValue),
2196
+ note: note.trim() || void 0
2197
+ }),
2198
+ onSuccess: async (reservation) => {
2199
+ await invalidate();
2200
+ onBooked(reservation);
2201
+ setOpen(false);
2202
+ },
2203
+ onError: (failure) => {
2204
+ setError(describeError(failure, t));
2205
+ invalidate();
2206
+ }
2207
+ });
2208
+ const rules = availability.rules;
2209
+ const canSubmit = selectedStart !== null && durationValue !== "" && !mutation.isPending;
2210
+ const noStarts = day !== null && dayAvailability.data !== void 0 && starts.length === 0;
2211
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StandardModal, {
2212
+ isOpen,
2213
+ onOpenChange: setOpen,
2214
+ size: "md",
2215
+ "data-cy": "reservations-booking-modal",
2216
+ children: [
2217
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalCloseTrigger, { "aria-label": t("common.close") }),
2218
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModalHeading, { children: props.resourceName ? t("booking.title", { resource: props.resourceName }) : t("booking.titleGeneric") }) }),
2219
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalBody, {
2220
+ className: "rv:flex rv:flex-col rv:gap-4 rv:p-1",
2221
+ children: [
2222
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextInput, {
2223
+ label: t("booking.date"),
2224
+ type: "date",
2225
+ value: dateKey,
2226
+ min: today(),
2227
+ max: lastDay,
2228
+ onChange: (value) => {
2229
+ setDateKey(value);
2230
+ setStartIso("");
2231
+ setDuration("");
2232
+ },
2233
+ description: t("booking.timezoneHint", { timezone: zone }),
2234
+ "data-cy": "reservations-booking-date"
2235
+ }),
2236
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectField, {
2237
+ label: t("booking.start"),
2238
+ value: selectedStart ? startIso : "",
2239
+ onChange: (value) => {
2240
+ setStartIso(value);
2241
+ setDuration("");
2242
+ },
2243
+ options: starts.map((start) => ({
2244
+ key: start.toISOString(),
2245
+ label: format.time(start)
2246
+ })),
2247
+ isDisabled: starts.length === 0,
2248
+ "data-cy": "reservations-booking-start"
2249
+ }),
2250
+ noStarts && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$6, {
2251
+ status: "warning",
2252
+ children: t("booking.noSlots")
2253
+ }),
2254
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectField, {
2255
+ label: t("booking.duration"),
2256
+ value: durationValue,
2257
+ onChange: setDuration,
2258
+ options: durations.map((minutes) => ({
2259
+ key: String(minutes),
2260
+ label: format.duration(minutes)
2261
+ })),
2262
+ isDisabled: durations.length === 0,
2263
+ description: t("booking.durationHint", {
2264
+ step: rules.timeStepMinutes,
2265
+ min: format.duration(rules.minDurationMinutes),
2266
+ max: format.duration(rules.maxDurationMinutes)
2267
+ }),
2268
+ "data-cy": "reservations-booking-duration"
2269
+ }),
2270
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField$1, {
2271
+ value: note,
2272
+ onChange: setNote,
2273
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$2, { children: t("booking.note") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextArea, {
2274
+ maxLength: 500,
2275
+ rows: 2
2276
+ })]
2277
+ }),
2278
+ rules.approvalRequired ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$6, {
2279
+ status: "accent",
2280
+ children: t("booking.approvalNeeded")
2281
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2282
+ className: "rv:text-sm rv:text-muted",
2283
+ "data-cy": "reservations-booking-instant",
2284
+ children: t("booking.instantNote")
2285
+ }),
2286
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckInRules, { rules })
2287
+ ]
2288
+ }),
2289
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ModalFooter, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$7, {
2290
+ variant: "tertiary",
2291
+ onPress: () => setOpen(false),
2292
+ children: t("common.cancel")
2293
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$7, {
2294
+ variant: "primary",
2295
+ isDisabled: !canSubmit,
2296
+ isPending: mutation.isPending,
2297
+ onPress: () => mutation.mutate(),
2298
+ "data-cy": "reservations-booking-submit",
2299
+ children: rules.approvalRequired ? t("booking.requestSubmit") : t("booking.submit")
2300
+ })] })
2301
+ ]
2302
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$4, {
2303
+ isOpen: error !== null,
2304
+ onClose: () => setError(null),
2305
+ status: "error",
2306
+ title: t("booking.failedTitle"),
2307
+ "data-cy": "reservations-booking-error",
2308
+ children: error ?? ""
2309
+ })] });
2310
+ }
2311
+ //#endregion
2312
+ //#region frontend/src/overview/KeepFreeDialog.tsx
2313
+ var { StatusDialog: StatusDialog$3 } = await importShared("@attraccess/plugins-frontend-ui");
2314
+ var { useMutation: useMutation$2 } = await importShared("@tanstack/react-query");
2315
+ var { useEffect: useEffect$4, useMemo: useMemo$5, useState: useState$6 } = await importShared("react");
2316
+ var MAX_TIMEOUT_MS = 2147483647;
2317
+ /**
2318
+ * Whether the viewer holds a confirmed booking of this resource that runs right now, from the
2319
+ * bookings the card already loaded (the visible range and the viewer's own upcoming list).
2320
+ * Re-evaluates exactly when one of those bookings starts or ends.
2321
+ */
2322
+ function useHoldsRunningBooking(resourceId, reservations) {
2323
+ const upcoming = useMyReservations("upcoming");
2324
+ const [now, setNow] = useState$6(() => Date.now());
2325
+ const spans = useMemo$5(() => [...reservations, ...upcoming.data ?? []].filter((entry) => entry.mine && entry.resourceId === resourceId && entry.status === "confirmed").map((entry) => ({
2326
+ start: new Date(entry.startTime).getTime(),
2327
+ end: new Date(entry.endTime).getTime()
2328
+ })), [
2329
+ reservations,
2330
+ upcoming.data,
2331
+ resourceId
2332
+ ]);
2333
+ const running = spans.some((span) => span.start <= now && now < span.end);
2334
+ const nextChange = Math.min(...spans.flatMap((span) => [span.start, span.end]).filter((time) => time > now));
2335
+ useEffect$4(() => {
2336
+ if (!Number.isFinite(nextChange)) return void 0;
2337
+ const timer = setTimeout(() => setNow(Date.now()), Math.min(nextChange - Date.now() + 50, MAX_TIMEOUT_MS));
2338
+ return () => clearTimeout(timer);
2339
+ }, [nextChange]);
2340
+ return running;
2341
+ }
2342
+ /**
2343
+ * Asks the holder what to do with the rest of a booking after their session ended early. Closing
2344
+ * the dialog (Escape) means "keep", which is also the server's default when nobody answers.
2345
+ */
2346
+ function KeepFreeDialog(props) {
2347
+ const { t } = useReservationsTranslations();
2348
+ const format = useFormatters(props.timezone);
2349
+ const invalidate = useInvalidateReservations();
2350
+ const holdsRunning = useHoldsRunningBooking(props.resourceId, props.reservations);
2351
+ const decision = usePendingDecision(props.resourceId, holdsRunning);
2352
+ const [error, setError] = useState$6(null);
2353
+ const reservation = holdsRunning ? decision.data ?? null : null;
2354
+ const answer = useMutation$2({
2355
+ mutationFn: (action) => reservationAction(reservation?.id ?? 0, action),
2356
+ onSettled: () => invalidate(),
2357
+ onError: (failure) => setError(describeError(failure, t))
2358
+ });
2359
+ const reservationId = reservation?.id ?? null;
2360
+ const { reset } = answer;
2361
+ useEffect$4(() => {
2362
+ reset();
2363
+ }, [reservationId, reset]);
2364
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$3, {
2365
+ isOpen: reservation !== null && !answer.isPending && !answer.isSuccess,
2366
+ onClose: () => answer.mutate("keep"),
2367
+ status: "info",
2368
+ title: reservation ? t("keepFree.title", { until: format.time(reservation.endTime) }) : "",
2369
+ action: {
2370
+ label: t("keepFree.free"),
2371
+ onPress: () => answer.mutate("end-early"),
2372
+ isPending: answer.isPending
2373
+ },
2374
+ closeLabel: t("keepFree.keep"),
2375
+ "data-cy": "reservations-keep-free-dialog",
2376
+ children: t("keepFree.body")
2377
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$3, {
2378
+ isOpen: error !== null,
2379
+ onClose: () => setError(null),
2380
+ status: "error",
2381
+ title: t("actions.failedTitle"),
2382
+ children: error ?? ""
2383
+ })] });
2384
+ }
2385
+ //#endregion
2386
+ //#region frontend/src/overview/NextBooking.tsx
2387
+ var { Button: Button$6 } = await importShared("@attraccess/plugins-frontend-ui");
2388
+ var { useMemo: useMemo$4 } = await importShared("react");
2389
+ /**
2390
+ * The caller's nearest live booking of this resource, independent of the range the timeline
2391
+ * shows. A booking that is running right now reads "Current booking" instead of "next".
2392
+ */
2393
+ function NextBooking({ resourceId, timezone, onAsk }) {
2394
+ const { t } = useReservationsTranslations();
2395
+ const format = useFormatters(timezone);
2396
+ const upcoming = useMyReservations("upcoming");
2397
+ const next = useMemo$4(() => (upcoming.data ?? []).find((reservation) => reservation.resourceId === resourceId), [upcoming.data, resourceId]);
2398
+ if (!next) return null;
2399
+ const running = new Date(next.startTime).getTime() <= Date.now();
2400
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2401
+ className: "rv:flex rv:flex-wrap rv:items-center rv:justify-between rv:gap-2",
2402
+ "data-cy": "reservations-next",
2403
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2404
+ className: "rv:flex rv:flex-col rv:gap-1",
2405
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2406
+ className: "rv:text-sm rv:font-medium",
2407
+ children: running ? t("card.current") : t("card.next")
2408
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2409
+ className: "rv:flex rv:items-center rv:gap-2 rv:text-sm",
2410
+ children: [format.range(next.startTime, next.endTime), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusChip, { status: next.status })]
2411
+ })]
2412
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2413
+ className: "rv:flex rv:gap-2",
2414
+ children: [next.canEndEarly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
2415
+ size: "sm",
2416
+ variant: "secondary",
2417
+ onPress: () => onAsk("end-early", next),
2418
+ children: t("actions.end-early.label")
2419
+ }), next.canCancel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$6, {
2420
+ size: "sm",
2421
+ variant: "tertiary",
2422
+ onPress: () => onAsk("cancel", next),
2423
+ children: t("actions.cancel.label")
2424
+ })]
2425
+ })]
2426
+ });
2427
+ }
2428
+ //#endregion
2429
+ //#region frontend/src/overview/ReservationsCard.tsx
2430
+ var { Button: Button$5, StatusAlert: StatusAlert$5, StatusDialog: StatusDialog$2 } = await importShared("@attraccess/plugins-frontend-ui");
2431
+ var { Chip, ToggleButton, ToggleButtonGroup } = await importShared("@heroui/react");
2432
+ var { CalendarCheckIcon: CalendarCheckIcon$1, ChevronLeftIcon, ChevronRightIcon } = await importShared("lucide-react");
2433
+ var { useEffect: useEffect$3, useMemo: useMemo$3, useRef, useState: useState$5 } = await importShared("react");
2434
+ /** Flat section like the host's other overview cards; it must not be split across the page columns. */
2435
+ function Section({ actions, children }) {
2436
+ const { t } = useReservationsTranslations();
2437
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2438
+ className: "rv:w-full rv:break-inside-avoid rv:mb-6",
2439
+ "data-cy": "reservations-card",
2440
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
2441
+ className: "rv:flex rv:flex-wrap rv:items-center rv:justify-between rv:gap-2 rv:border-b rv:border-separator rv:pb-2 rv:mb-3",
2442
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2443
+ className: "rv:flex rv:items-center rv:gap-2 rv:text-accent",
2444
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarCheckIcon$1, { className: "rv:size-4" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
2445
+ className: "rv:text-xs rv:font-semibold rv:uppercase rv:tracking-wider",
2446
+ children: t("card.title")
2447
+ })]
2448
+ }), actions && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2449
+ className: "rv:flex rv:flex-wrap rv:items-center rv:gap-2",
2450
+ children: actions
2451
+ })]
2452
+ }), children]
2453
+ });
2454
+ }
2455
+ /**
2456
+ * `resource.overview` slot. Renders nothing until the first answer says reservations are enabled
2457
+ * (so the card never flashes on resources without them), and nothing while they are disabled.
2458
+ */
2459
+ function ReservationsCard({ resourceId }) {
2460
+ const { t } = useReservationsTranslations();
2461
+ const [view, setView] = useState$5("week");
2462
+ const [offset, setOffset] = useState$5(0);
2463
+ const [bookingOpen, setBookingOpen] = useState$5(false);
2464
+ const [booked, setBooked] = useState$5(null);
2465
+ const [zoneGuess, setZoneGuess] = useState$5(null);
2466
+ const zone = zoneGuess ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
2467
+ const span = view === "week" ? 7 : 1;
2468
+ const first = addLocalDays(useMemo$3(() => localDateOf(/* @__PURE__ */ new Date(), zone), [zone]), offset * span);
2469
+ const days = Array.from({ length: span }, (_, index) => addLocalDays(first, index));
2470
+ const query = useAvailability(resourceId, startOfLocalDay(first, zone), startOfLocalDay(addLocalDays(first, span), zone), true, true);
2471
+ const [lastGood, setLastGood] = useState$5(null);
2472
+ useEffect$3(() => {
2473
+ if (query.data) setLastGood(query.data);
2474
+ }, [query.data]);
2475
+ const availability = query.data ?? lastGood;
2476
+ const shownDays = useRef(days);
2477
+ if (!query.isPlaceholderData) shownDays.current = days;
2478
+ const reportedZone = availability?.timezone;
2479
+ useEffect$3(() => {
2480
+ if (reportedZone) setZoneGuess(reportedZone);
2481
+ }, [reportedZone]);
2482
+ const resourceName = useResourceName(resourceId);
2483
+ const actions = useReservationActions({ timezone: availability?.timezone });
2484
+ const format = useFormatters(availability?.timezone);
2485
+ if (availability?.enabled === false) return null;
2486
+ const failure = query.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2487
+ className: "rv:flex rv:flex-col rv:items-start rv:gap-2",
2488
+ "data-cy": "reservations-load-error",
2489
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$5, {
2490
+ status: "danger",
2491
+ title: t("card.loadFailed"),
2492
+ children: describeError(query.error, t)
2493
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
2494
+ size: "sm",
2495
+ variant: "secondary",
2496
+ onPress: () => void query.refetch(),
2497
+ "data-cy": "reservations-retry",
2498
+ children: t("common.retry")
2499
+ })]
2500
+ }) : null;
2501
+ if (!availability) return failure ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { children: failure }) : null;
2502
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Section, {
2503
+ actions: availability.canBook.allowed ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
2504
+ variant: "primary",
2505
+ onPress: () => setBookingOpen(true),
2506
+ "data-cy": "reservations-reserve",
2507
+ children: t("card.reserve")
2508
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Chip, {
2509
+ size: "sm",
2510
+ "data-cy": "reservations-cannot-book",
2511
+ children: availability.canBook.reason ? describeCode(availability.canBook.reason, t) : t("card.cannotBook")
2512
+ }),
2513
+ children: [
2514
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2515
+ className: "rv:flex rv:flex-col rv:gap-4",
2516
+ children: [
2517
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimezoneHint, { timezone: availability.timezone }),
2518
+ availability.isManager && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2519
+ className: "rv:text-xs rv:text-muted",
2520
+ children: t("card.managerHint")
2521
+ }),
2522
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NextBooking, {
2523
+ resourceId,
2524
+ timezone: availability.timezone,
2525
+ onAsk: actions.ask
2526
+ }),
2527
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2528
+ className: "rv:flex rv:flex-wrap rv:items-center rv:gap-2",
2529
+ children: [
2530
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ToggleButtonGroup, {
2531
+ "aria-label": t("card.view"),
2532
+ size: "sm",
2533
+ selectionMode: "single",
2534
+ disallowEmptySelection: true,
2535
+ selectedKeys: [view],
2536
+ onSelectionChange: (keys) => {
2537
+ setView(keys.has("day") ? "day" : "week");
2538
+ setOffset(0);
2539
+ },
2540
+ "data-cy": "reservations-view",
2541
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleButton, {
2542
+ id: "day",
2543
+ children: t("card.day")
2544
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ToggleButton, {
2545
+ id: "week",
2546
+ children: t("card.week")
2547
+ })]
2548
+ }),
2549
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
2550
+ size: "sm",
2551
+ variant: "tertiary",
2552
+ isIconOnly: true,
2553
+ isDisabled: offset <= 0,
2554
+ onPress: () => setOffset(offset - 1),
2555
+ "aria-label": t("card.previous"),
2556
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronLeftIcon, { className: "rv:w-4 rv:h-4" })
2557
+ }),
2558
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$5, {
2559
+ size: "sm",
2560
+ variant: "tertiary",
2561
+ isIconOnly: true,
2562
+ onPress: () => setOffset(offset + 1),
2563
+ "aria-label": t("card.nextRange"),
2564
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronRightIcon, { className: "rv:w-4 rv:h-4" })
2565
+ })
2566
+ ]
2567
+ }),
2568
+ failure ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2569
+ className: query.isPlaceholderData ? "rv:opacity-50" : void 0,
2570
+ "aria-busy": query.isPlaceholderData,
2571
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvailabilityTimeline, {
2572
+ availability,
2573
+ days: query.isPlaceholderData ? shownDays.current : days
2574
+ })
2575
+ })
2576
+ ]
2577
+ }),
2578
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BookingModal, {
2579
+ resourceId,
2580
+ resourceName,
2581
+ availability,
2582
+ isOpen: bookingOpen,
2583
+ onOpenChange: setBookingOpen,
2584
+ onBooked: setBooked
2585
+ }),
2586
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$2, {
2587
+ isOpen: booked !== null,
2588
+ onClose: () => setBooked(null),
2589
+ status: "success",
2590
+ title: booked?.status === "pending" ? t("booking.requestedTitle") : t("booking.bookedTitle"),
2591
+ "data-cy": "reservations-booked-dialog",
2592
+ children: booked ? t(booked.status === "pending" ? "booking.requestedBody" : "booking.bookedBody", { range: format.range(booked.startTime, booked.endTime) }) : ""
2593
+ }),
2594
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KeepFreeDialog, {
2595
+ resourceId,
2596
+ timezone: availability.timezone,
2597
+ reservations: availability.reservations
2598
+ }),
2599
+ actions.dialogs
2600
+ ]
2601
+ });
2602
+ }
2603
+ //#endregion
2604
+ //#region frontend/src/shared/PagePagination.tsx
2605
+ var { Pagination } = await importShared("@heroui/react");
2606
+ /** Page numbers with ellipses: the first and last page, and the current one with its neighbours. */
2607
+ function pageNumbers(page, total) {
2608
+ if (total <= 7) return Array.from({ length: total }, (_, index) => index + 1);
2609
+ const pages = [1];
2610
+ if (page > 3) pages.push("ellipsis");
2611
+ for (let entry = Math.max(2, page - 1); entry <= Math.min(total - 1, page + 1); entry++) pages.push(entry);
2612
+ if (page < total - 2) pages.push("ellipsis");
2613
+ pages.push(total);
2614
+ return pages;
2615
+ }
2616
+ /** HeroUI pagination for the plugin's lists; hidden while everything fits on one page. */
2617
+ function PagePagination({ page, total, onChange }) {
2618
+ const { t } = useReservationsTranslations();
2619
+ if (total <= 1) return null;
2620
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination, {
2621
+ "aria-label": t("common.pagination"),
2622
+ "data-cy": "reservations-pagination",
2623
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Pagination.Content, { children: [
2624
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.Previous, {
2625
+ "aria-label": t("common.previousPage"),
2626
+ isDisabled: page <= 1,
2627
+ onPress: () => onChange(page - 1),
2628
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.PreviousIcon, {})
2629
+ }) }),
2630
+ pageNumbers(page, total).map((entry, index) => entry === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.Ellipsis, {}) }, `ellipsis-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.Link, {
2631
+ isActive: entry === page,
2632
+ onPress: () => onChange(entry),
2633
+ children: entry
2634
+ }) }, entry)),
2635
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.Next, {
2636
+ "aria-label": t("common.nextPage"),
2637
+ isDisabled: page >= total,
2638
+ onPress: () => onChange(page + 1),
2639
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pagination.NextIcon, {})
2640
+ }) })
2641
+ ] })
2642
+ });
2643
+ }
2644
+ //#endregion
2645
+ //#region frontend/src/shared/ReservationsTable.tsx
2646
+ var { Button: Button$4, EmptyState, StatusAlert: StatusAlert$4, TableDataLoadingIndicator: TableDataLoadingIndicator$1 } = await importShared("@attraccess/plugins-frontend-ui");
2647
+ var { Link: Link$1 } = await importShared("@heroui/react");
2648
+ /**
2649
+ * Shared bookings list; each row offers exactly the actions the API says are possible. Rows wrap
2650
+ * instead of scrolling, so every action stays reachable on a phone.
2651
+ */
2652
+ function ReservationsTable({ items, timezone, ariaLabel, showUser, isPending, error, onRetry, onAction }) {
2653
+ const { t } = useReservationsTranslations();
2654
+ const format = useFormatters(timezone);
2655
+ if (error) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2656
+ className: "rv:flex rv:flex-col rv:items-start rv:gap-3",
2657
+ "data-cy": "reservations-list-error",
2658
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$4, {
2659
+ status: "danger",
2660
+ title: t("table.loadFailed"),
2661
+ children: describeError(error, t)
2662
+ }), onRetry && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
2663
+ size: "sm",
2664
+ variant: "secondary",
2665
+ onPress: onRetry,
2666
+ children: t("common.retry")
2667
+ })]
2668
+ });
2669
+ if (isPending) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableDataLoadingIndicator$1, { label: t("common.loading") });
2670
+ if (items.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, { message: t("table.empty") });
2671
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
2672
+ "aria-label": ariaLabel,
2673
+ className: "rv:flex rv:flex-col rv:divide-y rv:divide-separator",
2674
+ children: items.map((item) => {
2675
+ const reason = item.status === "rejected" ? item.decisionReason ?? item.cancelReason : item.cancelReason;
2676
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
2677
+ className: "rv:flex rv:flex-wrap rv:items-start rv:justify-between rv:gap-x-4 rv:gap-y-2 rv:py-3",
2678
+ "data-cy": `reservations-row-${item.id}`,
2679
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2680
+ className: "rv:flex rv:min-w-0 rv:flex-col rv:gap-1",
2681
+ children: [
2682
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2683
+ className: "rv:flex rv:flex-wrap rv:items-center rv:gap-2",
2684
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link$1, {
2685
+ href: `/reservations/${item.id}`,
2686
+ className: "rv:font-medium",
2687
+ children: item.resourceName ?? `#${item.resourceId}`
2688
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusChip, { status: item.status })]
2689
+ }),
2690
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2691
+ className: "rv:text-sm",
2692
+ children: format.range(item.startTime, item.endTime)
2693
+ }),
2694
+ showUser && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2695
+ className: "rv:text-sm rv:text-muted",
2696
+ children: item.userName ?? "–"
2697
+ }),
2698
+ reason && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2699
+ className: "rv:text-sm rv:text-muted",
2700
+ children: t("table.reason", { reason })
2701
+ })
2702
+ ]
2703
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2704
+ className: "rv:flex rv:flex-wrap rv:gap-2",
2705
+ children: [
2706
+ item.canDecide && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
2707
+ size: "sm",
2708
+ variant: "primary",
2709
+ onPress: () => onAction("approve", item),
2710
+ children: t("actions.approve.label")
2711
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
2712
+ size: "sm",
2713
+ variant: "secondary",
2714
+ onPress: () => onAction("reject", item),
2715
+ children: t("actions.reject.label")
2716
+ })] }),
2717
+ item.canKeep && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
2718
+ size: "sm",
2719
+ variant: "secondary",
2720
+ onPress: () => onAction("keep", item),
2721
+ children: t("actions.keep.label")
2722
+ }),
2723
+ item.canEndEarly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
2724
+ size: "sm",
2725
+ variant: "secondary",
2726
+ onPress: () => onAction("end-early", item),
2727
+ children: t("actions.end-early.label")
2728
+ }),
2729
+ item.canCancel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$4, {
2730
+ size: "sm",
2731
+ variant: "tertiary",
2732
+ onPress: () => onAction("cancel", item),
2733
+ children: t("actions.cancel.label")
2734
+ })
2735
+ ]
2736
+ })]
2737
+ }, item.id);
2738
+ })
2739
+ });
2740
+ }
2741
+ //#endregion
2742
+ //#region frontend/src/pages/ResourceFilter.tsx
2743
+ var { useDebounce } = await importShared("@attraccess/plugins-frontend-ui");
2744
+ var { Autocomplete, Label: Label$1, ListBox: ListBox$1, SearchField } = await importShared("@heroui/react");
2745
+ var { useQuery: useQuery$2 } = await importShared("@tanstack/react-query");
2746
+ var { useState: useState$4 } = await importShared("react");
2747
+ var ALL$1 = "all";
2748
+ /**
2749
+ * Single-resource filter of the manage page. The host searches its resources as the user types, so
2750
+ * every resource is reachable, not just the first page; the chosen one stays shown when a later
2751
+ * search no longer lists it.
2752
+ */
2753
+ function ResourceFilter({ value, onChange }) {
2754
+ const { t } = useReservationsTranslations();
2755
+ const [search, setSearch] = useState$4("");
2756
+ const term = useDebounce(search.trim(), 250);
2757
+ const results = useQuery$2({
2758
+ queryKey: [
2759
+ "reservations",
2760
+ "host-resources",
2761
+ term
2762
+ ],
2763
+ queryFn: () => searchHostResources(term),
2764
+ staleTime: 6e4,
2765
+ placeholderData: (previous) => previous
2766
+ });
2767
+ const label = t("manage.filters.resource");
2768
+ const allLabel = t("manage.filters.allResources");
2769
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Autocomplete, {
2770
+ value: value ? String(value.id) : ALL$1,
2771
+ onChange: (key) => {
2772
+ const id = Number(key);
2773
+ onChange((results.data ?? []).find((entry) => entry.id === id) ?? null);
2774
+ },
2775
+ fullWidth: true,
2776
+ "data-cy": "reservations-manage-resource",
2777
+ children: [
2778
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label$1, { children: label }),
2779
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Autocomplete.Trigger, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Autocomplete.Value, { children: () => value?.name ?? allLabel }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Autocomplete.Indicator, {})] }),
2780
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Autocomplete.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Autocomplete.Filter, {
2781
+ inputValue: search,
2782
+ onInputChange: setSearch,
2783
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchField, {
2784
+ autoFocus: true,
2785
+ "aria-label": t("manage.filters.searchResources"),
2786
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SearchField.Group, { children: [
2787
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchField.SearchIcon, {}),
2788
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchField.Input, { placeholder: t("manage.filters.searchResources") }),
2789
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchField.ClearButton, {})
2790
+ ] })
2791
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ListBox$1, {
2792
+ "aria-label": label,
2793
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ListBox$1.Item, {
2794
+ id: ALL$1,
2795
+ textValue: allLabel,
2796
+ children: [allLabel, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListBox$1.ItemIndicator, {})]
2797
+ }), (results.data ?? []).map((resource) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ListBox$1.Item, {
2798
+ id: String(resource.id),
2799
+ textValue: resource.name,
2800
+ children: [resource.name, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListBox$1.ItemIndicator, {})]
2801
+ }, resource.id))]
2802
+ })]
2803
+ }) })
2804
+ ]
2805
+ });
2806
+ }
2807
+ //#endregion
2808
+ //#region frontend/src/pages/ManagePage.tsx
2809
+ var { PageHeader: PageHeader$2, StatusAlert: StatusAlert$3 } = await importShared("@attraccess/plugins-frontend-ui");
2810
+ var { Card: Card$2 } = await importShared("@heroui/react");
2811
+ var { useMemo: useMemo$2, useState: useState$3 } = await importShared("react");
2812
+ var STATUSES = [
2813
+ "pending",
2814
+ "confirmed",
2815
+ "rejected",
2816
+ "cancelled",
2817
+ "expired",
2818
+ "no_show",
2819
+ "completed"
2820
+ ];
2821
+ var ALL = "all";
2822
+ function ManagePage() {
2823
+ const { t } = useReservationsTranslations();
2824
+ const timezone = usePluginTimezone();
2825
+ const zone = timezone ?? browserTimeZone();
2826
+ const actions = useReservationActions({ timezone });
2827
+ const [resource, setResource] = useState$3(null);
2828
+ const [status, setStatus] = useState$3(ALL);
2829
+ const [fromKey, setFromKey] = useState$3("");
2830
+ const [toKey, setToKey] = useState$3("");
2831
+ const [page, setPage] = useState$3(1);
2832
+ const filter = useMemo$2(() => {
2833
+ const from = fromDateKey(fromKey);
2834
+ const to = fromDateKey(toKey);
2835
+ return {
2836
+ page,
2837
+ resourceId: resource?.id,
2838
+ status: status === ALL ? void 0 : status,
2839
+ from: from ? startOfLocalDay(from, zone).toISOString() : void 0,
2840
+ to: to ? startOfLocalDay(addLocalDays(to, 1), zone).toISOString() : void 0
2841
+ };
2842
+ }, [
2843
+ page,
2844
+ resource,
2845
+ status,
2846
+ fromKey,
2847
+ toKey,
2848
+ zone
2849
+ ]);
2850
+ const pending = useManagedReservations({
2851
+ page: 1,
2852
+ status: "pending"
2853
+ });
2854
+ const list = useManagedReservations(filter);
2855
+ const totalPages = list.data ? Math.max(1, Math.ceil(list.data.total / list.data.pageSize)) : 1;
2856
+ const resetPage = (setter) => (value) => {
2857
+ setter(value);
2858
+ setPage(1);
2859
+ };
2860
+ if (pending.error instanceof ReservationsApiError && pending.error.status === 403) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2861
+ className: "rv:flex rv:flex-col rv:gap-6",
2862
+ "data-cy": "reservations-manage-denied",
2863
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader$2, {
2864
+ title: t("manage.title"),
2865
+ backTo: "/reservations",
2866
+ noMargin: true
2867
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$3, {
2868
+ status: "warning",
2869
+ title: t("manage.denied")
2870
+ })]
2871
+ });
2872
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2873
+ className: "rv:flex rv:flex-col rv:gap-6",
2874
+ "data-cy": "reservations-manage-page",
2875
+ children: [
2876
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader$2, {
2877
+ title: t("manage.title"),
2878
+ subtitle: t("manage.subtitle"),
2879
+ backTo: "/reservations",
2880
+ noMargin: true
2881
+ }),
2882
+ timezone && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimezoneHint, { timezone }),
2883
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$2, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$2.Header, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$2.Title, { children: t("manage.pending") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$2.Description, { children: t("manage.pendingHint") })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$2.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReservationsTable, {
2884
+ items: pending.data?.items ?? [],
2885
+ timezone,
2886
+ ariaLabel: t("manage.pending"),
2887
+ ...listState(pending, timezone),
2888
+ showUser: true,
2889
+ onAction: actions.ask
2890
+ }) })] }),
2891
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2892
+ className: "rv:flex rv:flex-col rv:gap-4",
2893
+ "aria-labelledby": "reservations-manage-all-title",
2894
+ children: [
2895
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
2896
+ id: "reservations-manage-all-title",
2897
+ className: "rv:text-base rv:font-semibold",
2898
+ children: t("manage.all")
2899
+ }),
2900
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2901
+ className: "rv:grid rv:gap-3 rv:sm:grid-cols-2 rv:lg:grid-cols-4",
2902
+ children: [
2903
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResourceFilter, {
2904
+ value: resource,
2905
+ onChange: resetPage(setResource)
2906
+ }),
2907
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectField, {
2908
+ label: t("manage.filters.status"),
2909
+ value: status,
2910
+ onChange: resetPage(setStatus),
2911
+ options: [{
2912
+ key: ALL,
2913
+ label: t("manage.filters.allStatuses")
2914
+ }, ...STATUSES.map((entry) => ({
2915
+ key: entry,
2916
+ label: t(`status.${entry}`)
2917
+ }))]
2918
+ }),
2919
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextInput, {
2920
+ label: t("manage.filters.from"),
2921
+ type: "date",
2922
+ value: fromKey,
2923
+ onChange: resetPage(setFromKey)
2924
+ }),
2925
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextInput, {
2926
+ label: t("manage.filters.to"),
2927
+ type: "date",
2928
+ value: toKey,
2929
+ onChange: resetPage(setToKey)
2930
+ })
2931
+ ]
2932
+ }),
2933
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReservationsTable, {
2934
+ items: list.data?.items ?? [],
2935
+ timezone,
2936
+ ariaLabel: t("manage.all"),
2937
+ ...listState(list, timezone),
2938
+ showUser: true,
2939
+ onAction: actions.ask
2940
+ }),
2941
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PagePagination, {
2942
+ page,
2943
+ total: totalPages,
2944
+ onChange: setPage
2945
+ })
2946
+ ]
2947
+ }),
2948
+ actions.dialogs
2949
+ ]
2950
+ });
2951
+ }
2952
+ //#endregion
2953
+ //#region frontend/src/pages/MyReservationsPage.tsx
2954
+ var { PageHeader: PageHeader$1 } = await importShared("@attraccess/plugins-frontend-ui");
2955
+ var { Card: Card$1, Link } = await importShared("@heroui/react");
2956
+ function MyReservationsPage() {
2957
+ const { t } = useReservationsTranslations();
2958
+ const timezone = usePluginTimezone();
2959
+ const upcoming = useMyReservations("upcoming");
2960
+ const past = useMyReservations("past");
2961
+ const actions = useReservationActions({ timezone });
2962
+ const manager = useIsManagerAnywhere();
2963
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2964
+ className: "rv:flex rv:flex-col rv:gap-6",
2965
+ "data-cy": "reservations-my-page",
2966
+ children: [
2967
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader$1, {
2968
+ title: t("my.title"),
2969
+ subtitle: t("my.subtitle"),
2970
+ noMargin: true
2971
+ }),
2972
+ timezone && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimezoneHint, { timezone }),
2973
+ manager && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
2974
+ href: "/reservations/manage",
2975
+ "data-cy": "reservations-manage-link",
2976
+ children: t("my.manageLink")
2977
+ }) }),
2978
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Title, { children: t("my.upcoming") }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReservationsTable, {
2979
+ items: upcoming.data ?? [],
2980
+ timezone,
2981
+ ariaLabel: t("my.upcoming"),
2982
+ ...listState(upcoming, timezone),
2983
+ onAction: actions.ask
2984
+ }) })] }),
2985
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Title, { children: t("my.past") }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReservationsTable, {
2986
+ items: past.data ?? [],
2987
+ timezone,
2988
+ ariaLabel: t("my.past"),
2989
+ ...listState(past, timezone),
2990
+ onAction: actions.ask
2991
+ }) })] }),
2992
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card$1, {
2993
+ "data-cy": "reservations-my-feeds",
2994
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Title, { children: t("feeds.title") }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card$1.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcalFeeds, {}) })]
2995
+ }),
2996
+ actions.dialogs
2997
+ ]
2998
+ });
2999
+ }
3000
+ //#endregion
3001
+ //#region frontend/src/pages/ReservationDeepLinkPage.tsx
3002
+ var { Button: Button$3, PageHeader, StatusAlert: StatusAlert$2, TableDataLoadingIndicator } = await importShared("@attraccess/plugins-frontend-ui");
3003
+ var { Card } = await importShared("@heroui/react");
3004
+ var { useEffect: useEffect$2, useState: useState$2 } = await importShared("react");
3005
+ var { useNavigate, useParams, useSearchParams } = await importShared("react-router-dom");
3006
+ /**
3007
+ * `/reservations/:id?action=keep|cancel`, the target of mail links. Opening it only reads the
3008
+ * booking; the requested change happens after an explicit confirmation in a dialog.
3009
+ */
3010
+ function ReservationDeepLinkPage() {
3011
+ const { t } = useReservationsTranslations();
3012
+ const navigate = useNavigate();
3013
+ const params = useParams();
3014
+ const [search] = useSearchParams();
3015
+ const id = Number(params.id);
3016
+ const validId = Number.isInteger(id) && id > 0;
3017
+ const requestedParam = search.get("action");
3018
+ const requested = requestedParam === "keep" || requestedParam === "cancel" ? requestedParam : null;
3019
+ const timezone = usePluginTimezone();
3020
+ const format = useFormatters(timezone);
3021
+ const query = useReservation(id);
3022
+ const actions = useReservationActions({
3023
+ timezone,
3024
+ onDone: () => navigate("/reservations")
3025
+ });
3026
+ const [prompted, setPrompted] = useState$2(false);
3027
+ const reservation = query.data;
3028
+ const possible = reservation !== void 0 && (requested === "keep" ? reservation.canKeep : reservation.canCancel);
3029
+ useEffect$2(() => {
3030
+ if (!reservation || !requested || !possible || prompted) return;
3031
+ actions.ask(requested, reservation);
3032
+ setPrompted(true);
3033
+ }, [
3034
+ reservation,
3035
+ requested,
3036
+ possible,
3037
+ prompted,
3038
+ actions
3039
+ ]);
3040
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3041
+ className: "rv:flex rv:flex-col rv:gap-6",
3042
+ "data-cy": "reservations-detail-page",
3043
+ children: [
3044
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
3045
+ title: t("detail.title"),
3046
+ backTo: "/reservations",
3047
+ noMargin: true
3048
+ }),
3049
+ timezone && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimezoneHint, { timezone }),
3050
+ (query.isError || !validId) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$2, {
3051
+ status: "danger",
3052
+ title: t("detail.loadFailed"),
3053
+ children: validId ? describeError(query.error, t) : t("errors.RESERVATION_NOT_FOUND")
3054
+ }),
3055
+ validId && !query.isError && (!reservation || !timezone) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableDataLoadingIndicator, { label: t("common.loading") }),
3056
+ reservation && timezone && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card.Header, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card.Title, { children: reservation.resourceName ?? `#${reservation.resourceId}` }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card.Description, { children: format.range(reservation.startTime, reservation.endTime) })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card.Content, {
3057
+ className: "rv:flex rv:flex-col rv:gap-3",
3058
+ children: [
3059
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusChip, { status: reservation.status }),
3060
+ reservation.userName && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
3061
+ className: "rv:text-sm",
3062
+ children: t("detail.holder", { name: reservation.userName })
3063
+ }),
3064
+ reservation.note && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
3065
+ className: "rv:text-sm",
3066
+ children: reservation.note
3067
+ }),
3068
+ requested && !possible && !prompted && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$2, {
3069
+ status: "warning",
3070
+ children: requested === "keep" ? t("detail.cannotKeep") : t("detail.cannotCancel")
3071
+ }),
3072
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3073
+ className: "rv:flex rv:flex-wrap rv:gap-2",
3074
+ children: [reservation.canKeep && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
3075
+ variant: "secondary",
3076
+ onPress: () => actions.ask("keep", reservation),
3077
+ children: t("actions.keep.label")
3078
+ }), reservation.canCancel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$3, {
3079
+ variant: "secondary",
3080
+ onPress: () => actions.ask("cancel", reservation),
3081
+ children: t("actions.cancel.label")
3082
+ })]
3083
+ })
3084
+ ]
3085
+ })] }),
3086
+ actions.dialogs
3087
+ ]
3088
+ });
3089
+ }
3090
+ //#endregion
3091
+ //#region frontend/src/settings/AdminTimezoneSettings.tsx
3092
+ var { Button: Button$2, StatusAlert: StatusAlert$1, StatusDialog: StatusDialog$1 } = await importShared("@attraccess/plugins-frontend-ui");
3093
+ var { ListBox, ListBoxItem, Spinner: Spinner$1 } = await importShared("@heroui/react");
3094
+ var { useMutation: useMutation$1, useQuery: useQuery$1 } = await importShared("@tanstack/react-query");
3095
+ var { useEffect: useEffect$1, useMemo: useMemo$1, useState: useState$1 } = await importShared("react");
3096
+ var MAX_LISTED = 200;
3097
+ function supportedZones() {
3098
+ try {
3099
+ return Intl.supportedValuesOf("timeZone");
3100
+ } catch {
3101
+ return ["UTC"];
3102
+ }
3103
+ }
3104
+ /** `admin.settings` slot: the timezone used for bookable hours, the time grid, mails and iCal. */
3105
+ function AdminTimezoneSettings() {
3106
+ const { t } = useReservationsTranslations();
3107
+ const invalidate = useInvalidateReservations();
3108
+ const query = useQuery$1({
3109
+ queryKey: ["reservations", "global-settings"],
3110
+ queryFn: getGlobalSettings,
3111
+ retry: false
3112
+ });
3113
+ const [timezone, setTimezone] = useState$1("");
3114
+ const [filter, setFilter] = useState$1("");
3115
+ const [saved, setSaved] = useState$1(false);
3116
+ const [error, setError] = useState$1(null);
3117
+ const zones = useMemo$1(() => {
3118
+ const all = supportedZones();
3119
+ return all.includes("UTC") ? all : ["UTC", ...all];
3120
+ }, []);
3121
+ useEffect$1(() => {
3122
+ if (query.data) setTimezone(query.data.timezone);
3123
+ }, [query.data]);
3124
+ const save = useMutation$1({
3125
+ mutationFn: () => updateGlobalSettings(timezone),
3126
+ onSuccess: async () => {
3127
+ setSaved(true);
3128
+ await invalidate();
3129
+ await query.refetch();
3130
+ },
3131
+ onError: (failure) => setError(describeError(failure, t))
3132
+ });
3133
+ const savedZone = query.data?.timezone;
3134
+ const allMatches = useMemo$1(() => {
3135
+ const needle = filter.trim().toLowerCase();
3136
+ const found = needle ? zones.filter((zone) => zone.toLowerCase().includes(needle)) : zones;
3137
+ return savedZone && found.includes(savedZone) ? [savedZone, ...found.filter((zone) => zone !== savedZone)] : found;
3138
+ }, [
3139
+ zones,
3140
+ filter,
3141
+ savedZone
3142
+ ]);
3143
+ const matches = useMemo$1(() => allMatches.slice(0, MAX_LISTED), [allMatches]);
3144
+ if (query.error instanceof ReservationsApiError && query.error.status === 403) return null;
3145
+ if (query.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3146
+ className: "rv:flex rv:flex-col rv:items-start rv:gap-2",
3147
+ "data-cy": "reservations-admin-load-error",
3148
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert$1, {
3149
+ status: "danger",
3150
+ title: t("admin.loadFailed"),
3151
+ children: describeError(query.error, t)
3152
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
3153
+ size: "sm",
3154
+ variant: "secondary",
3155
+ onPress: () => void query.refetch(),
3156
+ children: t("common.retry")
3157
+ })]
3158
+ });
3159
+ if (!query.data) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
3160
+ className: "rv:flex rv:justify-center rv:py-4",
3161
+ "data-cy": "reservations-admin-loading",
3162
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner$1, {
3163
+ size: "sm",
3164
+ "aria-label": t("common.loading")
3165
+ })
3166
+ });
3167
+ const valid = isValidTimeZone(timezone);
3168
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3169
+ className: "rv:flex rv:flex-col rv:gap-3",
3170
+ "data-cy": "reservations-admin-settings",
3171
+ children: [
3172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
3173
+ className: "rv:text-sm rv:text-muted",
3174
+ children: t("admin.description")
3175
+ }),
3176
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
3177
+ className: "rv:text-sm",
3178
+ children: [
3179
+ t("admin.current"),
3180
+ ": ",
3181
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
3182
+ "data-cy": "reservations-admin-current",
3183
+ children: query.data.timezone
3184
+ }),
3185
+ " (",
3186
+ t("admin.default", { timezone: query.data.defaultTimezone }),
3187
+ ")"
3188
+ ]
3189
+ }),
3190
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TextInput, {
3191
+ label: t("admin.search"),
3192
+ value: filter,
3193
+ onChange: setFilter,
3194
+ placeholder: t("admin.searchPlaceholder"),
3195
+ description: allMatches.length > matches.length ? t("admin.matchesTruncated", {
3196
+ total: allMatches.length,
3197
+ shown: matches.length
3198
+ }) : t("admin.matches", { count: allMatches.length }),
3199
+ "data-cy": "reservations-admin-search"
3200
+ }),
3201
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListBox, {
3202
+ "aria-label": t("admin.list"),
3203
+ selectionMode: "single",
3204
+ selectedKeys: /* @__PURE__ */ new Set([timezone]),
3205
+ onSelectionChange: (keys) => {
3206
+ const [first] = Array.from(keys);
3207
+ if (first) setTimezone(String(first));
3208
+ },
3209
+ className: "rv:max-h-64 rv:overflow-y-auto",
3210
+ children: matches.map((zone) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListBoxItem, {
3211
+ id: zone,
3212
+ textValue: zone,
3213
+ children: zone
3214
+ }, zone))
3215
+ }),
3216
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$2, {
3217
+ variant: "primary",
3218
+ isDisabled: !valid || timezone === query.data.timezone,
3219
+ isPending: save.isPending,
3220
+ onPress: () => save.mutate(),
3221
+ "data-cy": "reservations-admin-save",
3222
+ children: t("common.save")
3223
+ }) }),
3224
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$1, {
3225
+ isOpen: saved,
3226
+ onClose: () => setSaved(false),
3227
+ status: "success",
3228
+ title: t("admin.saved"),
3229
+ children: t("admin.savedBody", { timezone: query.data.timezone })
3230
+ }),
3231
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog$1, {
3232
+ isOpen: error !== null,
3233
+ onClose: () => setError(null),
3234
+ status: "error",
3235
+ title: t("admin.failed"),
3236
+ children: error ?? ""
3237
+ })
3238
+ ]
3239
+ });
3240
+ }
3241
+ //#endregion
3242
+ //#region frontend/src/lib/validation.ts
3243
+ var INTEGER_RANGES = {
3244
+ timeStepMinutes: [5, 240],
3245
+ minDurationMinutes: [1, 1440],
3246
+ maxDurationMinutes: [1, 10080],
3247
+ maxAdvanceDays: [1, 730],
3248
+ minLeadMinutes: [0, 10080],
3249
+ bufferBeforeMinutes: [0, 1440],
3250
+ bufferAfterMinutes: [0, 1440],
3251
+ maxActiveBookingsPerUser: [0, 100],
3252
+ confirmWindowMinutes: [0, 1440],
3253
+ checkInGraceMinutes: [1, 240],
3254
+ earlyCheckInMinutes: [0, 240],
3255
+ handoverReminderMinutes: [0, 1440]
3256
+ };
3257
+ var HM = /^(?:[01]\d|2[0-3]):[0-5]\d$|^24:00$/;
3258
+ /** Field -> i18n key under `settings.validation`; empty when the values are valid. */
3259
+ function validateSettingsForm(values) {
3260
+ const errors = {};
3261
+ for (const [field, [min, max]] of Object.entries(INTEGER_RANGES)) {
3262
+ const value = values[field];
3263
+ if (!Number.isInteger(value) || value < min || value > max) errors[field] = "range";
3264
+ }
3265
+ if (!errors.timeStepMinutes && 1440 % values.timeStepMinutes !== 0) errors.timeStepMinutes = "stepDividesDay";
3266
+ if (Object.keys(errors).length === 0) {
3267
+ const step = values.timeStepMinutes;
3268
+ if (values.minDurationMinutes % step !== 0) errors.minDurationMinutes = "multipleOfStep";
3269
+ if (values.maxDurationMinutes % step !== 0) errors.maxDurationMinutes = "multipleOfStep";
3270
+ else if (values.maxDurationMinutes < values.minDurationMinutes) errors.maxDurationMinutes = "maxBelowMin";
3271
+ }
3272
+ Object.assign(errors, validateBookableHoursForm(values.bookableHours));
3273
+ return errors;
3274
+ }
3275
+ function validateBookableHoursForm(hours) {
3276
+ const errors = {};
3277
+ for (const day of WEEKDAYS) {
3278
+ const ranges = hours[day] ?? [];
3279
+ if (ranges.length > 8) errors[`bookableHours.${day}`] = "tooManyRanges";
3280
+ const parsed = [];
3281
+ for (const range of ranges) {
3282
+ if (!HM.test(range.start) || !HM.test(range.end) || range.start === "24:00") {
3283
+ errors[`bookableHours.${day}`] = "timeFormat";
3284
+ break;
3285
+ }
3286
+ if (parseHm(range.start) >= parseHm(range.end)) {
3287
+ errors[`bookableHours.${day}`] = "endAfterStart";
3288
+ break;
3289
+ }
3290
+ parsed.push([parseHm(range.start), parseHm(range.end)]);
3291
+ }
3292
+ if (!errors[`bookableHours.${day}`]) {
3293
+ parsed.sort((a, b) => a[0] - b[0]);
3294
+ for (let i = 1; i < parsed.length; i += 1) if (parsed[i][0] < parsed[i - 1][1]) errors[`bookableHours.${day}`] = "overlap";
3295
+ }
3296
+ }
3297
+ return errors;
3298
+ }
3299
+ //#endregion
3300
+ //#region frontend/src/settings/BookableHoursEditor.tsx
3301
+ var { Button: Button$1 } = await importShared("@attraccess/plugins-frontend-ui");
3302
+ var { Input, Label, TextField } = await importShared("@heroui/react");
3303
+ var { PlusIcon, Trash2Icon } = await importShared("lucide-react");
3304
+ var DISPLAY_ORDER = [
3305
+ "mon",
3306
+ "tue",
3307
+ "wed",
3308
+ "thu",
3309
+ "fri",
3310
+ "sat",
3311
+ "sun"
3312
+ ];
3313
+ /** Per weekday time ranges; no range anywhere means the resource is bookable around the clock. */
3314
+ function BookableHoursEditor({ value, onChange, errors }) {
3315
+ const { t } = useReservationsTranslations();
3316
+ const setDay = (day, ranges) => onChange({
3317
+ ...value,
3318
+ [day]: ranges
3319
+ });
3320
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3321
+ className: "rv:flex rv:min-w-0 rv:flex-col rv:gap-3",
3322
+ "data-cy": "reservations-bookable-hours",
3323
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
3324
+ className: "rv:text-sm rv:text-muted",
3325
+ children: t("settings.hours.description")
3326
+ }), DISPLAY_ORDER.map((day) => {
3327
+ const ranges = value[day] ?? [];
3328
+ const error = errors[`bookableHours.${day}`];
3329
+ const weekday = t(`weekdays.${day}`);
3330
+ const update = (index, patch) => setDay(day, ranges.map((range, i) => i === index ? {
3331
+ ...range,
3332
+ ...patch
3333
+ } : range));
3334
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3335
+ className: "rv:flex rv:flex-col rv:gap-2",
3336
+ children: [
3337
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3338
+ className: "rv:flex rv:flex-wrap rv:items-center rv:gap-2",
3339
+ children: [
3340
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
3341
+ className: "rv:w-28 rv:text-sm rv:font-medium",
3342
+ children: weekday
3343
+ }),
3344
+ ranges.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
3345
+ className: "rv:text-sm rv:text-muted",
3346
+ children: t("settings.hours.allDay")
3347
+ }),
3348
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$1, {
3349
+ size: "sm",
3350
+ variant: "tertiary",
3351
+ isDisabled: ranges.length >= 8,
3352
+ onPress: () => setDay(day, [...ranges, {
3353
+ start: "09:00",
3354
+ end: "17:00"
3355
+ }]),
3356
+ "aria-label": t("settings.hours.addRangeTo", { day: weekday }),
3357
+ "data-cy": `reservations-hours-add-${day}`,
3358
+ children: [
3359
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlusIcon, { size: 14 }),
3360
+ " ",
3361
+ t("settings.hours.addRange")
3362
+ ]
3363
+ })
3364
+ ]
3365
+ }),
3366
+ ranges.map((range, index) => {
3367
+ const where = {
3368
+ day: weekday,
3369
+ index: index + 1
3370
+ };
3371
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3372
+ className: "rv:flex rv:items-end rv:gap-2 rv:pl-2",
3373
+ children: [
3374
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField, {
3375
+ value: range.start,
3376
+ onChange: (start) => update(index, { start }),
3377
+ isInvalid: Boolean(error),
3378
+ className: "rv:min-w-0 rv:flex-1",
3379
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Label, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
3380
+ "aria-hidden": "true",
3381
+ children: t("settings.hours.from")
3382
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
3383
+ className: "rv:sr-only",
3384
+ children: t("settings.hours.fromLabel", where)
3385
+ })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
3386
+ placeholder: "09:00",
3387
+ maxLength: 5,
3388
+ fullWidth: true
3389
+ })]
3390
+ }),
3391
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TextField, {
3392
+ value: range.end,
3393
+ onChange: (end) => update(index, { end }),
3394
+ isInvalid: Boolean(error),
3395
+ className: "rv:min-w-0 rv:flex-1",
3396
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Label, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
3397
+ "aria-hidden": "true",
3398
+ children: t("settings.hours.to")
3399
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
3400
+ className: "rv:sr-only",
3401
+ children: t("settings.hours.toLabel", where)
3402
+ })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
3403
+ placeholder: "17:00",
3404
+ maxLength: 5,
3405
+ fullWidth: true
3406
+ })]
3407
+ }),
3408
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
3409
+ isIconOnly: true,
3410
+ variant: "ghost",
3411
+ className: "rv:shrink-0",
3412
+ "aria-label": t("settings.hours.removeRange", where),
3413
+ onPress: () => setDay(day, ranges.filter((_, i) => i !== index)),
3414
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2Icon, { size: 16 })
3415
+ })
3416
+ ]
3417
+ }, `${day}-${index}`);
3418
+ }),
3419
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
3420
+ className: "rv:pl-2 rv:text-sm rv:text-danger",
3421
+ children: t(`settings.validation.${error}`)
3422
+ })
3423
+ ]
3424
+ }, day);
3425
+ })]
3426
+ });
3427
+ }
3428
+ //#endregion
3429
+ //#region frontend/src/settings/ResourceSettingsForm.tsx
3430
+ var { Button, LabeledSwitch, StatusAlert, StatusDialog } = await importShared("@attraccess/plugins-frontend-ui");
3431
+ var { Fieldset, Spinner } = await importShared("@heroui/react");
3432
+ var { useMutation, useQuery } = await importShared("@tanstack/react-query");
3433
+ var { useEffect, useMemo, useState } = await importShared("react");
3434
+ var toValues = (settings) => {
3435
+ const { resourceId: _resourceId, ...values } = settings;
3436
+ return values;
3437
+ };
3438
+ /** Weekdays without ranges mean the same as absent ones, so they must not count as a change. */
3439
+ var comparable = (values) => JSON.stringify({
3440
+ ...values,
3441
+ bookableHours: Object.fromEntries(Object.entries(values.bookableHours).filter(([, ranges]) => ranges && ranges.length > 0).sort(([a], [b]) => a.localeCompare(b)))
3442
+ });
3443
+ var NUMBER_GROUPS = [
3444
+ {
3445
+ title: "rules",
3446
+ fields: [
3447
+ "timeStepMinutes",
3448
+ "minDurationMinutes",
3449
+ "maxDurationMinutes",
3450
+ "maxAdvanceDays",
3451
+ "minLeadMinutes"
3452
+ ]
3453
+ },
3454
+ {
3455
+ title: "limits",
3456
+ fields: [
3457
+ "bufferBeforeMinutes",
3458
+ "bufferAfterMinutes",
3459
+ "maxActiveBookingsPerUser"
3460
+ ]
3461
+ },
3462
+ {
3463
+ title: "checkIn",
3464
+ fields: [
3465
+ "confirmWindowMinutes",
3466
+ "checkInGraceMinutes",
3467
+ "earlyCheckInMinutes",
3468
+ "handoverReminderMinutes"
3469
+ ]
3470
+ }
3471
+ ];
3472
+ /** `resource.settings` slot. Renders nothing when the API says the user does not manage the resource. */
3473
+ function ResourceSettingsForm({ resourceId }) {
3474
+ const { t } = useReservationsTranslations();
3475
+ const invalidate = useInvalidateReservations();
3476
+ const query = useQuery({
3477
+ queryKey: [
3478
+ "reservations",
3479
+ "settings",
3480
+ resourceId
3481
+ ],
3482
+ queryFn: () => getResourceSettings(resourceId),
3483
+ retry: false,
3484
+ refetchOnWindowFocus: false
3485
+ });
3486
+ const [values, setValues] = useState(null);
3487
+ const [confirmDisable, setConfirmDisable] = useState(null);
3488
+ const [success, setSuccess] = useState(null);
3489
+ const [error, setError] = useState(null);
3490
+ useEffect(() => {
3491
+ if (query.data) setValues(toValues(query.data));
3492
+ }, [query.data]);
3493
+ const errors = useMemo(() => values ? validateSettingsForm(values) : {}, [values]);
3494
+ const dirty = useMemo(() => Boolean(values && query.data && comparable(values) !== comparable(toValues(query.data))), [values, query.data]);
3495
+ const save = useMutation({
3496
+ mutationFn: (cancelFutureBookings) => updateResourceSettings(resourceId, {
3497
+ ...values,
3498
+ cancelFutureBookings
3499
+ }),
3500
+ onSuccess: async (result) => {
3501
+ setConfirmDisable(null);
3502
+ setValues(toValues(result.settings));
3503
+ setSuccess(result.cancelledBookings);
3504
+ await invalidate();
3505
+ await query.refetch();
3506
+ },
3507
+ onError: (failure) => {
3508
+ setConfirmDisable(null);
3509
+ if (failure instanceof ReservationsApiError && failure.code === "FUTURE_BOOKINGS_EXIST") {
3510
+ setConfirmDisable(failure.count ?? 0);
3511
+ return;
3512
+ }
3513
+ setError(describeError(failure, t));
3514
+ }
3515
+ });
3516
+ const checkAndSave = async () => {
3517
+ if (!values || !query.data) return;
3518
+ if (query.data.enabled && !values.enabled) try {
3519
+ const { count } = await getFutureBookingsCount(resourceId);
3520
+ if (count > 0) {
3521
+ setConfirmDisable(count);
3522
+ return;
3523
+ }
3524
+ } catch (failure) {
3525
+ setError(describeError(failure, t));
3526
+ return;
3527
+ }
3528
+ save.mutate(void 0);
3529
+ };
3530
+ if (query.error instanceof ReservationsApiError && query.error.status === 403) return null;
3531
+ if (query.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3532
+ className: "rv:flex rv:flex-col rv:items-start rv:gap-2",
3533
+ "data-cy": "reservations-settings-load-error",
3534
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusAlert, {
3535
+ status: "danger",
3536
+ title: t("settings.loadFailed"),
3537
+ children: describeError(query.error, t)
3538
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
3539
+ size: "sm",
3540
+ variant: "secondary",
3541
+ onPress: () => void query.refetch(),
3542
+ children: t("common.retry")
3543
+ })]
3544
+ });
3545
+ if (!values) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
3546
+ className: "rv:flex rv:justify-center rv:py-4",
3547
+ "data-cy": "reservations-settings-loading",
3548
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {
3549
+ size: "sm",
3550
+ "aria-label": t("common.loading")
3551
+ })
3552
+ });
3553
+ const set = (key, value) => setValues({
3554
+ ...values,
3555
+ [key]: value
3556
+ });
3557
+ const invalid = Object.keys(errors).length > 0;
3558
+ const cancelDisable = () => {
3559
+ setConfirmDisable(null);
3560
+ setValues({
3561
+ ...values,
3562
+ enabled: true
3563
+ });
3564
+ };
3565
+ const whoOptions = [
3566
+ "can-start",
3567
+ "managers-only",
3568
+ "any-user"
3569
+ ].map((key) => ({
3570
+ key,
3571
+ label: t(`settings.whoCanBook.${key}`)
3572
+ }));
3573
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3574
+ className: "rv:flex rv:flex-col rv:gap-6",
3575
+ "data-cy": "reservations-settings",
3576
+ children: [
3577
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3578
+ className: "rv:flex rv:flex-col rv:gap-3",
3579
+ children: [
3580
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabeledSwitch, {
3581
+ isSelected: values.enabled,
3582
+ onChange: (value) => set("enabled", value),
3583
+ "data-cy": "reservations-setting-enabled",
3584
+ children: t("settings.enabled")
3585
+ }),
3586
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabeledSwitch, {
3587
+ isSelected: values.approvalRequired,
3588
+ onChange: (value) => set("approvalRequired", value),
3589
+ children: t("settings.approvalRequired")
3590
+ }),
3591
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectField, {
3592
+ label: t("settings.whoCanBook.label"),
3593
+ value: values.whoCanBook,
3594
+ onChange: (key) => set("whoCanBook", key),
3595
+ options: whoOptions
3596
+ }),
3597
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabeledSwitch, {
3598
+ isSelected: values.checkInEnabled,
3599
+ onChange: (value) => set("checkInEnabled", value),
3600
+ children: t("settings.checkInEnabled")
3601
+ })
3602
+ ]
3603
+ }),
3604
+ NUMBER_GROUPS.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Fieldset, {
3605
+ className: "rv:min-w-0",
3606
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fieldset.Legend, { children: t(`settings.groups.${group.title}`) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
3607
+ className: "rv:grid rv:gap-4 rv:sm:grid-cols-2",
3608
+ children: group.fields.map((field) => {
3609
+ const [min, max] = INTEGER_RANGES[field];
3610
+ const message = errors[field];
3611
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NumberInput, {
3612
+ label: t(`settings.fields.${field}`),
3613
+ value: values[field],
3614
+ onChange: (value) => set(field, value),
3615
+ min,
3616
+ max,
3617
+ description: t(`settings.hints.${field}`, {
3618
+ min,
3619
+ max
3620
+ }),
3621
+ errorMessage: message ? t(`settings.validation.${message}`, {
3622
+ min,
3623
+ max,
3624
+ step: values.timeStepMinutes
3625
+ }) : void 0,
3626
+ "data-cy": `reservations-setting-${field}`
3627
+ }, field);
3628
+ })
3629
+ })]
3630
+ }, group.title)),
3631
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Fieldset, {
3632
+ className: "rv:min-w-0",
3633
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fieldset.Legend, { children: t("settings.groups.hours") }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BookableHoursEditor, {
3634
+ value: values.bookableHours,
3635
+ onChange: (hours) => set("bookableHours", hours),
3636
+ errors
3637
+ })]
3638
+ }),
3639
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
3640
+ variant: "primary",
3641
+ isDisabled: invalid || !dirty,
3642
+ isPending: save.isPending,
3643
+ onPress: () => void checkAndSave(),
3644
+ "data-cy": "reservations-settings-save",
3645
+ children: t("common.save")
3646
+ }) }),
3647
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog, {
3648
+ isOpen: confirmDisable !== null,
3649
+ onClose: cancelDisable,
3650
+ status: "warning",
3651
+ title: t("settings.disableWarning.title"),
3652
+ action: {
3653
+ label: t("settings.disableWarning.confirm", { count: confirmDisable ?? 0 }),
3654
+ onPress: () => save.mutate(true),
3655
+ isPending: save.isPending
3656
+ },
3657
+ "data-cy": "reservations-disable-dialog",
3658
+ children: t("settings.disableWarning.body", { count: confirmDisable ?? 0 })
3659
+ }),
3660
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog, {
3661
+ isOpen: success !== null,
3662
+ onClose: () => setSuccess(null),
3663
+ status: "success",
3664
+ title: t("settings.saved.title"),
3665
+ "data-cy": "reservations-settings-saved",
3666
+ children: success ? t("settings.saved.bodyCancelled", { count: success }) : t("settings.saved.body")
3667
+ }),
3668
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusDialog, {
3669
+ isOpen: error !== null,
3670
+ onClose: () => setError(null),
3671
+ status: "error",
3672
+ title: t("settings.failed"),
3673
+ children: error ?? ""
3674
+ })
3675
+ ]
3676
+ });
3677
+ }
3678
+ //#endregion
3679
+ //#region frontend/src/plugin.tsx
3680
+ var { useTranslationState } = await importShared("@attraccess/plugins-frontend-ui");
3681
+ var { CalendarCheckIcon, CalendarClockIcon } = await importShared("lucide-react");
3682
+ var labels = () => useTranslationState.getState().language === "de" ? de_default : en_default;
3683
+ var ReservationsPlugin = class {
3684
+ constructor() {
3685
+ this.isManager = false;
3686
+ this.authGeneration = 0;
3687
+ this.sidebarListeners = /* @__PURE__ */ new Set();
3688
+ }
3689
+ getPluginName() {
3690
+ return "reservations-plugin@0.1.0";
3691
+ }
3692
+ getDependencies() {
3693
+ return [];
3694
+ }
3695
+ init(store) {
3696
+ this.pluginStore = store;
3697
+ }
3698
+ activate() {}
3699
+ deactivate() {}
3700
+ onApiAuthStateChange(authData) {
3701
+ const user = authData?.user;
3702
+ if (user?.id !== this.authUserId) resetManageAccess();
3703
+ this.authUserId = user?.id;
3704
+ const generation = ++this.authGeneration;
3705
+ const direct = user?.effectivePermissions?.includes("resources.update") ?? false;
3706
+ if (!user || direct) {
3707
+ this.setManager(direct);
3708
+ return;
3709
+ }
3710
+ getManageAccess().then(({ isManager }) => isManager, () => false).then((isManager) => {
3711
+ if (generation === this.authGeneration) this.setManager(isManager);
3712
+ });
3713
+ }
3714
+ /** The host reads the sidebar items again when this changes (it re-reads them on login but not after an async check). */
3715
+ onSidebarItemsChange(listener) {
3716
+ this.sidebarListeners.add(listener);
3717
+ return () => this.sidebarListeners.delete(listener);
3718
+ }
3719
+ setManager(value) {
3720
+ if (value === this.isManager) return;
3721
+ this.isManager = value;
3722
+ this.sidebarListeners.forEach((listener) => listener());
3723
+ }
3724
+ onApiEndpointChange(_endpoint) {}
3725
+ getRoutes() {
3726
+ return [
3727
+ {
3728
+ path: "/reservations",
3729
+ authRequired: true,
3730
+ element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyReservationsPage, {})
3731
+ },
3732
+ {
3733
+ path: "/reservations/manage",
3734
+ authRequired: true,
3735
+ element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ManagePage, {})
3736
+ },
3737
+ {
3738
+ path: "/reservations/:id",
3739
+ authRequired: true,
3740
+ element: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReservationDeepLinkPage, {})
3741
+ }
3742
+ ];
3743
+ }
3744
+ getSidebarItems() {
3745
+ const text = labels().sidebar;
3746
+ const items = [{
3747
+ label: text.my,
3748
+ path: "/reservations",
3749
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarClockIcon, { className: "rv:w-5 rv:h-5" })
3750
+ }];
3751
+ if (this.isManager) items.push({
3752
+ label: text.manage,
3753
+ path: "/reservations/manage",
3754
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarCheckIcon, { className: "rv:w-5 rv:h-5" })
3755
+ });
3756
+ return items;
3757
+ }
3758
+ getSlotContributions() {
3759
+ const text = labels().slots;
3760
+ return [
3761
+ {
3762
+ slotId: RESOURCE_OVERVIEW_SLOT,
3763
+ key: "reservations-overview",
3764
+ render: ({ resourceId }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReservationsCard, { resourceId })
3765
+ },
3766
+ {
3767
+ slotId: RESOURCE_SETTINGS_SLOT,
3768
+ key: "reservations-settings",
3769
+ title: text.settings,
3770
+ render: ({ resourceId }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResourceSettingsForm, { resourceId })
3771
+ },
3772
+ {
3773
+ slotId: ADMIN_SETTINGS_SLOT,
3774
+ key: "reservations-admin",
3775
+ title: text.admin,
3776
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdminTimezoneSettings, {})
3777
+ },
3778
+ {
3779
+ slotId: USER_ACCOUNT_SLOT,
3780
+ key: "reservations-account",
3781
+ title: text.account,
3782
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcalFeeds, {})
3783
+ }
3784
+ ];
3785
+ }
3786
+ };
3787
+ //#endregion
3788
+ export { ReservationsPlugin as default };