@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.
- package/CHANGELOG.md +49 -0
- package/dist/ai.cjs +254 -391
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +254 -391
- package/dist/auth.cjs +3547 -4998
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +3544 -4995
- package/dist/build-guard.cjs +101 -119
- package/dist/build-guard.mjs +91 -109
- package/dist/catalog.cjs +152 -224
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +152 -224
- package/dist/checkout.cjs +237 -320
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +236 -319
- package/dist/db-react.cjs +59 -87
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db-react.mjs +56 -84
- package/dist/db.cjs +2055 -3013
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +2068 -3026
- package/dist/entitlements.cjs +12 -20
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/entitlements.mjs +12 -20
- package/dist/errors.cjs +9 -12
- package/dist/errors.d.cts +37 -2
- package/dist/errors.d.ts +37 -2
- package/dist/errors.mjs +8 -12
- package/dist/firestore-compat.cjs +241 -297
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/firestore-compat.mjs +215 -271
- package/dist/index.cjs +3605 -5131
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +3710 -5236
- package/dist/mobile.cjs +238 -342
- package/dist/mobile.d.cts +1 -1
- package/dist/mobile.d.ts +1 -1
- package/dist/mobile.mjs +238 -342
- package/dist/mocks.cjs +312 -447
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.mjs +306 -441
- package/dist/notifications.cjs +226 -314
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +225 -313
- package/dist/react.cjs +522 -693
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +512 -683
- package/dist/support.cjs +329 -325
- package/dist/support.d.cts +25 -3
- package/dist/support.d.ts +25 -3
- package/dist/support.mjs +328 -325
- package/dist/telemetry.cjs +197 -301
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +197 -301
- package/dist/{types-Du_iioJ7.d.cts → types-Bx4kTLmk.d.cts} +26 -0
- package/dist/{types-BPATkXYu.d.ts → types-Dx0IrOSF.d.ts} +26 -0
- package/dist/usage.cjs +163 -227
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +163 -227
- package/dist/webhooks.cjs +258 -359
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +255 -356
- package/package.json +4 -3
- package/dist/ai.cjs.map +0 -1
- package/dist/ai.mjs.map +0 -1
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.mjs.map +0 -1
- package/dist/build-guard.cjs.map +0 -1
- package/dist/build-guard.mjs.map +0 -1
- package/dist/catalog.cjs.map +0 -1
- package/dist/catalog.mjs.map +0 -1
- package/dist/checkout.cjs.map +0 -1
- package/dist/checkout.mjs.map +0 -1
- package/dist/db-react.cjs.map +0 -1
- package/dist/db-react.mjs.map +0 -1
- package/dist/db.cjs.map +0 -1
- package/dist/db.mjs.map +0 -1
- package/dist/entitlements.cjs.map +0 -1
- package/dist/entitlements.mjs.map +0 -1
- package/dist/errors.cjs.map +0 -1
- package/dist/errors.mjs.map +0 -1
- package/dist/firestore-compat.cjs.map +0 -1
- package/dist/firestore-compat.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/mobile.cjs.map +0 -1
- package/dist/mobile.mjs.map +0 -1
- package/dist/mocks.cjs.map +0 -1
- package/dist/mocks.mjs.map +0 -1
- package/dist/notifications.cjs.map +0 -1
- package/dist/notifications.mjs.map +0 -1
- package/dist/react.cjs.map +0 -1
- package/dist/react.mjs.map +0 -1
- package/dist/support.cjs.map +0 -1
- package/dist/support.mjs.map +0 -1
- package/dist/telemetry.cjs.map +0 -1
- package/dist/telemetry.mjs.map +0 -1
- package/dist/usage.cjs.map +0 -1
- package/dist/usage.mjs.map +0 -1
- package/dist/webhooks.cjs.map +0 -1
- package/dist/webhooks.mjs.map +0 -1
package/dist/react.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
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
|
|
23
|
+
var l__namespace = /*#__PURE__*/_interopNamespace(l);
|
|
24
24
|
|
|
25
25
|
// src/react.ts
|
|
26
26
|
|
|
27
27
|
// src/errors.ts
|
|
28
|
-
var
|
|
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(
|
|
42
|
-
super(
|
|
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
|
|
47
|
+
var O = "https://api.neetru.com";
|
|
54
48
|
|
|
55
49
|
// src/account-bar.ts
|
|
56
|
-
var h =
|
|
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
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
77
|
-
headers: { authorization: `Bearer ${
|
|
65
|
+
let o = await c(r, {
|
|
66
|
+
headers: { authorization: `Bearer ${i}`, accept: "application/json" }
|
|
78
67
|
});
|
|
79
|
-
if (!
|
|
80
|
-
|
|
81
|
-
|
|
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(
|
|
85
|
-
email: String(
|
|
86
|
-
photoUrl:
|
|
72
|
+
displayName: String(f.account.displayName ?? ""),
|
|
73
|
+
email: String(f.account.email ?? ""),
|
|
74
|
+
photoUrl: f.account.photoUrl ?? null
|
|
87
75
|
},
|
|
88
|
-
accountUrl: String(
|
|
89
|
-
products: Array.isArray(
|
|
90
|
-
(
|
|
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
|
|
98
|
-
|
|
99
|
-
if (!
|
|
100
|
-
|
|
101
|
-
|
|
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
|
|
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
|
-
|
|
115
|
-
|
|
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:
|
|
122
|
-
|
|
123
|
-
({ r, c }) => h("rect", {
|
|
124
|
-
key: `${
|
|
125
|
-
x:
|
|
126
|
-
y:
|
|
127
|
-
width:
|
|
128
|
-
height:
|
|
129
|
-
fill:
|
|
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
|
|
135
|
-
|
|
136
|
-
|
|
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((
|
|
121
|
+
).filter((t) => t.offsetParent !== null || t === document.activeElement) : [];
|
|
141
122
|
}
|
|
142
|
-
function
|
|
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
|
-
|
|
152
|
-
const seedAccount = React2__namespace.useMemo(() => {
|
|
132
|
+
let o = { ...Z, ...c }, f = l__namespace.useMemo(() => {
|
|
153
133
|
try {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
}, [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
180
|
-
cancelled = true;
|
|
149
|
+
}), () => {
|
|
150
|
+
a = true;
|
|
181
151
|
};
|
|
182
|
-
}, [
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
192
|
-
if (!
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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",
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
[
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
}, [
|
|
243
|
-
if (!
|
|
244
|
-
|
|
245
|
-
|
|
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:
|
|
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
|
-
|
|
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:
|
|
278
|
-
border: `1px solid ${
|
|
279
|
-
backgroundColor:
|
|
280
|
-
color:
|
|
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:
|
|
291
|
-
"aria-label":
|
|
231
|
+
ref: g,
|
|
232
|
+
"aria-label": o.appsButton,
|
|
292
233
|
"aria-haspopup": "menu",
|
|
293
|
-
"aria-expanded":
|
|
234
|
+
"aria-expanded": y === "apps",
|
|
294
235
|
"data-neetru-appswitcher-button": "true",
|
|
295
|
-
onClick: () =>
|
|
296
|
-
style:
|
|
236
|
+
onClick: () => x((a) => a === "apps" ? null : "apps"),
|
|
237
|
+
style: B(y === "apps")
|
|
297
238
|
},
|
|
298
|
-
h(
|
|
299
|
-
)
|
|
300
|
-
const accountButton = h(
|
|
239
|
+
h(ee, {})
|
|
240
|
+
), J = h(
|
|
301
241
|
"button",
|
|
302
242
|
{
|
|
303
243
|
type: "button",
|
|
304
|
-
ref:
|
|
305
|
-
"aria-label": `${
|
|
244
|
+
ref: d,
|
|
245
|
+
"aria-label": `${o.accountButton}${C.displayName ? ` (${C.displayName})` : ""}`,
|
|
306
246
|
"aria-haspopup": "menu",
|
|
307
|
-
"aria-expanded":
|
|
247
|
+
"aria-expanded": y === "account",
|
|
308
248
|
"data-neetru-account-button": "true",
|
|
309
|
-
onClick: () =>
|
|
310
|
-
style: { ...
|
|
249
|
+
onClick: () => x((a) => a === "account" ? null : "account"),
|
|
250
|
+
style: { ...B(y === "account"), width: 36, height: 36 }
|
|
311
251
|
},
|
|
312
|
-
|
|
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:
|
|
321
|
-
border: `1px solid ${
|
|
322
|
-
borderRadius:
|
|
259
|
+
backgroundColor: b.bg,
|
|
260
|
+
border: `1px solid ${b.border}`,
|
|
261
|
+
borderRadius: M,
|
|
323
262
|
zIndex: 1e3,
|
|
324
|
-
color:
|
|
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 ${
|
|
337
|
-
color:
|
|
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
|
-
|
|
347
|
-
|
|
348
|
-
e.currentTarget.style.backgroundColor = C.bgHover;
|
|
283
|
+
}, _ = {
|
|
284
|
+
onMouseEnter: (a) => {
|
|
285
|
+
a.currentTarget.style.backgroundColor = b.bgHover;
|
|
349
286
|
},
|
|
350
|
-
onMouseLeave: (
|
|
351
|
-
|
|
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:
|
|
293
|
+
ref: S,
|
|
358
294
|
role: "menu",
|
|
359
|
-
"aria-label":
|
|
295
|
+
"aria-label": o.accountButton,
|
|
360
296
|
"data-neetru-account-menu": "true",
|
|
361
|
-
onKeyDown:
|
|
362
|
-
style:
|
|
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:
|
|
316
|
+
backgroundColor: C.photoUrl ? "transparent" : b.fg,
|
|
381
317
|
color: "#ffffff",
|
|
382
318
|
fontSize: 15,
|
|
383
319
|
fontWeight: 700
|
|
384
320
|
}
|
|
385
321
|
},
|
|
386
|
-
|
|
387
|
-
src:
|
|
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
|
-
}) :
|
|
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
|
-
|
|
344
|
+
C.displayName || C.email
|
|
409
345
|
),
|
|
410
|
-
|
|
346
|
+
C.email ? h(
|
|
411
347
|
"span",
|
|
412
348
|
{
|
|
413
349
|
style: {
|
|
414
|
-
color:
|
|
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
|
-
|
|
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:
|
|
366
|
+
href: z,
|
|
431
367
|
target: "_blank",
|
|
432
368
|
rel: "noopener noreferrer",
|
|
433
|
-
style:
|
|
434
|
-
...
|
|
369
|
+
style: D,
|
|
370
|
+
..._
|
|
435
371
|
},
|
|
436
|
-
|
|
372
|
+
o.myAccount
|
|
437
373
|
),
|
|
438
374
|
// Configurações da conta (deste produto)
|
|
439
|
-
|
|
375
|
+
i ? h(
|
|
440
376
|
"a",
|
|
441
|
-
{ role: "menuitem", href:
|
|
442
|
-
|
|
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:
|
|
451
|
-
disabled:
|
|
386
|
+
onClick: G,
|
|
387
|
+
disabled: T,
|
|
452
388
|
"data-neetru-signout": "true",
|
|
453
|
-
style: { ...
|
|
454
|
-
...
|
|
389
|
+
style: { ...D, cursor: T ? "not-allowed" : "pointer" },
|
|
390
|
+
..._
|
|
455
391
|
},
|
|
456
|
-
|
|
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:
|
|
397
|
+
ref: S,
|
|
463
398
|
role: "menu",
|
|
464
|
-
"aria-label":
|
|
399
|
+
"aria-label": o.appsTitle,
|
|
465
400
|
"data-neetru-appswitcher-menu": "true",
|
|
466
|
-
onKeyDown:
|
|
467
|
-
style: { ...
|
|
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:
|
|
413
|
+
color: b.muted
|
|
479
414
|
}
|
|
480
415
|
},
|
|
481
|
-
|
|
416
|
+
o.appsTitle
|
|
482
417
|
),
|
|
483
|
-
|
|
418
|
+
U.length === 0 ? h(
|
|
484
419
|
"div",
|
|
485
|
-
{ style: { padding: "4px 14px 16px", fontSize: 13, color:
|
|
486
|
-
|
|
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:
|
|
430
|
+
backgroundColor: b.borderSoft
|
|
496
431
|
}
|
|
497
432
|
},
|
|
498
|
-
|
|
499
|
-
|
|
433
|
+
U.map((a) => {
|
|
434
|
+
let k = !!t && a.slug === t;
|
|
500
435
|
return h(
|
|
501
436
|
"a",
|
|
502
437
|
{
|
|
503
|
-
key:
|
|
438
|
+
key: a.slug,
|
|
504
439
|
role: "menuitem",
|
|
505
|
-
href:
|
|
506
|
-
"aria-current":
|
|
507
|
-
"data-neetru-product":
|
|
508
|
-
"data-current":
|
|
509
|
-
title:
|
|
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:
|
|
518
|
-
backgroundColor:
|
|
452
|
+
color: b.fg,
|
|
453
|
+
backgroundColor: k ? b.bgHover : b.bg,
|
|
519
454
|
cursor: "pointer",
|
|
520
455
|
boxSizing: "border-box"
|
|
521
456
|
},
|
|
522
|
-
onMouseEnter: (
|
|
523
|
-
|
|
457
|
+
onMouseEnter: (v) => {
|
|
458
|
+
v.currentTarget.style.backgroundColor = b.bgHover;
|
|
524
459
|
},
|
|
525
|
-
onMouseLeave: (
|
|
526
|
-
|
|
460
|
+
onMouseLeave: (v) => {
|
|
461
|
+
v.currentTarget.style.backgroundColor = k ? b.bgHover : b.bg;
|
|
527
462
|
}
|
|
528
463
|
},
|
|
529
464
|
// Tile/ícone
|
|
530
|
-
|
|
531
|
-
src:
|
|
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:
|
|
481
|
+
backgroundColor: b.fg,
|
|
547
482
|
color: "#ffffff",
|
|
548
483
|
fontSize: 13,
|
|
549
484
|
fontWeight: 700
|
|
550
485
|
}
|
|
551
486
|
},
|
|
552
|
-
|
|
487
|
+
N(a.name)
|
|
553
488
|
),
|
|
554
489
|
h(
|
|
555
490
|
"span",
|
|
556
491
|
{
|
|
557
492
|
style: {
|
|
558
493
|
fontSize: 12,
|
|
559
|
-
fontWeight:
|
|
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
|
-
|
|
504
|
+
a.name
|
|
570
505
|
),
|
|
571
|
-
|
|
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:
|
|
514
|
+
color: b.muted
|
|
580
515
|
}
|
|
581
516
|
},
|
|
582
|
-
|
|
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:
|
|
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
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
539
|
+
V,
|
|
540
|
+
J,
|
|
541
|
+
X,
|
|
542
|
+
Y
|
|
608
543
|
);
|
|
609
544
|
}
|
|
610
545
|
|
|
611
546
|
// src/firestore-compat.ts
|
|
612
|
-
function
|
|
613
|
-
|
|
614
|
-
let
|
|
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
|
-
|
|
619
|
-
|
|
551
|
+
let r = c;
|
|
552
|
+
t.push({ field: r.field, op: r.op, value: r.value });
|
|
620
553
|
} else if (c.__constraint === "orderBy") {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
} else
|
|
624
|
-
|
|
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
|
|
639
|
-
|
|
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(
|
|
644
|
-
});
|
|
645
|
-
let payload = null;
|
|
567
|
+
body: JSON.stringify(t)
|
|
568
|
+
}), n = null;
|
|
646
569
|
try {
|
|
647
|
-
|
|
570
|
+
n = await i.json();
|
|
648
571
|
} catch {
|
|
649
|
-
|
|
572
|
+
n = null;
|
|
650
573
|
}
|
|
651
|
-
if (!
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
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
|
-
|
|
663
|
-
|
|
664
|
-
|
|
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(
|
|
672
|
-
redirectUrl,
|
|
673
|
-
status:
|
|
674
|
-
expiresAt: typeof
|
|
675
|
-
requiresKyc:
|
|
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
|
|
679
|
-
|
|
680
|
-
|
|
596
|
+
function re(e) {
|
|
597
|
+
let t = globalThis.location;
|
|
598
|
+
t && typeof t.assign == "function" && t.assign(e);
|
|
681
599
|
}
|
|
682
|
-
function
|
|
683
|
-
client,
|
|
684
|
-
startPath,
|
|
685
|
-
productId,
|
|
686
|
-
planId,
|
|
687
|
-
callbackUrl,
|
|
688
|
-
tenantType,
|
|
689
|
-
tenantId,
|
|
690
|
-
children,
|
|
691
|
-
onIntentCreated,
|
|
692
|
-
onError,
|
|
693
|
-
noAutoRedirect,
|
|
694
|
-
...
|
|
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
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
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
|
-
|
|
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
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
661
|
+
[x, R, t, i, n, s, c, r, m, f, u]
|
|
747
662
|
);
|
|
748
|
-
return
|
|
663
|
+
return l__namespace.createElement(
|
|
749
664
|
"a",
|
|
750
665
|
{
|
|
751
|
-
...
|
|
752
|
-
href:
|
|
753
|
-
onClick:
|
|
754
|
-
"aria-busy":
|
|
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
|
-
|
|
672
|
+
o
|
|
758
673
|
);
|
|
759
674
|
}
|
|
760
|
-
var
|
|
761
|
-
|
|
762
|
-
|
|
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:
|
|
768
|
-
width: Math.round(
|
|
769
|
-
height:
|
|
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
|
-
|
|
686
|
+
l__namespace.createElement("path", { d: oe, fill: e })
|
|
774
687
|
);
|
|
775
688
|
}
|
|
776
|
-
var
|
|
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
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
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
|
|
791
|
-
client,
|
|
792
|
-
redirectUri,
|
|
793
|
-
scope,
|
|
794
|
-
postLoginRedirect,
|
|
795
|
-
theme = "dark",
|
|
796
|
-
label = "Entrar com Neetru",
|
|
797
|
-
onError,
|
|
798
|
-
style,
|
|
799
|
-
disabled,
|
|
800
|
-
...
|
|
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
|
-
|
|
803
|
-
|
|
804
|
-
|
|
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
|
-
|
|
810
|
-
if (
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
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
|
-
}, [
|
|
821
|
-
return
|
|
726
|
+
}, [e, t, i, n, p, r]);
|
|
727
|
+
return l__namespace.createElement(
|
|
822
728
|
"button",
|
|
823
729
|
{
|
|
824
|
-
...
|
|
730
|
+
...u,
|
|
825
731
|
type: "button",
|
|
826
|
-
onClick:
|
|
827
|
-
disabled:
|
|
828
|
-
onMouseEnter: () =>
|
|
829
|
-
onMouseLeave: () =>
|
|
830
|
-
"aria-label":
|
|
831
|
-
"aria-busy":
|
|
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 ${
|
|
843
|
-
backgroundColor:
|
|
844
|
-
color:
|
|
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:
|
|
852
|
-
opacity:
|
|
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":
|
|
858
|
-
...
|
|
763
|
+
"--neetru-login-focus-ring": R.fg,
|
|
764
|
+
...o
|
|
859
765
|
}
|
|
860
766
|
},
|
|
861
|
-
|
|
862
|
-
|
|
767
|
+
l__namespace.createElement(ae, { fill: R.fg }),
|
|
768
|
+
l__namespace.createElement("span", null, m ? "Entrando\u2026" : c)
|
|
863
769
|
);
|
|
864
770
|
}
|
|
865
|
-
var
|
|
771
|
+
var j = l__namespace.createContext({
|
|
866
772
|
readonly: false
|
|
867
773
|
});
|
|
868
|
-
function
|
|
869
|
-
return
|
|
774
|
+
function Ce() {
|
|
775
|
+
return l__namespace.useContext(j);
|
|
870
776
|
}
|
|
871
|
-
function
|
|
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
|
-
|
|
786
|
+
let [o, f] = l__namespace.useState({
|
|
881
787
|
status: "loading"
|
|
882
|
-
});
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
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
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
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
|
-
|
|
897
|
-
allowed:
|
|
898
|
-
reason:
|
|
899
|
-
limit:
|
|
900
|
-
currentUsage:
|
|
901
|
-
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
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
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
|
-
|
|
920
|
-
return (
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
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:
|
|
938
|
-
reason:
|
|
939
|
-
limit:
|
|
940
|
-
currentUsage:
|
|
824
|
+
readonly: T,
|
|
825
|
+
reason: y?.reason,
|
|
826
|
+
limit: y?.limit,
|
|
827
|
+
currentUsage: y?.currentUsage
|
|
941
828
|
}
|
|
942
829
|
},
|
|
943
|
-
|
|
830
|
+
r
|
|
944
831
|
);
|
|
945
832
|
}
|
|
946
|
-
var
|
|
947
|
-
function
|
|
948
|
-
return typeof document
|
|
833
|
+
var $ = 5e3;
|
|
834
|
+
function q() {
|
|
835
|
+
return typeof document < "u" && document.hidden === true;
|
|
949
836
|
}
|
|
950
|
-
function
|
|
951
|
-
if (!
|
|
952
|
-
if (
|
|
953
|
-
return `collection:${
|
|
954
|
-
|
|
955
|
-
|
|
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
|
|
959
|
-
return
|
|
960
|
-
|
|
961
|
-
|
|
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
|
|
966
|
-
|
|
967
|
-
if (!
|
|
968
|
-
|
|
969
|
-
|
|
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
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
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:
|
|
861
|
+
isLoading: s !== null,
|
|
981
862
|
error: null,
|
|
982
863
|
isStale: false,
|
|
983
864
|
lastUpdated: null
|
|
984
|
-
});
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
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
|
-
|
|
998
|
-
|
|
999
|
-
|
|
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:
|
|
879
|
+
isStale: d.stale === true,
|
|
1008
880
|
lastUpdated: Date.now()
|
|
1009
881
|
});
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
|
|
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:
|
|
887
|
+
error: d instanceof Error ? d : new Error(String(d)),
|
|
1018
888
|
isStale: true
|
|
1019
889
|
}));
|
|
1020
890
|
};
|
|
1021
|
-
if (
|
|
1022
|
-
let
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
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
|
-
|
|
1033
|
-
|
|
901
|
+
g();
|
|
902
|
+
let S = setInterval(g, i);
|
|
1034
903
|
return () => {
|
|
1035
|
-
|
|
1036
|
-
clearInterval(timer);
|
|
1037
|
-
mountedRef.current = false;
|
|
904
|
+
d = true, clearInterval(S), o.current = false;
|
|
1038
905
|
};
|
|
1039
906
|
}
|
|
1040
|
-
let
|
|
907
|
+
let p;
|
|
1041
908
|
try {
|
|
1042
|
-
|
|
1043
|
-
} catch (
|
|
1044
|
-
|
|
909
|
+
p = x.onSnapshot(y, T);
|
|
910
|
+
} catch (d) {
|
|
911
|
+
R(d);
|
|
1045
912
|
}
|
|
1046
913
|
return () => {
|
|
1047
|
-
|
|
1048
|
-
unsub?.();
|
|
914
|
+
o.current = false, p?.();
|
|
1049
915
|
};
|
|
1050
|
-
}, [
|
|
1051
|
-
return state;
|
|
916
|
+
}, [s, i, n]), c;
|
|
1052
917
|
}
|
|
1053
|
-
function
|
|
1054
|
-
|
|
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:
|
|
921
|
+
isLoading: s !== null,
|
|
1060
922
|
error: null,
|
|
1061
923
|
isStale: false,
|
|
1062
924
|
lastUpdated: null
|
|
1063
|
-
});
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
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
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
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:
|
|
939
|
+
isStale: p?.stale === true,
|
|
1086
940
|
lastUpdated: Date.now()
|
|
1087
941
|
});
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
setState((prev) => ({
|
|
1092
|
-
...prev,
|
|
942
|
+
}, T = (p) => {
|
|
943
|
+
o.current && r((d) => ({
|
|
944
|
+
...d,
|
|
1093
945
|
isLoading: false,
|
|
1094
|
-
error:
|
|
946
|
+
error: p instanceof Error ? p : new Error(String(p)),
|
|
1095
947
|
isStale: true
|
|
1096
948
|
}));
|
|
1097
949
|
};
|
|
1098
|
-
if (
|
|
1099
|
-
let
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
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
|
-
|
|
1110
|
-
|
|
960
|
+
d();
|
|
961
|
+
let g = setInterval(d, i);
|
|
1111
962
|
return () => {
|
|
1112
|
-
|
|
1113
|
-
clearInterval(timer);
|
|
1114
|
-
mountedRef.current = false;
|
|
963
|
+
p = true, clearInterval(g), o.current = false;
|
|
1115
964
|
};
|
|
1116
965
|
}
|
|
1117
|
-
let
|
|
966
|
+
let R;
|
|
1118
967
|
try {
|
|
1119
|
-
|
|
1120
|
-
} catch (
|
|
1121
|
-
|
|
968
|
+
R = m.onSnapshot(x);
|
|
969
|
+
} catch (p) {
|
|
970
|
+
T(p);
|
|
1122
971
|
}
|
|
1123
972
|
return () => {
|
|
1124
|
-
|
|
1125
|
-
unsub?.();
|
|
973
|
+
o.current = false, R?.();
|
|
1126
974
|
};
|
|
1127
|
-
}, [
|
|
1128
|
-
return state;
|
|
975
|
+
}, [s, i, n]), c;
|
|
1129
976
|
}
|
|
1130
|
-
function
|
|
1131
|
-
|
|
1132
|
-
|
|
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
|
|
1138
|
-
|
|
1139
|
-
|
|
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
|
-
|
|
985
|
+
o = n.getUser();
|
|
1144
986
|
} catch {
|
|
1145
|
-
|
|
987
|
+
o = null;
|
|
1146
988
|
}
|
|
1147
|
-
return { user:
|
|
1148
|
-
});
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
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
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
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
|
-
|
|
1175
|
-
clearTimeout(timer);
|
|
1176
|
-
unsub?.();
|
|
1008
|
+
r.current = false, clearTimeout(f), u?.();
|
|
1177
1009
|
};
|
|
1178
|
-
}, [
|
|
1179
|
-
return state;
|
|
1010
|
+
}, [n, i]), s;
|
|
1180
1011
|
}
|
|
1181
1012
|
|
|
1182
|
-
exports.CheckoutLink =
|
|
1183
|
-
exports.EntitlementGate =
|
|
1184
|
-
exports.NeetruAccountBar =
|
|
1185
|
-
exports.NeetruLoginButton =
|
|
1186
|
-
exports.fetchNeetruAccountBar =
|
|
1187
|
-
exports.initialsFrom =
|
|
1188
|
-
exports.useCollection =
|
|
1189
|
-
exports.useDoc =
|
|
1190
|
-
exports.useEntitlementContext =
|
|
1191
|
-
exports.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;
|