@relai-fi/subscriptions-react 0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/context.tsx","../src/hooks.ts","../src/components/SubscribeButton.tsx","../src/format.ts","../src/components/PricingCard.tsx","../src/theme.ts","../src/components/PricingTable.tsx"],"names":["createContext","useMemo","jsx","useContext","useState","useEffect","useCallback","useRef","jsxs","Fragment"],"mappings":";;;;;;;;AAOO,IAAM,gBAAA,GAAmB;AAEzB,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,WAAA,CACkB,MAAA,EAChB,OAAA,EACgB,IAAA,EAChB;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAJG,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAEA,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AAAA,EACd;AACF;AAsBO,SAAS,iBAAA,CAAkB,IAAA,GAA2B,EAAC,EAAgB;AAC5E,EAAA,MAAM,WAAW,IAAA,CAAK,OAAA,IAAW,gBAAA,EAAkB,OAAA,CAAQ,OAAO,EAAE,CAAA;AACpE,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,IAAS,UAAA,CAAW,KAAA;AACxC,EAAA,IAAI,CAAC,MAAA,EAAQ,MAAM,IAAI,MAAM,oDAA+C,CAAA;AAE5E,EAAA,eAAe,OAAA,CACb,MAAA,EACA,IAAA,EACA,IAAA,GAA2D,EAAC,EAChD;AACZ,IAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,OAAA,GAAU,IAAI,CAAA;AAClC,IAAA,KAAA,MAAW,CAAC,CAAA,EAAG,CAAC,CAAA,IAAK,OAAO,OAAA,CAAQ,IAAA,CAAK,KAAA,IAAS,EAAE,CAAA,EAAG,GAAA,CAAI,YAAA,CAAa,GAAA,CA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AA,QACf,aAAa,GAAA,EAAK,WAAA;AAAA,QAClB,SAAA;AAAA,QACA,OAAO,GAAA,EAAK,KAAA;AAAA,QACZ,MAAA;AAAA,QACA,MAAA;AAAA,QACA,WAAA;AAAA,QACA,iBAAiB,KAAA,CAAM,eAAA;AAAA,QACvB,cAAc,KAAA,CAAM,YAAA;AAAA,QACpB,SAAS,KAAA,CAAM,OAAA;AAAA,QACf,QAAQ,KAAA,CAAM;AAAA,OAAA;AAAA,MAZT,IAAA,CAAK;AAAA,KAaZ;AAAA,EAEJ,CAAC,CAAA,EACH,CAAA;AAEJ","file":"index.cjs","sourcesContent":["import type {\n PlanMeta,\n PrepareSubscribeResult,\n Subscription,\n SubscriptionStatusResult,\n} from \"./types.js\";\n\nexport const DEFAULT_BASE_URL = \"https://api.relai.fi\";\n\nexport class RelaiApiError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n public readonly body?: unknown,\n ) {\n super(message);\n this.name = \"RelaiApiError\";\n }\n}\n\nexport interface RelaiClientOptions {\n /** API base URL. Defaults to https://api.relai.fi */\n baseUrl?: string;\n /** Custom fetch (defaults to global fetch). */\n fetch?: typeof fetch;\n}\n\n/** Browser-safe client for the public RelAI subscriptions endpoints. No API key. */\nexport interface RelaiClient {\n readonly baseUrl: string;\n /** Public plan terms for a pricing card. */\n meta(planId: string): Promise<PlanMeta>;\n /** Is `wallet` actively subscribed to `planId`? */\n status(planId: string, wallet: string): Promise<SubscriptionStatusResult>;\n /** Build the next unsigned subscribe transaction (two-stage). */\n prepareSubscribe(planId: string, wallet: string): Promise<PrepareSubscribeResult>;\n /** Confirm the subscription after the signed tx is broadcast. */\n confirmSubscribe(planId: string, wallet: string, signature: string): Promise<Subscription>;\n}\n\nexport function createRelaiClient(opts: RelaiClientOptions = {}): RelaiClient {\n const baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\");\n const _fetch = opts.fetch ?? globalThis.fetch;\n if (!_fetch) throw new Error(\"No fetch available — pass `fetch` in options.\");\n\n async function request<T>(\n method: string,\n path: string,\n init: { body?: unknown; query?: Record<string, string> } = {},\n ): Promise<T> {\n const url = new URL(baseUrl + path);\n for (const [k, v] of Object.entries(init.query ?? {})) url.searchParams.set(k, v);\n const res = await _fetch(url.toString(), {\n method,\n headers: { \"Content-Type\": \"application/json\" },\n body: init.body === undefined ? undefined : JSON.stringify(init.body),\n });\n const text = await res.text();\n let json: unknown;\n try {\n json = text ? JSON.parse(text) : undefined;\n } catch {\n json = text;\n }\n if (!res.ok) {\n const msg = (json as { error?: string })?.error ?? `RelAI ${method} ${path} failed (${res.status})`;\n throw new RelaiApiError(res.status, msg, json ?? text);\n }\n return json as T;\n }\n\n const enc = encodeURIComponent;\n\n return {\n baseUrl,\n meta: (planId) => request<PlanMeta>(\"GET\", `/s/${enc(planId)}/meta`),\n status: (planId, wallet) =>\n request<SubscriptionStatusResult>(\"GET\", `/s/${enc(planId)}/status`, { query: { wallet } }),\n prepareSubscribe: (planId, wallet) =>\n request<PrepareSubscribeResult>(\"POST\", `/s/${enc(planId)}/subscribe`, {\n body: { subscriberWallet: wallet },\n }),\n confirmSubscribe: async (planId, wallet, signature) => {\n const { subscription } = await request<{ subscription: Subscription }>(\n \"POST\",\n `/s/${enc(planId)}/confirm`,\n { body: { subscriberWallet: wallet, signature } },\n );\n return subscription;\n },\n };\n}\n","import { createContext, useContext, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createRelaiClient } from \"./client.js\";\nimport type { RelaiClient } from \"./client.js\";\nimport type { RelaiTheme, SignAndSend } from \"./types.js\";\n\nexport interface RelaiContextValue {\n client: RelaiClient;\n /** The connected subscriber's wallet address (base58), if any. */\n wallet?: string;\n /** Signs + broadcasts a base64 wire tx → signature. */\n signAndSend?: SignAndSend;\n theme?: RelaiTheme;\n}\n\nconst RelaiContext = createContext<RelaiContextValue | null>(null);\n\nexport interface RelaiProviderProps {\n /** Provide a client, or `baseUrl` to build the default one. */\n client?: RelaiClient;\n baseUrl?: string;\n wallet?: string;\n signAndSend?: SignAndSend;\n theme?: RelaiTheme;\n children: ReactNode;\n}\n\n/**\n * Optional. Sets the RelAI client, wallet, signAndSend and theme for every\n * component below it. Individual components also accept these as props (props win).\n */\nexport function RelaiProvider({\n client,\n baseUrl,\n wallet,\n signAndSend,\n theme,\n children,\n}: RelaiProviderProps) {\n const value = useMemo<RelaiContextValue>(\n () => ({\n client: client ?? createRelaiClient({ baseUrl }),\n wallet,\n signAndSend,\n theme,\n }),\n [client, baseUrl, wallet, signAndSend, theme],\n );\n return <RelaiContext.Provider value={value}>{children}</RelaiContext.Provider>;\n}\n\n/** Read the RelAI context (returns null outside a provider). */\nexport function useRelaiContext(): RelaiContextValue | null {\n return useContext(RelaiContext);\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { createRelaiClient } from \"./client.js\";\nimport type { RelaiClient } from \"./client.js\";\nimport { useRelaiContext } from \"./context.js\";\nimport type {\n PlanMeta,\n SignAndSend,\n Subscription,\n SubscriptionStatusResult,\n} from \"./types.js\";\n\nexport interface RelaiResolvedOptions {\n client?: RelaiClient;\n baseUrl?: string;\n wallet?: string;\n signAndSend?: SignAndSend;\n}\n\nexport interface RelaiResolved {\n client: RelaiClient;\n wallet?: string;\n signAndSend?: SignAndSend;\n}\n\n/** Merge per-component props over the provider context (props win). */\nexport function useRelaiResolved(opts: RelaiResolvedOptions = {}): RelaiResolved {\n const ctx = useRelaiContext();\n return useMemo<RelaiResolved>(() => {\n const client =\n opts.client ??\n ctx?.client ??\n createRelaiClient({ baseUrl: opts.baseUrl });\n return {\n client,\n wallet: opts.wallet ?? ctx?.wallet,\n signAndSend: opts.signAndSend ?? ctx?.signAndSend,\n };\n }, [opts.client, opts.baseUrl, opts.wallet, opts.signAndSend, ctx]);\n}\n\nexport interface UsePlanMetaResult {\n plan?: PlanMeta;\n loading: boolean;\n error?: Error;\n}\n\n/** Fetch public plan terms for `planId`. */\nexport function usePlanMeta(planId: string, client: RelaiClient): UsePlanMetaResult {\n const [state, setState] = useState<UsePlanMetaResult>({ loading: true });\n useEffect(() => {\n let alive = true;\n setState({ loading: true });\n client\n .meta(planId)\n .then((plan) => alive && setState({ plan, loading: false }))\n .catch((error: Error) => alive && setState({ loading: false, error }));\n return () => {\n alive = false;\n };\n }, [planId, client]);\n return state;\n}\n\nexport interface UseSubscriptionStatusResult {\n status?: SubscriptionStatusResult;\n loading: boolean;\n error?: Error;\n refetch: () => void;\n}\n\n/** Track whether `wallet` is subscribed to `planId`. No-op until a wallet is set. */\nexport function useSubscriptionStatus(\n planId: string,\n wallet: string | undefined,\n client: RelaiClient,\n): UseSubscriptionStatusResult {\n const [state, setState] = useState<Omit<UseSubscriptionStatusResult, \"refetch\">>({\n loading: false,\n });\n const [nonce, setNonce] = useState(0);\n const refetch = useCallback(() => setNonce((n) => n + 1), []);\n\n useEffect(() => {\n if (!wallet) {\n setState({ loading: false, status: undefined });\n return;\n }\n let alive = true;\n setState({ loading: true });\n client\n .status(planId, wallet)\n .then((status) => alive && setState({ status, loading: false }))\n .catch((error: Error) => alive && setState({ loading: false, error }));\n return () => {\n alive = false;\n };\n }, [planId, wallet, client, nonce]);\n\n return { ...state, refetch };\n}\n\nexport type SubscribeState =\n | \"idle\"\n | \"preparing\"\n | \"signing\"\n | \"confirming\"\n | \"done\"\n | \"error\";\n\nexport interface UseSubscribeOptions extends RelaiResolvedOptions {\n planId: string;\n onSubscribed?: (sub: Subscription) => void;\n onError?: (err: Error) => void;\n}\n\nexport interface UseSubscribeResult {\n subscribe: () => Promise<Subscription | undefined>;\n state: SubscribeState;\n error?: Error;\n subscription?: Subscription;\n /** True while the flow is mid-run (preparing/signing/confirming). */\n busy: boolean;\n reset: () => void;\n}\n\n/**\n * Runs the full two-stage subscribe flow:\n * prepare → (init-authority sign → prepare again) → sign → confirm.\n */\nexport function useSubscribe(opts: UseSubscribeOptions): UseSubscribeResult {\n const { client, wallet, signAndSend } = useRelaiResolved(opts);\n const [state, setState] = useState<SubscribeState>(\"idle\");\n const [error, setError] = useState<Error | undefined>();\n const [subscription, setSubscription] = useState<Subscription | undefined>();\n const running = useRef(false);\n\n const reset = useCallback(() => {\n setState(\"idle\");\n setError(undefined);\n setSubscription(undefined);\n }, []);\n\n const subscribe = useCallback(async (): Promise<Subscription | undefined> => {\n if (running.current) return undefined;\n if (!wallet) {\n const err = new Error(\"No wallet — connect a wallet before subscribing.\");\n setError(err);\n setState(\"error\");\n opts.onError?.(err);\n return undefined;\n }\n if (!signAndSend) {\n const err = new Error(\"No signAndSend — pass one (see @relai-fi/subscriptions-react/wallet).\");\n setError(err);\n setState(\"error\");\n opts.onError?.(err);\n return undefined;\n }\n\n running.current = true;\n setError(undefined);\n try {\n setState(\"preparing\");\n let prep = await client.prepareSubscribe(opts.planId, wallet);\n\n // Stage 1: one-time delegate authority init for this wallet+mint.\n if (prep.stage === \"init-authority\") {\n setState(\"signing\");\n await signAndSend(prep.wireTransaction);\n setState(\"preparing\");\n prep = await client.prepareSubscribe(opts.planId, wallet);\n }\n\n // Stage 2: the subscribe transaction.\n setState(\"signing\");\n const sig = await signAndSend(prep.wireTransaction);\n\n setState(\"confirming\");\n const sub = await client.confirmSubscribe(opts.planId, wallet, sig);\n setSubscription(sub);\n setState(\"done\");\n opts.onSubscribed?.(sub);\n return sub;\n } catch (e) {\n const err = e instanceof Error ? e : new Error(String(e));\n setError(err);\n setState(\"error\");\n opts.onError?.(err);\n return undefined;\n } finally {\n running.current = false;\n }\n }, [client, wallet, signAndSend, opts]);\n\n const busy = state === \"preparing\" || state === \"signing\" || state === \"confirming\";\n return { subscribe, state, error, subscription, busy, reset };\n}\n","import type { CSSProperties, ReactNode } from \"react\";\nimport { useRelaiResolved, useSubscribe, useSubscriptionStatus } from \"../hooks.js\";\nimport type { RelaiResolvedOptions } from \"../hooks.js\";\nimport type { Subscription } from \"../types.js\";\n\nexport interface SubscribeButtonLabels {\n subscribe?: string;\n connect?: string;\n preparing?: string;\n signing?: string;\n confirming?: string;\n active?: string;\n retry?: string;\n}\n\nconst DEFAULT_LABELS: Required<SubscribeButtonLabels> = {\n subscribe: \"Subscribe\",\n connect: \"Connect wallet\",\n preparing: \"Preparing…\",\n signing: \"Confirm in wallet…\",\n confirming: \"Activating…\",\n active: \"Subscribed\",\n retry: \"Try again\",\n};\n\nexport interface SubscribeButtonProps extends RelaiResolvedOptions {\n planId: string;\n /** Called when the user has no connected wallet and clicks the button. */\n onConnectWallet?: () => void;\n onSubscribed?: (sub: Subscription) => void;\n onError?: (err: Error) => void;\n /** Hide the \"Subscribed\" current-plan state (skip the status check). */\n hideStatus?: boolean;\n labels?: SubscribeButtonLabels;\n className?: string;\n style?: CSSProperties;\n children?: ReactNode;\n}\n\n/**\n * A single subscribe button for `planId`. Resolves wallet / signAndSend / client\n * from props or <RelaiProvider>. Runs the two-stage subscribe flow on click and\n * reflects the live state. Shows \"Subscribed\" when the wallet already has the plan.\n */\nexport function SubscribeButton(props: SubscribeButtonProps) {\n const { planId, onConnectWallet, hideStatus, className, style, children } = props;\n const labels = { ...DEFAULT_LABELS, ...props.labels };\n const { client, wallet } = useRelaiResolved(props);\n\n const { status, refetch } = useSubscriptionStatus(\n planId,\n hideStatus ? undefined : wallet,\n client,\n );\n const { subscribe, state, busy } = useSubscribe({\n ...props,\n onSubscribed: (sub) => {\n refetch();\n props.onSubscribed?.(sub);\n },\n });\n\n const alreadyActive = !hideStatus && status?.active === true;\n\n let label: string;\n let disabled = false;\n let dataState = state;\n\n if (alreadyActive || state === \"done\") {\n label = labels.active;\n disabled = true;\n dataState = \"done\";\n } else if (!wallet) {\n label = labels.connect;\n disabled = !onConnectWallet;\n } else if (state === \"preparing\") {\n label = labels.preparing;\n disabled = true;\n } else if (state === \"signing\") {\n label = labels.signing;\n disabled = true;\n } else if (state === \"confirming\") {\n label = labels.confirming;\n disabled = true;\n } else if (state === \"error\") {\n label = labels.retry;\n } else {\n label = labels.subscribe;\n }\n\n const onClick = () => {\n if (busy || alreadyActive) return;\n if (!wallet) {\n onConnectWallet?.();\n return;\n }\n void subscribe();\n };\n\n return (\n <button\n type=\"button\"\n className={[\"relai-btn\", className].filter(Boolean).join(\" \")}\n style={style}\n data-state={dataState}\n data-busy={busy ? \"true\" : undefined}\n aria-busy={busy || undefined}\n disabled={disabled}\n onClick={onClick}\n >\n {busy && <span className=\"relai-spinner\" aria-hidden=\"true\" />}\n {children ?? label}\n </button>\n );\n}\n","import type { Network } from \"./types.js\";\n\nconst USDC_DECIMALS = 6;\n\n/** \"5000000\" → \"5.00\" (or \"5.00 USDC\" with the ticker). */\nexport function formatUsdc(\n amountBaseUnits: string | number,\n opts: { withTicker?: boolean; decimals?: number } = {},\n): string {\n const decimals = opts.decimals ?? USDC_DECIMALS;\n const n = Number(amountBaseUnits) / 10 ** decimals;\n // Trim to 2 dp for whole-cent USDC; keep more only if the value needs it.\n const dp = Number.isInteger(n * 100) ? 2 : Math.min(decimals, 6);\n const s = n.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: dp });\n return opts.withTicker ? `${s} USDC` : s;\n}\n\n/** Short price suffix for a pricing card: 720 → \"/mo\", 24 → \"/day\", 1 → \"/hr\". */\nexport function formatPeriodSuffix(periodHours: number): string {\n switch (periodHours) {\n case 1:\n return \"/hr\";\n case 24:\n return \"/day\";\n case 168:\n return \"/wk\";\n case 720:\n return \"/mo\";\n case 8760:\n return \"/yr\";\n default:\n return periodHours % 24 === 0 ? `/${periodHours / 24}d` : `/${periodHours}h`;\n }\n}\n\n/** Human label: 720 → \"Billed monthly\", 1 → \"Billed hourly\". */\nexport function formatPeriodLabel(periodHours: number): string {\n const map: Record<number, string> = {\n 1: \"hourly\",\n 24: \"daily\",\n 168: \"weekly\",\n 720: \"monthly\",\n 8760: \"yearly\",\n };\n const known = map[periodHours];\n if (known) return `Billed ${known}`;\n if (periodHours % 24 === 0) return `Billed every ${periodHours / 24} days`;\n return `Billed every ${periodHours} hours`;\n}\n\nexport function formatNetwork(network: Network): string {\n return network === \"solana-devnet\" ? \"Solana devnet\" : \"Solana\";\n}\n","import type { CSSProperties } from \"react\";\nimport { SubscribeButton } from \"./SubscribeButton.js\";\nimport type { SubscribeButtonLabels } from \"./SubscribeButton.js\";\nimport type { RelaiResolvedOptions } from \"../hooks.js\";\nimport { formatNetwork, formatPeriodLabel, formatPeriodSuffix, formatUsdc } from \"../format.js\";\nimport type { PlanMeta, Subscription } from \"../types.js\";\n\nexport interface PricingCardProps extends RelaiResolvedOptions {\n plan: PlanMeta;\n /** Bullet features shown under the price. */\n features?: string[];\n /** Short line under the plan name. */\n description?: string;\n /** Visually emphasize this card. */\n highlight?: boolean;\n /** Ribbon text (e.g. \"Popular\"). Defaults to \"Popular\" when highlight is set. */\n badge?: string;\n /** Hide the \"Solana / Solana devnet\" network line. */\n hideNetwork?: boolean;\n onConnectWallet?: () => void;\n onSubscribed?: (sub: Subscription) => void;\n onError?: (err: Error) => void;\n labels?: SubscribeButtonLabels;\n className?: string;\n style?: CSSProperties;\n}\n\nconst Check = () => (\n <svg className=\"relai-check\" viewBox=\"0 0 20 20\" width=\"18\" height=\"18\" aria-hidden=\"true\">\n <path\n d=\"M16.7 5.3a1 1 0 0 1 0 1.4l-7.5 7.5a1 1 0 0 1-1.4 0L3.3 9.7a1 1 0 1 1 1.4-1.4l3.3 3.29 6.8-6.8a1 1 0 0 1 1.4 0Z\"\n fill=\"currentColor\"\n />\n </svg>\n);\n\n/** A single Stripe-style pricing card for one plan. */\nexport function PricingCard(props: PricingCardProps) {\n const { plan, features, description, highlight, hideNetwork, className, style } = props;\n const badge = props.badge ?? (highlight ? \"Popular\" : undefined);\n\n return (\n <div\n className={[\"relai-card\", highlight ? \"relai-card--highlight\" : \"\", className]\n .filter(Boolean)\n .join(\" \")}\n style={style}\n data-plan={plan.planId}\n >\n {badge && <span className=\"relai-badge\">{badge}</span>}\n\n <div className=\"relai-card__head\">\n <h3 className=\"relai-card__name\">{plan.name}</h3>\n {description && <p className=\"relai-card__desc\">{description}</p>}\n </div>\n\n <div className=\"relai-price\">\n <span className=\"relai-price__amount\">{formatUsdc(plan.amountBaseUnits)}</span>\n <span className=\"relai-price__unit\">\n <span className=\"relai-price__ticker\">USDC</span>\n <span className=\"relai-price__period\">{formatPeriodSuffix(plan.periodHours)}</span>\n </span>\n </div>\n <p className=\"relai-price__caption\">\n {formatPeriodLabel(plan.periodHours)}\n {!hideNetwork && <> · {formatNetwork(plan.network)}</>}\n </p>\n\n <SubscribeButton\n planId={plan.planId}\n client={props.client}\n baseUrl={props.baseUrl}\n wallet={props.wallet}\n signAndSend={props.signAndSend}\n onConnectWallet={props.onConnectWallet}\n onSubscribed={props.onSubscribed}\n onError={props.onError}\n labels={props.labels}\n />\n\n {features && features.length > 0 && (\n <ul className=\"relai-features\">\n {features.map((f, i) => (\n <li key={i} className=\"relai-features__item\">\n <Check />\n <span>{f}</span>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n}\n","import type { CSSProperties } from \"react\";\nimport type { RelaiTheme } from \"./types.js\";\n\n/** Map a RelaiTheme onto the `--relai-*` CSS variables consumed by styles.css. */\nexport function themeToCssVars(theme?: RelaiTheme): CSSProperties {\n if (!theme) return {};\n const v: Record<string, string> = {};\n if (theme.primary) v[\"--relai-primary\"] = theme.primary;\n if (theme.primaryForeground) v[\"--relai-primary-fg\"] = theme.primaryForeground;\n if (theme.background) v[\"--relai-bg\"] = theme.background;\n if (theme.card) v[\"--relai-card\"] = theme.card;\n if (theme.foreground) v[\"--relai-fg\"] = theme.foreground;\n if (theme.mutedForeground) v[\"--relai-muted-fg\"] = theme.mutedForeground;\n if (theme.border) v[\"--relai-border\"] = theme.border;\n if (theme.radius) v[\"--relai-radius\"] = theme.radius;\n return v as CSSProperties;\n}\n","import { useEffect, useState } from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { PricingCard } from \"./PricingCard.js\";\nimport type { SubscribeButtonLabels } from \"./SubscribeButton.js\";\nimport { useRelaiResolved } from \"../hooks.js\";\nimport type { RelaiResolvedOptions } from \"../hooks.js\";\nimport { useRelaiContext } from \"../context.js\";\nimport { themeToCssVars } from \"../theme.js\";\nimport type { PlanMeta, RelaiTheme, Subscription } from \"../types.js\";\n\nexport interface PlanCardConfig {\n features?: string[];\n description?: string;\n highlight?: boolean;\n badge?: string;\n}\n\nexport interface PricingTableProps extends RelaiResolvedOptions {\n /** Plans to show, in order. Use this, or `plans`, or a single `planId`. */\n planIds?: string[];\n /** Preloaded plan metadata (skips fetching). */\n plans?: PlanMeta[];\n /** Shorthand for a one-plan table. */\n planId?: string;\n /** Per-plan presentation, keyed by planId. */\n cards?: Record<string, PlanCardConfig>;\n /** Emphasize one plan (adds the \"Popular\" ribbon unless overridden in `cards`). */\n highlightPlanId?: string;\n theme?: RelaiTheme;\n onConnectWallet?: () => void;\n onSubscribed?: (sub: Subscription) => void;\n onError?: (err: Error) => void;\n labels?: SubscribeButtonLabels;\n loadingText?: string;\n errorText?: string;\n className?: string;\n style?: CSSProperties;\n}\n\nfunction useManyPlanMetas(\n ids: string[],\n preloaded: PlanMeta[] | undefined,\n client: ReturnType<typeof useRelaiResolved>[\"client\"],\n) {\n const key = ids.join(\",\");\n const [state, setState] = useState<{ plans: PlanMeta[]; loading: boolean; error?: Error }>(\n () => ({ plans: preloaded ?? [], loading: !preloaded }),\n );\n\n useEffect(() => {\n if (preloaded) {\n setState({ plans: preloaded, loading: false });\n return;\n }\n if (ids.length === 0) {\n setState({ plans: [], loading: false });\n return;\n }\n let alive = true;\n setState({ plans: [], loading: true });\n Promise.all(ids.map((id) => client.meta(id)))\n .then((plans) => alive && setState({ plans, loading: false }))\n .catch((error: Error) => alive && setState({ plans: [], loading: false, error }));\n return () => {\n alive = false;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key, preloaded, client]);\n\n return state;\n}\n\n/**\n * Drop-in Stripe-style pricing table for RelAI subscription plans.\n *\n * import \"@relai-fi/subscriptions-react/styles.css\";\n * <PricingTable planIds={[\"pl_basic\", \"pl_pro\"]} highlightPlanId=\"pl_pro\"\n * wallet={address} signAndSend={signAndSend} />\n */\nexport function PricingTable(props: PricingTableProps) {\n const { client, wallet, signAndSend } = useRelaiResolved(props);\n const ctx = useRelaiContext();\n const theme = props.theme ?? ctx?.theme;\n\n const ids = props.plans\n ? props.plans.map((p) => p.planId)\n : props.planIds ?? (props.planId ? [props.planId] : []);\n\n const { plans, loading, error } = useManyPlanMetas(ids, props.plans, client);\n\n const rootStyle: CSSProperties = { ...themeToCssVars(theme), ...props.style };\n const rootClass = [\"relai-root\", \"relai-table\", props.className].filter(Boolean).join(\" \");\n\n if (loading) {\n return (\n <div className={rootClass} style={rootStyle}>\n <div className=\"relai-state relai-state--loading\">{props.loadingText ?? \"Loading plans…\"}</div>\n </div>\n );\n }\n if (error) {\n return (\n <div className={rootClass} style={rootStyle}>\n <div className=\"relai-state relai-state--error\">\n {props.errorText ?? \"Couldn't load plans.\"}\n </div>\n </div>\n );\n }\n\n return (\n <div className={rootClass} style={rootStyle} data-count={plans.length}>\n {plans.map((plan) => {\n const cfg = props.cards?.[plan.planId];\n const highlight = cfg?.highlight ?? props.highlightPlanId === plan.planId;\n return (\n <PricingCard\n key={plan.planId}\n plan={plan}\n features={cfg?.features}\n description={cfg?.description}\n highlight={highlight}\n badge={cfg?.badge}\n client={client}\n wallet={wallet}\n signAndSend={signAndSend}\n onConnectWallet={props.onConnectWallet}\n onSubscribed={props.onSubscribed}\n onError={props.onError}\n labels={props.labels}\n />\n );\n })}\n </div>\n );\n}\n"]}
@@ -0,0 +1,208 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+ import { PlanMeta, SubscriptionStatusResult, PrepareSubscribeResult, Subscription, Network } from '@relai-fi/subscriptions';
4
+ export { Network, PlanMeta, PrepareSubscribeResult, Subscription, SubscriptionStatus, SubscriptionStatusResult } from '@relai-fi/subscriptions';
5
+ import { S as SignAndSend, R as RelaiTheme } from './types-CTW_egjj.cjs';
6
+
7
+ declare const DEFAULT_BASE_URL = "https://api.relai.fi";
8
+ declare class RelaiApiError extends Error {
9
+ readonly status: number;
10
+ readonly body?: unknown | undefined;
11
+ constructor(status: number, message: string, body?: unknown | undefined);
12
+ }
13
+ interface RelaiClientOptions {
14
+ /** API base URL. Defaults to https://api.relai.fi */
15
+ baseUrl?: string;
16
+ /** Custom fetch (defaults to global fetch). */
17
+ fetch?: typeof fetch;
18
+ }
19
+ /** Browser-safe client for the public RelAI subscriptions endpoints. No API key. */
20
+ interface RelaiClient {
21
+ readonly baseUrl: string;
22
+ /** Public plan terms for a pricing card. */
23
+ meta(planId: string): Promise<PlanMeta>;
24
+ /** Is `wallet` actively subscribed to `planId`? */
25
+ status(planId: string, wallet: string): Promise<SubscriptionStatusResult>;
26
+ /** Build the next unsigned subscribe transaction (two-stage). */
27
+ prepareSubscribe(planId: string, wallet: string): Promise<PrepareSubscribeResult>;
28
+ /** Confirm the subscription after the signed tx is broadcast. */
29
+ confirmSubscribe(planId: string, wallet: string, signature: string): Promise<Subscription>;
30
+ }
31
+ declare function createRelaiClient(opts?: RelaiClientOptions): RelaiClient;
32
+
33
+ interface RelaiContextValue {
34
+ client: RelaiClient;
35
+ /** The connected subscriber's wallet address (base58), if any. */
36
+ wallet?: string;
37
+ /** Signs + broadcasts a base64 wire tx → signature. */
38
+ signAndSend?: SignAndSend;
39
+ theme?: RelaiTheme;
40
+ }
41
+ interface RelaiProviderProps {
42
+ /** Provide a client, or `baseUrl` to build the default one. */
43
+ client?: RelaiClient;
44
+ baseUrl?: string;
45
+ wallet?: string;
46
+ signAndSend?: SignAndSend;
47
+ theme?: RelaiTheme;
48
+ children: ReactNode;
49
+ }
50
+ /**
51
+ * Optional. Sets the RelAI client, wallet, signAndSend and theme for every
52
+ * component below it. Individual components also accept these as props (props win).
53
+ */
54
+ declare function RelaiProvider({ client, baseUrl, wallet, signAndSend, theme, children, }: RelaiProviderProps): react.JSX.Element;
55
+ /** Read the RelAI context (returns null outside a provider). */
56
+ declare function useRelaiContext(): RelaiContextValue | null;
57
+
58
+ interface RelaiResolvedOptions {
59
+ client?: RelaiClient;
60
+ baseUrl?: string;
61
+ wallet?: string;
62
+ signAndSend?: SignAndSend;
63
+ }
64
+ interface RelaiResolved {
65
+ client: RelaiClient;
66
+ wallet?: string;
67
+ signAndSend?: SignAndSend;
68
+ }
69
+ /** Merge per-component props over the provider context (props win). */
70
+ declare function useRelaiResolved(opts?: RelaiResolvedOptions): RelaiResolved;
71
+ interface UsePlanMetaResult {
72
+ plan?: PlanMeta;
73
+ loading: boolean;
74
+ error?: Error;
75
+ }
76
+ /** Fetch public plan terms for `planId`. */
77
+ declare function usePlanMeta(planId: string, client: RelaiClient): UsePlanMetaResult;
78
+ interface UseSubscriptionStatusResult {
79
+ status?: SubscriptionStatusResult;
80
+ loading: boolean;
81
+ error?: Error;
82
+ refetch: () => void;
83
+ }
84
+ /** Track whether `wallet` is subscribed to `planId`. No-op until a wallet is set. */
85
+ declare function useSubscriptionStatus(planId: string, wallet: string | undefined, client: RelaiClient): UseSubscriptionStatusResult;
86
+ type SubscribeState = "idle" | "preparing" | "signing" | "confirming" | "done" | "error";
87
+ interface UseSubscribeOptions extends RelaiResolvedOptions {
88
+ planId: string;
89
+ onSubscribed?: (sub: Subscription) => void;
90
+ onError?: (err: Error) => void;
91
+ }
92
+ interface UseSubscribeResult {
93
+ subscribe: () => Promise<Subscription | undefined>;
94
+ state: SubscribeState;
95
+ error?: Error;
96
+ subscription?: Subscription;
97
+ /** True while the flow is mid-run (preparing/signing/confirming). */
98
+ busy: boolean;
99
+ reset: () => void;
100
+ }
101
+ /**
102
+ * Runs the full two-stage subscribe flow:
103
+ * prepare → (init-authority sign → prepare again) → sign → confirm.
104
+ */
105
+ declare function useSubscribe(opts: UseSubscribeOptions): UseSubscribeResult;
106
+
107
+ interface SubscribeButtonLabels {
108
+ subscribe?: string;
109
+ connect?: string;
110
+ preparing?: string;
111
+ signing?: string;
112
+ confirming?: string;
113
+ active?: string;
114
+ retry?: string;
115
+ }
116
+ interface SubscribeButtonProps extends RelaiResolvedOptions {
117
+ planId: string;
118
+ /** Called when the user has no connected wallet and clicks the button. */
119
+ onConnectWallet?: () => void;
120
+ onSubscribed?: (sub: Subscription) => void;
121
+ onError?: (err: Error) => void;
122
+ /** Hide the "Subscribed" current-plan state (skip the status check). */
123
+ hideStatus?: boolean;
124
+ labels?: SubscribeButtonLabels;
125
+ className?: string;
126
+ style?: CSSProperties;
127
+ children?: ReactNode;
128
+ }
129
+ /**
130
+ * A single subscribe button for `planId`. Resolves wallet / signAndSend / client
131
+ * from props or <RelaiProvider>. Runs the two-stage subscribe flow on click and
132
+ * reflects the live state. Shows "Subscribed" when the wallet already has the plan.
133
+ */
134
+ declare function SubscribeButton(props: SubscribeButtonProps): react.JSX.Element;
135
+
136
+ interface PlanCardConfig {
137
+ features?: string[];
138
+ description?: string;
139
+ highlight?: boolean;
140
+ badge?: string;
141
+ }
142
+ interface PricingTableProps extends RelaiResolvedOptions {
143
+ /** Plans to show, in order. Use this, or `plans`, or a single `planId`. */
144
+ planIds?: string[];
145
+ /** Preloaded plan metadata (skips fetching). */
146
+ plans?: PlanMeta[];
147
+ /** Shorthand for a one-plan table. */
148
+ planId?: string;
149
+ /** Per-plan presentation, keyed by planId. */
150
+ cards?: Record<string, PlanCardConfig>;
151
+ /** Emphasize one plan (adds the "Popular" ribbon unless overridden in `cards`). */
152
+ highlightPlanId?: string;
153
+ theme?: RelaiTheme;
154
+ onConnectWallet?: () => void;
155
+ onSubscribed?: (sub: Subscription) => void;
156
+ onError?: (err: Error) => void;
157
+ labels?: SubscribeButtonLabels;
158
+ loadingText?: string;
159
+ errorText?: string;
160
+ className?: string;
161
+ style?: CSSProperties;
162
+ }
163
+ /**
164
+ * Drop-in Stripe-style pricing table for RelAI subscription plans.
165
+ *
166
+ * import "@relai-fi/subscriptions-react/styles.css";
167
+ * <PricingTable planIds={["pl_basic", "pl_pro"]} highlightPlanId="pl_pro"
168
+ * wallet={address} signAndSend={signAndSend} />
169
+ */
170
+ declare function PricingTable(props: PricingTableProps): react.JSX.Element;
171
+
172
+ interface PricingCardProps extends RelaiResolvedOptions {
173
+ plan: PlanMeta;
174
+ /** Bullet features shown under the price. */
175
+ features?: string[];
176
+ /** Short line under the plan name. */
177
+ description?: string;
178
+ /** Visually emphasize this card. */
179
+ highlight?: boolean;
180
+ /** Ribbon text (e.g. "Popular"). Defaults to "Popular" when highlight is set. */
181
+ badge?: string;
182
+ /** Hide the "Solana / Solana devnet" network line. */
183
+ hideNetwork?: boolean;
184
+ onConnectWallet?: () => void;
185
+ onSubscribed?: (sub: Subscription) => void;
186
+ onError?: (err: Error) => void;
187
+ labels?: SubscribeButtonLabels;
188
+ className?: string;
189
+ style?: CSSProperties;
190
+ }
191
+ /** A single Stripe-style pricing card for one plan. */
192
+ declare function PricingCard(props: PricingCardProps): react.JSX.Element;
193
+
194
+ /** "5000000" → "5.00" (or "5.00 USDC" with the ticker). */
195
+ declare function formatUsdc(amountBaseUnits: string | number, opts?: {
196
+ withTicker?: boolean;
197
+ decimals?: number;
198
+ }): string;
199
+ /** Short price suffix for a pricing card: 720 → "/mo", 24 → "/day", 1 → "/hr". */
200
+ declare function formatPeriodSuffix(periodHours: number): string;
201
+ /** Human label: 720 → "Billed monthly", 1 → "Billed hourly". */
202
+ declare function formatPeriodLabel(periodHours: number): string;
203
+ declare function formatNetwork(network: Network): string;
204
+
205
+ /** Map a RelaiTheme onto the `--relai-*` CSS variables consumed by styles.css. */
206
+ declare function themeToCssVars(theme?: RelaiTheme): CSSProperties;
207
+
208
+ export { DEFAULT_BASE_URL, type PlanCardConfig, PricingCard, type PricingCardProps, PricingTable, type PricingTableProps, RelaiApiError, type RelaiClient, type RelaiClientOptions, type RelaiContextValue, RelaiProvider, type RelaiProviderProps, type RelaiResolved, type RelaiResolvedOptions, RelaiTheme, SignAndSend, SubscribeButton, type SubscribeButtonLabels, type SubscribeButtonProps, type SubscribeState, type UsePlanMetaResult, type UseSubscribeOptions, type UseSubscribeResult, type UseSubscriptionStatusResult, createRelaiClient, formatNetwork, formatPeriodLabel, formatPeriodSuffix, formatUsdc, themeToCssVars, usePlanMeta, useRelaiContext, useRelaiResolved, useSubscribe, useSubscriptionStatus };
@@ -0,0 +1,208 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+ import { PlanMeta, SubscriptionStatusResult, PrepareSubscribeResult, Subscription, Network } from '@relai-fi/subscriptions';
4
+ export { Network, PlanMeta, PrepareSubscribeResult, Subscription, SubscriptionStatus, SubscriptionStatusResult } from '@relai-fi/subscriptions';
5
+ import { S as SignAndSend, R as RelaiTheme } from './types-CTW_egjj.js';
6
+
7
+ declare const DEFAULT_BASE_URL = "https://api.relai.fi";
8
+ declare class RelaiApiError extends Error {
9
+ readonly status: number;
10
+ readonly body?: unknown | undefined;
11
+ constructor(status: number, message: string, body?: unknown | undefined);
12
+ }
13
+ interface RelaiClientOptions {
14
+ /** API base URL. Defaults to https://api.relai.fi */
15
+ baseUrl?: string;
16
+ /** Custom fetch (defaults to global fetch). */
17
+ fetch?: typeof fetch;
18
+ }
19
+ /** Browser-safe client for the public RelAI subscriptions endpoints. No API key. */
20
+ interface RelaiClient {
21
+ readonly baseUrl: string;
22
+ /** Public plan terms for a pricing card. */
23
+ meta(planId: string): Promise<PlanMeta>;
24
+ /** Is `wallet` actively subscribed to `planId`? */
25
+ status(planId: string, wallet: string): Promise<SubscriptionStatusResult>;
26
+ /** Build the next unsigned subscribe transaction (two-stage). */
27
+ prepareSubscribe(planId: string, wallet: string): Promise<PrepareSubscribeResult>;
28
+ /** Confirm the subscription after the signed tx is broadcast. */
29
+ confirmSubscribe(planId: string, wallet: string, signature: string): Promise<Subscription>;
30
+ }
31
+ declare function createRelaiClient(opts?: RelaiClientOptions): RelaiClient;
32
+
33
+ interface RelaiContextValue {
34
+ client: RelaiClient;
35
+ /** The connected subscriber's wallet address (base58), if any. */
36
+ wallet?: string;
37
+ /** Signs + broadcasts a base64 wire tx → signature. */
38
+ signAndSend?: SignAndSend;
39
+ theme?: RelaiTheme;
40
+ }
41
+ interface RelaiProviderProps {
42
+ /** Provide a client, or `baseUrl` to build the default one. */
43
+ client?: RelaiClient;
44
+ baseUrl?: string;
45
+ wallet?: string;
46
+ signAndSend?: SignAndSend;
47
+ theme?: RelaiTheme;
48
+ children: ReactNode;
49
+ }
50
+ /**
51
+ * Optional. Sets the RelAI client, wallet, signAndSend and theme for every
52
+ * component below it. Individual components also accept these as props (props win).
53
+ */
54
+ declare function RelaiProvider({ client, baseUrl, wallet, signAndSend, theme, children, }: RelaiProviderProps): react.JSX.Element;
55
+ /** Read the RelAI context (returns null outside a provider). */
56
+ declare function useRelaiContext(): RelaiContextValue | null;
57
+
58
+ interface RelaiResolvedOptions {
59
+ client?: RelaiClient;
60
+ baseUrl?: string;
61
+ wallet?: string;
62
+ signAndSend?: SignAndSend;
63
+ }
64
+ interface RelaiResolved {
65
+ client: RelaiClient;
66
+ wallet?: string;
67
+ signAndSend?: SignAndSend;
68
+ }
69
+ /** Merge per-component props over the provider context (props win). */
70
+ declare function useRelaiResolved(opts?: RelaiResolvedOptions): RelaiResolved;
71
+ interface UsePlanMetaResult {
72
+ plan?: PlanMeta;
73
+ loading: boolean;
74
+ error?: Error;
75
+ }
76
+ /** Fetch public plan terms for `planId`. */
77
+ declare function usePlanMeta(planId: string, client: RelaiClient): UsePlanMetaResult;
78
+ interface UseSubscriptionStatusResult {
79
+ status?: SubscriptionStatusResult;
80
+ loading: boolean;
81
+ error?: Error;
82
+ refetch: () => void;
83
+ }
84
+ /** Track whether `wallet` is subscribed to `planId`. No-op until a wallet is set. */
85
+ declare function useSubscriptionStatus(planId: string, wallet: string | undefined, client: RelaiClient): UseSubscriptionStatusResult;
86
+ type SubscribeState = "idle" | "preparing" | "signing" | "confirming" | "done" | "error";
87
+ interface UseSubscribeOptions extends RelaiResolvedOptions {
88
+ planId: string;
89
+ onSubscribed?: (sub: Subscription) => void;
90
+ onError?: (err: Error) => void;
91
+ }
92
+ interface UseSubscribeResult {
93
+ subscribe: () => Promise<Subscription | undefined>;
94
+ state: SubscribeState;
95
+ error?: Error;
96
+ subscription?: Subscription;
97
+ /** True while the flow is mid-run (preparing/signing/confirming). */
98
+ busy: boolean;
99
+ reset: () => void;
100
+ }
101
+ /**
102
+ * Runs the full two-stage subscribe flow:
103
+ * prepare → (init-authority sign → prepare again) → sign → confirm.
104
+ */
105
+ declare function useSubscribe(opts: UseSubscribeOptions): UseSubscribeResult;
106
+
107
+ interface SubscribeButtonLabels {
108
+ subscribe?: string;
109
+ connect?: string;
110
+ preparing?: string;
111
+ signing?: string;
112
+ confirming?: string;
113
+ active?: string;
114
+ retry?: string;
115
+ }
116
+ interface SubscribeButtonProps extends RelaiResolvedOptions {
117
+ planId: string;
118
+ /** Called when the user has no connected wallet and clicks the button. */
119
+ onConnectWallet?: () => void;
120
+ onSubscribed?: (sub: Subscription) => void;
121
+ onError?: (err: Error) => void;
122
+ /** Hide the "Subscribed" current-plan state (skip the status check). */
123
+ hideStatus?: boolean;
124
+ labels?: SubscribeButtonLabels;
125
+ className?: string;
126
+ style?: CSSProperties;
127
+ children?: ReactNode;
128
+ }
129
+ /**
130
+ * A single subscribe button for `planId`. Resolves wallet / signAndSend / client
131
+ * from props or <RelaiProvider>. Runs the two-stage subscribe flow on click and
132
+ * reflects the live state. Shows "Subscribed" when the wallet already has the plan.
133
+ */
134
+ declare function SubscribeButton(props: SubscribeButtonProps): react.JSX.Element;
135
+
136
+ interface PlanCardConfig {
137
+ features?: string[];
138
+ description?: string;
139
+ highlight?: boolean;
140
+ badge?: string;
141
+ }
142
+ interface PricingTableProps extends RelaiResolvedOptions {
143
+ /** Plans to show, in order. Use this, or `plans`, or a single `planId`. */
144
+ planIds?: string[];
145
+ /** Preloaded plan metadata (skips fetching). */
146
+ plans?: PlanMeta[];
147
+ /** Shorthand for a one-plan table. */
148
+ planId?: string;
149
+ /** Per-plan presentation, keyed by planId. */
150
+ cards?: Record<string, PlanCardConfig>;
151
+ /** Emphasize one plan (adds the "Popular" ribbon unless overridden in `cards`). */
152
+ highlightPlanId?: string;
153
+ theme?: RelaiTheme;
154
+ onConnectWallet?: () => void;
155
+ onSubscribed?: (sub: Subscription) => void;
156
+ onError?: (err: Error) => void;
157
+ labels?: SubscribeButtonLabels;
158
+ loadingText?: string;
159
+ errorText?: string;
160
+ className?: string;
161
+ style?: CSSProperties;
162
+ }
163
+ /**
164
+ * Drop-in Stripe-style pricing table for RelAI subscription plans.
165
+ *
166
+ * import "@relai-fi/subscriptions-react/styles.css";
167
+ * <PricingTable planIds={["pl_basic", "pl_pro"]} highlightPlanId="pl_pro"
168
+ * wallet={address} signAndSend={signAndSend} />
169
+ */
170
+ declare function PricingTable(props: PricingTableProps): react.JSX.Element;
171
+
172
+ interface PricingCardProps extends RelaiResolvedOptions {
173
+ plan: PlanMeta;
174
+ /** Bullet features shown under the price. */
175
+ features?: string[];
176
+ /** Short line under the plan name. */
177
+ description?: string;
178
+ /** Visually emphasize this card. */
179
+ highlight?: boolean;
180
+ /** Ribbon text (e.g. "Popular"). Defaults to "Popular" when highlight is set. */
181
+ badge?: string;
182
+ /** Hide the "Solana / Solana devnet" network line. */
183
+ hideNetwork?: boolean;
184
+ onConnectWallet?: () => void;
185
+ onSubscribed?: (sub: Subscription) => void;
186
+ onError?: (err: Error) => void;
187
+ labels?: SubscribeButtonLabels;
188
+ className?: string;
189
+ style?: CSSProperties;
190
+ }
191
+ /** A single Stripe-style pricing card for one plan. */
192
+ declare function PricingCard(props: PricingCardProps): react.JSX.Element;
193
+
194
+ /** "5000000" → "5.00" (or "5.00 USDC" with the ticker). */
195
+ declare function formatUsdc(amountBaseUnits: string | number, opts?: {
196
+ withTicker?: boolean;
197
+ decimals?: number;
198
+ }): string;
199
+ /** Short price suffix for a pricing card: 720 → "/mo", 24 → "/day", 1 → "/hr". */
200
+ declare function formatPeriodSuffix(periodHours: number): string;
201
+ /** Human label: 720 → "Billed monthly", 1 → "Billed hourly". */
202
+ declare function formatPeriodLabel(periodHours: number): string;
203
+ declare function formatNetwork(network: Network): string;
204
+
205
+ /** Map a RelaiTheme onto the `--relai-*` CSS variables consumed by styles.css. */
206
+ declare function themeToCssVars(theme?: RelaiTheme): CSSProperties;
207
+
208
+ export { DEFAULT_BASE_URL, type PlanCardConfig, PricingCard, type PricingCardProps, PricingTable, type PricingTableProps, RelaiApiError, type RelaiClient, type RelaiClientOptions, type RelaiContextValue, RelaiProvider, type RelaiProviderProps, type RelaiResolved, type RelaiResolvedOptions, RelaiTheme, SignAndSend, SubscribeButton, type SubscribeButtonLabels, type SubscribeButtonProps, type SubscribeState, type UsePlanMetaResult, type UseSubscribeOptions, type UseSubscribeResult, type UseSubscriptionStatusResult, createRelaiClient, formatNetwork, formatPeriodLabel, formatPeriodSuffix, formatUsdc, themeToCssVars, usePlanMeta, useRelaiContext, useRelaiResolved, useSubscribe, useSubscriptionStatus };