@neetru/sdk 3.7.0 → 3.8.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 (73) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +66 -1
  3. package/dist/ai.cjs +221 -177
  4. package/dist/ai.d.cts +1 -1
  5. package/dist/ai.d.ts +1 -1
  6. package/dist/ai.mjs +221 -177
  7. package/dist/auth.cjs +1227 -1064
  8. package/dist/auth.d.cts +1 -1
  9. package/dist/auth.d.ts +1 -1
  10. package/dist/auth.mjs +1224 -1061
  11. package/dist/catalog.cjs +164 -97
  12. package/dist/catalog.d.cts +1 -1
  13. package/dist/catalog.d.ts +1 -1
  14. package/dist/catalog.mjs +164 -97
  15. package/dist/checkout.cjs +182 -115
  16. package/dist/checkout.d.cts +1 -1
  17. package/dist/checkout.d.ts +1 -1
  18. package/dist/checkout.mjs +181 -114
  19. package/dist/db-react.d.cts +1 -1
  20. package/dist/db-react.d.ts +1 -1
  21. package/dist/db.cjs +370 -298
  22. package/dist/db.d.cts +1 -1
  23. package/dist/db.d.ts +1 -1
  24. package/dist/db.mjs +362 -290
  25. package/dist/entitlements.cjs +17 -10
  26. package/dist/entitlements.d.cts +1 -1
  27. package/dist/entitlements.d.ts +1 -1
  28. package/dist/entitlements.mjs +17 -10
  29. package/dist/errors.cjs +15 -8
  30. package/dist/errors.d.cts +24 -3
  31. package/dist/errors.d.ts +24 -3
  32. package/dist/errors.mjs +14 -7
  33. package/dist/firestore-compat.d.cts +1 -1
  34. package/dist/firestore-compat.d.ts +1 -1
  35. package/dist/index.cjs +1409 -1075
  36. package/dist/index.d.cts +177 -3
  37. package/dist/index.d.ts +177 -3
  38. package/dist/index.mjs +1544 -1217
  39. package/dist/mobile.cjs +400 -181
  40. package/dist/mobile.d.cts +59 -4
  41. package/dist/mobile.d.ts +59 -4
  42. package/dist/mobile.mjs +400 -181
  43. package/dist/mocks.cjs +9 -2
  44. package/dist/mocks.d.cts +1 -1
  45. package/dist/mocks.d.ts +1 -1
  46. package/dist/mocks.mjs +9 -2
  47. package/dist/notifications.cjs +197 -130
  48. package/dist/notifications.d.cts +1 -1
  49. package/dist/notifications.d.ts +1 -1
  50. package/dist/notifications.mjs +196 -129
  51. package/dist/react.cjs +303 -282
  52. package/dist/react.d.cts +1 -1
  53. package/dist/react.d.ts +1 -1
  54. package/dist/react.mjs +295 -274
  55. package/dist/support.cjs +299 -229
  56. package/dist/support.d.cts +8 -4
  57. package/dist/support.d.ts +8 -4
  58. package/dist/support.mjs +298 -228
  59. package/dist/telemetry.cjs +234 -167
  60. package/dist/telemetry.d.cts +1 -1
  61. package/dist/telemetry.d.ts +1 -1
  62. package/dist/telemetry.mjs +234 -167
  63. package/dist/{types-Bx4kTLmk.d.cts → types-D-9bjlM0.d.cts} +48 -1
  64. package/dist/{types-Dx0IrOSF.d.ts → types-bVztFQTI.d.ts} +48 -1
  65. package/dist/usage.cjs +183 -116
  66. package/dist/usage.d.cts +1 -1
  67. package/dist/usage.d.ts +1 -1
  68. package/dist/usage.mjs +183 -116
  69. package/dist/webhooks.cjs +215 -148
  70. package/dist/webhooks.d.cts +1 -1
  71. package/dist/webhooks.d.ts +1 -1
  72. package/dist/webhooks.mjs +212 -145
  73. package/package.json +2 -1
package/dist/react.cjs CHANGED
@@ -38,16 +38,37 @@ var E = class e extends Error {
38
38
  * para um `NeetruDbErrorCode` mais específico (recuperável vs não).
39
39
  */
40
40
  reason;
41
- constructor(t, i, n, s, c) {
42
- super(i), this.name = "NeetruError", this.code = t, this.status = n, this.requestId = s, this.reason = c, Object.setPrototypeOf(this, e.prototype);
41
+ /**
42
+ * 3.8.0: `x-correlation-id` da requisição que falhou. O SDK gera um UUID por
43
+ * chamada (ou usa o que o chamador passou) e manda no header; o Core grava o
44
+ * mesmo id nos logs/auditoria — cite-o ao abrir um ticket de suporte.
45
+ * `undefined` em erros que acontecem antes de qualquer requisição.
46
+ */
47
+ correlationId;
48
+ constructor(t, i, n, s, c, o) {
49
+ super(i), this.name = "NeetruError", this.code = t, this.status = n, this.requestId = s, this.reason = c, this.correlationId = o, Object.setPrototypeOf(this, e.prototype);
43
50
  }
44
51
  };
45
52
 
46
53
  // src/types.ts
47
54
  var O = "https://api.neetru.com";
48
55
 
56
+ // src/end-user-token.ts
57
+ var ee = /* @__PURE__ */ new WeakMap();
58
+ function te(e) {
59
+ return ee.get(e);
60
+ }
61
+ async function M(e) {
62
+ try {
63
+ let t = te(e), i = e.auth, n = t ? await t.getIdToken() : typeof i?.getIdToken == "function" ? await i.getIdToken() : null;
64
+ return typeof n == "string" && n.length > 0 ? n : null;
65
+ } catch {
66
+ return null;
67
+ }
68
+ }
69
+
49
70
  // src/account-bar.ts
50
- var h = l__namespace.createElement, Z = {
71
+ var y = l__namespace.createElement, ne = {
51
72
  accountButton: "Abrir menu da conta",
52
73
  appsButton: "Seus produtos Neetru",
53
74
  appsTitle: "Trocar de produto",
@@ -57,25 +78,25 @@ var h = l__namespace.createElement, Z = {
57
78
  currentBadge: "Atual",
58
79
  emptyProducts: "Nenhum outro produto dispon\xEDvel."
59
80
  };
60
- async function Q(e) {
61
- let t = e.auth, i = typeof t?.getIdToken == "function" ? t.getIdToken() : null;
62
- if (!i) return null;
63
- let n = e.config, s = (n.baseUrl ?? O).replace(/\/+$/, ""), c = n.fetch ?? globalThis.fetch, r = `${s}/api/sdk/v1/account/bar`;
81
+ async function W(e) {
82
+ let t = await M(e);
83
+ if (!t) return null;
84
+ let i = e.config, n = (i.baseUrl ?? O).replace(/\/+$/, ""), s = i.fetch ?? globalThis.fetch, c = `${n}/api/sdk/v1/account/bar`;
64
85
  try {
65
- let o = await c(r, {
66
- headers: { authorization: `Bearer ${i}`, accept: "application/json" }
86
+ let o = await s(c, {
87
+ headers: { authorization: `Bearer ${t}`, accept: "application/json" }
67
88
  });
68
89
  if (!o.ok) return null;
69
- let f = await o.json();
70
- return !f || typeof f != "object" || !f.account ? null : {
90
+ let r = await o.json();
91
+ return !r || typeof r != "object" || !r.account ? null : {
71
92
  account: {
72
- displayName: String(f.account.displayName ?? ""),
73
- email: String(f.account.email ?? ""),
74
- photoUrl: f.account.photoUrl ?? null
93
+ displayName: String(r.account.displayName ?? ""),
94
+ email: String(r.account.email ?? ""),
95
+ photoUrl: r.account.photoUrl ?? null
75
96
  },
76
- accountUrl: String(f.accountUrl ?? "https://minhaconta.neetru.com"),
77
- products: Array.isArray(f.products) ? f.products.filter(
78
- (u) => !!u && typeof u.slug == "string" && typeof u.url == "string"
97
+ accountUrl: String(r.accountUrl ?? "https://minhaconta.neetru.com"),
98
+ products: Array.isArray(r.products) ? r.products.filter(
99
+ (b) => !!b && typeof b.slug == "string" && typeof b.url == "string"
79
100
  ) : []
80
101
  };
81
102
  } catch {
@@ -88,23 +109,23 @@ function N(e) {
88
109
  let i = t.includes("@") ? t.split("@")[0] : t, n = i.split(/[\s._-]+/).filter(Boolean);
89
110
  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();
90
111
  }
91
- var b = {
112
+ var h = {
92
113
  bg: "#ffffff",
93
114
  bgHover: "#f5f5f5",
94
115
  fg: "#0a0a0a",
95
116
  muted: "#666666",
96
117
  border: "#0a0a0a",
97
118
  borderSoft: "#e5e5e5"
98
- }, M = 0;
99
- function ee({ size: e = 18, color: t = b.fg }) {
100
- 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);
101
- return h(
119
+ }, H = 0;
120
+ function re({ size: e = 18, color: t = h.fg }) {
121
+ let i = [0, 1, 2].flatMap((c) => [0, 1, 2].map((o) => ({ r: c, c: o }))), n = e / 3, s = Math.max(2, e / 7);
122
+ return y(
102
123
  "svg",
103
124
  { width: e, height: e, viewBox: `0 0 ${e} ${e}`, "aria-hidden": true, style: { display: "block" } },
104
125
  i.map(
105
- ({ r: c, c: r }) => h("rect", {
106
- key: `${c}-${r}`,
107
- x: r * n + (n - s) / 2,
126
+ ({ r: c, c: o }) => y("rect", {
127
+ key: `${c}-${o}`,
128
+ x: o * n + (n - s) / 2,
108
129
  y: c * n + (n - s) / 2,
109
130
  width: s,
110
131
  height: s,
@@ -113,23 +134,23 @@ function ee({ size: e = 18, color: t = b.fg }) {
113
134
  )
114
135
  );
115
136
  }
116
- function H(e) {
137
+ function Q(e) {
117
138
  return e ? Array.from(
118
139
  e.querySelectorAll(
119
140
  'a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])'
120
141
  )
121
142
  ).filter((t) => t.offsetParent !== null || t === document.activeElement) : [];
122
143
  }
123
- function te({
144
+ function oe({
124
145
  client: e,
125
146
  currentProductSlug: t,
126
147
  settingsUrl: i,
127
148
  onSignOut: n,
128
149
  fetchBar: s,
129
150
  labels: c,
130
- className: r
151
+ className: o
131
152
  }) {
132
- let o = { ...Z, ...c }, f = l__namespace.useMemo(() => {
153
+ let r = { ...ne, ...c }, b = l__namespace.useMemo(() => {
133
154
  try {
134
155
  let a = e.auth.getUser();
135
156
  return a ? {
@@ -140,58 +161,58 @@ function te({
140
161
  } catch {
141
162
  return null;
142
163
  }
143
- }, [e]), [u, m] = l__namespace.useState(null), [y, x] = l__namespace.useState(null), [T, R] = l__namespace.useState(false), p = l__namespace.useRef(null), d = l__namespace.useRef(null), g = l__namespace.useRef(null), S = l__namespace.useRef(null);
164
+ }, [e]), [u, f] = l__namespace.useState(null), [m, w] = l__namespace.useState(null), [T, R] = l__namespace.useState(false), p = l__namespace.useRef(null), d = l__namespace.useRef(null), g = l__namespace.useRef(null), C = l__namespace.useRef(null);
144
165
  l__namespace.useEffect(() => {
145
- let a = false, k = s ?? Q;
146
- return Promise.resolve(k(e)).then((v) => {
147
- !a && v && m(v);
166
+ let a = false, k = s ?? W;
167
+ return Promise.resolve(k(e)).then((S) => {
168
+ !a && S && f(S);
148
169
  }).catch(() => {
149
170
  }), () => {
150
171
  a = true;
151
172
  };
152
173
  }, [e, s]);
153
- let C = u?.account ?? f, z = u?.accountUrl ?? "https://minhaconta.neetru.com", U = u?.products ?? [], L = l__namespace.useCallback((a) => {
154
- x(null), (a === "apps" ? g.current : d.current)?.focus();
174
+ let v = u?.account ?? b, G = u?.accountUrl ?? "https://minhaconta.neetru.com", A = u?.products ?? [], L = l__namespace.useCallback((a) => {
175
+ w(null), (a === "apps" ? g.current : d.current)?.focus();
155
176
  }, []);
156
177
  l__namespace.useEffect(() => {
157
- if (!y) return;
158
- H(S.current)[0]?.focus();
159
- let k = (v) => {
160
- p.current && !p.current.contains(v.target) && x(null);
178
+ if (!m) return;
179
+ Q(C.current)[0]?.focus();
180
+ let k = (S) => {
181
+ p.current && !p.current.contains(S.target) && w(null);
161
182
  };
162
183
  return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
163
- }, [y]);
184
+ }, [m]);
164
185
  let P = l__namespace.useCallback(
165
186
  (a) => {
166
187
  if (a.key === "Escape") {
167
- a.stopPropagation(), L(y);
188
+ a.stopPropagation(), L(m);
168
189
  return;
169
190
  }
170
- let k = H(S.current);
191
+ let k = Q(C.current);
171
192
  if (k.length === 0) return;
172
- let v = k.indexOf(document.activeElement);
173
- 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());
193
+ let S = k.indexOf(document.activeElement);
194
+ a.key === "Tab" ? a.shiftKey && S <= 0 ? (a.preventDefault(), k[k.length - 1].focus()) : !a.shiftKey && S === k.length - 1 && (a.preventDefault(), k[0].focus()) : a.key === "ArrowDown" ? (a.preventDefault(), k[(S + 1) % k.length].focus()) : a.key === "ArrowUp" && (a.preventDefault(), k[(S - 1 + k.length) % k.length].focus());
174
195
  },
175
- [y, L]
176
- ), G = l__namespace.useCallback(async () => {
196
+ [m, L]
197
+ ), K = l__namespace.useCallback(async () => {
177
198
  if (!T) {
178
199
  R(true);
179
200
  try {
180
201
  await e.auth.signOut();
181
202
  } catch {
182
203
  } finally {
183
- R(false), x(null), n?.();
204
+ R(false), w(null), n?.();
184
205
  }
185
206
  }
186
207
  }, [e, T, n]);
187
- if (!C) return null;
188
- let I = N(C.displayName || C.email), K = C.photoUrl ? h("img", {
189
- src: C.photoUrl,
208
+ if (!v) return null;
209
+ let I = N(v.displayName || v.email), V = v.photoUrl ? y("img", {
210
+ src: v.photoUrl,
190
211
  alt: "",
191
212
  width: 32,
192
213
  height: 32,
193
214
  style: { width: 32, height: 32, objectFit: "cover", display: "block" }
194
- }) : h(
215
+ }) : y(
195
216
  "span",
196
217
  {
197
218
  "aria-hidden": true,
@@ -201,7 +222,7 @@ function te({
201
222
  display: "inline-flex",
202
223
  alignItems: "center",
203
224
  justifyContent: "center",
204
- backgroundColor: b.fg,
225
+ backgroundColor: h.fg,
205
226
  color: "#ffffff",
206
227
  fontSize: 13,
207
228
  fontWeight: 700,
@@ -216,51 +237,51 @@ function te({
216
237
  width: 36,
217
238
  height: 36,
218
239
  padding: 0,
219
- borderRadius: M,
220
- border: `1px solid ${a ? b.border : b.borderSoft}`,
221
- backgroundColor: a ? b.bgHover : b.bg,
222
- color: b.fg,
240
+ borderRadius: H,
241
+ border: `1px solid ${a ? h.border : h.borderSoft}`,
242
+ backgroundColor: a ? h.bgHover : h.bg,
243
+ color: h.fg,
223
244
  cursor: "pointer",
224
245
  boxSizing: "border-box",
225
246
  fontFamily: "inherit",
226
247
  overflow: "hidden"
227
- }), V = h(
248
+ }), J = y(
228
249
  "button",
229
250
  {
230
251
  type: "button",
231
252
  ref: g,
232
- "aria-label": o.appsButton,
253
+ "aria-label": r.appsButton,
233
254
  "aria-haspopup": "menu",
234
- "aria-expanded": y === "apps",
255
+ "aria-expanded": m === "apps",
235
256
  "data-neetru-appswitcher-button": "true",
236
- onClick: () => x((a) => a === "apps" ? null : "apps"),
237
- style: B(y === "apps")
257
+ onClick: () => w((a) => a === "apps" ? null : "apps"),
258
+ style: B(m === "apps")
238
259
  },
239
- h(ee, {})
240
- ), J = h(
260
+ y(re, {})
261
+ ), X = y(
241
262
  "button",
242
263
  {
243
264
  type: "button",
244
265
  ref: d,
245
- "aria-label": `${o.accountButton}${C.displayName ? ` (${C.displayName})` : ""}`,
266
+ "aria-label": `${r.accountButton}${v.displayName ? ` (${v.displayName})` : ""}`,
246
267
  "aria-haspopup": "menu",
247
- "aria-expanded": y === "account",
268
+ "aria-expanded": m === "account",
248
269
  "data-neetru-account-button": "true",
249
- onClick: () => x((a) => a === "account" ? null : "account"),
250
- style: { ...B(y === "account"), width: 36, height: 36 }
270
+ onClick: () => w((a) => a === "account" ? null : "account"),
271
+ style: { ...B(m === "account"), width: 36, height: 36 }
251
272
  },
252
- K
273
+ V
253
274
  ), F = {
254
275
  position: "absolute",
255
276
  top: "calc(100% + 6px)",
256
277
  right: 0,
257
278
  minWidth: 260,
258
279
  maxWidth: 320,
259
- backgroundColor: b.bg,
260
- border: `1px solid ${b.border}`,
261
- borderRadius: M,
280
+ backgroundColor: h.bg,
281
+ border: `1px solid ${h.border}`,
282
+ borderRadius: H,
262
283
  zIndex: 1e3,
263
- color: b.fg,
284
+ color: h.fg,
264
285
  fontFamily: "inherit"
265
286
  // BMW: sem sombra/glassmorphism — borda sólida define o recorte.
266
287
  }, D = {
@@ -271,8 +292,8 @@ function te({
271
292
  padding: "10px 14px",
272
293
  background: "transparent",
273
294
  border: "none",
274
- borderTop: `1px solid ${b.borderSoft}`,
275
- color: b.fg,
295
+ borderTop: `1px solid ${h.borderSoft}`,
296
+ color: h.fg,
276
297
  fontSize: 14,
277
298
  fontWeight: 400,
278
299
  textAlign: "left",
@@ -282,26 +303,26 @@ function te({
282
303
  fontFamily: "inherit"
283
304
  }, _ = {
284
305
  onMouseEnter: (a) => {
285
- a.currentTarget.style.backgroundColor = b.bgHover;
306
+ a.currentTarget.style.backgroundColor = h.bgHover;
286
307
  },
287
308
  onMouseLeave: (a) => {
288
309
  a.currentTarget.style.backgroundColor = "transparent";
289
310
  }
290
- }, X = y === "account" ? h(
311
+ }, Y = m === "account" ? y(
291
312
  "div",
292
313
  {
293
- ref: S,
314
+ ref: C,
294
315
  role: "menu",
295
- "aria-label": o.accountButton,
316
+ "aria-label": r.accountButton,
296
317
  "data-neetru-account-menu": "true",
297
318
  onKeyDown: P,
298
319
  style: F
299
320
  },
300
321
  // Header identidade
301
- h(
322
+ y(
302
323
  "div",
303
324
  { style: { display: "flex", gap: 12, alignItems: "center", padding: 14 } },
304
- h(
325
+ y(
305
326
  "span",
306
327
  {
307
328
  "aria-hidden": true,
@@ -313,24 +334,24 @@ function te({
313
334
  alignItems: "center",
314
335
  justifyContent: "center",
315
336
  overflow: "hidden",
316
- backgroundColor: C.photoUrl ? "transparent" : b.fg,
337
+ backgroundColor: v.photoUrl ? "transparent" : h.fg,
317
338
  color: "#ffffff",
318
339
  fontSize: 15,
319
340
  fontWeight: 700
320
341
  }
321
342
  },
322
- C.photoUrl ? h("img", {
323
- src: C.photoUrl,
343
+ v.photoUrl ? y("img", {
344
+ src: v.photoUrl,
324
345
  alt: "",
325
346
  width: 40,
326
347
  height: 40,
327
348
  style: { width: 40, height: 40, objectFit: "cover", display: "block" }
328
349
  }) : I
329
350
  ),
330
- h(
351
+ y(
331
352
  "span",
332
353
  { style: { display: "flex", flexDirection: "column", minWidth: 0 } },
333
- h(
354
+ y(
334
355
  "span",
335
356
  {
336
357
  style: {
@@ -341,67 +362,67 @@ function te({
341
362
  textOverflow: "ellipsis"
342
363
  }
343
364
  },
344
- C.displayName || C.email
365
+ v.displayName || v.email
345
366
  ),
346
- C.email ? h(
367
+ v.email ? y(
347
368
  "span",
348
369
  {
349
370
  style: {
350
- color: b.muted,
371
+ color: h.muted,
351
372
  fontSize: 12,
352
373
  whiteSpace: "nowrap",
353
374
  overflow: "hidden",
354
375
  textOverflow: "ellipsis"
355
376
  }
356
377
  },
357
- C.email
378
+ v.email
358
379
  ) : null
359
380
  )
360
381
  ),
361
382
  // Minha conta Neetru
362
- h(
383
+ y(
363
384
  "a",
364
385
  {
365
386
  role: "menuitem",
366
- href: z,
387
+ href: G,
367
388
  target: "_blank",
368
389
  rel: "noopener noreferrer",
369
390
  style: D,
370
391
  ..._
371
392
  },
372
- o.myAccount
393
+ r.myAccount
373
394
  ),
374
395
  // Configurações da conta (deste produto)
375
- i ? h(
396
+ i ? y(
376
397
  "a",
377
398
  { role: "menuitem", href: i, style: D, ..._ },
378
- o.accountSettings
399
+ r.accountSettings
379
400
  ) : null,
380
401
  // Sair
381
- h(
402
+ y(
382
403
  "button",
383
404
  {
384
405
  type: "button",
385
406
  role: "menuitem",
386
- onClick: G,
407
+ onClick: K,
387
408
  disabled: T,
388
409
  "data-neetru-signout": "true",
389
410
  style: { ...D, cursor: T ? "not-allowed" : "pointer" },
390
411
  ..._
391
412
  },
392
- T ? `${o.signOut}\u2026` : o.signOut
413
+ T ? `${r.signOut}\u2026` : r.signOut
393
414
  )
394
- ) : null, Y = y === "apps" ? h(
415
+ ) : null, Z = m === "apps" ? y(
395
416
  "div",
396
417
  {
397
- ref: S,
418
+ ref: C,
398
419
  role: "menu",
399
- "aria-label": o.appsTitle,
420
+ "aria-label": r.appsTitle,
400
421
  "data-neetru-appswitcher-menu": "true",
401
422
  onKeyDown: P,
402
423
  style: { ...F, minWidth: 280 }
403
424
  },
404
- h(
425
+ y(
405
426
  "div",
406
427
  {
407
428
  style: {
@@ -410,16 +431,16 @@ function te({
410
431
  fontWeight: 700,
411
432
  letterSpacing: "0.08em",
412
433
  textTransform: "uppercase",
413
- color: b.muted
434
+ color: h.muted
414
435
  }
415
436
  },
416
- o.appsTitle
437
+ r.appsTitle
417
438
  ),
418
- U.length === 0 ? h(
439
+ A.length === 0 ? y(
419
440
  "div",
420
- { style: { padding: "4px 14px 16px", fontSize: 13, color: b.muted } },
421
- o.emptyProducts
422
- ) : h(
441
+ { style: { padding: "4px 14px 16px", fontSize: 13, color: h.muted } },
442
+ r.emptyProducts
443
+ ) : y(
423
444
  "div",
424
445
  {
425
446
  style: {
@@ -427,12 +448,12 @@ function te({
427
448
  gridTemplateColumns: "1fr 1fr",
428
449
  gap: 1,
429
450
  padding: 1,
430
- backgroundColor: b.borderSoft
451
+ backgroundColor: h.borderSoft
431
452
  }
432
453
  },
433
- U.map((a) => {
454
+ A.map((a) => {
434
455
  let k = !!t && a.slug === t;
435
- return h(
456
+ return y(
436
457
  "a",
437
458
  {
438
459
  key: a.slug,
@@ -449,26 +470,26 @@ function te({
449
470
  gap: 6,
450
471
  padding: "14px 8px",
451
472
  textDecoration: "none",
452
- color: b.fg,
453
- backgroundColor: k ? b.bgHover : b.bg,
473
+ color: h.fg,
474
+ backgroundColor: k ? h.bgHover : h.bg,
454
475
  cursor: "pointer",
455
476
  boxSizing: "border-box"
456
477
  },
457
- onMouseEnter: (v) => {
458
- v.currentTarget.style.backgroundColor = b.bgHover;
478
+ onMouseEnter: (S) => {
479
+ S.currentTarget.style.backgroundColor = h.bgHover;
459
480
  },
460
- onMouseLeave: (v) => {
461
- v.currentTarget.style.backgroundColor = k ? b.bgHover : b.bg;
481
+ onMouseLeave: (S) => {
482
+ S.currentTarget.style.backgroundColor = k ? h.bgHover : h.bg;
462
483
  }
463
484
  },
464
485
  // Tile/ícone
465
- a.iconUrl ? h("img", {
486
+ a.iconUrl ? y("img", {
466
487
  src: a.iconUrl,
467
488
  alt: "",
468
489
  width: 32,
469
490
  height: 32,
470
491
  style: { width: 32, height: 32, objectFit: "cover", display: "block" }
471
- }) : h(
492
+ }) : y(
472
493
  "span",
473
494
  {
474
495
  "aria-hidden": true,
@@ -478,7 +499,7 @@ function te({
478
499
  display: "inline-flex",
479
500
  alignItems: "center",
480
501
  justifyContent: "center",
481
- backgroundColor: b.fg,
502
+ backgroundColor: h.fg,
482
503
  color: "#ffffff",
483
504
  fontSize: 13,
484
505
  fontWeight: 700
@@ -486,7 +507,7 @@ function te({
486
507
  },
487
508
  N(a.name)
488
509
  ),
489
- h(
510
+ y(
490
511
  "span",
491
512
  {
492
513
  style: {
@@ -503,7 +524,7 @@ function te({
503
524
  },
504
525
  a.name
505
526
  ),
506
- k ? h(
527
+ k ? y(
507
528
  "span",
508
529
  {
509
530
  style: {
@@ -511,20 +532,20 @@ function te({
511
532
  fontWeight: 700,
512
533
  letterSpacing: "0.08em",
513
534
  textTransform: "uppercase",
514
- color: b.muted
535
+ color: h.muted
515
536
  }
516
537
  },
517
- o.currentBadge
538
+ r.currentBadge
518
539
  ) : null
519
540
  );
520
541
  })
521
542
  )
522
543
  ) : null;
523
- return h(
544
+ return y(
524
545
  "div",
525
546
  {
526
547
  ref: p,
527
- className: r,
548
+ className: o,
528
549
  "data-neetru-account-bar": "true",
529
550
  style: {
530
551
  position: "relative",
@@ -536,30 +557,30 @@ function te({
536
557
  fontFamily: "inherit"
537
558
  }
538
559
  },
539
- V,
540
560
  J,
541
561
  X,
542
- Y
562
+ Y,
563
+ Z
543
564
  );
544
565
  }
545
566
 
546
567
  // src/firestore-compat.ts
547
- function A(e) {
568
+ function U(e) {
548
569
  let t = [], i, n;
549
570
  for (let c of e)
550
571
  if (c.__constraint === "where") {
551
- let r = c;
552
- t.push({ field: r.field, op: r.op, value: r.value });
572
+ let o = c;
573
+ t.push({ field: o.field, op: o.op, value: o.value });
553
574
  } else if (c.__constraint === "orderBy") {
554
- let r = c;
555
- i = { field: r.field, direction: r.direction };
575
+ let o = c;
576
+ i = { field: o.field, direction: o.direction };
556
577
  } else c.__constraint === "limit" && (n = c.value);
557
578
  let s = {};
558
579
  return t.length > 0 && (s.where = t), i && (s.orderBy = i), n !== void 0 && (s.limit = n), s;
559
580
  }
560
581
 
561
582
  // src/react.ts
562
- async function ne(e, t) {
583
+ async function ie(e, t) {
563
584
  let i = await fetch(e, {
564
585
  method: "POST",
565
586
  headers: { "content-type": "application/json", accept: "application/json" },
@@ -572,9 +593,9 @@ async function ne(e, t) {
572
593
  n = null;
573
594
  }
574
595
  if (!i.ok) {
575
- 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}`;
596
+ let o = n, r = o?.error, b = (r && typeof r == "object" && typeof r.code == "string" ? r.code : void 0) ?? "server_error", u = o && (typeof o.error == "object" && o.error?.message || typeof o.error == "string" && o.error || typeof o.message == "string" && o.message) || `Checkout BFF respondeu HTTP ${i.status}`;
576
597
  throw new E(
577
- f,
598
+ b,
578
599
  typeof u == "string" ? u : `Checkout BFF respondeu HTTP ${i.status}`,
579
600
  i.status
580
601
  );
@@ -593,38 +614,38 @@ async function ne(e, t) {
593
614
  requiresKyc: n?.requiresKyc === true || s.requiresKyc === true
594
615
  };
595
616
  }
596
- function re(e) {
617
+ function se(e) {
597
618
  let t = globalThis.location;
598
619
  t && typeof t.assign == "function" && t.assign(e);
599
620
  }
600
- function xe({
621
+ function Ee({
601
622
  client: e,
602
623
  startPath: t,
603
624
  productId: i,
604
625
  planId: n,
605
626
  callbackUrl: s,
606
627
  tenantType: c,
607
- tenantId: r,
608
- children: o,
609
- onIntentCreated: f,
628
+ tenantId: o,
629
+ children: r,
630
+ onIntentCreated: b,
610
631
  onError: u,
611
- noAutoRedirect: m,
612
- ...y
632
+ noAutoRedirect: f,
633
+ ...m
613
634
  }) {
614
- let [x, T] = l__namespace.useState(false), R = e?.checkout, p = l__namespace.useCallback(
635
+ let [w, T] = l__namespace.useState(false), R = e?.checkout, p = l__namespace.useCallback(
615
636
  async (d) => {
616
- if (d.preventDefault(), !x) {
637
+ if (d.preventDefault(), !w) {
617
638
  if (t) {
618
639
  T(true);
619
640
  try {
620
- let g = await ne(t, {
641
+ let g = await ie(t, {
621
642
  productId: i,
622
643
  planId: n,
623
644
  callbackUrl: s,
624
645
  tenantType: c,
625
- tenantId: r
646
+ tenantId: o
626
647
  });
627
- f?.(g), m || re(g.redirectUrl);
648
+ b?.(g), f || se(g.redirectUrl);
628
649
  } catch (g) {
629
650
  u?.(g instanceof Error ? g : new Error(String(g)));
630
651
  } finally {
@@ -647,10 +668,10 @@ function xe({
647
668
  planId: n,
648
669
  callbackUrl: s,
649
670
  tenantType: c,
650
- tenantId: r,
651
- autoRedirect: !m
671
+ tenantId: o,
672
+ autoRedirect: !f
652
673
  });
653
- f?.(g);
674
+ b?.(g);
654
675
  } catch (g) {
655
676
  u?.(g instanceof Error ? g : new Error(String(g)));
656
677
  } finally {
@@ -658,72 +679,72 @@ function xe({
658
679
  }
659
680
  }
660
681
  },
661
- [x, R, t, i, n, s, c, r, m, f, u]
682
+ [w, R, t, i, n, s, c, o, f, b, u]
662
683
  );
663
684
  return l__namespace.createElement(
664
685
  "a",
665
686
  {
666
- ...y,
667
- href: y.href ?? "#",
687
+ ...m,
688
+ href: m.href ?? "#",
668
689
  onClick: p,
669
- "aria-busy": x || void 0,
690
+ "aria-busy": w || void 0,
670
691
  "data-neetru-checkout-link": "true"
671
692
  },
672
- o
693
+ r
673
694
  );
674
695
  }
675
- 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;
676
- function ae({ fill: e, size: t = 16 }) {
696
+ var ae = "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", ce = "0 0 527 760", le = 527 / 760;
697
+ function ue({ fill: e, size: t = 16 }) {
677
698
  return l__namespace.createElement(
678
699
  "svg",
679
700
  {
680
- viewBox: ie,
681
- width: Math.round(t * se),
701
+ viewBox: ce,
702
+ width: Math.round(t * le),
682
703
  height: t,
683
704
  "aria-hidden": true,
684
705
  style: { flexShrink: 0 }
685
706
  },
686
- l__namespace.createElement("path", { d: oe, fill: e })
707
+ l__namespace.createElement("path", { d: ae, fill: e })
687
708
  );
688
709
  }
689
- var ce = {
710
+ var de = {
690
711
  dark: { bg: "#0a0a0a", bgHover: "#1a1a1a", fg: "#ffffff", border: "#0a0a0a" },
691
712
  light: { bg: "#ffffff", bgHover: "#f5f5f5", fg: "#0a0a0a", border: "#0a0a0a" }
692
- }, 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;}";
693
- function ue() {
694
- if (typeof document > "u" || !document.head || document.getElementById(W)) return;
713
+ }, j = "neetru-login-button-focus-style", pe = "button[data-neetru-login-button]:focus-visible{outline:2px solid var(--neetru-login-focus-ring,#ffffff);outline-offset:2px;}";
714
+ function ge() {
715
+ if (typeof document > "u" || !document.head || document.getElementById(j)) return;
695
716
  let e = document.createElement("style");
696
- e.id = W, e.textContent = le, document.head.appendChild(e);
717
+ e.id = j, e.textContent = pe, document.head.appendChild(e);
697
718
  }
698
- function we({
719
+ function De({
699
720
  client: e,
700
721
  redirectUri: t,
701
722
  scope: i,
702
723
  postLoginRedirect: n,
703
724
  theme: s = "dark",
704
725
  label: c = "Entrar com Neetru",
705
- onError: r,
706
- style: o,
707
- disabled: f,
726
+ onError: o,
727
+ style: r,
728
+ disabled: b,
708
729
  ...u
709
730
  }) {
710
- let [m, y] = l__namespace.useState(false), [x, T] = l__namespace.useState(false), R = ce[s], p = !!f || m;
731
+ let [f, m] = l__namespace.useState(false), [w, T] = l__namespace.useState(false), R = de[s], p = !!b || f;
711
732
  l__namespace.useEffect(() => {
712
- ue();
733
+ ge();
713
734
  }, []);
714
735
  let d = l__namespace.useCallback(async () => {
715
736
  if (!p) {
716
- y(true);
737
+ m(true);
717
738
  try {
718
739
  let g = { redirectUri: t, scope: i, postLoginRedirect: n };
719
740
  await e.auth.signIn(g);
720
741
  } catch (g) {
721
- r?.(g instanceof Error ? g : new Error(String(g)));
742
+ o?.(g instanceof Error ? g : new Error(String(g)));
722
743
  } finally {
723
- y(false);
744
+ m(false);
724
745
  }
725
746
  }
726
- }, [e, t, i, n, p, r]);
747
+ }, [e, t, i, n, p, o]);
727
748
  return l__namespace.createElement(
728
749
  "button",
729
750
  {
@@ -734,7 +755,7 @@ function we({
734
755
  onMouseEnter: () => T(true),
735
756
  onMouseLeave: () => T(false),
736
757
  "aria-label": u["aria-label"] ?? c,
737
- "aria-busy": m || void 0,
758
+ "aria-busy": f || void 0,
738
759
  "data-neetru-login-button": "true",
739
760
  style: {
740
761
  display: "inline-flex",
@@ -746,7 +767,7 @@ function we({
746
767
  padding: "0 20px",
747
768
  borderRadius: 0,
748
769
  border: `1px solid ${R.border}`,
749
- backgroundColor: x && !p ? R.bgHover : R.bg,
770
+ backgroundColor: w && !p ? R.bgHover : R.bg,
750
771
  color: R.fg,
751
772
  fontSize: "14px",
752
773
  fontWeight: 700,
@@ -755,132 +776,132 @@ function we({
755
776
  fontFamily: "inherit",
756
777
  lineHeight: 1,
757
778
  cursor: p ? "not-allowed" : "pointer",
758
- opacity: p && !m ? 0.6 : 1,
779
+ opacity: p && !f ? 0.6 : 1,
759
780
  transition: "background-color 150ms ease",
760
781
  boxSizing: "border-box",
761
782
  // Cor do ring de foco de teclado (:focus-visible) — ver
762
783
  // NEETRU_LOGIN_FOCUS_CSS. Usa a cor do texto (contraste AA garantido).
763
784
  "--neetru-login-focus-ring": R.fg,
764
- ...o
785
+ ...r
765
786
  }
766
787
  },
767
- l__namespace.createElement(ae, { fill: R.fg }),
768
- l__namespace.createElement("span", null, m ? "Entrando\u2026" : c)
788
+ l__namespace.createElement(ue, { fill: R.fg }),
789
+ l__namespace.createElement("span", null, f ? "Entrando\u2026" : c)
769
790
  );
770
791
  }
771
- var j = l__namespace.createContext({
792
+ var $ = l__namespace.createContext({
772
793
  readonly: false
773
794
  });
774
- function Ce() {
775
- return l__namespace.useContext(j);
795
+ function _e() {
796
+ return l__namespace.useContext($);
776
797
  }
777
- function Se({
798
+ function Ne({
778
799
  client: e,
779
800
  feature: t,
780
801
  productSlug: i,
781
802
  mode: n = "block",
782
803
  fallback: s,
783
804
  loading: c,
784
- children: r
805
+ children: o
785
806
  }) {
786
- let [o, f] = l__namespace.useState({
807
+ let [r, b] = l__namespace.useState({
787
808
  status: "loading"
788
- }), u = i ?? e.config.productId ?? "", m = e.config.tenantId;
809
+ }), u = i ?? e.config.productId ?? "", f = e.config.tenantId;
789
810
  if (l__namespace.useEffect(() => {
790
811
  let R = false;
791
812
  return (async () => {
792
813
  try {
793
814
  let d, g = e.usage;
794
- if (g && typeof g.check == "function" && m) {
795
- let S = await g.check(t, {
815
+ if (g && typeof g.check == "function" && f) {
816
+ let C = await g.check(t, {
796
817
  productId: u,
797
- tenantId: m
818
+ tenantId: f
798
819
  });
799
820
  d = {
800
- allowed: S.allowed === !0,
801
- reason: S.reason,
802
- limit: S.limit,
803
- currentUsage: S.currentUsage,
804
- behavior: S.behavior
821
+ allowed: C.allowed === !0,
822
+ reason: C.reason,
823
+ limit: C.limit,
824
+ currentUsage: C.currentUsage,
825
+ behavior: C.behavior
805
826
  };
806
827
  } else
807
828
  typeof console < "u" && console.warn(
808
829
  "[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)."
809
830
  ), d = { allowed: !1, reason: "tenant_id_required" };
810
- R || f({ status: "ready", result: d });
831
+ R || b({ status: "ready", result: d });
811
832
  } catch (d) {
812
- R || f({ status: "ready", result: { allowed: true, reason: "check_error_fallback" } }), typeof console < "u" && console.warn("[EntitlementGate] check failed \u2014 fail-open", d);
833
+ R || b({ status: "ready", result: { allowed: true, reason: "check_error_fallback" } }), typeof console < "u" && console.warn("[EntitlementGate] check failed \u2014 fail-open", d);
813
834
  }
814
835
  })(), () => {
815
836
  R = true;
816
837
  };
817
- }, [e, t, u, m]), o.status === "loading")
838
+ }, [e, t, u, f]), r.status === "loading")
818
839
  return l__namespace.createElement(l__namespace.Fragment, null, c ?? null);
819
- let y = o.result, x = y?.allowed === true, T = !x && (n === "readonly" || y?.behavior === "readonly");
820
- return !x && n === "block" && !T ? l__namespace.createElement(l__namespace.Fragment, null, s ?? null) : l__namespace.createElement(
821
- j.Provider,
840
+ let m = r.result, w = m?.allowed === true, T = !w && (n === "readonly" || m?.behavior === "readonly");
841
+ return !w && n === "block" && !T ? l__namespace.createElement(l__namespace.Fragment, null, s ?? null) : l__namespace.createElement(
842
+ $.Provider,
822
843
  {
823
844
  value: {
824
845
  readonly: T,
825
- reason: y?.reason,
826
- limit: y?.limit,
827
- currentUsage: y?.currentUsage
846
+ reason: m?.reason,
847
+ limit: m?.limit,
848
+ currentUsage: m?.currentUsage
828
849
  }
829
850
  },
830
- r
851
+ o
831
852
  );
832
853
  }
833
- var $ = 5e3;
834
- function q() {
854
+ var q = 5e3;
855
+ function z() {
835
856
  return typeof document < "u" && document.hidden === true;
836
857
  }
837
- function de(e) {
858
+ function fe(e) {
838
859
  if (!e) return null;
839
860
  if (e.__kind === "collection")
840
861
  return `collection:${e.id}`;
841
- let t = A(e.constraints);
862
+ let t = U(e.constraints);
842
863
  return `query:${e.collection}:${JSON.stringify(t)}`;
843
864
  }
844
- function pe(e) {
865
+ function me(e) {
845
866
  return e.docs.map((t) => {
846
867
  let i = t.data, { id: n, ...s } = i;
847
868
  return { ...s, id: t.id };
848
869
  });
849
870
  }
850
- function ge(e, t) {
871
+ function ye(e, t) {
851
872
  let i = e?.docs[0];
852
873
  if (!i) return null;
853
874
  let n = i.data, { id: s, ...c } = n;
854
875
  return { ...c, id: t };
855
876
  }
856
- function ve(e, t) {
857
- let i = t?.intervalMs ?? $, n = t?.poll ?? false, s = de(
877
+ function Ue(e, t) {
878
+ let i = t?.intervalMs ?? q, n = t?.poll ?? false, s = fe(
858
879
  e
859
- ), [c, r] = l__namespace.useState({
880
+ ), [c, o] = l__namespace.useState({
860
881
  data: null,
861
882
  isLoading: s !== null,
862
883
  error: null,
863
884
  isStale: false,
864
885
  lastUpdated: null
865
- }), o = l__namespace.useRef(true), f = l__namespace.useRef(e);
866
- return f.current = e, l__namespace.useEffect(() => {
867
- o.current = true;
868
- let u = f.current;
886
+ }), r = l__namespace.useRef(true), b = l__namespace.useRef(e);
887
+ return b.current = e, l__namespace.useEffect(() => {
888
+ r.current = true;
889
+ let u = b.current;
869
890
  if (!u || s === null)
870
- return r({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
871
- o.current = false;
891
+ return o({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
892
+ r.current = false;
872
893
  };
873
- r((d) => ({ ...d, isLoading: d.data === null }));
874
- 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) => {
875
- o.current && r({
876
- data: pe(d),
894
+ o((d) => ({ ...d, isLoading: d.data === null }));
895
+ let f = u.__kind === "query" ? u.collection : u.id, m = u.__kind === "query" ? U(u.constraints) : void 0, w = u.db.collection(f), T = (d) => {
896
+ r.current && o({
897
+ data: me(d),
877
898
  isLoading: false,
878
899
  error: null,
879
900
  isStale: d.stale === true,
880
901
  lastUpdated: Date.now()
881
902
  });
882
903
  }, R = (d) => {
883
- o.current && r((g) => ({
904
+ r.current && o((g) => ({
884
905
  ...g,
885
906
  // Mantém o último data bom — não limpa em erro de refresh.
886
907
  isLoading: false,
@@ -890,57 +911,57 @@ function ve(e, t) {
890
911
  };
891
912
  if (n) {
892
913
  let d = false, g = async () => {
893
- if (!(d || q()))
914
+ if (!(d || z()))
894
915
  try {
895
- let C = await x.list(y);
896
- d || T(C);
897
- } catch (C) {
898
- d || R(C);
916
+ let v = await w.list(m);
917
+ d || T(v);
918
+ } catch (v) {
919
+ d || R(v);
899
920
  }
900
921
  };
901
922
  g();
902
- let S = setInterval(g, i);
923
+ let C = setInterval(g, i);
903
924
  return () => {
904
- d = true, clearInterval(S), o.current = false;
925
+ d = true, clearInterval(C), r.current = false;
905
926
  };
906
927
  }
907
928
  let p;
908
929
  try {
909
- p = x.onSnapshot(y, T);
930
+ p = w.onSnapshot(m, T);
910
931
  } catch (d) {
911
932
  R(d);
912
933
  }
913
934
  return () => {
914
- o.current = false, p?.();
935
+ r.current = false, p?.();
915
936
  };
916
937
  }, [s, i, n]), c;
917
938
  }
918
- function Ee(e, t) {
919
- let i = t?.intervalMs ?? $, n = t?.poll ?? false, s = e && e.id ? `${e.collection}/${e.id}` : null, [c, r] = l__namespace.useState({
939
+ function Ae(e, t) {
940
+ let i = t?.intervalMs ?? q, n = t?.poll ?? false, s = e && e.id ? `${e.collection}/${e.id}` : null, [c, o] = l__namespace.useState({
920
941
  data: null,
921
942
  isLoading: s !== null,
922
943
  error: null,
923
944
  isStale: false,
924
945
  lastUpdated: null
925
- }), o = l__namespace.useRef(true), f = l__namespace.useRef(e);
926
- return f.current = e, l__namespace.useEffect(() => {
927
- o.current = true;
928
- let u = f.current;
946
+ }), r = l__namespace.useRef(true), b = l__namespace.useRef(e);
947
+ return b.current = e, l__namespace.useEffect(() => {
948
+ r.current = true;
949
+ let u = b.current;
929
950
  if (!u || s === null)
930
- return r({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
931
- o.current = false;
951
+ return o({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
952
+ r.current = false;
932
953
  };
933
- r((p) => ({ ...p, isLoading: p.data === null }));
934
- let m = u.db.collection(u.collection).doc(u.id), y = u.id, x = (p) => {
935
- o.current && r({
936
- data: ge(p, y),
954
+ o((p) => ({ ...p, isLoading: p.data === null }));
955
+ let f = u.db.collection(u.collection).doc(u.id), m = u.id, w = (p) => {
956
+ r.current && o({
957
+ data: ye(p, m),
937
958
  isLoading: false,
938
959
  error: null,
939
960
  isStale: p?.stale === true,
940
961
  lastUpdated: Date.now()
941
962
  });
942
963
  }, T = (p) => {
943
- o.current && r((d) => ({
964
+ r.current && o((d) => ({
944
965
  ...d,
945
966
  isLoading: false,
946
967
  error: p instanceof Error ? p : new Error(String(p)),
@@ -949,74 +970,74 @@ function Ee(e, t) {
949
970
  };
950
971
  if (n) {
951
972
  let p = false, d = async () => {
952
- if (!(p || q()))
973
+ if (!(p || z()))
953
974
  try {
954
- let S = await m.get();
955
- p || x(S);
956
- } catch (S) {
957
- p || T(S);
975
+ let C = await f.get();
976
+ p || w(C);
977
+ } catch (C) {
978
+ p || T(C);
958
979
  }
959
980
  };
960
981
  d();
961
982
  let g = setInterval(d, i);
962
983
  return () => {
963
- p = true, clearInterval(g), o.current = false;
984
+ p = true, clearInterval(g), r.current = false;
964
985
  };
965
986
  }
966
987
  let R;
967
988
  try {
968
- R = m.onSnapshot(x);
989
+ R = f.onSnapshot(w);
969
990
  } catch (p) {
970
991
  T(p);
971
992
  }
972
993
  return () => {
973
- o.current = false, R?.();
994
+ r.current = false, R?.();
974
995
  };
975
996
  }, [s, i, n]), c;
976
997
  }
977
- function fe(e) {
998
+ function he(e) {
978
999
  let t = e;
979
1000
  return t.auth && typeof t.auth.onAuthStateChanged == "function" ? t.auth : e;
980
1001
  }
981
- function De(e, t) {
982
- let i = t?.timeoutMs ?? 8e3, n = fe(e), [s, c] = l__namespace.useState(() => {
983
- let o = null;
1002
+ function Le(e, t) {
1003
+ let i = t?.timeoutMs ?? 8e3, n = he(e), [s, c] = l__namespace.useState(() => {
1004
+ let r = null;
984
1005
  try {
985
- o = n.getUser();
1006
+ r = n.getUser();
986
1007
  } catch {
987
- o = null;
1008
+ r = null;
988
1009
  }
989
- return { user: o, isLoading: o === null, error: null };
990
- }), r = l__namespace.useRef(true);
1010
+ return { user: r, isLoading: r === null, error: null };
1011
+ }), o = l__namespace.useRef(true);
991
1012
  return l__namespace.useEffect(() => {
992
- r.current = true;
993
- let o = false, f = setTimeout(() => {
994
- !r.current || o || c((m) => m.isLoading ? { ...m, isLoading: false } : m);
1013
+ o.current = true;
1014
+ let r = false, b = setTimeout(() => {
1015
+ !o.current || r || c((f) => f.isLoading ? { ...f, isLoading: false } : f);
995
1016
  }, i), u;
996
1017
  try {
997
- u = n.onAuthStateChanged((m) => {
998
- r.current && (o = !0, c({ user: m ?? null, isLoading: !1, error: null }));
1018
+ u = n.onAuthStateChanged((f) => {
1019
+ o.current && (r = !0, c({ user: f ?? null, isLoading: !1, error: null }));
999
1020
  });
1000
- } catch (m) {
1001
- r.current && c({
1021
+ } catch (f) {
1022
+ o.current && c({
1002
1023
  user: null,
1003
1024
  isLoading: false,
1004
- error: m instanceof Error ? m : new Error(String(m))
1025
+ error: f instanceof Error ? f : new Error(String(f))
1005
1026
  });
1006
1027
  }
1007
1028
  return () => {
1008
- r.current = false, clearTimeout(f), u?.();
1029
+ o.current = false, clearTimeout(b), u?.();
1009
1030
  };
1010
1031
  }, [n, i]), s;
1011
1032
  }
1012
1033
 
1013
- exports.CheckoutLink = xe;
1014
- exports.EntitlementGate = Se;
1015
- exports.NeetruAccountBar = te;
1016
- exports.NeetruLoginButton = we;
1017
- exports.fetchNeetruAccountBar = Q;
1034
+ exports.CheckoutLink = Ee;
1035
+ exports.EntitlementGate = Ne;
1036
+ exports.NeetruAccountBar = oe;
1037
+ exports.NeetruLoginButton = De;
1038
+ exports.fetchNeetruAccountBar = W;
1018
1039
  exports.initialsFrom = N;
1019
- exports.useCollection = ve;
1020
- exports.useDoc = Ee;
1021
- exports.useEntitlementContext = Ce;
1022
- exports.useUser = De;
1040
+ exports.useCollection = Ue;
1041
+ exports.useDoc = Ae;
1042
+ exports.useEntitlementContext = _e;
1043
+ exports.useUser = Le;