priceos 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/react.ts"],"sourcesContent":["import { createContext, createElement, useContext, useEffect, useState, type CSSProperties, type ReactNode } from \"react\";\nimport useSWR, { useSWRConfig, type SWRConfiguration } from \"swr\";\nimport type {\n CreateCheckoutRequest,\n CreateCheckoutResponse,\n GetFeatureAccessResponse,\n GetPricingTableResponse,\n PricingTableFeature,\n PricingTablePlan,\n LimitFeatureKeyFromAccessMap,\n PriceOSCustomer,\n TrackUsageBody,\n TrackUsageResponse,\n} from \"./types\";\n\nexport type PriceOsCustomer<TFeatureAccessMap = GetFeatureAccessResponse> =\n PriceOSCustomer<TFeatureAccessMap>;\nexport type { PriceOSCustomer } from \"./types\";\nexport type {\n PricingTablePlan,\n PricingTableFeature,\n GetPricingTableResponse as PriceOSPricingTableData,\n} from \"./types\";\n\nexport type PriceOsTrackUsageBody<TFeatureAccessMap = GetFeatureAccessResponse> = Omit<\n TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>,\n \"customerId\" | \"amount\"\n> & {\n amount?: number;\n};\n\nexport type PriceOsTrackUsageFn<TFeatureAccessMap = GetFeatureAccessResponse> = {\n (\n featureKey: LimitFeatureKeyFromAccessMap<TFeatureAccessMap>\n ): Promise<TrackUsageResponse>;\n (body: PriceOsTrackUsageBody<TFeatureAccessMap>): Promise<TrackUsageResponse>;\n};\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warn\" | \"info\" | \"debug\";\n\nexport type UseCustomerOptions<TFeatureAccessMap = GetFeatureAccessResponse> = {\n enabled?: boolean;\n errorOnNotFound?: boolean;\n swr?: SWRConfiguration<PriceOSCustomer<TFeatureAccessMap> | null, Error>;\n};\n\nexport type UseFeatureAccessOptions<TFeatureAccessMap = GetFeatureAccessResponse> = {\n enabled?: boolean;\n errorOnNotFound?: boolean;\n swr?: SWRConfiguration<TFeatureAccessMap | null, Error>;\n};\n\nexport type UsePricingTableOptions = {\n enabled?: boolean;\n customerId?: string;\n pricingTableKey?: string;\n swr?: SWRConfiguration<GetPricingTableResponse | null, Error>;\n};\n\nexport type PriceOSProviderProps = {\n children: ReactNode;\n getBearerToken?: () => Promise<string | null | undefined>;\n backendUrl?: string;\n logLevel?: PriceOSLogLevel;\n};\n\nexport type UseCustomerResult<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customer: PriceOSCustomer<TFeatureAccessMap> | null;\n error: Error | null;\n isLoading: boolean;\n refetch: () => Promise<void>;\n trackUsage: (body: PriceOsTrackUsageBody<TFeatureAccessMap>) => Promise<TrackUsageResponse>;\n};\n\nexport type UseFeatureAccessResult<TFeatureAccessMap = GetFeatureAccessResponse> = {\n featureAccess: TFeatureAccessMap | null;\n error: Error | null;\n isLoading: boolean;\n refetch: () => Promise<void>;\n};\n\ntype FeatureAccessRecord<TFeatureAccessMap> =\n NonNullable<TFeatureAccessMap> extends Record<string, unknown>\n ? NonNullable<TFeatureAccessMap>\n : Record<string, never>;\n\ntype FeatureAccessKey<TFeatureAccessMap> = keyof FeatureAccessRecord<TFeatureAccessMap> & string;\n\nexport type UseFeatureAccessByKeyResult<\n TFeatureAccessMap = GetFeatureAccessResponse,\n TFeatureKey extends keyof FeatureAccessRecord<TFeatureAccessMap> & string =\n keyof FeatureAccessRecord<TFeatureAccessMap> & string\n> = Partial<FeatureAccessRecord<TFeatureAccessMap>[TFeatureKey]> & {\n error: Error | null;\n isLoading: boolean;\n refetch: () => Promise<void>;\n};\n\nexport type UseTrackUsageResult<TFeatureAccessMap = GetFeatureAccessResponse> = {\n trackUsage: PriceOsTrackUsageFn<TFeatureAccessMap>;\n};\n\nexport type UsePricingTableResult = {\n pricingTable: GetPricingTableResponse | null;\n error: Error | null;\n isLoading: boolean;\n refetch: () => Promise<void>;\n createCheckoutSession: (\n body: Omit<CreateCheckoutRequest, \"customerId\"> & { customerId?: string }\n ) => Promise<CreateCheckoutResponse>;\n};\n\nexport type PriceOSPricingTableProps = {\n customerId?: string;\n pricingTableKey?: string;\n className?: string;\n yearlyLabel?: string;\n successUrl?: string;\n cancelUrl?: string;\n loadingFallback?: ReactNode;\n errorFallback?: ReactNode;\n emptyFallback?: ReactNode;\n onCustomCtaClick?: (input: {\n plan: PricingTablePlan;\n customCta: { buttonAction?: \"stripe_checkout\" | \"custom_url\"; buttonText?: string; linkUrl?: string };\n }) => void | Promise<void>;\n};\n\ntype PricingTablePlanPrice = NonNullable<PricingTablePlan[\"monthlyPrice\"] | PricingTablePlan[\"yearlyPrice\"]>;\ntype CreateBillingPortalSessionBody = {\n customerId?: string;\n returnUrl?: string;\n};\ntype CreateBillingPortalSessionResponse = {\n url: string;\n};\n\nexport type PricingTableViewProps = {\n pricingTable: GetPricingTableResponse | null;\n isLoading?: boolean;\n error?: Error | null;\n className?: string;\n yearlyLabel?: string;\n loadingFallback?: ReactNode;\n errorFallback?: ReactNode;\n emptyFallback?: ReactNode;\n onCheckout?: (input: { plan: PricingTablePlan; price: PricingTablePlanPrice }) => Promise<void>;\n onCustomCtaClick?: (input: {\n plan: PricingTablePlan;\n customCta: { buttonAction?: \"stripe_checkout\" | \"custom_url\"; buttonText?: string; linkUrl?: string };\n }) => void | Promise<void>;\n};\n\nconst DEFAULT_BACKEND_URL = \"/api/priceos\";\nconst DEFAULT_LOG_LEVEL: PriceOSLogLevel = \"error\";\nconst LOG_LEVEL_RANK: Record<Exclude<PriceOSLogLevel, \"none\">, number> = {\n error: 0,\n warn: 1,\n info: 2,\n debug: 3,\n};\nconst LOG_PREFIX = \"[priceos/react]\";\n\ntype PriceOSContextValue = {\n getBearerToken?: () => Promise<string | null | undefined>;\n backendUrl?: string;\n logLevel?: PriceOSLogLevel;\n};\n\nconst PriceOSContext = createContext<PriceOSContextValue>({});\n\nconst normalizeBaseUrl = (baseUrl: string) => baseUrl.replace(/\\/$/, \"\");\n\nconst buildUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/customer`;\n};\n\nconst buildFeatureAccessUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/feature-access`;\n};\n\nconst buildPricingTableUrl = (\n backendUrl: string,\n customerId?: string | null,\n pricingTableKey?: string | null\n) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n const params = new URLSearchParams();\n if (customerId && customerId.trim().length > 0) {\n params.set(\"customerId\", customerId.trim());\n }\n if (pricingTableKey && pricingTableKey.trim().length > 0) {\n params.set(\"pricingTableKey\", pricingTableKey.trim());\n }\n const queryString = params.toString();\n return `${normalizedBase}/v1/pricing-table${queryString ? `?${queryString}` : \"\"}`;\n};\n\nconst buildCheckoutUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/checkout`;\n};\n\nconst buildBillingPortalUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/portal`;\n};\n\nconst buildTrackUsageUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/usage`;\n};\n\nconst resolveIdempotencyKey = (body: { idempotencyKey?: string; eventKey?: string }) => {\n const providedEventKey = typeof body.eventKey === \"string\" ? body.eventKey.trim() : \"\";\n const providedIdempotencyKey =\n typeof body.idempotencyKey === \"string\"\n ? String(body.idempotencyKey).trim()\n : \"\";\n return providedIdempotencyKey || providedEventKey;\n};\n\nconst normalizeTrackUsageInput = <TFeatureAccessMap = GetFeatureAccessResponse>(\n input: PriceOsTrackUsageBody<TFeatureAccessMap> | LimitFeatureKeyFromAccessMap<TFeatureAccessMap>\n): PriceOsTrackUsageBody<TFeatureAccessMap> => {\n if (typeof input === \"string\") {\n return { featureKey: input as LimitFeatureKeyFromAccessMap<TFeatureAccessMap> };\n }\n return input;\n};\n\nconst shouldLog = (currentLevel: PriceOSLogLevel, targetLevel: Exclude<PriceOSLogLevel, \"none\">) => {\n if (currentLevel === \"none\") return false;\n return LOG_LEVEL_RANK[targetLevel] <= LOG_LEVEL_RANK[currentLevel];\n};\n\nconst logMessage = (\n currentLevel: PriceOSLogLevel,\n level: Exclude<PriceOSLogLevel, \"none\">,\n message: string,\n details?: unknown\n) => {\n if (!shouldLog(currentLevel, level)) return;\n const logger =\n level === \"error\" ? console.error : level === \"warn\" ? console.warn : console.info;\n if (details === undefined) {\n logger(LOG_PREFIX, message);\n return;\n }\n logger(LOG_PREFIX, message, details);\n};\n\nconst requestCustomer = async <TFeatureAccessMap = GetFeatureAccessResponse>(\n fetchFn: typeof fetch,\n url: string,\n logLevel: PriceOSLogLevel,\n errorOnNotFound: boolean,\n bearerToken?: string | null\n): Promise<PriceOSCustomer<TFeatureAccessMap> | null> => {\n logMessage(logLevel, \"debug\", \"Requesting customer\", { url, hasBearerToken: Boolean(bearerToken) });\n const headers = bearerToken ? { Authorization: `Bearer ${bearerToken}` } : undefined;\n const response = await fetchFn(url, headers ? { headers } : undefined);\n logMessage(logLevel, \"info\", \"Customer request completed\", { url, status: response.status });\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Customer response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n if (!response.ok) {\n if (response.status === 404 && !errorOnNotFound) {\n logMessage(logLevel, \"info\", \"Customer not found\", { url, status: response.status });\n return null;\n }\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Customer request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n if (parseFailed) {\n throw new Error(\"Invalid JSON response\");\n }\n logMessage(logLevel, \"debug\", \"Customer request succeeded\", { url, hasCustomer: Boolean(data) });\n return data as PriceOSCustomer<TFeatureAccessMap> | null;\n};\n\nconst requestTrackUsage = async <TFeatureAccessMap = GetFeatureAccessResponse>(\n fetchFn: typeof fetch,\n url: string,\n body: PriceOsTrackUsageBody<TFeatureAccessMap>,\n logLevel: PriceOSLogLevel,\n bearerToken?: string | null\n): Promise<TrackUsageResponse> => {\n const idempotencyKey = resolveIdempotencyKey(body);\n logMessage(logLevel, \"debug\", \"Tracking usage\", { url, featureKey: body.featureKey });\n const headers: Record<string, string> = {\n \"content-type\": \"application/json\",\n ...(bearerToken ? { Authorization: `Bearer ${bearerToken}` } : {}),\n };\n const payload = {\n ...body,\n ...(idempotencyKey ? { idempotencyKey } : {}),\n amount: body.amount ?? 1,\n };\n delete (payload as { eventKey?: string }).eventKey;\n const response = await fetchFn(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(payload),\n });\n logMessage(logLevel, \"info\", \"Usage track request completed\", { url, status: response.status });\n\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Usage track response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n\n if (!response.ok) {\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Usage track request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n\n if (parseFailed || !data || typeof data !== \"object\") {\n throw new Error(\"Invalid JSON response\");\n }\n\n return data as TrackUsageResponse;\n};\n\nconst requestFeatureAccess = async <TFeatureAccessMap = GetFeatureAccessResponse>(\n fetchFn: typeof fetch,\n url: string,\n logLevel: PriceOSLogLevel,\n errorOnNotFound: boolean,\n bearerToken?: string | null\n): Promise<TFeatureAccessMap | null> => {\n logMessage(logLevel, \"debug\", \"Requesting feature access\", { url, hasBearerToken: Boolean(bearerToken) });\n const headers = bearerToken ? { Authorization: `Bearer ${bearerToken}` } : undefined;\n const response = await fetchFn(url, headers ? { headers } : undefined);\n logMessage(logLevel, \"info\", \"Feature access request completed\", { url, status: response.status });\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Feature access response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n if (!response.ok) {\n if (response.status === 404 && !errorOnNotFound) {\n logMessage(logLevel, \"info\", \"Feature access not found\", { url, status: response.status });\n return null;\n }\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Feature access request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n if (parseFailed) {\n throw new Error(\"Invalid JSON response\");\n }\n logMessage(logLevel, \"debug\", \"Feature access request succeeded\", { url, hasData: Boolean(data) });\n return (data as TFeatureAccessMap | null) ?? null;\n};\n\nconst requestPricingTable = async (\n fetchFn: typeof fetch,\n url: string,\n logLevel: PriceOSLogLevel,\n bearerToken?: string | null\n): Promise<GetPricingTableResponse | null> => {\n logMessage(logLevel, \"debug\", \"Requesting pricing table\", { url, hasBearerToken: Boolean(bearerToken) });\n const headers = bearerToken ? { Authorization: `Bearer ${bearerToken}` } : undefined;\n const response = await fetchFn(url, headers ? { headers } : undefined);\n logMessage(logLevel, \"info\", \"Pricing table request completed\", { url, status: response.status });\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Pricing table response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n if (!response.ok) {\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Pricing table request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n if (parseFailed) {\n throw new Error(\"Invalid JSON response\");\n }\n return (data as GetPricingTableResponse | null) ?? null;\n};\n\nconst requestCheckoutSession = async (\n fetchFn: typeof fetch,\n url: string,\n body: CreateCheckoutRequest,\n logLevel: PriceOSLogLevel,\n bearerToken?: string | null\n): Promise<CreateCheckoutResponse> => {\n logMessage(logLevel, \"debug\", \"Creating checkout session\", {\n url,\n stripePriceId: body.stripePriceId,\n hasCustomerId: Boolean(body.customerId),\n });\n const headers: Record<string, string> = {\n \"content-type\": \"application/json\",\n ...(bearerToken ? { Authorization: `Bearer ${bearerToken}` } : {}),\n };\n const response = await fetchFn(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n logMessage(logLevel, \"info\", \"Checkout session request completed\", { url, status: response.status });\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Checkout session response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n if (!response.ok) {\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Checkout session request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n if (parseFailed || !data || typeof data !== \"object\") {\n throw new Error(\"Invalid JSON response\");\n }\n return data as CreateCheckoutResponse;\n};\n\nconst requestBillingPortalSession = async (\n fetchFn: typeof fetch,\n url: string,\n body: CreateBillingPortalSessionBody,\n logLevel: PriceOSLogLevel,\n bearerToken?: string | null\n): Promise<CreateBillingPortalSessionResponse> => {\n logMessage(logLevel, \"debug\", \"Creating billing portal session\", {\n url,\n hasCustomerId: Boolean(body.customerId),\n });\n const headers: Record<string, string> = {\n \"content-type\": \"application/json\",\n ...(bearerToken ? { Authorization: `Bearer ${bearerToken}` } : {}),\n };\n const response = await fetchFn(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n logMessage(logLevel, \"info\", \"Billing portal request completed\", { url, status: response.status });\n\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Billing portal response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n\n if (!response.ok) {\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Billing portal request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n\n if (\n parseFailed ||\n !data ||\n typeof data !== \"object\" ||\n !(\"url\" in data) ||\n typeof (data as { url?: unknown }).url !== \"string\"\n ) {\n throw new Error(\"Invalid JSON response\");\n }\n\n return data as CreateBillingPortalSessionResponse;\n};\n\nexport function PriceOSProvider({ children, getBearerToken, backendUrl, logLevel }: PriceOSProviderProps) {\n return createElement(\n PriceOSContext.Provider,\n { value: { getBearerToken, backendUrl, logLevel } },\n children\n );\n}\n\nexport function useCustomer<TFeatureAccessMap = GetFeatureAccessResponse>(\n options: UseCustomerOptions<TFeatureAccessMap> = {}\n): UseCustomerResult<TFeatureAccessMap> {\n const { enabled = true, errorOnNotFound = false, swr } = options;\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n const { mutate: globalMutate } = useSWRConfig();\n const fetcher = async (url: string) => {\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n logMessage(logLevel, \"debug\", \"Resolved bearer token\", {\n url,\n hasBearerToken: Boolean(bearerToken),\n });\n return requestCustomer<TFeatureAccessMap>(fetch, url, logLevel, errorOnNotFound, bearerToken);\n };\n const trackUsage = async (body: PriceOsTrackUsageBody<TFeatureAccessMap>) => {\n const url = buildTrackUsageUrl(backendUrl ?? DEFAULT_BACKEND_URL);\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n const result = await requestTrackUsage<TFeatureAccessMap>(fetch, url, body, logLevel, bearerToken);\n await mutate();\n await globalMutate(buildFeatureAccessUrl(backendUrl ?? DEFAULT_BACKEND_URL));\n return result;\n };\n const key = enabled ? buildUrl(backendUrl ?? DEFAULT_BACKEND_URL) : null;\n const { data, error, isLoading, mutate } = useSWR(\n key,\n fetcher,\n swr\n );\n\n return {\n customer: data ?? null,\n error,\n isLoading,\n refetch: async () => {\n await mutate();\n },\n trackUsage,\n };\n}\n\nexport function useFeatureAccess<TFeatureAccessMap = GetFeatureAccessResponse>(\n featureKey: FeatureAccessKey<TFeatureAccessMap>,\n options?: UseFeatureAccessOptions<TFeatureAccessMap>\n): UseFeatureAccessByKeyResult<\n TFeatureAccessMap,\n FeatureAccessKey<TFeatureAccessMap>\n>;\n\nexport function useFeatureAccess<\n TFeatureAccessMap extends Record<string, unknown>,\n TFeatureKey extends keyof TFeatureAccessMap & string = keyof TFeatureAccessMap & string\n>(\n featureKey: TFeatureKey,\n options?: UseFeatureAccessOptions<TFeatureAccessMap>\n): UseFeatureAccessByKeyResult<TFeatureAccessMap, TFeatureKey>;\n\nexport function useFeatureAccess<\n TFeatureAccessMap = GetFeatureAccessResponse,\n TFeatureKey extends FeatureAccessKey<TFeatureAccessMap> =\n FeatureAccessKey<TFeatureAccessMap>\n>(\n featureKey: TFeatureKey,\n options?: UseFeatureAccessOptions<TFeatureAccessMap>\n): UseFeatureAccessByKeyResult<TFeatureAccessMap, TFeatureKey>;\n\nexport function useFeatureAccess<TFeatureAccessMap = GetFeatureAccessResponse>(\n options?: UseFeatureAccessOptions<TFeatureAccessMap>\n): UseFeatureAccessResult<TFeatureAccessMap>;\n\nexport function useFeatureAccess<\n TFeatureAccessMap = GetFeatureAccessResponse,\n TFeatureKey extends FeatureAccessKey<TFeatureAccessMap> =\n FeatureAccessKey<TFeatureAccessMap>\n>(\n featureKeyOrOptions: TFeatureKey | UseFeatureAccessOptions<TFeatureAccessMap> = {},\n keyedOptions: UseFeatureAccessOptions<TFeatureAccessMap> = {}\n): UseFeatureAccessResult<TFeatureAccessMap> | UseFeatureAccessByKeyResult<TFeatureAccessMap, TFeatureKey> {\n const featureKey = typeof featureKeyOrOptions === \"string\" ? featureKeyOrOptions : null;\n const options = featureKey\n ? keyedOptions\n : (featureKeyOrOptions as UseFeatureAccessOptions<TFeatureAccessMap>);\n const { enabled = true, errorOnNotFound = false, swr } = options;\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n const fetcher = async (url: string) => {\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n logMessage(logLevel, \"debug\", \"Resolved bearer token\", {\n url,\n hasBearerToken: Boolean(bearerToken),\n });\n return requestFeatureAccess<TFeatureAccessMap>(fetch, url, logLevel, errorOnNotFound, bearerToken);\n };\n const key = enabled ? buildFeatureAccessUrl(backendUrl ?? DEFAULT_BACKEND_URL) : null;\n const { data, error, isLoading, mutate } = useSWR(\n key,\n fetcher,\n swr\n );\n\n const refetch = async () => {\n await mutate();\n };\n\n if (featureKey) {\n const selectedFeature = (data as FeatureAccessRecord<TFeatureAccessMap> | null)?.[featureKey];\n const featureData =\n selectedFeature && typeof selectedFeature === \"object\"\n ? (selectedFeature as object)\n : {};\n\n return {\n ...featureData,\n error,\n isLoading,\n refetch,\n } as UseFeatureAccessByKeyResult<TFeatureAccessMap, TFeatureKey>;\n }\n\n return {\n featureAccess: data ?? null,\n error,\n isLoading,\n refetch,\n };\n}\n\nexport function useTrackUsage<TFeatureAccessMap = GetFeatureAccessResponse>(): UseTrackUsageResult<TFeatureAccessMap> {\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n const { mutate } = useSWRConfig();\n\n function trackUsage(featureKey: LimitFeatureKeyFromAccessMap<TFeatureAccessMap>): Promise<TrackUsageResponse>;\n function trackUsage(body: PriceOsTrackUsageBody<TFeatureAccessMap>): Promise<TrackUsageResponse>;\n async function trackUsage(\n input: PriceOsTrackUsageBody<TFeatureAccessMap> | LimitFeatureKeyFromAccessMap<TFeatureAccessMap>\n ): Promise<TrackUsageResponse> {\n const body = normalizeTrackUsageInput<TFeatureAccessMap>(input);\n const url = buildTrackUsageUrl(backendUrl ?? DEFAULT_BACKEND_URL);\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n const result = await requestTrackUsage<TFeatureAccessMap>(fetch, url, body, logLevel, bearerToken);\n await mutate(buildUrl(backendUrl ?? DEFAULT_BACKEND_URL));\n await mutate(buildFeatureAccessUrl(backendUrl ?? DEFAULT_BACKEND_URL));\n return result;\n }\n\n return { trackUsage };\n}\n\nexport function usePricingTable(options: UsePricingTableOptions = {}): UsePricingTableResult {\n const { enabled = true, customerId, pricingTableKey, swr } = options;\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n const fetcher = async (url: string) => {\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n return requestPricingTable(fetch, url, logLevel, bearerToken);\n };\n const key = enabled\n ? buildPricingTableUrl(backendUrl ?? DEFAULT_BACKEND_URL, customerId, pricingTableKey)\n : null;\n const { data, error, isLoading, mutate } = useSWR(\n key,\n fetcher,\n swr\n );\n\n const createCheckoutSession = async (\n body: Omit<CreateCheckoutRequest, \"customerId\"> & { customerId?: string }\n ) => {\n const url = buildCheckoutUrl(backendUrl ?? DEFAULT_BACKEND_URL);\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n const resolvedCustomerId = body.customerId ?? customerId;\n return requestCheckoutSession(\n fetch,\n url,\n {\n ...body,\n ...(resolvedCustomerId ? { customerId: resolvedCustomerId } : {}),\n },\n logLevel,\n bearerToken\n );\n };\n\n return {\n pricingTable: data ?? null,\n error,\n isLoading,\n refetch: async () => {\n await mutate();\n },\n createCheckoutSession,\n };\n}\n\nconst getDisplayPlanPrice = (plan: PricingTablePlan, yearlyBilling: boolean) => {\n if (yearlyBilling) return plan.yearlyPrice ?? plan.monthlyPrice;\n return plan.monthlyPrice ?? plan.yearlyPrice;\n};\n\nconst formatCurrencyAmount = (amount: number, currency: string) =>\n new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: currency.toUpperCase(),\n minimumFractionDigits: 0,\n maximumFractionDigits: 2,\n }).format(amount / 100);\n\nconst getRecurringIntervalLabel = (price: PricingTablePlanPrice): string | null => {\n if (!price.recurringInterval) return null;\n const intervalCount =\n typeof price.recurringIntervalCount === \"number\" && price.recurringIntervalCount > 0\n ? price.recurringIntervalCount\n : 1;\n if (intervalCount === 1) return price.recurringInterval;\n return `${intervalCount} ${price.recurringInterval}s`;\n};\n\nconst getRenderedPriceDisplay = ({\n price,\n pricingDisplay,\n}: {\n price: PricingTablePlanPrice;\n pricingDisplay: \"monthly_terms\" | \"monthly_terms_only\" | \"annual_terms\";\n}) => {\n const currency = typeof price.currency === \"string\" ? price.currency.trim() : \"\";\n const numericUnitAmount = typeof price.unitAmount === \"number\" ? price.unitAmount : null;\n const hasNumericPrice = numericUnitAmount !== null && currency.length > 0;\n\n if (\n (pricingDisplay === \"monthly_terms\" || pricingDisplay === \"monthly_terms_only\") &&\n price.recurringInterval === \"year\" &&\n hasNumericPrice\n ) {\n const intervalCount =\n typeof price.recurringIntervalCount === \"number\" && price.recurringIntervalCount > 0\n ? price.recurringIntervalCount\n : 1;\n const monthlyAmount = Math.round(numericUnitAmount / (intervalCount * 12));\n return {\n amountText: formatCurrencyAmount(monthlyAmount, currency),\n intervalText: \"month\",\n subText:\n pricingDisplay === \"monthly_terms\"\n ? `${formatCurrencyAmount(numericUnitAmount, currency)} billed annually`\n : null,\n };\n }\n\n const slashMatch = price.label.match(/^(.*?)(?:\\s*\\/\\s*|\\s+per\\s+)(day|week|month|year)s?$/i);\n if (slashMatch) {\n return {\n amountText: slashMatch[1].trim(),\n intervalText: slashMatch[2].toLowerCase(),\n subText: null,\n };\n }\n\n return {\n amountText: hasNumericPrice ? formatCurrencyAmount(numericUnitAmount, currency) : price.label,\n intervalText: getRecurringIntervalLabel(price),\n subText: null,\n };\n};\n\nconst normalizeText = (value: string | null | undefined) => {\n if (typeof value !== \"string\") return \"\";\n return value.trim();\n};\n\nconst normalizeHexColor = (value: string | null | undefined): string | null => {\n const normalized = normalizeText(value);\n if (!normalized) return null;\n const match = normalized.match(/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);\n if (!match) return null;\n const hex = match[1].toLowerCase();\n if (hex.length === 3) {\n return `#${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;\n }\n return `#${hex}`;\n};\n\nconst isDarkHexColor = (value: string | null | undefined) => {\n const hex = normalizeHexColor(value);\n if (!hex) return false;\n const r = parseInt(hex.slice(1, 3), 16);\n const g = parseInt(hex.slice(3, 5), 16);\n const b = parseInt(hex.slice(5, 7), 16);\n const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;\n return luminance < 0.5;\n};\n\nconst resolveFontFamily = (fontFamily: string | null | undefined) => {\n if (!fontFamily) return undefined;\n if (fontFamily === \"system\") {\n return \"ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \\\"Segoe UI\\\", sans-serif\";\n }\n if (fontFamily === \"serif\") {\n return \"ui-serif, Georgia, Cambria, \\\"Times New Roman\\\", Times, serif\";\n }\n if (fontFamily === \"mono\") {\n return \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\";\n }\n return fontFamily;\n};\n\nconst getCheckoutUrls = (successUrl?: string, cancelUrl?: string) => {\n if (successUrl) {\n return {\n successUrl,\n cancelUrl: cancelUrl ?? successUrl,\n };\n }\n if (typeof window === \"undefined\") {\n throw new Error(\"successUrl is required when rendering on the server.\");\n }\n const currentUrl = new URL(window.location.href);\n const success = new URL(currentUrl.toString());\n success.searchParams.set(\"checkout\", \"success\");\n const canceled = new URL(currentUrl.toString());\n canceled.searchParams.set(\"checkout\", \"canceled\");\n return {\n successUrl: success.toString(),\n cancelUrl: cancelUrl ?? canceled.toString(),\n };\n};\n\nconst renderFeatureLabel = (feature: PricingTableFeature) => feature.label;\n\nconst PRICING_TABLE_COLUMN_WIDTH = 312;\nconst PRICING_TABLE_GRID_GAP = 8;\nconst PRICING_TABLE_MAX_COLUMNS = 4;\n\nconst getPricingTableGridMaxWidth = (columnCount: number) => {\n const safeCount = Math.max(1, Math.min(columnCount, PRICING_TABLE_MAX_COLUMNS));\n const totalGap = Math.max(0, safeCount - 1) * PRICING_TABLE_GRID_GAP;\n return `${safeCount * PRICING_TABLE_COLUMN_WIDTH + totalGap}px`;\n};\n\nconst pricingTableStyles: Record<string, CSSProperties> = {\n section: {\n display: \"grid\",\n gap: \"1rem\",\n },\n billingToggle: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"0.25rem\",\n padding: \"0.25rem\",\n borderRadius: \"0.625rem\",\n border: \"1px solid rgba(148, 163, 184, 0.35)\",\n backgroundColor: \"rgba(148, 163, 184, 0.12)\",\n width: \"fit-content\",\n marginInline: \"auto\",\n },\n billingToggleButton: {\n appearance: \"none\",\n border: \"none\",\n borderRadius: \"0.45rem\",\n padding: \"0.45rem 1rem\",\n fontSize: \"0.9rem\",\n lineHeight: 1.1,\n fontWeight: 600,\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n color: \"inherit\",\n },\n billingToggleButtonActive: {\n backgroundColor: \"#2563eb\",\n color: \"#fff\",\n },\n error: {\n margin: 0,\n padding: \"0.625rem 0.75rem\",\n borderRadius: \"0.5rem\",\n border: \"1px solid rgba(239, 68, 68, 0.45)\",\n backgroundColor: \"rgba(239, 68, 68, 0.14)\",\n color: \"rgb(248, 113, 113)\",\n },\n planGrid: {\n display: \"grid\",\n gridTemplateColumns: \"repeat(auto-fit, minmax(220px, 1fr))\",\n gap: \"0.5rem\",\n width: \"100%\",\n marginInline: \"auto\",\n },\n planCard: {\n display: \"grid\",\n gap: \"0.75rem\",\n padding: \"1rem\",\n border: \"none\",\n backgroundColor: \"transparent\",\n alignContent: \"start\",\n },\n planCardCurrent: {\n border: \"none\",\n backgroundColor: \"transparent\",\n },\n planCardHighlight: {\n border: \"1px solid rgba(148, 163, 184, 0.35)\",\n borderRadius: \"0.75rem\",\n backgroundColor: \"rgba(148, 163, 184, 0.06)\",\n padding: \"1rem\",\n },\n planPriceBlock: {\n display: \"grid\",\n gap: \"0.25rem\",\n alignContent: \"start\",\n minHeight: \"3.95rem\",\n },\n planPriceRow: {\n display: \"flex\",\n alignItems: \"flex-end\",\n gap: \"0.4rem\",\n lineHeight: 1,\n },\n planPriceAmount: {\n margin: 0,\n fontSize: \"2.25rem\",\n lineHeight: 1,\n fontWeight: 700,\n letterSpacing: \"-0.02em\",\n },\n planPriceInterval: {\n margin: 0,\n fontSize: \"0.8125rem\",\n lineHeight: 1.05,\n opacity: 0.6,\n fontWeight: 400,\n },\n planPriceSubtext: {\n margin: 0,\n fontSize: \"0.8125rem\",\n lineHeight: 1.2,\n opacity: 0.6,\n },\n planTop: {\n display: \"flex\",\n alignItems: \"flex-start\",\n justifyContent: \"space-between\",\n gap: \"0.5rem\",\n },\n planName: {\n margin: 0,\n fontSize: \"1.25rem\",\n fontWeight: 600,\n },\n planDescription: {\n margin: 0,\n fontSize: \"0.95rem\",\n lineHeight: 1.35,\n opacity: 0.78,\n minHeight: \"2.6rem\",\n maxHeight: \"2.6rem\",\n display: \"-webkit-box\",\n WebkitBoxOrient: \"vertical\",\n WebkitLineClamp: 2,\n whiteSpace: \"normal\",\n textOverflow: \"ellipsis\",\n overflow: \"hidden\",\n },\n planPricePlaceholder: {\n height: \"3.95rem\",\n },\n currentPill: {\n fontSize: \"0.75rem\",\n lineHeight: 1,\n fontWeight: 700,\n padding: \"0.3rem 0.45rem\",\n borderRadius: \"999px\",\n border: \"1px solid rgba(59, 130, 246, 0.6)\",\n color: \"rgb(147, 197, 253)\",\n whiteSpace: \"nowrap\",\n },\n highlightPill: {\n display: \"inline-flex\",\n width: \"fit-content\",\n fontSize: \"0.75rem\",\n lineHeight: 1,\n fontWeight: 500,\n padding: \"0.3rem 0.45rem\",\n borderRadius: \"0.35rem\",\n backgroundColor: \"rgba(148, 163, 184, 0.24)\",\n color: \"rgba(15, 23, 42, 0.75)\",\n whiteSpace: \"nowrap\",\n },\n planPrice: {\n margin: 0,\n fontSize: \"1.75rem\",\n lineHeight: 1.15,\n fontWeight: 800,\n },\n planPriceMuted: {\n margin: 0,\n opacity: 0.75,\n },\n ctaButton: {\n appearance: \"none\",\n border: \"none\",\n borderRadius: \"0.625rem\",\n padding: \"0 1rem\",\n height: \"44px\",\n fontWeight: 500,\n fontSize: \"1rem\",\n lineHeight: 1.1,\n cursor: \"pointer\",\n backgroundColor: \"#2563eb\",\n color: \"#fff\",\n width: \"100%\",\n },\n ctaButtonDisabled: {\n cursor: \"not-allowed\",\n opacity: 0.7,\n backgroundColor: \"rgba(148, 163, 184, 0.45)\",\n color: \"inherit\",\n },\n featureSection: {\n display: \"grid\",\n gap: \"0.5rem\",\n },\n featureSubtitle: {\n margin: 0,\n fontSize: \"0.95rem\",\n lineHeight: 1.2,\n fontWeight: 400,\n opacity: 0.65,\n },\n featureList: {\n margin: 0,\n padding: 0,\n listStyle: \"none\",\n display: \"grid\",\n gap: \"0.5rem\",\n opacity: 0.9,\n },\n featureItem: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"0.55rem\",\n lineHeight: 1.35,\n },\n featureCheckIcon: {\n width: 14,\n height: 14,\n borderRadius: \"999px\",\n backgroundColor: \"rgba(15, 23, 42, 0.45)\",\n color: \"#fff\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: \"0.65rem\",\n fontWeight: 700,\n flexShrink: 0,\n marginTop: \"1px\",\n },\n featureText: {\n margin: 0,\n fontSize: \"1rem\",\n },\n watermarkRow: {\n display: \"flex\",\n justifyContent: \"flex-end\",\n marginTop: \"0.25rem\",\n },\n watermarkLink: {\n fontSize: \"0.75rem\",\n lineHeight: 1.2,\n opacity: 0.72,\n textDecoration: \"none\",\n },\n loadingRoot: {\n display: \"grid\",\n gap: \"1rem\",\n },\n loadingShell: {\n padding: \"1.75rem 1.5rem\",\n },\n loadingGrid: {\n display: \"grid\",\n gridTemplateColumns: \"repeat(auto-fit, minmax(220px, 1fr))\",\n gap: \"0.5rem\",\n width: \"100%\",\n marginInline: \"auto\",\n },\n loadingCard: {\n display: \"grid\",\n gap: \"0.7rem\",\n alignContent: \"start\",\n },\n loadingPulse: {\n backgroundColor: \"#dfe3e8\",\n animation: \"priceosPricingSkeletonPulse 1.3s ease-in-out infinite\",\n },\n loadingHero: {\n width: \"74%\",\n maxWidth: 180,\n height: 120,\n borderRadius: \"0.4rem\",\n },\n loadingHeadline: {\n width: \"50%\",\n height: 24,\n borderRadius: \"0.35rem\",\n marginTop: \"0.25rem\",\n },\n loadingLine: {\n width: \"100%\",\n height: 16,\n borderRadius: \"0.35rem\",\n },\n loadingCta: {\n width: \"100%\",\n height: 44,\n borderRadius: \"0.45rem\",\n marginTop: \"1rem\",\n },\n};\n\nconst renderDefaultPricingTableLoading = (className?: string) => {\n const cards = Array.from({ length: 3 }).map((_, index) =>\n createElement(\n \"div\",\n { key: index, style: pricingTableStyles.loadingCard },\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingHero,\n },\n }),\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingHeadline,\n },\n }),\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingLine,\n },\n }),\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingLine,\n },\n }),\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingCta,\n },\n }),\n ),\n );\n const loadingGridStyle: CSSProperties = {\n ...pricingTableStyles.loadingGrid,\n maxWidth: getPricingTableGridMaxWidth(cards.length),\n };\n\n return createElement(\n \"div\",\n { className, style: pricingTableStyles.loadingRoot },\n createElement(\"style\", {\n dangerouslySetInnerHTML: {\n __html:\n \"@keyframes priceosPricingSkeletonPulse { 0% { opacity: 0.82; } 50% { opacity: 1; } 100% { opacity: 0.82; } }\",\n },\n }),\n createElement(\n \"div\",\n { style: pricingTableStyles.loadingShell },\n createElement(\"div\", { style: loadingGridStyle }, ...cards),\n ),\n );\n};\n\nexport function PricingTableView({\n pricingTable,\n isLoading = false,\n error = null,\n className,\n yearlyLabel = \"Save with yearly billing\",\n loadingFallback,\n errorFallback,\n emptyFallback,\n onCheckout,\n onCustomCtaClick,\n}: PricingTableViewProps) {\n const [yearlyBilling, setYearlyBilling] = useState(true);\n const [checkoutPriceId, setCheckoutPriceId] = useState<string | null>(null);\n const [checkoutError, setCheckoutError] = useState<string | null>(null);\n\n const plans = pricingTable?.plans ?? [];\n const planGridStyle: CSSProperties = {\n ...pricingTableStyles.planGrid,\n maxWidth: getPricingTableGridMaxWidth(plans.length),\n };\n const tableSettings = pricingTable?.table?.settings;\n const currentPriceIdSet = new Set(pricingTable?.customer?.currentPriceIds ?? []);\n const currentProductIdSet = new Set(pricingTable?.customer?.currentProductIds ?? []);\n const hasMonthly = plans.some((plan) => Boolean(plan.monthlyPrice));\n const hasYearly = plans.some((plan) => Boolean(plan.yearlyPrice));\n const showBillingToggle = hasMonthly && hasYearly;\n const isPlanCurrentByAnySelection = (plan: PricingTablePlan) => {\n return (\n currentProductIdSet.has(plan.productId) ||\n (typeof plan.monthlyPrice?.stripePriceId === \"string\" &&\n currentPriceIdSet.has(plan.monthlyPrice.stripePriceId)) ||\n (typeof plan.yearlyPrice?.stripePriceId === \"string\" &&\n currentPriceIdSet.has(plan.yearlyPrice.stripePriceId)) ||\n plan.isCurrent === true\n );\n };\n const hasCurrentMonthlyPrice = plans.some((plan) => {\n const priceId = plan.monthlyPrice?.stripePriceId;\n return typeof priceId === \"string\" && currentPriceIdSet.has(priceId);\n });\n const hasCurrentYearlyPrice = plans.some((plan) => {\n const priceId = plan.yearlyPrice?.stripePriceId;\n return typeof priceId === \"string\" && currentPriceIdSet.has(priceId);\n });\n const isPlanCurrentForBillingView = (plan: PricingTablePlan, billingYearly: boolean) => {\n const displayPrice = getDisplayPlanPrice(plan, billingYearly);\n const displayPriceId =\n typeof displayPrice?.stripePriceId === \"string\" ? displayPrice.stripePriceId : null;\n const hasMonthlyAndYearly = Boolean(plan.monthlyPrice && plan.yearlyPrice);\n const currentByDisplayedPrice = Boolean(displayPriceId && currentPriceIdSet.has(displayPriceId));\n if (hasMonthlyAndYearly) return currentByDisplayedPrice;\n\n return currentByDisplayedPrice || isPlanCurrentByAnySelection(plan);\n };\n const rawPricingDisplay =\n (tableSettings as { pricingDisplay?: unknown } | undefined)?.pricingDisplay;\n const pricingDisplay: \"monthly_terms\" | \"monthly_terms_only\" | \"annual_terms\" =\n rawPricingDisplay === \"annual_terms\"\n ? \"annual_terms\"\n : rawPricingDisplay === \"monthly_terms_only\"\n ? \"monthly_terms_only\"\n : \"monthly_terms\";\n const resolvedHighlightProductId =\n typeof (tableSettings as { highlightProductId?: unknown } | undefined)?.highlightProductId === \"string\"\n ? ((tableSettings as { highlightProductId?: string }).highlightProductId ?? \"\").trim()\n : \"\";\n const resolvedHighlightLabel = (() => {\n const raw =\n typeof (tableSettings as { highlightLabel?: unknown } | undefined)?.highlightLabel === \"string\"\n ? ((tableSettings as { highlightLabel?: string }).highlightLabel ?? \"\").trim()\n : \"\";\n return raw.length ? raw : \"Most popular\";\n })();\n const defaultFeaturesSubheader = (() => {\n const raw =\n typeof (tableSettings as { featuresSubheader?: unknown } | undefined)?.featuresSubheader === \"string\"\n ? ((tableSettings as { featuresSubheader?: string }).featuresSubheader ?? \"\").trim()\n : \"\";\n return raw.length ? raw : \"This includes:\";\n })();\n const highlightPlanId = tableSettings?.highlightProduct\n ? (resolvedHighlightProductId || plans[Math.floor((plans.length - 1) / 2)]?.productId || null)\n : null;\n const shouldReserveHighlightRow = Boolean(\n highlightPlanId &&\n plans.some((plan) => plan.productId === highlightPlanId && !isPlanCurrentForBillingView(plan, yearlyBilling)),\n );\n const currentPlanIndexByProduct = plans.findIndex((plan) => isPlanCurrentByAnySelection(plan));\n\n useEffect(() => {\n if (hasCurrentMonthlyPrice && !hasCurrentYearlyPrice) {\n setYearlyBilling(false);\n return;\n }\n if (hasCurrentYearlyPrice && !hasCurrentMonthlyPrice) {\n setYearlyBilling(true);\n return;\n }\n if (!hasMonthly && hasYearly) {\n setYearlyBilling(true);\n return;\n }\n if (hasMonthly && !hasYearly) {\n setYearlyBilling(false);\n return;\n }\n if (tableSettings?.defaultView === \"monthly\") {\n setYearlyBilling(false);\n return;\n }\n if (tableSettings?.defaultView === \"yearly\") {\n setYearlyBilling(true);\n }\n }, [hasCurrentMonthlyPrice, hasCurrentYearlyPrice, hasMonthly, hasYearly, tableSettings?.defaultView]);\n\n const buttonRadius =\n tableSettings?.buttonShape === \"square\"\n ? \"0.35rem\"\n : tableSettings?.buttonShape === \"pill\"\n ? \"999px\"\n : pricingTableStyles.ctaButton.borderRadius;\n const hasBackgroundColor = normalizeHexColor(tableSettings?.backgroundColor) !== null;\n const darkBackground = isDarkHexColor(tableSettings?.backgroundColor);\n const sectionTextColor = hasBackgroundColor ? (darkBackground ? \"#f8fafc\" : \"#0f172a\") : null;\n const mutedTextColor = hasBackgroundColor\n ? darkBackground\n ? \"rgba(248, 250, 252, 0.72)\"\n : \"rgba(15, 23, 42, 0.72)\"\n : null;\n const resolvedFontFamily = resolveFontFamily(tableSettings?.fontFamily);\n const sectionStyle: CSSProperties = {\n ...pricingTableStyles.section,\n ...(tableSettings?.backgroundColor\n ? {\n backgroundColor: tableSettings.backgroundColor,\n padding: \"1rem\",\n }\n : {}),\n ...(sectionTextColor ? { color: sectionTextColor } : {}),\n ...(resolvedFontFamily ? { fontFamily: resolvedFontFamily } : {}),\n };\n const ctaAccentColor = tableSettings?.buttonColor || \"#2563eb\";\n const ctaTextColor = isDarkHexColor(ctaAccentColor) ? \"#ffffff\" : \"#0f172a\";\n const buttonStyle: CSSProperties = {\n ...pricingTableStyles.ctaButton,\n backgroundColor: ctaAccentColor,\n color: ctaTextColor,\n ...(buttonRadius ? { borderRadius: buttonRadius } : {}),\n };\n const billingToggleButtonActiveStyle: CSSProperties = {\n ...pricingTableStyles.billingToggleButtonActive,\n backgroundColor: ctaAccentColor,\n color: ctaTextColor,\n };\n const outlinedButtonStyle: CSSProperties = {\n ...buttonStyle,\n border: `1px solid ${ctaAccentColor}`,\n backgroundColor: \"transparent\",\n color: ctaAccentColor,\n };\n const disabledButtonStyle: CSSProperties = {\n ...pricingTableStyles.ctaButtonDisabled,\n ...(mutedTextColor ? { color: mutedTextColor } : {}),\n };\n const outlinedDisabledButtonStyle: CSSProperties = {\n ...outlinedButtonStyle,\n ...disabledButtonStyle,\n backgroundColor: \"transparent\",\n borderColor: mutedTextColor || ctaAccentColor,\n };\n const outlinedCustomActionDisabledButtonStyle: CSSProperties = {\n ...outlinedDisabledButtonStyle,\n borderColor: ctaAccentColor,\n color: ctaAccentColor,\n };\n const priceAmountStyle: CSSProperties = {\n ...pricingTableStyles.planPriceAmount,\n ...(sectionTextColor ? { color: sectionTextColor } : {}),\n };\n const priceIntervalStyle: CSSProperties = {\n ...pricingTableStyles.planPriceInterval,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n const priceSubtextStyle: CSSProperties = {\n ...pricingTableStyles.planPriceSubtext,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n const planDescriptionStyle: CSSProperties = {\n ...pricingTableStyles.planDescription,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n const featureSubtitleStyle: CSSProperties = {\n ...pricingTableStyles.featureSubtitle,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n const featureTextStyle: CSSProperties = {\n ...pricingTableStyles.featureText,\n ...(sectionTextColor ? { color: sectionTextColor } : {}),\n };\n const featureCheckStyle: CSSProperties = {\n ...pricingTableStyles.featureCheckIcon,\n ...(darkBackground\n ? { backgroundColor: \"rgba(248, 250, 252, 0.4)\", color: \"#0f172a\" }\n : {}),\n };\n const highlightPillStyle: CSSProperties = {\n ...pricingTableStyles.highlightPill,\n ...(darkBackground\n ? {\n backgroundColor: \"rgba(148, 163, 184, 0.18)\",\n color: \"rgba(226, 232, 240, 0.92)\",\n border: \"1px solid rgba(148, 163, 184, 0.32)\",\n }\n : {}),\n };\n const currentPillStyle: CSSProperties = {\n ...pricingTableStyles.currentPill,\n backgroundColor: ctaAccentColor,\n color: ctaTextColor,\n border: \"none\",\n };\n const watermarkLinkStyle: CSSProperties = {\n ...pricingTableStyles.watermarkLink,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n\n if (isLoading) {\n return loadingFallback ? createElement(\"div\", { className }, loadingFallback) : renderDefaultPricingTableLoading(className);\n }\n\n if (error) {\n return createElement(\n \"div\",\n { className },\n errorFallback ??\n createElement(\"p\", { role: \"alert\" }, error.message || \"Failed to load pricing table.\")\n );\n }\n\n if (!plans.length) {\n return createElement(\n \"div\",\n { className },\n emptyFallback ?? createElement(\"p\", null, \"No plans available.\")\n );\n }\n\n return createElement(\n \"section\",\n { className, style: sectionStyle },\n showBillingToggle\n ? createElement(\n \"div\",\n { style: pricingTableStyles.billingToggle, role: \"tablist\", \"aria-label\": yearlyLabel || \"Billing interval\" },\n createElement(\n \"button\",\n {\n type: \"button\",\n role: \"tab\",\n \"aria-selected\": !yearlyBilling,\n style: !yearlyBilling\n ? { ...pricingTableStyles.billingToggleButton, ...billingToggleButtonActiveStyle }\n : pricingTableStyles.billingToggleButton,\n onClick: () => setYearlyBilling(false),\n },\n \"Monthly\"\n ),\n createElement(\n \"button\",\n {\n type: \"button\",\n role: \"tab\",\n \"aria-selected\": yearlyBilling,\n style: yearlyBilling\n ? { ...pricingTableStyles.billingToggleButton, ...billingToggleButtonActiveStyle }\n : pricingTableStyles.billingToggleButton,\n onClick: () => setYearlyBilling(true),\n },\n \"Yearly\"\n )\n )\n : null,\n checkoutError\n ? createElement(\"p\", { role: \"alert\", style: pricingTableStyles.error }, checkoutError)\n : null,\n createElement(\n \"div\",\n { style: planGridStyle },\n ...plans.map((plan, planIndex) => {\n const planDescriptionRaw = (plan as { description?: unknown }).description;\n const planDescription =\n typeof planDescriptionRaw === \"string\" && planDescriptionRaw.trim().length > 0\n ? planDescriptionRaw.trim()\n : \"\";\n const customCtaRaw = (plan as { customCta?: unknown }).customCta;\n const customCtaObject =\n customCtaRaw && typeof customCtaRaw === \"object\" && !Array.isArray(customCtaRaw)\n ? (customCtaRaw as { buttonAction?: unknown; buttonText?: unknown; linkUrl?: unknown })\n : null;\n const customCtaButtonAction: \"stripe_checkout\" | \"custom_url\" | undefined =\n customCtaObject?.buttonAction === \"stripe_checkout\" ||\n customCtaObject?.buttonAction === \"custom_url\"\n ? customCtaObject.buttonAction\n : undefined;\n const customCta = customCtaObject\n ? {\n ...(customCtaButtonAction ? { buttonAction: customCtaButtonAction } : {}),\n ...(typeof customCtaObject.buttonText === \"string\" &&\n customCtaObject.buttonText.trim().length > 0\n ? { buttonText: customCtaObject.buttonText.trim() }\n : {}),\n ...(typeof customCtaObject.linkUrl === \"string\" &&\n customCtaObject.linkUrl.trim().length > 0\n ? { linkUrl: customCtaObject.linkUrl.trim() }\n : {}),\n }\n : null;\n const hasCustomCta = Boolean(customCtaRaw);\n const customButtonText = customCta?.buttonText || \"Choose plan\";\n const hasCustomLink = Boolean(customCta?.linkUrl);\n const customButtonAction =\n customCta?.buttonAction === \"custom_url\"\n ? \"custom_url\"\n : customCta?.buttonAction === \"stripe_checkout\"\n ? \"stripe_checkout\"\n : null;\n const displayPrice = getDisplayPlanPrice(plan, yearlyBilling);\n const isSyntheticPriceId =\n typeof displayPrice?.stripePriceId === \"string\" &&\n (displayPrice.stripePriceId.startsWith(\"custom_text_\") ||\n displayPrice.stripePriceId.startsWith(\"preview-custom-price-text-\"));\n const usesCustomCtaAction =\n customButtonAction === \"custom_url\" || !displayPrice || hasCustomLink;\n const usesCustomAction = usesCustomCtaAction || isSyntheticPriceId;\n const renderedPrice = displayPrice\n ? getRenderedPriceDisplay({ price: displayPrice, pricingDisplay })\n : null;\n const isCurrent = isPlanCurrentForBillingView(plan, yearlyBilling);\n const isDowngrade = currentPlanIndexByProduct >= 0 && planIndex < currentPlanIndexByProduct && !isCurrent;\n const isOpeningCheckout = checkoutPriceId === displayPrice?.stripePriceId;\n const checkoutDisabled = !onCheckout;\n const canHandleNoLinkCustomAction = Boolean(onCustomCtaClick);\n const isDisabled = usesCustomAction\n ? isCurrent || checkoutPriceId !== null || (!hasCustomLink && !canHandleNoLinkCustomAction)\n : isCurrent || !displayPrice || checkoutPriceId !== null || checkoutDisabled;\n const buttonLabel = isCurrent\n ? \"Current plan\"\n : isOpeningCheckout\n ? \"Opening checkout...\"\n : isDowngrade\n ? \"Downgrade\"\n : hasCustomCta\n ? customButtonText\n : displayPrice?.stripePriceId\n ? \"Subscribe\"\n : \"Choose plan\";\n const planFeaturesSubheaderRaw = (plan as { featuresSubheader?: unknown }).featuresSubheader;\n const resolvedPlanFeaturesSubheader =\n typeof planFeaturesSubheaderRaw === \"string\"\n ? planFeaturesSubheaderRaw.trim()\n : defaultFeaturesSubheader;\n const showPlanFeaturesSubheader = resolvedPlanFeaturesSubheader.length > 0;\n const isHighlighted = highlightPlanId === plan.productId && !isCurrent;\n const useOutlinedButton = Boolean(highlightPlanId) && plan.productId !== highlightPlanId;\n const resolvedButtonStyle = useOutlinedButton ? outlinedButtonStyle : buttonStyle;\n const resolvedDisabledButtonStyle = useOutlinedButton\n ? usesCustomAction\n ? outlinedCustomActionDisabledButtonStyle\n : outlinedDisabledButtonStyle\n : disabledButtonStyle;\n\n return createElement(\n \"article\",\n {\n key: plan.productId,\n style: isCurrent\n ? { ...pricingTableStyles.planCard, ...pricingTableStyles.planCardCurrent }\n : isHighlighted\n ? { ...pricingTableStyles.planCard, ...pricingTableStyles.planCardHighlight }\n : pricingTableStyles.planCard,\n },\n createElement(\n \"div\",\n { style: pricingTableStyles.planTop },\n createElement(\n \"div\",\n { style: { display: \"grid\", gap: \"0.45rem\" } },\n shouldReserveHighlightRow\n ? isHighlighted\n ? createElement(\"span\", { style: highlightPillStyle }, resolvedHighlightLabel)\n : createElement(\n \"span\",\n {\n \"aria-hidden\": true,\n style: { ...highlightPillStyle, visibility: \"hidden\" },\n },\n resolvedHighlightLabel\n )\n : null,\n createElement(\"h4\", { style: pricingTableStyles.planName }, plan.name),\n createElement(\n \"p\",\n { style: planDescriptionStyle },\n planDescription || \"\\u00a0\"\n )\n ),\n isCurrent ? createElement(\"span\", { style: currentPillStyle }, \"Current\") : null\n ),\n displayPrice && renderedPrice\n ? createElement(\n \"div\",\n { style: pricingTableStyles.planPriceBlock },\n createElement(\n \"div\",\n { style: pricingTableStyles.planPriceRow },\n createElement(\"p\", { style: priceAmountStyle }, renderedPrice.amountText),\n renderedPrice.intervalText\n ? createElement(\n \"p\",\n { style: priceIntervalStyle },\n \"per \",\n createElement(\"br\"),\n renderedPrice.intervalText\n )\n : null\n ),\n renderedPrice.subText\n ? createElement(\"p\", { style: priceSubtextStyle }, renderedPrice.subText)\n : null\n )\n : createElement(\"div\", { \"aria-hidden\": true, style: pricingTableStyles.planPricePlaceholder }),\n createElement(\n \"button\",\n {\n type: \"button\",\n disabled: isDisabled,\n style: isDisabled\n ? { ...resolvedButtonStyle, ...resolvedDisabledButtonStyle }\n : resolvedButtonStyle,\n onClick: () => {\n if (usesCustomAction) {\n if (isCurrent || checkoutPriceId !== null) return;\n const runCustomAction = async () => {\n if (!onCustomCtaClick) return;\n setCheckoutError(null);\n try {\n await onCustomCtaClick({ plan, customCta: customCta ?? {} });\n } catch (customActionError) {\n setCheckoutError(\n customActionError instanceof Error\n ? customActionError.message\n : \"Failed to perform action.\"\n );\n }\n };\n if (isDowngrade && onCustomCtaClick) {\n void runCustomAction();\n return;\n }\n if (typeof window !== \"undefined\" && customCta?.linkUrl) {\n window.location.assign(customCta.linkUrl);\n return;\n }\n if (onCustomCtaClick) {\n void runCustomAction();\n return;\n }\n return;\n }\n if (!displayPrice || isCurrent || checkoutPriceId !== null || !onCheckout) return;\n const run = async () => {\n setCheckoutError(null);\n setCheckoutPriceId(displayPrice.stripePriceId);\n try {\n await onCheckout({ plan, price: displayPrice });\n } catch (checkoutSessionError) {\n setCheckoutError(\n checkoutSessionError instanceof Error\n ? checkoutSessionError.message\n : \"Failed to start checkout.\"\n );\n } finally {\n setCheckoutPriceId(null);\n }\n };\n void run();\n },\n },\n buttonLabel\n ),\n createElement(\n \"div\",\n { style: pricingTableStyles.featureSection },\n plan.features.length && showPlanFeaturesSubheader\n ? createElement(\"p\", { style: featureSubtitleStyle }, resolvedPlanFeaturesSubheader)\n : null,\n createElement(\n \"ul\",\n { style: pricingTableStyles.featureList },\n ...plan.features.map((feature) =>\n createElement(\n \"li\",\n {\n key: `${plan.productId}:${feature.featureKey}`,\n style: pricingTableStyles.featureItem,\n },\n createElement(\"span\", { \"aria-hidden\": true, style: featureCheckStyle }, \"\\u2713\"),\n createElement(\"span\", { style: featureTextStyle }, renderFeatureLabel(feature))\n )\n )\n )\n )\n );\n })\n ),\n createElement(\n \"div\",\n { style: pricingTableStyles.watermarkRow },\n createElement(\n \"a\",\n {\n href: \"https://priceos.com\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n style: watermarkLinkStyle,\n },\n \"Powered by PriceOS\"\n )\n )\n );\n}\n\nexport function PriceOSPricingTable({\n customerId,\n pricingTableKey,\n className,\n yearlyLabel = \"Save with yearly billing\",\n successUrl,\n cancelUrl,\n loadingFallback,\n errorFallback,\n emptyFallback,\n onCustomCtaClick,\n}: PriceOSPricingTableProps) {\n const { pricingTable, isLoading, error, createCheckoutSession } = usePricingTable({\n customerId,\n pricingTableKey,\n });\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n\n const onCheckout = async ({ price }: { plan: PricingTablePlan; price: PricingTablePlanPrice }) => {\n const urls = getCheckoutUrls(successUrl, cancelUrl);\n const response = await createCheckoutSession({\n stripePriceId: price.stripePriceId,\n successUrl: urls.successUrl,\n cancelUrl: urls.cancelUrl,\n });\n if (typeof window !== \"undefined\") {\n window.location.assign(response.url);\n }\n };\n const handleCustomCtaClick = onCustomCtaClick\n ? onCustomCtaClick\n : async () => {\n const url = buildBillingPortalUrl(backendUrl ?? DEFAULT_BACKEND_URL);\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n const returnUrl = typeof window !== \"undefined\" ? window.location.href : undefined;\n const response = await requestBillingPortalSession(\n fetch,\n url,\n {\n ...(customerId ? { customerId } : {}),\n ...(returnUrl ? { returnUrl } : {}),\n },\n logLevel,\n bearerToken\n );\n if (typeof window !== \"undefined\") {\n window.location.assign(response.url);\n }\n };\n\n return createElement(PricingTableView, {\n pricingTable,\n isLoading,\n error,\n className,\n yearlyLabel,\n loadingFallback,\n errorFallback,\n emptyFallback,\n onCheckout,\n onCustomCtaClick: handleCustomCtaClick,\n });\n}\n\nexport const PricingTable = PriceOSPricingTable;\n"],"mappings":";AAAA,SAAS,eAAe,eAAe,YAAY,WAAW,gBAAoD;AAClH,OAAO,UAAU,oBAA2C;AAwJ5D,IAAM,sBAAsB;AAC5B,IAAM,oBAAqC;AAC3C,IAAM,iBAAmE;AAAA,EACvE,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AACA,IAAM,aAAa;AAQnB,IAAM,iBAAiB,cAAmC,CAAC,CAAC;AAE5D,IAAM,mBAAmB,CAAC,YAAoB,QAAQ,QAAQ,OAAO,EAAE;AAEvE,IAAM,WAAW,CAAC,eAAuB;AACvC,QAAM,iBAAiB,iBAAiB,UAAU;AAClD,SAAO,GAAG,cAAc;AAC1B;AAEA,IAAM,wBAAwB,CAAC,eAAuB;AACpD,QAAM,iBAAiB,iBAAiB,UAAU;AAClD,SAAO,GAAG,cAAc;AAC1B;AAEA,IAAM,uBAAuB,CAC3B,YACA,YACA,oBACG;AACH,QAAM,iBAAiB,iBAAiB,UAAU;AAClD,QAAM,SAAS,IAAI,gBAAgB;AACnC,MAAI,cAAc,WAAW,KAAK,EAAE,SAAS,GAAG;AAC9C,WAAO,IAAI,cAAc,WAAW,KAAK,CAAC;AAAA,EAC5C;AACA,MAAI,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pB,CAAC;AACH;AAEO,IAAM,eAAe;","names":["error"]}
1
+ {"version":3,"sources":["../src/react.ts"],"sourcesContent":["import { createContext, createElement, useContext, useEffect, useState, type CSSProperties, type ReactNode } from \"react\";\nimport useSWR, { useSWRConfig, type SWRConfiguration } from \"swr\";\nimport type {\n CreateCheckoutRequest,\n CreateCustomerCheckoutRequest,\n CreateCustomerCheckoutResponse,\n CreateCustomerPortalResponse,\n GetFeatureAccessResponse,\n GetPricingTableResponse,\n PricingTableFeature,\n PricingTablePlan,\n LimitFeatureKeyFromAccessMap,\n PriceOSCustomer,\n TrackUsageBody,\n TrackUsageResponse,\n} from \"./types\";\n\nexport type PriceOsCustomer<TFeatureAccessMap = GetFeatureAccessResponse> =\n PriceOSCustomer<TFeatureAccessMap>;\nexport type { PriceOSCustomer } from \"./types\";\nexport type {\n PricingTablePlan,\n PricingTableFeature,\n GetPricingTableResponse as PriceOSPricingTableData,\n} from \"./types\";\n\nexport type PriceOsTrackUsageBody<TFeatureAccessMap = GetFeatureAccessResponse> = Omit<\n TrackUsageBody<LimitFeatureKeyFromAccessMap<TFeatureAccessMap>>,\n \"customerId\" | \"amount\"\n> & {\n amount?: number;\n};\n\nexport type PriceOsTrackUsageFn<TFeatureAccessMap = GetFeatureAccessResponse> = {\n (\n featureKey: LimitFeatureKeyFromAccessMap<TFeatureAccessMap>\n ): Promise<TrackUsageResponse>;\n (body: PriceOsTrackUsageBody<TFeatureAccessMap>): Promise<TrackUsageResponse>;\n};\n\nexport type PriceOSLogLevel = \"none\" | \"error\" | \"warn\" | \"info\" | \"debug\";\n\nexport type UseCustomerOptions<TFeatureAccessMap = GetFeatureAccessResponse> = {\n enabled?: boolean;\n errorOnNotFound?: boolean;\n swr?: SWRConfiguration<PriceOSCustomer<TFeatureAccessMap> | null, Error>;\n};\n\nexport type UseFeatureAccessOptions<TFeatureAccessMap = GetFeatureAccessResponse> = {\n enabled?: boolean;\n errorOnNotFound?: boolean;\n swr?: SWRConfiguration<TFeatureAccessMap | null, Error>;\n};\n\nexport type UsePricingTableOptions = {\n enabled?: boolean;\n pricingTableKey?: string;\n swr?: SWRConfiguration<GetPricingTableResponse | null, Error>;\n};\n\nexport type UseCheckoutOptions = {\n customerId?: string;\n};\n\nexport type UseCustomerPortalOptions = {\n customerId?: string;\n};\n\nexport type PriceOSProviderProps = {\n children: ReactNode;\n getBearerToken?: () => Promise<string | null | undefined>;\n backendUrl?: string;\n logLevel?: PriceOSLogLevel;\n};\n\nexport type UseCustomerResult<TFeatureAccessMap = GetFeatureAccessResponse> = {\n customer: PriceOSCustomer<TFeatureAccessMap> | null;\n error: Error | null;\n isLoading: boolean;\n refetch: () => Promise<void>;\n trackUsage: (body: PriceOsTrackUsageBody<TFeatureAccessMap>) => Promise<TrackUsageResponse>;\n};\n\nexport type UseFeatureAccessResult<TFeatureAccessMap = GetFeatureAccessResponse> = {\n featureAccess: TFeatureAccessMap | null;\n error: Error | null;\n isLoading: boolean;\n refetch: () => Promise<void>;\n};\n\ntype FeatureAccessRecord<TFeatureAccessMap> =\n NonNullable<TFeatureAccessMap> extends Record<string, unknown>\n ? NonNullable<TFeatureAccessMap>\n : Record<string, never>;\n\ntype FeatureAccessKey<TFeatureAccessMap> = keyof FeatureAccessRecord<TFeatureAccessMap> & string;\n\nexport type UseFeatureAccessByKeyResult<\n TFeatureAccessMap = GetFeatureAccessResponse,\n TFeatureKey extends keyof FeatureAccessRecord<TFeatureAccessMap> & string =\n keyof FeatureAccessRecord<TFeatureAccessMap> & string\n> = Partial<FeatureAccessRecord<TFeatureAccessMap>[TFeatureKey]> & {\n error: Error | null;\n isLoading: boolean;\n refetch: () => Promise<void>;\n};\n\nexport type UseTrackUsageResult<TFeatureAccessMap = GetFeatureAccessResponse> = {\n trackUsage: PriceOsTrackUsageFn<TFeatureAccessMap>;\n};\n\ntype CreateCheckoutBody = Omit<CreateCustomerCheckoutRequest, \"checkoutParams\"> & {\n stripePriceId?: CreateCheckoutRequest[\"stripePriceId\"];\n customerId?: string;\n cancelUrl?: string;\n metadata?: Record<string, string>;\n checkoutParams?: Record<string, unknown>;\n};\n\nexport type UsePricingTableResult = {\n pricingTable: GetPricingTableResponse | null;\n error: Error | null;\n isLoading: boolean;\n refetch: () => Promise<void>;\n createCheckoutSession: (body: CreateCheckoutBody) => Promise<CreateCustomerCheckoutResponse>;\n};\n\nexport type UseCheckoutResult = {\n createCheckoutSession: (body: CreateCheckoutBody) => Promise<CreateCustomerCheckoutResponse>;\n openCheckout: (body: CreateCheckoutBody) => Promise<CreateCustomerCheckoutResponse>;\n};\n\nexport type UseCustomerPortalResult = {\n createCustomerPortalSession: (body?: { customerId?: string }) => Promise<CreateCustomerPortalResponse>;\n openCustomerPortal: (body?: { customerId?: string }) => Promise<CreateCustomerPortalResponse>;\n};\n\nexport type PriceOSPricingTableProps = {\n pricingTableKey?: string;\n className?: string;\n yearlyLabel?: string;\n successUrl?: string;\n cancelUrl?: string;\n loadingFallback?: ReactNode;\n errorFallback?: ReactNode;\n emptyFallback?: ReactNode;\n onCustomCtaClick?: (input: {\n plan: PricingTablePlan;\n customCta: { buttonAction?: \"stripe_checkout\" | \"custom_url\"; buttonText?: string; linkUrl?: string };\n }) => void | Promise<void>;\n};\n\ntype PricingTablePlanPrice = NonNullable<PricingTablePlan[\"monthlyPrice\"] | PricingTablePlan[\"yearlyPrice\"]>;\ntype CreateCustomerPortalSessionBody = {\n customerId?: string;\n};\n\nexport type PricingTableViewProps = {\n pricingTable: GetPricingTableResponse | null;\n isLoading?: boolean;\n error?: Error | null;\n className?: string;\n yearlyLabel?: string;\n loadingFallback?: ReactNode;\n errorFallback?: ReactNode;\n emptyFallback?: ReactNode;\n onCheckout?: (input: { plan: PricingTablePlan; price: PricingTablePlanPrice }) => Promise<void>;\n onCustomCtaClick?: (input: {\n plan: PricingTablePlan;\n customCta: { buttonAction?: \"stripe_checkout\" | \"custom_url\"; buttonText?: string; linkUrl?: string };\n }) => void | Promise<void>;\n};\n\nconst DEFAULT_BACKEND_URL = \"/api/priceos\";\nconst DEFAULT_LOG_LEVEL: PriceOSLogLevel = \"error\";\nconst LOG_LEVEL_RANK: Record<Exclude<PriceOSLogLevel, \"none\">, number> = {\n error: 0,\n warn: 1,\n info: 2,\n debug: 3,\n};\nconst LOG_PREFIX = \"[priceos/react]\";\n\ntype PriceOSContextValue = {\n getBearerToken?: () => Promise<string | null | undefined>;\n backendUrl?: string;\n logLevel?: PriceOSLogLevel;\n};\n\nconst PriceOSContext = createContext<PriceOSContextValue>({});\n\nconst normalizeBaseUrl = (baseUrl: string) => baseUrl.replace(/\\/$/, \"\");\n\nconst buildUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/customer`;\n};\n\nconst buildFeatureAccessUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/feature-access`;\n};\n\nconst buildPricingTableUrl = (backendUrl: string, pricingTableKey?: string | null) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n const params = new URLSearchParams();\n if (pricingTableKey && pricingTableKey.trim().length > 0) {\n params.set(\"pricingTableKey\", pricingTableKey.trim());\n }\n const queryString = params.toString();\n return `${normalizedBase}/v1/pricing-table${queryString ? `?${queryString}` : \"\"}`;\n};\n\nconst buildCheckoutUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/checkout`;\n};\n\nconst buildCustomerPortalUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/customer-portal`;\n};\n\nconst buildTrackUsageUrl = (backendUrl: string) => {\n const normalizedBase = normalizeBaseUrl(backendUrl);\n return `${normalizedBase}/v1/usage`;\n};\n\nconst resolveIdempotencyKey = (body: { idempotencyKey?: string }) => {\n const providedIdempotencyKey =\n typeof body.idempotencyKey === \"string\"\n ? String(body.idempotencyKey).trim()\n : \"\";\n return providedIdempotencyKey;\n};\n\nconst normalizeTrackUsageInput = <TFeatureAccessMap = GetFeatureAccessResponse>(\n input: PriceOsTrackUsageBody<TFeatureAccessMap> | LimitFeatureKeyFromAccessMap<TFeatureAccessMap>\n): PriceOsTrackUsageBody<TFeatureAccessMap> => {\n if (typeof input === \"string\") {\n return { featureKey: input as LimitFeatureKeyFromAccessMap<TFeatureAccessMap> };\n }\n return input;\n};\n\nconst shouldLog = (currentLevel: PriceOSLogLevel, targetLevel: Exclude<PriceOSLogLevel, \"none\">) => {\n if (currentLevel === \"none\") return false;\n return LOG_LEVEL_RANK[targetLevel] <= LOG_LEVEL_RANK[currentLevel];\n};\n\nconst logMessage = (\n currentLevel: PriceOSLogLevel,\n level: Exclude<PriceOSLogLevel, \"none\">,\n message: string,\n details?: unknown\n) => {\n if (!shouldLog(currentLevel, level)) return;\n const logger =\n level === \"error\" ? console.error : level === \"warn\" ? console.warn : console.info;\n if (details === undefined) {\n logger(LOG_PREFIX, message);\n return;\n }\n logger(LOG_PREFIX, message, details);\n};\n\nconst requestCustomer = async <TFeatureAccessMap = GetFeatureAccessResponse>(\n fetchFn: typeof fetch,\n url: string,\n logLevel: PriceOSLogLevel,\n errorOnNotFound: boolean,\n bearerToken?: string | null\n): Promise<PriceOSCustomer<TFeatureAccessMap> | null> => {\n logMessage(logLevel, \"debug\", \"Requesting customer\", { url, hasBearerToken: Boolean(bearerToken) });\n const headers = bearerToken ? { Authorization: `Bearer ${bearerToken}` } : undefined;\n const response = await fetchFn(url, headers ? { headers } : undefined);\n logMessage(logLevel, \"info\", \"Customer request completed\", { url, status: response.status });\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Customer response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n if (!response.ok) {\n if (response.status === 404 && !errorOnNotFound) {\n logMessage(logLevel, \"info\", \"Customer not found\", { url, status: response.status });\n return null;\n }\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Customer request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n if (parseFailed) {\n throw new Error(\"Invalid JSON response\");\n }\n logMessage(logLevel, \"debug\", \"Customer request succeeded\", { url, hasCustomer: Boolean(data) });\n return data as PriceOSCustomer<TFeatureAccessMap> | null;\n};\n\nconst requestTrackUsage = async <TFeatureAccessMap = GetFeatureAccessResponse>(\n fetchFn: typeof fetch,\n url: string,\n body: PriceOsTrackUsageBody<TFeatureAccessMap>,\n logLevel: PriceOSLogLevel,\n bearerToken?: string | null\n): Promise<TrackUsageResponse> => {\n const idempotencyKey = resolveIdempotencyKey(body);\n logMessage(logLevel, \"debug\", \"Tracking usage\", { url, featureKey: body.featureKey });\n const headers: Record<string, string> = {\n \"content-type\": \"application/json\",\n ...(bearerToken ? { Authorization: `Bearer ${bearerToken}` } : {}),\n };\n const payload = {\n ...body,\n ...(idempotencyKey ? { idempotencyKey } : {}),\n amount: body.amount ?? 1,\n };\n const response = await fetchFn(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(payload),\n });\n logMessage(logLevel, \"info\", \"Usage track request completed\", { url, status: response.status });\n\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Usage track response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n\n if (!response.ok) {\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Usage track request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n\n if (parseFailed || !data || typeof data !== \"object\") {\n throw new Error(\"Invalid JSON response\");\n }\n\n return data as TrackUsageResponse;\n};\n\nconst requestFeatureAccess = async <TFeatureAccessMap = GetFeatureAccessResponse>(\n fetchFn: typeof fetch,\n url: string,\n logLevel: PriceOSLogLevel,\n errorOnNotFound: boolean,\n bearerToken?: string | null\n): Promise<TFeatureAccessMap | null> => {\n logMessage(logLevel, \"debug\", \"Requesting feature access\", { url, hasBearerToken: Boolean(bearerToken) });\n const headers = bearerToken ? { Authorization: `Bearer ${bearerToken}` } : undefined;\n const response = await fetchFn(url, headers ? { headers } : undefined);\n logMessage(logLevel, \"info\", \"Feature access request completed\", { url, status: response.status });\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Feature access response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n if (!response.ok) {\n if (response.status === 404 && !errorOnNotFound) {\n logMessage(logLevel, \"info\", \"Feature access not found\", { url, status: response.status });\n return null;\n }\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Feature access request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n if (parseFailed) {\n throw new Error(\"Invalid JSON response\");\n }\n logMessage(logLevel, \"debug\", \"Feature access request succeeded\", { url, hasData: Boolean(data) });\n return (data as TFeatureAccessMap | null) ?? null;\n};\n\nconst requestPricingTable = async (\n fetchFn: typeof fetch,\n url: string,\n logLevel: PriceOSLogLevel,\n bearerToken?: string | null\n): Promise<GetPricingTableResponse | null> => {\n logMessage(logLevel, \"debug\", \"Requesting pricing table\", { url, hasBearerToken: Boolean(bearerToken) });\n const headers = bearerToken ? { Authorization: `Bearer ${bearerToken}` } : undefined;\n const response = await fetchFn(url, headers ? { headers } : undefined);\n logMessage(logLevel, \"info\", \"Pricing table request completed\", { url, status: response.status });\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Pricing table response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n if (!response.ok) {\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Pricing table request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n if (parseFailed) {\n throw new Error(\"Invalid JSON response\");\n }\n return (data as GetPricingTableResponse | null) ?? null;\n};\n\nconst requestCheckoutSession = async (\n fetchFn: typeof fetch,\n url: string,\n body: CreateCheckoutBody,\n logLevel: PriceOSLogLevel,\n bearerToken?: string | null\n): Promise<CreateCustomerCheckoutResponse> => {\n logMessage(logLevel, \"debug\", \"Creating checkout session\", {\n url,\n stripeProductKey: body.stripeProductKey,\n hasCustomerId: Boolean(body.customerId),\n });\n const headers: Record<string, string> = {\n \"content-type\": \"application/json\",\n ...(bearerToken ? { Authorization: `Bearer ${bearerToken}` } : {}),\n };\n const response = await fetchFn(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n logMessage(logLevel, \"info\", \"Checkout session request completed\", { url, status: response.status });\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Checkout session response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n if (!response.ok) {\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Checkout session request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n if (parseFailed || !data || typeof data !== \"object\") {\n throw new Error(\"Invalid JSON response\");\n }\n return data as CreateCustomerCheckoutResponse;\n};\n\nconst requestCustomerPortalSession = async (\n fetchFn: typeof fetch,\n url: string,\n body: CreateCustomerPortalSessionBody,\n logLevel: PriceOSLogLevel,\n bearerToken?: string | null\n): Promise<CreateCustomerPortalResponse> => {\n logMessage(logLevel, \"debug\", \"Creating customer portal session\", {\n url,\n hasCustomerId: Boolean(body.customerId),\n });\n const headers: Record<string, string> = {\n \"content-type\": \"application/json\",\n ...(bearerToken ? { Authorization: `Bearer ${bearerToken}` } : {}),\n };\n const response = await fetchFn(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n });\n logMessage(logLevel, \"info\", \"Customer portal request completed\", { url, status: response.status });\n\n const text = await response.text();\n let data: unknown = null;\n let parseFailed = false;\n if (text) {\n try {\n data = JSON.parse(text) as unknown;\n } catch {\n parseFailed = true;\n logMessage(logLevel, \"warn\", \"Customer portal response is not JSON\", {\n url,\n status: response.status,\n bodyPreview: text.slice(0, 300),\n });\n }\n }\n\n if (!response.ok) {\n const message =\n !parseFailed && data && typeof data === \"object\" && \"error\" in data\n ? String((data as { error?: unknown }).error)\n : text || response.statusText;\n logMessage(logLevel, \"error\", \"Customer portal request failed\", {\n url,\n status: response.status,\n message,\n });\n throw new Error(message || \"Request failed\");\n }\n\n if (\n parseFailed ||\n !data ||\n typeof data !== \"object\" ||\n !(\"url\" in data) ||\n typeof (data as { url?: unknown }).url !== \"string\"\n ) {\n throw new Error(\"Invalid JSON response\");\n }\n\n return data as CreateCustomerPortalResponse;\n};\n\nexport function PriceOSProvider({ children, getBearerToken, backendUrl, logLevel }: PriceOSProviderProps) {\n return createElement(\n PriceOSContext.Provider,\n { value: { getBearerToken, backendUrl, logLevel } },\n children\n );\n}\n\nexport function useCustomer<TFeatureAccessMap = GetFeatureAccessResponse>(\n options: UseCustomerOptions<TFeatureAccessMap> = {}\n): UseCustomerResult<TFeatureAccessMap> {\n const { enabled = true, errorOnNotFound = false, swr } = options;\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n const { mutate: globalMutate } = useSWRConfig();\n const fetcher = async (url: string) => {\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n logMessage(logLevel, \"debug\", \"Resolved bearer token\", {\n url,\n hasBearerToken: Boolean(bearerToken),\n });\n return requestCustomer<TFeatureAccessMap>(fetch, url, logLevel, errorOnNotFound, bearerToken);\n };\n const trackUsage = async (body: PriceOsTrackUsageBody<TFeatureAccessMap>) => {\n const url = buildTrackUsageUrl(backendUrl ?? DEFAULT_BACKEND_URL);\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n const result = await requestTrackUsage<TFeatureAccessMap>(fetch, url, body, logLevel, bearerToken);\n await mutate();\n await globalMutate(buildFeatureAccessUrl(backendUrl ?? DEFAULT_BACKEND_URL));\n return result;\n };\n const key = enabled ? buildUrl(backendUrl ?? DEFAULT_BACKEND_URL) : null;\n const { data, error, isLoading, mutate } = useSWR(\n key,\n fetcher,\n swr\n );\n\n return {\n customer: data ?? null,\n error,\n isLoading,\n refetch: async () => {\n await mutate();\n },\n trackUsage,\n };\n}\n\nexport function useFeatureAccess<TFeatureAccessMap = GetFeatureAccessResponse>(\n featureKey: FeatureAccessKey<TFeatureAccessMap>,\n options?: UseFeatureAccessOptions<TFeatureAccessMap>\n): UseFeatureAccessByKeyResult<\n TFeatureAccessMap,\n FeatureAccessKey<TFeatureAccessMap>\n>;\n\nexport function useFeatureAccess<\n TFeatureAccessMap extends Record<string, unknown>,\n TFeatureKey extends keyof TFeatureAccessMap & string = keyof TFeatureAccessMap & string\n>(\n featureKey: TFeatureKey,\n options?: UseFeatureAccessOptions<TFeatureAccessMap>\n): UseFeatureAccessByKeyResult<TFeatureAccessMap, TFeatureKey>;\n\nexport function useFeatureAccess<\n TFeatureAccessMap = GetFeatureAccessResponse,\n TFeatureKey extends FeatureAccessKey<TFeatureAccessMap> =\n FeatureAccessKey<TFeatureAccessMap>\n>(\n featureKey: TFeatureKey,\n options?: UseFeatureAccessOptions<TFeatureAccessMap>\n): UseFeatureAccessByKeyResult<TFeatureAccessMap, TFeatureKey>;\n\nexport function useFeatureAccess<TFeatureAccessMap = GetFeatureAccessResponse>(\n options?: UseFeatureAccessOptions<TFeatureAccessMap>\n): UseFeatureAccessResult<TFeatureAccessMap>;\n\nexport function useFeatureAccess<\n TFeatureAccessMap = GetFeatureAccessResponse,\n TFeatureKey extends FeatureAccessKey<TFeatureAccessMap> =\n FeatureAccessKey<TFeatureAccessMap>\n>(\n featureKeyOrOptions: TFeatureKey | UseFeatureAccessOptions<TFeatureAccessMap> = {},\n keyedOptions: UseFeatureAccessOptions<TFeatureAccessMap> = {}\n): UseFeatureAccessResult<TFeatureAccessMap> | UseFeatureAccessByKeyResult<TFeatureAccessMap, TFeatureKey> {\n const featureKey = typeof featureKeyOrOptions === \"string\" ? featureKeyOrOptions : null;\n const options = featureKey\n ? keyedOptions\n : (featureKeyOrOptions as UseFeatureAccessOptions<TFeatureAccessMap>);\n const { enabled = true, errorOnNotFound = false, swr } = options;\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n const fetcher = async (url: string) => {\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n logMessage(logLevel, \"debug\", \"Resolved bearer token\", {\n url,\n hasBearerToken: Boolean(bearerToken),\n });\n return requestFeatureAccess<TFeatureAccessMap>(fetch, url, logLevel, errorOnNotFound, bearerToken);\n };\n const key = enabled ? buildFeatureAccessUrl(backendUrl ?? DEFAULT_BACKEND_URL) : null;\n const { data, error, isLoading, mutate } = useSWR(\n key,\n fetcher,\n swr\n );\n\n const refetch = async () => {\n await mutate();\n };\n\n if (featureKey) {\n const selectedFeature = (data as FeatureAccessRecord<TFeatureAccessMap> | null)?.[featureKey];\n const featureData =\n selectedFeature && typeof selectedFeature === \"object\"\n ? (selectedFeature as object)\n : {};\n\n return {\n ...featureData,\n error,\n isLoading,\n refetch,\n } as UseFeatureAccessByKeyResult<TFeatureAccessMap, TFeatureKey>;\n }\n\n return {\n featureAccess: data ?? null,\n error,\n isLoading,\n refetch,\n };\n}\n\nexport function useTrackUsage<TFeatureAccessMap = GetFeatureAccessResponse>(): UseTrackUsageResult<TFeatureAccessMap> {\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n const { mutate } = useSWRConfig();\n\n function trackUsage(featureKey: LimitFeatureKeyFromAccessMap<TFeatureAccessMap>): Promise<TrackUsageResponse>;\n function trackUsage(body: PriceOsTrackUsageBody<TFeatureAccessMap>): Promise<TrackUsageResponse>;\n async function trackUsage(\n input: PriceOsTrackUsageBody<TFeatureAccessMap> | LimitFeatureKeyFromAccessMap<TFeatureAccessMap>\n ): Promise<TrackUsageResponse> {\n const body = normalizeTrackUsageInput<TFeatureAccessMap>(input);\n const url = buildTrackUsageUrl(backendUrl ?? DEFAULT_BACKEND_URL);\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n const result = await requestTrackUsage<TFeatureAccessMap>(fetch, url, body, logLevel, bearerToken);\n await mutate(buildUrl(backendUrl ?? DEFAULT_BACKEND_URL));\n await mutate(buildFeatureAccessUrl(backendUrl ?? DEFAULT_BACKEND_URL));\n return result;\n }\n\n return { trackUsage };\n}\n\nexport function useCheckout(options: UseCheckoutOptions = {}): UseCheckoutResult {\n const { customerId } = options;\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n\n const createCheckoutSession = async (body: CreateCheckoutBody) => {\n const url = buildCheckoutUrl(backendUrl ?? DEFAULT_BACKEND_URL);\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n const resolvedCustomerId = body.customerId ?? customerId;\n const baseCheckoutParams = body.checkoutParams && typeof body.checkoutParams === \"object\"\n ? body.checkoutParams\n : {};\n const checkoutParams = {\n ...baseCheckoutParams,\n ...(body.cancelUrl ? { cancel_url: body.cancelUrl } : {}),\n ...(body.metadata ? { metadata: body.metadata } : {}),\n };\n return requestCheckoutSession(\n fetch,\n url,\n {\n ...body,\n checkoutParams,\n ...(resolvedCustomerId ? { customerId: resolvedCustomerId } : {}),\n },\n logLevel,\n bearerToken\n );\n };\n\n const openCheckout = async (body: CreateCheckoutBody) => {\n const response = await createCheckoutSession(body);\n if (typeof window !== \"undefined\") {\n window.location.assign(response.url);\n }\n return response;\n };\n\n return {\n createCheckoutSession,\n openCheckout,\n };\n}\n\nexport function useCustomerPortal(options: UseCustomerPortalOptions = {}): UseCustomerPortalResult {\n const { customerId } = options;\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n\n const createCustomerPortalSession = async (body?: { customerId?: string }) => {\n const url = buildCustomerPortalUrl(backendUrl ?? DEFAULT_BACKEND_URL);\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n const resolvedCustomerId = body?.customerId ?? customerId;\n return requestCustomerPortalSession(\n fetch,\n url,\n resolvedCustomerId ? { customerId: resolvedCustomerId } : {},\n logLevel,\n bearerToken\n );\n };\n\n const openCustomerPortal = async (body?: { customerId?: string }) => {\n const response = await createCustomerPortalSession(body);\n if (typeof window !== \"undefined\") {\n window.location.assign(response.url);\n }\n return response;\n };\n\n return {\n createCustomerPortalSession,\n openCustomerPortal,\n };\n}\n\nexport function usePricingTable(options: UsePricingTableOptions = {}): UsePricingTableResult {\n const { enabled = true, pricingTableKey, swr } = options;\n const { getBearerToken, backendUrl, logLevel = DEFAULT_LOG_LEVEL } = useContext(PriceOSContext);\n const { createCheckoutSession } = useCheckout();\n const fetcher = async (url: string) => {\n let bearerToken: string | null | undefined;\n try {\n bearerToken = getBearerToken ? await getBearerToken() : undefined;\n } catch (error) {\n logMessage(logLevel, \"error\", \"Failed to resolve bearer token\", {\n url,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n return requestPricingTable(fetch, url, logLevel, bearerToken);\n };\n const key = enabled ? buildPricingTableUrl(backendUrl ?? DEFAULT_BACKEND_URL, pricingTableKey) : null;\n const { data, error, isLoading, mutate } = useSWR(\n key,\n fetcher,\n swr\n );\n\n return {\n pricingTable: data ?? null,\n error,\n isLoading,\n refetch: async () => {\n await mutate();\n },\n createCheckoutSession,\n };\n}\n\nconst getDisplayPlanPrice = (plan: PricingTablePlan, yearlyBilling: boolean) => {\n if (yearlyBilling) return plan.yearlyPrice ?? plan.monthlyPrice;\n return plan.monthlyPrice ?? plan.yearlyPrice;\n};\n\nconst formatCurrencyAmount = (amount: number, currency: string) =>\n new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: currency.toUpperCase(),\n minimumFractionDigits: 0,\n maximumFractionDigits: 2,\n }).format(amount / 100);\n\nconst getRecurringIntervalLabel = (price: PricingTablePlanPrice): string | null => {\n if (!price.recurringInterval) return null;\n const intervalCount =\n typeof price.recurringIntervalCount === \"number\" && price.recurringIntervalCount > 0\n ? price.recurringIntervalCount\n : 1;\n if (intervalCount === 1) return price.recurringInterval;\n return `${intervalCount} ${price.recurringInterval}s`;\n};\n\nconst getRenderedPriceDisplay = ({\n price,\n pricingDisplay,\n}: {\n price: PricingTablePlanPrice;\n pricingDisplay: \"monthly_terms\" | \"monthly_terms_only\" | \"annual_terms\";\n}) => {\n const currency = typeof price.currency === \"string\" ? price.currency.trim() : \"\";\n const numericUnitAmount = typeof price.unitAmount === \"number\" ? price.unitAmount : null;\n const hasNumericPrice = numericUnitAmount !== null && currency.length > 0;\n\n if (\n (pricingDisplay === \"monthly_terms\" || pricingDisplay === \"monthly_terms_only\") &&\n price.recurringInterval === \"year\" &&\n hasNumericPrice\n ) {\n const intervalCount =\n typeof price.recurringIntervalCount === \"number\" && price.recurringIntervalCount > 0\n ? price.recurringIntervalCount\n : 1;\n const monthlyAmount = Math.round(numericUnitAmount / (intervalCount * 12));\n return {\n amountText: formatCurrencyAmount(monthlyAmount, currency),\n intervalText: \"month\",\n subText:\n pricingDisplay === \"monthly_terms\"\n ? `${formatCurrencyAmount(numericUnitAmount, currency)} billed annually`\n : null,\n };\n }\n\n const slashMatch = price.label.match(/^(.*?)(?:\\s*\\/\\s*|\\s+per\\s+)(day|week|month|year)s?$/i);\n if (slashMatch) {\n return {\n amountText: slashMatch[1].trim(),\n intervalText: slashMatch[2].toLowerCase(),\n subText: null,\n };\n }\n\n return {\n amountText: hasNumericPrice ? formatCurrencyAmount(numericUnitAmount, currency) : price.label,\n intervalText: getRecurringIntervalLabel(price),\n subText: null,\n };\n};\n\nconst normalizeText = (value: string | null | undefined) => {\n if (typeof value !== \"string\") return \"\";\n return value.trim();\n};\n\nconst normalizeHexColor = (value: string | null | undefined): string | null => {\n const normalized = normalizeText(value);\n if (!normalized) return null;\n const match = normalized.match(/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);\n if (!match) return null;\n const hex = match[1].toLowerCase();\n if (hex.length === 3) {\n return `#${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;\n }\n return `#${hex}`;\n};\n\nconst isDarkHexColor = (value: string | null | undefined) => {\n const hex = normalizeHexColor(value);\n if (!hex) return false;\n const r = parseInt(hex.slice(1, 3), 16);\n const g = parseInt(hex.slice(3, 5), 16);\n const b = parseInt(hex.slice(5, 7), 16);\n const luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;\n return luminance < 0.5;\n};\n\nconst resolveFontFamily = (fontFamily: string | null | undefined) => {\n if (!fontFamily) return undefined;\n if (fontFamily === \"system\") {\n return \"ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \\\"Segoe UI\\\", sans-serif\";\n }\n if (fontFamily === \"serif\") {\n return \"ui-serif, Georgia, Cambria, \\\"Times New Roman\\\", Times, serif\";\n }\n if (fontFamily === \"mono\") {\n return \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace\";\n }\n return fontFamily;\n};\n\nconst getCheckoutUrls = (successUrl?: string, cancelUrl?: string) => {\n if (successUrl) {\n return {\n successUrl,\n cancelUrl: cancelUrl ?? successUrl,\n };\n }\n if (typeof window === \"undefined\") {\n throw new Error(\"successUrl is required when rendering on the server.\");\n }\n const currentUrl = new URL(window.location.href);\n const success = new URL(currentUrl.toString());\n success.searchParams.set(\"checkout\", \"success\");\n const canceled = new URL(currentUrl.toString());\n canceled.searchParams.set(\"checkout\", \"canceled\");\n return {\n successUrl: success.toString(),\n cancelUrl: cancelUrl ?? canceled.toString(),\n };\n};\n\nconst renderFeatureLabel = (feature: PricingTableFeature) => feature.label;\n\nconst PRICING_TABLE_COLUMN_WIDTH = 312;\nconst PRICING_TABLE_GRID_GAP = 8;\nconst PRICING_TABLE_MAX_COLUMNS = 4;\n\nconst getPricingTableGridMaxWidth = (columnCount: number) => {\n const safeCount = Math.max(1, Math.min(columnCount, PRICING_TABLE_MAX_COLUMNS));\n const totalGap = Math.max(0, safeCount - 1) * PRICING_TABLE_GRID_GAP;\n return `${safeCount * PRICING_TABLE_COLUMN_WIDTH + totalGap}px`;\n};\n\nconst pricingTableStyles: Record<string, CSSProperties> = {\n section: {\n display: \"grid\",\n gap: \"1rem\",\n },\n billingToggle: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"0.25rem\",\n padding: \"0.25rem\",\n borderRadius: \"0.625rem\",\n border: \"1px solid rgba(148, 163, 184, 0.35)\",\n backgroundColor: \"rgba(148, 163, 184, 0.12)\",\n width: \"fit-content\",\n marginInline: \"auto\",\n },\n billingToggleButton: {\n appearance: \"none\",\n border: \"none\",\n borderRadius: \"0.45rem\",\n padding: \"0.45rem 1rem\",\n fontSize: \"0.9rem\",\n lineHeight: 1.1,\n fontWeight: 600,\n cursor: \"pointer\",\n backgroundColor: \"transparent\",\n color: \"inherit\",\n },\n billingToggleButtonActive: {\n backgroundColor: \"#2563eb\",\n color: \"#fff\",\n },\n error: {\n margin: 0,\n padding: \"0.625rem 0.75rem\",\n borderRadius: \"0.5rem\",\n border: \"1px solid rgba(239, 68, 68, 0.45)\",\n backgroundColor: \"rgba(239, 68, 68, 0.14)\",\n color: \"rgb(248, 113, 113)\",\n },\n planGrid: {\n display: \"grid\",\n gridTemplateColumns: \"repeat(auto-fit, minmax(220px, 1fr))\",\n gap: \"0.5rem\",\n width: \"100%\",\n marginInline: \"auto\",\n },\n planCard: {\n display: \"grid\",\n gap: \"0.75rem\",\n padding: \"1rem\",\n border: \"none\",\n backgroundColor: \"transparent\",\n alignContent: \"start\",\n },\n planCardCurrent: {\n border: \"none\",\n backgroundColor: \"transparent\",\n },\n planCardHighlight: {\n border: \"1px solid rgba(148, 163, 184, 0.35)\",\n borderRadius: \"0.75rem\",\n backgroundColor: \"rgba(148, 163, 184, 0.06)\",\n padding: \"1rem\",\n },\n planPriceBlock: {\n display: \"grid\",\n gap: \"0.25rem\",\n alignContent: \"start\",\n minHeight: \"3.95rem\",\n },\n planPriceRow: {\n display: \"flex\",\n alignItems: \"flex-end\",\n gap: \"0.4rem\",\n lineHeight: 1,\n },\n planPriceAmount: {\n margin: 0,\n fontSize: \"2.25rem\",\n lineHeight: 1,\n fontWeight: 700,\n letterSpacing: \"-0.02em\",\n },\n planPriceInterval: {\n margin: 0,\n fontSize: \"0.8125rem\",\n lineHeight: 1.05,\n opacity: 0.6,\n fontWeight: 400,\n },\n planPriceSubtext: {\n margin: 0,\n fontSize: \"0.8125rem\",\n lineHeight: 1.2,\n opacity: 0.6,\n },\n planTop: {\n display: \"flex\",\n alignItems: \"flex-start\",\n justifyContent: \"space-between\",\n gap: \"0.5rem\",\n },\n planName: {\n margin: 0,\n fontSize: \"1.25rem\",\n fontWeight: 600,\n },\n planDescription: {\n margin: 0,\n fontSize: \"0.95rem\",\n lineHeight: 1.35,\n opacity: 0.78,\n minHeight: \"2.6rem\",\n maxHeight: \"2.6rem\",\n display: \"-webkit-box\",\n WebkitBoxOrient: \"vertical\",\n WebkitLineClamp: 2,\n whiteSpace: \"normal\",\n textOverflow: \"ellipsis\",\n overflow: \"hidden\",\n },\n planPricePlaceholder: {\n height: \"3.95rem\",\n },\n currentPill: {\n fontSize: \"0.75rem\",\n lineHeight: 1,\n fontWeight: 700,\n padding: \"0.3rem 0.45rem\",\n borderRadius: \"999px\",\n border: \"1px solid rgba(59, 130, 246, 0.6)\",\n color: \"rgb(147, 197, 253)\",\n whiteSpace: \"nowrap\",\n },\n highlightPill: {\n display: \"inline-flex\",\n width: \"fit-content\",\n fontSize: \"0.75rem\",\n lineHeight: 1,\n fontWeight: 500,\n padding: \"0.3rem 0.45rem\",\n borderRadius: \"0.35rem\",\n backgroundColor: \"rgba(148, 163, 184, 0.24)\",\n color: \"rgba(15, 23, 42, 0.75)\",\n whiteSpace: \"nowrap\",\n },\n planPrice: {\n margin: 0,\n fontSize: \"1.75rem\",\n lineHeight: 1.15,\n fontWeight: 800,\n },\n planPriceMuted: {\n margin: 0,\n opacity: 0.75,\n },\n ctaButton: {\n appearance: \"none\",\n border: \"none\",\n borderRadius: \"0.625rem\",\n padding: \"0 1rem\",\n height: \"44px\",\n fontWeight: 500,\n fontSize: \"1rem\",\n lineHeight: 1.1,\n cursor: \"pointer\",\n backgroundColor: \"#2563eb\",\n color: \"#fff\",\n width: \"100%\",\n },\n ctaButtonDisabled: {\n cursor: \"not-allowed\",\n opacity: 0.7,\n backgroundColor: \"rgba(148, 163, 184, 0.45)\",\n color: \"inherit\",\n },\n featureSection: {\n display: \"grid\",\n gap: \"0.5rem\",\n },\n featureSubtitle: {\n margin: 0,\n fontSize: \"0.95rem\",\n lineHeight: 1.2,\n fontWeight: 400,\n opacity: 0.65,\n },\n featureList: {\n margin: 0,\n padding: 0,\n listStyle: \"none\",\n display: \"grid\",\n gap: \"0.5rem\",\n opacity: 0.9,\n },\n featureItem: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"0.55rem\",\n lineHeight: 1.35,\n },\n featureCheckIcon: {\n width: 14,\n height: 14,\n borderRadius: \"999px\",\n backgroundColor: \"rgba(15, 23, 42, 0.45)\",\n color: \"#fff\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: \"0.65rem\",\n fontWeight: 700,\n flexShrink: 0,\n marginTop: \"1px\",\n },\n featureText: {\n margin: 0,\n fontSize: \"1rem\",\n },\n watermarkRow: {\n display: \"flex\",\n justifyContent: \"flex-end\",\n marginTop: \"0.25rem\",\n },\n watermarkLink: {\n fontSize: \"0.75rem\",\n lineHeight: 1.2,\n opacity: 0.72,\n textDecoration: \"none\",\n },\n loadingRoot: {\n display: \"grid\",\n gap: \"1rem\",\n },\n loadingShell: {\n padding: \"1.75rem 1.5rem\",\n },\n loadingGrid: {\n display: \"grid\",\n gridTemplateColumns: \"repeat(auto-fit, minmax(220px, 1fr))\",\n gap: \"0.5rem\",\n width: \"100%\",\n marginInline: \"auto\",\n },\n loadingCard: {\n display: \"grid\",\n gap: \"0.7rem\",\n alignContent: \"start\",\n },\n loadingPulse: {\n backgroundColor: \"#dfe3e8\",\n animation: \"priceosPricingSkeletonPulse 1.3s ease-in-out infinite\",\n },\n loadingHero: {\n width: \"74%\",\n maxWidth: 180,\n height: 120,\n borderRadius: \"0.4rem\",\n },\n loadingHeadline: {\n width: \"50%\",\n height: 24,\n borderRadius: \"0.35rem\",\n marginTop: \"0.25rem\",\n },\n loadingLine: {\n width: \"100%\",\n height: 16,\n borderRadius: \"0.35rem\",\n },\n loadingCta: {\n width: \"100%\",\n height: 44,\n borderRadius: \"0.45rem\",\n marginTop: \"1rem\",\n },\n};\n\nconst renderDefaultPricingTableLoading = (className?: string) => {\n const cards = Array.from({ length: 3 }).map((_, index) =>\n createElement(\n \"div\",\n { key: index, style: pricingTableStyles.loadingCard },\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingHero,\n },\n }),\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingHeadline,\n },\n }),\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingLine,\n },\n }),\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingLine,\n },\n }),\n createElement(\"div\", {\n style: {\n ...pricingTableStyles.loadingPulse,\n ...pricingTableStyles.loadingCta,\n },\n }),\n ),\n );\n const loadingGridStyle: CSSProperties = {\n ...pricingTableStyles.loadingGrid,\n maxWidth: getPricingTableGridMaxWidth(cards.length),\n };\n\n return createElement(\n \"div\",\n { className, style: pricingTableStyles.loadingRoot },\n createElement(\"style\", {\n dangerouslySetInnerHTML: {\n __html:\n \"@keyframes priceosPricingSkeletonPulse { 0% { opacity: 0.82; } 50% { opacity: 1; } 100% { opacity: 0.82; } }\",\n },\n }),\n createElement(\n \"div\",\n { style: pricingTableStyles.loadingShell },\n createElement(\"div\", { style: loadingGridStyle }, ...cards),\n ),\n );\n};\n\nexport function PricingTableView({\n pricingTable,\n isLoading = false,\n error = null,\n className,\n yearlyLabel = \"Save with yearly billing\",\n loadingFallback,\n errorFallback,\n emptyFallback,\n onCheckout,\n onCustomCtaClick,\n}: PricingTableViewProps) {\n const [yearlyBilling, setYearlyBilling] = useState(true);\n const [checkoutPriceId, setCheckoutPriceId] = useState<string | null>(null);\n const [checkoutError, setCheckoutError] = useState<string | null>(null);\n\n const plans = pricingTable?.plans ?? [];\n const planGridStyle: CSSProperties = {\n ...pricingTableStyles.planGrid,\n maxWidth: getPricingTableGridMaxWidth(plans.length),\n };\n const tableSettings = pricingTable?.table?.settings;\n const currentPriceIdSet = new Set(pricingTable?.customer?.currentPriceIds ?? []);\n const currentProductIdSet = new Set(pricingTable?.customer?.currentProductIds ?? []);\n const hasMonthly = plans.some((plan) => Boolean(plan.monthlyPrice));\n const hasYearly = plans.some((plan) => Boolean(plan.yearlyPrice));\n const showBillingToggle = hasMonthly && hasYearly;\n const isPlanCurrentByAnySelection = (plan: PricingTablePlan) => {\n return (\n currentProductIdSet.has(plan.productId) ||\n (typeof plan.monthlyPrice?.stripePriceId === \"string\" &&\n currentPriceIdSet.has(plan.monthlyPrice.stripePriceId)) ||\n (typeof plan.yearlyPrice?.stripePriceId === \"string\" &&\n currentPriceIdSet.has(plan.yearlyPrice.stripePriceId)) ||\n plan.isCurrent === true\n );\n };\n const hasCurrentMonthlyPrice = plans.some((plan) => {\n const priceId = plan.monthlyPrice?.stripePriceId;\n return typeof priceId === \"string\" && currentPriceIdSet.has(priceId);\n });\n const hasCurrentYearlyPrice = plans.some((plan) => {\n const priceId = plan.yearlyPrice?.stripePriceId;\n return typeof priceId === \"string\" && currentPriceIdSet.has(priceId);\n });\n const isPlanCurrentForBillingView = (plan: PricingTablePlan, billingYearly: boolean) => {\n const displayPrice = getDisplayPlanPrice(plan, billingYearly);\n const displayPriceId =\n typeof displayPrice?.stripePriceId === \"string\" ? displayPrice.stripePriceId : null;\n const hasMonthlyAndYearly = Boolean(plan.monthlyPrice && plan.yearlyPrice);\n const currentByDisplayedPrice = Boolean(displayPriceId && currentPriceIdSet.has(displayPriceId));\n if (hasMonthlyAndYearly) return currentByDisplayedPrice;\n\n return currentByDisplayedPrice || isPlanCurrentByAnySelection(plan);\n };\n const rawPricingDisplay =\n (tableSettings as { pricingDisplay?: unknown } | undefined)?.pricingDisplay;\n const pricingDisplay: \"monthly_terms\" | \"monthly_terms_only\" | \"annual_terms\" =\n rawPricingDisplay === \"annual_terms\"\n ? \"annual_terms\"\n : rawPricingDisplay === \"monthly_terms_only\"\n ? \"monthly_terms_only\"\n : \"monthly_terms\";\n const resolvedHighlightProductId =\n typeof (tableSettings as { highlightProductId?: unknown } | undefined)?.highlightProductId === \"string\"\n ? ((tableSettings as { highlightProductId?: string }).highlightProductId ?? \"\").trim()\n : \"\";\n const resolvedHighlightLabel = (() => {\n const raw =\n typeof (tableSettings as { highlightLabel?: unknown } | undefined)?.highlightLabel === \"string\"\n ? ((tableSettings as { highlightLabel?: string }).highlightLabel ?? \"\").trim()\n : \"\";\n return raw.length ? raw : \"Most popular\";\n })();\n const defaultFeaturesSubheader = (() => {\n const raw =\n typeof (tableSettings as { featuresSubheader?: unknown } | undefined)?.featuresSubheader === \"string\"\n ? ((tableSettings as { featuresSubheader?: string }).featuresSubheader ?? \"\").trim()\n : \"\";\n return raw.length ? raw : \"This includes:\";\n })();\n const highlightPlanId = tableSettings?.highlightProduct\n ? (resolvedHighlightProductId || plans[Math.floor((plans.length - 1) / 2)]?.productId || null)\n : null;\n const shouldReserveHighlightRow = Boolean(\n highlightPlanId &&\n plans.some((plan) => plan.productId === highlightPlanId && !isPlanCurrentForBillingView(plan, yearlyBilling)),\n );\n const currentPlanIndexByProduct = plans.findIndex((plan) => isPlanCurrentByAnySelection(plan));\n\n useEffect(() => {\n if (hasCurrentMonthlyPrice && !hasCurrentYearlyPrice) {\n setYearlyBilling(false);\n return;\n }\n if (hasCurrentYearlyPrice && !hasCurrentMonthlyPrice) {\n setYearlyBilling(true);\n return;\n }\n if (!hasMonthly && hasYearly) {\n setYearlyBilling(true);\n return;\n }\n if (hasMonthly && !hasYearly) {\n setYearlyBilling(false);\n return;\n }\n if (tableSettings?.defaultView === \"monthly\") {\n setYearlyBilling(false);\n return;\n }\n if (tableSettings?.defaultView === \"yearly\") {\n setYearlyBilling(true);\n }\n }, [hasCurrentMonthlyPrice, hasCurrentYearlyPrice, hasMonthly, hasYearly, tableSettings?.defaultView]);\n\n const buttonRadius =\n tableSettings?.buttonShape === \"square\"\n ? \"0.35rem\"\n : tableSettings?.buttonShape === \"pill\"\n ? \"999px\"\n : pricingTableStyles.ctaButton.borderRadius;\n const hasBackgroundColor = normalizeHexColor(tableSettings?.backgroundColor) !== null;\n const darkBackground = isDarkHexColor(tableSettings?.backgroundColor);\n const sectionTextColor = hasBackgroundColor ? (darkBackground ? \"#f8fafc\" : \"#0f172a\") : null;\n const mutedTextColor = hasBackgroundColor\n ? darkBackground\n ? \"rgba(248, 250, 252, 0.72)\"\n : \"rgba(15, 23, 42, 0.72)\"\n : null;\n const resolvedFontFamily = resolveFontFamily(tableSettings?.fontFamily);\n const sectionStyle: CSSProperties = {\n ...pricingTableStyles.section,\n ...(tableSettings?.backgroundColor\n ? {\n backgroundColor: tableSettings.backgroundColor,\n padding: \"1rem\",\n }\n : {}),\n ...(sectionTextColor ? { color: sectionTextColor } : {}),\n ...(resolvedFontFamily ? { fontFamily: resolvedFontFamily } : {}),\n };\n const ctaAccentColor = tableSettings?.buttonColor || \"#2563eb\";\n const ctaTextColor = isDarkHexColor(ctaAccentColor) ? \"#ffffff\" : \"#0f172a\";\n const buttonStyle: CSSProperties = {\n ...pricingTableStyles.ctaButton,\n backgroundColor: ctaAccentColor,\n color: ctaTextColor,\n ...(buttonRadius ? { borderRadius: buttonRadius } : {}),\n };\n const billingToggleButtonActiveStyle: CSSProperties = {\n ...pricingTableStyles.billingToggleButtonActive,\n backgroundColor: ctaAccentColor,\n color: ctaTextColor,\n };\n const outlinedButtonStyle: CSSProperties = {\n ...buttonStyle,\n border: `1px solid ${ctaAccentColor}`,\n backgroundColor: \"transparent\",\n color: ctaAccentColor,\n };\n const disabledButtonStyle: CSSProperties = {\n ...pricingTableStyles.ctaButtonDisabled,\n ...(mutedTextColor ? { color: mutedTextColor } : {}),\n };\n const outlinedDisabledButtonStyle: CSSProperties = {\n ...outlinedButtonStyle,\n ...disabledButtonStyle,\n backgroundColor: \"transparent\",\n borderColor: mutedTextColor || ctaAccentColor,\n };\n const outlinedCustomActionDisabledButtonStyle: CSSProperties = {\n ...outlinedDisabledButtonStyle,\n borderColor: ctaAccentColor,\n color: ctaAccentColor,\n };\n const priceAmountStyle: CSSProperties = {\n ...pricingTableStyles.planPriceAmount,\n ...(sectionTextColor ? { color: sectionTextColor } : {}),\n };\n const priceIntervalStyle: CSSProperties = {\n ...pricingTableStyles.planPriceInterval,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n const priceSubtextStyle: CSSProperties = {\n ...pricingTableStyles.planPriceSubtext,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n const planDescriptionStyle: CSSProperties = {\n ...pricingTableStyles.planDescription,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n const featureSubtitleStyle: CSSProperties = {\n ...pricingTableStyles.featureSubtitle,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n const featureTextStyle: CSSProperties = {\n ...pricingTableStyles.featureText,\n ...(sectionTextColor ? { color: sectionTextColor } : {}),\n };\n const featureCheckStyle: CSSProperties = {\n ...pricingTableStyles.featureCheckIcon,\n ...(darkBackground\n ? { backgroundColor: \"rgba(248, 250, 252, 0.4)\", color: \"#0f172a\" }\n : {}),\n };\n const highlightPillStyle: CSSProperties = {\n ...pricingTableStyles.highlightPill,\n ...(darkBackground\n ? {\n backgroundColor: \"rgba(148, 163, 184, 0.18)\",\n color: \"rgba(226, 232, 240, 0.92)\",\n border: \"1px solid rgba(148, 163, 184, 0.32)\",\n }\n : {}),\n };\n const currentPillStyle: CSSProperties = {\n ...pricingTableStyles.currentPill,\n backgroundColor: ctaAccentColor,\n color: ctaTextColor,\n border: \"none\",\n };\n const watermarkLinkStyle: CSSProperties = {\n ...pricingTableStyles.watermarkLink,\n ...(mutedTextColor ? { color: mutedTextColor, opacity: 1 } : {}),\n };\n\n if (isLoading) {\n return loadingFallback ? createElement(\"div\", { className }, loadingFallback) : renderDefaultPricingTableLoading(className);\n }\n\n if (error) {\n return createElement(\n \"div\",\n { className },\n errorFallback ??\n createElement(\"p\", { role: \"alert\" }, error.message || \"Failed to load pricing table.\")\n );\n }\n\n if (!plans.length) {\n return createElement(\n \"div\",\n { className },\n emptyFallback ?? createElement(\"p\", null, \"No plans available.\")\n );\n }\n\n return createElement(\n \"section\",\n { className, style: sectionStyle },\n showBillingToggle\n ? createElement(\n \"div\",\n { style: pricingTableStyles.billingToggle, role: \"tablist\", \"aria-label\": yearlyLabel || \"Billing interval\" },\n createElement(\n \"button\",\n {\n type: \"button\",\n role: \"tab\",\n \"aria-selected\": !yearlyBilling,\n style: !yearlyBilling\n ? { ...pricingTableStyles.billingToggleButton, ...billingToggleButtonActiveStyle }\n : pricingTableStyles.billingToggleButton,\n onClick: () => setYearlyBilling(false),\n },\n \"Monthly\"\n ),\n createElement(\n \"button\",\n {\n type: \"button\",\n role: \"tab\",\n \"aria-selected\": yearlyBilling,\n style: yearlyBilling\n ? { ...pricingTableStyles.billingToggleButton, ...billingToggleButtonActiveStyle }\n : pricingTableStyles.billingToggleButton,\n onClick: () => setYearlyBilling(true),\n },\n \"Yearly\"\n )\n )\n : null,\n checkoutError\n ? createElement(\"p\", { role: \"alert\", style: pricingTableStyles.error }, checkoutError)\n : null,\n createElement(\n \"div\",\n { style: planGridStyle },\n ...plans.map((plan, planIndex) => {\n const planDescriptionRaw = (plan as { description?: unknown }).description;\n const planDescription =\n typeof planDescriptionRaw === \"string\" && planDescriptionRaw.trim().length > 0\n ? planDescriptionRaw.trim()\n : \"\";\n const customCtaRaw = (plan as { customCta?: unknown }).customCta;\n const customCtaObject =\n customCtaRaw && typeof customCtaRaw === \"object\" && !Array.isArray(customCtaRaw)\n ? (customCtaRaw as { buttonAction?: unknown; buttonText?: unknown; linkUrl?: unknown })\n : null;\n const customCtaButtonAction: \"stripe_checkout\" | \"custom_url\" | undefined =\n customCtaObject?.buttonAction === \"stripe_checkout\" ||\n customCtaObject?.buttonAction === \"custom_url\"\n ? customCtaObject.buttonAction\n : undefined;\n const customCta = customCtaObject\n ? {\n ...(customCtaButtonAction ? { buttonAction: customCtaButtonAction } : {}),\n ...(typeof customCtaObject.buttonText === \"string\" &&\n customCtaObject.buttonText.trim().length > 0\n ? { buttonText: customCtaObject.buttonText.trim() }\n : {}),\n ...(typeof customCtaObject.linkUrl === \"string\" &&\n customCtaObject.linkUrl.trim().length > 0\n ? { linkUrl: customCtaObject.linkUrl.trim() }\n : {}),\n }\n : null;\n const hasCustomCta = Boolean(customCtaRaw);\n const customButtonText = customCta?.buttonText || \"Choose plan\";\n const hasCustomLink = Boolean(customCta?.linkUrl);\n const customButtonAction =\n customCta?.buttonAction === \"custom_url\"\n ? \"custom_url\"\n : customCta?.buttonAction === \"stripe_checkout\"\n ? \"stripe_checkout\"\n : null;\n const displayPrice = getDisplayPlanPrice(plan, yearlyBilling);\n const isSyntheticPriceId =\n typeof displayPrice?.stripePriceId === \"string\" &&\n (displayPrice.stripePriceId.startsWith(\"custom_text_\") ||\n displayPrice.stripePriceId.startsWith(\"preview-custom-price-text-\"));\n const usesCustomCtaAction =\n customButtonAction === \"custom_url\" || !displayPrice || hasCustomLink;\n const usesCustomAction = usesCustomCtaAction || isSyntheticPriceId;\n const renderedPrice = displayPrice\n ? getRenderedPriceDisplay({ price: displayPrice, pricingDisplay })\n : null;\n const isCurrent = isPlanCurrentForBillingView(plan, yearlyBilling);\n const isDowngrade = currentPlanIndexByProduct >= 0 && planIndex < currentPlanIndexByProduct && !isCurrent;\n const isOpeningCheckout = checkoutPriceId === displayPrice?.stripePriceId;\n const checkoutDisabled = !onCheckout;\n const canHandleNoLinkCustomAction = Boolean(onCustomCtaClick);\n const isDisabled = usesCustomAction\n ? isCurrent || checkoutPriceId !== null || (!hasCustomLink && !canHandleNoLinkCustomAction)\n : isCurrent || !displayPrice || checkoutPriceId !== null || checkoutDisabled;\n const buttonLabel = isCurrent\n ? \"Current plan\"\n : isOpeningCheckout\n ? \"Opening checkout...\"\n : isDowngrade\n ? \"Downgrade\"\n : hasCustomCta\n ? customButtonText\n : displayPrice?.stripePriceId\n ? \"Subscribe\"\n : \"Choose plan\";\n const planFeaturesSubheaderRaw = (plan as { featuresSubheader?: unknown }).featuresSubheader;\n const resolvedPlanFeaturesSubheader =\n typeof planFeaturesSubheaderRaw === \"string\"\n ? planFeaturesSubheaderRaw.trim()\n : defaultFeaturesSubheader;\n const showPlanFeaturesSubheader = resolvedPlanFeaturesSubheader.length > 0;\n const isHighlighted = highlightPlanId === plan.productId && !isCurrent;\n const useOutlinedButton = Boolean(highlightPlanId) && plan.productId !== highlightPlanId;\n const resolvedButtonStyle = useOutlinedButton ? outlinedButtonStyle : buttonStyle;\n const resolvedDisabledButtonStyle = useOutlinedButton\n ? usesCustomAction\n ? outlinedCustomActionDisabledButtonStyle\n : outlinedDisabledButtonStyle\n : disabledButtonStyle;\n\n return createElement(\n \"article\",\n {\n key: plan.productId,\n style: isCurrent\n ? { ...pricingTableStyles.planCard, ...pricingTableStyles.planCardCurrent }\n : isHighlighted\n ? { ...pricingTableStyles.planCard, ...pricingTableStyles.planCardHighlight }\n : pricingTableStyles.planCard,\n },\n createElement(\n \"div\",\n { style: pricingTableStyles.planTop },\n createElement(\n \"div\",\n { style: { display: \"grid\", gap: \"0.45rem\" } },\n shouldReserveHighlightRow\n ? isHighlighted\n ? createElement(\"span\", { style: highlightPillStyle }, resolvedHighlightLabel)\n : createElement(\n \"span\",\n {\n \"aria-hidden\": true,\n style: { ...highlightPillStyle, visibility: \"hidden\" },\n },\n resolvedHighlightLabel\n )\n : null,\n createElement(\"h4\", { style: pricingTableStyles.planName }, plan.name),\n createElement(\n \"p\",\n { style: planDescriptionStyle },\n planDescription || \"\\u00a0\"\n )\n ),\n isCurrent ? createElement(\"span\", { style: currentPillStyle }, \"Current\") : null\n ),\n displayPrice && renderedPrice\n ? createElement(\n \"div\",\n { style: pricingTableStyles.planPriceBlock },\n createElement(\n \"div\",\n { style: pricingTableStyles.planPriceRow },\n createElement(\"p\", { style: priceAmountStyle }, renderedPrice.amountText),\n renderedPrice.intervalText\n ? createElement(\n \"p\",\n { style: priceIntervalStyle },\n \"per \",\n createElement(\"br\"),\n renderedPrice.intervalText\n )\n : null\n ),\n renderedPrice.subText\n ? createElement(\"p\", { style: priceSubtextStyle }, renderedPrice.subText)\n : null\n )\n : createElement(\"div\", { \"aria-hidden\": true, style: pricingTableStyles.planPricePlaceholder }),\n createElement(\n \"button\",\n {\n type: \"button\",\n disabled: isDisabled,\n style: isDisabled\n ? { ...resolvedButtonStyle, ...resolvedDisabledButtonStyle }\n : resolvedButtonStyle,\n onClick: () => {\n if (usesCustomAction) {\n if (isCurrent || checkoutPriceId !== null) return;\n const runCustomAction = async () => {\n if (!onCustomCtaClick) return;\n setCheckoutError(null);\n try {\n await onCustomCtaClick({ plan, customCta: customCta ?? {} });\n } catch (customActionError) {\n setCheckoutError(\n customActionError instanceof Error\n ? customActionError.message\n : \"Failed to perform action.\"\n );\n }\n };\n if (isDowngrade && onCustomCtaClick) {\n void runCustomAction();\n return;\n }\n if (typeof window !== \"undefined\" && customCta?.linkUrl) {\n window.location.assign(customCta.linkUrl);\n return;\n }\n if (onCustomCtaClick) {\n void runCustomAction();\n return;\n }\n return;\n }\n if (!displayPrice || isCurrent || checkoutPriceId !== null || !onCheckout) return;\n const run = async () => {\n setCheckoutError(null);\n setCheckoutPriceId(displayPrice.stripePriceId);\n try {\n await onCheckout({ plan, price: displayPrice });\n } catch (checkoutSessionError) {\n setCheckoutError(\n checkoutSessionError instanceof Error\n ? checkoutSessionError.message\n : \"Failed to start checkout.\"\n );\n } finally {\n setCheckoutPriceId(null);\n }\n };\n void run();\n },\n },\n buttonLabel\n ),\n createElement(\n \"div\",\n { style: pricingTableStyles.featureSection },\n plan.features.length && showPlanFeaturesSubheader\n ? createElement(\"p\", { style: featureSubtitleStyle }, resolvedPlanFeaturesSubheader)\n : null,\n createElement(\n \"ul\",\n { style: pricingTableStyles.featureList },\n ...plan.features.map((feature) =>\n createElement(\n \"li\",\n {\n key: `${plan.productId}:${feature.featureKey}`,\n style: pricingTableStyles.featureItem,\n },\n createElement(\"span\", { \"aria-hidden\": true, style: featureCheckStyle }, \"\\u2713\"),\n createElement(\"span\", { style: featureTextStyle }, renderFeatureLabel(feature))\n )\n )\n )\n )\n );\n })\n ),\n createElement(\n \"div\",\n { style: pricingTableStyles.watermarkRow },\n createElement(\n \"a\",\n {\n href: \"https://priceos.com\",\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n style: watermarkLinkStyle,\n },\n \"Powered by PriceOS\"\n )\n )\n );\n}\n\nexport function PriceOSPricingTable({\n pricingTableKey,\n className,\n yearlyLabel = \"Save with yearly billing\",\n successUrl,\n cancelUrl,\n loadingFallback,\n errorFallback,\n emptyFallback,\n onCustomCtaClick,\n}: PriceOSPricingTableProps) {\n const { pricingTable, isLoading, error } = usePricingTable({\n pricingTableKey,\n });\n const { openCheckout } = useCheckout();\n const { openCustomerPortal } = useCustomerPortal();\n\n const onCheckout = async ({ plan, price }: { plan: PricingTablePlan; price: PricingTablePlanPrice }) => {\n const urls = getCheckoutUrls(successUrl, cancelUrl);\n await openCheckout({\n stripeProductKey: plan.productKey,\n stripePriceId: price.stripePriceId,\n successUrl: urls.successUrl,\n cancelUrl: urls.cancelUrl,\n });\n };\n const handleCustomCtaClick = onCustomCtaClick\n ? onCustomCtaClick\n : async () => {\n await openCustomerPortal();\n };\n\n return createElement(PricingTableView, {\n pricingTable,\n isLoading,\n error,\n className,\n yearlyLabel,\n loadingFallback,\n errorFallback,\n em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C;AAAA,EACH;AACA,QAAM,uBAAuB,mBACzB,mBACA,YAAY;AACV,UAAM,mBAAmB;AAAA,EAC3B;AAEJ,SAAO,cAAc,kBAAkB;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,EACpB,CAAC;AACH;AAEO,IAAM,eAAe;","names":["error"]}
package/dist/types.d.ts CHANGED
@@ -1,13 +1,22 @@
1
1
  import type { paths } from "./gen/openapi";
2
+ import type Stripe from "stripe";
2
3
  type WithFeatureAccess<T, TFeatureAccessMap> = T extends {
3
4
  featureAccess: unknown;
4
5
  } ? Omit<T, "featureAccess"> & {
5
6
  featureAccess: TFeatureAccessMap;
6
7
  } : T;
8
+ type WithStripeSubscriptions<T> = T extends {
9
+ subscriptions?: unknown;
10
+ } ? Omit<T, "subscriptions"> & {
11
+ subscriptions?: Stripe.Subscription[];
12
+ } : T;
7
13
  type GetCustomerResponseBase = paths["/v1/customers/{customerId}"]["get"]["responses"][200]["content"]["application/json"];
8
- export type GetCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<GetCustomerResponseBase, TFeatureAccessMap>;
14
+ export type GetCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithStripeSubscriptions<WithFeatureAccess<GetCustomerResponseBase, TFeatureAccessMap>>;
9
15
  export type PriceOSCustomer<TFeatureAccessMap = GetFeatureAccessResponse> = GetCustomerResponse<TFeatureAccessMap>;
10
- export type GetCustomerRequest = paths["/v1/customers/{customerId}"]["get"]["parameters"]["path"];
16
+ type GetCustomerParameters = paths["/v1/customers/{customerId}"]["get"]["parameters"];
17
+ export type GetCustomerRequest = GetCustomerParameters["path"];
18
+ export type GetCustomerQuery = NonNullable<GetCustomerParameters["query"]>;
19
+ export type GetCustomerExpand = NonNullable<GetCustomerQuery["expand"]>[number];
11
20
  export type CreateCustomerRequest = paths["/v1/customers"]["post"]["requestBody"]["content"]["application/json"];
12
21
  type CreateCustomerResponseBase = paths["/v1/customers"]["post"]["responses"][201]["content"]["application/json"];
13
22
  export type CreateCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<CreateCustomerResponseBase, TFeatureAccessMap>;
@@ -21,6 +30,19 @@ export type DeleteCustomerRequest = paths["/v1/customers/{customerId}"]["delete"
21
30
  export type DeleteCustomerResponse = paths["/v1/customers/{customerId}"]["delete"]["responses"][200]["content"]["application/json"];
22
31
  export type CreateCustomerPortalRequest = paths["/v1/customers/{customerId}/customer_portal"]["post"]["parameters"]["path"];
23
32
  export type CreateCustomerPortalResponse = paths["/v1/customers/{customerId}/customer_portal"]["post"]["responses"][200]["content"]["application/json"];
33
+ export type CreateCustomerCheckoutRequest = paths["/v1/customers/{customerId}/checkout"]["post"]["requestBody"]["content"]["application/json"];
34
+ export type CreateCustomerCheckoutResponse = paths["/v1/customers/{customerId}/checkout"]["post"]["responses"][200]["content"]["application/json"];
35
+ type CustomProductBodyBase = paths["/v1/customers/{customerId}/custom-product/add"]["post"]["requestBody"]["content"]["application/json"];
36
+ export type AddCustomProductRequest = CustomProductBodyBase & {
37
+ customerId: string;
38
+ };
39
+ type AddCustomProductResponseBase = paths["/v1/customers/{customerId}/custom-product/add"]["post"]["responses"][200]["content"]["application/json"];
40
+ export type AddCustomProductResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<AddCustomProductResponseBase, TFeatureAccessMap>;
41
+ export type RemoveCustomProductRequest = CustomProductBodyBase & {
42
+ customerId: string;
43
+ };
44
+ type RemoveCustomProductResponseBase = paths["/v1/customers/{customerId}/custom-product/remove"]["post"]["responses"][200]["content"]["application/json"];
45
+ export type RemoveCustomProductResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<RemoveCustomProductResponseBase, TFeatureAccessMap>;
24
46
  export type LinkCustomerBody = paths["/v1/customers/link"]["post"]["requestBody"]["content"]["application/json"];
25
47
  type LinkCustomerResponseBase = paths["/v1/customers/link"]["post"]["responses"][200]["content"]["application/json"];
26
48
  export type LinkCustomerResponse<TFeatureAccessMap = GetFeatureAccessResponse> = WithFeatureAccess<LinkCustomerResponseBase, TFeatureAccessMap>;
@@ -80,19 +102,10 @@ export type GrantBonusResponse = CreateBonusResponse;
80
102
  type UsageEventPathParams = paths["/v1/usage/{id}"]["get"]["parameters"]["path"];
81
103
  export type GetUsageEventRequest = UsageEventPathParams;
82
104
  export type GetUsageEventResponse = paths["/v1/usage/{id}"]["get"]["responses"][200]["content"]["application/json"];
83
- type UsageEventByIdempotencyKeyPathParams = paths["/v1/usage/idempotency-key/{idempotencyKey}"]["get"]["parameters"]["path"];
84
- export type GetUsageEventByIdempotencyKeyRequest = UsageEventByIdempotencyKeyPathParams;
85
- export type GetUsageEventByIdempotencyKeyResponse = paths["/v1/usage/idempotency-key/{idempotencyKey}"]["get"]["responses"][200]["content"]["application/json"];
86
- export type GetUsageEventByKeyRequest = GetUsageEventByIdempotencyKeyRequest;
87
- export type GetUsageEventByKeyResponse = GetUsageEventByIdempotencyKeyResponse;
88
105
  type UpdateUsageEventBodyBase = paths["/v1/usage/{id}"]["put"]["requestBody"]["content"]["application/json"];
89
106
  export type UpdateUsageEventBody = UpdateUsageEventBodyBase;
90
107
  export type UpdateUsageEventRequest = UpdateUsageEventBody & UsageEventPathParams;
91
108
  export type UpdateUsageEventResponse = paths["/v1/usage/{id}"]["put"]["responses"][200]["content"]["application/json"];
92
- type VoidUsageEventBodyBase = paths["/v1/usage/{id}/void"]["post"]["requestBody"]["content"]["application/json"];
93
- export type VoidUsageEventBody = VoidUsageEventBodyBase;
94
- export type VoidUsageEventRequest = VoidUsageEventBody & UsageEventPathParams;
95
- export type VoidUsageEventResponse = paths["/v1/usage/{id}/void"]["post"]["responses"][200]["content"]["application/json"];
96
109
  export type DeleteUsageEventRequest = UsageEventPathParams;
97
110
  export type DeleteUsageEventResponse = paths["/v1/usage/{id}"]["delete"]["responses"][200]["content"]["application/json"];
98
111
  type DeleteUsageEventsBodyBase = paths["/v1/usage/delete"]["post"]["requestBody"]["content"]["application/json"];
@@ -129,5 +142,5 @@ export type ListUsageEventsBody<TFeatureKey extends string = ListUsageEventsBody
129
142
  };
130
143
  export type ListUsageEventsResponse = paths["/v1/usage/events"]["post"]["responses"][200]["content"]["application/json"];
131
144
  export type UsageEvent = ListUsageEventsResponse["usageEvents"][number];
132
- export type UsageEventDetail = GetUsageEventResponse["usageEvent"];
145
+ export type UsageEventDetail = GetUsageEventResponse;
133
146
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "priceos",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -37,7 +37,8 @@
37
37
  "typecheck": "tsc -p tsconfig.json --noEmit"
38
38
  },
39
39
  "dependencies": {
40
- "openapi-fetch": "^0.15.0"
40
+ "openapi-fetch": "^0.15.0",
41
+ "stripe": "^20.1.0"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "react": ">=18",