bt-core-app 2.2.44 → 2.2.45

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.
@@ -1,148 +1,151 @@
1
- import { isLengthyArray as q, appendUrl as S, isNullOrEmpty as v, jwtDecrypt as B } from "./helpers.mjs";
1
+ import { isLengthyArray as B, appendUrl as w, isNullOrEmpty as v, jwtDecrypt as J } from "./helpers.mjs";
2
2
  import m from "../bt-core/core/node_modules/luxon/src/datetime.mjs";
3
3
  import "../bt-core/core/node_modules/luxon/src/duration.mjs";
4
- import { useStorage as J } from "@vueuse/core";
5
- import { ref as K, computed as L, toValue as o } from "vue";
6
- import { useAuthUrl as k } from "./urls.mjs";
7
- import { useApi as R } from "./api.mjs";
8
- let b = "Australia/Melbourne", I;
9
- const C = "auth-credentials-state";
10
- function ne() {
11
- return I;
4
+ import { useStorage as K } from "@vueuse/core";
5
+ import { ref as j, computed as L, toValue as o } from "vue";
6
+ import { useAuthUrl as S } from "./urls.mjs";
7
+ import { useApi as C } from "./api.mjs";
8
+ let I = "Australia/Melbourne", O;
9
+ const R = "auth-credentials-state";
10
+ function ue() {
11
+ return O;
12
12
  }
13
- function ue(u) {
14
- const c = u.expiryTokenFormat ?? "d/MM/yyyy h:mm:ss a", D = u.tokenRefreshMinuteWindow ?? 10800;
15
- let h = K(localStorage.getItem(C) ?? "");
16
- h.value.length == 0 && O();
17
- function O() {
18
- h.value = Math.random().toString(36).substring(4, 19) + Math.random().toString(12).substring(1, 11), localStorage.setItem(C, h.value);
13
+ function ie(n) {
14
+ const c = n.expiryTokenFormat ?? "d/MM/yyyy h:mm:ss a", D = n.tokenRefreshMinuteWindow ?? 10800;
15
+ let h = j(localStorage.getItem(R) ?? "");
16
+ h.value.length == 0 && x();
17
+ function x() {
18
+ h.value = Math.random().toString(36).substring(4, 19) + Math.random().toString(12).substring(1, 11), localStorage.setItem(R, h.value);
19
19
  }
20
- const i = J("auth-credentials", {});
21
- u.menu != null && (u.menu.currentView.value = i.value.subscriptionCode);
22
- function F(r) {
23
- if (r == null)
24
- return !0;
25
- var e = u.getAuthItem != null ? u.getAuthItem(r) : null;
20
+ const i = K("auth-credentials", {});
21
+ n.menu != null && (n.menu.currentView.value = i.value.subscriptionCode);
22
+ function F(e) {
26
23
  if (e == null)
24
+ return !0;
25
+ var r = n.getAuthItem != null ? n.getAuthItem(e) : null;
26
+ if (r == null)
27
27
  return !1;
28
- if (e.requiresAuth === !1)
28
+ if (r.requiresAuth === !1)
29
29
  return !0;
30
30
  const t = o(i);
31
- if (t.isSuspended && e.ignoreSuspension !== !0)
31
+ if (t.isSuspended && r.ignoreSuspension !== !0)
32
32
  return !1;
33
33
  if (t.isGlobalAdmin)
34
34
  return !0;
35
- if (e.permissions != null && e.permissions.length > 0) {
36
- if (Array.isArray(e.permissions[0])) {
37
- if (e.permissions.every((l) => l.some((a) => !d(a))))
35
+ if (r.permissions != null && r.permissions.length > 0) {
36
+ if (Array.isArray(r.permissions[0])) {
37
+ if (r.permissions.every((s) => s.some((a) => !d(a))))
38
38
  return !1;
39
39
  } else
40
- for (var n = 0; n < e.permissions.length; n++)
41
- if (!d(e.permissions[n]))
40
+ for (var u = 0; u < r.permissions.length; u++)
41
+ if (!d(r.permissions[u]))
42
42
  return !1;
43
43
  }
44
44
  return !0;
45
45
  }
46
- function d(r) {
47
- const e = o(i);
48
- if (e.userPermissions != null)
49
- for (var t = 0; t < e.userPermissions.length; t++) {
50
- var n = e.userPermissions[t].split(".");
51
- if (e.userPermissions[t] == "everything.edit" || r == n[0] && n.length > 1 && n[1] == "edit")
46
+ function d(e) {
47
+ const r = o(i);
48
+ if (r.userPermissions != null)
49
+ for (var t = 0; t < r.userPermissions.length; t++) {
50
+ var u = r.userPermissions[t].split(".");
51
+ if (r.userPermissions[t] == "everything.edit" || e == u[0] && u.length > 1 && u[1] == "edit")
52
52
  return !0;
53
53
  }
54
54
  return !1;
55
55
  }
56
- function _(r) {
57
- if (r == null)
58
- return !0;
59
- var e = u.getAuthItem != null ? u.getAuthItem(r) : null;
56
+ function _(e) {
60
57
  if (e == null)
58
+ return !0;
59
+ var r = n.getAuthItem != null ? n.getAuthItem(e) : null;
60
+ if (r == null)
61
61
  return !1;
62
- if (e.requiresAuth === !1)
62
+ if (r.requiresAuth === !1)
63
63
  return !0;
64
64
  const t = o(i);
65
- if (t.isSuspended && e.ignoreSuspension !== !0)
65
+ if (t.isSuspended && r.ignoreSuspension !== !0)
66
66
  return !1;
67
67
  if (t.isGlobalAdmin)
68
68
  return !0;
69
- if (e.permissions != null && e.permissions.length > 0) {
70
- if (Array.isArray(e.permissions[0])) {
71
- if (e.permissions.every((l) => l.some((a) => !g(a))))
69
+ if (r.permissions != null && r.permissions.length > 0) {
70
+ if (Array.isArray(r.permissions[0])) {
71
+ if (r.permissions.every((s) => s.some((a) => !g(a))))
72
72
  return !1;
73
73
  } else
74
- for (var n = 0; n < e.permissions.length; n++)
75
- if (!g(e.permissions[n]))
74
+ for (var u = 0; u < r.permissions.length; u++)
75
+ if (!g(r.permissions[u]))
76
76
  return !1;
77
77
  }
78
78
  return !0;
79
79
  }
80
- function g(r) {
81
- const e = o(i);
82
- if (e.userPermissions != null)
83
- for (var t = 0; t < e.userPermissions.length; t++) {
84
- var n = e.userPermissions[t].split(".");
85
- if (r == n[0] || r == "everything" || e.userPermissions[t] == "everything.view" || e.userPermissions[t] == "everything.edit")
80
+ function g(e) {
81
+ const r = o(i);
82
+ if (r.userPermissions != null)
83
+ for (var t = 0; t < r.userPermissions.length; t++) {
84
+ var u = r.userPermissions[t].split(".");
85
+ if (e == u[0] || e == "everything" || r.userPermissions[t] == "everything.view" || r.userPermissions[t] == "everything.edit")
86
86
  return !0;
87
87
  }
88
88
  return !1;
89
89
  }
90
- function x(r, e, t) {
91
- let n = !0, l = !0;
92
- return r != null && r.length > 0 && (r.some((s) => V(s)) || (l = !1)), l ? o(i).isGlobalAdmin ? !0 : (e != null && e.length > 0 && (Array.isArray(e[0]) ? t == "edit" ? e.some((s) => s.every((f) => d(f))) || (n = !1) : e.some((s) => s.every((f) => g(f))) || (n = !1) : e.forEach((s) => {
93
- t == "edit" ? d(s) || (n = !1) : g(s) || (n = !1);
94
- })), n) : !1;
90
+ function E(e, r, t) {
91
+ let u = !0, s = !0;
92
+ return e != null && e.length > 0 && (e.some((l) => V(l)) || (s = !1)), s ? o(i).isGlobalAdmin ? !0 : (r != null && r.length > 0 && (Array.isArray(r[0]) ? t == "edit" ? r.some((l) => l.every((f) => d(f))) || (u = !1) : r.some((l) => l.every((f) => g(f))) || (u = !1) : r.forEach((l) => {
93
+ t == "edit" ? d(l) || (u = !1) : g(l) || (u = !1);
94
+ })), u) : !1;
95
95
  }
96
- function p(r, e = !1) {
97
- var t = u.getAuthItem != null ? u.getAuthItem(r) : null;
98
- let n = !1;
96
+ function p(e, r = !1) {
97
+ var t = n.getAuthItem != null ? n.getAuthItem(e) : null;
98
+ let u = !1;
99
99
  if (t == null)
100
100
  return !1;
101
- let l = t.subscriptions ?? [], a = t.permissions ?? [], s = x(l, a, "view");
102
- return s || !e || !q(t.children) ? s : ((t == null ? void 0 : t.children) != null && t.children.forEach((f) => {
103
- p(f, !0) && (n = !0);
104
- }), n);
101
+ let s = t.subscriptions ?? [], a = t.permissions ?? [], l = E(s, a, "view");
102
+ return l || !r || !B(t.children) ? l : ((t == null ? void 0 : t.children) != null && t.children.forEach((f) => {
103
+ p(f, !0) && (u = !0);
104
+ }), u);
105
105
  }
106
- function w(r) {
107
- return u.getAuthorizeUrl ?? (u.getAuthorizeUrl = (e, t) => {
108
- const n = S(k(), `authorize?response_type=code&client_id=${u.oauthClientID}&redirect_uri=${window.location.origin}/authentication&state=${t}`);
109
- return e != null ? `${n}&redirect_path=${e}` : n;
110
- }), u.getAuthorizeUrl != null ? u.getAuthorizeUrl(r, h.value) ?? "" : "";
106
+ function k(e) {
107
+ return n.getAuthorizeUrl ?? (n.getAuthorizeUrl = (r, t) => {
108
+ const u = w(S(), `authorize?response_type=code&client_id=${n.oauthClientID}&redirect_uri=${window.location.origin}/authentication&state=${t}`);
109
+ return r != null ? `${u}&redirect_path=${r}` : u;
110
+ }), n.getAuthorizeUrl != null ? n.getAuthorizeUrl(e, h.value) ?? "" : "";
111
111
  }
112
- function E(r) {
112
+ function P(e) {
113
113
  var t;
114
- return r == null ? 0 : ((t = (u.subscriptionOptions ?? []).find((n) => n.code == r)) == null ? void 0 : t.value) ?? 0;
114
+ return e == null ? 0 : ((t = (n.subscriptionOptions ?? []).find((u) => u.code == e)) == null ? void 0 : t.value) ?? 0;
115
115
  }
116
- function V(r) {
117
- const e = o(i);
118
- if (e.subscriptionCode == null)
116
+ function V(e) {
117
+ const r = o(i);
118
+ if (r.subscriptionCode == null)
119
119
  return !1;
120
- if (e.subscriptionCode == r)
120
+ if (r.subscriptionCode == e)
121
121
  return !0;
122
- const t = E(r), n = E(e.subscriptionCode);
123
- return t <= n;
122
+ const t = P(e), u = P(r.subscriptionCode);
123
+ return t <= u;
124
+ }
125
+ async function Z(e) {
126
+ i.value = void 0, A(), n.firebase != null && await n.firebase.unregister(), e != null && n.router != null && n.router.currentRoute.value.path != e && n.router.push({ path: e });
124
127
  }
125
- function y(r) {
126
- i.value = void 0, P(), r != null && u.router != null && u.router.currentRoute.value.path != r && u.router.push({ path: r });
128
+ function y(e) {
129
+ i.value = void 0, A(), e != null && n.router != null && n.router.currentRoute.value.path != e && n.router.push({ path: e });
127
130
  }
128
- function Z(r, e) {
131
+ function G(e, r) {
129
132
  const t = o(i);
130
- if (A() || !t.isLoggedIn) {
133
+ if (b() || !t.isLoggedIn) {
131
134
  y();
132
- let n = w(r);
133
- e != null && (n.includes("?") || (n = n + "?"), n.includes("&") && (n = n + "&"), n = n + new URLSearchParams(e).toString()), window.location.href = n;
135
+ let u = k(e);
136
+ r != null && (u.includes("?") || (u = u + "?"), u.includes("&") && (u = u + "&"), u = u + new URLSearchParams(r).toString()), window.location.href = u;
134
137
  } else
135
- !v(r) && u.router != null && u.router.push({ path: r });
138
+ !v(e) && n.router != null && n.router.push({ path: e });
136
139
  }
137
- async function G() {
138
- return u.tryRefreshToken ?? (u.tryRefreshToken = async () => {
139
- if (u.useTokenRefresh !== !0 || v(i.value.refreshToken) || v(i.value.refreshExpiresOn))
140
+ async function M() {
141
+ return n.tryRefreshToken ?? (n.tryRefreshToken = async () => {
142
+ if (n.useTokenRefresh !== !0 || v(i.value.refreshToken) || v(i.value.refreshExpiresOn))
140
143
  return;
141
- const r = m.fromFormat(i.value.refreshExpiresOn, c), e = m.fromFormat(i.value.expiresOn, c), t = m.utc().toFormat(c), n = e.plus({ minutes: 0 - D });
142
- if (!(t > r.toFormat(c)) && !(t < n.toFormat(c))) {
143
- var l = S(k(), u.tokenRefreshPath ?? "refreshtoken");
144
+ const e = m.fromFormat(i.value.refreshExpiresOn, c), r = m.fromFormat(i.value.expiresOn, c), t = m.utc().toFormat(c), u = r.plus({ minutes: 0 - D });
145
+ if (!(t > e.toFormat(c)) && !(t < u.toFormat(c))) {
146
+ var s = w(S(), n.tokenRefreshPath ?? "refreshtoken");
144
147
  try {
145
- var a = await fetch(l, {
148
+ var a = await fetch(s, {
146
149
  method: "POST",
147
150
  mode: "cors",
148
151
  cache: "no-cache",
@@ -152,106 +155,107 @@ function ue(u) {
152
155
  body: JSON.stringify({ refreshToken: i.value.refreshToken })
153
156
  });
154
157
  if (a.ok) {
155
- var s = await a.json();
156
- a != null && s.data != null && T(s.data);
158
+ var l = await a.json();
159
+ a != null && l.data != null && T(l.data);
157
160
  }
158
161
  } catch {
159
162
  }
160
163
  }
161
- }), await u.tryRefreshToken(i.value);
164
+ }), await n.tryRefreshToken(i.value);
162
165
  }
163
- async function M() {
164
- return u.testToken ?? (u.testToken = async () => {
165
- let r = i.value.token, e = !1;
166
- const t = u.getTokenTestUrl ?? (() => S(k(), "test"));
167
- return r != null && (await R().post({
168
- additionalUrl: t(r),
166
+ async function $() {
167
+ return n.testToken ?? (n.testToken = async () => {
168
+ let e = i.value.token, r = !1;
169
+ const t = n.getTokenTestUrl ?? (() => w(S(), "test"));
170
+ return e != null && (await C().post({
171
+ additionalUrl: t(e),
169
172
  data: {
170
- token: r
173
+ token: e
171
174
  }
172
- })).data === !0 && (e = !0), e ? !0 : (y(u.tokenInvalidPath), !1);
173
- }), await u.testToken();
175
+ })).data === !0 && (r = !0), r ? !0 : (y(n.tokenInvalidPath), !1);
176
+ }), await n.testToken();
174
177
  }
175
- async function $(r, e) {
176
- return u.getToken ?? (u.getToken = async () => {
177
- let t = r, n = e, l = u.oauthGrantType ?? "authorization_token", a = u.oauthClientID ?? "";
178
- if (t == null || n == null)
178
+ async function z(e, r) {
179
+ return n.getToken ?? (n.getToken = async () => {
180
+ let t = e, u = r, s = n.oauthGrantType ?? "authorization_token", a = n.oauthClientID ?? "";
181
+ if (t == null || u == null)
179
182
  throw new Error("Code and State required in OAuth token process");
180
- if (n != h.value)
183
+ if (u != h.value)
181
184
  throw new Error("state does not match");
182
- let s = "";
183
- u.getTokenUrl ?? (u.getTokenUrl = () => S(k(), "token")), s = u.getTokenUrl(t, `${window.location.origin}/authentication`, l, a);
185
+ let l = "";
186
+ n.getTokenUrl ?? (n.getTokenUrl = () => w(S(), "token")), l = n.getTokenUrl(t, `${window.location.origin}/authentication`, s, a);
184
187
  const f = {};
185
- f.grant_type = l, f.code = t, f.redirect_uri = `${window.location.origin}/authentication`, f.client_id = a;
186
- const N = await R().post({
187
- additionalUrl: s,
188
+ f.grant_type = s, f.code = t, f.redirect_uri = `${window.location.origin}/authentication`, f.client_id = a;
189
+ const q = await C().post({
190
+ additionalUrl: l,
188
191
  data: f
189
192
  });
190
- T(N.access_token);
191
- }), await u.getToken(r, e);
193
+ T(q.access_token);
194
+ }), await n.getToken(e, r);
192
195
  }
193
- function T(r) {
194
- if (r == null)
196
+ function T(e) {
197
+ if (e == null)
195
198
  return;
196
- const e = B(r);
197
- z(e, r), u.processTokenPayload != null && u.processTokenPayload(i, e);
199
+ const r = J(e);
200
+ W(r, e), n.processTokenPayload != null && n.processTokenPayload(i, r);
198
201
  }
199
- function z(r, e) {
200
- var n;
202
+ function W(e, r) {
203
+ var u;
201
204
  const t = i.value;
202
- t.expiresOn = r.ExpiresOn, t.isGlobalAdmin = r.IsGlobalAdmin == "True", t.isLoggedIn = !0, t.permissions = r.Permissions, t.subscriptionCode = r.Subscription, t.refreshExpiresOn = r.RefreshTokenExpiresOn, t.refreshToken = r.RefreshToken, (u == null ? void 0 : u.menu) != null && (u.menu.currentView.value = t.subscriptionCode), t.timeZone ?? (t.timeZone = u.defaultTimeZone ?? b), t.token = e, t.userID = r.UserLoginID, t.userPermissions = r.Permissions != null && r.Permissions.length > 0 ? ((n = r.Permissions) == null ? void 0 : n.split(",")) ?? [] : [];
205
+ t.expiresOn = e.ExpiresOn, t.isGlobalAdmin = e.IsGlobalAdmin == "True", t.isLoggedIn = !0, t.permissions = e.Permissions, t.subscriptionCode = e.Subscription, t.refreshExpiresOn = e.RefreshTokenExpiresOn, t.refreshToken = e.RefreshToken, (n == null ? void 0 : n.menu) != null && (n.menu.currentView.value = t.subscriptionCode), t.timeZone ?? (t.timeZone = n.defaultTimeZone ?? I), t.token = r, t.userID = e.UserLoginID, t.userPermissions = e.Permissions != null && e.Permissions.length > 0 ? ((u = e.Permissions) == null ? void 0 : u.split(",")) ?? [] : [];
203
206
  }
204
- function P() {
205
- var r;
206
- i.value ?? (i.value = {}), (r = i.value).timeZone ?? (r.timeZone = u.defaultTimeZone ?? b);
207
+ function A() {
208
+ var e;
209
+ i.value ?? (i.value = {}), (e = i.value).timeZone ?? (e.timeZone = n.defaultTimeZone ?? I);
207
210
  }
208
- function W(r, e) {
211
+ function N(e, r) {
209
212
  const t = o(i);
210
- if (t.isLoggedIn && A() && U()) {
213
+ if (t.isLoggedIn && b() && U()) {
211
214
  y();
212
- let n = w(r);
213
- e != null && (n.includes("?") || (n = n + "?"), n.includes("&") && (n = n + "&"), n = n + new URLSearchParams(e).toString()), window.location.href = n;
215
+ let u = k(e);
216
+ r != null && (u.includes("?") || (u = u + "?"), u.includes("&") && (u = u + "&"), u = u + new URLSearchParams(r).toString()), window.location.href = u;
214
217
  }
215
218
  return t.isLoggedIn;
216
219
  }
217
220
  function U() {
218
- if (!u.useTokenRefresh || v(i.value.refreshExpiresOn) || v(i.value.refreshToken))
221
+ if (!n.useTokenRefresh || v(i.value.refreshExpiresOn) || v(i.value.refreshToken))
219
222
  return !0;
220
- const r = m.fromFormat(i.value.refreshExpiresOn, c);
221
- return m.utc() > r;
223
+ const e = m.fromFormat(i.value.refreshExpiresOn, c);
224
+ return m.utc() > e;
222
225
  }
223
- function A() {
224
- const r = o(i);
225
- if (r == null || r.expiresOn == null)
226
+ function b() {
227
+ const e = o(i);
228
+ if (e == null || e.expiresOn == null)
226
229
  return !0;
227
- const e = m.fromFormat(r.expiresOn, c), t = m.utc();
228
- return e <= t;
230
+ const r = m.fromFormat(e.expiresOn, c), t = m.utc();
231
+ return r <= t;
229
232
  }
230
- return P(), I = {
233
+ return A(), O = {
231
234
  authState: h,
232
235
  canEdit: F,
233
236
  canEditPermit: d,
234
237
  canView: _,
235
238
  canViewPermit: g,
236
239
  credentials: i,
237
- doShow: x,
240
+ doShow: E,
238
241
  doShowByNav: p,
239
- getAuthorizeUrl: w,
240
- getToken: $,
242
+ getAuthorizeUrl: k,
243
+ getToken: z,
241
244
  isLoggedIn: L(() => i.value.isLoggedIn === !0),
242
- login: Z,
245
+ login: G,
243
246
  logout: y,
247
+ logoutAsync: Z,
244
248
  refreshTokenExpired: U,
245
- resetAuthState: O,
249
+ resetAuthState: x,
246
250
  setAuth: T,
247
- testToken: M,
248
- timeZone: L(() => i.value.timeZone ?? u.defaultTimeZone ?? b),
249
- tokenExpired: A,
250
- tryLogin: W,
251
- tryRefreshToken: G
252
- }, I;
251
+ testToken: $,
252
+ timeZone: L(() => i.value.timeZone ?? n.defaultTimeZone ?? I),
253
+ tokenExpired: b,
254
+ tryLogin: N,
255
+ tryRefreshToken: M
256
+ }, O;
253
257
  }
254
258
  export {
255
- ue as createAuth,
256
- ne as useAuth
259
+ ie as createAuth,
260
+ ue as useAuth
257
261
  };
@@ -23,8 +23,8 @@ export interface BTFirebase {
23
23
  actionLoadingMsg: any;
24
24
  app: FirebaseApp;
25
25
  messaging: Messaging;
26
- initiate: () => Promise<void>;
27
26
  permission: Ref<NotificationPermission>;
27
+ register: () => Promise<void>;
28
28
  unregister: () => Promise<void>;
29
29
  }
30
30
  export declare function useFirebaseListener(handler?: (payload: MessagePayload) => void): void;
@@ -1,88 +1,88 @@
1
- import { ref as w } from "vue";
2
- import { useActions as v } from "./actions.mjs";
1
+ import { ref as b } from "vue";
2
+ import { useActions as w } from "./actions.mjs";
3
3
  import { appendUrl as u } from "./helpers.mjs";
4
4
  import { useDataUrl as d } from "./urls.mjs";
5
5
  import "../bt-core/core/node_modules/firebase/app/dist/esm/index.esm.mjs";
6
- import { getMessaging as R, onRegistered as F, onUnregistered as h, onMessage as L, register as k, unregister as D } from "../bt-core/core/node_modules/@firebase/messaging/dist/esm/index.esm.mjs";
6
+ import { getMessaging as v, onRegistered as R, onUnregistered as F, onMessage as h, register as L, unregister as k } from "../bt-core/core/node_modules/@firebase/messaging/dist/esm/index.esm.mjs";
7
7
  import { getDetailedDeviceType as m } from "./devices.mjs";
8
- import { initializeApp as E } from "../bt-core/core/node_modules/@firebase/app/dist/esm/index.esm.mjs";
8
+ import { initializeApp as D } from "../bt-core/core/node_modules/@firebase/app/dist/esm/index.esm.mjs";
9
9
  let t, g;
10
- function S(e) {
10
+ function P(e) {
11
11
  g = e;
12
12
  }
13
- function p() {
13
+ function S() {
14
14
  return t;
15
15
  }
16
- function q(e) {
17
- const { actionLoadingMsg: y, apiPost: c } = v();
16
+ function p(e) {
17
+ if (t != null)
18
+ return t;
19
+ const { actionLoadingMsg: y, apiPost: l } = w();
18
20
  var a = "", n = "";
19
21
  (e == null ? void 0 : e.finalRegisterURL) != null ? a = e.finalRegisterURL : a = u(d(), (e == null ? void 0 : e.registerUrl) ?? "FirebaseNotifications/Register"), (e == null ? void 0 : e.finalUnregisterURL) != null ? n = e.finalUnregisterURL : n = u(d(), (e == null ? void 0 : e.unregisterURL) ?? "FirebaseNotifications/Unregister");
20
- const l = E(e.config), i = R(l), o = w(typeof window < "u" && "Notification" in window ? Notification.permission : "default");
22
+ const c = D(e.config), i = v(c), o = b(typeof window < "u" && "Notification" in window ? Notification.permission : "default");
21
23
  async function f() {
22
- F(i, async (r) => {
23
- console.log("Firebase Installation ID received:", r);
24
+ if (o.value === "granted")
24
25
  try {
25
- await c({
26
- data: {
27
- token: r,
28
- deviceType: m()
29
- },
30
- finalUrl: a,
31
- throwError: !0
32
- });
33
- } catch (s) {
34
- console.log("firebase initiation error"), console.log(s);
26
+ const r = await navigator.serviceWorker.ready;
27
+ await L(
28
+ i,
29
+ {
30
+ vapidKey: e.vapidPublicKey,
31
+ serviceWorkerRegistration: r
32
+ }
33
+ );
34
+ } catch (r) {
35
+ console.log("Error triggering firebase register:", r);
35
36
  }
36
- }), h(i, async (r) => {
37
- console.log("Firebase Installation ID unregistered:", r);
38
- try {
39
- await c({
40
- data: {
41
- token: r,
42
- deviceType: m()
43
- },
44
- finalUrl: n,
45
- throwError: !0
46
- });
47
- } catch (s) {
48
- console.log("firebase backend unregister notification error", s);
49
- }
50
- }), L(i, (r) => {
51
- g != null && g(r);
52
- }), o.value === "granted" && await U();
53
37
  }
54
38
  async function U() {
55
39
  try {
56
- const r = await navigator.serviceWorker.ready;
57
- await k(
58
- i,
59
- {
60
- vapidKey: e.vapidPublicKey,
61
- serviceWorkerRegistration: r
62
- }
63
- );
40
+ await k(i), console.log("Successfully requested Firebase unregistration.");
64
41
  } catch (r) {
65
- console.log("Error triggering firebase register:", r);
42
+ throw console.log("Error calling firebase unregister:", r), r;
66
43
  }
67
44
  }
68
- async function b() {
45
+ return R(i, async (r) => {
46
+ console.log("Firebase Installation ID received:", r);
69
47
  try {
70
- await D(i), console.log("Successfully requested Firebase unregistration.");
71
- } catch (r) {
72
- throw console.log("Error calling firebase unregister:", r), r;
48
+ await l({
49
+ data: {
50
+ token: r,
51
+ deviceType: m()
52
+ },
53
+ finalUrl: a,
54
+ throwError: !0
55
+ });
56
+ } catch (s) {
57
+ console.log("firebase initiation error"), console.log(s);
73
58
  }
74
- }
75
- return t == null && e.initiateImmediately && f(), t ?? (t = {
59
+ }), F(i, async (r) => {
60
+ console.log("Firebase Installation ID unregistered:", r);
61
+ try {
62
+ await l({
63
+ data: {
64
+ token: r,
65
+ deviceType: m()
66
+ },
67
+ finalUrl: n,
68
+ throwError: !0
69
+ });
70
+ } catch (s) {
71
+ console.log("firebase backend unregister notification error", s);
72
+ }
73
+ }), h(i, (r) => {
74
+ g != null && g(r);
75
+ }), t == null && e.initiateImmediately && f(), t ?? (t = {
76
76
  actionLoadingMsg: y,
77
- app: l,
77
+ app: c,
78
78
  messaging: i,
79
- initiate: f,
80
79
  permission: o,
81
- unregister: b
80
+ register: f,
81
+ unregister: U
82
82
  }), t;
83
83
  }
84
84
  export {
85
- q as createFirebase,
86
- p as useFirebase,
87
- S as useFirebaseListener
85
+ p as createFirebase,
86
+ S as useFirebase,
87
+ P as useFirebaseListener
88
88
  };