tauri-notice-window 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,33 +1,35 @@
1
- import { create as oe } from "zustand";
2
- import { syncTabs as ue } from "zustand-sync";
3
- import ce from "dexie";
4
- import { useCallback as A, useState as x, useEffect as B } from "react";
5
- import { jsx as k, Fragment as de } from "react/jsx-runtime";
6
- const Z = "tauri-notice-config", G = {
1
+ import { create as ge } from "zustand";
2
+ import { syncTabs as ye } from "zustand-sync";
3
+ import be from "dexie";
4
+ import { useCallback as I, useState as E, useEffect as G } from "react";
5
+ import { jsx as A, Fragment as pe } from "react/jsx-runtime";
6
+ const K = "tauri-notice-config", Q = {
7
7
  routePrefix: "/notice",
8
8
  databaseName: "tauri-notice-db",
9
9
  defaultWidth: 400,
10
- defaultHeight: 300
11
- }, Y = () => {
10
+ defaultHeight: 300,
11
+ notFoundUrl: "/404"
12
+ // Default 404 page
13
+ }, X = () => {
12
14
  try {
13
- const t = localStorage.getItem(Z);
15
+ const t = localStorage.getItem(K);
14
16
  if (t)
15
- return { ...G, ...JSON.parse(t) };
17
+ return { ...Q, ...JSON.parse(t) };
16
18
  } catch (t) {
17
19
  console.warn("Failed to load config from localStorage:", t);
18
20
  }
19
- return G;
20
- }, we = (t) => {
21
+ return Q;
22
+ }, _e = (t) => {
21
23
  try {
22
- localStorage.setItem(Z, JSON.stringify(t));
24
+ localStorage.setItem(K, JSON.stringify(t));
23
25
  } catch (e) {
24
26
  console.warn("Failed to save config to localStorage:", e);
25
27
  }
26
- }, Ge = (t) => {
27
- const i = { ...Y(), ...t };
28
- we(i);
29
- }, K = () => Y();
30
- class he extends ce {
28
+ }, He = (t) => {
29
+ const i = { ...X(), ...t };
30
+ _e(i);
31
+ }, ee = () => X();
32
+ class fe extends be {
31
33
  messages;
32
34
  constructor(e) {
33
35
  super(e), this.version(1).stores({
@@ -35,14 +37,14 @@ class he extends ce {
35
37
  });
36
38
  }
37
39
  }
38
- let v = null;
39
- const X = () => {
40
- if (!v) {
41
- const t = K();
42
- v = new he(t.databaseName);
43
- }
44
- return v;
45
- }, h = () => v || X(), ge = async (t) => {
40
+ let D = null;
41
+ const te = () => {
42
+ if (!D) {
43
+ const t = ee();
44
+ D = new fe(t.databaseName);
45
+ }
46
+ return D;
47
+ }, h = () => D || te(), me = async (t) => {
46
48
  const e = {
47
49
  ...t,
48
50
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -52,30 +54,36 @@ const X = () => {
52
54
  queuePosition: 0
53
55
  };
54
56
  await h().messages.put(e);
55
- }, be = async (t) => !!await h().messages.get(t), ye = async (t) => {
57
+ }, ve = async (t) => !!await h().messages.get(t), We = async (t) => {
56
58
  const e = await h().messages.get(t);
57
59
  return e?.isShown === !0 || e?.queueStatus === "shown";
58
- }, pe = async () => await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), _e = async (t, e) => {
60
+ }, Se = async () => await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), De = async (t, e) => {
59
61
  await h().messages.update(t, { queueStatus: e });
60
- }, ee = async (t) => {
62
+ }, ie = async (t) => {
61
63
  await h().messages.update(t, {
62
64
  queueStatus: "shown",
63
65
  isShown: !0
64
66
  });
65
- }, fe = async (t) => {
67
+ }, Ne = async (t) => {
66
68
  await h().messages.update(t, {
67
69
  queueStatus: "hidden"
68
70
  });
69
- }, me = async (t) => await h().messages.get(t), Ue = async (t) => {
71
+ }, ne = async (t) => await h().messages.get(t), Ve = async (t) => {
70
72
  await h().messages.delete(t);
71
- }, ve = async () => {
73
+ try {
74
+ const { useMessageQueueStore: e } = await Promise.resolve().then(() => Pe), { removeFromQueue: i } = e.getState();
75
+ i(t);
76
+ } catch (e) {
77
+ console.warn("Failed to remove message from queue store:", e);
78
+ }
79
+ }, ze = async () => {
72
80
  await h().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
73
- }, We = async (t) => {
81
+ }, Ae = async (t) => {
74
82
  const e = t.map(
75
83
  (i) => h().messages.update(i.id, { queuePosition: i.position })
76
84
  );
77
85
  await Promise.all(e);
78
- }, Se = (t, e) => ({
86
+ }, Oe = (t, e) => ({
79
87
  // Initial state
80
88
  queue: [],
81
89
  currentMessage: null,
@@ -85,11 +93,11 @@ const X = () => {
85
93
  // Enqueue a new message
86
94
  enqueue: async (i) => {
87
95
  const n = e();
88
- if (await ye(i.id)) {
96
+ if (await We(i.id)) {
89
97
  console.log(`Message ${i.id} was already shown, skipping`);
90
98
  return;
91
99
  }
92
- if (await be(i.id) || await ge(i), !n.queue.some((u) => u.id === i.id)) {
100
+ if (await ve(i.id) || await me(i), !n.queue.some((u) => u.id === i.id)) {
93
101
  const u = [...n.queue, i];
94
102
  t({ queue: u }), await e().persistQueue();
95
103
  }
@@ -110,10 +118,14 @@ const X = () => {
110
118
  t({ isProcessing: !1, currentMessage: null });
111
119
  return;
112
120
  }
121
+ if (!await ne(n.id)) {
122
+ console.log(`Message ${n.id} was deleted, skipping to next`), await e().showNext();
123
+ return;
124
+ }
113
125
  t({
114
126
  currentMessage: n,
115
127
  isProcessing: !0
116
- }), await _e(n.id, "showing"), await e().persistQueue();
128
+ }), await De(n.id, "showing"), await e().persistQueue();
117
129
  },
118
130
  // Clear current message and show next
119
131
  clearCurrent: () => {
@@ -138,16 +150,16 @@ const X = () => {
138
150
  initializeFromDatabase: async () => {
139
151
  if (e().initialized) return;
140
152
  t({ initialized: !0 });
141
- const n = await pe();
153
+ const n = await Se();
142
154
  n.length > 0 && (t({ queue: n }), await e().showNext());
143
155
  },
144
156
  // Persist queue to database
145
157
  persistQueue: async () => {
146
- const n = e().queue.map((a, r) => ({
158
+ const n = e().queue.map((a, l) => ({
147
159
  id: a.id,
148
- position: r
160
+ position: l
149
161
  }));
150
- await We(n);
162
+ await Ae(n);
151
163
  },
152
164
  // Clear all messages on logout
153
165
  clearOnLogout: async () => {
@@ -157,7 +169,19 @@ const X = () => {
157
169
  isProcessing: !1,
158
170
  activeWindowIds: [],
159
171
  initialized: !1
160
- }), await ve();
172
+ }), await ze();
173
+ },
174
+ // Remove a specific message from the queue by ID
175
+ removeFromQueue: (i) => {
176
+ const n = e(), a = n.queue.filter((l) => l.id !== i);
177
+ t({ queue: a }), n.currentMessage?.id === i && (async () => {
178
+ try {
179
+ const { closeNoticeWindow: r } = await Promise.resolve().then(() => Fe);
180
+ await r(i);
181
+ } catch (r) {
182
+ console.warn("Failed to close notice window:", r), e().clearCurrent();
183
+ }
184
+ })();
161
185
  },
162
186
  // Add active window ID
163
187
  addActiveWindow: (i) => {
@@ -168,7 +192,7 @@ const X = () => {
168
192
  removeActiveWindow: (i) => {
169
193
  const n = e(), a = String(i);
170
194
  t({
171
- activeWindowIds: n.activeWindowIds.filter((r) => r !== a)
195
+ activeWindowIds: n.activeWindowIds.filter((l) => l !== a)
172
196
  });
173
197
  },
174
198
  // Check if window is active
@@ -176,46 +200,50 @@ const X = () => {
176
200
  const n = e(), a = String(i);
177
201
  return n.activeWindowIds.includes(a);
178
202
  }
179
- }), d = oe()(
180
- ue(Se, {
203
+ }), w = ge()(
204
+ ye(Oe, {
181
205
  name: "tauri-notice-queue"
182
206
  })
183
- ), D = {
207
+ ), S = {
184
208
  queueLength: (t) => t.queue.length,
185
209
  currentMessage: (t) => t.currentMessage,
186
210
  isProcessing: (t) => t.isProcessing,
187
211
  queue: (t) => t.queue
188
- }, He = () => {
189
- const t = d((i) => i.enqueue);
190
- return { showNotice: A(
212
+ }, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
213
+ __proto__: null,
214
+ messageQueueSelectors: S,
215
+ useMessageQueueStore: w
216
+ }, Symbol.toStringTag, { value: "Module" })), $e = () => {
217
+ const t = w((i) => i.enqueue);
218
+ return { showNotice: I(
191
219
  async (i) => {
192
220
  await t(i);
193
221
  },
194
222
  [t]
195
223
  ) };
196
224
  };
197
- function De(t, e, i, n) {
225
+ function xe(t, e, i, n) {
198
226
  if (typeof e == "function" ? t !== e || !n : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
199
227
  return i === "m" ? n : i === "a" ? n.call(t) : n ? n.value : e.get(t);
200
228
  }
201
- function Ne(t, e, i, n, a) {
229
+ function Ie(t, e, i, n, a) {
202
230
  if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
203
231
  return e.set(t, i), i;
204
232
  }
205
- var N;
206
- const w = "__TAURI_TO_IPC_KEY__";
207
- function ze(t, e = !1) {
233
+ var O;
234
+ const d = "__TAURI_TO_IPC_KEY__";
235
+ function Me(t, e = !1) {
208
236
  return window.__TAURI_INTERNALS__.transformCallback(t, e);
209
237
  }
210
238
  async function s(t, e = {}, i) {
211
239
  return window.__TAURI_INTERNALS__.invoke(t, e, i);
212
240
  }
213
- class Ae {
241
+ class ke {
214
242
  get rid() {
215
- return De(this, N, "f");
243
+ return xe(this, O, "f");
216
244
  }
217
245
  constructor(e) {
218
- N.set(this, void 0), Ne(this, N, e);
246
+ O.set(this, void 0), Ie(this, O, e);
219
247
  }
220
248
  /**
221
249
  * Destroys and cleans up this resource from memory.
@@ -227,8 +255,8 @@ class Ae {
227
255
  });
228
256
  }
229
257
  }
230
- N = /* @__PURE__ */ new WeakMap();
231
- class te {
258
+ O = /* @__PURE__ */ new WeakMap();
259
+ class se {
232
260
  constructor(...e) {
233
261
  this.type = "Logical", e.length === 1 ? "Logical" in e[0] ? (this.width = e[0].Logical.width, this.height = e[0].Logical.height) : (this.width = e[0].width, this.height = e[0].height) : (this.width = e[0], this.height = e[1]);
234
262
  }
@@ -248,19 +276,19 @@ class te {
248
276
  * @since 2.0.0
249
277
  */
250
278
  toPhysical(e) {
251
- return new b(this.width * e, this.height * e);
279
+ return new y(this.width * e, this.height * e);
252
280
  }
253
- [w]() {
281
+ [d]() {
254
282
  return {
255
283
  width: this.width,
256
284
  height: this.height
257
285
  };
258
286
  }
259
287
  toJSON() {
260
- return this[w]();
288
+ return this[d]();
261
289
  }
262
290
  }
263
- class b {
291
+ class y {
264
292
  constructor(...e) {
265
293
  this.type = "Physical", e.length === 1 ? "Physical" in e[0] ? (this.width = e[0].Physical.width, this.height = e[0].Physical.height) : (this.width = e[0].width, this.height = e[0].height) : (this.width = e[0], this.height = e[1]);
266
294
  }
@@ -276,16 +304,16 @@ class b {
276
304
  * ```
277
305
  */
278
306
  toLogical(e) {
279
- return new te(this.width / e, this.height / e);
307
+ return new se(this.width / e, this.height / e);
280
308
  }
281
- [w]() {
309
+ [d]() {
282
310
  return {
283
311
  width: this.width,
284
312
  height: this.height
285
313
  };
286
314
  }
287
315
  toJSON() {
288
- return this[w]();
316
+ return this[d]();
289
317
  }
290
318
  }
291
319
  class g {
@@ -293,12 +321,12 @@ class g {
293
321
  this.size = e;
294
322
  }
295
323
  toLogical(e) {
296
- return this.size instanceof te ? this.size : this.size.toLogical(e);
324
+ return this.size instanceof se ? this.size : this.size.toLogical(e);
297
325
  }
298
326
  toPhysical(e) {
299
- return this.size instanceof b ? this.size : this.size.toPhysical(e);
327
+ return this.size instanceof y ? this.size : this.size.toPhysical(e);
300
328
  }
301
- [w]() {
329
+ [d]() {
302
330
  return {
303
331
  [`${this.size.type}`]: {
304
332
  width: this.size.width,
@@ -307,10 +335,10 @@ class g {
307
335
  };
308
336
  }
309
337
  toJSON() {
310
- return this[w]();
338
+ return this[d]();
311
339
  }
312
340
  }
313
- class ie {
341
+ class ae {
314
342
  constructor(...e) {
315
343
  this.type = "Logical", e.length === 1 ? "Logical" in e[0] ? (this.x = e[0].Logical.x, this.y = e[0].Logical.y) : (this.x = e[0].x, this.y = e[0].y) : (this.x = e[0], this.y = e[1]);
316
344
  }
@@ -332,14 +360,14 @@ class ie {
332
360
  toPhysical(e) {
333
361
  return new c(this.x * e, this.y * e);
334
362
  }
335
- [w]() {
363
+ [d]() {
336
364
  return {
337
365
  x: this.x,
338
366
  y: this.y
339
367
  };
340
368
  }
341
369
  toJSON() {
342
- return this[w]();
370
+ return this[d]();
343
371
  }
344
372
  }
345
373
  class c {
@@ -362,29 +390,29 @@ class c {
362
390
  * @since 2.0.0
363
391
  */
364
392
  toLogical(e) {
365
- return new ie(this.x / e, this.y / e);
393
+ return new ae(this.x / e, this.y / e);
366
394
  }
367
- [w]() {
395
+ [d]() {
368
396
  return {
369
397
  x: this.x,
370
398
  y: this.y
371
399
  };
372
400
  }
373
401
  toJSON() {
374
- return this[w]();
402
+ return this[d]();
375
403
  }
376
404
  }
377
- class p {
405
+ class _ {
378
406
  constructor(e) {
379
407
  this.position = e;
380
408
  }
381
409
  toLogical(e) {
382
- return this.position instanceof ie ? this.position : this.position.toLogical(e);
410
+ return this.position instanceof ae ? this.position : this.position.toLogical(e);
383
411
  }
384
412
  toPhysical(e) {
385
413
  return this.position instanceof c ? this.position : this.position.toPhysical(e);
386
414
  }
387
- [w]() {
415
+ [d]() {
388
416
  return {
389
417
  [`${this.position.type}`]: {
390
418
  x: this.position.x,
@@ -393,47 +421,47 @@ class p {
393
421
  };
394
422
  }
395
423
  toJSON() {
396
- return this[w]();
424
+ return this[d]();
397
425
  }
398
426
  }
399
427
  var o;
400
428
  (function(t) {
401
429
  t.WINDOW_RESIZED = "tauri://resize", t.WINDOW_MOVED = "tauri://move", t.WINDOW_CLOSE_REQUESTED = "tauri://close-requested", t.WINDOW_DESTROYED = "tauri://destroyed", t.WINDOW_FOCUS = "tauri://focus", t.WINDOW_BLUR = "tauri://blur", t.WINDOW_SCALE_FACTOR_CHANGED = "tauri://scale-change", t.WINDOW_THEME_CHANGED = "tauri://theme-changed", t.WINDOW_CREATED = "tauri://window-created", t.WEBVIEW_CREATED = "tauri://webview-created", t.DRAG_ENTER = "tauri://drag-enter", t.DRAG_OVER = "tauri://drag-over", t.DRAG_DROP = "tauri://drag-drop", t.DRAG_LEAVE = "tauri://drag-leave";
402
430
  })(o || (o = {}));
403
- async function ne(t, e) {
431
+ async function re(t, e) {
404
432
  window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t, e), await s("plugin:event|unlisten", {
405
433
  event: t,
406
434
  eventId: e
407
435
  });
408
436
  }
409
- async function O(t, e, i) {
437
+ async function M(t, e, i) {
410
438
  var n;
411
439
  const a = typeof i?.target == "string" ? { kind: "AnyLabel", label: i.target } : (n = i?.target) !== null && n !== void 0 ? n : { kind: "Any" };
412
440
  return s("plugin:event|listen", {
413
441
  event: t,
414
442
  target: a,
415
- handler: ze(e)
416
- }).then((r) => async () => ne(t, r));
443
+ handler: Me(e)
444
+ }).then((l) => async () => re(t, l));
417
445
  }
418
- async function E(t, e, i) {
419
- return O(t, (n) => {
420
- ne(t, n.id), e(n);
446
+ async function B(t, e, i) {
447
+ return M(t, (n) => {
448
+ re(t, n.id), e(n);
421
449
  }, i);
422
450
  }
423
- async function se(t, e) {
451
+ async function le(t, e) {
424
452
  await s("plugin:event|emit", {
425
453
  event: t,
426
454
  payload: e
427
455
  });
428
456
  }
429
- async function ae(t, e, i) {
457
+ async function oe(t, e, i) {
430
458
  await s("plugin:event|emit_to", {
431
459
  target: typeof t == "string" ? { kind: "AnyLabel", label: t } : t,
432
460
  event: e,
433
461
  payload: i
434
462
  });
435
463
  }
436
- class W extends Ae {
464
+ class N extends ke {
437
465
  /**
438
466
  * Creates an Image from a resource ID. For internal use only.
439
467
  *
@@ -445,10 +473,10 @@ class W extends Ae {
445
473
  /** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
446
474
  static async new(e, i, n) {
447
475
  return s("plugin:image|new", {
448
- rgba: z(e),
476
+ rgba: x(e),
449
477
  width: i,
450
478
  height: n
451
- }).then((a) => new W(a));
479
+ }).then((a) => new N(a));
452
480
  }
453
481
  /**
454
482
  * Creates a new image using the provided bytes by inferring the file format.
@@ -465,8 +493,8 @@ class W extends Ae {
465
493
  */
466
494
  static async fromBytes(e) {
467
495
  return s("plugin:image|from_bytes", {
468
- bytes: z(e)
469
- }).then((i) => new W(i));
496
+ bytes: x(e)
497
+ }).then((i) => new N(i));
470
498
  }
471
499
  /**
472
500
  * Creates a new image using the provided path.
@@ -481,7 +509,7 @@ class W extends Ae {
481
509
  * ```
482
510
  */
483
511
  static async fromPath(e) {
484
- return s("plugin:image|from_path", { path: e }).then((i) => new W(i));
512
+ return s("plugin:image|from_path", { path: e }).then((i) => new N(i));
485
513
  }
486
514
  /** Returns the RGBA data for this image, in row-major order from top to bottom. */
487
515
  async rgba() {
@@ -494,14 +522,14 @@ class W extends Ae {
494
522
  return s("plugin:image|size", { rid: this.rid });
495
523
  }
496
524
  }
497
- function z(t) {
498
- return t == null ? null : typeof t == "string" ? t : t instanceof W ? t.rid : t;
525
+ function x(t) {
526
+ return t == null ? null : typeof t == "string" ? t : t instanceof N ? t.rid : t;
499
527
  }
500
- var R;
528
+ var F;
501
529
  (function(t) {
502
530
  t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
503
- })(R || (R = {}));
504
- class Oe {
531
+ })(F || (F = {}));
532
+ class Ce {
505
533
  constructor(e) {
506
534
  this._preventDefault = !1, this.event = e.event, this.id = e.id;
507
535
  }
@@ -512,24 +540,24 @@ class Oe {
512
540
  return this._preventDefault;
513
541
  }
514
542
  }
515
- var U;
543
+ var j;
516
544
  (function(t) {
517
545
  t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
518
- })(U || (U = {}));
519
- function le() {
520
- return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
546
+ })(j || (j = {}));
547
+ function ue() {
548
+ return new k(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
521
549
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
522
550
  skip: !0
523
551
  });
524
552
  }
525
- async function M() {
526
- return s("plugin:window|get_all_windows").then((t) => t.map((e) => new P(e, {
553
+ async function R() {
554
+ return s("plugin:window|get_all_windows").then((t) => t.map((e) => new k(e, {
527
555
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
528
556
  skip: !0
529
557
  })));
530
558
  }
531
- const C = ["tauri://created", "tauri://error"];
532
- class P {
559
+ const T = ["tauri://created", "tauri://error"];
560
+ class k {
533
561
  /**
534
562
  * Creates a new Window.
535
563
  * @example
@@ -570,19 +598,19 @@ class P {
570
598
  */
571
599
  static async getByLabel(e) {
572
600
  var i;
573
- return (i = (await M()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
601
+ return (i = (await R()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
574
602
  }
575
603
  /**
576
604
  * Get an instance of `Window` for the current window.
577
605
  */
578
606
  static getCurrent() {
579
- return le();
607
+ return ue();
580
608
  }
581
609
  /**
582
610
  * Gets a list of instances of `Window` for all available windows.
583
611
  */
584
612
  static async getAll() {
585
- return M();
613
+ return R();
586
614
  }
587
615
  /**
588
616
  * Gets the focused window.
@@ -595,7 +623,7 @@ class P {
595
623
  * @returns The Window instance or `undefined` if there is not any focused window.
596
624
  */
597
625
  static async getFocusedWindow() {
598
- for (const e of await M())
626
+ for (const e of await R())
599
627
  if (await e.isFocused())
600
628
  return e;
601
629
  return null;
@@ -623,7 +651,7 @@ class P {
623
651
  return this._handleTauriEvent(e, i) ? () => {
624
652
  const n = this.listeners[e];
625
653
  n.splice(n.indexOf(i), 1);
626
- } : O(e, i, {
654
+ } : M(e, i, {
627
655
  target: { kind: "Window", label: this.label }
628
656
  });
629
657
  }
@@ -650,7 +678,7 @@ class P {
650
678
  return this._handleTauriEvent(e, i) ? () => {
651
679
  const n = this.listeners[e];
652
680
  n.splice(n.indexOf(i), 1);
653
- } : E(e, i, {
681
+ } : B(e, i, {
654
682
  target: { kind: "Window", label: this.label }
655
683
  });
656
684
  }
@@ -666,7 +694,7 @@ class P {
666
694
  * @param payload Event payload.
667
695
  */
668
696
  async emit(e, i) {
669
- if (C.includes(e)) {
697
+ if (T.includes(e)) {
670
698
  for (const n of this.listeners[e] || [])
671
699
  n({
672
700
  event: e,
@@ -675,7 +703,7 @@ class P {
675
703
  });
676
704
  return;
677
705
  }
678
- return se(e, i);
706
+ return le(e, i);
679
707
  }
680
708
  /**
681
709
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -690,7 +718,7 @@ class P {
690
718
  * @param payload Event payload.
691
719
  */
692
720
  async emitTo(e, i, n) {
693
- if (C.includes(i)) {
721
+ if (T.includes(i)) {
694
722
  for (const a of this.listeners[i] || [])
695
723
  a({
696
724
  event: i,
@@ -699,11 +727,11 @@ class P {
699
727
  });
700
728
  return;
701
729
  }
702
- return ae(e, i, n);
730
+ return oe(e, i, n);
703
731
  }
704
732
  /** @ignore */
705
733
  _handleTauriEvent(e, i) {
706
- return C.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
734
+ return T.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
707
735
  }
708
736
  // Getters
709
737
  /**
@@ -765,7 +793,7 @@ class P {
765
793
  async innerSize() {
766
794
  return s("plugin:window|inner_size", {
767
795
  label: this.label
768
- }).then((e) => new b(e));
796
+ }).then((e) => new y(e));
769
797
  }
770
798
  /**
771
799
  * The physical size of the entire window.
@@ -781,7 +809,7 @@ class P {
781
809
  async outerSize() {
782
810
  return s("plugin:window|outer_size", {
783
811
  label: this.label
784
- }).then((e) => new b(e));
812
+ }).then((e) => new y(e));
785
813
  }
786
814
  /**
787
815
  * Gets the window's current fullscreen state.
@@ -1032,7 +1060,7 @@ class P {
1032
1060
  */
1033
1061
  async requestUserAttention(e) {
1034
1062
  let i = null;
1035
- return e && (e === R.Critical ? i = { type: "Critical" } : i = { type: "Informational" }), s("plugin:window|request_user_attention", {
1063
+ return e && (e === F.Critical ? i = { type: "Critical" } : i = { type: "Informational" }), s("plugin:window|request_user_attention", {
1036
1064
  label: this.label,
1037
1065
  value: i
1038
1066
  });
@@ -1508,7 +1536,7 @@ class P {
1508
1536
  async setPosition(e) {
1509
1537
  return s("plugin:window|set_position", {
1510
1538
  label: this.label,
1511
- value: e instanceof p ? e : new p(e)
1539
+ value: e instanceof _ ? e : new _(e)
1512
1540
  });
1513
1541
  }
1514
1542
  /**
@@ -1602,7 +1630,7 @@ class P {
1602
1630
  async setIcon(e) {
1603
1631
  return s("plugin:window|set_icon", {
1604
1632
  label: this.label,
1605
- value: z(e)
1633
+ value: x(e)
1606
1634
  });
1607
1635
  }
1608
1636
  /**
@@ -1720,7 +1748,7 @@ class P {
1720
1748
  async setCursorPosition(e) {
1721
1749
  return s("plugin:window|set_cursor_position", {
1722
1750
  label: this.label,
1723
- value: e instanceof p ? e : new p(e)
1751
+ value: e instanceof _ ? e : new _(e)
1724
1752
  });
1725
1753
  }
1726
1754
  /**
@@ -1837,7 +1865,7 @@ class P {
1837
1865
  async setOverlayIcon(e) {
1838
1866
  return s("plugin:window|set_overlay_icon", {
1839
1867
  label: this.label,
1840
- value: e ? z(e) : void 0
1868
+ value: e ? x(e) : void 0
1841
1869
  });
1842
1870
  }
1843
1871
  /**
@@ -1927,7 +1955,7 @@ class P {
1927
1955
  */
1928
1956
  async onResized(e) {
1929
1957
  return this.listen(o.WINDOW_RESIZED, (i) => {
1930
- i.payload = new b(i.payload), e(i);
1958
+ i.payload = new y(i.payload), e(i);
1931
1959
  });
1932
1960
  }
1933
1961
  /**
@@ -1976,7 +2004,7 @@ class P {
1976
2004
  */
1977
2005
  async onCloseRequested(e) {
1978
2006
  return this.listen(o.WINDOW_CLOSE_REQUESTED, async (i) => {
1979
- const n = new Oe(i);
2007
+ const n = new Ce(i);
1980
2008
  await e(n), n.isPreventDefault() || await this.destroy();
1981
2009
  });
1982
2010
  }
@@ -2006,37 +2034,37 @@ class P {
2006
2034
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2007
2035
  */
2008
2036
  async onDragDropEvent(e) {
2009
- const i = await this.listen(o.DRAG_ENTER, (l) => {
2037
+ const i = await this.listen(o.DRAG_ENTER, (r) => {
2010
2038
  e({
2011
- ...l,
2039
+ ...r,
2012
2040
  payload: {
2013
2041
  type: "enter",
2014
- paths: l.payload.paths,
2015
- position: new c(l.payload.position)
2042
+ paths: r.payload.paths,
2043
+ position: new c(r.payload.position)
2016
2044
  }
2017
2045
  });
2018
- }), n = await this.listen(o.DRAG_OVER, (l) => {
2046
+ }), n = await this.listen(o.DRAG_OVER, (r) => {
2019
2047
  e({
2020
- ...l,
2048
+ ...r,
2021
2049
  payload: {
2022
2050
  type: "over",
2023
- position: new c(l.payload.position)
2051
+ position: new c(r.payload.position)
2024
2052
  }
2025
2053
  });
2026
- }), a = await this.listen(o.DRAG_DROP, (l) => {
2054
+ }), a = await this.listen(o.DRAG_DROP, (r) => {
2027
2055
  e({
2028
- ...l,
2056
+ ...r,
2029
2057
  payload: {
2030
2058
  type: "drop",
2031
- paths: l.payload.paths,
2032
- position: new c(l.payload.position)
2059
+ paths: r.payload.paths,
2060
+ position: new c(r.payload.position)
2033
2061
  }
2034
2062
  });
2035
- }), r = await this.listen(o.DRAG_LEAVE, (l) => {
2036
- e({ ...l, payload: { type: "leave" } });
2063
+ }), l = await this.listen(o.DRAG_LEAVE, (r) => {
2064
+ e({ ...r, payload: { type: "leave" } });
2037
2065
  });
2038
2066
  return () => {
2039
- i(), a(), n(), r();
2067
+ i(), a(), n(), l();
2040
2068
  };
2041
2069
  }
2042
2070
  /**
@@ -2115,41 +2143,41 @@ var H;
2115
2143
  (function(t) {
2116
2144
  t.Disabled = "disabled", t.Throttle = "throttle", t.Suspend = "suspend";
2117
2145
  })(H || (H = {}));
2118
- var Q;
2146
+ var V;
2119
2147
  (function(t) {
2120
2148
  t.Default = "default", t.FluentOverlay = "fluentOverlay";
2121
- })(Q || (Q = {}));
2122
- var V;
2149
+ })(V || (V = {}));
2150
+ var $;
2123
2151
  (function(t) {
2124
2152
  t.AppearanceBased = "appearanceBased", t.Light = "light", t.Dark = "dark", t.MediumLight = "mediumLight", t.UltraDark = "ultraDark", t.Titlebar = "titlebar", t.Selection = "selection", t.Menu = "menu", t.Popover = "popover", t.Sidebar = "sidebar", t.HeaderView = "headerView", t.Sheet = "sheet", t.WindowBackground = "windowBackground", t.HudWindow = "hudWindow", t.FullScreenUI = "fullScreenUI", t.Tooltip = "tooltip", t.ContentBackground = "contentBackground", t.UnderWindowBackground = "underWindowBackground", t.UnderPageBackground = "underPageBackground", t.Mica = "mica", t.Blur = "blur", t.Acrylic = "acrylic", t.Tabbed = "tabbed", t.TabbedDark = "tabbedDark", t.TabbedLight = "tabbedLight";
2125
- })(V || (V = {}));
2126
- var j;
2153
+ })($ || ($ = {}));
2154
+ var J;
2127
2155
  (function(t) {
2128
2156
  t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
2129
- })(j || (j = {}));
2130
- function Pe(t) {
2157
+ })(J || (J = {}));
2158
+ function Le(t) {
2131
2159
  return t === null ? null : {
2132
2160
  name: t.name,
2133
2161
  scaleFactor: t.scaleFactor,
2134
2162
  position: new c(t.position),
2135
- size: new b(t.size),
2163
+ size: new y(t.size),
2136
2164
  workArea: {
2137
2165
  position: new c(t.workArea.position),
2138
- size: new b(t.workArea.size)
2166
+ size: new y(t.workArea.size)
2139
2167
  }
2140
2168
  };
2141
2169
  }
2142
- async function Ie() {
2143
- return s("plugin:window|primary_monitor").then(Pe);
2170
+ async function Ee() {
2171
+ return s("plugin:window|primary_monitor").then(Le);
2144
2172
  }
2145
- function re() {
2146
- return new T(le(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
2173
+ function ce() {
2174
+ return new U(ue(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
2147
2175
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2148
2176
  skip: !0
2149
2177
  });
2150
2178
  }
2151
- async function $() {
2152
- return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new T(new P(e.windowLabel, {
2179
+ async function Z() {
2180
+ return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new U(new k(e.windowLabel, {
2153
2181
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2154
2182
  skip: !0
2155
2183
  }), e.label, {
@@ -2157,8 +2185,8 @@ async function $() {
2157
2185
  skip: !0
2158
2186
  })));
2159
2187
  }
2160
- const L = ["tauri://created", "tauri://error"];
2161
- class T {
2188
+ const q = ["tauri://created", "tauri://error"];
2189
+ class U {
2162
2190
  /**
2163
2191
  * Creates a new Webview.
2164
2192
  * @example
@@ -2213,19 +2241,19 @@ class T {
2213
2241
  */
2214
2242
  static async getByLabel(e) {
2215
2243
  var i;
2216
- return (i = (await $()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
2244
+ return (i = (await Z()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
2217
2245
  }
2218
2246
  /**
2219
2247
  * Get an instance of `Webview` for the current webview.
2220
2248
  */
2221
2249
  static getCurrent() {
2222
- return re();
2250
+ return ce();
2223
2251
  }
2224
2252
  /**
2225
2253
  * Gets a list of instances of `Webview` for all available webviews.
2226
2254
  */
2227
2255
  static async getAll() {
2228
- return $();
2256
+ return Z();
2229
2257
  }
2230
2258
  /**
2231
2259
  * Listen to an emitted event on this webview.
@@ -2250,7 +2278,7 @@ class T {
2250
2278
  return this._handleTauriEvent(e, i) ? () => {
2251
2279
  const n = this.listeners[e];
2252
2280
  n.splice(n.indexOf(i), 1);
2253
- } : O(e, i, {
2281
+ } : M(e, i, {
2254
2282
  target: { kind: "Webview", label: this.label }
2255
2283
  });
2256
2284
  }
@@ -2277,7 +2305,7 @@ class T {
2277
2305
  return this._handleTauriEvent(e, i) ? () => {
2278
2306
  const n = this.listeners[e];
2279
2307
  n.splice(n.indexOf(i), 1);
2280
- } : E(e, i, {
2308
+ } : B(e, i, {
2281
2309
  target: { kind: "Webview", label: this.label }
2282
2310
  });
2283
2311
  }
@@ -2294,7 +2322,7 @@ class T {
2294
2322
  * @param payload Event payload.
2295
2323
  */
2296
2324
  async emit(e, i) {
2297
- if (L.includes(e)) {
2325
+ if (q.includes(e)) {
2298
2326
  for (const n of this.listeners[e] || [])
2299
2327
  n({
2300
2328
  event: e,
@@ -2303,7 +2331,7 @@ class T {
2303
2331
  });
2304
2332
  return;
2305
2333
  }
2306
- return se(e, i);
2334
+ return le(e, i);
2307
2335
  }
2308
2336
  /**
2309
2337
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -2319,7 +2347,7 @@ class T {
2319
2347
  * @param payload Event payload.
2320
2348
  */
2321
2349
  async emitTo(e, i, n) {
2322
- if (L.includes(i)) {
2350
+ if (q.includes(i)) {
2323
2351
  for (const a of this.listeners[i] || [])
2324
2352
  a({
2325
2353
  event: i,
@@ -2328,11 +2356,11 @@ class T {
2328
2356
  });
2329
2357
  return;
2330
2358
  }
2331
- return ae(e, i, n);
2359
+ return oe(e, i, n);
2332
2360
  }
2333
2361
  /** @ignore */
2334
2362
  _handleTauriEvent(e, i) {
2335
- return L.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2363
+ return q.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
2336
2364
  }
2337
2365
  // Getters
2338
2366
  /**
@@ -2364,7 +2392,7 @@ class T {
2364
2392
  async size() {
2365
2393
  return s("plugin:webview|webview_size", {
2366
2394
  label: this.label
2367
- }).then((e) => new b(e));
2395
+ }).then((e) => new y(e));
2368
2396
  }
2369
2397
  // Setters
2370
2398
  /**
@@ -2413,7 +2441,7 @@ class T {
2413
2441
  async setPosition(e) {
2414
2442
  return s("plugin:webview|set_webview_position", {
2415
2443
  label: this.label,
2416
- value: e instanceof p ? e : new p(e)
2444
+ value: e instanceof _ ? e : new _(e)
2417
2445
  });
2418
2446
  }
2419
2447
  /**
@@ -2569,51 +2597,51 @@ class T {
2569
2597
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2570
2598
  */
2571
2599
  async onDragDropEvent(e) {
2572
- const i = await this.listen(o.DRAG_ENTER, (l) => {
2600
+ const i = await this.listen(o.DRAG_ENTER, (r) => {
2573
2601
  e({
2574
- ...l,
2602
+ ...r,
2575
2603
  payload: {
2576
2604
  type: "enter",
2577
- paths: l.payload.paths,
2578
- position: new c(l.payload.position)
2605
+ paths: r.payload.paths,
2606
+ position: new c(r.payload.position)
2579
2607
  }
2580
2608
  });
2581
- }), n = await this.listen(o.DRAG_OVER, (l) => {
2609
+ }), n = await this.listen(o.DRAG_OVER, (r) => {
2582
2610
  e({
2583
- ...l,
2611
+ ...r,
2584
2612
  payload: {
2585
2613
  type: "over",
2586
- position: new c(l.payload.position)
2614
+ position: new c(r.payload.position)
2587
2615
  }
2588
2616
  });
2589
- }), a = await this.listen(o.DRAG_DROP, (l) => {
2617
+ }), a = await this.listen(o.DRAG_DROP, (r) => {
2590
2618
  e({
2591
- ...l,
2619
+ ...r,
2592
2620
  payload: {
2593
2621
  type: "drop",
2594
- paths: l.payload.paths,
2595
- position: new c(l.payload.position)
2622
+ paths: r.payload.paths,
2623
+ position: new c(r.payload.position)
2596
2624
  }
2597
2625
  });
2598
- }), r = await this.listen(o.DRAG_LEAVE, (l) => {
2599
- e({ ...l, payload: { type: "leave" } });
2626
+ }), l = await this.listen(o.DRAG_LEAVE, (r) => {
2627
+ e({ ...r, payload: { type: "leave" } });
2600
2628
  });
2601
2629
  return () => {
2602
- i(), a(), n(), r();
2630
+ i(), a(), n(), l();
2603
2631
  };
2604
2632
  }
2605
2633
  }
2606
- function xe() {
2607
- const t = re();
2608
- return new _(t.label, { skip: !0 });
2634
+ function P() {
2635
+ const t = ce();
2636
+ return new f(t.label, { skip: !0 });
2609
2637
  }
2610
- async function J() {
2611
- return s("plugin:window|get_all_windows").then((t) => t.map((e) => new _(e, {
2638
+ async function Y() {
2639
+ return s("plugin:window|get_all_windows").then((t) => t.map((e) => new f(e, {
2612
2640
  // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
2613
2641
  skip: !0
2614
2642
  })));
2615
2643
  }
2616
- class _ {
2644
+ class f {
2617
2645
  /**
2618
2646
  * Creates a new {@link Window} hosting a {@link Webview}.
2619
2647
  * @example
@@ -2656,20 +2684,20 @@ class _ {
2656
2684
  */
2657
2685
  static async getByLabel(e) {
2658
2686
  var i;
2659
- const n = (i = (await J()).find((a) => a.label === e)) !== null && i !== void 0 ? i : null;
2660
- return n ? new _(n.label, { skip: !0 }) : null;
2687
+ const n = (i = (await Y()).find((a) => a.label === e)) !== null && i !== void 0 ? i : null;
2688
+ return n ? new f(n.label, { skip: !0 }) : null;
2661
2689
  }
2662
2690
  /**
2663
2691
  * Get an instance of `Webview` for the current webview.
2664
2692
  */
2665
2693
  static getCurrent() {
2666
- return xe();
2694
+ return P();
2667
2695
  }
2668
2696
  /**
2669
2697
  * Gets a list of instances of `Webview` for all available webviews.
2670
2698
  */
2671
2699
  static async getAll() {
2672
- return J();
2700
+ return Y();
2673
2701
  }
2674
2702
  /**
2675
2703
  * Listen to an emitted event on this webivew window.
@@ -2694,7 +2722,7 @@ class _ {
2694
2722
  return this._handleTauriEvent(e, i) ? () => {
2695
2723
  const n = this.listeners[e];
2696
2724
  n.splice(n.indexOf(i), 1);
2697
- } : O(e, i, {
2725
+ } : M(e, i, {
2698
2726
  target: { kind: "WebviewWindow", label: this.label }
2699
2727
  });
2700
2728
  }
@@ -2721,7 +2749,7 @@ class _ {
2721
2749
  return this._handleTauriEvent(e, i) ? () => {
2722
2750
  const n = this.listeners[e];
2723
2751
  n.splice(n.indexOf(i), 1);
2724
- } : E(e, i, {
2752
+ } : B(e, i, {
2725
2753
  target: { kind: "WebviewWindow", label: this.label }
2726
2754
  });
2727
2755
  }
@@ -2745,8 +2773,8 @@ class _ {
2745
2773
  return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
2746
2774
  }
2747
2775
  }
2748
- ke(_, [P, T]);
2749
- function ke(t, e) {
2776
+ Re(f, [k, U]);
2777
+ function Re(t, e) {
2750
2778
  (Array.isArray(e) ? e : [e]).forEach((i) => {
2751
2779
  Object.getOwnPropertyNames(i.prototype).forEach((n) => {
2752
2780
  var a;
@@ -2759,14 +2787,21 @@ function ke(t, e) {
2759
2787
  });
2760
2788
  });
2761
2789
  }
2762
- const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
2790
+ const z = /* @__PURE__ */ new Map(), Te = (t) => {
2791
+ if (!t || t.trim() === "") return !1;
2792
+ try {
2793
+ return !!(t.startsWith("/") || t.startsWith("http://") || t.startsWith("https://") || t.startsWith("tauri://"));
2794
+ } catch {
2795
+ return !1;
2796
+ }
2797
+ }, qe = async (t, e, i) => {
2763
2798
  const n = i?.padding ?? 20;
2764
2799
  if (i?.x !== void 0 && i?.y !== void 0)
2765
2800
  return { x: i.x, y: i.y };
2766
- let a = 1920, r = 1080;
2801
+ let a = 1920, l = 1080;
2767
2802
  try {
2768
- const u = await Ie();
2769
- u?.size && (a = u.size.width, r = u.size.height);
2803
+ const u = await Ee();
2804
+ u?.size && (a = u.size.width, l = u.size.height);
2770
2805
  } catch (u) {
2771
2806
  console.warn("Failed to get monitor info, using defaults:", u);
2772
2807
  }
@@ -2774,7 +2809,7 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
2774
2809
  case "right-bottom":
2775
2810
  return {
2776
2811
  x: a - t - n,
2777
- y: r - e - n
2812
+ y: l - e - n
2778
2813
  };
2779
2814
  case "right-top":
2780
2815
  return {
@@ -2784,7 +2819,7 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
2784
2819
  case "left-bottom":
2785
2820
  return {
2786
2821
  x: n,
2787
- y: r - e - n
2822
+ y: l - e - n
2788
2823
  };
2789
2824
  case "left-top":
2790
2825
  return {
@@ -2794,157 +2829,192 @@ const S = /* @__PURE__ */ new Map(), Me = async (t, e, i) => {
2794
2829
  case "center":
2795
2830
  return {
2796
2831
  x: (a - t) / 2,
2797
- y: (r - e) / 2
2832
+ y: (l - e) / 2
2798
2833
  };
2799
2834
  default:
2800
2835
  return {
2801
2836
  x: a - t - n,
2802
- y: r - e - n
2837
+ y: l - e - n
2803
2838
  };
2804
2839
  }
2805
- }, Ce = async (t) => {
2806
- const e = String(t.id), i = d.getState();
2840
+ }, we = async (t) => {
2841
+ const e = String(t.id), i = w.getState();
2807
2842
  if (i.isWindowActive(e)) {
2808
2843
  console.log(`Notice window already open for message: ${e}`);
2809
2844
  return;
2810
2845
  }
2811
- const n = K(), a = `notice-${e}`, r = `${n.routePrefix}/${t.type}?id=${t.id}`, l = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight, { x: f, y: m } = await Me(l, u, t.windowPosition);
2846
+ const n = ee(), a = `notice-${e}`;
2847
+ let l = `${n.routePrefix}/${t.type}?id=${t.id}`;
2848
+ Te(l) || (console.warn(`Invalid window URL: ${l}. Using fallback 404 page.`), l = n.notFoundUrl || "/404");
2849
+ const r = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight, { x: m, y: v } = await qe(r, u, t.windowPosition);
2812
2850
  try {
2813
- const y = new _(a, {
2814
- url: r,
2851
+ const b = new f(a, {
2852
+ url: l,
2815
2853
  title: t.title,
2816
- width: l,
2854
+ width: r,
2817
2855
  height: u,
2818
- x: f,
2819
- y: m,
2856
+ x: m,
2857
+ y: v,
2820
2858
  resizable: !0,
2821
2859
  decorations: !0,
2822
2860
  skipTaskbar: !1,
2823
2861
  alwaysOnTop: !0
2824
2862
  });
2825
- S.set(e, y), i.addActiveWindow(e), y.once("tauri://destroyed", async () => {
2826
- S.delete(e), i.removeActiveWindow(e), await ee(e), i.clearCurrent();
2863
+ z.set(e, b), i.addActiveWindow(e), b.once("tauri://destroyed", async () => {
2864
+ z.delete(e), i.removeActiveWindow(e), await ie(e), i.clearCurrent();
2827
2865
  }), console.log(`Created notice window: ${a}`);
2828
- } catch (y) {
2829
- console.error("Failed to create notice window:", y), i.removeActiveWindow(e), i.clearCurrent();
2866
+ } catch (b) {
2867
+ console.error("Failed to create notice window:", b), i.removeActiveWindow(e), i.clearCurrent();
2830
2868
  }
2831
- }, q = async (t) => {
2832
- const e = String(t), i = S.get(e), n = d.getState();
2869
+ }, C = async (t) => {
2870
+ const e = String(t), i = z.get(e), n = w.getState();
2833
2871
  if (i)
2834
2872
  try {
2835
- await i.close(), S.delete(e), n.removeActiveWindow(e), await ee(e), n.clearCurrent(), console.log(`Closed notice window: ${e}`);
2873
+ await i.close(), z.delete(e), n.removeActiveWindow(e), await ie(e), n.clearCurrent(), console.log(`Closed notice window: ${e}`);
2836
2874
  } catch (a) {
2837
2875
  console.error("Failed to close notice window:", a);
2838
2876
  }
2839
- }, Le = async () => {
2840
- const t = Array.from(S.keys()).map(
2841
- (e) => q(e)
2877
+ }, de = async () => {
2878
+ const t = Array.from(z.keys()).map(
2879
+ (e) => C(e)
2842
2880
  );
2843
2881
  await Promise.all(t);
2844
- }, Re = () => {
2882
+ }, he = () => {
2845
2883
  let t = null;
2846
- d.subscribe((e) => {
2884
+ w.subscribe((e) => {
2847
2885
  const i = e.currentMessage;
2848
- i && i !== t ? (t = i, Ce(i)) : i || (t = null);
2886
+ i && i !== t ? (t = i, we(i)) : i || (t = null);
2849
2887
  }), console.log("Notice window system initialized");
2850
- }, Qe = () => {
2851
- const t = d((i) => i.currentMessage);
2852
- return { closeNotice: A(async () => {
2853
- t && await q(t.id);
2888
+ }, Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2889
+ __proto__: null,
2890
+ closeAllNoticeWindows: de,
2891
+ closeNoticeWindow: C,
2892
+ createNoticeWindow: we,
2893
+ initializeNoticeWindowSystem: he
2894
+ }, Symbol.toStringTag, { value: "Module" })), Je = () => {
2895
+ const t = w((i) => i.currentMessage);
2896
+ return { closeNotice: I(async () => {
2897
+ t && await C(t.id);
2854
2898
  }, [t]) };
2855
- }, Ve = () => {
2856
- const t = d();
2857
- return { hideNotice: A(
2899
+ }, Ze = () => {
2900
+ const t = w();
2901
+ return { hideNotice: I(
2858
2902
  async (i) => {
2859
- await fe(i), await q(i), t.currentMessage?.id === i && t.clearCurrent();
2903
+ await Ne(i), await C(i), t.currentMessage?.id === i && t.clearCurrent();
2860
2904
  },
2861
2905
  [t]
2862
2906
  ) };
2863
- }, je = () => {
2864
- const t = d((i) => i.clearOnLogout);
2865
- return { hideAllNotices: A(async () => {
2866
- await Le(), await t();
2907
+ }, Ye = () => {
2908
+ const t = w((i) => i.clearOnLogout);
2909
+ return { hideAllNotices: I(async () => {
2910
+ await de(), await t();
2867
2911
  }, [t]) };
2868
- }, $e = () => {
2869
- const t = d(D.queueLength), e = d(D.currentMessage), i = d(D.isProcessing), n = d(D.queue);
2912
+ }, Ke = () => {
2913
+ const t = w(S.queueLength), e = w(S.currentMessage), i = w(S.isProcessing), n = w(S.queue);
2870
2914
  return {
2871
2915
  queueLength: t,
2872
2916
  currentMessage: e,
2873
2917
  isProcessing: i,
2874
2918
  queue: n
2875
2919
  };
2876
- }, Je = ({ children: t, onLoad: e, onClose: i }) => {
2877
- const [n, a] = x(null), [r, l] = x(!0), [u, f] = x(null);
2878
- return B(() => {
2920
+ }, Xe = ({ children: t, onLoad: e, onClose: i }) => {
2921
+ const [n, a] = E(null), [l, r] = E(!0), [u, m] = E(null);
2922
+ return G(() => {
2879
2923
  (async () => {
2880
2924
  try {
2881
- const F = new URLSearchParams(window.location.search).get("id");
2882
- if (!F) {
2883
- f("No message ID provided"), l(!1);
2925
+ const p = new URLSearchParams(window.location.search).get("id");
2926
+ if (!p) {
2927
+ m("No message ID provided"), r(!1), setTimeout(async () => {
2928
+ try {
2929
+ await P().close();
2930
+ } catch (W) {
2931
+ console.error("Failed to close window:", W);
2932
+ }
2933
+ }, 1e3);
2884
2934
  return;
2885
2935
  }
2886
- const I = await me(F);
2887
- if (!I) {
2888
- f("Message not found"), l(!1);
2936
+ const L = await ne(p);
2937
+ if (!L) {
2938
+ console.log(`Message ${p} not found in database, closing window`), m("Message not found"), r(!1), setTimeout(async () => {
2939
+ try {
2940
+ await P().close();
2941
+ } catch (W) {
2942
+ console.error("Failed to close window:", W);
2943
+ }
2944
+ }, 500);
2889
2945
  return;
2890
2946
  }
2891
- a(I), l(!1), e && e(I);
2892
- } catch (y) {
2893
- console.error("Failed to load message:", y), f("Failed to load message"), l(!1);
2947
+ a(L), r(!1), e && e(L);
2948
+ } catch (b) {
2949
+ console.error("Failed to load message:", b), m("Failed to load message"), r(!1), setTimeout(async () => {
2950
+ try {
2951
+ await P().close();
2952
+ } catch (p) {
2953
+ console.error("Failed to close window:", p);
2954
+ }
2955
+ }, 1e3);
2894
2956
  }
2895
2957
  })();
2896
- }, [e]), B(() => {
2958
+ }, [e]), G(() => {
2897
2959
  if (!n || !i) return;
2898
- const m = () => {
2960
+ const v = () => {
2899
2961
  i(n);
2900
2962
  };
2901
- return window.addEventListener("beforeunload", m), () => {
2902
- window.removeEventListener("beforeunload", m);
2963
+ return window.addEventListener("beforeunload", v), () => {
2964
+ window.removeEventListener("beforeunload", v);
2903
2965
  };
2904
- }, [n, i]), r ? /* @__PURE__ */ k("div", { style: {
2966
+ }, [n, i]), l ? /* @__PURE__ */ A("div", { style: {
2905
2967
  display: "flex",
2906
2968
  justifyContent: "center",
2907
2969
  alignItems: "center",
2908
2970
  height: "100vh",
2909
2971
  fontFamily: "system-ui, -apple-system, sans-serif"
2910
- }, children: "Loading..." }) : u || !n ? /* @__PURE__ */ k("div", { style: {
2972
+ }, children: "Loading..." }) : u ? /* @__PURE__ */ A("div", { style: {
2973
+ display: "flex",
2974
+ justifyContent: "center",
2975
+ alignItems: "center",
2976
+ height: "100vh",
2977
+ fontFamily: "system-ui, -apple-system, sans-serif",
2978
+ color: "#ef4444"
2979
+ }, children: u }) : n ? /* @__PURE__ */ A(pe, { children: t(n) }) : /* @__PURE__ */ A("div", { style: {
2911
2980
  display: "flex",
2912
2981
  justifyContent: "center",
2913
2982
  alignItems: "center",
2914
2983
  height: "100vh",
2915
2984
  fontFamily: "system-ui, -apple-system, sans-serif",
2916
2985
  color: "#ef4444"
2917
- }, children: u || "Message not found" }) : /* @__PURE__ */ k(de, { children: t(n) });
2918
- }, Ze = async () => {
2919
- X(), Re();
2920
- const { initializeFromDatabase: t } = d.getState();
2986
+ }, children: "Closing window..." });
2987
+ }, et = async () => {
2988
+ te(), he();
2989
+ const { initializeFromDatabase: t } = w.getState();
2921
2990
  await t(), console.log("Tauri Notice System initialized");
2922
2991
  };
2923
2992
  export {
2924
- Je as NoticeLayout,
2925
- ve as clearPendingMessages,
2926
- Le as closeAllNoticeWindows,
2927
- q as closeNoticeWindow,
2928
- Ce as createNoticeWindow,
2929
- Ue as deleteMessageById,
2930
- me as getMessage,
2931
- K as getNoticeConfig,
2932
- pe as getPendingMessages,
2933
- be as hasMessage,
2934
- X as initializeDatabase,
2935
- Ze as initializeNoticeSystem,
2936
- Re as initializeNoticeWindowSystem,
2937
- ye as isMessageShown,
2938
- fe as markAsHidden,
2939
- ee as markAsShown,
2940
- D as messageQueueSelectors,
2941
- ge as saveMessage,
2942
- Ge as setNoticeConfig,
2943
- Qe as useCloseNotice,
2944
- je as useHideAllNotices,
2945
- Ve as useHideNotice,
2946
- $e as useMessageQueue,
2947
- d as useMessageQueueStore,
2948
- He as useNoticeWindow
2993
+ Xe as NoticeLayout,
2994
+ ze as clearPendingMessages,
2995
+ de as closeAllNoticeWindows,
2996
+ C as closeNoticeWindow,
2997
+ we as createNoticeWindow,
2998
+ Ve as deleteMessageById,
2999
+ ne as getMessage,
3000
+ ee as getNoticeConfig,
3001
+ Se as getPendingMessages,
3002
+ ve as hasMessage,
3003
+ te as initializeDatabase,
3004
+ et as initializeNoticeSystem,
3005
+ he as initializeNoticeWindowSystem,
3006
+ We as isMessageShown,
3007
+ Ne as markAsHidden,
3008
+ ie as markAsShown,
3009
+ S as messageQueueSelectors,
3010
+ me as saveMessage,
3011
+ He as setNoticeConfig,
3012
+ De as updateQueueStatus,
3013
+ Je as useCloseNotice,
3014
+ Ye as useHideAllNotices,
3015
+ Ze as useHideNotice,
3016
+ Ke as useMessageQueue,
3017
+ w as useMessageQueueStore,
3018
+ $e as useNoticeWindow
2949
3019
  };
2950
3020
  //# sourceMappingURL=index.js.map