@solvapay/react 1.0.9-preview.1 → 1.0.9

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.
@@ -0,0 +1,721 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React, { Ref } from 'react';
3
+ import { b as Plan, w as Product, q as UseTopupAmountSelectorReturn, v as PurchaseInfo, T as TopupFormProps, t as PaywallStructuredContent } from '../index-onWNU7iT.js';
4
+ import { U as UsageSnapshot } from '../useUsage-nD7zwSbG.js';
5
+ export { r as ActivationFlow, s as ActivationFlowActivateButton, t as ActivationFlowActivated, v as ActivationFlowAmountPicker, w as ActivationFlowContinueButton, x as ActivationFlowError, y as ActivationFlowLoading, z as ActivationFlowRetrying, D as ActivationFlowRoot, A as ActivationFlowStep, E as ActivationFlowSummary, B as BalanceBadge, i as CancelPlanButton, M as MandateText, l as MandateTextProps, F as PaymentForm, c as PaymentFormCardElement, a as PaymentFormCustomerFields, h as PaymentFormError, g as PaymentFormLoading, d as PaymentFormMandateText, b as PaymentFormPaymentElement, G as PaymentFormRoot, f as PaymentFormSubmitButton, P as PaymentFormSummary, e as PaymentFormTermsCheckbox, m as PlanBadge, n as ProductBadge, o as PurchaseGate, H as PurchaseGateAllowed, I as PurchaseGateBlocked, J as PurchaseGateError, K as PurchaseGateLoading, L as PurchaseGateRoot, N as useActivationFlow, O as usePurchaseGate } from '../useUsage-nD7zwSbG.js';
6
+ import { PaymentElement } from '@stripe/react-stripe-js';
7
+ import { Stripe, StripeElements } from '@stripe/stripe-js';
8
+ import '../adapters/auth.js';
9
+
10
+ interface SlotProps extends React.HTMLAttributes<HTMLElement> {
11
+ children?: React.ReactNode;
12
+ }
13
+ declare const Slot: React.ForwardRefExoticComponent<SlotProps & React.RefAttributes<HTMLElement>>;
14
+ declare const Slottable: ({ children }: {
15
+ children: React.ReactNode;
16
+ }) => react_jsx_runtime.JSX.Element;
17
+
18
+ type PossibleRef<T> = Ref<T> | null | undefined;
19
+ /**
20
+ * Assign a value to a single ref, whether it's a function ref, object ref,
21
+ * or null/undefined. Mirrors the Radix UI helper so primitives can cleanly
22
+ * forward refs when composed via `asChild`.
23
+ */
24
+ declare function setRef<T>(ref: PossibleRef<T>, value: T | null): void;
25
+ /**
26
+ * Compose multiple refs into a single callback ref. Forwards the node
27
+ * (or null on unmount) to every provided ref. Null/undefined refs are ignored.
28
+ */
29
+ declare function composeRefs<T>(...refs: Array<PossibleRef<T>>): (node: T | null) => void;
30
+
31
+ /**
32
+ * Compose a consumer-provided event handler with an internal handler.
33
+ * The consumer handler runs first; the internal handler is skipped when
34
+ * the consumer calls `event.preventDefault()` (unless opted out).
35
+ *
36
+ * Mirrors the Radix UI helper so primitive leaves can safely chain
37
+ * user handlers with their own state updates.
38
+ */
39
+ declare function composeEventHandlers<E extends {
40
+ defaultPrevented: boolean;
41
+ }>(originalEventHandler?: ((event: E) => void) | undefined, ourEventHandler?: ((event: E) => void) | undefined, { checkForDefaultPrevented }?: {
42
+ checkForDefaultPrevented?: boolean;
43
+ }): (event: E) => void;
44
+
45
+ /**
46
+ * CheckoutSummary compound primitive.
47
+ *
48
+ * Unstyled, accessible building blocks for rendering a checkout-time summary
49
+ * of the selected plan + product. Consumers compose subcomponents; the
50
+ * top-level `@solvapay/react` package ships a thin default-tree shim in
51
+ * `src/components/CheckoutSummary.tsx`.
52
+ *
53
+ * Every leaf subcomponent accepts `asChild` for Slot-style composition with
54
+ * consumer elements (shadcn/ui, Tailwind, plain HTML). State comes from
55
+ * `usePlan` + `useProduct` with optional fallback through
56
+ * `PlanSelectionContext`.
57
+ */
58
+
59
+ type CheckoutSummaryContextValue = {
60
+ plan: Plan | null;
61
+ product: Product | null;
62
+ priceFormatted: string;
63
+ trialBanner: string | null;
64
+ loading: boolean;
65
+ };
66
+ declare const CheckoutSummaryRoot: React.ForwardRefExoticComponent<{
67
+ planRef?: string;
68
+ productRef?: string;
69
+ asChild?: boolean;
70
+ children?: React.ReactNode;
71
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<HTMLDivElement>>;
72
+ declare const CheckoutSummaryProduct: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
73
+ asChild?: boolean;
74
+ } & React.RefAttributes<HTMLSpanElement>>;
75
+ declare const CheckoutSummaryPlan: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
76
+ asChild?: boolean;
77
+ } & React.RefAttributes<HTMLSpanElement>>;
78
+ declare const CheckoutSummaryPrice: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
79
+ asChild?: boolean;
80
+ } & React.RefAttributes<HTMLSpanElement>>;
81
+ declare const CheckoutSummaryTrial: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
82
+ asChild?: boolean;
83
+ } & React.RefAttributes<HTMLSpanElement>>;
84
+ declare const CheckoutSummaryTaxNote: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
85
+ asChild?: boolean;
86
+ } & React.RefAttributes<HTMLSpanElement>>;
87
+ declare const CheckoutSummary: {
88
+ readonly Root: React.ForwardRefExoticComponent<{
89
+ planRef?: string;
90
+ productRef?: string;
91
+ asChild?: boolean;
92
+ children?: React.ReactNode;
93
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<HTMLDivElement>>;
94
+ readonly Product: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
95
+ asChild?: boolean;
96
+ } & React.RefAttributes<HTMLSpanElement>>;
97
+ readonly Plan: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
98
+ asChild?: boolean;
99
+ } & React.RefAttributes<HTMLSpanElement>>;
100
+ readonly Price: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
101
+ asChild?: boolean;
102
+ } & React.RefAttributes<HTMLSpanElement>>;
103
+ readonly Trial: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
104
+ asChild?: boolean;
105
+ } & React.RefAttributes<HTMLSpanElement>>;
106
+ readonly TaxNote: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
107
+ asChild?: boolean;
108
+ } & React.RefAttributes<HTMLSpanElement>>;
109
+ };
110
+ /**
111
+ * Hook for consumers who need the resolved plan/product/price state directly
112
+ * (for example, to gate sibling UI outside the primitive tree).
113
+ *
114
+ * Must be called inside `<CheckoutSummary.Root>`.
115
+ */
116
+ declare function useCheckoutSummary(): CheckoutSummaryContextValue;
117
+
118
+ /**
119
+ * PlanSelector compound primitive.
120
+ *
121
+ * Unstyled, accessible building blocks for fetching a product's active plans
122
+ * and letting users pick one. Consumers compose subcomponents; the top-level
123
+ * `@solvapay/react` package ships a thin default-tree shim in
124
+ * `src/components/PlanSelector.tsx`.
125
+ *
126
+ * State machine lives in the existing `usePlans` hook and
127
+ * `PlanSelectionContext`. Each `Card` emits `data-state=idle|selected|current|disabled`
128
+ * and optional `data-free`, `data-popular`, `data-trial` flags for CSS
129
+ * targeting without inline styles.
130
+ */
131
+
132
+ type PlanSelectorContextValue = {
133
+ plans: Plan[];
134
+ loading: boolean;
135
+ error: Error | null;
136
+ selectedPlan: Plan | null;
137
+ selectedPlanRef: string | null;
138
+ popularPlanRef: string | undefined;
139
+ currentPlanRef: string | null;
140
+ isCurrent: (ref: string) => boolean;
141
+ isFree: (ref: string) => boolean;
142
+ isPopular: (ref: string) => boolean;
143
+ select: (ref: string) => void;
144
+ /**
145
+ * Clear the current selection so no plan is selected. Pins
146
+ * `userHasSelected` true so auto-selection doesn't reassert.
147
+ */
148
+ clearSelection: () => void;
149
+ };
150
+ declare const PlanSelectorRoot: React.ForwardRefExoticComponent<{
151
+ productRef?: string;
152
+ fetcher?: (productRef: string) => Promise<Plan[]>;
153
+ filter?: (plan: Plan, index: number) => boolean;
154
+ sortBy?: (a: Plan, b: Plan) => number;
155
+ autoSelectFirstPaid?: boolean;
156
+ initialPlanRef?: string;
157
+ currentPlanRef?: string | null;
158
+ popularPlanRef?: string;
159
+ onSelect?: (planRef: string, plan: Plan) => void;
160
+ children?: React.ReactNode;
161
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onSelect"> & React.RefAttributes<HTMLDivElement>>;
162
+ declare const PlanSelectorHeading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & {
163
+ asChild?: boolean;
164
+ } & React.RefAttributes<HTMLHeadingElement>>;
165
+ declare const PlanSelectorGrid: React.ForwardRefExoticComponent<{
166
+ children?: React.ReactNode;
167
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<HTMLDivElement>>;
168
+ declare const PlanSelectorCard: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
169
+ asChild?: boolean;
170
+ } & React.RefAttributes<HTMLButtonElement>>;
171
+ declare const PlanSelectorCardName: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
172
+ asChild?: boolean;
173
+ } & React.RefAttributes<HTMLSpanElement>>;
174
+ declare const PlanSelectorCardPrice: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
175
+ asChild?: boolean;
176
+ } & React.RefAttributes<HTMLSpanElement>>;
177
+ declare const PlanSelectorCardInterval: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
178
+ asChild?: boolean;
179
+ } & React.RefAttributes<HTMLSpanElement>>;
180
+ declare const PlanSelectorCardBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
181
+ asChild?: boolean;
182
+ } & {
183
+ 'data-variant'?: "current" | "popular";
184
+ } & React.RefAttributes<HTMLSpanElement>>;
185
+ declare const PlanSelectorLoading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
186
+ asChild?: boolean;
187
+ } & React.RefAttributes<HTMLDivElement>>;
188
+ declare const PlanSelectorError: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
189
+ asChild?: boolean;
190
+ } & React.RefAttributes<HTMLDivElement>>;
191
+ declare const PlanSelector: {
192
+ readonly Root: React.ForwardRefExoticComponent<{
193
+ productRef?: string;
194
+ fetcher?: (productRef: string) => Promise<Plan[]>;
195
+ filter?: (plan: Plan, index: number) => boolean;
196
+ sortBy?: (a: Plan, b: Plan) => number;
197
+ autoSelectFirstPaid?: boolean;
198
+ initialPlanRef?: string;
199
+ currentPlanRef?: string | null;
200
+ popularPlanRef?: string;
201
+ onSelect?: (planRef: string, plan: Plan) => void;
202
+ children?: React.ReactNode;
203
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onSelect"> & React.RefAttributes<HTMLDivElement>>;
204
+ readonly Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & {
205
+ asChild?: boolean;
206
+ } & React.RefAttributes<HTMLHeadingElement>>;
207
+ readonly Grid: React.ForwardRefExoticComponent<{
208
+ children?: React.ReactNode;
209
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<HTMLDivElement>>;
210
+ readonly Card: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
211
+ asChild?: boolean;
212
+ } & React.RefAttributes<HTMLButtonElement>>;
213
+ readonly CardName: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
214
+ asChild?: boolean;
215
+ } & React.RefAttributes<HTMLSpanElement>>;
216
+ readonly CardPrice: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
217
+ asChild?: boolean;
218
+ } & React.RefAttributes<HTMLSpanElement>>;
219
+ readonly CardInterval: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
220
+ asChild?: boolean;
221
+ } & React.RefAttributes<HTMLSpanElement>>;
222
+ readonly CardBadge: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
223
+ asChild?: boolean;
224
+ } & {
225
+ 'data-variant'?: "current" | "popular";
226
+ } & React.RefAttributes<HTMLSpanElement>>;
227
+ readonly Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
228
+ asChild?: boolean;
229
+ } & React.RefAttributes<HTMLDivElement>>;
230
+ readonly Error: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
231
+ asChild?: boolean;
232
+ } & React.RefAttributes<HTMLDivElement>>;
233
+ };
234
+ /**
235
+ * Hook for reading the shared PlanSelector state inside the primitive tree.
236
+ * Must be called under `<PlanSelector.Root>`.
237
+ */
238
+ declare function usePlanSelector(): PlanSelectorContextValue;
239
+
240
+ /**
241
+ * AmountPicker compound primitive.
242
+ *
243
+ * Unstyled building blocks for the top-up amount selector: quick-pick pills
244
+ * (`Option`), a custom input (`Custom`), and a `Confirm` button that runs
245
+ * the hook's `validate()` before proceeding. State comes from
246
+ * `useTopupAmountSelector` via `Root` and is exposed through
247
+ * `useAmountPicker()` for fully custom layouts.
248
+ *
249
+ * `Option` emits `data-state=idle|selected|disabled` and a numeric
250
+ * `data-amount` attribute; `Custom` emits `data-state=active|dormant`
251
+ * based on whether the custom input holds the active resolved amount.
252
+ */
253
+
254
+ type AmountPickerContextValue = UseTopupAmountSelectorReturn & {
255
+ currency: string;
256
+ emit: 'major' | 'minor';
257
+ creditsPerMinorUnit: number | null;
258
+ displayExchangeRate: number | null;
259
+ estimatedCredits: number | null;
260
+ isApproximate: boolean;
261
+ /**
262
+ * `resolvedAmount` expressed in minor units (e.g. cents). Respects
263
+ * zero-decimal currencies: for JPY this equals `resolvedAmount`; for USD
264
+ * it equals `resolvedAmount * 100`. `null` when no valid amount is set.
265
+ */
266
+ resolvedAmountMinor: number | null;
267
+ };
268
+ declare const AmountPickerRoot: React.ForwardRefExoticComponent<{
269
+ currency: string;
270
+ minAmount?: number;
271
+ maxAmount?: number;
272
+ /**
273
+ * Whether `onChange` and `Confirm.onConfirm` deliver the amount in major
274
+ * units (e.g. dollars, `19.99`) or minor units (e.g. cents, `1999`).
275
+ * Defaults to `'major'` for back-compat. Respects zero-decimal currencies
276
+ * (JPY → integer yen in either mode).
277
+ */
278
+ emit?: "major" | "minor";
279
+ /**
280
+ * Externally-owned selector. When provided, `Root` uses this instance
281
+ * instead of calling `useTopupAmountSelector` internally. Lets parent
282
+ * flows (e.g. `ActivationFlow.AmountPicker`) share state with the inner
283
+ * picker so selections feed back into retry logic.
284
+ */
285
+ selector?: UseTopupAmountSelectorReturn;
286
+ onChange?: (amount: number | null) => void;
287
+ asChild?: boolean;
288
+ children?: React.ReactNode;
289
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & React.RefAttributes<HTMLDivElement>>;
290
+ declare const AmountPickerOption: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
291
+ asChild?: boolean;
292
+ amount: number;
293
+ } & React.RefAttributes<HTMLButtonElement>>;
294
+ declare const AmountPickerCustom: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
295
+ asChild?: boolean;
296
+ } & React.RefAttributes<HTMLInputElement>>;
297
+ declare const AmountPickerConfirm: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
298
+ asChild?: boolean;
299
+ onConfirm?: (amount: number) => void;
300
+ } & React.RefAttributes<HTMLButtonElement>>;
301
+ declare const AmountPicker: {
302
+ readonly Root: React.ForwardRefExoticComponent<{
303
+ currency: string;
304
+ minAmount?: number;
305
+ maxAmount?: number;
306
+ /**
307
+ * Whether `onChange` and `Confirm.onConfirm` deliver the amount in major
308
+ * units (e.g. dollars, `19.99`) or minor units (e.g. cents, `1999`).
309
+ * Defaults to `'major'` for back-compat. Respects zero-decimal currencies
310
+ * (JPY → integer yen in either mode).
311
+ */
312
+ emit?: "major" | "minor";
313
+ /**
314
+ * Externally-owned selector. When provided, `Root` uses this instance
315
+ * instead of calling `useTopupAmountSelector` internally. Lets parent
316
+ * flows (e.g. `ActivationFlow.AmountPicker`) share state with the inner
317
+ * picker so selections feed back into retry logic.
318
+ */
319
+ selector?: UseTopupAmountSelectorReturn;
320
+ onChange?: (amount: number | null) => void;
321
+ asChild?: boolean;
322
+ children?: React.ReactNode;
323
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & React.RefAttributes<HTMLDivElement>>;
324
+ readonly Option: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
325
+ asChild?: boolean;
326
+ amount: number;
327
+ } & React.RefAttributes<HTMLButtonElement>>;
328
+ readonly Custom: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
329
+ asChild?: boolean;
330
+ } & React.RefAttributes<HTMLInputElement>>;
331
+ readonly Confirm: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
332
+ asChild?: boolean;
333
+ onConfirm?: (amount: number) => void;
334
+ } & React.RefAttributes<HTMLButtonElement>>;
335
+ };
336
+ declare function useAmountPicker(): AmountPickerContextValue;
337
+ /** Helper for copy consumers composing the default-tree shim. */
338
+ declare function useAmountPickerCopy(): {
339
+ selectAmountLabel: string;
340
+ customAmountLabel: string;
341
+ creditEstimate: (credits: number) => string;
342
+ };
343
+
344
+ /**
345
+ * CancelledPlanNotice compound primitive.
346
+ *
347
+ * Banner surfaced when the customer has a cancelled-but-still-active
348
+ * purchase. `Root` renders `null` when no cancelled purchase exists;
349
+ * otherwise it emits `data-state=active|expired` and `data-has-reason`,
350
+ * and all leaves render only their respective slice of the cancellation
351
+ * data (Expires, DaysRemaining, AccessUntil, CancelledOn, Reason).
352
+ * `ReactivateButton` wires up `usePurchaseActions().reactivateRenewal`
353
+ * with `data-state=idle|reactivating`.
354
+ */
355
+
356
+ type NoticeState = 'active' | 'expired';
357
+ type CancelledPlanNoticeContextValue = {
358
+ purchase: PurchaseInfo;
359
+ state: NoticeState;
360
+ daysRemaining: number | null;
361
+ hasReason: boolean;
362
+ formatDate: (date?: string) => string | null;
363
+ reactivate: () => Promise<void>;
364
+ isReactivating: boolean;
365
+ };
366
+ declare const CancelledPlanNoticeRoot: React.ForwardRefExoticComponent<{
367
+ onReactivated?: () => void;
368
+ onError?: (error: Error) => void;
369
+ asChild?: boolean;
370
+ children?: React.ReactNode;
371
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "onError" | "children"> & React.RefAttributes<HTMLDivElement>>;
372
+ declare const CancelledPlanNoticeHeading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
373
+ asChild?: boolean;
374
+ } & React.RefAttributes<HTMLParagraphElement>>;
375
+ declare const CancelledPlanNoticeExpires: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
376
+ asChild?: boolean;
377
+ } & React.RefAttributes<HTMLParagraphElement>>;
378
+ declare const CancelledPlanNoticeDaysRemaining: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
379
+ asChild?: boolean;
380
+ } & React.RefAttributes<HTMLParagraphElement>>;
381
+ declare const CancelledPlanNoticeAccessUntil: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
382
+ asChild?: boolean;
383
+ } & React.RefAttributes<HTMLParagraphElement>>;
384
+ declare const CancelledPlanNoticeCancelledOn: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
385
+ asChild?: boolean;
386
+ } & React.RefAttributes<HTMLParagraphElement>>;
387
+ declare const CancelledPlanNoticeReason: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
388
+ asChild?: boolean;
389
+ } & React.RefAttributes<HTMLSpanElement>>;
390
+ declare const CancelledPlanNoticeReactivateButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
391
+ asChild?: boolean;
392
+ } & React.RefAttributes<HTMLButtonElement>>;
393
+ declare const CancelledPlanNotice: {
394
+ readonly Root: React.ForwardRefExoticComponent<{
395
+ onReactivated?: () => void;
396
+ onError?: (error: Error) => void;
397
+ asChild?: boolean;
398
+ children?: React.ReactNode;
399
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "onError" | "children"> & React.RefAttributes<HTMLDivElement>>;
400
+ readonly Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
401
+ asChild?: boolean;
402
+ } & React.RefAttributes<HTMLParagraphElement>>;
403
+ readonly Expires: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
404
+ asChild?: boolean;
405
+ } & React.RefAttributes<HTMLParagraphElement>>;
406
+ readonly DaysRemaining: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
407
+ asChild?: boolean;
408
+ } & React.RefAttributes<HTMLParagraphElement>>;
409
+ readonly AccessUntil: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
410
+ asChild?: boolean;
411
+ } & React.RefAttributes<HTMLParagraphElement>>;
412
+ readonly CancelledOn: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
413
+ asChild?: boolean;
414
+ } & React.RefAttributes<HTMLParagraphElement>>;
415
+ readonly Reason: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
416
+ asChild?: boolean;
417
+ } & React.RefAttributes<HTMLSpanElement>>;
418
+ readonly ReactivateButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
419
+ asChild?: boolean;
420
+ } & React.RefAttributes<HTMLButtonElement>>;
421
+ };
422
+ declare function useCancelledPlanNotice(): CancelledPlanNoticeContextValue;
423
+
424
+ /**
425
+ * CreditGate compound primitive.
426
+ *
427
+ * Companion to `<PurchaseGate>` for usage-based flows. `Root` compares the
428
+ * customer's credit balance against a threshold and drives
429
+ * `data-state=allowed|blocked|loading`. Subcomponents render only in their
430
+ * matching state:
431
+ * - `Heading`, `Subheading`, `Topup` — `blocked`
432
+ * - `Loading` — `loading`
433
+ * - `Error` — when `useBalance()` reports a fetch error
434
+ *
435
+ * Consumer-rendered "allowed" content is gated via the `useCreditGate()`
436
+ * hook or by conditionally mounting children.
437
+ */
438
+
439
+ type GateState = 'allowed' | 'blocked' | 'loading';
440
+ type CreditGateContextValue = {
441
+ state: GateState;
442
+ loading: boolean;
443
+ hasCredits: boolean;
444
+ balance: number | null;
445
+ productName: string | null;
446
+ topupAmount: number;
447
+ topupCurrency: string;
448
+ };
449
+ type TopupProps = {
450
+ amount?: number;
451
+ currency?: string;
452
+ };
453
+ declare const CreditGateRoot: React.ForwardRefExoticComponent<{
454
+ minCredits?: number;
455
+ productRef?: string;
456
+ topupAmount?: number;
457
+ topupCurrency?: string;
458
+ asChild?: boolean;
459
+ children?: React.ReactNode;
460
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<HTMLDivElement>>;
461
+ declare const CreditGateHeading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
462
+ asChild?: boolean;
463
+ } & React.RefAttributes<HTMLHeadingElement>>;
464
+ declare const CreditGateSubheading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
465
+ asChild?: boolean;
466
+ } & React.RefAttributes<HTMLParagraphElement>>;
467
+ declare const CreditGateTopup: React.FC<TopupProps>;
468
+ declare const CreditGateLoading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
469
+ asChild?: boolean;
470
+ } & React.RefAttributes<HTMLDivElement>>;
471
+ declare const CreditGateError: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
472
+ asChild?: boolean;
473
+ } & React.RefAttributes<HTMLDivElement>>;
474
+ declare const CreditGate: {
475
+ readonly Root: React.ForwardRefExoticComponent<{
476
+ minCredits?: number;
477
+ productRef?: string;
478
+ topupAmount?: number;
479
+ topupCurrency?: string;
480
+ asChild?: boolean;
481
+ children?: React.ReactNode;
482
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & React.RefAttributes<HTMLDivElement>>;
483
+ readonly Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
484
+ asChild?: boolean;
485
+ } & React.RefAttributes<HTMLHeadingElement>>;
486
+ readonly Subheading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
487
+ asChild?: boolean;
488
+ } & React.RefAttributes<HTMLParagraphElement>>;
489
+ readonly Topup: React.FC<TopupProps>;
490
+ readonly Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
491
+ asChild?: boolean;
492
+ } & React.RefAttributes<HTMLDivElement>>;
493
+ readonly Error: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
494
+ asChild?: boolean;
495
+ } & React.RefAttributes<HTMLDivElement>>;
496
+ };
497
+ declare function useCreditGate(): CreditGateContextValue;
498
+
499
+ type TopupFormState = 'loading' | 'ready' | 'error';
500
+ type TopupFormContextValue = {
501
+ amount: number;
502
+ currency?: string;
503
+ state: TopupFormState;
504
+ clientSecret: string | null;
505
+ stripe: Stripe | null;
506
+ elements: StripeElements | null;
507
+ isReady: boolean;
508
+ isProcessing: boolean;
509
+ paymentInputComplete: boolean;
510
+ canSubmit: boolean;
511
+ error: string | null;
512
+ returnUrl: string;
513
+ setPaymentInputComplete: (complete: boolean) => void;
514
+ submit: () => Promise<void>;
515
+ };
516
+ type PaymentElementProps = {
517
+ options?: React.ComponentProps<typeof PaymentElement>['options'];
518
+ };
519
+ declare const TopupFormRoot: React.ForwardRefExoticComponent<TopupFormProps & {
520
+ asChild?: boolean;
521
+ children?: React.ReactNode;
522
+ } & React.RefAttributes<HTMLDivElement>>;
523
+ declare const TopupFormPaymentElement: React.FC<PaymentElementProps>;
524
+ declare const TopupFormSubmitButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
525
+ asChild?: boolean;
526
+ } & React.RefAttributes<HTMLButtonElement>>;
527
+ declare const TopupFormLoading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
528
+ asChild?: boolean;
529
+ } & React.RefAttributes<HTMLDivElement>>;
530
+ declare const TopupFormError: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
531
+ asChild?: boolean;
532
+ } & React.RefAttributes<HTMLDivElement>>;
533
+ declare const TopupForm: {
534
+ readonly Root: React.ForwardRefExoticComponent<TopupFormProps & {
535
+ asChild?: boolean;
536
+ children?: React.ReactNode;
537
+ } & React.RefAttributes<HTMLDivElement>>;
538
+ readonly AmountPicker: React.ForwardRefExoticComponent<{
539
+ currency: string;
540
+ minAmount?: number;
541
+ maxAmount?: number;
542
+ emit?: "major" | "minor";
543
+ selector?: UseTopupAmountSelectorReturn;
544
+ onChange?: (amount: number | null) => void;
545
+ asChild?: boolean;
546
+ children?: React.ReactNode;
547
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & React.RefAttributes<HTMLDivElement>>;
548
+ readonly PaymentElement: React.FC<PaymentElementProps>;
549
+ readonly SubmitButton: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
550
+ asChild?: boolean;
551
+ } & React.RefAttributes<HTMLButtonElement>>;
552
+ readonly Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
553
+ asChild?: boolean;
554
+ } & React.RefAttributes<HTMLDivElement>>;
555
+ readonly Error: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
556
+ asChild?: boolean;
557
+ } & React.RefAttributes<HTMLDivElement>>;
558
+ };
559
+ declare function useTopupForm(): TopupFormContextValue;
560
+
561
+ interface PaywallNoticeClassNames {
562
+ root?: string;
563
+ heading?: string;
564
+ message?: string;
565
+ productContext?: string;
566
+ balance?: string;
567
+ plans?: string;
568
+ hostedLink?: string;
569
+ embeddedCheckout?: string;
570
+ retryButton?: string;
571
+ }
572
+ interface PaywallNoticeContextValue {
573
+ content: PaywallStructuredContent;
574
+ resolved: boolean;
575
+ refetch: () => Promise<void>;
576
+ onResolved?: () => void;
577
+ classNames: PaywallNoticeClassNames;
578
+ }
579
+ interface PaywallNoticeRootProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'content'> {
580
+ content: PaywallStructuredContent;
581
+ /**
582
+ * Called once the paywall requirement is met (purchase created or plan
583
+ * activated). Consumers typically use this to dismiss the notice and
584
+ * retry the original tool call.
585
+ */
586
+ onResolved?: () => void;
587
+ classNames?: PaywallNoticeClassNames;
588
+ asChild?: boolean;
589
+ }
590
+ declare const Root$1: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>>;
591
+ declare const Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
592
+ asChild?: boolean;
593
+ } & React.RefAttributes<HTMLHeadingElement>>;
594
+ declare const Message: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
595
+ asChild?: boolean;
596
+ } & React.RefAttributes<HTMLParagraphElement>>;
597
+ declare const ProductContext: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
598
+ asChild?: boolean;
599
+ } & React.RefAttributes<HTMLDivElement>>;
600
+ declare const Balance: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
601
+ asChild?: boolean;
602
+ } & React.RefAttributes<HTMLDivElement>>;
603
+ interface PlansProps {
604
+ /** Custom className forwarded to the underlying `<PlanSelector.Root>`. */
605
+ className?: string;
606
+ children?: React.ReactNode;
607
+ }
608
+ declare function Plans({ className, children }: PlansProps): react_jsx_runtime.JSX.Element | null;
609
+ declare const HostedCheckoutLink: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & {
610
+ asChild?: boolean;
611
+ } & React.RefAttributes<HTMLAnchorElement>>;
612
+ interface EmbeddedCheckoutProps {
613
+ /**
614
+ * Return URL forwarded to `<PaymentForm.Root>` for Stripe's
615
+ * confirmPayment step.
616
+ */
617
+ returnUrl: string;
618
+ className?: string;
619
+ children?: React.ReactNode;
620
+ }
621
+ declare function EmbeddedCheckout({ returnUrl, className, children, }: EmbeddedCheckoutProps): react_jsx_runtime.JSX.Element | null;
622
+ declare const Retry: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
623
+ asChild?: boolean;
624
+ } & React.RefAttributes<HTMLButtonElement>>;
625
+ declare const PaywallNotice: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>> & {
626
+ Root: React.ForwardRefExoticComponent<PaywallNoticeRootProps & React.RefAttributes<HTMLDivElement>>;
627
+ Heading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
628
+ asChild?: boolean;
629
+ } & React.RefAttributes<HTMLHeadingElement>>;
630
+ Message: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
631
+ asChild?: boolean;
632
+ } & React.RefAttributes<HTMLParagraphElement>>;
633
+ ProductContext: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
634
+ asChild?: boolean;
635
+ } & React.RefAttributes<HTMLDivElement>>;
636
+ Plans: typeof Plans;
637
+ Balance: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLElement> & {
638
+ asChild?: boolean;
639
+ } & React.RefAttributes<HTMLDivElement>>;
640
+ HostedCheckoutLink: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & {
641
+ asChild?: boolean;
642
+ } & React.RefAttributes<HTMLAnchorElement>>;
643
+ EmbeddedCheckout: typeof EmbeddedCheckout;
644
+ Retry: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
645
+ asChild?: boolean;
646
+ } & React.RefAttributes<HTMLButtonElement>>;
647
+ };
648
+
649
+ declare function usePaywallNotice(): PaywallNoticeContextValue;
650
+
651
+ /**
652
+ * `<UsageMeter>` compound primitive — renders the authenticated customer's
653
+ * usage against their plan quota.
654
+ *
655
+ * Composes `useUsage()` internally so integrators only render the leaf
656
+ * primitives they care about. Leaves render `null` when the active plan
657
+ * isn't usage-based, so dropping the compound into any account page is
658
+ * safe.
659
+ *
660
+ * State:
661
+ * - root / bar `data-state="safe" | "warning" | "critical" | "loading"`
662
+ * - root `data-solvapay-usage-meter`
663
+ * - bar `data-solvapay-usage-meter-bar`
664
+ */
665
+
666
+ type UsageMeterState = 'safe' | 'warning' | 'critical' | 'loading';
667
+ interface UsageMeterContextValue {
668
+ usage: UsageSnapshot | null;
669
+ loading: boolean;
670
+ error: Error | null;
671
+ percentUsed: number | null;
672
+ isApproachingLimit: boolean;
673
+ isAtLimit: boolean;
674
+ isUnlimited: boolean;
675
+ state: UsageMeterState;
676
+ warningAt: number;
677
+ criticalAt: number;
678
+ }
679
+ interface UsageMeterClassNames {
680
+ root?: string;
681
+ bar?: string;
682
+ label?: string;
683
+ percentage?: string;
684
+ resetsIn?: string;
685
+ loading?: string;
686
+ empty?: string;
687
+ error?: string;
688
+ }
689
+ interface UsageMeterRootProps extends React.HTMLAttributes<HTMLDivElement> {
690
+ /** Percent at which the bar flips to `data-state="warning"`. Default 75. */
691
+ warningAt?: number;
692
+ /** Percent at which the bar flips to `data-state="critical"`. Default 90. */
693
+ criticalAt?: number;
694
+ classNames?: UsageMeterClassNames;
695
+ asChild?: boolean;
696
+ /**
697
+ * Override the usage snapshot rather than reading from `useUsage`.
698
+ * Mostly useful for tests / Storybook demos.
699
+ */
700
+ usageOverride?: UsageSnapshot | null;
701
+ }
702
+ declare const Root: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>>;
703
+ declare const Bar: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
704
+ declare const Label: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
705
+ declare const Percentage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
706
+ declare const ResetsIn: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
707
+ declare const Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
708
+ declare const Empty: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
709
+ declare const UsageMeter: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>> & {
710
+ Root: React.ForwardRefExoticComponent<UsageMeterRootProps & React.RefAttributes<HTMLDivElement>>;
711
+ Bar: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
712
+ Label: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
713
+ Percentage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
714
+ ResetsIn: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & React.RefAttributes<HTMLSpanElement>>;
715
+ Loading: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
716
+ Empty: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
717
+ };
718
+
719
+ declare function useUsageMeter(): UsageMeterContextValue;
720
+
721
+ export { AmountPicker, AmountPickerConfirm, AmountPickerCustom, AmountPickerOption, AmountPickerRoot, CancelledPlanNotice, CancelledPlanNoticeAccessUntil, CancelledPlanNoticeCancelledOn, CancelledPlanNoticeDaysRemaining, CancelledPlanNoticeExpires, CancelledPlanNoticeHeading, CancelledPlanNoticeReactivateButton, CancelledPlanNoticeReason, CancelledPlanNoticeRoot, CheckoutSummary, CheckoutSummaryPlan, CheckoutSummaryPrice, CheckoutSummaryProduct, CheckoutSummaryRoot, CheckoutSummaryTaxNote, CheckoutSummaryTrial, CreditGate, CreditGateError, CreditGateHeading, CreditGateLoading, CreditGateRoot, CreditGateSubheading, CreditGateTopup, PaywallNotice, Balance as PaywallNoticeBalance, type PaywallNoticeClassNames, EmbeddedCheckout as PaywallNoticeEmbeddedCheckout, Heading as PaywallNoticeHeading, HostedCheckoutLink as PaywallNoticeHostedCheckoutLink, Message as PaywallNoticeMessage, Plans as PaywallNoticePlans, ProductContext as PaywallNoticeProductContext, Retry as PaywallNoticeRetry, Root$1 as PaywallNoticeRoot, type PaywallNoticeRootProps, PlanSelector, PlanSelectorCard, PlanSelectorCardBadge, PlanSelectorCardInterval, PlanSelectorCardName, PlanSelectorCardPrice, PlanSelectorError, PlanSelectorGrid, PlanSelectorHeading, PlanSelectorLoading, PlanSelectorRoot, Slot, Slottable, TopupForm, TopupFormError, TopupFormLoading, TopupFormPaymentElement, TopupFormRoot, TopupFormSubmitButton, UsageMeter, Bar as UsageMeterBar, type UsageMeterClassNames, Empty as UsageMeterEmpty, Label as UsageMeterLabel, Loading as UsageMeterLoading, Percentage as UsageMeterPercentage, ResetsIn as UsageMeterResetsIn, Root as UsageMeterRoot, type UsageMeterRootProps, composeEventHandlers, composeRefs, setRef, useAmountPicker, useAmountPickerCopy, useCancelledPlanNotice, useCheckoutSummary, useCreditGate, usePaywallNotice, usePlanSelector, useTopupForm, useUsageMeter };