@iblai/web-containers 1.72.0 → 1.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/cjs/_virtual/index2.js +2 -2
  2. package/dist/cjs/_virtual/index3.js +2 -2
  3. package/dist/cjs/components/credit-balance.js +41 -69
  4. package/dist/cjs/components/credit-balance.js.map +1 -1
  5. package/dist/cjs/components/modals/contact-admin-modal.js +34 -0
  6. package/dist/cjs/components/modals/contact-admin-modal.js.map +1 -0
  7. package/dist/cjs/components/modals/upgrade-package-modal.js +279 -18
  8. package/dist/cjs/components/modals/upgrade-package-modal.js.map +1 -1
  9. package/dist/cjs/components/profile/add-credits-modal.js +167 -21
  10. package/dist/cjs/components/profile/add-credits-modal.js.map +1 -1
  11. package/dist/cjs/components/profile/auto-recharge-modal.js +1 -1
  12. package/dist/cjs/components/profile/auto-recharge-modal.js.map +1 -1
  13. package/dist/cjs/components/profile/billing-credits.js +4 -4
  14. package/dist/cjs/components/profile/billing-credits.js.map +1 -1
  15. package/dist/cjs/components/profile/billing.js +58 -99
  16. package/dist/cjs/components/profile/billing.js.map +1 -1
  17. package/dist/cjs/components/profile/pending-credit-top-up.js +216 -0
  18. package/dist/cjs/components/profile/pending-credit-top-up.js.map +1 -0
  19. package/dist/cjs/components/profile/use-complete-pending-credit-top-up.js +70 -0
  20. package/dist/cjs/components/profile/use-complete-pending-credit-top-up.js.map +1 -0
  21. package/dist/cjs/components/subscription-top-banner.js +121 -0
  22. package/dist/cjs/components/subscription-top-banner.js.map +1 -0
  23. package/dist/cjs/i18n/messages/en.json.js +122 -20
  24. package/dist/cjs/i18n/messages/en.json.js.map +1 -1
  25. package/dist/cjs/i18n/messages/es.json.js +124 -22
  26. package/dist/cjs/i18n/messages/es.json.js.map +1 -1
  27. package/dist/cjs/i18n/messages/fr.json.js +122 -20
  28. package/dist/cjs/i18n/messages/fr.json.js.map +1 -1
  29. package/dist/cjs/i18n/messages/zh.json.js +123 -21
  30. package/dist/cjs/i18n/messages/zh.json.js.map +1 -1
  31. package/dist/cjs/index.js +4 -0
  32. package/dist/cjs/index.js.map +1 -1
  33. package/dist/cjs/node_modules/.pnpm/css-mediaquery@0.1.2/node_modules/css-mediaquery/index.js +1 -1
  34. package/dist/cjs/node_modules/.pnpm/matchmediaquery@0.4.2/node_modules/matchmediaquery/index.js +1 -1
  35. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -1
  36. package/dist/cjs/web-containers/tsconfig.build.tsbuildinfo +1 -1
  37. package/dist/esm/_virtual/index2.js +2 -2
  38. package/dist/esm/_virtual/index3.js +2 -2
  39. package/dist/esm/components/credit-balance.js +44 -72
  40. package/dist/esm/components/credit-balance.js.map +1 -1
  41. package/dist/esm/components/modals/contact-admin-modal.js +32 -0
  42. package/dist/esm/components/modals/contact-admin-modal.js.map +1 -0
  43. package/dist/esm/components/modals/upgrade-package-modal.js +281 -20
  44. package/dist/esm/components/modals/upgrade-package-modal.js.map +1 -1
  45. package/dist/esm/components/profile/add-credits-modal.js +170 -24
  46. package/dist/esm/components/profile/add-credits-modal.js.map +1 -1
  47. package/dist/esm/components/profile/auto-recharge-modal.js +1 -1
  48. package/dist/esm/components/profile/auto-recharge-modal.js.map +1 -1
  49. package/dist/esm/components/profile/billing-credits.js +4 -4
  50. package/dist/esm/components/profile/billing-credits.js.map +1 -1
  51. package/dist/esm/components/profile/billing.js +60 -101
  52. package/dist/esm/components/profile/billing.js.map +1 -1
  53. package/dist/esm/components/profile/pending-credit-top-up.js +202 -0
  54. package/dist/esm/components/profile/pending-credit-top-up.js.map +1 -0
  55. package/dist/esm/components/profile/use-complete-pending-credit-top-up.js +68 -0
  56. package/dist/esm/components/profile/use-complete-pending-credit-top-up.js.map +1 -0
  57. package/dist/esm/components/subscription-top-banner.js +119 -0
  58. package/dist/esm/components/subscription-top-banner.js.map +1 -0
  59. package/dist/esm/i18n/messages/en.json.js +121 -21
  60. package/dist/esm/i18n/messages/en.json.js.map +1 -1
  61. package/dist/esm/i18n/messages/es.json.js +123 -23
  62. package/dist/esm/i18n/messages/es.json.js.map +1 -1
  63. package/dist/esm/i18n/messages/fr.json.js +121 -21
  64. package/dist/esm/i18n/messages/fr.json.js.map +1 -1
  65. package/dist/esm/i18n/messages/zh.json.js +122 -22
  66. package/dist/esm/i18n/messages/zh.json.js.map +1 -1
  67. package/dist/esm/index.js +2 -0
  68. package/dist/esm/index.js.map +1 -1
  69. package/dist/esm/node_modules/.pnpm/css-mediaquery@0.1.2/node_modules/css-mediaquery/index.js +1 -1
  70. package/dist/esm/node_modules/.pnpm/matchmediaquery@0.4.2/node_modules/matchmediaquery/index.js +1 -1
  71. package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -1
  72. package/dist/esm/web-containers/tsconfig.build.tsbuildinfo +1 -1
  73. package/dist/index.d.ts +95 -5
  74. package/dist/package.json +1 -1
  75. package/package.json +3 -3
@@ -0,0 +1,202 @@
1
+ /**
2
+ * A credit top-up that has to wait for a payment method.
3
+ *
4
+ * Someone without a card on file still just presses "Add Credits" and types an
5
+ * amount. We then send them to the Stripe customer portal to save a card, and
6
+ * when Stripe brings them back we charge that amount and add the credits —
7
+ * one trip instead of "add a card, come back, open Add Credits again".
8
+ *
9
+ * The amount travels on the portal's after-completion URL so the return page
10
+ * knows what was asked for, but the URL alone never charges anything: the
11
+ * amount is also written to localStorage under a one-time nonce before the
12
+ * redirect, and the charge only runs when the URL's nonce, amount and tenant
13
+ * all match that record and it is still fresh. The record is deleted the
14
+ * moment it is claimed, so a reload (or a second mounted surface) can't charge
15
+ * twice, and a crafted link can't charge an amount the person never entered.
16
+ *
17
+ * localStorage (not sessionStorage) because the Stripe portal is a full
18
+ * navigation and some hosts open it in a new tab.
19
+ */
20
+ const PENDING_CREDIT_TOP_UP_STORAGE_KEY = 'ibl_pending_credit_top_up';
21
+ /** Query params appended to the portal's after-completion URL. */
22
+ const CREDIT_TOP_UP_QUERY_PARAMS = {
23
+ nonce: 'credit_topup',
24
+ amount: 'credit_topup_amount',
25
+ };
26
+ /** A top-up that is not claimed within the hour is forgotten. */
27
+ const PENDING_CREDIT_TOP_UP_TTL_MS = 60 * 60 * 1000;
28
+ function getStorage() {
29
+ try {
30
+ if (typeof window === 'undefined' || !window.localStorage)
31
+ return null;
32
+ return window.localStorage;
33
+ }
34
+ catch (_a) {
35
+ return null;
36
+ }
37
+ }
38
+ function createNonce() {
39
+ const cryptoApi = typeof globalThis !== 'undefined' ? globalThis.crypto : undefined;
40
+ if (cryptoApi && typeof cryptoApi.randomUUID === 'function') {
41
+ return cryptoApi.randomUUID();
42
+ }
43
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
44
+ }
45
+ /** Normalises any accepted amount input to the "25.00" form stored and sent. */
46
+ function normaliseTopUpAmountUsd(amount) {
47
+ const num = typeof amount === 'string' ? parseFloat(amount) : amount;
48
+ if (!Number.isFinite(num) || num <= 0)
49
+ return null;
50
+ return num.toFixed(2);
51
+ }
52
+ /** The pending record, if one is stored, well-formed and not expired. */
53
+ function readPendingCreditTopUp(now = Date.now()) {
54
+ const storage = getStorage();
55
+ if (!storage)
56
+ return null;
57
+ const raw = storage.getItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
58
+ if (!raw)
59
+ return null;
60
+ try {
61
+ const parsed = JSON.parse(raw);
62
+ if (!parsed ||
63
+ typeof parsed.nonce !== 'string' ||
64
+ typeof parsed.amountUsd !== 'string' ||
65
+ typeof parsed.tenant !== 'string' ||
66
+ typeof parsed.createdAt !== 'number') {
67
+ storage.removeItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
68
+ return null;
69
+ }
70
+ if (now - parsed.createdAt > PENDING_CREDIT_TOP_UP_TTL_MS) {
71
+ storage.removeItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
72
+ return null;
73
+ }
74
+ return parsed;
75
+ }
76
+ catch (_a) {
77
+ storage.removeItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
78
+ return null;
79
+ }
80
+ }
81
+ function clearPendingCreditTopUp() {
82
+ var _a;
83
+ (_a = getStorage()) === null || _a === void 0 ? void 0 : _a.removeItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
84
+ }
85
+ /**
86
+ * Records the top-up to finish after the payment method is saved and returns
87
+ * the URL Stripe should send the person back to: `currentUrl` plus the amount
88
+ * and the one-time nonce. Any existing query (e.g. `profileTab=billing`) is
89
+ * kept so the person lands where they left.
90
+ */
91
+ function beginPendingCreditTopUp({ tenant, amountUsd, currentUrl, now = Date.now(), }) {
92
+ var _a;
93
+ const pending = {
94
+ nonce: createNonce(),
95
+ amountUsd,
96
+ tenant,
97
+ createdAt: now,
98
+ };
99
+ (_a = getStorage()) === null || _a === void 0 ? void 0 : _a.setItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY, JSON.stringify(pending));
100
+ const url = new URL(currentUrl);
101
+ url.searchParams.set(CREDIT_TOP_UP_QUERY_PARAMS.nonce, pending.nonce);
102
+ url.searchParams.set(CREDIT_TOP_UP_QUERY_PARAMS.amount, pending.amountUsd);
103
+ return { pending, afterCompletionUrl: url.toString() };
104
+ }
105
+ /** True when the URL carries the top-up return params at all. */
106
+ function hasPendingCreditTopUpParams(url) {
107
+ try {
108
+ return new URL(url).searchParams.has(CREDIT_TOP_UP_QUERY_PARAMS.nonce);
109
+ }
110
+ catch (_a) {
111
+ return false;
112
+ }
113
+ }
114
+ /** The same URL without the top-up return params (for `history.replaceState`). */
115
+ function stripPendingCreditTopUpParams(url) {
116
+ try {
117
+ const parsed = new URL(url);
118
+ parsed.searchParams.delete(CREDIT_TOP_UP_QUERY_PARAMS.nonce);
119
+ parsed.searchParams.delete(CREDIT_TOP_UP_QUERY_PARAMS.amount);
120
+ return parsed.toString();
121
+ }
122
+ catch (_a) {
123
+ return url;
124
+ }
125
+ }
126
+ /**
127
+ * Claims the top-up the URL refers to: returns it, and deletes the stored
128
+ * record, only when the URL's nonce and amount match the record for this
129
+ * tenant. Returns null (and leaves nothing to claim) otherwise.
130
+ */
131
+ function claimPendingCreditTopUp({ url, tenant, now = Date.now(), }) {
132
+ let params;
133
+ try {
134
+ params = new URL(url).searchParams;
135
+ }
136
+ catch (_a) {
137
+ return null;
138
+ }
139
+ const nonce = params.get(CREDIT_TOP_UP_QUERY_PARAMS.nonce);
140
+ const amount = params.get(CREDIT_TOP_UP_QUERY_PARAMS.amount);
141
+ if (!nonce || !amount)
142
+ return null;
143
+ const pending = readPendingCreditTopUp(now);
144
+ if (!pending)
145
+ return null;
146
+ if (pending.nonce !== nonce || pending.tenant !== tenant)
147
+ return null;
148
+ if (normaliseTopUpAmountUsd(amount) !== pending.amountUsd)
149
+ return null;
150
+ clearPendingCreditTopUp();
151
+ return pending;
152
+ }
153
+ /**
154
+ * The backend's plain-sentence refusal from a rejected top-up call, whatever
155
+ * shape the data layer threw it in (`{ data: { detail } }`, `{ data: 'text' }`
156
+ * or a bare `{ detail }`). Undefined when there is none.
157
+ */
158
+ function readTopUpErrorDetail(error) {
159
+ if (!error || typeof error !== 'object')
160
+ return undefined;
161
+ const err = error;
162
+ if (typeof err.data === 'string' && err.data.trim())
163
+ return err.data;
164
+ if (err.data && typeof err.data === 'object') {
165
+ const detail = err.data.detail;
166
+ if (typeof detail === 'string' && detail.trim())
167
+ return detail;
168
+ }
169
+ if (typeof err.detail === 'string' && err.detail.trim())
170
+ return err.detail;
171
+ return undefined;
172
+ }
173
+ function readStringField(body, key) {
174
+ if (!body || typeof body !== 'object')
175
+ return undefined;
176
+ const value = body[key];
177
+ return typeof value === 'string' && value.trim() ? value : undefined;
178
+ }
179
+ function readTopUpError(error) {
180
+ if (!error || typeof error !== 'object')
181
+ return {};
182
+ const err = error;
183
+ const body = err.data && typeof err.data === 'object' ? err.data : error;
184
+ return {
185
+ detail: readTopUpErrorDetail(error),
186
+ code: readStringField(body, 'code'),
187
+ errorType: readStringField(body, 'error_type'),
188
+ };
189
+ }
190
+ /** Refusals that saving a (new) card on Stripe fixes. */
191
+ const PAYMENT_METHOD_ERROR_TYPES = new Set(['card_error', 'payment_method_error']);
192
+ /**
193
+ * True when the backend refused the top-up because of the payment method:
194
+ * the card on file was refused (expired, declined, …) or there is none.
195
+ */
196
+ function isPaymentMethodProblem(error) {
197
+ const { errorType } = readTopUpError(error);
198
+ return errorType !== undefined && PAYMENT_METHOD_ERROR_TYPES.has(errorType);
199
+ }
200
+
201
+ export { CREDIT_TOP_UP_QUERY_PARAMS, PENDING_CREDIT_TOP_UP_STORAGE_KEY, PENDING_CREDIT_TOP_UP_TTL_MS, beginPendingCreditTopUp, claimPendingCreditTopUp, clearPendingCreditTopUp, hasPendingCreditTopUpParams, isPaymentMethodProblem, normaliseTopUpAmountUsd, readPendingCreditTopUp, readTopUpError, readTopUpErrorDetail, stripPendingCreditTopUpParams };
202
+ //# sourceMappingURL=pending-credit-top-up.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-credit-top-up.js","sources":["../../../../../../../src/components/profile/pending-credit-top-up.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;AAkBG;AAEI,MAAM,iCAAiC,GAAG;AAEjD;AACO,MAAM,0BAA0B,GAAG;AACxC,IAAA,KAAK,EAAE,cAAc;AACrB,IAAA,MAAM,EAAE,qBAAqB;;AAG/B;MACa,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG;AAUtD,SAAS,UAAU,GAAA;AACjB,IAAA,IAAI;QACF,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,YAAY;AAAE,YAAA,OAAO,IAAI;QACtE,OAAO,MAAM,CAAC,YAAY;IAC5B;AAAE,IAAA,OAAA,EAAA,EAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;AAEA,SAAS,WAAW,GAAA;AAClB,IAAA,MAAM,SAAS,GAAG,OAAO,UAAU,KAAK,WAAW,GAAG,UAAU,CAAC,MAAM,G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AAQ,IAAI,KAAK,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,SAAS;AACtE;AAEM,SAAU,cAAc,CAAC,KAAc,EAAA;AAC3C,IAAA,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,EAAE;IAClD,MAAM,GAAG,GAAG,KAA2B;IACvC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,GAAG,GAAG,CAAC,IAAI,GAAG,KAAK;IACxE,OAAO;AACL,QAAA,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC;AACnC,QAAA,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC;AACnC,QAAA,SAAS,EAAE,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC;KAC/C;AACH;AAEA;AACA,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAC;AAElF;;;AAGG;AACG,SAAU,sBAAsB,CAAC,KAAc,EAAA;IACnD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC;IAC3C,OAAO,SAAS,KAAK,SAAS,IAAI,0BAA0B,CAAC,GAAG,CAAC,SAAS,CAAC;AAC7E;;;;"}
@@ -0,0 +1,68 @@
1
+ import { useState, useRef, useEffect } from 'react';
2
+ import { useTriggerAutoRechargeMutation } from '@iblai/data-layer';
3
+ import { toast } from 'sonner';
4
+ import { useT } from '../../i18n/context.js';
5
+ import '../../packages/i18n/dist/index.esm.js';
6
+ import { hasPendingCreditTopUpParams, claimPendingCreditTopUp, stripPendingCreditTopUpParams, readTopUpErrorDetail } from './pending-credit-top-up.js';
7
+
8
+ function formatUsd(amount) {
9
+ const num = parseFloat(amount);
10
+ return Number.isFinite(num) ? `$${num.toFixed(2)}` : `$${amount}`;
11
+ }
12
+ /**
13
+ * Finishes a credit top-up that was waiting for a payment method (see
14
+ * `pending-credit-top-up.ts`). Mount it on every surface that offers
15
+ * "Add Credits" — the Billing tab and the navbar credit dropdown — so whichever
16
+ * one is on the page Stripe returns to charges the saved card for the amount
17
+ * the person entered, adds the credits, and says so in a toast. The billing
18
+ * query is invalidated by the mutation, so the balance on screen updates too.
19
+ *
20
+ * Claiming deletes the stored record first, so with both surfaces mounted only
21
+ * the first effect to run charges; the other finds nothing. The return params
22
+ * are removed from the address bar either way so a reload can't replay them.
23
+ */
24
+ function useCompletePendingCreditTopUp({ tenant, enabled = true, }) {
25
+ const t = useT();
26
+ const [triggerAutoRecharge] = useTriggerAutoRechargeMutation();
27
+ const [isCompleting, setIsCompleting] = useState(false);
28
+ const startedRef = useRef(false);
29
+ useEffect(() => {
30
+ if (!enabled || !tenant || startedRef.current)
31
+ return;
32
+ if (typeof window === 'undefined')
33
+ return;
34
+ const currentUrl = window.location.href;
35
+ if (!hasPendingCreditTopUpParams(currentUrl))
36
+ return;
37
+ startedRef.current = true;
38
+ const pending = claimPendingCreditTopUp({ url: currentUrl, tenant });
39
+ // A null state lets Next's patched replaceState sync the app router (and
40
+ // useSearchParams) with the new URL. Handing window.history.state back
41
+ // carries Next's internal marker, which makes it skip that sync, and a
42
+ // later router.replace built from the stale params would put the nonce
43
+ // and amount back in the address bar.
44
+ window.history.replaceState(null, '', stripPendingCreditTopUpParams(currentUrl));
45
+ if (!pending)
46
+ return;
47
+ setIsCompleting(true);
48
+ const toastId = toast.loading(t('profileAddCreditsModal.addingCredits'));
49
+ triggerAutoRecharge({ amount_usd: pending.amountUsd, platform_key: tenant })
50
+ .unwrap()
51
+ .then(() => {
52
+ toast.success(t('profileAddCreditsModal.creditsAddedAfterPayment', {
53
+ amount: formatUsd(pending.amountUsd),
54
+ }), { id: toastId });
55
+ })
56
+ .catch((error) => {
57
+ var _a;
58
+ toast.error((_a = readTopUpErrorDetail(error)) !== null && _a !== void 0 ? _a : t('profileAddCreditsModal.failedToAddCreditsAfterPayment'), { id: toastId });
59
+ })
60
+ .finally(() => setIsCompleting(false));
61
+ // The claim is one-shot by design (startedRef): re-runs from a changed
62
+ // dependency find nothing left to do.
63
+ }, [enabled, tenant, t, triggerAutoRecharge]);
64
+ return { isCompleting };
65
+ }
66
+
67
+ export { useCompletePendingCreditTopUp };
68
+ //# sourceMappingURL=use-complete-pending-credit-top-up.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-complete-pending-credit-top-up.js","sources":["../../../../../../../src/components/profile/use-complete-pending-credit-top-up.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAaA,SAAS,SAAS,CAAC,MAAc,EAAA;AAC/B,IAAA,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC;IAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAA,CAAA,EAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,CAAE,GAAG,CAAA,CAAA,EAAI,MAAM,CAAA,CAAE;AACnE;AAEA;;;;;;;;;;;AAWG;AACG,SAAU,6BAA6B,CAAC,EAC5C,MAAM,EACN,OAAO,GAAG,IAAI,GAIf,EAAA;AACC,IAAA,MAAM,CAAC,GAAG,IAAI,EAAE;AAChB,IAAA,MAAM,CAAC,mBAAmB,CAAC,GAAG,8BAA8B,EAAE;IAC9D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACvD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IAEhC,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,OAAO;YAAE;QAC/C,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE;AACnC,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI;AACvC,QAAA,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC;YAAE;AAE9C,QAAA,UAAU,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,MAAM,OAAO,GAAG,uBAAuB,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;;;;;;AAMpE,QAAA,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,6BAA6B,CAAC,UAAU,CAAC,CAAC;AAChF,QAAA,IAAI,CAAC,OAAO;YAAE;QAEd,eAAe,CAAC,IAAI,CAAC;QACrB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC;AACxE,QAAA,mBAAmB,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE;AACxE,aAAA,MAAM;aACN,IAAI,CAAC,MAAK;AACT,YAAA,KAAK,CAAC,OAAO,CACX,CAAC,CAAC,iDAAiD,EAAE;AACnD,gBAAA,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;AACrC,aAAA,CAAC,EACF,EAAE,EAAE,EAAE,OAAO,EAAE,CAChB;AACH,QAAA,CAAC;AACA,aAAA,KAAK,CAAC,CAAC,KAAc,KAAI;;YACxB,KAAK,CAAC,KAAK,CACT,CAAA,EAAA,GAAA,oBAAoB,CAAC,KAAK,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,CAAC,CAAC,uDAAuD,CAAC,EACzF,EAAE,EAAE,EAAE,OAAO,EAAE,CAChB;AACH,QAAA,CAAC;aACA,OAAO,CAAC,MAAM,eAAe,CAAC,KAAK,CAAC,CAAC;;;IAG1C,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;IAE7C,OAAO,EAAE,YAAY,EAAE;AACzB;;;;"}
@@ -0,0 +1,119 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useState, useEffect } from 'react';
3
+ import { useSelector } from 'react-redux';
4
+ import { useIsStripeActivated, useTopBannerButtonHandler, isLoggedIn, SUBSCRIPTION_BANNER_PARENT_SELECTOR } from '@iblai/web-utils';
5
+ import { useT } from '../i18n/context.js';
6
+ import '../packages/i18n/dist/index.esm.js';
7
+ import { TopBanner } from './top-banner/index.js';
8
+
9
+ const byId = (selector) => document.querySelector(selector);
10
+ /**
11
+ * The credits banner across the top of the app ("You've run out of credits…"),
12
+ * driven by the `topBanner` slice the subscription flow writes to. A non-admin
13
+ * whose organization ran out gets `ContactAdminModal` instead. Its button does what
14
+ * `useTopBannerButtonHandler` maps the banner's trigger to. Shows only for a
15
+ * signed-in person on a tenant with billing on.
16
+ *
17
+ * While shown it shortens the sidebar shell (`[data-slot="sidebar-*"]`) and
18
+ * the main content container by its own height so nothing scrolls under it,
19
+ * and puts everything back when closed.
20
+ */
21
+ function SubscriptionTopBanner({ hidden = false, parentContainerSelector = SUBSCRIPTION_BANNER_PARENT_SELECTOR, }) {
22
+ const t = useT();
23
+ const stripeActivated = useIsStripeActivated();
24
+ const topBannerOptions = useSelector((state) => { var _a; return (_a = state.topBanner) === null || _a === void 0 ? void 0 : _a.topBannerOptions; });
25
+ const getTopBannerButtonHandler = useTopBannerButtonHandler();
26
+ const [initialStyles, setInitialStyles] = useState({});
27
+ useEffect(() => {
28
+ const sideBarWrapper = byId('[data-slot="sidebar-wrapper"]');
29
+ const mainContentContainer = byId('#main-content-container > div');
30
+ const sidebarContainer = byId('[data-slot="sidebar-container"]');
31
+ const sidebarInset = byId('[data-slot="sidebar-inset"]');
32
+ const body = byId('body');
33
+ setInitialStyles({
34
+ sideBarWrapper: sideBarWrapper
35
+ ? {
36
+ maxHeight: sideBarWrapper.style.maxHeight,
37
+ top: sideBarWrapper.style.top,
38
+ position: sideBarWrapper.style.position,
39
+ }
40
+ : undefined,
41
+ mainContentContainer: mainContentContainer
42
+ ? {
43
+ position: mainContentContainer.style.position,
44
+ top: mainContentContainer.style.top,
45
+ }
46
+ : undefined,
47
+ sidebarContainer: sidebarContainer
48
+ ? { top: sidebarContainer.style.top, height: sidebarContainer.style.height }
49
+ : undefined,
50
+ sidebarInset: sidebarInset
51
+ ? { top: sidebarInset.style.top, height: sidebarInset.style.height }
52
+ : undefined,
53
+ body: body ? { overflow: body.style.overflow } : undefined,
54
+ });
55
+ }, []);
56
+ const handleTopBannerLoad = (bannerRef) => {
57
+ if (!bannerRef)
58
+ return;
59
+ const bannerHeight = bannerRef.clientHeight;
60
+ const sideBarWrapper = byId('[data-slot="sidebar-wrapper"]');
61
+ if (sideBarWrapper) {
62
+ sideBarWrapper.style.maxHeight = `calc(100vh - ${bannerHeight}px)`;
63
+ sideBarWrapper.style.top = '3px';
64
+ sideBarWrapper.style.position = 'relative';
65
+ }
66
+ const mainContentContainer = byId('#main-content-container > div');
67
+ if (mainContentContainer) {
68
+ mainContentContainer.style.position = 'relative';
69
+ mainContentContainer.style.top = '-12px';
70
+ }
71
+ const sidebarContainer = byId('[data-slot="sidebar-container"]');
72
+ if (sidebarContainer) {
73
+ sidebarContainer.style.top = '48px';
74
+ sidebarContainer.style.height = `calc(100% - ${bannerHeight}px)`;
75
+ }
76
+ const sidebarInset = byId('[data-slot="sidebar-inset"]');
77
+ if (sidebarInset) {
78
+ sidebarInset.style.height = `calc(100dvh - ${bannerHeight}px)`;
79
+ }
80
+ const body = byId('body');
81
+ if (body) {
82
+ body.style.overflow = 'hidden';
83
+ }
84
+ };
85
+ const handleTopBannerClose = () => {
86
+ var _a;
87
+ const sideBarWrapper = byId('[data-slot="sidebar-wrapper"]');
88
+ if (sideBarWrapper && initialStyles.sideBarWrapper) {
89
+ sideBarWrapper.style.maxHeight = initialStyles.sideBarWrapper.maxHeight;
90
+ sideBarWrapper.style.top = initialStyles.sideBarWrapper.top;
91
+ sideBarWrapper.style.position = initialStyles.sideBarWrapper.position;
92
+ }
93
+ const mainContentContainer = byId('#main-content-container > div');
94
+ if (mainContentContainer && initialStyles.mainContentContainer) {
95
+ mainContentContainer.style.position = initialStyles.mainContentContainer.position;
96
+ mainContentContainer.style.top = initialStyles.mainContentContainer.top;
97
+ }
98
+ const sidebarContainer = byId('[data-slot="sidebar-container"]');
99
+ if (sidebarContainer && initialStyles.sidebarContainer) {
100
+ sidebarContainer.style.top = initialStyles.sidebarContainer.top;
101
+ sidebarContainer.style.height = initialStyles.sidebarContainer.height;
102
+ }
103
+ const sidebarInset = byId('[data-slot="sidebar-inset"]');
104
+ if (sidebarInset && initialStyles.sidebarInset) {
105
+ sidebarInset.style.height = initialStyles.sidebarInset.height;
106
+ }
107
+ const body = byId('body');
108
+ if (body) {
109
+ body.style.overflow = ((_a = initialStyles.body) === null || _a === void 0 ? void 0 : _a.overflow) || 'auto';
110
+ }
111
+ };
112
+ if (hidden || !(topBannerOptions === null || topBannerOptions === void 0 ? void 0 : topBannerOptions.enabled) || !stripeActivated || !isLoggedIn()) {
113
+ return null;
114
+ }
115
+ return (jsx(TopBanner, { parentContainerSelector: parentContainerSelector, bannerText: topBannerOptions.bannerText, buttonHandler: getTopBannerButtonHandler(topBannerOptions.onUpgrade), buttonLabel: topBannerOptions.buttonLabel || t('creditBalance.upgrade'), loading: topBannerOptions.loading, tooltipText: topBannerOptions.tooltipText, onLoad: handleTopBannerLoad, onClose: handleTopBannerClose }));
116
+ }
117
+
118
+ export { SubscriptionTopBanner };
119
+ //# sourceMappingURL=subscription-top-banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription-top-banner.js","sources":["../../../../../../src/components/subscription-top-banner.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;;AA6BA,MAAM,IAAI,GAAG,CAAC,QAAgB,KAAK,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAuB;AAEzF;;;;;;;;;;AAUG;AACG,SAAU,qBAAqB,CAAC,EACpC,MAAM,GAAG,KAAK,EACd,uBAAuB,GAAG,mCAAmC,GAClC,EAAA;AAC3B,IAAA,MAAM,CAAC,GAAG,IAAI,EAAE;AAChB,IAAA,MAAM,eAAe,GAAG,oBAAo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