import { ClassValue } from 'clsx'; import { PaymentMethod, FilingTrackerStep, FilingTrackerState, Platform } from '../types/index.js'; /** * Read the `__csrf` cookie and return it as the `x-csrf-token` header for * mutating requests. * * Returns `{}` outside the browser (so native callers can use the same * helper as a no-op). In the browser, returns `{}` when the cookie is * missing — the server is the trust boundary and must reject — but logs * a one-time warning so the missing token surfaces in the dev console * rather than failing silently. * * The cookie value is `decodeURIComponent`'d to match the encoding the * server applies when setting it; without this, tokens containing `+`, * `=`, or `%` would desync between client and server. */ declare function csrfHeaders(): Record; /** * Safely extract a bounded error message from a fetch Response body. * * Caps the message at MAX_ERROR_LEN to prevent a malicious or misbehaving * backend from injecting an arbitrarily large string into the UI. The * fallback message is used if the body is not JSON or has no `error` field. */ declare const MAX_ERROR_LEN = 500; declare function clampErrorMessage(msg: unknown, fallback: string): string; declare function readErrorMessage(res: Response, fallback: string): Promise; /** * Returns a safe href value for an anchor or image source. * * Allows: relative paths (starting with /, ./, ../), and absolute http(s) URLs. * Blocks: javascript:, data:, file:, vbscript:, mailto:, etc. * * React only sanitizes `javascript:` in href attributes by default; this * helper closes the gap for `data:` (which can carry HTML/JS) and any other * non-network protocol that a misconfigured or malicious config could supply. * * Returns the supplied `fallback` (default '#') for any input that fails * validation, so the markup never renders an unsafe URL. */ declare function safeUrl(url: string | undefined | null, fallback?: string): string; /** * Normalize the backend-supplied list of enabled payment rails into the * ordered, validated set of {@link PaymentMethod}s this UI should render. * * The backend (the rail layer, #241/#242/#243) is the source of truth for * which rails are enabled. The widget MUST NOT hardcode the option list — it * passes whatever the backend reports through here so the selector stays in * sync as rails are turned on/off. This helper: * * - drops unknown / disabled methods (anything not in KNOWN_PAYMENT_METHODS), * so a typo or a not-yet-shipped rail never renders a dead button; * - de-duplicates; * - applies a stable display order (card first, then crypto rails). * * This is display-only: no chain config, no derivation, no signing. Selecting * a crypto rail drives the existing deposit-address / pending display, which * the backend rail response populates. * * @param raw The methods the backend reports as enabled (e.g. from config or * the pricing/rails endpoint). `undefined`/empty falls back to the * historical default of Solana only. */ declare function supportedPaymentMethods(raw?: readonly (string | null | undefined)[] | null): PaymentMethod[]; /** Human label for a payment method (e.g. 'eth' → 'Ethereum'). */ declare function paymentMethodLabel(method: PaymentMethod): string; /** True when the rail is an on-chain crypto rail (vs a fiat card rail). */ declare function isCryptoPaymentMethod(method: PaymentMethod): boolean; declare const TRACKER_LABELS: Record; /** * Verb tenses per state. `pending` is the neutral noun used when the row * hasn't been entered yet; `progressing` is the gerund shown while the step * is in-flight (terminal typing animation); `done` is the past-tense label * used once the step completes. All lowercase by design. */ declare const TRACKER_VERBS: Record; /** Pure normalization of a server-shaped tracker. Cascade-forward + current pointer. */ declare function deriveTrackerStates(raw: FilingTrackerState[] | null | undefined): FilingTrackerState[]; declare function currentState(states: FilingTrackerState[]): FilingTrackerState | null; declare function isAllDone(states: FilingTrackerState[]): boolean; declare function hasFailed(states: FilingTrackerState[]): boolean; /** Pick the headline word for the big typing-text animation. */ declare function pickHeadline(states: FilingTrackerState[], loaded: boolean): { text: string; playing: boolean; stepId: FilingTrackerStep; }; declare function cn(...inputs: ClassValue[]): string; declare function formatTokens(amount: number | undefined | null): string; declare function calculateBalancePercentage(current: number, max: number): number; declare function getBalanceColor(percentage: number): string; /** * Format a paperwork USD amount for display. * * Stacknet stores `paper_work` as a 6-decimal fixed-point integer string — * so `'1500000'` means $1.50. Pass any of (string | number | bigint | null * | undefined) and get back a plain dollar string. By default, returns * with 2 decimals + `$` prefix; pass `{ withSymbol: false }` for a bare * decimal number, or `{ maxDecimals: 6 }` to surface sub-cent precision. * * formatPaperUsd('0') → '$0.00' * formatPaperUsd('1500000') → '$1.50' * formatPaperUsd('1234567') → '$1.23' * formatPaperUsd('1234567', { maxDecimals: 6 }) → '$1.234567' */ declare function formatPaperUsd(raw: string | number | bigint | null | undefined, opts?: { withSymbol?: boolean; maxDecimals?: number; }): string; declare function formatDate(dateString: string | number | null | undefined): string; declare function detectPlatform(): Platform; export { MAX_ERROR_LEN, TRACKER_LABELS, TRACKER_VERBS, calculateBalancePercentage, clampErrorMessage, cn, csrfHeaders, currentState, deriveTrackerStates, detectPlatform, formatDate, formatPaperUsd, formatTokens, getBalanceColor, hasFailed, isAllDone, isCryptoPaymentMethod, paymentMethodLabel, pickHeadline, readErrorMessage, safeUrl, supportedPaymentMethods };