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