@neetru/sdk 3.6.0 → 3.7.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/ai.cjs +254 -391
  3. package/dist/ai.d.cts +1 -1
  4. package/dist/ai.d.ts +1 -1
  5. package/dist/ai.mjs +254 -391
  6. package/dist/auth.cjs +3547 -4998
  7. package/dist/auth.d.cts +1 -1
  8. package/dist/auth.d.ts +1 -1
  9. package/dist/auth.mjs +3544 -4995
  10. package/dist/build-guard.cjs +101 -119
  11. package/dist/build-guard.mjs +91 -109
  12. package/dist/catalog.cjs +152 -224
  13. package/dist/catalog.d.cts +1 -1
  14. package/dist/catalog.d.ts +1 -1
  15. package/dist/catalog.mjs +152 -224
  16. package/dist/checkout.cjs +237 -320
  17. package/dist/checkout.d.cts +1 -1
  18. package/dist/checkout.d.ts +1 -1
  19. package/dist/checkout.mjs +236 -319
  20. package/dist/db-react.cjs +59 -87
  21. package/dist/db-react.d.cts +1 -1
  22. package/dist/db-react.d.ts +1 -1
  23. package/dist/db-react.mjs +56 -84
  24. package/dist/db.cjs +2055 -3013
  25. package/dist/db.d.cts +1 -1
  26. package/dist/db.d.ts +1 -1
  27. package/dist/db.mjs +2068 -3026
  28. package/dist/entitlements.cjs +12 -20
  29. package/dist/entitlements.d.cts +1 -1
  30. package/dist/entitlements.d.ts +1 -1
  31. package/dist/entitlements.mjs +12 -20
  32. package/dist/errors.cjs +9 -12
  33. package/dist/errors.d.cts +37 -2
  34. package/dist/errors.d.ts +37 -2
  35. package/dist/errors.mjs +8 -12
  36. package/dist/firestore-compat.cjs +241 -297
  37. package/dist/firestore-compat.d.cts +1 -1
  38. package/dist/firestore-compat.d.ts +1 -1
  39. package/dist/firestore-compat.mjs +215 -271
  40. package/dist/index.cjs +3605 -5131
  41. package/dist/index.d.cts +6 -4
  42. package/dist/index.d.ts +6 -4
  43. package/dist/index.mjs +3710 -5236
  44. package/dist/mobile.cjs +238 -342
  45. package/dist/mobile.d.cts +1 -1
  46. package/dist/mobile.d.ts +1 -1
  47. package/dist/mobile.mjs +238 -342
  48. package/dist/mocks.cjs +312 -447
  49. package/dist/mocks.d.cts +1 -1
  50. package/dist/mocks.d.ts +1 -1
  51. package/dist/mocks.mjs +306 -441
  52. package/dist/notifications.cjs +226 -314
  53. package/dist/notifications.d.cts +1 -1
  54. package/dist/notifications.d.ts +1 -1
  55. package/dist/notifications.mjs +225 -313
  56. package/dist/react.cjs +522 -693
  57. package/dist/react.d.cts +1 -1
  58. package/dist/react.d.ts +1 -1
  59. package/dist/react.mjs +512 -683
  60. package/dist/support.cjs +329 -325
  61. package/dist/support.d.cts +25 -3
  62. package/dist/support.d.ts +25 -3
  63. package/dist/support.mjs +328 -325
  64. package/dist/telemetry.cjs +197 -301
  65. package/dist/telemetry.d.cts +1 -1
  66. package/dist/telemetry.d.ts +1 -1
  67. package/dist/telemetry.mjs +197 -301
  68. package/dist/{types-Du_iioJ7.d.cts → types-Bx4kTLmk.d.cts} +26 -0
  69. package/dist/{types-BPATkXYu.d.ts → types-Dx0IrOSF.d.ts} +26 -0
  70. package/dist/usage.cjs +163 -227
  71. package/dist/usage.d.cts +1 -1
  72. package/dist/usage.d.ts +1 -1
  73. package/dist/usage.mjs +163 -227
  74. package/dist/webhooks.cjs +258 -359
  75. package/dist/webhooks.d.cts +1 -1
  76. package/dist/webhooks.d.ts +1 -1
  77. package/dist/webhooks.mjs +255 -356
  78. package/package.json +4 -3
  79. package/dist/ai.cjs.map +0 -1
  80. package/dist/ai.mjs.map +0 -1
  81. package/dist/auth.cjs.map +0 -1
  82. package/dist/auth.mjs.map +0 -1
  83. package/dist/build-guard.cjs.map +0 -1
  84. package/dist/build-guard.mjs.map +0 -1
  85. package/dist/catalog.cjs.map +0 -1
  86. package/dist/catalog.mjs.map +0 -1
  87. package/dist/checkout.cjs.map +0 -1
  88. package/dist/checkout.mjs.map +0 -1
  89. package/dist/db-react.cjs.map +0 -1
  90. package/dist/db-react.mjs.map +0 -1
  91. package/dist/db.cjs.map +0 -1
  92. package/dist/db.mjs.map +0 -1
  93. package/dist/entitlements.cjs.map +0 -1
  94. package/dist/entitlements.mjs.map +0 -1
  95. package/dist/errors.cjs.map +0 -1
  96. package/dist/errors.mjs.map +0 -1
  97. package/dist/firestore-compat.cjs.map +0 -1
  98. package/dist/firestore-compat.mjs.map +0 -1
  99. package/dist/index.cjs.map +0 -1
  100. package/dist/index.mjs.map +0 -1
  101. package/dist/mobile.cjs.map +0 -1
  102. package/dist/mobile.mjs.map +0 -1
  103. package/dist/mocks.cjs.map +0 -1
  104. package/dist/mocks.mjs.map +0 -1
  105. package/dist/notifications.cjs.map +0 -1
  106. package/dist/notifications.mjs.map +0 -1
  107. package/dist/react.cjs.map +0 -1
  108. package/dist/react.mjs.map +0 -1
  109. package/dist/support.cjs.map +0 -1
  110. package/dist/support.mjs.map +0 -1
  111. package/dist/telemetry.cjs.map +0 -1
  112. package/dist/telemetry.mjs.map +0 -1
  113. package/dist/usage.cjs.map +0 -1
  114. package/dist/usage.mjs.map +0 -1
  115. package/dist/webhooks.cjs.map +0 -1
  116. package/dist/webhooks.mjs.map +0 -1
package/dist/react.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import * as React2 from 'react';
1
+ import * as l from 'react';
2
2
 
3
3
  // src/react.ts
4
4
 
5
5
  // src/errors.ts
6
- var NeetruError = class _NeetruError extends Error {
6
+ var E = class e extends Error {
7
7
  code;
8
8
  status;
9
9
  requestId;
@@ -16,23 +16,16 @@ var NeetruError = class _NeetruError extends Error {
16
16
  * para um `NeetruDbErrorCode` mais específico (recuperável vs não).
17
17
  */
18
18
  reason;
19
- constructor(code, message, status, requestId, reason) {
20
- super(message);
21
- this.name = "NeetruError";
22
- this.code = code;
23
- this.status = status;
24
- this.requestId = requestId;
25
- this.reason = reason;
26
- Object.setPrototypeOf(this, _NeetruError.prototype);
19
+ constructor(t, i, n, s, c) {
20
+ super(i), this.name = "NeetruError", this.code = t, this.status = n, this.requestId = s, this.reason = c, Object.setPrototypeOf(this, e.prototype);
27
21
  }
28
22
  };
29
23
 
30
24
  // src/types.ts
31
- var DEFAULT_BASE_URL = "https://api.neetru.com";
25
+ var O = "https://api.neetru.com";
32
26
 
33
27
  // src/account-bar.ts
34
- var h = React2.createElement;
35
- var DEFAULT_LABELS = {
28
+ var h = l.createElement, Z = {
36
29
  accountButton: "Abrir menu da conta",
37
30
  appsButton: "Seus produtos Neetru",
38
31
  appsTitle: "Trocar de produto",
@@ -42,186 +35,136 @@ var DEFAULT_LABELS = {
42
35
  currentBadge: "Atual",
43
36
  emptyProducts: "Nenhum outro produto dispon\xEDvel."
44
37
  };
45
- async function fetchNeetruAccountBar(client) {
46
- const auth = client.auth;
47
- const idToken = typeof auth?.getIdToken === "function" ? auth.getIdToken() : null;
48
- if (!idToken) return null;
49
- const config = client.config;
50
- const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
51
- const fetchFn = config.fetch ?? globalThis.fetch;
52
- const url = `${baseUrl}/api/sdk/v1/account/bar`;
38
+ async function Q(e) {
39
+ let t = e.auth, i = typeof t?.getIdToken == "function" ? t.getIdToken() : null;
40
+ if (!i) return null;
41
+ let n = e.config, s = (n.baseUrl ?? O).replace(/\/+$/, ""), c = n.fetch ?? globalThis.fetch, r = `${s}/api/sdk/v1/account/bar`;
53
42
  try {
54
- const res = await fetchFn(url, {
55
- headers: { authorization: `Bearer ${idToken}`, accept: "application/json" }
43
+ let o = await c(r, {
44
+ headers: { authorization: `Bearer ${i}`, accept: "application/json" }
56
45
  });
57
- if (!res.ok) return null;
58
- const body = await res.json();
59
- if (!body || typeof body !== "object" || !body.account) return null;
60
- return {
46
+ if (!o.ok) return null;
47
+ let f = await o.json();
48
+ return !f || typeof f != "object" || !f.account ? null : {
61
49
  account: {
62
- displayName: String(body.account.displayName ?? ""),
63
- email: String(body.account.email ?? ""),
64
- photoUrl: body.account.photoUrl ?? null
50
+ displayName: String(f.account.displayName ?? ""),
51
+ email: String(f.account.email ?? ""),
52
+ photoUrl: f.account.photoUrl ?? null
65
53
  },
66
- accountUrl: String(body.accountUrl ?? "https://minhaconta.neetru.com"),
67
- products: Array.isArray(body.products) ? body.products.filter(
68
- (p) => !!p && typeof p.slug === "string" && typeof p.url === "string"
54
+ accountUrl: String(f.accountUrl ?? "https://minhaconta.neetru.com"),
55
+ products: Array.isArray(f.products) ? f.products.filter(
56
+ (u) => !!u && typeof u.slug == "string" && typeof u.url == "string"
69
57
  ) : []
70
58
  };
71
59
  } catch {
72
60
  return null;
73
61
  }
74
62
  }
75
- function initialsFrom(nameOrEmail) {
76
- const s = (nameOrEmail ?? "").trim();
77
- if (!s) return "?";
78
- const local = s.includes("@") ? s.split("@")[0] : s;
79
- const parts = local.split(/[\s._-]+/).filter(Boolean);
80
- if (parts.length === 0) return local.slice(0, 1).toUpperCase();
81
- if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
82
- return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
63
+ function N(e) {
64
+ let t = (e ?? "").trim();
65
+ if (!t) return "?";
66
+ let i = t.includes("@") ? t.split("@")[0] : t, n = i.split(/[\s._-]+/).filter(Boolean);
67
+ return n.length === 0 ? i.slice(0, 1).toUpperCase() : n.length === 1 ? n[0].slice(0, 2).toUpperCase() : (n[0][0] + n[n.length - 1][0]).toUpperCase();
83
68
  }
84
- var C = {
69
+ var b = {
85
70
  bg: "#ffffff",
86
71
  bgHover: "#f5f5f5",
87
72
  fg: "#0a0a0a",
88
73
  muted: "#666666",
89
74
  border: "#0a0a0a",
90
75
  borderSoft: "#e5e5e5"
91
- };
92
- var SQUARE = 0;
93
- function WaffleIcon({ size = 18, color = C.fg }) {
94
- const dots = [0, 1, 2].flatMap((r) => [0, 1, 2].map((c) => ({ r, c })));
95
- const gap = size / 3;
96
- const dot = Math.max(2, size / 7);
76
+ }, M = 0;
77
+ function ee({ size: e = 18, color: t = b.fg }) {
78
+ let i = [0, 1, 2].flatMap((c) => [0, 1, 2].map((r) => ({ r: c, c: r }))), n = e / 3, s = Math.max(2, e / 7);
97
79
  return h(
98
80
  "svg",
99
- { width: size, height: size, viewBox: `0 0 ${size} ${size}`, "aria-hidden": true, style: { display: "block" } },
100
- dots.map(
101
- ({ r, c }) => h("rect", {
102
- key: `${r}-${c}`,
103
- x: c * gap + (gap - dot) / 2,
104
- y: r * gap + (gap - dot) / 2,
105
- width: dot,
106
- height: dot,
107
- fill: color
81
+ { width: e, height: e, viewBox: `0 0 ${e} ${e}`, "aria-hidden": true, style: { display: "block" } },
82
+ i.map(
83
+ ({ r: c, c: r }) => h("rect", {
84
+ key: `${c}-${r}`,
85
+ x: r * n + (n - s) / 2,
86
+ y: c * n + (n - s) / 2,
87
+ width: s,
88
+ height: s,
89
+ fill: t
108
90
  })
109
91
  )
110
92
  );
111
93
  }
112
- function focusables(container) {
113
- if (!container) return [];
114
- return Array.from(
115
- container.querySelectorAll(
94
+ function H(e) {
95
+ return e ? Array.from(
96
+ e.querySelectorAll(
116
97
  'a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])'
117
98
  )
118
- ).filter((el) => el.offsetParent !== null || el === document.activeElement);
99
+ ).filter((t) => t.offsetParent !== null || t === document.activeElement) : [];
119
100
  }
120
- function NeetruAccountBar({
121
- client,
122
- currentProductSlug,
123
- settingsUrl,
124
- onSignOut,
125
- fetchBar,
126
- labels,
127
- className
101
+ function te({
102
+ client: e,
103
+ currentProductSlug: t,
104
+ settingsUrl: i,
105
+ onSignOut: n,
106
+ fetchBar: s,
107
+ labels: c,
108
+ className: r
128
109
  }) {
129
- const L = { ...DEFAULT_LABELS, ...labels };
130
- const seedAccount = React2.useMemo(() => {
110
+ let o = { ...Z, ...c }, f = l.useMemo(() => {
131
111
  try {
132
- const u = client.auth.getUser();
133
- if (!u) return null;
134
- return {
135
- displayName: u.displayName || u.email || "",
136
- email: u.email || "",
137
- photoUrl: u.photoURL ?? null
138
- };
112
+ let a = e.auth.getUser();
113
+ return a ? {
114
+ displayName: a.displayName || a.email || "",
115
+ email: a.email || "",
116
+ photoUrl: a.photoURL ?? null
117
+ } : null;
139
118
  } catch {
140
119
  return null;
141
120
  }
142
- }, [client]);
143
- const [data, setData] = React2.useState(null);
144
- const [open, setOpen] = React2.useState(null);
145
- const [signingOut, setSigningOut] = React2.useState(false);
146
- const containerRef = React2.useRef(null);
147
- const accountBtnRef = React2.useRef(null);
148
- const appsBtnRef = React2.useRef(null);
149
- const popoverRef = React2.useRef(null);
150
- React2.useEffect(() => {
151
- let cancelled = false;
152
- const run = fetchBar ?? fetchNeetruAccountBar;
153
- Promise.resolve(run(client)).then((res) => {
154
- if (!cancelled && res) setData(res);
121
+ }, [e]), [u, m] = l.useState(null), [y, x] = l.useState(null), [T, R] = l.useState(false), p = l.useRef(null), d = l.useRef(null), g = l.useRef(null), S = l.useRef(null);
122
+ l.useEffect(() => {
123
+ let a = false, k = s ?? Q;
124
+ return Promise.resolve(k(e)).then((v) => {
125
+ !a && v && m(v);
155
126
  }).catch(() => {
156
- });
157
- return () => {
158
- cancelled = true;
127
+ }), () => {
128
+ a = true;
159
129
  };
160
- }, [client, fetchBar]);
161
- const account = data?.account ?? seedAccount;
162
- const accountUrl = data?.accountUrl ?? "https://minhaconta.neetru.com";
163
- const products = data?.products ?? [];
164
- const closeAndRefocus = React2.useCallback((which) => {
165
- setOpen(null);
166
- const trigger = which === "apps" ? appsBtnRef.current : accountBtnRef.current;
167
- trigger?.focus();
130
+ }, [e, s]);
131
+ let C = u?.account ?? f, z = u?.accountUrl ?? "https://minhaconta.neetru.com", U = u?.products ?? [], L = l.useCallback((a) => {
132
+ x(null), (a === "apps" ? g.current : d.current)?.focus();
168
133
  }, []);
169
- React2.useEffect(() => {
170
- if (!open) return;
171
- const first = focusables(popoverRef.current)[0];
172
- first?.focus();
173
- const onDocMouseDown = (e) => {
174
- if (containerRef.current && !containerRef.current.contains(e.target)) {
175
- setOpen(null);
176
- }
134
+ l.useEffect(() => {
135
+ if (!y) return;
136
+ H(S.current)[0]?.focus();
137
+ let k = (v) => {
138
+ p.current && !p.current.contains(v.target) && x(null);
177
139
  };
178
- document.addEventListener("mousedown", onDocMouseDown);
179
- return () => document.removeEventListener("mousedown", onDocMouseDown);
180
- }, [open]);
181
- const onPopoverKeyDown = React2.useCallback(
182
- (e) => {
183
- if (e.key === "Escape") {
184
- e.stopPropagation();
185
- closeAndRefocus(open);
140
+ return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
141
+ }, [y]);
142
+ let P = l.useCallback(
143
+ (a) => {
144
+ if (a.key === "Escape") {
145
+ a.stopPropagation(), L(y);
186
146
  return;
187
147
  }
188
- const items = focusables(popoverRef.current);
189
- if (items.length === 0) return;
190
- const idx = items.indexOf(document.activeElement);
191
- if (e.key === "Tab") {
192
- if (e.shiftKey && idx <= 0) {
193
- e.preventDefault();
194
- items[items.length - 1].focus();
195
- } else if (!e.shiftKey && idx === items.length - 1) {
196
- e.preventDefault();
197
- items[0].focus();
198
- }
199
- } else if (e.key === "ArrowDown") {
200
- e.preventDefault();
201
- items[(idx + 1) % items.length].focus();
202
- } else if (e.key === "ArrowUp") {
203
- e.preventDefault();
204
- items[(idx - 1 + items.length) % items.length].focus();
205
- }
148
+ let k = H(S.current);
149
+ if (k.length === 0) return;
150
+ let v = k.indexOf(document.activeElement);
151
+ a.key === "Tab" ? a.shiftKey && v <= 0 ? (a.preventDefault(), k[k.length - 1].focus()) : !a.shiftKey && v === k.length - 1 && (a.preventDefault(), k[0].focus()) : a.key === "ArrowDown" ? (a.preventDefault(), k[(v + 1) % k.length].focus()) : a.key === "ArrowUp" && (a.preventDefault(), k[(v - 1 + k.length) % k.length].focus());
206
152
  },
207
- [open, closeAndRefocus]
208
- );
209
- const handleSignOut = React2.useCallback(async () => {
210
- if (signingOut) return;
211
- setSigningOut(true);
212
- try {
213
- await client.auth.signOut();
214
- } catch {
215
- } finally {
216
- setSigningOut(false);
217
- setOpen(null);
218
- onSignOut?.();
153
+ [y, L]
154
+ ), G = l.useCallback(async () => {
155
+ if (!T) {
156
+ R(true);
157
+ try {
158
+ await e.auth.signOut();
159
+ } catch {
160
+ } finally {
161
+ R(false), x(null), n?.();
162
+ }
219
163
  }
220
- }, [client, signingOut, onSignOut]);
221
- if (!account) return null;
222
- const initials = initialsFrom(account.displayName || account.email);
223
- const avatarInner = account.photoUrl ? h("img", {
224
- src: account.photoUrl,
164
+ }, [e, T, n]);
165
+ if (!C) return null;
166
+ let I = N(C.displayName || C.email), K = C.photoUrl ? h("img", {
167
+ src: C.photoUrl,
225
168
  alt: "",
226
169
  width: 32,
227
170
  height: 32,
@@ -236,74 +179,69 @@ function NeetruAccountBar({
236
179
  display: "inline-flex",
237
180
  alignItems: "center",
238
181
  justifyContent: "center",
239
- backgroundColor: C.fg,
182
+ backgroundColor: b.fg,
240
183
  color: "#ffffff",
241
184
  fontSize: 13,
242
185
  fontWeight: 700,
243
186
  letterSpacing: "0.02em"
244
187
  }
245
188
  },
246
- initials
247
- );
248
- const iconBtnStyle = (active) => ({
189
+ I
190
+ ), B = (a) => ({
249
191
  display: "inline-flex",
250
192
  alignItems: "center",
251
193
  justifyContent: "center",
252
194
  width: 36,
253
195
  height: 36,
254
196
  padding: 0,
255
- borderRadius: SQUARE,
256
- border: `1px solid ${active ? C.border : C.borderSoft}`,
257
- backgroundColor: active ? C.bgHover : C.bg,
258
- color: C.fg,
197
+ borderRadius: M,
198
+ border: `1px solid ${a ? b.border : b.borderSoft}`,
199
+ backgroundColor: a ? b.bgHover : b.bg,
200
+ color: b.fg,
259
201
  cursor: "pointer",
260
202
  boxSizing: "border-box",
261
203
  fontFamily: "inherit",
262
204
  overflow: "hidden"
263
- });
264
- const appsButton = h(
205
+ }), V = h(
265
206
  "button",
266
207
  {
267
208
  type: "button",
268
- ref: appsBtnRef,
269
- "aria-label": L.appsButton,
209
+ ref: g,
210
+ "aria-label": o.appsButton,
270
211
  "aria-haspopup": "menu",
271
- "aria-expanded": open === "apps",
212
+ "aria-expanded": y === "apps",
272
213
  "data-neetru-appswitcher-button": "true",
273
- onClick: () => setOpen((o) => o === "apps" ? null : "apps"),
274
- style: iconBtnStyle(open === "apps")
214
+ onClick: () => x((a) => a === "apps" ? null : "apps"),
215
+ style: B(y === "apps")
275
216
  },
276
- h(WaffleIcon, {})
277
- );
278
- const accountButton = h(
217
+ h(ee, {})
218
+ ), J = h(
279
219
  "button",
280
220
  {
281
221
  type: "button",
282
- ref: accountBtnRef,
283
- "aria-label": `${L.accountButton}${account.displayName ? ` (${account.displayName})` : ""}`,
222
+ ref: d,
223
+ "aria-label": `${o.accountButton}${C.displayName ? ` (${C.displayName})` : ""}`,
284
224
  "aria-haspopup": "menu",
285
- "aria-expanded": open === "account",
225
+ "aria-expanded": y === "account",
286
226
  "data-neetru-account-button": "true",
287
- onClick: () => setOpen((o) => o === "account" ? null : "account"),
288
- style: { ...iconBtnStyle(open === "account"), width: 36, height: 36 }
227
+ onClick: () => x((a) => a === "account" ? null : "account"),
228
+ style: { ...B(y === "account"), width: 36, height: 36 }
289
229
  },
290
- avatarInner
291
- );
292
- const popoverStyle = {
230
+ K
231
+ ), F = {
293
232
  position: "absolute",
294
233
  top: "calc(100% + 6px)",
295
234
  right: 0,
296
235
  minWidth: 260,
297
236
  maxWidth: 320,
298
- backgroundColor: C.bg,
299
- border: `1px solid ${C.border}`,
300
- borderRadius: SQUARE,
237
+ backgroundColor: b.bg,
238
+ border: `1px solid ${b.border}`,
239
+ borderRadius: M,
301
240
  zIndex: 1e3,
302
- color: C.fg,
241
+ color: b.fg,
303
242
  fontFamily: "inherit"
304
243
  // BMW: sem sombra/glassmorphism — borda sólida define o recorte.
305
- };
306
- const menuItemStyle = {
244
+ }, D = {
307
245
  display: "flex",
308
246
  alignItems: "center",
309
247
  gap: 10,
@@ -311,8 +249,8 @@ function NeetruAccountBar({
311
249
  padding: "10px 14px",
312
250
  background: "transparent",
313
251
  border: "none",
314
- borderTop: `1px solid ${C.borderSoft}`,
315
- color: C.fg,
252
+ borderTop: `1px solid ${b.borderSoft}`,
253
+ color: b.fg,
316
254
  fontSize: 14,
317
255
  fontWeight: 400,
318
256
  textAlign: "left",
@@ -320,24 +258,22 @@ function NeetruAccountBar({
320
258
  cursor: "pointer",
321
259
  boxSizing: "border-box",
322
260
  fontFamily: "inherit"
323
- };
324
- const hoverHandlers = {
325
- onMouseEnter: (e) => {
326
- e.currentTarget.style.backgroundColor = C.bgHover;
261
+ }, _ = {
262
+ onMouseEnter: (a) => {
263
+ a.currentTarget.style.backgroundColor = b.bgHover;
327
264
  },
328
- onMouseLeave: (e) => {
329
- e.currentTarget.style.backgroundColor = "transparent";
265
+ onMouseLeave: (a) => {
266
+ a.currentTarget.style.backgroundColor = "transparent";
330
267
  }
331
- };
332
- const accountPopover = open === "account" ? h(
268
+ }, X = y === "account" ? h(
333
269
  "div",
334
270
  {
335
- ref: popoverRef,
271
+ ref: S,
336
272
  role: "menu",
337
- "aria-label": L.accountButton,
273
+ "aria-label": o.accountButton,
338
274
  "data-neetru-account-menu": "true",
339
- onKeyDown: onPopoverKeyDown,
340
- style: popoverStyle
275
+ onKeyDown: P,
276
+ style: F
341
277
  },
342
278
  // Header identidade
343
279
  h(
@@ -355,19 +291,19 @@ function NeetruAccountBar({
355
291
  alignItems: "center",
356
292
  justifyContent: "center",
357
293
  overflow: "hidden",
358
- backgroundColor: account.photoUrl ? "transparent" : C.fg,
294
+ backgroundColor: C.photoUrl ? "transparent" : b.fg,
359
295
  color: "#ffffff",
360
296
  fontSize: 15,
361
297
  fontWeight: 700
362
298
  }
363
299
  },
364
- account.photoUrl ? h("img", {
365
- src: account.photoUrl,
300
+ C.photoUrl ? h("img", {
301
+ src: C.photoUrl,
366
302
  alt: "",
367
303
  width: 40,
368
304
  height: 40,
369
305
  style: { width: 40, height: 40, objectFit: "cover", display: "block" }
370
- }) : initials
306
+ }) : I
371
307
  ),
372
308
  h(
373
309
  "span",
@@ -383,20 +319,20 @@ function NeetruAccountBar({
383
319
  textOverflow: "ellipsis"
384
320
  }
385
321
  },
386
- account.displayName || account.email
322
+ C.displayName || C.email
387
323
  ),
388
- account.email ? h(
324
+ C.email ? h(
389
325
  "span",
390
326
  {
391
327
  style: {
392
- color: C.muted,
328
+ color: b.muted,
393
329
  fontSize: 12,
394
330
  whiteSpace: "nowrap",
395
331
  overflow: "hidden",
396
332
  textOverflow: "ellipsis"
397
333
  }
398
334
  },
399
- account.email
335
+ C.email
400
336
  ) : null
401
337
  )
402
338
  ),
@@ -405,19 +341,19 @@ function NeetruAccountBar({
405
341
  "a",
406
342
  {
407
343
  role: "menuitem",
408
- href: accountUrl,
344
+ href: z,
409
345
  target: "_blank",
410
346
  rel: "noopener noreferrer",
411
- style: menuItemStyle,
412
- ...hoverHandlers
347
+ style: D,
348
+ ..._
413
349
  },
414
- L.myAccount
350
+ o.myAccount
415
351
  ),
416
352
  // Configurações da conta (deste produto)
417
- settingsUrl ? h(
353
+ i ? h(
418
354
  "a",
419
- { role: "menuitem", href: settingsUrl, style: menuItemStyle, ...hoverHandlers },
420
- L.accountSettings
355
+ { role: "menuitem", href: i, style: D, ..._ },
356
+ o.accountSettings
421
357
  ) : null,
422
358
  // Sair
423
359
  h(
@@ -425,24 +361,23 @@ function NeetruAccountBar({
425
361
  {
426
362
  type: "button",
427
363
  role: "menuitem",
428
- onClick: handleSignOut,
429
- disabled: signingOut,
364
+ onClick: G,
365
+ disabled: T,
430
366
  "data-neetru-signout": "true",
431
- style: { ...menuItemStyle, cursor: signingOut ? "not-allowed" : "pointer" },
432
- ...hoverHandlers
367
+ style: { ...D, cursor: T ? "not-allowed" : "pointer" },
368
+ ..._
433
369
  },
434
- signingOut ? `${L.signOut}\u2026` : L.signOut
370
+ T ? `${o.signOut}\u2026` : o.signOut
435
371
  )
436
- ) : null;
437
- const appsPopover = open === "apps" ? h(
372
+ ) : null, Y = y === "apps" ? h(
438
373
  "div",
439
374
  {
440
- ref: popoverRef,
375
+ ref: S,
441
376
  role: "menu",
442
- "aria-label": L.appsTitle,
377
+ "aria-label": o.appsTitle,
443
378
  "data-neetru-appswitcher-menu": "true",
444
- onKeyDown: onPopoverKeyDown,
445
- style: { ...popoverStyle, minWidth: 280 }
379
+ onKeyDown: P,
380
+ style: { ...F, minWidth: 280 }
446
381
  },
447
382
  h(
448
383
  "div",
@@ -453,15 +388,15 @@ function NeetruAccountBar({
453
388
  fontWeight: 700,
454
389
  letterSpacing: "0.08em",
455
390
  textTransform: "uppercase",
456
- color: C.muted
391
+ color: b.muted
457
392
  }
458
393
  },
459
- L.appsTitle
394
+ o.appsTitle
460
395
  ),
461
- products.length === 0 ? h(
396
+ U.length === 0 ? h(
462
397
  "div",
463
- { style: { padding: "4px 14px 16px", fontSize: 13, color: C.muted } },
464
- L.emptyProducts
398
+ { style: { padding: "4px 14px 16px", fontSize: 13, color: b.muted } },
399
+ o.emptyProducts
465
400
  ) : h(
466
401
  "div",
467
402
  {
@@ -470,21 +405,21 @@ function NeetruAccountBar({
470
405
  gridTemplateColumns: "1fr 1fr",
471
406
  gap: 1,
472
407
  padding: 1,
473
- backgroundColor: C.borderSoft
408
+ backgroundColor: b.borderSoft
474
409
  }
475
410
  },
476
- products.map((p) => {
477
- const isCurrent = !!currentProductSlug && p.slug === currentProductSlug;
411
+ U.map((a) => {
412
+ let k = !!t && a.slug === t;
478
413
  return h(
479
414
  "a",
480
415
  {
481
- key: p.slug,
416
+ key: a.slug,
482
417
  role: "menuitem",
483
- href: p.url,
484
- "aria-current": isCurrent ? "true" : void 0,
485
- "data-neetru-product": p.slug,
486
- "data-current": isCurrent ? "true" : void 0,
487
- title: p.name,
418
+ href: a.url,
419
+ "aria-current": k ? "true" : void 0,
420
+ "data-neetru-product": a.slug,
421
+ "data-current": k ? "true" : void 0,
422
+ title: a.name,
488
423
  style: {
489
424
  display: "flex",
490
425
  flexDirection: "column",
@@ -492,21 +427,21 @@ function NeetruAccountBar({
492
427
  gap: 6,
493
428
  padding: "14px 8px",
494
429
  textDecoration: "none",
495
- color: C.fg,
496
- backgroundColor: isCurrent ? C.bgHover : C.bg,
430
+ color: b.fg,
431
+ backgroundColor: k ? b.bgHover : b.bg,
497
432
  cursor: "pointer",
498
433
  boxSizing: "border-box"
499
434
  },
500
- onMouseEnter: (e) => {
501
- e.currentTarget.style.backgroundColor = C.bgHover;
435
+ onMouseEnter: (v) => {
436
+ v.currentTarget.style.backgroundColor = b.bgHover;
502
437
  },
503
- onMouseLeave: (e) => {
504
- e.currentTarget.style.backgroundColor = isCurrent ? C.bgHover : C.bg;
438
+ onMouseLeave: (v) => {
439
+ v.currentTarget.style.backgroundColor = k ? b.bgHover : b.bg;
505
440
  }
506
441
  },
507
442
  // Tile/ícone
508
- p.iconUrl ? h("img", {
509
- src: p.iconUrl,
443
+ a.iconUrl ? h("img", {
444
+ src: a.iconUrl,
510
445
  alt: "",
511
446
  width: 32,
512
447
  height: 32,
@@ -521,20 +456,20 @@ function NeetruAccountBar({
521
456
  display: "inline-flex",
522
457
  alignItems: "center",
523
458
  justifyContent: "center",
524
- backgroundColor: C.fg,
459
+ backgroundColor: b.fg,
525
460
  color: "#ffffff",
526
461
  fontSize: 13,
527
462
  fontWeight: 700
528
463
  }
529
464
  },
530
- initialsFrom(p.name)
465
+ N(a.name)
531
466
  ),
532
467
  h(
533
468
  "span",
534
469
  {
535
470
  style: {
536
471
  fontSize: 12,
537
- fontWeight: isCurrent ? 700 : 400,
472
+ fontWeight: k ? 700 : 400,
538
473
  textAlign: "center",
539
474
  lineHeight: 1.2,
540
475
  maxWidth: "100%",
@@ -544,9 +479,9 @@ function NeetruAccountBar({
544
479
  width: "100%"
545
480
  }
546
481
  },
547
- p.name
482
+ a.name
548
483
  ),
549
- isCurrent ? h(
484
+ k ? h(
550
485
  "span",
551
486
  {
552
487
  style: {
@@ -554,10 +489,10 @@ function NeetruAccountBar({
554
489
  fontWeight: 700,
555
490
  letterSpacing: "0.08em",
556
491
  textTransform: "uppercase",
557
- color: C.muted
492
+ color: b.muted
558
493
  }
559
494
  },
560
- L.currentBadge
495
+ o.currentBadge
561
496
  ) : null
562
497
  );
563
498
  })
@@ -566,8 +501,8 @@ function NeetruAccountBar({
566
501
  return h(
567
502
  "div",
568
503
  {
569
- ref: containerRef,
570
- className,
504
+ ref: p,
505
+ className: r,
571
506
  "data-neetru-account-bar": "true",
572
507
  style: {
573
508
  position: "relative",
@@ -579,234 +514,205 @@ function NeetruAccountBar({
579
514
  fontFamily: "inherit"
580
515
  }
581
516
  },
582
- appsButton,
583
- accountButton,
584
- accountPopover,
585
- appsPopover
517
+ V,
518
+ J,
519
+ X,
520
+ Y
586
521
  );
587
522
  }
588
523
 
589
524
  // src/firestore-compat.ts
590
- function toDbQuery(constraints) {
591
- const whereFilters = [];
592
- let orderByClause;
593
- let limitValue;
594
- for (const c of constraints) {
525
+ function A(e) {
526
+ let t = [], i, n;
527
+ for (let c of e)
595
528
  if (c.__constraint === "where") {
596
- const w = c;
597
- whereFilters.push({ field: w.field, op: normalizeOp(w.op), value: w.value });
529
+ let r = c;
530
+ t.push({ field: r.field, op: r.op, value: r.value });
598
531
  } else if (c.__constraint === "orderBy") {
599
- const o = c;
600
- orderByClause = { field: o.field, direction: o.direction };
601
- } else if (c.__constraint === "limit") {
602
- limitValue = c.value;
603
- }
604
- }
605
- const out = {};
606
- if (whereFilters.length > 0) out.where = whereFilters;
607
- if (orderByClause) out.orderBy = orderByClause;
608
- if (limitValue !== void 0) out.limit = limitValue;
609
- return out;
610
- }
611
- function normalizeOp(op) {
612
- return op;
532
+ let r = c;
533
+ i = { field: r.field, direction: r.direction };
534
+ } else c.__constraint === "limit" && (n = c.value);
535
+ let s = {};
536
+ return t.length > 0 && (s.where = t), i && (s.orderBy = i), n !== void 0 && (s.limit = n), s;
613
537
  }
614
538
 
615
539
  // src/react.ts
616
- async function startCheckoutViaBff(startPath, input) {
617
- const res = await fetch(startPath, {
540
+ async function ne(e, t) {
541
+ let i = await fetch(e, {
618
542
  method: "POST",
619
543
  headers: { "content-type": "application/json", accept: "application/json" },
620
544
  credentials: "include",
621
- body: JSON.stringify(input)
622
- });
623
- let payload = null;
545
+ body: JSON.stringify(t)
546
+ }), n = null;
624
547
  try {
625
- payload = await res.json();
548
+ n = await i.json();
626
549
  } catch {
627
- payload = null;
550
+ n = null;
628
551
  }
629
- if (!res.ok) {
630
- const p = payload;
631
- const errField = p?.error;
632
- const code = (errField && typeof errField === "object" && typeof errField.code === "string" ? errField.code : void 0) ?? "server_error";
633
- const msg = p && (typeof p.error === "object" && p.error?.message || typeof p.error === "string" && p.error || typeof p.message === "string" && p.message) || `Checkout BFF respondeu HTTP ${res.status}`;
634
- throw new NeetruError(
635
- code,
636
- typeof msg === "string" ? msg : `Checkout BFF respondeu HTTP ${res.status}`,
637
- res.status
552
+ if (!i.ok) {
553
+ let r = n, o = r?.error, f = (o && typeof o == "object" && typeof o.code == "string" ? o.code : void 0) ?? "server_error", u = r && (typeof r.error == "object" && r.error?.message || typeof r.error == "string" && r.error || typeof r.message == "string" && r.message) || `Checkout BFF respondeu HTTP ${i.status}`;
554
+ throw new E(
555
+ f,
556
+ typeof u == "string" ? u : `Checkout BFF respondeu HTTP ${i.status}`,
557
+ i.status
638
558
  );
639
559
  }
640
- const intent = payload?.intent ?? payload ?? {};
641
- const redirectUrl = payload?.redirectUrl ?? intent.redirectUrl;
642
- if (!redirectUrl || typeof redirectUrl !== "string") {
643
- throw new NeetruError(
560
+ let s = n?.intent ?? n ?? {}, c = n?.redirectUrl ?? s.redirectUrl;
561
+ if (!c || typeof c != "string")
562
+ throw new E(
644
563
  "invalid_response",
645
564
  "Resposta do route BFF de checkout sem `redirectUrl`."
646
565
  );
647
- }
648
566
  return {
649
- intentId: String(payload?.intentId ?? intent.intentId ?? ""),
650
- redirectUrl,
651
- status: payload?.status ?? intent.status ?? "pending",
652
- expiresAt: typeof payload?.expiresAt === "string" ? payload.expiresAt : typeof intent.expiresAt === "string" ? intent.expiresAt : "",
653
- requiresKyc: payload?.requiresKyc === true || intent.requiresKyc === true
567
+ intentId: String(n?.intentId ?? s.intentId ?? ""),
568
+ redirectUrl: c,
569
+ status: n?.status ?? s.status ?? "pending",
570
+ expiresAt: typeof n?.expiresAt == "string" ? n.expiresAt : typeof s.expiresAt == "string" ? s.expiresAt : "",
571
+ requiresKyc: n?.requiresKyc === true || s.requiresKyc === true
654
572
  };
655
573
  }
656
- function checkoutRedirect(url) {
657
- const loc = globalThis.location;
658
- if (loc && typeof loc.assign === "function") loc.assign(url);
574
+ function re(e) {
575
+ let t = globalThis.location;
576
+ t && typeof t.assign == "function" && t.assign(e);
659
577
  }
660
- function CheckoutLink({
661
- client,
662
- startPath,
663
- productId,
664
- planId,
665
- callbackUrl,
666
- tenantType,
667
- tenantId,
668
- children,
669
- onIntentCreated,
670
- onError,
671
- noAutoRedirect,
672
- ...rest
578
+ function xe({
579
+ client: e,
580
+ startPath: t,
581
+ productId: i,
582
+ planId: n,
583
+ callbackUrl: s,
584
+ tenantType: c,
585
+ tenantId: r,
586
+ children: o,
587
+ onIntentCreated: f,
588
+ onError: u,
589
+ noAutoRedirect: m,
590
+ ...y
673
591
  }) {
674
- const [submitting, setSubmitting] = React2.useState(false);
675
- const checkout = client?.checkout;
676
- const handleClick = React2.useCallback(
677
- async (event) => {
678
- event.preventDefault();
679
- if (submitting) return;
680
- if (startPath) {
681
- setSubmitting(true);
592
+ let [x, T] = l.useState(false), R = e?.checkout, p = l.useCallback(
593
+ async (d) => {
594
+ if (d.preventDefault(), !x) {
595
+ if (t) {
596
+ T(true);
597
+ try {
598
+ let g = await ne(t, {
599
+ productId: i,
600
+ planId: n,
601
+ callbackUrl: s,
602
+ tenantType: c,
603
+ tenantId: r
604
+ });
605
+ f?.(g), m || re(g.redirectUrl);
606
+ } catch (g) {
607
+ u?.(g instanceof Error ? g : new Error(String(g)));
608
+ } finally {
609
+ T(false);
610
+ }
611
+ return;
612
+ }
613
+ if (!R || typeof R.start != "function") {
614
+ u?.(
615
+ new Error(
616
+ "CheckoutLink: passe `startPath` (padr\xE3o BFF/cookie recomendado) OU um `client` com o namespace `checkout` (SDK 1.1+)."
617
+ )
618
+ );
619
+ return;
620
+ }
621
+ T(true);
682
622
  try {
683
- const result = await startCheckoutViaBff(startPath, {
684
- productId,
685
- planId,
686
- callbackUrl,
687
- tenantType,
688
- tenantId
623
+ let g = await R.start({
624
+ productId: i,
625
+ planId: n,
626
+ callbackUrl: s,
627
+ tenantType: c,
628
+ tenantId: r,
629
+ autoRedirect: !m
689
630
  });
690
- onIntentCreated?.(result);
691
- if (!noAutoRedirect) checkoutRedirect(result.redirectUrl);
692
- } catch (err) {
693
- onError?.(err instanceof Error ? err : new Error(String(err)));
631
+ f?.(g);
632
+ } catch (g) {
633
+ u?.(g instanceof Error ? g : new Error(String(g)));
694
634
  } finally {
695
- setSubmitting(false);
635
+ T(false);
696
636
  }
697
- return;
698
- }
699
- if (!checkout || typeof checkout.start !== "function") {
700
- onError?.(
701
- new Error(
702
- "CheckoutLink: passe `startPath` (padr\xE3o BFF/cookie recomendado) OU um `client` com o namespace `checkout` (SDK 1.1+)."
703
- )
704
- );
705
- return;
706
- }
707
- setSubmitting(true);
708
- try {
709
- const result = await checkout.start({
710
- productId,
711
- planId,
712
- callbackUrl,
713
- tenantType,
714
- tenantId,
715
- autoRedirect: !noAutoRedirect
716
- });
717
- onIntentCreated?.(result);
718
- } catch (err) {
719
- onError?.(err instanceof Error ? err : new Error(String(err)));
720
- } finally {
721
- setSubmitting(false);
722
637
  }
723
638
  },
724
- [submitting, checkout, startPath, productId, planId, callbackUrl, tenantType, tenantId, noAutoRedirect, onIntentCreated, onError]
639
+ [x, R, t, i, n, s, c, r, m, f, u]
725
640
  );
726
- return React2.createElement(
641
+ return l.createElement(
727
642
  "a",
728
643
  {
729
- ...rest,
730
- href: rest.href ?? "#",
731
- onClick: handleClick,
732
- "aria-busy": submitting || void 0,
644
+ ...y,
645
+ href: y.href ?? "#",
646
+ onClick: p,
647
+ "aria-busy": x || void 0,
733
648
  "data-neetru-checkout-link": "true"
734
649
  },
735
- children
650
+ o
736
651
  );
737
652
  }
738
- var NEETRU_FLAME_PATH = "M 281 5.163 C 240.659 26.308, 211.260 52.739, 187.750 89 C 177.297 105.123, 167.942 126.107, 162.988 144.543 C 154.486 176.188, 153.303 204.118, 159.101 236.317 C 161.553 249.934, 164.601 259.065, 171.539 273.568 C 179.323 289.843, 188.311 302.619, 205.856 322.343 C 216.993 334.865, 218.719 337.460, 223.536 348.944 C 233.797 373.403, 237.419 401.984, 232.417 419.032 C 229.111 430.300, 219.859 441.975, 210.427 446.779 C 186.006 459.218, 155.612 448.383, 142.319 422.500 C 128.813 396.204, 123.953 356.753, 129.495 318.395 C 131.172 306.786, 138.276 276.222, 140.080 272.850 C 140.675 271.738, 140.944 270.610, 140.676 270.343 C 139.995 269.662, 121.004 281.262, 112 287.859 C 100.565 296.237, 95.542 300.566, 83.993 312 C 44.470 351.127, 19.275 398.763, 8.623 454.500 C 4.302 477.115, 3.308 513.551, 6.332 538.569 C 9.164 562.011, 17.855 591.852, 27.324 610.648 C 37.693 631.233, 54.130 653.987, 71.900 672.357 C 80.540 681.289, 98.477 696.992, 104.478 700.878 C 106.690 702.310, 108.725 703.766, 109 704.114 C 109.836 705.172, 125.939 715.307, 135.539 720.817 C 152.923 730.795, 169.097 737.316, 200.500 747.009 C 204.454 748.230, 222.087 751.463, 234 753.153 C 246.383 754.909, 283.484 754.921, 296 753.173 C 310.006 751.217, 321.722 749.122, 328.500 747.360 C 384.024 732.928, 433.393 701.075, 469.555 656.351 C 491.448 629.275, 505.223 601.823, 514.391 567 C 519.380 548.047, 520.999 536.377, 521.686 514.410 C 523.126 468.370, 514.560 426.479, 494.812 383 C 471.567 331.818, 436.019 282.480, 379.951 223.582 C 354.302 196.638, 349.024 190.981, 341.670 182.551 C 318.918 156.471, 301.763 128.316, 293.505 103.500 C 286.625 82.826, 285.662 76.446, 285.578 51 C 285.500 27.576, 285.510 27.460, 288.750 15.129 C 290.538 8.326, 292 2.363, 292 1.879 C 292 0.197, 288.454 1.255, 281 5.163";
739
- var NEETRU_FLAME_VIEWBOX = "0 0 527 760";
740
- var NEETRU_FLAME_ASPECT = 527 / 760;
741
- function NeetruFlameIcon({ fill, size = 16 }) {
742
- return React2.createElement(
653
+ var oe = "M 281 5.163 C 240.659 26.308, 211.260 52.739, 187.750 89 C 177.297 105.123, 167.942 126.107, 162.988 144.543 C 154.486 176.188, 153.303 204.118, 159.101 236.317 C 161.553 249.934, 164.601 259.065, 171.539 273.568 C 179.323 289.843, 188.311 302.619, 205.856 322.343 C 216.993 334.865, 218.719 337.460, 223.536 348.944 C 233.797 373.403, 237.419 401.984, 232.417 419.032 C 229.111 430.300, 219.859 441.975, 210.427 446.779 C 186.006 459.218, 155.612 448.383, 142.319 422.500 C 128.813 396.204, 123.953 356.753, 129.495 318.395 C 131.172 306.786, 138.276 276.222, 140.080 272.850 C 140.675 271.738, 140.944 270.610, 140.676 270.343 C 139.995 269.662, 121.004 281.262, 112 287.859 C 100.565 296.237, 95.542 300.566, 83.993 312 C 44.470 351.127, 19.275 398.763, 8.623 454.500 C 4.302 477.115, 3.308 513.551, 6.332 538.569 C 9.164 562.011, 17.855 591.852, 27.324 610.648 C 37.693 631.233, 54.130 653.987, 71.900 672.357 C 80.540 681.289, 98.477 696.992, 104.478 700.878 C 106.690 702.310, 108.725 703.766, 109 704.114 C 109.836 705.172, 125.939 715.307, 135.539 720.817 C 152.923 730.795, 169.097 737.316, 200.500 747.009 C 204.454 748.230, 222.087 751.463, 234 753.153 C 246.383 754.909, 283.484 754.921, 296 753.173 C 310.006 751.217, 321.722 749.122, 328.500 747.360 C 384.024 732.928, 433.393 701.075, 469.555 656.351 C 491.448 629.275, 505.223 601.823, 514.391 567 C 519.380 548.047, 520.999 536.377, 521.686 514.410 C 523.126 468.370, 514.560 426.479, 494.812 383 C 471.567 331.818, 436.019 282.480, 379.951 223.582 C 354.302 196.638, 349.024 190.981, 341.670 182.551 C 318.918 156.471, 301.763 128.316, 293.505 103.500 C 286.625 82.826, 285.662 76.446, 285.578 51 C 285.500 27.576, 285.510 27.460, 288.750 15.129 C 290.538 8.326, 292 2.363, 292 1.879 C 292 0.197, 288.454 1.255, 281 5.163", ie = "0 0 527 760", se = 527 / 760;
654
+ function ae({ fill: e, size: t = 16 }) {
655
+ return l.createElement(
743
656
  "svg",
744
657
  {
745
- viewBox: NEETRU_FLAME_VIEWBOX,
746
- width: Math.round(size * NEETRU_FLAME_ASPECT),
747
- height: size,
658
+ viewBox: ie,
659
+ width: Math.round(t * se),
660
+ height: t,
748
661
  "aria-hidden": true,
749
662
  style: { flexShrink: 0 }
750
663
  },
751
- React2.createElement("path", { d: NEETRU_FLAME_PATH, fill })
664
+ l.createElement("path", { d: oe, fill: e })
752
665
  );
753
666
  }
754
- var NEETRU_LOGIN_BUTTON_THEME = {
667
+ var ce = {
755
668
  dark: { bg: "#0a0a0a", bgHover: "#1a1a1a", fg: "#ffffff", border: "#0a0a0a" },
756
669
  light: { bg: "#ffffff", bgHover: "#f5f5f5", fg: "#0a0a0a", border: "#0a0a0a" }
757
- };
758
- var NEETRU_LOGIN_FOCUS_STYLE_ID = "neetru-login-button-focus-style";
759
- var NEETRU_LOGIN_FOCUS_CSS = "button[data-neetru-login-button]:focus-visible{outline:2px solid var(--neetru-login-focus-ring,#ffffff);outline-offset:2px;}";
760
- function ensureLoginFocusStyleInjected() {
761
- if (typeof document === "undefined" || !document.head) return;
762
- if (document.getElementById(NEETRU_LOGIN_FOCUS_STYLE_ID)) return;
763
- const styleEl = document.createElement("style");
764
- styleEl.id = NEETRU_LOGIN_FOCUS_STYLE_ID;
765
- styleEl.textContent = NEETRU_LOGIN_FOCUS_CSS;
766
- document.head.appendChild(styleEl);
670
+ }, W = "neetru-login-button-focus-style", le = "button[data-neetru-login-button]:focus-visible{outline:2px solid var(--neetru-login-focus-ring,#ffffff);outline-offset:2px;}";
671
+ function ue() {
672
+ if (typeof document > "u" || !document.head || document.getElementById(W)) return;
673
+ let e = document.createElement("style");
674
+ e.id = W, e.textContent = le, document.head.appendChild(e);
767
675
  }
768
- function NeetruLoginButton({
769
- client,
770
- redirectUri,
771
- scope,
772
- postLoginRedirect,
773
- theme = "dark",
774
- label = "Entrar com Neetru",
775
- onError,
776
- style,
777
- disabled,
778
- ...rest
676
+ function we({
677
+ client: e,
678
+ redirectUri: t,
679
+ scope: i,
680
+ postLoginRedirect: n,
681
+ theme: s = "dark",
682
+ label: c = "Entrar com Neetru",
683
+ onError: r,
684
+ style: o,
685
+ disabled: f,
686
+ ...u
779
687
  }) {
780
- const [isLoading, setIsLoading] = React2.useState(false);
781
- const [isHover, setIsHover] = React2.useState(false);
782
- const colors = NEETRU_LOGIN_BUTTON_THEME[theme];
783
- const isDisabled = Boolean(disabled) || isLoading;
784
- React2.useEffect(() => {
785
- ensureLoginFocusStyleInjected();
688
+ let [m, y] = l.useState(false), [x, T] = l.useState(false), R = ce[s], p = !!f || m;
689
+ l.useEffect(() => {
690
+ ue();
786
691
  }, []);
787
- const handleClick = React2.useCallback(async () => {
788
- if (isDisabled) return;
789
- setIsLoading(true);
790
- try {
791
- const options = { redirectUri, scope, postLoginRedirect };
792
- await client.auth.signIn(options);
793
- } catch (err) {
794
- onError?.(err instanceof Error ? err : new Error(String(err)));
795
- } finally {
796
- setIsLoading(false);
692
+ let d = l.useCallback(async () => {
693
+ if (!p) {
694
+ y(true);
695
+ try {
696
+ let g = { redirectUri: t, scope: i, postLoginRedirect: n };
697
+ await e.auth.signIn(g);
698
+ } catch (g) {
699
+ r?.(g instanceof Error ? g : new Error(String(g)));
700
+ } finally {
701
+ y(false);
702
+ }
797
703
  }
798
- }, [client, redirectUri, scope, postLoginRedirect, isDisabled, onError]);
799
- return React2.createElement(
704
+ }, [e, t, i, n, p, r]);
705
+ return l.createElement(
800
706
  "button",
801
707
  {
802
- ...rest,
708
+ ...u,
803
709
  type: "button",
804
- onClick: handleClick,
805
- disabled: isDisabled,
806
- onMouseEnter: () => setIsHover(true),
807
- onMouseLeave: () => setIsHover(false),
808
- "aria-label": rest["aria-label"] ?? label,
809
- "aria-busy": isLoading || void 0,
710
+ onClick: d,
711
+ disabled: p,
712
+ onMouseEnter: () => T(true),
713
+ onMouseLeave: () => T(false),
714
+ "aria-label": u["aria-label"] ?? c,
715
+ "aria-busy": m || void 0,
810
716
  "data-neetru-login-button": "true",
811
717
  style: {
812
718
  display: "inline-flex",
@@ -817,346 +723,269 @@ function NeetruLoginButton({
817
723
  height: "48px",
818
724
  padding: "0 20px",
819
725
  borderRadius: 0,
820
- border: `1px solid ${colors.border}`,
821
- backgroundColor: isHover && !isDisabled ? colors.bgHover : colors.bg,
822
- color: colors.fg,
726
+ border: `1px solid ${R.border}`,
727
+ backgroundColor: x && !p ? R.bgHover : R.bg,
728
+ color: R.fg,
823
729
  fontSize: "14px",
824
730
  fontWeight: 700,
825
731
  textTransform: "uppercase",
826
732
  letterSpacing: "0.08em",
827
733
  fontFamily: "inherit",
828
734
  lineHeight: 1,
829
- cursor: isDisabled ? "not-allowed" : "pointer",
830
- opacity: isDisabled && !isLoading ? 0.6 : 1,
735
+ cursor: p ? "not-allowed" : "pointer",
736
+ opacity: p && !m ? 0.6 : 1,
831
737
  transition: "background-color 150ms ease",
832
738
  boxSizing: "border-box",
833
739
  // Cor do ring de foco de teclado (:focus-visible) — ver
834
740
  // NEETRU_LOGIN_FOCUS_CSS. Usa a cor do texto (contraste AA garantido).
835
- "--neetru-login-focus-ring": colors.fg,
836
- ...style
741
+ "--neetru-login-focus-ring": R.fg,
742
+ ...o
837
743
  }
838
744
  },
839
- React2.createElement(NeetruFlameIcon, { fill: colors.fg }),
840
- React2.createElement("span", null, isLoading ? "Entrando\u2026" : label)
745
+ l.createElement(ae, { fill: R.fg }),
746
+ l.createElement("span", null, m ? "Entrando\u2026" : c)
841
747
  );
842
748
  }
843
- var EntitlementContext = React2.createContext({
749
+ var j = l.createContext({
844
750
  readonly: false
845
751
  });
846
- function useEntitlementContext() {
847
- return React2.useContext(EntitlementContext);
752
+ function Ce() {
753
+ return l.useContext(j);
848
754
  }
849
- function EntitlementGate({
850
- client,
851
- feature,
852
- productSlug,
853
- mode = "block",
854
- fallback,
855
- loading,
856
- children
755
+ function Se({
756
+ client: e,
757
+ feature: t,
758
+ productSlug: i,
759
+ mode: n = "block",
760
+ fallback: s,
761
+ loading: c,
762
+ children: r
857
763
  }) {
858
- const [state, setState] = React2.useState({
764
+ let [o, f] = l.useState({
859
765
  status: "loading"
860
- });
861
- const resolvedSlug = productSlug ?? client.config.productId ?? "";
862
- const resolvedTenantId = client.config.tenantId;
863
- React2.useEffect(() => {
864
- let cancelled = false;
865
- const run = async () => {
766
+ }), u = i ?? e.config.productId ?? "", m = e.config.tenantId;
767
+ if (l.useEffect(() => {
768
+ let R = false;
769
+ return (async () => {
866
770
  try {
867
- let result2;
868
- const usage = client.usage;
869
- if (usage && typeof usage.check === "function" && resolvedTenantId) {
870
- const res = await usage.check(feature, {
871
- productId: resolvedSlug,
872
- tenantId: resolvedTenantId
771
+ let d, g = e.usage;
772
+ if (g && typeof g.check == "function" && m) {
773
+ let S = await g.check(t, {
774
+ productId: u,
775
+ tenantId: m
873
776
  });
874
- result2 = {
875
- allowed: res.allowed === true,
876
- reason: res.reason,
877
- limit: res.limit,
878
- currentUsage: res.currentUsage,
879
- behavior: res.behavior
777
+ d = {
778
+ allowed: S.allowed === !0,
779
+ reason: S.reason,
780
+ limit: S.limit,
781
+ currentUsage: S.currentUsage,
782
+ behavior: S.behavior
880
783
  };
881
- } else {
882
- if (typeof console !== "undefined") {
883
- console.warn(
884
- "[EntitlementGate] tenantId ausente em client.config \u2014 n\xE3o \xE9 poss\xEDvel verificar entitlement (client.entitlements.check() est\xE1 deprecado, ver src/entitlements.ts). Configure tenantId no createNeetruClient() ou passe via props. Bloqueando por padr\xE3o (fail-closed)."
885
- );
886
- }
887
- result2 = { allowed: false, reason: "tenant_id_required" };
888
- }
889
- if (!cancelled) setState({ status: "ready", result: result2 });
890
- } catch (err) {
891
- if (!cancelled) {
892
- setState({ status: "ready", result: { allowed: true, reason: "check_error_fallback" } });
893
- }
894
- if (typeof console !== "undefined") console.warn("[EntitlementGate] check failed \u2014 fail-open", err);
784
+ } else
785
+ typeof console < "u" && console.warn(
786
+ "[EntitlementGate] tenantId ausente em client.config \u2014 n\xE3o \xE9 poss\xEDvel verificar entitlement (client.entitlements.check() est\xE1 deprecado, ver src/entitlements.ts). Configure tenantId no createNeetruClient() ou passe via props. Bloqueando por padr\xE3o (fail-closed)."
787
+ ), d = { allowed: !1, reason: "tenant_id_required" };
788
+ R || f({ status: "ready", result: d });
789
+ } catch (d) {
790
+ R || f({ status: "ready", result: { allowed: true, reason: "check_error_fallback" } }), typeof console < "u" && console.warn("[EntitlementGate] check failed \u2014 fail-open", d);
895
791
  }
792
+ })(), () => {
793
+ R = true;
896
794
  };
897
- run();
898
- return () => {
899
- cancelled = true;
900
- };
901
- }, [client, feature, resolvedSlug, resolvedTenantId]);
902
- if (state.status === "loading") {
903
- return React2.createElement(React2.Fragment, null, loading ?? null);
904
- }
905
- const result = state.result;
906
- const allowed = result?.allowed === true;
907
- const isReadonly = !allowed && (mode === "readonly" || result?.behavior === "readonly");
908
- if (!allowed && mode === "block" && !isReadonly) {
909
- return React2.createElement(React2.Fragment, null, fallback ?? null);
910
- }
911
- return React2.createElement(
912
- EntitlementContext.Provider,
795
+ }, [e, t, u, m]), o.status === "loading")
796
+ return l.createElement(l.Fragment, null, c ?? null);
797
+ let y = o.result, x = y?.allowed === true, T = !x && (n === "readonly" || y?.behavior === "readonly");
798
+ return !x && n === "block" && !T ? l.createElement(l.Fragment, null, s ?? null) : l.createElement(
799
+ j.Provider,
913
800
  {
914
801
  value: {
915
- readonly: isReadonly,
916
- reason: result?.reason,
917
- limit: result?.limit,
918
- currentUsage: result?.currentUsage
802
+ readonly: T,
803
+ reason: y?.reason,
804
+ limit: y?.limit,
805
+ currentUsage: y?.currentUsage
919
806
  }
920
807
  },
921
- children
808
+ r
922
809
  );
923
810
  }
924
- var DEFAULT_INTERVAL_MS = 5e3;
925
- function isDocumentHidden() {
926
- return typeof document !== "undefined" && document.hidden === true;
811
+ var $ = 5e3;
812
+ function q() {
813
+ return typeof document < "u" && document.hidden === true;
927
814
  }
928
- function serializeSource(source) {
929
- if (!source) return null;
930
- if (source.__kind === "collection") {
931
- return `collection:${source.id}`;
932
- }
933
- const dbQuery = toDbQuery(source.constraints);
934
- return `query:${source.collection}:${JSON.stringify(dbQuery)}`;
815
+ function de(e) {
816
+ if (!e) return null;
817
+ if (e.__kind === "collection")
818
+ return `collection:${e.id}`;
819
+ let t = A(e.constraints);
820
+ return `query:${e.collection}:${JSON.stringify(t)}`;
935
821
  }
936
- function rowsFromList(snap) {
937
- return snap.docs.map((d) => {
938
- const data = d.data;
939
- const { id: _omit, ...rest } = data;
940
- return { ...rest, id: d.id };
822
+ function pe(e) {
823
+ return e.docs.map((t) => {
824
+ let i = t.data, { id: n, ...s } = i;
825
+ return { ...s, id: t.id };
941
826
  });
942
827
  }
943
- function rowFromGet(snap, id) {
944
- const first = snap?.docs[0];
945
- if (!first) return null;
946
- const data = first.data;
947
- const { id: _omit, ...rest } = data;
948
- return { ...rest, id };
828
+ function ge(e, t) {
829
+ let i = e?.docs[0];
830
+ if (!i) return null;
831
+ let n = i.data, { id: s, ...c } = n;
832
+ return { ...c, id: t };
949
833
  }
950
- function useCollection(source, options) {
951
- const intervalMs = options?.intervalMs ?? DEFAULT_INTERVAL_MS;
952
- const poll = options?.poll ?? false;
953
- const sourceKey = serializeSource(
954
- source
955
- );
956
- const [state, setState] = React2.useState({
834
+ function ve(e, t) {
835
+ let i = t?.intervalMs ?? $, n = t?.poll ?? false, s = de(
836
+ e
837
+ ), [c, r] = l.useState({
957
838
  data: null,
958
- isLoading: sourceKey !== null,
839
+ isLoading: s !== null,
959
840
  error: null,
960
841
  isStale: false,
961
842
  lastUpdated: null
962
- });
963
- const mountedRef = React2.useRef(true);
964
- const sourceRef = React2.useRef(source);
965
- sourceRef.current = source;
966
- React2.useEffect(() => {
967
- mountedRef.current = true;
968
- const current = sourceRef.current;
969
- if (!current || sourceKey === null) {
970
- setState({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null });
971
- return () => {
972
- mountedRef.current = false;
843
+ }), o = l.useRef(true), f = l.useRef(e);
844
+ return f.current = e, l.useEffect(() => {
845
+ o.current = true;
846
+ let u = f.current;
847
+ if (!u || s === null)
848
+ return r({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
849
+ o.current = false;
973
850
  };
974
- }
975
- setState((prev) => ({ ...prev, isLoading: prev.data === null }));
976
- const collectionName = current.__kind === "query" ? current.collection : current.id;
977
- const dbQuery = current.__kind === "query" ? toDbQuery(current.constraints) : void 0;
978
- const col = current.db.collection(collectionName);
979
- const applySnap = (snap) => {
980
- if (!mountedRef.current) return;
981
- setState({
982
- data: rowsFromList(snap),
851
+ r((d) => ({ ...d, isLoading: d.data === null }));
852
+ let m = u.__kind === "query" ? u.collection : u.id, y = u.__kind === "query" ? A(u.constraints) : void 0, x = u.db.collection(m), T = (d) => {
853
+ o.current && r({
854
+ data: pe(d),
983
855
  isLoading: false,
984
856
  error: null,
985
- isStale: snap.stale === true,
857
+ isStale: d.stale === true,
986
858
  lastUpdated: Date.now()
987
859
  });
988
- };
989
- const applyError = (e) => {
990
- if (!mountedRef.current) return;
991
- setState((prev) => ({
992
- ...prev,
860
+ }, R = (d) => {
861
+ o.current && r((g) => ({
862
+ ...g,
993
863
  // Mantém o último data bom — não limpa em erro de refresh.
994
864
  isLoading: false,
995
- error: e instanceof Error ? e : new Error(String(e)),
865
+ error: d instanceof Error ? d : new Error(String(d)),
996
866
  isStale: true
997
867
  }));
998
868
  };
999
- if (poll) {
1000
- let cancelled = false;
1001
- const fetchOnce = async () => {
1002
- if (cancelled || isDocumentHidden()) return;
1003
- try {
1004
- const snap = await col.list(dbQuery);
1005
- if (!cancelled) applySnap(snap);
1006
- } catch (e) {
1007
- if (!cancelled) applyError(e);
1008
- }
869
+ if (n) {
870
+ let d = false, g = async () => {
871
+ if (!(d || q()))
872
+ try {
873
+ let C = await x.list(y);
874
+ d || T(C);
875
+ } catch (C) {
876
+ d || R(C);
877
+ }
1009
878
  };
1010
- void fetchOnce();
1011
- const timer = setInterval(fetchOnce, intervalMs);
879
+ g();
880
+ let S = setInterval(g, i);
1012
881
  return () => {
1013
- cancelled = true;
1014
- clearInterval(timer);
1015
- mountedRef.current = false;
882
+ d = true, clearInterval(S), o.current = false;
1016
883
  };
1017
884
  }
1018
- let unsub;
885
+ let p;
1019
886
  try {
1020
- unsub = col.onSnapshot(dbQuery, applySnap);
1021
- } catch (e) {
1022
- applyError(e);
887
+ p = x.onSnapshot(y, T);
888
+ } catch (d) {
889
+ R(d);
1023
890
  }
1024
891
  return () => {
1025
- mountedRef.current = false;
1026
- unsub?.();
892
+ o.current = false, p?.();
1027
893
  };
1028
- }, [sourceKey, intervalMs, poll]);
1029
- return state;
894
+ }, [s, i, n]), c;
1030
895
  }
1031
- function useDoc(ref, options) {
1032
- const intervalMs = options?.intervalMs ?? DEFAULT_INTERVAL_MS;
1033
- const poll = options?.poll ?? false;
1034
- const refKey = ref && ref.id ? `${ref.collection}/${ref.id}` : null;
1035
- const [state, setState] = React2.useState({
896
+ function Ee(e, t) {
897
+ let i = t?.intervalMs ?? $, n = t?.poll ?? false, s = e && e.id ? `${e.collection}/${e.id}` : null, [c, r] = l.useState({
1036
898
  data: null,
1037
- isLoading: refKey !== null,
899
+ isLoading: s !== null,
1038
900
  error: null,
1039
901
  isStale: false,
1040
902
  lastUpdated: null
1041
- });
1042
- const mountedRef = React2.useRef(true);
1043
- const refRef = React2.useRef(ref);
1044
- refRef.current = ref;
1045
- React2.useEffect(() => {
1046
- mountedRef.current = true;
1047
- const current = refRef.current;
1048
- if (!current || refKey === null) {
1049
- setState({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null });
1050
- return () => {
1051
- mountedRef.current = false;
903
+ }), o = l.useRef(true), f = l.useRef(e);
904
+ return f.current = e, l.useEffect(() => {
905
+ o.current = true;
906
+ let u = f.current;
907
+ if (!u || s === null)
908
+ return r({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
909
+ o.current = false;
1052
910
  };
1053
- }
1054
- setState((prev) => ({ ...prev, isLoading: prev.data === null }));
1055
- const docRef = current.db.collection(current.collection).doc(current.id);
1056
- const id = current.id;
1057
- const applySnap = (snap) => {
1058
- if (!mountedRef.current) return;
1059
- setState({
1060
- data: rowFromGet(snap, id),
911
+ r((p) => ({ ...p, isLoading: p.data === null }));
912
+ let m = u.db.collection(u.collection).doc(u.id), y = u.id, x = (p) => {
913
+ o.current && r({
914
+ data: ge(p, y),
1061
915
  isLoading: false,
1062
916
  error: null,
1063
- isStale: snap?.stale === true,
917
+ isStale: p?.stale === true,
1064
918
  lastUpdated: Date.now()
1065
919
  });
1066
- };
1067
- const applyError = (e) => {
1068
- if (!mountedRef.current) return;
1069
- setState((prev) => ({
1070
- ...prev,
920
+ }, T = (p) => {
921
+ o.current && r((d) => ({
922
+ ...d,
1071
923
  isLoading: false,
1072
- error: e instanceof Error ? e : new Error(String(e)),
924
+ error: p instanceof Error ? p : new Error(String(p)),
1073
925
  isStale: true
1074
926
  }));
1075
927
  };
1076
- if (poll) {
1077
- let cancelled = false;
1078
- const fetchOnce = async () => {
1079
- if (cancelled || isDocumentHidden()) return;
1080
- try {
1081
- const snap = await docRef.get();
1082
- if (!cancelled) applySnap(snap);
1083
- } catch (e) {
1084
- if (!cancelled) applyError(e);
1085
- }
928
+ if (n) {
929
+ let p = false, d = async () => {
930
+ if (!(p || q()))
931
+ try {
932
+ let S = await m.get();
933
+ p || x(S);
934
+ } catch (S) {
935
+ p || T(S);
936
+ }
1086
937
  };
1087
- void fetchOnce();
1088
- const timer = setInterval(fetchOnce, intervalMs);
938
+ d();
939
+ let g = setInterval(d, i);
1089
940
  return () => {
1090
- cancelled = true;
1091
- clearInterval(timer);
1092
- mountedRef.current = false;
941
+ p = true, clearInterval(g), o.current = false;
1093
942
  };
1094
943
  }
1095
- let unsub;
944
+ let R;
1096
945
  try {
1097
- unsub = docRef.onSnapshot(applySnap);
1098
- } catch (e) {
1099
- applyError(e);
946
+ R = m.onSnapshot(x);
947
+ } catch (p) {
948
+ T(p);
1100
949
  }
1101
950
  return () => {
1102
- mountedRef.current = false;
1103
- unsub?.();
951
+ o.current = false, R?.();
1104
952
  };
1105
- }, [refKey, intervalMs, poll]);
1106
- return state;
953
+ }, [s, i, n]), c;
1107
954
  }
1108
- function resolveAuth(input) {
1109
- const maybe = input;
1110
- if (maybe.auth && typeof maybe.auth.onAuthStateChanged === "function") {
1111
- return maybe.auth;
1112
- }
1113
- return input;
955
+ function fe(e) {
956
+ let t = e;
957
+ return t.auth && typeof t.auth.onAuthStateChanged == "function" ? t.auth : e;
1114
958
  }
1115
- function useUser(input, options) {
1116
- const timeoutMs = options?.timeoutMs ?? 8e3;
1117
- const auth = resolveAuth(input);
1118
- const [state, setState] = React2.useState(() => {
1119
- let seeded = null;
959
+ function De(e, t) {
960
+ let i = t?.timeoutMs ?? 8e3, n = fe(e), [s, c] = l.useState(() => {
961
+ let o = null;
1120
962
  try {
1121
- seeded = auth.getUser();
963
+ o = n.getUser();
1122
964
  } catch {
1123
- seeded = null;
965
+ o = null;
1124
966
  }
1125
- return { user: seeded, isLoading: seeded === null, error: null };
1126
- });
1127
- const mountedRef = React2.useRef(true);
1128
- React2.useEffect(() => {
1129
- mountedRef.current = true;
1130
- let settled = false;
1131
- const timer = setTimeout(() => {
1132
- if (!mountedRef.current || settled) return;
1133
- setState((prev) => prev.isLoading ? { ...prev, isLoading: false } : prev);
1134
- }, timeoutMs);
1135
- let unsub;
967
+ return { user: o, isLoading: o === null, error: null };
968
+ }), r = l.useRef(true);
969
+ return l.useEffect(() => {
970
+ r.current = true;
971
+ let o = false, f = setTimeout(() => {
972
+ !r.current || o || c((m) => m.isLoading ? { ...m, isLoading: false } : m);
973
+ }, i), u;
1136
974
  try {
1137
- unsub = auth.onAuthStateChanged((user) => {
1138
- if (!mountedRef.current) return;
1139
- settled = true;
1140
- setState({ user: user ?? null, isLoading: false, error: null });
975
+ u = n.onAuthStateChanged((m) => {
976
+ r.current && (o = !0, c({ user: m ?? null, isLoading: !1, error: null }));
977
+ });
978
+ } catch (m) {
979
+ r.current && c({
980
+ user: null,
981
+ isLoading: false,
982
+ error: m instanceof Error ? m : new Error(String(m))
1141
983
  });
1142
- } catch (e) {
1143
- if (mountedRef.current) {
1144
- setState({
1145
- user: null,
1146
- isLoading: false,
1147
- error: e instanceof Error ? e : new Error(String(e))
1148
- });
1149
- }
1150
984
  }
1151
985
  return () => {
1152
- mountedRef.current = false;
1153
- clearTimeout(timer);
1154
- unsub?.();
986
+ r.current = false, clearTimeout(f), u?.();
1155
987
  };
1156
- }, [auth, timeoutMs]);
1157
- return state;
988
+ }, [n, i]), s;
1158
989
  }
1159
990
 
1160
- export { CheckoutLink, EntitlementGate, NeetruAccountBar, NeetruLoginButton, fetchNeetruAccountBar, initialsFrom, useCollection, useDoc, useEntitlementContext, useUser };
1161
- //# sourceMappingURL=react.mjs.map
1162
- //# sourceMappingURL=react.mjs.map
991
+ export { xe as CheckoutLink, Se as EntitlementGate, te as NeetruAccountBar, we as NeetruLoginButton, Q as fetchNeetruAccountBar, N as initialsFrom, ve as useCollection, Ee as useDoc, Ce as useEntitlementContext, De as useUser };