@kelviq/react-sdk 2.0.2 → 2.1.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/dist/components/KQFeatureList.d.ts +19 -0
- package/dist/components/KQPrice.d.ts +29 -0
- package/dist/contexts/KelviqContext.d.ts +6 -2
- package/dist/contexts/KelviqProvider.d.ts +4 -2
- package/dist/hooks/usePricing.d.ts +9 -0
- package/dist/index.d.ts +4 -0
- package/dist/kelviq-react-sdk.js +536 -364
- package/dist/kelviq-react-sdk.umd.cjs +1 -1
- package/dist/types/api.types.d.ts +95 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/sdk.types.d.ts +6 -0
- package/dist/utils/formatPrice.d.ts +11 -0
- package/package.json +1 -1
package/dist/kelviq-react-sdk.js
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import { jsx as L, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as oe, useState as I, useCallback as K, useEffect as se, useMemo as ae, useContext as le } from "react";
|
|
3
|
+
const ce = "GET", ue = 5e3, de = 3, fe = 1e3;
|
|
4
|
+
function x(n) {
|
|
5
5
|
const {
|
|
6
|
-
method:
|
|
7
|
-
headers:
|
|
6
|
+
method: i = ce,
|
|
7
|
+
headers: a = {},
|
|
8
8
|
// Renamed to avoid conflict with internal 'headers' variable
|
|
9
|
-
body:
|
|
10
|
-
timeout:
|
|
11
|
-
maxRetries:
|
|
12
|
-
backoffBaseDelay:
|
|
13
|
-
queryParams:
|
|
14
|
-
accessToken:
|
|
9
|
+
body: r,
|
|
10
|
+
timeout: f = ue,
|
|
11
|
+
maxRetries: l = de,
|
|
12
|
+
backoffBaseDelay: c = fe,
|
|
13
|
+
queryParams: E,
|
|
14
|
+
accessToken: o
|
|
15
15
|
// Use the direct accessToken
|
|
16
16
|
} = n;
|
|
17
|
-
let { url:
|
|
18
|
-
return new Promise((
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
for (const
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
let { url: s } = n, p = 0;
|
|
18
|
+
return new Promise((q, U) => {
|
|
19
|
+
if (E) {
|
|
20
|
+
const v = new URLSearchParams();
|
|
21
|
+
for (const S in E)
|
|
22
|
+
E[S] !== void 0 && v.append(S, String(E[S]));
|
|
23
|
+
v.toString() && (s += (s.includes("?") ? "&" : "?") + v.toString());
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
25
|
+
function b() {
|
|
26
|
+
const v = new XMLHttpRequest();
|
|
27
|
+
v.open(i, s, !0), v.timeout = f;
|
|
28
|
+
const S = {
|
|
29
29
|
Accept: "application/json",
|
|
30
30
|
"X-Requested-With": "XMLHttpRequest",
|
|
31
|
-
...
|
|
31
|
+
...a
|
|
32
32
|
// Apply custom headers, allowing them to override defaults
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
for (const [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const { status:
|
|
39
|
-
if (
|
|
34
|
+
i !== "GET" && r && typeof r == "object" && !(r instanceof FormData) && (S["Content-Type"] || (S["Content-Type"] = "application/json")), o && (S.Authorization = `Bearer ${o}`);
|
|
35
|
+
for (const [u, m] of Object.entries(S))
|
|
36
|
+
v.setRequestHeader(u, m);
|
|
37
|
+
v.onload = function() {
|
|
38
|
+
const { status: u, statusText: m, responseText: y } = v;
|
|
39
|
+
if (u >= 200 && u < 300)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
} catch (
|
|
44
|
-
const
|
|
41
|
+
const P = y ? JSON.parse(y) : {};
|
|
42
|
+
q({ status: u, statusText: m, data: P });
|
|
43
|
+
} catch (P) {
|
|
44
|
+
const _ = P instanceof Error ? P : new Error(String(P));
|
|
45
45
|
console.error(
|
|
46
|
-
`Kelviq SDK (apiRequest): Invalid JSON response for URL ${
|
|
47
|
-
),
|
|
46
|
+
`Kelviq SDK (apiRequest): Invalid JSON response for URL ${s}. Error: ${_.message}. Response: ${y}`
|
|
47
|
+
), U(
|
|
48
48
|
new Error(
|
|
49
|
-
`Invalid JSON response: ${
|
|
49
|
+
`Invalid JSON response: ${_.message}`
|
|
50
50
|
)
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
else
|
|
54
|
-
|
|
55
|
-
`Request to ${
|
|
54
|
+
A(
|
|
55
|
+
`Request to ${s} failed with status ${u} ${m}. Response: ${y}`
|
|
56
56
|
);
|
|
57
|
-
},
|
|
58
|
-
`Network error for URL ${
|
|
59
|
-
),
|
|
60
|
-
function
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
57
|
+
}, v.onerror = () => A(
|
|
58
|
+
`Network error for URL ${s}. The request could not be completed.`
|
|
59
|
+
), v.ontimeout = () => A(`Request to ${s} timed out.`);
|
|
60
|
+
function A(u) {
|
|
61
|
+
if (p < l) {
|
|
62
|
+
p++;
|
|
63
|
+
const m = Math.min(
|
|
64
|
+
c * Math.pow(2, p - 1),
|
|
65
65
|
3e4
|
|
66
66
|
// Cap retry delay at 30 seconds
|
|
67
67
|
);
|
|
68
68
|
console.warn(
|
|
69
|
-
`Kelviq SDK (apiRequest): Retrying request to ${
|
|
70
|
-
), setTimeout(
|
|
69
|
+
`Kelviq SDK (apiRequest): Retrying request to ${s}. Attempt ${p}/${l}. Error: ${u}. Retrying in ${m}ms.`
|
|
70
|
+
), setTimeout(b, m);
|
|
71
71
|
} else
|
|
72
|
-
|
|
72
|
+
U(
|
|
73
73
|
new Error(
|
|
74
|
-
`${
|
|
74
|
+
`${u} (Max retries ${l} reached)`
|
|
75
75
|
)
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
try {
|
|
79
|
-
let
|
|
80
|
-
|
|
81
|
-
} catch (
|
|
82
|
-
const
|
|
79
|
+
let u = r;
|
|
80
|
+
r && typeof r == "object" && !(r instanceof FormData) && S["Content-Type"] === "application/json" && (u = JSON.stringify(r)), v.send(u);
|
|
81
|
+
} catch (u) {
|
|
82
|
+
const m = u instanceof Error ? u : new Error(String(u));
|
|
83
83
|
console.error(
|
|
84
|
-
`Kelviq SDK (apiRequest): Error sending request to ${
|
|
85
|
-
|
|
86
|
-
),
|
|
84
|
+
`Kelviq SDK (apiRequest): Error sending request to ${s}.`,
|
|
85
|
+
m
|
|
86
|
+
), U(new Error(`Failed to send request: ${m.message}`));
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
b();
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
let
|
|
96
|
-
for (const
|
|
97
|
-
const
|
|
98
|
-
|
|
92
|
+
function me(n, i) {
|
|
93
|
+
const a = i[0].featureType;
|
|
94
|
+
if (a === "METER") {
|
|
95
|
+
let r = 0, f = 0, l = !1;
|
|
96
|
+
for (const E of i) {
|
|
97
|
+
const o = E, s = typeof o.usageLimit == "number" ? o.usageLimit : null, p = typeof o.currentUsage == "number" ? o.currentUsage : 0;
|
|
98
|
+
s === null && (r = null), r !== null && (r += s), f += p, o.hardLimit && (l = !0);
|
|
99
99
|
}
|
|
100
|
-
const
|
|
100
|
+
const c = r !== null ? r - f : null;
|
|
101
101
|
return {
|
|
102
102
|
featureId: n,
|
|
103
|
-
featureType:
|
|
104
|
-
hasAccess:
|
|
105
|
-
currentUsage:
|
|
106
|
-
usageLimit:
|
|
107
|
-
remaining:
|
|
108
|
-
hardLimit:
|
|
109
|
-
items:
|
|
103
|
+
featureType: a,
|
|
104
|
+
hasAccess: c === null || c > 0,
|
|
105
|
+
currentUsage: f,
|
|
106
|
+
usageLimit: r,
|
|
107
|
+
remaining: c,
|
|
108
|
+
hardLimit: l,
|
|
109
|
+
items: i
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
112
|
+
if (a === "CUSTOMIZABLE") {
|
|
113
|
+
const r = i[0];
|
|
114
114
|
return {
|
|
115
115
|
featureId: n,
|
|
116
|
-
featureType:
|
|
117
|
-
hasAccess:
|
|
118
|
-
currentUsage: typeof
|
|
119
|
-
usageLimit: typeof
|
|
120
|
-
remaining: typeof
|
|
121
|
-
hardLimit:
|
|
122
|
-
items:
|
|
116
|
+
featureType: a,
|
|
117
|
+
hasAccess: i.some((f) => f.hasAccess),
|
|
118
|
+
currentUsage: typeof r.currentUsage == "number" ? r.currentUsage : 0,
|
|
119
|
+
usageLimit: typeof r.usageLimit == "number" ? r.usageLimit : null,
|
|
120
|
+
remaining: typeof r.remaining == "number" ? r.remaining : null,
|
|
121
|
+
hardLimit: r.hardLimit === !0,
|
|
122
|
+
items: i
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
return {
|
|
126
126
|
featureId: n,
|
|
127
|
-
featureType:
|
|
128
|
-
hasAccess:
|
|
127
|
+
featureType: a,
|
|
128
|
+
hasAccess: i.some((r) => r.hasAccess),
|
|
129
129
|
currentUsage: 0,
|
|
130
130
|
usageLimit: null,
|
|
131
131
|
remaining: null,
|
|
132
132
|
hardLimit: !1,
|
|
133
|
-
items:
|
|
133
|
+
items: i
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
const
|
|
136
|
+
function ge(n) {
|
|
137
|
+
const i = {};
|
|
138
138
|
if (!n || !Array.isArray(n.entitlements))
|
|
139
139
|
return console.warn(
|
|
140
140
|
"Kelviq SDK: Invalid or empty entitlements array in API response.",
|
|
141
141
|
n
|
|
142
|
-
),
|
|
143
|
-
const
|
|
144
|
-
for (const
|
|
145
|
-
if (!
|
|
142
|
+
), i;
|
|
143
|
+
const a = {};
|
|
144
|
+
for (const r of n.entitlements) {
|
|
145
|
+
if (!r || typeof r.featureId != "string" || typeof r.featureType != "string") {
|
|
146
146
|
console.warn(
|
|
147
147
|
"Kelviq SDK: Skipping invalid raw entitlement object:",
|
|
148
|
-
|
|
148
|
+
r
|
|
149
149
|
);
|
|
150
150
|
continue;
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
a[r.featureId] || (a[r.featureId] = []), a[r.featureId].push(r);
|
|
153
153
|
}
|
|
154
|
-
for (const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
for (const r in a)
|
|
155
|
+
i[r] = me(
|
|
156
|
+
r,
|
|
157
|
+
a[r]
|
|
158
158
|
);
|
|
159
|
-
return
|
|
159
|
+
return i;
|
|
160
160
|
}
|
|
161
|
-
const
|
|
161
|
+
const re = {
|
|
162
162
|
allEntitlements: {
|
|
163
163
|
data: null,
|
|
164
164
|
isLoading: !0,
|
|
@@ -193,456 +193,628 @@ const V = {
|
|
|
193
193
|
refreshCustomer: () => (console.warn(
|
|
194
194
|
"refreshCustomer called on default KelviqContext. Ensure KelviqProvider is properly set up."
|
|
195
195
|
), Promise.resolve()),
|
|
196
|
+
pricing: {
|
|
197
|
+
data: null,
|
|
198
|
+
isLoading: !1,
|
|
199
|
+
error: null
|
|
200
|
+
},
|
|
201
|
+
refreshPricing: () => (console.warn(
|
|
202
|
+
"refreshPricing called on default KelviqContext. Ensure KelviqProvider is properly set up."
|
|
203
|
+
), Promise.resolve()),
|
|
196
204
|
isLoading: !0,
|
|
197
205
|
error: null,
|
|
198
206
|
apiUrl: "",
|
|
199
207
|
environment: "production",
|
|
200
208
|
entitlementsPath: "",
|
|
201
209
|
customerId: ""
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
),
|
|
210
|
+
}, te = oe(
|
|
211
|
+
re
|
|
212
|
+
), pe = "https://edge.api.kelviq.com/api/v1/", he = "https://edge.sandboxapi.kelviq.com/api/v1/", Ee = "https://api.kelviq.com/api/v1/", Le = "https://sandboxapi.kelviq.com/api/v1/", ve = "entitlements/", Ae = "monetization/product-offering/", qe = ({
|
|
205
213
|
children: n,
|
|
206
|
-
apiUrl:
|
|
207
|
-
entitlementsPath:
|
|
208
|
-
customerId:
|
|
209
|
-
environment:
|
|
210
|
-
accessToken:
|
|
211
|
-
|
|
214
|
+
apiUrl: i,
|
|
215
|
+
entitlementsPath: a = ve,
|
|
216
|
+
customerId: r,
|
|
217
|
+
environment: f = "production",
|
|
218
|
+
accessToken: l,
|
|
219
|
+
productId: c,
|
|
220
|
+
config: E = {}
|
|
212
221
|
}) => {
|
|
213
222
|
const {
|
|
214
|
-
onError:
|
|
215
|
-
maxRetries:
|
|
216
|
-
timeout:
|
|
217
|
-
backoffBaseDelay:
|
|
218
|
-
fetchEntitlementsOnMount:
|
|
219
|
-
fetchSubscriptionsOnMount:
|
|
220
|
-
fetchCustomerOnMount:
|
|
221
|
-
|
|
223
|
+
onError: o,
|
|
224
|
+
maxRetries: s,
|
|
225
|
+
timeout: p,
|
|
226
|
+
backoffBaseDelay: q,
|
|
227
|
+
fetchEntitlementsOnMount: U = !0,
|
|
228
|
+
fetchSubscriptionsOnMount: b = !1,
|
|
229
|
+
fetchCustomerOnMount: v = !1,
|
|
230
|
+
fetchPricingOnMount: S = !1
|
|
231
|
+
} = E, A = i || (f === "sandbox" ? he : pe), u = f === "sandbox" ? Le : Ee, [m, y] = I({
|
|
232
|
+
data: null,
|
|
233
|
+
isLoading: !!A && U,
|
|
234
|
+
error: null
|
|
235
|
+
}), [P, _] = I(null), [k, T] = I({
|
|
222
236
|
data: null,
|
|
223
|
-
isLoading: !!
|
|
237
|
+
isLoading: !!A && b,
|
|
224
238
|
error: null
|
|
225
|
-
}), [
|
|
239
|
+
}), [X, M] = I({
|
|
226
240
|
data: null,
|
|
227
|
-
isLoading: !!
|
|
241
|
+
isLoading: !!A && v,
|
|
228
242
|
error: null
|
|
229
|
-
}), [
|
|
243
|
+
}), [z, D] = I({
|
|
230
244
|
data: null,
|
|
231
|
-
isLoading: !!
|
|
245
|
+
isLoading: !!A && S,
|
|
232
246
|
error: null
|
|
233
|
-
}), [
|
|
234
|
-
!!
|
|
235
|
-
), [
|
|
236
|
-
(
|
|
237
|
-
const
|
|
238
|
-
`Kelviq SDK (${e}): ${
|
|
247
|
+
}), [F, $] = I(
|
|
248
|
+
!!A && U
|
|
249
|
+
), [W, j] = I(null), h = K(
|
|
250
|
+
(d, e, t) => {
|
|
251
|
+
const g = new Error(
|
|
252
|
+
`Kelviq SDK (${e}): ${d}`
|
|
239
253
|
);
|
|
240
|
-
console.error(
|
|
254
|
+
console.error(g.message, t || ""), j((R) => R || g), o && o(g);
|
|
241
255
|
},
|
|
242
|
-
[
|
|
243
|
-
),
|
|
244
|
-
if (!
|
|
245
|
-
const
|
|
246
|
-
return
|
|
256
|
+
[o]
|
|
257
|
+
), O = K(() => {
|
|
258
|
+
if (!A) {
|
|
259
|
+
const t = "API URL not configured. Cannot fetch entitlements.";
|
|
260
|
+
return y({
|
|
247
261
|
data: null,
|
|
248
262
|
isLoading: !1,
|
|
249
|
-
error: new Error(
|
|
250
|
-
}), h(
|
|
263
|
+
error: new Error(t)
|
|
264
|
+
}), h(t, "fetchAllEntitlements"), $(!1), Promise.reject(new Error(t));
|
|
251
265
|
}
|
|
252
|
-
if (!
|
|
253
|
-
const
|
|
254
|
-
return
|
|
266
|
+
if (!r) {
|
|
267
|
+
const t = "CustomerId must be provided as props to KelviqProvider.";
|
|
268
|
+
return y(() => ({
|
|
255
269
|
data: null,
|
|
256
270
|
isLoading: !1,
|
|
257
|
-
error: new Error(
|
|
258
|
-
})), h(
|
|
271
|
+
error: new Error(t)
|
|
272
|
+
})), h(t, "fetchAllEntitlements"), $(!1), Promise.reject(new Error(t));
|
|
259
273
|
}
|
|
260
|
-
|
|
261
|
-
...
|
|
274
|
+
y((t) => ({
|
|
275
|
+
...t,
|
|
262
276
|
isLoading: !0,
|
|
263
277
|
error: null
|
|
264
|
-
})),
|
|
265
|
-
const
|
|
266
|
-
return
|
|
267
|
-
url:
|
|
278
|
+
})), $(!0), j(null);
|
|
279
|
+
const d = `${A.replace(/\/$/, "")}/${a.replace(/^\//, "")}`;
|
|
280
|
+
return x({
|
|
281
|
+
url: d,
|
|
268
282
|
method: "GET",
|
|
269
|
-
timeout:
|
|
270
|
-
maxRetries:
|
|
271
|
-
backoffBaseDelay:
|
|
272
|
-
accessToken:
|
|
283
|
+
timeout: p,
|
|
284
|
+
maxRetries: s,
|
|
285
|
+
backoffBaseDelay: q,
|
|
286
|
+
accessToken: l,
|
|
273
287
|
queryParams: {
|
|
274
|
-
customer_id:
|
|
288
|
+
customer_id: r
|
|
275
289
|
}
|
|
276
|
-
}).then((
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
290
|
+
}).then((t) => {
|
|
291
|
+
if (t && t.data && Array.isArray(t.data.entitlements)) {
|
|
292
|
+
_(t.data);
|
|
293
|
+
const g = ge(
|
|
294
|
+
t.data
|
|
281
295
|
);
|
|
282
|
-
|
|
283
|
-
data:
|
|
296
|
+
y({
|
|
297
|
+
data: g,
|
|
284
298
|
isLoading: !1,
|
|
285
299
|
error: null
|
|
286
300
|
});
|
|
287
301
|
} else {
|
|
288
|
-
const
|
|
302
|
+
const g = new Error(
|
|
289
303
|
"Received empty, malformed, or invalid data structure from entitlements API."
|
|
290
304
|
);
|
|
291
|
-
throw
|
|
305
|
+
throw y({
|
|
292
306
|
data: null,
|
|
293
307
|
isLoading: !1,
|
|
294
|
-
error:
|
|
308
|
+
error: g
|
|
295
309
|
}), h(
|
|
296
|
-
|
|
310
|
+
g.message,
|
|
297
311
|
"fetchAllEntitlements",
|
|
298
|
-
|
|
299
|
-
),
|
|
312
|
+
t
|
|
313
|
+
), g;
|
|
300
314
|
}
|
|
301
|
-
}).catch((
|
|
302
|
-
const
|
|
303
|
-
return
|
|
304
|
-
...
|
|
315
|
+
}).catch((t) => {
|
|
316
|
+
const g = t instanceof Error ? t : new Error(String(t));
|
|
317
|
+
return y((R) => ({
|
|
318
|
+
...R,
|
|
305
319
|
isLoading: !1,
|
|
306
|
-
error:
|
|
307
|
-
})), h(
|
|
320
|
+
error: g
|
|
321
|
+
})), h(g.message, "fetchAllEntitlements", t), Promise.reject(g);
|
|
308
322
|
}).finally(() => {
|
|
309
|
-
|
|
323
|
+
$(!1);
|
|
310
324
|
});
|
|
311
325
|
}, [
|
|
326
|
+
A,
|
|
327
|
+
r,
|
|
312
328
|
a,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
329
|
+
p,
|
|
330
|
+
s,
|
|
331
|
+
q,
|
|
316
332
|
l,
|
|
317
|
-
L,
|
|
318
|
-
g,
|
|
319
333
|
h
|
|
320
|
-
]),
|
|
321
|
-
if (!
|
|
334
|
+
]), B = K(() => {
|
|
335
|
+
if (!u) {
|
|
322
336
|
const e = "Main API URL not configured. Cannot fetch subscriptions.";
|
|
323
|
-
return
|
|
337
|
+
return T({
|
|
324
338
|
data: null,
|
|
325
339
|
isLoading: !1,
|
|
326
340
|
error: new Error(e)
|
|
327
341
|
}), h(e, "fetchSubscriptions"), Promise.reject(new Error(e));
|
|
328
342
|
}
|
|
329
|
-
if (!
|
|
343
|
+
if (!r) {
|
|
330
344
|
const e = "CustomerId must be provided as props to KelviqProvider.";
|
|
331
|
-
return
|
|
345
|
+
return T({
|
|
332
346
|
data: null,
|
|
333
347
|
isLoading: !1,
|
|
334
348
|
error: new Error(e)
|
|
335
349
|
}), h(e, "fetchSubscriptions"), Promise.reject(new Error(e));
|
|
336
350
|
}
|
|
337
|
-
|
|
351
|
+
T((e) => ({
|
|
338
352
|
...e,
|
|
339
353
|
isLoading: !0,
|
|
340
354
|
error: null
|
|
341
355
|
}));
|
|
342
|
-
const
|
|
343
|
-
return
|
|
344
|
-
url:
|
|
356
|
+
const d = `${u.replace(/\/$/, "")}/subscriptions/`;
|
|
357
|
+
return x({
|
|
358
|
+
url: d,
|
|
345
359
|
method: "GET",
|
|
346
|
-
timeout:
|
|
347
|
-
maxRetries:
|
|
348
|
-
backoffBaseDelay:
|
|
349
|
-
accessToken:
|
|
350
|
-
queryParams: { customer_id:
|
|
360
|
+
timeout: p,
|
|
361
|
+
maxRetries: s,
|
|
362
|
+
backoffBaseDelay: q,
|
|
363
|
+
accessToken: l,
|
|
364
|
+
queryParams: { customer_id: r }
|
|
351
365
|
}).then((e) => {
|
|
352
366
|
if (e && e.data && Array.isArray(e.data.results))
|
|
353
|
-
|
|
367
|
+
T({
|
|
354
368
|
data: e.data.results,
|
|
355
369
|
isLoading: !1,
|
|
356
370
|
error: null
|
|
357
371
|
});
|
|
358
372
|
else {
|
|
359
|
-
const
|
|
373
|
+
const t = new Error(
|
|
360
374
|
"Received empty, malformed, or invalid data structure from subscriptions API."
|
|
361
375
|
);
|
|
362
|
-
throw
|
|
376
|
+
throw T({
|
|
363
377
|
data: null,
|
|
364
378
|
isLoading: !1,
|
|
365
|
-
error:
|
|
379
|
+
error: t
|
|
366
380
|
}), h(
|
|
367
|
-
|
|
381
|
+
t.message,
|
|
368
382
|
"fetchSubscriptions",
|
|
369
383
|
e
|
|
370
|
-
),
|
|
384
|
+
), t;
|
|
371
385
|
}
|
|
372
386
|
}).catch((e) => {
|
|
373
|
-
const
|
|
374
|
-
return
|
|
375
|
-
...
|
|
387
|
+
const t = e instanceof Error ? e : new Error(String(e));
|
|
388
|
+
return T((g) => ({
|
|
389
|
+
...g,
|
|
376
390
|
isLoading: !1,
|
|
377
|
-
error:
|
|
391
|
+
error: t
|
|
378
392
|
})), h(
|
|
379
|
-
|
|
393
|
+
t.message,
|
|
380
394
|
"fetchSubscriptions",
|
|
381
395
|
e
|
|
382
|
-
), Promise.reject(
|
|
396
|
+
), Promise.reject(t);
|
|
383
397
|
});
|
|
384
398
|
}, [
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
399
|
+
u,
|
|
400
|
+
r,
|
|
401
|
+
p,
|
|
402
|
+
s,
|
|
403
|
+
q,
|
|
388
404
|
l,
|
|
389
|
-
L,
|
|
390
|
-
g,
|
|
391
405
|
h
|
|
392
|
-
]),
|
|
393
|
-
if (!
|
|
406
|
+
]), N = K(() => {
|
|
407
|
+
if (!u) {
|
|
394
408
|
const e = "Main API URL not configured. Cannot fetch customer.";
|
|
395
|
-
return
|
|
409
|
+
return M({
|
|
396
410
|
data: null,
|
|
397
411
|
isLoading: !1,
|
|
398
412
|
error: new Error(e)
|
|
399
413
|
}), h(e, "fetchCustomer"), Promise.reject(new Error(e));
|
|
400
414
|
}
|
|
401
|
-
if (!
|
|
415
|
+
if (!r) {
|
|
402
416
|
const e = "CustomerId must be provided as props to KelviqProvider.";
|
|
403
|
-
return
|
|
417
|
+
return M({
|
|
404
418
|
data: null,
|
|
405
419
|
isLoading: !1,
|
|
406
420
|
error: new Error(e)
|
|
407
421
|
}), h(e, "fetchCustomer"), Promise.reject(new Error(e));
|
|
408
422
|
}
|
|
409
|
-
|
|
423
|
+
M((e) => ({
|
|
410
424
|
...e,
|
|
411
425
|
isLoading: !0,
|
|
412
426
|
error: null
|
|
413
427
|
}));
|
|
414
|
-
const
|
|
415
|
-
return
|
|
416
|
-
url:
|
|
428
|
+
const d = `${u.replace(/\/$/, "")}/customers/${r}/`;
|
|
429
|
+
return x({
|
|
430
|
+
url: d,
|
|
417
431
|
method: "GET",
|
|
418
|
-
timeout:
|
|
419
|
-
maxRetries:
|
|
420
|
-
backoffBaseDelay:
|
|
421
|
-
accessToken:
|
|
432
|
+
timeout: p,
|
|
433
|
+
maxRetries: s,
|
|
434
|
+
backoffBaseDelay: q,
|
|
435
|
+
accessToken: l
|
|
422
436
|
}).then((e) => {
|
|
423
437
|
if (e && e.data)
|
|
424
|
-
|
|
438
|
+
M({
|
|
425
439
|
data: e.data,
|
|
426
440
|
isLoading: !1,
|
|
427
441
|
error: null
|
|
428
442
|
});
|
|
429
443
|
else {
|
|
430
|
-
const
|
|
444
|
+
const t = new Error(
|
|
431
445
|
"Received empty or invalid data from customer API."
|
|
432
446
|
);
|
|
433
|
-
throw
|
|
447
|
+
throw M({
|
|
434
448
|
data: null,
|
|
435
449
|
isLoading: !1,
|
|
436
|
-
error:
|
|
450
|
+
error: t
|
|
437
451
|
}), h(
|
|
438
|
-
|
|
452
|
+
t.message,
|
|
439
453
|
"fetchCustomer",
|
|
440
454
|
e
|
|
441
|
-
),
|
|
455
|
+
), t;
|
|
442
456
|
}
|
|
443
457
|
}).catch((e) => {
|
|
444
|
-
const
|
|
445
|
-
return
|
|
446
|
-
...
|
|
458
|
+
const t = e instanceof Error ? e : new Error(String(e));
|
|
459
|
+
return M((g) => ({
|
|
460
|
+
...g,
|
|
447
461
|
isLoading: !1,
|
|
448
|
-
error:
|
|
449
|
-
})), h(
|
|
462
|
+
error: t
|
|
463
|
+
})), h(t.message, "fetchCustomer", e), Promise.reject(t);
|
|
450
464
|
});
|
|
451
465
|
}, [
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
466
|
+
u,
|
|
467
|
+
r,
|
|
468
|
+
p,
|
|
469
|
+
s,
|
|
470
|
+
q,
|
|
471
|
+
l,
|
|
472
|
+
h
|
|
473
|
+
]), G = K(() => {
|
|
474
|
+
if (!u) {
|
|
475
|
+
const e = "Main API URL not configured. Cannot fetch pricing.";
|
|
476
|
+
return D({
|
|
477
|
+
data: null,
|
|
478
|
+
isLoading: !1,
|
|
479
|
+
error: new Error(e)
|
|
480
|
+
}), h(e, "fetchPricing"), Promise.reject(new Error(e));
|
|
481
|
+
}
|
|
482
|
+
if (!c) {
|
|
483
|
+
const e = "productId must be provided as a prop to KelviqProvider to fetch pricing.";
|
|
484
|
+
return D({
|
|
485
|
+
data: null,
|
|
486
|
+
isLoading: !1,
|
|
487
|
+
error: new Error(e)
|
|
488
|
+
}), h(e, "fetchPricing"), Promise.reject(new Error(e));
|
|
489
|
+
}
|
|
490
|
+
D((e) => ({
|
|
491
|
+
...e,
|
|
492
|
+
isLoading: !0,
|
|
493
|
+
error: null
|
|
494
|
+
}));
|
|
495
|
+
const d = `${u.replace(/\/$/, "")}/${Ae.replace(/^\//, "")}${c}/`;
|
|
496
|
+
return x({
|
|
497
|
+
url: d,
|
|
498
|
+
method: "GET",
|
|
499
|
+
timeout: p,
|
|
500
|
+
maxRetries: s,
|
|
501
|
+
backoffBaseDelay: q,
|
|
502
|
+
accessToken: l
|
|
503
|
+
}).then((e) => {
|
|
504
|
+
if (e && e.data && Array.isArray(e.data.plans))
|
|
505
|
+
D({
|
|
506
|
+
data: e.data,
|
|
507
|
+
isLoading: !1,
|
|
508
|
+
error: null
|
|
509
|
+
});
|
|
510
|
+
else {
|
|
511
|
+
const t = new Error(
|
|
512
|
+
"Received empty, malformed, or invalid data structure from pricing API."
|
|
513
|
+
);
|
|
514
|
+
throw D({
|
|
515
|
+
data: null,
|
|
516
|
+
isLoading: !1,
|
|
517
|
+
error: t
|
|
518
|
+
}), h(
|
|
519
|
+
t.message,
|
|
520
|
+
"fetchPricing",
|
|
521
|
+
e
|
|
522
|
+
), t;
|
|
523
|
+
}
|
|
524
|
+
}).catch((e) => {
|
|
525
|
+
const t = e instanceof Error ? e : new Error(String(e));
|
|
526
|
+
return D((g) => ({
|
|
527
|
+
...g,
|
|
528
|
+
isLoading: !1,
|
|
529
|
+
error: t
|
|
530
|
+
})), h(t.message, "fetchPricing", e), Promise.reject(t);
|
|
531
|
+
});
|
|
532
|
+
}, [
|
|
533
|
+
u,
|
|
534
|
+
c,
|
|
535
|
+
p,
|
|
536
|
+
s,
|
|
537
|
+
q,
|
|
455
538
|
l,
|
|
456
|
-
L,
|
|
457
|
-
g,
|
|
458
539
|
h
|
|
459
540
|
]);
|
|
460
|
-
|
|
461
|
-
let
|
|
462
|
-
if (!
|
|
463
|
-
if (
|
|
541
|
+
se(() => {
|
|
542
|
+
let d = !0;
|
|
543
|
+
if (!A) {
|
|
544
|
+
if (d) {
|
|
464
545
|
const e = new Error(
|
|
465
546
|
"KelviqProvider: `apiBaseUrl` must be provided in config."
|
|
466
547
|
);
|
|
467
|
-
|
|
468
|
-
...
|
|
548
|
+
j(e), $(!1), y((t) => ({
|
|
549
|
+
...t,
|
|
469
550
|
isLoading: !1,
|
|
470
551
|
error: e
|
|
471
|
-
})),
|
|
552
|
+
})), E.onError && E.onError(e);
|
|
472
553
|
}
|
|
473
554
|
return;
|
|
474
555
|
}
|
|
475
|
-
return
|
|
476
|
-
|
|
556
|
+
return U ? O().catch((e) => {
|
|
557
|
+
d && F && $(!1), console.error(
|
|
477
558
|
"Kelviq SDK: Initial entitlement fetch failed.",
|
|
478
559
|
e
|
|
479
560
|
);
|
|
480
|
-
}) :
|
|
561
|
+
}) : d && (y((e) => ({
|
|
481
562
|
...e,
|
|
482
563
|
isLoading: !1,
|
|
483
564
|
data: null,
|
|
484
565
|
error: null
|
|
485
|
-
})),
|
|
566
|
+
})), $(!1)), b && B().catch((e) => {
|
|
486
567
|
console.error(
|
|
487
568
|
"Kelviq SDK: Initial subscriptions fetch failed.",
|
|
488
569
|
e
|
|
489
570
|
);
|
|
490
|
-
}),
|
|
571
|
+
}), v && N().catch((e) => {
|
|
491
572
|
console.error(
|
|
492
573
|
"Kelviq SDK: Initial customer fetch failed.",
|
|
493
574
|
e
|
|
494
575
|
);
|
|
576
|
+
}), S && G().catch((e) => {
|
|
577
|
+
console.error(
|
|
578
|
+
"Kelviq SDK: Initial pricing fetch failed.",
|
|
579
|
+
e
|
|
580
|
+
);
|
|
495
581
|
}), () => {
|
|
496
|
-
|
|
582
|
+
d = !1;
|
|
497
583
|
};
|
|
498
|
-
}, [
|
|
499
|
-
const
|
|
500
|
-
() =>
|
|
501
|
-
[
|
|
502
|
-
),
|
|
503
|
-
() =>
|
|
504
|
-
customerId:
|
|
505
|
-
entitlements:
|
|
584
|
+
}, [A, U, b, v, S]);
|
|
585
|
+
const J = K(
|
|
586
|
+
() => m.data ? m.data : {},
|
|
587
|
+
[m.data]
|
|
588
|
+
), Q = K(
|
|
589
|
+
() => P ? {
|
|
590
|
+
customerId: P.customerId,
|
|
591
|
+
entitlements: P.entitlements
|
|
506
592
|
} : null,
|
|
507
|
-
[
|
|
508
|
-
),
|
|
509
|
-
(
|
|
510
|
-
customerId:
|
|
511
|
-
entitlements:
|
|
512
|
-
(e) => e.featureId ===
|
|
593
|
+
[P]
|
|
594
|
+
), V = K(
|
|
595
|
+
(d) => P ? {
|
|
596
|
+
customerId: P.customerId,
|
|
597
|
+
entitlements: P.entitlements.filter(
|
|
598
|
+
(e) => e.featureId === d
|
|
513
599
|
)
|
|
514
600
|
} : null,
|
|
515
|
-
[
|
|
516
|
-
),
|
|
517
|
-
(
|
|
518
|
-
[
|
|
519
|
-
),
|
|
520
|
-
(
|
|
521
|
-
|
|
522
|
-
if (!
|
|
523
|
-
const
|
|
524
|
-
if (!
|
|
525
|
-
const
|
|
526
|
-
return ("usageLimit" in e || "currentUsage" in e) && (
|
|
527
|
-
...
|
|
601
|
+
[P]
|
|
602
|
+
), Y = K(
|
|
603
|
+
(d) => m.data ? m.data[d] ?? null : null,
|
|
604
|
+
[m.data]
|
|
605
|
+
), Z = K(
|
|
606
|
+
(d, e) => {
|
|
607
|
+
y((t) => {
|
|
608
|
+
if (!t.data) return t;
|
|
609
|
+
const g = t.data[d];
|
|
610
|
+
if (!g) return t;
|
|
611
|
+
const R = { ...g, ...e };
|
|
612
|
+
return ("usageLimit" in e || "currentUsage" in e) && (R.remaining = R.usageLimit !== null ? R.usageLimit - R.currentUsage : null), {
|
|
613
|
+
...t,
|
|
528
614
|
data: {
|
|
529
|
-
...
|
|
530
|
-
[
|
|
615
|
+
...t.data,
|
|
616
|
+
[d]: R
|
|
531
617
|
}
|
|
532
618
|
};
|
|
533
619
|
});
|
|
534
620
|
},
|
|
535
621
|
[]
|
|
536
|
-
),
|
|
537
|
-
(
|
|
538
|
-
if (!
|
|
539
|
-
const e =
|
|
622
|
+
), ee = K(
|
|
623
|
+
(d) => {
|
|
624
|
+
if (!m.data) return !1;
|
|
625
|
+
const e = m.data[d];
|
|
540
626
|
return e ? e.hasAccess : !1;
|
|
541
627
|
},
|
|
542
|
-
[
|
|
543
|
-
),
|
|
628
|
+
[m.data]
|
|
629
|
+
), ie = ae(
|
|
544
630
|
() => ({
|
|
545
|
-
allEntitlements:
|
|
546
|
-
refreshAllEntitlements:
|
|
547
|
-
getEntitlements:
|
|
548
|
-
getEntitlement:
|
|
549
|
-
getRawEntitlements:
|
|
550
|
-
getRawEntitlement:
|
|
551
|
-
hasAccess:
|
|
552
|
-
updateEntitlement:
|
|
553
|
-
subscriptions:
|
|
554
|
-
refreshSubscriptions:
|
|
555
|
-
customer:
|
|
556
|
-
refreshCustomer:
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
631
|
+
allEntitlements: m,
|
|
632
|
+
refreshAllEntitlements: O,
|
|
633
|
+
getEntitlements: J,
|
|
634
|
+
getEntitlement: Y,
|
|
635
|
+
getRawEntitlements: Q,
|
|
636
|
+
getRawEntitlement: V,
|
|
637
|
+
hasAccess: ee,
|
|
638
|
+
updateEntitlement: Z,
|
|
639
|
+
subscriptions: k,
|
|
640
|
+
refreshSubscriptions: B,
|
|
641
|
+
customer: X,
|
|
642
|
+
refreshCustomer: N,
|
|
643
|
+
pricing: z,
|
|
644
|
+
refreshPricing: G,
|
|
645
|
+
isLoading: F,
|
|
646
|
+
error: W,
|
|
647
|
+
environment: f,
|
|
648
|
+
apiUrl: A,
|
|
649
|
+
entitlementsPath: a,
|
|
650
|
+
customerId: r
|
|
563
651
|
}),
|
|
564
652
|
[
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
G,
|
|
568
|
-
W,
|
|
569
|
-
H,
|
|
570
|
-
X,
|
|
653
|
+
m,
|
|
654
|
+
O,
|
|
571
655
|
J,
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
656
|
+
Y,
|
|
657
|
+
Q,
|
|
658
|
+
V,
|
|
659
|
+
ee,
|
|
660
|
+
Z,
|
|
661
|
+
k,
|
|
662
|
+
B,
|
|
663
|
+
X,
|
|
575
664
|
N,
|
|
665
|
+
z,
|
|
666
|
+
G,
|
|
576
667
|
F,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
668
|
+
W,
|
|
669
|
+
f,
|
|
670
|
+
A,
|
|
580
671
|
a,
|
|
581
|
-
|
|
582
|
-
t
|
|
672
|
+
r
|
|
583
673
|
]
|
|
584
674
|
);
|
|
585
|
-
return /* @__PURE__ */
|
|
586
|
-
},
|
|
587
|
-
const n =
|
|
588
|
-
if (n === void 0 || n ===
|
|
675
|
+
return /* @__PURE__ */ L(te.Provider, { value: ie, children: n });
|
|
676
|
+
}, C = () => {
|
|
677
|
+
const n = le(te);
|
|
678
|
+
if (n === void 0 || n === re)
|
|
589
679
|
throw new Error(
|
|
590
680
|
"useKelviq must be used within an initialized KelviqProvider."
|
|
591
681
|
);
|
|
592
682
|
return n;
|
|
593
|
-
},
|
|
683
|
+
}, H = ({
|
|
594
684
|
featureId: n,
|
|
595
|
-
children:
|
|
596
|
-
fallback:
|
|
597
|
-
loadingComponent:
|
|
598
|
-
condition:
|
|
685
|
+
children: i,
|
|
686
|
+
fallback: a = null,
|
|
687
|
+
loadingComponent: r,
|
|
688
|
+
condition: f
|
|
599
689
|
}) => {
|
|
600
690
|
const {
|
|
601
|
-
getEntitlement:
|
|
602
|
-
isLoading:
|
|
603
|
-
error:
|
|
604
|
-
} =
|
|
605
|
-
return
|
|
606
|
-
},
|
|
607
|
-
const
|
|
608
|
-
return /* @__PURE__ */
|
|
609
|
-
|
|
691
|
+
getEntitlement: l,
|
|
692
|
+
isLoading: c,
|
|
693
|
+
error: E
|
|
694
|
+
} = C(), o = l(n);
|
|
695
|
+
return c && !o ? /* @__PURE__ */ L(w, { children: r !== void 0 ? r : a }) : E && !o ? /* @__PURE__ */ L(w, { children: a }) : !o || !o.hasAccess || f && !f(o) ? /* @__PURE__ */ L(w, { children: a }) : typeof i == "function" ? /* @__PURE__ */ L(w, { children: i(o) }) : /* @__PURE__ */ L(w, { children: i });
|
|
696
|
+
}, Se = (n) => /* @__PURE__ */ L(H, { ...n }), be = (n) => {
|
|
697
|
+
const i = (a) => a.hasAccess && (a.remaining === null || a.remaining > 0);
|
|
698
|
+
return /* @__PURE__ */ L(
|
|
699
|
+
H,
|
|
610
700
|
{
|
|
611
701
|
...n,
|
|
612
|
-
condition: n.condition ||
|
|
702
|
+
condition: n.condition || i
|
|
613
703
|
}
|
|
614
704
|
);
|
|
615
|
-
},
|
|
616
|
-
const { allEntitlements: n } =
|
|
705
|
+
}, Ke = (n) => /* @__PURE__ */ L(H, { ...n }), Ue = () => {
|
|
706
|
+
const { allEntitlements: n } = C();
|
|
707
|
+
return n;
|
|
708
|
+
}, Re = (n) => {
|
|
709
|
+
const { getEntitlement: i } = C();
|
|
710
|
+
return i(n);
|
|
711
|
+
}, Ce = (n) => {
|
|
712
|
+
const { getEntitlement: i } = C();
|
|
713
|
+
return i(n);
|
|
714
|
+
}, $e = (n) => {
|
|
715
|
+
const { getEntitlement: i } = C();
|
|
716
|
+
return i(n);
|
|
717
|
+
}, Ie = () => {
|
|
718
|
+
const { subscriptions: n } = C();
|
|
617
719
|
return n;
|
|
618
|
-
},
|
|
619
|
-
const {
|
|
620
|
-
return s(n);
|
|
621
|
-
}, qe = (n) => {
|
|
622
|
-
const { getEntitlement: s } = K();
|
|
623
|
-
return s(n);
|
|
624
|
-
}, ye = (n) => {
|
|
625
|
-
const { getEntitlement: s } = K();
|
|
626
|
-
return s(n);
|
|
627
|
-
}, Se = () => {
|
|
628
|
-
const { subscriptions: n } = K();
|
|
720
|
+
}, Te = () => {
|
|
721
|
+
const { customer: n } = C();
|
|
629
722
|
return n;
|
|
630
|
-
},
|
|
631
|
-
const {
|
|
723
|
+
}, ne = () => {
|
|
724
|
+
const { pricing: n } = C();
|
|
632
725
|
return n;
|
|
726
|
+
}, ye = (n, i, a = {}) => {
|
|
727
|
+
if (typeof n != "number")
|
|
728
|
+
return "";
|
|
729
|
+
const {
|
|
730
|
+
compact: r = !1,
|
|
731
|
+
locale: f = a.pricingLocale || "en-US",
|
|
732
|
+
includeCurrencySymbol: l = !0
|
|
733
|
+
} = a;
|
|
734
|
+
try {
|
|
735
|
+
const c = {
|
|
736
|
+
notation: r ? "compact" : "standard",
|
|
737
|
+
compactDisplay: "short"
|
|
738
|
+
}, o = new Intl.NumberFormat(f, c).format(n);
|
|
739
|
+
return l ? `${i}${o}` : o;
|
|
740
|
+
} catch {
|
|
741
|
+
const c = n.toString();
|
|
742
|
+
return l ? `${i}${c}` : c;
|
|
743
|
+
}
|
|
744
|
+
}, Me = ({
|
|
745
|
+
planIdentifier: n,
|
|
746
|
+
billingPeriod: i,
|
|
747
|
+
children: a,
|
|
748
|
+
formatOptions: r,
|
|
749
|
+
loadingComponent: f = null,
|
|
750
|
+
fallback: l = null
|
|
751
|
+
}) => {
|
|
752
|
+
const { data: c, isLoading: E } = ne();
|
|
753
|
+
if (E)
|
|
754
|
+
return /* @__PURE__ */ L(w, { children: f });
|
|
755
|
+
if (!c || !Array.isArray(c.plans))
|
|
756
|
+
return /* @__PURE__ */ L(w, { children: l });
|
|
757
|
+
const o = c.plans.find(
|
|
758
|
+
(b) => b.identifier === n && b.enabled
|
|
759
|
+
);
|
|
760
|
+
if (!o)
|
|
761
|
+
return /* @__PURE__ */ L(w, { children: l });
|
|
762
|
+
const s = o.price.charges.find(
|
|
763
|
+
(b) => b.chargePeriod === i
|
|
764
|
+
) ?? null, p = s ? s.priceData.amount : 0, q = o.price.priceType === "FREE", U = q ? "Free" : ye(p, c.currencySymbol, {
|
|
765
|
+
...r,
|
|
766
|
+
pricingLocale: c.pricingLocale
|
|
767
|
+
});
|
|
768
|
+
return /* @__PURE__ */ L(w, { children: a({
|
|
769
|
+
plan: o,
|
|
770
|
+
charge: s,
|
|
771
|
+
amount: p,
|
|
772
|
+
formattedPrice: U,
|
|
773
|
+
currencySymbol: c.currencySymbol,
|
|
774
|
+
currencyCode: c.currencyCode,
|
|
775
|
+
pricingLocale: c.pricingLocale,
|
|
776
|
+
isFree: q,
|
|
777
|
+
hasFreeTrial: o.price.freeTrial,
|
|
778
|
+
trialPeriod: o.price.trialPeriod
|
|
779
|
+
}) });
|
|
780
|
+
}, De = ({
|
|
781
|
+
planIdentifier: n,
|
|
782
|
+
children: i,
|
|
783
|
+
loadingComponent: a = null,
|
|
784
|
+
fallback: r = null,
|
|
785
|
+
featureType: f
|
|
786
|
+
}) => {
|
|
787
|
+
const { data: l, isLoading: c } = ne();
|
|
788
|
+
if (c)
|
|
789
|
+
return /* @__PURE__ */ L(w, { children: a });
|
|
790
|
+
if (!l || !Array.isArray(l.plans))
|
|
791
|
+
return /* @__PURE__ */ L(w, { children: r });
|
|
792
|
+
const E = l.plans.find(
|
|
793
|
+
(s) => s.identifier === n && s.enabled
|
|
794
|
+
);
|
|
795
|
+
if (!E)
|
|
796
|
+
return /* @__PURE__ */ L(w, { children: r });
|
|
797
|
+
let o = E.features.filter((s) => s.enabled);
|
|
798
|
+
return f && (o = o.filter((s) => s.featureType === f)), o.length === 0 ? /* @__PURE__ */ L(w, { children: r }) : /* @__PURE__ */ L(w, { children: o.map(
|
|
799
|
+
(s, p) => i({ feature: s, plan: E, index: p })
|
|
800
|
+
) });
|
|
633
801
|
};
|
|
634
802
|
export {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
803
|
+
De as KQFeatureList,
|
|
804
|
+
Me as KQPrice,
|
|
805
|
+
te as KelviqContext,
|
|
806
|
+
qe as KelviqProvider,
|
|
807
|
+
Ke as ShowWhenBooleanEntitled,
|
|
808
|
+
Se as ShowWhenCustomizableEntitled,
|
|
809
|
+
be as ShowWhenMeteredEntitled,
|
|
810
|
+
re as defaultKelviqContextValue,
|
|
811
|
+
ye as kqFormatPrice,
|
|
812
|
+
Ue as useAllEntitlements,
|
|
813
|
+
Re as useBooleanEntitlement,
|
|
814
|
+
Te as useCustomer,
|
|
815
|
+
Ce as useCustomizableEntitlement,
|
|
816
|
+
C as useKelviq,
|
|
817
|
+
$e as useMeteredEntitlement,
|
|
818
|
+
ne as usePricing,
|
|
819
|
+
Ie as useSubscriptions
|
|
648
820
|
};
|