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