@pollinations/ui 0.0.2 → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +38 -71
  2. package/dist/{Chip-SM52sUbZ.d.cts → Chip-CQCq34kS.d.cts} +1 -1
  3. package/dist/{Chip-C5impfYd.d.ts → Chip-Cj4xG7Te.d.ts} +1 -1
  4. package/dist/app-user-menu/sdk.cjs +497 -0
  5. package/dist/app-user-menu/sdk.cjs.map +1 -0
  6. package/dist/app-user-menu/sdk.d.cts +18 -0
  7. package/dist/app-user-menu/sdk.d.ts +18 -0
  8. package/dist/app-user-menu/sdk.js +469 -0
  9. package/dist/app-user-menu/sdk.js.map +1 -0
  10. package/dist/app.css +94 -3
  11. package/dist/auth/index.cjs +77 -62
  12. package/dist/auth/index.cjs.map +1 -1
  13. package/dist/auth/index.js +77 -62
  14. package/dist/auth/index.js.map +1 -1
  15. package/dist/gen/index.cjs +477 -0
  16. package/dist/gen/index.cjs.map +1 -0
  17. package/dist/gen/index.d.cts +35 -0
  18. package/dist/gen/index.d.ts +35 -0
  19. package/dist/gen/index.js +451 -0
  20. package/dist/gen/index.js.map +1 -0
  21. package/dist/index.cjs +1875 -761
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +294 -109
  24. package/dist/index.d.ts +294 -109
  25. package/dist/index.js +1889 -798
  26. package/dist/index.js.map +1 -1
  27. package/dist/styles.css +1 -1
  28. package/dist/theme-jRPPBmld.d.cts +20 -0
  29. package/dist/theme-jRPPBmld.d.ts +20 -0
  30. package/dist/wallet/index.cjs +17 -8
  31. package/dist/wallet/index.cjs.map +1 -1
  32. package/dist/wallet/index.d.cts +2 -2
  33. package/dist/wallet/index.d.ts +2 -2
  34. package/dist/wallet/index.js +17 -8
  35. package/dist/wallet/index.js.map +1 -1
  36. package/package.json +15 -18
  37. package/dist/Button-Bn8pGg6N.d.ts +0 -26
  38. package/dist/Button-CWUBCiIc.d.cts +0 -26
  39. package/dist/auth/sdk.cjs +0 -220
  40. package/dist/auth/sdk.cjs.map +0 -1
  41. package/dist/auth/sdk.d.cts +0 -53
  42. package/dist/auth/sdk.d.ts +0 -53
  43. package/dist/auth/sdk.js +0 -187
  44. package/dist/auth/sdk.js.map +0 -1
  45. package/dist/modality/index.cjs +0 -83
  46. package/dist/modality/index.cjs.map +0 -1
  47. package/dist/modality/index.d.cts +0 -25
  48. package/dist/modality/index.d.ts +0 -25
  49. package/dist/modality/index.js +0 -56
  50. package/dist/modality/index.js.map +0 -1
  51. package/dist/theme-VMRlhqST.d.cts +0 -9
  52. package/dist/theme-VMRlhqST.d.ts +0 -9
  53. package/dist/wallet/sdk.cjs +0 -206
  54. package/dist/wallet/sdk.cjs.map +0 -1
  55. package/dist/wallet/sdk.d.cts +0 -33
  56. package/dist/wallet/sdk.d.ts +0 -33
  57. package/dist/wallet/sdk.js +0 -175
  58. package/dist/wallet/sdk.js.map +0 -1
  59. package/dist/wallet.css +0 -73
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/modules/app-user-menu/sdk.ts","../../src/modules/app-user-menu/AppUserMenu.tsx","../../src/lib/cn.ts","../../src/primitives/ChevronIcon.tsx","../../src/primitives/Dropdown.tsx","../../src/primitives/DropdownItem.tsx","../../src/modules/auth/LoginButton.tsx","../../src/primitives/Button.tsx","../../src/modules/auth/UserAvatar.tsx","../../src/modules/auth/UserName.tsx","../../src/modules/auth/WhenLoggedIn.tsx","../../src/modules/auth/WhenLoggedOut.tsx","../../src/modules/wallet/Balance.tsx","../../src/primitives/Chip.tsx","../../src/modules/wallet/format-pollen.ts"],"sourcesContent":["export {\n AppUserMenu,\n type AppUserMenuLabels,\n type AppUserMenuProps,\n isEmbeddedContext,\n} from \"./AppUserMenu.tsx\";\n","import { useAuthActions } from \"@pollinations/sdk/react\";\nimport { ChevronIcon } from \"../../primitives/ChevronIcon.tsx\";\nimport { Dropdown } from \"../../primitives/Dropdown.tsx\";\nimport { DropdownItem } from \"../../primitives/DropdownItem.tsx\";\nimport {\n LoginButton,\n UserAvatar,\n UserName,\n WhenLoggedIn,\n WhenLoggedOut,\n} from \"../auth/sdk.ts\";\nimport { Balance } from \"../wallet/sdk.ts\";\n\nexport type AppUserMenuLabels = {\n authorize: string;\n appUserMenu: string;\n topUpAccount: string;\n logout: string;\n};\n\nexport type AppUserMenuProps = {\n dashboardHref: string;\n labels?: Partial<AppUserMenuLabels>;\n hiddenWhenEmbedded?: boolean;\n embedQueryParam?: string;\n};\n\nconst defaultLabels: AppUserMenuLabels = {\n authorize: \"Authorize app\",\n appUserMenu: \"App user menu\",\n topUpAccount: \"Top up account\",\n logout: \"Log out from this app\",\n};\n\nexport function isEmbeddedContext(embedQueryParam = \"embed\"): boolean {\n if (typeof window === \"undefined\") return false;\n const search = new URLSearchParams(window.location.search);\n if (search.get(embedQueryParam) === \"1\") return true;\n try {\n return window.self !== window.top;\n } catch {\n return true;\n }\n}\n\nexport function AppUserMenu({\n dashboardHref,\n labels: labelOverrides,\n hiddenWhenEmbedded = false,\n embedQueryParam = \"embed\",\n}: AppUserMenuProps) {\n if (hiddenWhenEmbedded && isEmbeddedContext(embedQueryParam)) return null;\n\n return (\n <AppUserMenuContent\n dashboardHref={dashboardHref}\n labels={labelOverrides}\n />\n );\n}\n\nfunction AppUserMenuContent({\n dashboardHref,\n labels: labelOverrides,\n}: Pick<AppUserMenuProps, \"dashboardHref\" | \"labels\">) {\n const labels = { ...defaultLabels, ...labelOverrides };\n const { logout } = useAuthActions();\n\n return (\n <div data-theme=\"amber\" className=\"polli:flex polli:justify-end\">\n <WhenLoggedOut>\n <LoginButton theme=\"amber\">{labels.authorize}</LoginButton>\n </WhenLoggedOut>\n\n <WhenLoggedIn>\n <Dropdown\n theme=\"amber\"\n align=\"end\"\n className=\"polli:w-64 polli:p-1\"\n trigger={(open) => (\n <button\n type=\"button\"\n data-theme=\"amber\"\n aria-label={labels.appUserMenu}\n className=\"polli-control polli:flex polli:min-w-0 polli:items-center polli:gap-2 polli:rounded-full polli:bg-theme-bg-active polli:py-1 polli:pl-1 polli:pr-3 polli:text-theme-text-base polli:shadow-sm polli:transition-colors polli:hover:bg-theme-bg-hover\"\n >\n <UserAvatar\n size=\"md\"\n className=\"polli:h-8 polli:w-8\"\n />\n <span className=\"polli:flex polli:min-w-0 polli:flex-col polli:items-start polli:leading-tight\">\n <UserName className=\"polli:max-w-32 polli:truncate polli:text-sm polli:font-semibold\" />\n <Balance className=\"polli:bg-transparent polli:px-0 polli:py-0 polli:text-xs polli:text-theme-text-base\" />\n </span>\n <ChevronIcon\n expanded={open}\n className=\"polli:h-4 polli:w-4 polli:text-theme-text-base\"\n />\n </button>\n )}\n >\n {(close) => (\n <div\n data-theme=\"amber\"\n className=\"polli:flex polli:flex-col\"\n >\n <DropdownItem\n as=\"a\"\n href={dashboardHref}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={close}\n >\n {labels.topUpAccount}\n </DropdownItem>\n <DropdownItem\n type=\"button\"\n onClick={() => {\n close();\n logout();\n }}\n >\n {labels.logout}\n </DropdownItem>\n </div>\n )}\n </Dropdown>\n </WhenLoggedIn>\n </div>\n );\n}\n","import { clsx } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst twMerge = extendTailwindMerge({ prefix: \"polli\" });\n\n/** Internal class merge for polli:-prefixed package primitive classes. */\nexport function cn(...inputs: (string | undefined | null | false)[]) {\n return twMerge(clsx(...inputs));\n}\n","import type { FC } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\n\ntype ChevronIconProps = {\n /** Rotate 180° when expanded/open. */\n expanded?: boolean;\n className?: string;\n};\n\n/**\n * Canonical chevron used for collapsibles, dropdown triggers, and select pills\n * across the app. One icon everywhere.\n */\nexport const ChevronIcon: FC<ChevronIconProps> = ({ expanded, className }) => (\n <svg\n aria-hidden=\"true\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n className={cn(\n \"polli:shrink-0 polli:transition-transform polli:duration-200 polli:ease-out\",\n expanded && \"polli:rotate-180\",\n className,\n )}\n >\n <path\n d=\"M3 4.5 6 7.5l3-3\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n />\n </svg>\n);\n","import { Popover } from \"@ark-ui/react/popover\";\nimport { Portal } from \"@ark-ui/react/portal\";\nimport type { FC, ReactNode } from \"react\";\nimport { useState } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\nimport type { ThemeName } from \"../theme.ts\";\n\nconst DEFAULT_PANEL =\n \"polli:rounded-lg polli:border polli:border-theme-border polli:bg-theme-bg-pale polli:shadow-lg\";\n\nexport type DropdownProps = {\n theme: ThemeName;\n /** Trigger element; receives the current open state (e.g. to rotate a chevron). */\n trigger: (open: boolean) => ReactNode;\n /** Panel content. As a function, receives `close` to dismiss after a selection. */\n children: ReactNode | ((close: () => void) => ReactNode);\n /** Panel placement relative to the trigger. */\n align?: \"start\" | \"end\";\n /** Controlled open state. Omit to let the Dropdown manage its own. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Appended after the surface (widths, padding, max-height…). */\n className?: string;\n};\n\nexport const Dropdown: FC<DropdownProps> = ({\n theme,\n trigger,\n children,\n align = \"start\",\n open: openProp,\n onOpenChange,\n className,\n}) => {\n const [internalOpen, setInternalOpen] = useState(false);\n const isControlled = openProp !== undefined;\n const open = isControlled ? openProp : internalOpen;\n\n const setOpen = (next: boolean) => {\n if (!isControlled) setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n return (\n <Popover.Root\n open={open}\n onOpenChange={(details) => setOpen(details.open)}\n positioning={{\n placement: align === \"end\" ? \"bottom-end\" : \"bottom-start\",\n }}\n >\n <Popover.Trigger asChild>{trigger(open)}</Popover.Trigger>\n <Portal>\n <Popover.Positioner>\n <Popover.Content\n data-theme={theme}\n className={cn(\n \"polli:z-50 polli:overflow-hidden polli:focus:outline-none\",\n DEFAULT_PANEL,\n className,\n )}\n >\n {typeof children === \"function\"\n ? children(() => setOpen(false))\n : children}\n </Popover.Content>\n </Popover.Positioner>\n </Portal>\n </Popover.Root>\n );\n};\n","import type { PropsWithChildren } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\n\ntype BaseDropdownItemProps = {\n className?: string;\n};\n\nexport type DropdownItemProps<T extends React.ElementType = \"button\"> =\n PropsWithChildren<BaseDropdownItemProps> & {\n as?: T;\n } & Omit<\n React.ComponentPropsWithoutRef<T>,\n keyof BaseDropdownItemProps | \"as\"\n >;\n\nexport function DropdownItem<T extends React.ElementType = \"button\">({\n as,\n className,\n children,\n ...rest\n}: DropdownItemProps<T>) {\n const Component: React.ElementType = as || \"button\";\n return (\n <Component\n {...(Component === \"button\" ? { type: \"button\" } : undefined)}\n {...rest}\n className={cn(\n \"polli-control polli:flex polli:w-full polli:cursor-pointer polli:items-center polli:gap-2 polli:rounded-lg polli:bg-transparent polli:px-3 polli:py-2 polli:text-left polli:text-sm polli:font-medium polli:text-theme-text-base polli:no-underline polli:transition-colors polli:hover:bg-theme-bg-hover polli:focus-visible:bg-theme-bg-hover\",\n className,\n )}\n >\n {children}\n </Component>\n );\n}\n","import { useAuthActions, useAuthState } from \"@pollinations/sdk/react\";\nimport type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"../../primitives/Button.tsx\";\n\nexport type LoginButtonProps = Omit<\n ButtonProps<\"button\">,\n \"as\" | \"onClick\" | \"children\"\n> & {\n children: ReactNode;\n};\n\n/** Button that kicks off the auth redirect. `null` when already logged in. */\nexport function LoginButton({ children, ...buttonProps }: LoginButtonProps) {\n const { isLoggedIn } = useAuthState();\n const { login } = useAuthActions();\n if (isLoggedIn) return null;\n return (\n <Button {...buttonProps} onClick={() => login()}>\n {children}\n </Button>\n );\n}\n","import type { PropsWithChildren } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\nimport type { ThemeName } from \"../theme.ts\";\n\n/** Button only supports `danger`. Label/status color recipes live on Chip. */\ntype ButtonIntent = \"danger\";\n\nconst sizes = {\n sm: \"polli:px-2 polli:pt-0.5 polli:pb-1\",\n md: \"polli:px-4 polli:pt-1.5 polli:pb-2\",\n lg: \"polli:px-6 polli:py-3\",\n} as const;\n\n// Cascade-driven base — reads [data-theme] vars.\nconst themeClasses =\n \"polli:bg-theme-bg-active polli:text-theme-text-base \" +\n \"polli:hover:bg-theme-bg-hover polli:transition-colors\";\n\n// Single intent: danger. Soft recipe — light tile + deep text, slightly\n// deeper bg on hover. No filled CTAs anywhere.\nconst intentClasses: Record<ButtonIntent, string> = {\n danger:\n \"polli:bg-intent-danger-bg-light polli:text-intent-danger-text \" +\n \"polli:hover:bg-intent-danger-bg-hover polli:transition-colors\",\n};\n\ntype BaseButtonProps = {\n /** Override the cascade theme for this button's subtree. Ignored when `intent` is set. */\n theme?: ThemeName;\n /** Only `\"danger\"` for now. */\n intent?: ButtonIntent;\n size?: keyof typeof sizes;\n className?: string;\n disabled?: boolean;\n};\n\nconst buttonClasses = ({\n theme: _theme,\n intent,\n size,\n className,\n disabled,\n}: BaseButtonProps & { disabled?: boolean }) => {\n const colorClasses = intent ? intentClasses[intent] : themeClasses;\n return cn(\n \"polli-control polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:self-center polli:font-medium polli:leading-normal polli:box-border\",\n disabled\n ? \"polli:opacity-50 polli:cursor-not-allowed\"\n : \"polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer\",\n colorClasses,\n sizes[size || \"md\"],\n className,\n );\n};\n\nexport type ButtonProps<T extends React.ElementType = \"button\"> =\n PropsWithChildren<BaseButtonProps> & {\n as?: T;\n } & Omit<React.ComponentPropsWithoutRef<T>, keyof BaseButtonProps | \"as\">;\n\nexport function Button<T extends React.ElementType = \"button\">({\n as,\n children,\n theme,\n intent,\n size,\n className,\n disabled,\n ...buttonProps\n}: ButtonProps<T>) {\n const Component: React.ElementType = as || \"button\";\n\n return (\n <Component\n // Cascade override only applies when `intent` is unset.\n data-theme={intent ? undefined : theme}\n data-intent={intent}\n className={buttonClasses({\n theme,\n intent,\n size,\n className,\n disabled,\n })}\n disabled={disabled}\n {...buttonProps}\n >\n {children}\n </Component>\n );\n}\n","import { useAccountProfile, useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\n\nexport type UserAvatarProps = {\n size?: \"sm\" | \"md\" | \"lg\";\n className?: string;\n};\n\nconst sizeClass = {\n sm: \"polli:w-6 polli:h-6 polli:text-xs\",\n md: \"polli:w-9 polli:h-9 polli:text-sm\",\n lg: \"polli:w-12 polli:h-12 polli:text-base\",\n} as const;\n\nfunction initials(name: string): string | null {\n const parts = name.trim().split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return null;\n if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;\n const first = parts[0][0] ?? \"\";\n const last = parts[parts.length - 1][0] ?? \"\";\n return (first + last).toUpperCase() || null;\n}\n\n/** Avatar from `profile.image`, or initials from `profile.name`. `null` otherwise. */\nexport function UserAvatar({ size = \"md\", className }: UserAvatarProps) {\n const { isLoggedIn } = useAuthState();\n const { data: profile } = useAccountProfile({ enabled: isLoggedIn });\n if (!isLoggedIn) return null;\n\n const base = cn(\n \"polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:overflow-hidden polli:bg-theme-bg-pale polli:text-theme-text-strong polli:font-semibold polli:select-none\",\n sizeClass[size],\n className,\n );\n\n if (profile?.image) {\n return (\n <img\n data-polli=\"user-avatar\"\n src={profile.image}\n alt={profile.name ?? \"\"}\n className={base}\n />\n );\n }\n const label = profile?.name ? initials(profile.name) : null;\n if (!label) return null;\n return (\n <div\n data-polli=\"user-avatar\"\n role=\"img\"\n aria-label={profile?.name ?? undefined}\n className={base}\n >\n {label}\n </div>\n );\n}\n","import { useAccountProfile, useAuthState } from \"@pollinations/sdk/react\";\n\nexport type UserNameProps = { className?: string };\n\n/**\n * Renders the user's display name. Falls back to GitHub username when the\n * `profile` scope was not granted (or `name` is empty). `null` when logged\n * out, or when neither name nor GitHub username is available.\n */\nexport function UserName({ className }: UserNameProps) {\n const { isLoggedIn } = useAuthState();\n const { data: profile } = useAccountProfile({ enabled: isLoggedIn });\n if (!isLoggedIn || !profile) return null;\n const display = profile.name || profile.githubUsername;\n if (!display) return null;\n return (\n <span data-polli=\"user-name\" className={className}>\n {display}\n </span>\n );\n}\n","import { useAuthState } from \"@pollinations/sdk/react\";\nimport { Fragment, type ReactNode } from \"react\";\n\nexport type WhenLoggedInProps = { children: ReactNode };\n\n/** Renders `children` only when a user is signed in. */\nexport function WhenLoggedIn({ children }: WhenLoggedInProps) {\n const { isLoggedIn } = useAuthState();\n if (!isLoggedIn) return null;\n return <Fragment>{children}</Fragment>;\n}\n","import { useAuthState } from \"@pollinations/sdk/react\";\nimport { Fragment, type ReactNode } from \"react\";\n\nexport type WhenLoggedOutProps = { children: ReactNode };\n\n/** Renders `children` only when no user is signed in. */\nexport function WhenLoggedOut({ children }: WhenLoggedOutProps) {\n const { isLoggedIn } = useAuthState();\n if (isLoggedIn) return null;\n return <Fragment>{children}</Fragment>;\n}\n","import { useAccountBalance, useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { Chip } from \"../../primitives/Chip.tsx\";\nimport { formatPollen } from \"./format-pollen.ts\";\n\nexport type BalanceProps = { className?: string };\n\n/** Renders the logged-in user's pollen balance. `null` until loaded. */\nexport function Balance({ className }: BalanceProps = {}) {\n const { isLoggedIn } = useAuthState();\n const { data: balance } = useAccountBalance({ enabled: isLoggedIn });\n if (!isLoggedIn || balance == null) return null;\n return (\n <Chip\n data-polli=\"balance\"\n className={cn(\"polli:tabular-nums\", className)}\n >\n {formatPollen(balance.balance)} pollen\n </Chip>\n );\n}\n","import type { ComponentPropsWithoutRef, FC } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\nimport type { ThemeName } from \"../theme.ts\";\n\n/** Semantic chip labels for status and metadata badges. */\ntype ChipIntent =\n | \"news\"\n | \"alpha\"\n | \"neutral\"\n | \"success\"\n | \"warning\"\n | \"danger\";\n\nconst chipSizes = {\n sm: \"polli:px-2 polli:py-0.5 polli:text-xs\",\n md: \"polli:px-2.5 polli:py-0.5 polli:text-sm\",\n lg: \"polli:px-3 polli:py-1 polli:text-sm\",\n} as const;\n\nconst intentClasses: Record<ChipIntent, string> = {\n news: \"polli:bg-intent-news-bg-light polli:text-intent-news-text\",\n alpha: \"polli:bg-intent-alpha-bg-light polli:text-intent-alpha-text\",\n neutral: \"polli:bg-ink-100/80 polli:text-ink-900\",\n success: \"polli:bg-intent-success-bg-light polli:text-intent-success-text\",\n warning: \"polli:bg-intent-warning-bg-light polli:text-intent-warning-text\",\n danger: \"polli:bg-intent-danger-bg-light polli:text-intent-danger-text\",\n};\n\nexport type ChipProps = ComponentPropsWithoutRef<\"span\"> & {\n /** Override the cascade theme for this chip's subtree. */\n theme?: ThemeName;\n /** Semantic intent. Wins over `theme` when set. */\n intent?: ChipIntent;\n size?: keyof typeof chipSizes;\n};\n\n// Static, rectangular colored container. Round shapes are reserved for buttons.\n// Reads `bg-theme-bg-active` / `text-theme-text-strong` from the cascade unless\n// `intent` is set (semantic, theme-independent).\nexport const Chip: FC<ChipProps> = ({\n theme,\n intent,\n size = \"md\",\n className,\n children,\n ...rest\n}) => {\n const intentClass = intent\n ? intentClasses[intent]\n : \"polli:bg-theme-bg-active polli:text-theme-text-strong\";\n return (\n <span\n {...rest}\n data-theme={theme}\n className={cn(\n \"polli:inline-flex polli:shrink-0 polli:items-center polli:gap-1 polli:rounded-lg polli:font-medium polli:leading-normal\",\n chipSizes[size],\n intentClass,\n className,\n )}\n >\n {children}\n </span>\n );\n};\n","// 5-digit budget for pollen display. Integer takes its space, decimals fill\n// the remainder (capped at 4), floor toward -infinity, trailing zeros stripped.\n// Integers needing >=6 digits switch to compact (K/M/B, 3 sig figs).\n// Decimal point and minus sign do not count toward the budget.\n\nconst BUDGET = 5;\nconst MAX_DECIMALS = 4;\nconst COMPACT_THRESHOLD = 100_000;\n\nfunction floorTo(value: number, decimals: number): number {\n const factor = 10 ** decimals;\n return Math.floor(value * factor) / factor;\n}\n\nfunction formatCompact(value: number): string {\n const abs = Math.abs(value);\n const sign = value < 0 ? \"-\" : \"\";\n const [unit, scale] =\n abs >= 1e9\n ? ([\"B\", 1e9] as const)\n : abs >= 1e6\n ? ([\"M\", 1e6] as const)\n : ([\"K\", 1e3] as const);\n const ratio = abs / scale;\n const intDigits = Math.max(1, Math.floor(Math.log10(ratio)) + 1);\n const decimals = Math.max(0, 3 - intDigits);\n const floored = floorTo(ratio, decimals);\n return `${sign}${Number(floored.toFixed(decimals)).toString()}${unit}`;\n}\n\nexport function formatPollen(value: number): string {\n if (!Number.isFinite(value) || value === 0) return \"0\";\n\n const abs = Math.abs(value);\n\n if (abs >= COMPACT_THRESHOLD) return formatCompact(value);\n\n const intDigits = abs >= 1 ? Math.floor(Math.log10(abs)) + 1 : 1;\n const decimals = Math.min(MAX_DECIMALS, Math.max(0, BUDGET - intDigits));\n const floored = floorTo(value, decimals);\n if (floored === 0) return \"0\";\n return Number(floored.toFixed(decimals)).toString();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAA+B;;;ACA/B,kBAAqB;AACrB,4BAAoC;AAEpC,IAAM,cAAU,2CAAoB,EAAE,QAAQ,QAAQ,CAAC;AAGhD,SAAS,MAAM,QAA+C;AACjE,SAAO,YAAQ,kBAAK,GAAG,MAAM,CAAC;AAClC;;;ACiBQ;AAZD,IAAM,cAAoC,CAAC,EAAE,UAAU,UAAU,MACpE;AAAA,EAAC;AAAA;AAAA,IACG,eAAY;AAAA,IACZ,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,WAAW;AAAA,MACP;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,IACJ;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACG,GAAE;AAAA,QAC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M,SAAS,iBAAO,WAAU,GACjD;AAAA,IAEA,8CAAC,gBACG;AAAA,MAAC;AAAA;AAAA,QACG,OAAM;AAAA,QACN,OAAM;AAAA,QACN,WAAU;AAAA,QACV,SAAS,CAAC,SACN;AAAA,UAAC;AAAA;AAAA,YACG,MAAK;AAAA,YACL,cAAW;AAAA,YACX,cAAY,OAAO;AAAA,YACnB,WAAU;AAAA,YAEV;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACG,MAAK;AAAA,kBACL,WAAU;AAAA;AAAA,cACd;AAAA,cACA,+CAAC,UAAK,WAAU,iFACZ;AAAA,8DAAC,YAAS,WAAU,mEAAkE;AAAA,gBACtF,8CAAC,WAAQ,WAAU,uFAAsF;AAAA,iBAC7G;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACG,UAAU;AAAA,kBACV,WAAU;AAAA;AAAA,cACd;AAAA;AAAA;AAAA,QACJ;AAAA,QAGH,WAAC,UACE;AAAA,UAAC;AAAA;AAAA,YACG,cAAW;AAAA,YACX,WAAU;AAAA,YAEV;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACG,IAAG;AAAA,kBACH,MAAM;AAAA,kBACN,QAAO;AAAA,kBACP,KAAI;AAAA,kBACJ,SAAS;AAAA,kBAER,iBAAO;AAAA;AAAA,cACZ;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACG,MAAK;AAAA,kBACL,SAAS,MAAM;AACX,0BAAM;AACN,2BAAO;AAAA,kBACX;AAAA,kBAEC,iBAAO;AAAA;AAAA,cACZ;AAAA;AAAA;AAAA,QACJ;AAAA;AAAA,IAER,GACJ;AAAA,KACJ;AAER;","names":["import_react","import_jsx_runtime","import_jsx_runtime","import_react","import_jsx_runtime","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","intentClasses","import_jsx_runtime","import_jsx_runtime"]}
@@ -0,0 +1,18 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type AppUserMenuLabels = {
4
+ authorize: string;
5
+ appUserMenu: string;
6
+ topUpAccount: string;
7
+ logout: string;
8
+ };
9
+ type AppUserMenuProps = {
10
+ dashboardHref: string;
11
+ labels?: Partial<AppUserMenuLabels>;
12
+ hiddenWhenEmbedded?: boolean;
13
+ embedQueryParam?: string;
14
+ };
15
+ declare function isEmbeddedContext(embedQueryParam?: string): boolean;
16
+ declare function AppUserMenu({ dashboardHref, labels: labelOverrides, hiddenWhenEmbedded, embedQueryParam, }: AppUserMenuProps): react_jsx_runtime.JSX.Element | null;
17
+
18
+ export { AppUserMenu, type AppUserMenuLabels, type AppUserMenuProps, isEmbeddedContext };
@@ -0,0 +1,18 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type AppUserMenuLabels = {
4
+ authorize: string;
5
+ appUserMenu: string;
6
+ topUpAccount: string;
7
+ logout: string;
8
+ };
9
+ type AppUserMenuProps = {
10
+ dashboardHref: string;
11
+ labels?: Partial<AppUserMenuLabels>;
12
+ hiddenWhenEmbedded?: boolean;
13
+ embedQueryParam?: string;
14
+ };
15
+ declare function isEmbeddedContext(embedQueryParam?: string): boolean;
16
+ declare function AppUserMenu({ dashboardHref, labels: labelOverrides, hiddenWhenEmbedded, embedQueryParam, }: AppUserMenuProps): react_jsx_runtime.JSX.Element | null;
17
+
18
+ export { AppUserMenu, type AppUserMenuLabels, type AppUserMenuProps, isEmbeddedContext };
@@ -0,0 +1,469 @@
1
+ // src/modules/app-user-menu/AppUserMenu.tsx
2
+ import { useAuthActions as useAuthActions2 } from "@pollinations/sdk/react";
3
+
4
+ // src/lib/cn.ts
5
+ import { clsx } from "clsx";
6
+ import { extendTailwindMerge } from "tailwind-merge";
7
+ var twMerge = extendTailwindMerge({ prefix: "polli" });
8
+ function cn(...inputs) {
9
+ return twMerge(clsx(...inputs));
10
+ }
11
+
12
+ // src/primitives/ChevronIcon.tsx
13
+ import { jsx } from "react/jsx-runtime";
14
+ var ChevronIcon = ({ expanded, className }) => /* @__PURE__ */ jsx(
15
+ "svg",
16
+ {
17
+ "aria-hidden": "true",
18
+ width: "12",
19
+ height: "12",
20
+ viewBox: "0 0 12 12",
21
+ className: cn(
22
+ "polli:shrink-0 polli:transition-transform polli:duration-200 polli:ease-out",
23
+ expanded && "polli:rotate-180",
24
+ className
25
+ ),
26
+ children: /* @__PURE__ */ jsx(
27
+ "path",
28
+ {
29
+ d: "M3 4.5 6 7.5l3-3",
30
+ fill: "none",
31
+ stroke: "currentColor",
32
+ strokeLinecap: "round",
33
+ strokeLinejoin: "round",
34
+ strokeWidth: "1.5"
35
+ }
36
+ )
37
+ }
38
+ );
39
+
40
+ // src/primitives/Dropdown.tsx
41
+ import { Popover } from "@ark-ui/react/popover";
42
+ import { Portal } from "@ark-ui/react/portal";
43
+ import { useState } from "react";
44
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
45
+ var DEFAULT_PANEL = "polli:rounded-lg polli:border polli:border-theme-border polli:bg-theme-bg-pale polli:shadow-lg";
46
+ var Dropdown = ({
47
+ theme,
48
+ trigger,
49
+ children,
50
+ align = "start",
51
+ open: openProp,
52
+ onOpenChange,
53
+ className
54
+ }) => {
55
+ const [internalOpen, setInternalOpen] = useState(false);
56
+ const isControlled = openProp !== void 0;
57
+ const open = isControlled ? openProp : internalOpen;
58
+ const setOpen = (next) => {
59
+ if (!isControlled) setInternalOpen(next);
60
+ onOpenChange?.(next);
61
+ };
62
+ return /* @__PURE__ */ jsxs(
63
+ Popover.Root,
64
+ {
65
+ open,
66
+ onOpenChange: (details) => setOpen(details.open),
67
+ positioning: {
68
+ placement: align === "end" ? "bottom-end" : "bottom-start"
69
+ },
70
+ children: [
71
+ /* @__PURE__ */ jsx2(Popover.Trigger, { asChild: true, children: trigger(open) }),
72
+ /* @__PURE__ */ jsx2(Portal, { children: /* @__PURE__ */ jsx2(Popover.Positioner, { children: /* @__PURE__ */ jsx2(
73
+ Popover.Content,
74
+ {
75
+ "data-theme": theme,
76
+ className: cn(
77
+ "polli:z-50 polli:overflow-hidden polli:focus:outline-none",
78
+ DEFAULT_PANEL,
79
+ className
80
+ ),
81
+ children: typeof children === "function" ? children(() => setOpen(false)) : children
82
+ }
83
+ ) }) })
84
+ ]
85
+ }
86
+ );
87
+ };
88
+
89
+ // src/primitives/DropdownItem.tsx
90
+ import { jsx as jsx3 } from "react/jsx-runtime";
91
+ function DropdownItem({
92
+ as,
93
+ className,
94
+ children,
95
+ ...rest
96
+ }) {
97
+ const Component = as || "button";
98
+ return /* @__PURE__ */ jsx3(
99
+ Component,
100
+ {
101
+ ...Component === "button" ? { type: "button" } : void 0,
102
+ ...rest,
103
+ className: cn(
104
+ "polli-control polli:flex polli:w-full polli:cursor-pointer polli:items-center polli:gap-2 polli:rounded-lg polli:bg-transparent polli:px-3 polli:py-2 polli:text-left polli:text-sm polli:font-medium polli:text-theme-text-base polli:no-underline polli:transition-colors polli:hover:bg-theme-bg-hover polli:focus-visible:bg-theme-bg-hover",
105
+ className
106
+ ),
107
+ children
108
+ }
109
+ );
110
+ }
111
+
112
+ // src/modules/auth/LoginButton.tsx
113
+ import { useAuthActions, useAuthState } from "@pollinations/sdk/react";
114
+
115
+ // src/primitives/Button.tsx
116
+ import { jsx as jsx4 } from "react/jsx-runtime";
117
+ var sizes = {
118
+ sm: "polli:px-2 polli:pt-0.5 polli:pb-1",
119
+ md: "polli:px-4 polli:pt-1.5 polli:pb-2",
120
+ lg: "polli:px-6 polli:py-3"
121
+ };
122
+ var themeClasses = "polli:bg-theme-bg-active polli:text-theme-text-base polli:hover:bg-theme-bg-hover polli:transition-colors";
123
+ var intentClasses = {
124
+ danger: "polli:bg-intent-danger-bg-light polli:text-intent-danger-text polli:hover:bg-intent-danger-bg-hover polli:transition-colors"
125
+ };
126
+ var buttonClasses = ({
127
+ theme: _theme,
128
+ intent,
129
+ size,
130
+ className,
131
+ disabled
132
+ }) => {
133
+ const colorClasses = intent ? intentClasses[intent] : themeClasses;
134
+ return cn(
135
+ "polli-control polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:self-center polli:font-medium polli:leading-normal polli:box-border",
136
+ disabled ? "polli:opacity-50 polli:cursor-not-allowed" : "polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer",
137
+ colorClasses,
138
+ sizes[size || "md"],
139
+ className
140
+ );
141
+ };
142
+ function Button({
143
+ as,
144
+ children,
145
+ theme,
146
+ intent,
147
+ size,
148
+ className,
149
+ disabled,
150
+ ...buttonProps
151
+ }) {
152
+ const Component = as || "button";
153
+ return /* @__PURE__ */ jsx4(
154
+ Component,
155
+ {
156
+ "data-theme": intent ? void 0 : theme,
157
+ "data-intent": intent,
158
+ className: buttonClasses({
159
+ theme,
160
+ intent,
161
+ size,
162
+ className,
163
+ disabled
164
+ }),
165
+ disabled,
166
+ ...buttonProps,
167
+ children
168
+ }
169
+ );
170
+ }
171
+
172
+ // src/modules/auth/LoginButton.tsx
173
+ import { jsx as jsx5 } from "react/jsx-runtime";
174
+ function LoginButton({ children, ...buttonProps }) {
175
+ const { isLoggedIn } = useAuthState();
176
+ const { login } = useAuthActions();
177
+ if (isLoggedIn) return null;
178
+ return /* @__PURE__ */ jsx5(Button, { ...buttonProps, onClick: () => login(), children });
179
+ }
180
+
181
+ // src/modules/auth/UserAvatar.tsx
182
+ import { useAccountProfile, useAuthState as useAuthState2 } from "@pollinations/sdk/react";
183
+ import { jsx as jsx6 } from "react/jsx-runtime";
184
+ var sizeClass = {
185
+ sm: "polli:w-6 polli:h-6 polli:text-xs",
186
+ md: "polli:w-9 polli:h-9 polli:text-sm",
187
+ lg: "polli:w-12 polli:h-12 polli:text-base"
188
+ };
189
+ function initials(name) {
190
+ const parts = name.trim().split(/\s+/).filter(Boolean);
191
+ if (parts.length === 0) return null;
192
+ if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;
193
+ const first = parts[0][0] ?? "";
194
+ const last = parts[parts.length - 1][0] ?? "";
195
+ return (first + last).toUpperCase() || null;
196
+ }
197
+ function UserAvatar({ size = "md", className }) {
198
+ const { isLoggedIn } = useAuthState2();
199
+ const { data: profile } = useAccountProfile({ enabled: isLoggedIn });
200
+ if (!isLoggedIn) return null;
201
+ const base = cn(
202
+ "polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:overflow-hidden polli:bg-theme-bg-pale polli:text-theme-text-strong polli:font-semibold polli:select-none",
203
+ sizeClass[size],
204
+ className
205
+ );
206
+ if (profile?.image) {
207
+ return /* @__PURE__ */ jsx6(
208
+ "img",
209
+ {
210
+ "data-polli": "user-avatar",
211
+ src: profile.image,
212
+ alt: profile.name ?? "",
213
+ className: base
214
+ }
215
+ );
216
+ }
217
+ const label = profile?.name ? initials(profile.name) : null;
218
+ if (!label) return null;
219
+ return /* @__PURE__ */ jsx6(
220
+ "div",
221
+ {
222
+ "data-polli": "user-avatar",
223
+ role: "img",
224
+ "aria-label": profile?.name ?? void 0,
225
+ className: base,
226
+ children: label
227
+ }
228
+ );
229
+ }
230
+
231
+ // src/modules/auth/UserName.tsx
232
+ import { useAccountProfile as useAccountProfile2, useAuthState as useAuthState3 } from "@pollinations/sdk/react";
233
+ import { jsx as jsx7 } from "react/jsx-runtime";
234
+ function UserName({ className }) {
235
+ const { isLoggedIn } = useAuthState3();
236
+ const { data: profile } = useAccountProfile2({ enabled: isLoggedIn });
237
+ if (!isLoggedIn || !profile) return null;
238
+ const display = profile.name || profile.githubUsername;
239
+ if (!display) return null;
240
+ return /* @__PURE__ */ jsx7("span", { "data-polli": "user-name", className, children: display });
241
+ }
242
+
243
+ // src/modules/auth/WhenLoggedIn.tsx
244
+ import { useAuthState as useAuthState4 } from "@pollinations/sdk/react";
245
+ import { Fragment } from "react";
246
+ import { jsx as jsx8 } from "react/jsx-runtime";
247
+ function WhenLoggedIn({ children }) {
248
+ const { isLoggedIn } = useAuthState4();
249
+ if (!isLoggedIn) return null;
250
+ return /* @__PURE__ */ jsx8(Fragment, { children });
251
+ }
252
+
253
+ // src/modules/auth/WhenLoggedOut.tsx
254
+ import { useAuthState as useAuthState5 } from "@pollinations/sdk/react";
255
+ import { Fragment as Fragment2 } from "react";
256
+ import { jsx as jsx9 } from "react/jsx-runtime";
257
+ function WhenLoggedOut({ children }) {
258
+ const { isLoggedIn } = useAuthState5();
259
+ if (isLoggedIn) return null;
260
+ return /* @__PURE__ */ jsx9(Fragment2, { children });
261
+ }
262
+
263
+ // src/modules/wallet/Balance.tsx
264
+ import { useAccountBalance, useAuthState as useAuthState6 } from "@pollinations/sdk/react";
265
+
266
+ // src/primitives/Chip.tsx
267
+ import { jsx as jsx10 } from "react/jsx-runtime";
268
+ var chipSizes = {
269
+ sm: "polli:px-2 polli:py-0.5 polli:text-xs",
270
+ md: "polli:px-2.5 polli:py-0.5 polli:text-sm",
271
+ lg: "polli:px-3 polli:py-1 polli:text-sm"
272
+ };
273
+ var intentClasses2 = {
274
+ news: "polli:bg-intent-news-bg-light polli:text-intent-news-text",
275
+ alpha: "polli:bg-intent-alpha-bg-light polli:text-intent-alpha-text",
276
+ neutral: "polli:bg-ink-100/80 polli:text-ink-900",
277
+ success: "polli:bg-intent-success-bg-light polli:text-intent-success-text",
278
+ warning: "polli:bg-intent-warning-bg-light polli:text-intent-warning-text",
279
+ danger: "polli:bg-intent-danger-bg-light polli:text-intent-danger-text"
280
+ };
281
+ var Chip = ({
282
+ theme,
283
+ intent,
284
+ size = "md",
285
+ className,
286
+ children,
287
+ ...rest
288
+ }) => {
289
+ const intentClass = intent ? intentClasses2[intent] : "polli:bg-theme-bg-active polli:text-theme-text-strong";
290
+ return /* @__PURE__ */ jsx10(
291
+ "span",
292
+ {
293
+ ...rest,
294
+ "data-theme": theme,
295
+ className: cn(
296
+ "polli:inline-flex polli:shrink-0 polli:items-center polli:gap-1 polli:rounded-lg polli:font-medium polli:leading-normal",
297
+ chipSizes[size],
298
+ intentClass,
299
+ className
300
+ ),
301
+ children
302
+ }
303
+ );
304
+ };
305
+
306
+ // src/modules/wallet/format-pollen.ts
307
+ var BUDGET = 5;
308
+ var MAX_DECIMALS = 4;
309
+ var COMPACT_THRESHOLD = 1e5;
310
+ function floorTo(value, decimals) {
311
+ const factor = 10 ** decimals;
312
+ return Math.floor(value * factor) / factor;
313
+ }
314
+ function formatCompact(value) {
315
+ const abs = Math.abs(value);
316
+ const sign = value < 0 ? "-" : "";
317
+ const [unit, scale] = abs >= 1e9 ? ["B", 1e9] : abs >= 1e6 ? ["M", 1e6] : ["K", 1e3];
318
+ const ratio = abs / scale;
319
+ const intDigits = Math.max(1, Math.floor(Math.log10(ratio)) + 1);
320
+ const decimals = Math.max(0, 3 - intDigits);
321
+ const floored = floorTo(ratio, decimals);
322
+ return `${sign}${Number(floored.toFixed(decimals)).toString()}${unit}`;
323
+ }
324
+ function formatPollen(value) {
325
+ if (!Number.isFinite(value) || value === 0) return "0";
326
+ const abs = Math.abs(value);
327
+ if (abs >= COMPACT_THRESHOLD) return formatCompact(value);
328
+ const intDigits = abs >= 1 ? Math.floor(Math.log10(abs)) + 1 : 1;
329
+ const decimals = Math.min(MAX_DECIMALS, Math.max(0, BUDGET - intDigits));
330
+ const floored = floorTo(value, decimals);
331
+ if (floored === 0) return "0";
332
+ return Number(floored.toFixed(decimals)).toString();
333
+ }
334
+
335
+ // src/modules/wallet/Balance.tsx
336
+ import { jsxs as jsxs2 } from "react/jsx-runtime";
337
+ function Balance({ className } = {}) {
338
+ const { isLoggedIn } = useAuthState6();
339
+ const { data: balance } = useAccountBalance({ enabled: isLoggedIn });
340
+ if (!isLoggedIn || balance == null) return null;
341
+ return /* @__PURE__ */ jsxs2(
342
+ Chip,
343
+ {
344
+ "data-polli": "balance",
345
+ className: cn("polli:tabular-nums", className),
346
+ children: [
347
+ formatPollen(balance.balance),
348
+ " pollen"
349
+ ]
350
+ }
351
+ );
352
+ }
353
+
354
+ // src/modules/app-user-menu/AppUserMenu.tsx
355
+ import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
356
+ var defaultLabels = {
357
+ authorize: "Authorize app",
358
+ appUserMenu: "App user menu",
359
+ topUpAccount: "Top up account",
360
+ logout: "Log out from this app"
361
+ };
362
+ function isEmbeddedContext(embedQueryParam = "embed") {
363
+ if (typeof window === "undefined") return false;
364
+ const search = new URLSearchParams(window.location.search);
365
+ if (search.get(embedQueryParam) === "1") return true;
366
+ try {
367
+ return window.self !== window.top;
368
+ } catch {
369
+ return true;
370
+ }
371
+ }
372
+ function AppUserMenu({
373
+ dashboardHref,
374
+ labels: labelOverrides,
375
+ hiddenWhenEmbedded = false,
376
+ embedQueryParam = "embed"
377
+ }) {
378
+ if (hiddenWhenEmbedded && isEmbeddedContext(embedQueryParam)) return null;
379
+ return /* @__PURE__ */ jsx11(
380
+ AppUserMenuContent,
381
+ {
382
+ dashboardHref,
383
+ labels: labelOverrides
384
+ }
385
+ );
386
+ }
387
+ function AppUserMenuContent({
388
+ dashboardHref,
389
+ labels: labelOverrides
390
+ }) {
391
+ const labels = { ...defaultLabels, ...labelOverrides };
392
+ const { logout } = useAuthActions2();
393
+ return /* @__PURE__ */ jsxs3("div", { "data-theme": "amber", className: "polli:flex polli:justify-end", children: [
394
+ /* @__PURE__ */ jsx11(WhenLoggedOut, { children: /* @__PURE__ */ jsx11(LoginButton, { theme: "amber", children: labels.authorize }) }),
395
+ /* @__PURE__ */ jsx11(WhenLoggedIn, { children: /* @__PURE__ */ jsx11(
396
+ Dropdown,
397
+ {
398
+ theme: "amber",
399
+ align: "end",
400
+ className: "polli:w-64 polli:p-1",
401
+ trigger: (open) => /* @__PURE__ */ jsxs3(
402
+ "button",
403
+ {
404
+ type: "button",
405
+ "data-theme": "amber",
406
+ "aria-label": labels.appUserMenu,
407
+ className: "polli-control polli:flex polli:min-w-0 polli:items-center polli:gap-2 polli:rounded-full polli:bg-theme-bg-active polli:py-1 polli:pl-1 polli:pr-3 polli:text-theme-text-base polli:shadow-sm polli:transition-colors polli:hover:bg-theme-bg-hover",
408
+ children: [
409
+ /* @__PURE__ */ jsx11(
410
+ UserAvatar,
411
+ {
412
+ size: "md",
413
+ className: "polli:h-8 polli:w-8"
414
+ }
415
+ ),
416
+ /* @__PURE__ */ jsxs3("span", { className: "polli:flex polli:min-w-0 polli:flex-col polli:items-start polli:leading-tight", children: [
417
+ /* @__PURE__ */ jsx11(UserName, { className: "polli:max-w-32 polli:truncate polli:text-sm polli:font-semibold" }),
418
+ /* @__PURE__ */ jsx11(Balance, { className: "polli:bg-transparent polli:px-0 polli:py-0 polli:text-xs polli:text-theme-text-base" })
419
+ ] }),
420
+ /* @__PURE__ */ jsx11(
421
+ ChevronIcon,
422
+ {
423
+ expanded: open,
424
+ className: "polli:h-4 polli:w-4 polli:text-theme-text-base"
425
+ }
426
+ )
427
+ ]
428
+ }
429
+ ),
430
+ children: (close) => /* @__PURE__ */ jsxs3(
431
+ "div",
432
+ {
433
+ "data-theme": "amber",
434
+ className: "polli:flex polli:flex-col",
435
+ children: [
436
+ /* @__PURE__ */ jsx11(
437
+ DropdownItem,
438
+ {
439
+ as: "a",
440
+ href: dashboardHref,
441
+ target: "_blank",
442
+ rel: "noopener noreferrer",
443
+ onClick: close,
444
+ children: labels.topUpAccount
445
+ }
446
+ ),
447
+ /* @__PURE__ */ jsx11(
448
+ DropdownItem,
449
+ {
450
+ type: "button",
451
+ onClick: () => {
452
+ close();
453
+ logout();
454
+ },
455
+ children: labels.logout
456
+ }
457
+ )
458
+ ]
459
+ }
460
+ )
461
+ }
462
+ ) })
463
+ ] });
464
+ }
465
+ export {
466
+ AppUserMenu,
467
+ isEmbeddedContext
468
+ };
469
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/modules/app-user-menu/AppUserMenu.tsx","../../src/lib/cn.ts","../../src/primitives/ChevronIcon.tsx","../../src/primitives/Dropdown.tsx","../../src/primitives/DropdownItem.tsx","../../src/modules/auth/LoginButton.tsx","../../src/primitives/Button.tsx","../../src/modules/auth/UserAvatar.tsx","../../src/modules/auth/UserName.tsx","../../src/modules/auth/WhenLoggedIn.tsx","../../src/modules/auth/WhenLoggedOut.tsx","../../src/modules/wallet/Balance.tsx","../../src/primitives/Chip.tsx","../../src/modules/wallet/format-pollen.ts"],"sourcesContent":["import { useAuthActions } from \"@pollinations/sdk/react\";\nimport { ChevronIcon } from \"../../primitives/ChevronIcon.tsx\";\nimport { Dropdown } from \"../../primitives/Dropdown.tsx\";\nimport { DropdownItem } from \"../../primitives/DropdownItem.tsx\";\nimport {\n LoginButton,\n UserAvatar,\n UserName,\n WhenLoggedIn,\n WhenLoggedOut,\n} from \"../auth/sdk.ts\";\nimport { Balance } from \"../wallet/sdk.ts\";\n\nexport type AppUserMenuLabels = {\n authorize: string;\n appUserMenu: string;\n topUpAccount: string;\n logout: string;\n};\n\nexport type AppUserMenuProps = {\n dashboardHref: string;\n labels?: Partial<AppUserMenuLabels>;\n hiddenWhenEmbedded?: boolean;\n embedQueryParam?: string;\n};\n\nconst defaultLabels: AppUserMenuLabels = {\n authorize: \"Authorize app\",\n appUserMenu: \"App user menu\",\n topUpAccount: \"Top up account\",\n logout: \"Log out from this app\",\n};\n\nexport function isEmbeddedContext(embedQueryParam = \"embed\"): boolean {\n if (typeof window === \"undefined\") return false;\n const search = new URLSearchParams(window.location.search);\n if (search.get(embedQueryParam) === \"1\") return true;\n try {\n return window.self !== window.top;\n } catch {\n return true;\n }\n}\n\nexport function AppUserMenu({\n dashboardHref,\n labels: labelOverrides,\n hiddenWhenEmbedded = false,\n embedQueryParam = \"embed\",\n}: AppUserMenuProps) {\n if (hiddenWhenEmbedded && isEmbeddedContext(embedQueryParam)) return null;\n\n return (\n <AppUserMenuContent\n dashboardHref={dashboardHref}\n labels={labelOverrides}\n />\n );\n}\n\nfunction AppUserMenuContent({\n dashboardHref,\n labels: labelOverrides,\n}: Pick<AppUserMenuProps, \"dashboardHref\" | \"labels\">) {\n const labels = { ...defaultLabels, ...labelOverrides };\n const { logout } = useAuthActions();\n\n return (\n <div data-theme=\"amber\" className=\"polli:flex polli:justify-end\">\n <WhenLoggedOut>\n <LoginButton theme=\"amber\">{labels.authorize}</LoginButton>\n </WhenLoggedOut>\n\n <WhenLoggedIn>\n <Dropdown\n theme=\"amber\"\n align=\"end\"\n className=\"polli:w-64 polli:p-1\"\n trigger={(open) => (\n <button\n type=\"button\"\n data-theme=\"amber\"\n aria-label={labels.appUserMenu}\n className=\"polli-control polli:flex polli:min-w-0 polli:items-center polli:gap-2 polli:rounded-full polli:bg-theme-bg-active polli:py-1 polli:pl-1 polli:pr-3 polli:text-theme-text-base polli:shadow-sm polli:transition-colors polli:hover:bg-theme-bg-hover\"\n >\n <UserAvatar\n size=\"md\"\n className=\"polli:h-8 polli:w-8\"\n />\n <span className=\"polli:flex polli:min-w-0 polli:flex-col polli:items-start polli:leading-tight\">\n <UserName className=\"polli:max-w-32 polli:truncate polli:text-sm polli:font-semibold\" />\n <Balance className=\"polli:bg-transparent polli:px-0 polli:py-0 polli:text-xs polli:text-theme-text-base\" />\n </span>\n <ChevronIcon\n expanded={open}\n className=\"polli:h-4 polli:w-4 polli:text-theme-text-base\"\n />\n </button>\n )}\n >\n {(close) => (\n <div\n data-theme=\"amber\"\n className=\"polli:flex polli:flex-col\"\n >\n <DropdownItem\n as=\"a\"\n href={dashboardHref}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={close}\n >\n {labels.topUpAccount}\n </DropdownItem>\n <DropdownItem\n type=\"button\"\n onClick={() => {\n close();\n logout();\n }}\n >\n {labels.logout}\n </DropdownItem>\n </div>\n )}\n </Dropdown>\n </WhenLoggedIn>\n </div>\n );\n}\n","import { clsx } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst twMerge = extendTailwindMerge({ prefix: \"polli\" });\n\n/** Internal class merge for polli:-prefixed package primitive classes. */\nexport function cn(...inputs: (string | undefined | null | false)[]) {\n return twMerge(clsx(...inputs));\n}\n","import type { FC } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\n\ntype ChevronIconProps = {\n /** Rotate 180° when expanded/open. */\n expanded?: boolean;\n className?: string;\n};\n\n/**\n * Canonical chevron used for collapsibles, dropdown triggers, and select pills\n * across the app. One icon everywhere.\n */\nexport const ChevronIcon: FC<ChevronIconProps> = ({ expanded, className }) => (\n <svg\n aria-hidden=\"true\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n className={cn(\n \"polli:shrink-0 polli:transition-transform polli:duration-200 polli:ease-out\",\n expanded && \"polli:rotate-180\",\n className,\n )}\n >\n <path\n d=\"M3 4.5 6 7.5l3-3\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n />\n </svg>\n);\n","import { Popover } from \"@ark-ui/react/popover\";\nimport { Portal } from \"@ark-ui/react/portal\";\nimport type { FC, ReactNode } from \"react\";\nimport { useState } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\nimport type { ThemeName } from \"../theme.ts\";\n\nconst DEFAULT_PANEL =\n \"polli:rounded-lg polli:border polli:border-theme-border polli:bg-theme-bg-pale polli:shadow-lg\";\n\nexport type DropdownProps = {\n theme: ThemeName;\n /** Trigger element; receives the current open state (e.g. to rotate a chevron). */\n trigger: (open: boolean) => ReactNode;\n /** Panel content. As a function, receives `close` to dismiss after a selection. */\n children: ReactNode | ((close: () => void) => ReactNode);\n /** Panel placement relative to the trigger. */\n align?: \"start\" | \"end\";\n /** Controlled open state. Omit to let the Dropdown manage its own. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Appended after the surface (widths, padding, max-height…). */\n className?: string;\n};\n\nexport const Dropdown: FC<DropdownProps> = ({\n theme,\n trigger,\n children,\n align = \"start\",\n open: openProp,\n onOpenChange,\n className,\n}) => {\n const [internalOpen, setInternalOpen] = useState(false);\n const isControlled = openProp !== undefined;\n const open = isControlled ? openProp : internalOpen;\n\n const setOpen = (next: boolean) => {\n if (!isControlled) setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n return (\n <Popover.Root\n open={open}\n onOpenChange={(details) => setOpen(details.open)}\n positioning={{\n placement: align === \"end\" ? \"bottom-end\" : \"bottom-start\",\n }}\n >\n <Popover.Trigger asChild>{trigger(open)}</Popover.Trigger>\n <Portal>\n <Popover.Positioner>\n <Popover.Content\n data-theme={theme}\n className={cn(\n \"polli:z-50 polli:overflow-hidden polli:focus:outline-none\",\n DEFAULT_PANEL,\n className,\n )}\n >\n {typeof children === \"function\"\n ? children(() => setOpen(false))\n : children}\n </Popover.Content>\n </Popover.Positioner>\n </Portal>\n </Popover.Root>\n );\n};\n","import type { PropsWithChildren } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\n\ntype BaseDropdownItemProps = {\n className?: string;\n};\n\nexport type DropdownItemProps<T extends React.ElementType = \"button\"> =\n PropsWithChildren<BaseDropdownItemProps> & {\n as?: T;\n } & Omit<\n React.ComponentPropsWithoutRef<T>,\n keyof BaseDropdownItemProps | \"as\"\n >;\n\nexport function DropdownItem<T extends React.ElementType = \"button\">({\n as,\n className,\n children,\n ...rest\n}: DropdownItemProps<T>) {\n const Component: React.ElementType = as || \"button\";\n return (\n <Component\n {...(Component === \"button\" ? { type: \"button\" } : undefined)}\n {...rest}\n className={cn(\n \"polli-control polli:flex polli:w-full polli:cursor-pointer polli:items-center polli:gap-2 polli:rounded-lg polli:bg-transparent polli:px-3 polli:py-2 polli:text-left polli:text-sm polli:font-medium polli:text-theme-text-base polli:no-underline polli:transition-colors polli:hover:bg-theme-bg-hover polli:focus-visible:bg-theme-bg-hover\",\n className,\n )}\n >\n {children}\n </Component>\n );\n}\n","import { useAuthActions, useAuthState } from \"@pollinations/sdk/react\";\nimport type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"../../primitives/Button.tsx\";\n\nexport type LoginButtonProps = Omit<\n ButtonProps<\"button\">,\n \"as\" | \"onClick\" | \"children\"\n> & {\n children: ReactNode;\n};\n\n/** Button that kicks off the auth redirect. `null` when already logged in. */\nexport function LoginButton({ children, ...buttonProps }: LoginButtonProps) {\n const { isLoggedIn } = useAuthState();\n const { login } = useAuthActions();\n if (isLoggedIn) return null;\n return (\n <Button {...buttonProps} onClick={() => login()}>\n {children}\n </Button>\n );\n}\n","import type { PropsWithChildren } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\nimport type { ThemeName } from \"../theme.ts\";\n\n/** Button only supports `danger`. Label/status color recipes live on Chip. */\ntype ButtonIntent = \"danger\";\n\nconst sizes = {\n sm: \"polli:px-2 polli:pt-0.5 polli:pb-1\",\n md: \"polli:px-4 polli:pt-1.5 polli:pb-2\",\n lg: \"polli:px-6 polli:py-3\",\n} as const;\n\n// Cascade-driven base — reads [data-theme] vars.\nconst themeClasses =\n \"polli:bg-theme-bg-active polli:text-theme-text-base \" +\n \"polli:hover:bg-theme-bg-hover polli:transition-colors\";\n\n// Single intent: danger. Soft recipe — light tile + deep text, slightly\n// deeper bg on hover. No filled CTAs anywhere.\nconst intentClasses: Record<ButtonIntent, string> = {\n danger:\n \"polli:bg-intent-danger-bg-light polli:text-intent-danger-text \" +\n \"polli:hover:bg-intent-danger-bg-hover polli:transition-colors\",\n};\n\ntype BaseButtonProps = {\n /** Override the cascade theme for this button's subtree. Ignored when `intent` is set. */\n theme?: ThemeName;\n /** Only `\"danger\"` for now. */\n intent?: ButtonIntent;\n size?: keyof typeof sizes;\n className?: string;\n disabled?: boolean;\n};\n\nconst buttonClasses = ({\n theme: _theme,\n intent,\n size,\n className,\n disabled,\n}: BaseButtonProps & { disabled?: boolean }) => {\n const colorClasses = intent ? intentClasses[intent] : themeClasses;\n return cn(\n \"polli-control polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:self-center polli:font-medium polli:leading-normal polli:box-border\",\n disabled\n ? \"polli:opacity-50 polli:cursor-not-allowed\"\n : \"polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer\",\n colorClasses,\n sizes[size || \"md\"],\n className,\n );\n};\n\nexport type ButtonProps<T extends React.ElementType = \"button\"> =\n PropsWithChildren<BaseButtonProps> & {\n as?: T;\n } & Omit<React.ComponentPropsWithoutRef<T>, keyof BaseButtonProps | \"as\">;\n\nexport function Button<T extends React.ElementType = \"button\">({\n as,\n children,\n theme,\n intent,\n size,\n className,\n disabled,\n ...buttonProps\n}: ButtonProps<T>) {\n const Component: React.ElementType = as || \"button\";\n\n return (\n <Component\n // Cascade override only applies when `intent` is unset.\n data-theme={intent ? undefined : theme}\n data-intent={intent}\n className={buttonClasses({\n theme,\n intent,\n size,\n className,\n disabled,\n })}\n disabled={disabled}\n {...buttonProps}\n >\n {children}\n </Component>\n );\n}\n","import { useAccountProfile, useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\n\nexport type UserAvatarProps = {\n size?: \"sm\" | \"md\" | \"lg\";\n className?: string;\n};\n\nconst sizeClass = {\n sm: \"polli:w-6 polli:h-6 polli:text-xs\",\n md: \"polli:w-9 polli:h-9 polli:text-sm\",\n lg: \"polli:w-12 polli:h-12 polli:text-base\",\n} as const;\n\nfunction initials(name: string): string | null {\n const parts = name.trim().split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return null;\n if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;\n const first = parts[0][0] ?? \"\";\n const last = parts[parts.length - 1][0] ?? \"\";\n return (first + last).toUpperCase() || null;\n}\n\n/** Avatar from `profile.image`, or initials from `profile.name`. `null` otherwise. */\nexport function UserAvatar({ size = \"md\", className }: UserAvatarProps) {\n const { isLoggedIn } = useAuthState();\n const { data: profile } = useAccountProfile({ enabled: isLoggedIn });\n if (!isLoggedIn) return null;\n\n const base = cn(\n \"polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:overflow-hidden polli:bg-theme-bg-pale polli:text-theme-text-strong polli:font-semibold polli:select-none\",\n sizeClass[size],\n className,\n );\n\n if (profile?.image) {\n return (\n <img\n data-polli=\"user-avatar\"\n src={profile.image}\n alt={profile.name ?? \"\"}\n className={base}\n />\n );\n }\n const label = profile?.name ? initials(profile.name) : null;\n if (!label) return null;\n return (\n <div\n data-polli=\"user-avatar\"\n role=\"img\"\n aria-label={profile?.name ?? undefined}\n className={base}\n >\n {label}\n </div>\n );\n}\n","import { useAccountProfile, useAuthState } from \"@pollinations/sdk/react\";\n\nexport type UserNameProps = { className?: string };\n\n/**\n * Renders the user's display name. Falls back to GitHub username when the\n * `profile` scope was not granted (or `name` is empty). `null` when logged\n * out, or when neither name nor GitHub username is available.\n */\nexport function UserName({ className }: UserNameProps) {\n const { isLoggedIn } = useAuthState();\n const { data: profile } = useAccountProfile({ enabled: isLoggedIn });\n if (!isLoggedIn || !profile) return null;\n const display = profile.name || profile.githubUsername;\n if (!display) return null;\n return (\n <span data-polli=\"user-name\" className={className}>\n {display}\n </span>\n );\n}\n","import { useAuthState } from \"@pollinations/sdk/react\";\nimport { Fragment, type ReactNode } from \"react\";\n\nexport type WhenLoggedInProps = { children: ReactNode };\n\n/** Renders `children` only when a user is signed in. */\nexport function WhenLoggedIn({ children }: WhenLoggedInProps) {\n const { isLoggedIn } = useAuthState();\n if (!isLoggedIn) return null;\n return <Fragment>{children}</Fragment>;\n}\n","import { useAuthState } from \"@pollinations/sdk/react\";\nimport { Fragment, type ReactNode } from \"react\";\n\nexport type WhenLoggedOutProps = { children: ReactNode };\n\n/** Renders `children` only when no user is signed in. */\nexport function WhenLoggedOut({ children }: WhenLoggedOutProps) {\n const { isLoggedIn } = useAuthState();\n if (isLoggedIn) return null;\n return <Fragment>{children}</Fragment>;\n}\n","import { useAccountBalance, useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { Chip } from \"../../primitives/Chip.tsx\";\nimport { formatPollen } from \"./format-pollen.ts\";\n\nexport type BalanceProps = { className?: string };\n\n/** Renders the logged-in user's pollen balance. `null` until loaded. */\nexport function Balance({ className }: BalanceProps = {}) {\n const { isLoggedIn } = useAuthState();\n const { data: balance } = useAccountBalance({ enabled: isLoggedIn });\n if (!isLoggedIn || balance == null) return null;\n return (\n <Chip\n data-polli=\"balance\"\n className={cn(\"polli:tabular-nums\", className)}\n >\n {formatPollen(balance.balance)} pollen\n </Chip>\n );\n}\n","import type { ComponentPropsWithoutRef, FC } from \"react\";\nimport { cn } from \"../lib/cn.ts\";\nimport type { ThemeName } from \"../theme.ts\";\n\n/** Semantic chip labels for status and metadata badges. */\ntype ChipIntent =\n | \"news\"\n | \"alpha\"\n | \"neutral\"\n | \"success\"\n | \"warning\"\n | \"danger\";\n\nconst chipSizes = {\n sm: \"polli:px-2 polli:py-0.5 polli:text-xs\",\n md: \"polli:px-2.5 polli:py-0.5 polli:text-sm\",\n lg: \"polli:px-3 polli:py-1 polli:text-sm\",\n} as const;\n\nconst intentClasses: Record<ChipIntent, string> = {\n news: \"polli:bg-intent-news-bg-light polli:text-intent-news-text\",\n alpha: \"polli:bg-intent-alpha-bg-light polli:text-intent-alpha-text\",\n neutral: \"polli:bg-ink-100/80 polli:text-ink-900\",\n success: \"polli:bg-intent-success-bg-light polli:text-intent-success-text\",\n warning: \"polli:bg-intent-warning-bg-light polli:text-intent-warning-text\",\n danger: \"polli:bg-intent-danger-bg-light polli:text-intent-danger-text\",\n};\n\nexport type ChipProps = ComponentPropsWithoutRef<\"span\"> & {\n /** Override the cascade theme for this chip's subtree. */\n theme?: ThemeName;\n /** Semantic intent. Wins over `theme` when set. */\n intent?: ChipIntent;\n size?: keyof typeof chipSizes;\n};\n\n// Static, rectangular colored container. Round shapes are reserved for buttons.\n// Reads `bg-theme-bg-active` / `text-theme-text-strong` from the cascade unless\n// `intent` is set (semantic, theme-independent).\nexport const Chip: FC<ChipProps> = ({\n theme,\n intent,\n size = \"md\",\n className,\n children,\n ...rest\n}) => {\n const intentClass = intent\n ? intentClasses[intent]\n : \"polli:bg-theme-bg-active polli:text-theme-text-strong\";\n return (\n <span\n {...rest}\n data-theme={theme}\n className={cn(\n \"polli:inline-flex polli:shrink-0 polli:items-center polli:gap-1 polli:rounded-lg polli:font-medium polli:leading-normal\",\n chipSizes[size],\n intentClass,\n className,\n )}\n >\n {children}\n </span>\n );\n};\n","// 5-digit budget for pollen display. Integer takes its space, decimals fill\n// the remainder (capped at 4), floor toward -infinity, trailing zeros stripped.\n// Integers needing >=6 digits switch to compact (K/M/B, 3 sig figs).\n// Decimal point and minus sign do not count toward the budget.\n\nconst BUDGET = 5;\nconst MAX_DECIMALS = 4;\nconst COMPACT_THRESHOLD = 100_000;\n\nfunction floorTo(value: number, decimals: number): number {\n const factor = 10 ** decimals;\n return Math.floor(value * factor) / factor;\n}\n\nfunction formatCompact(value: number): string {\n const abs = Math.abs(value);\n const sign = value < 0 ? \"-\" : \"\";\n const [unit, scale] =\n abs >= 1e9\n ? ([\"B\", 1e9] as const)\n : abs >= 1e6\n ? ([\"M\", 1e6] as const)\n : ([\"K\", 1e3] as const);\n const ratio = abs / scale;\n const intDigits = Math.max(1, Math.floor(Math.log10(ratio)) + 1);\n const decimals = Math.max(0, 3 - intDigits);\n const floored = floorTo(ratio, decimals);\n return `${sign}${Number(floored.toFixed(decimals)).toString()}${unit}`;\n}\n\nexport function formatPollen(value: number): string {\n if (!Number.isFinite(value) || value === 0) return \"0\";\n\n const abs = Math.abs(value);\n\n if (abs >= COMPACT_THRESHOLD) return formatCompact(value);\n\n const intDigits = abs >= 1 ? Math.floor(Math.log10(abs)) + 1 : 1;\n const decimals = Math.min(MAX_DECIMALS, Math.max(0, BUDGET - intDigits));\n const floored = floorTo(value, decimals);\n if (floored === 0) return \"0\";\n return Number(floored.toFixed(decimals)).toString();\n}\n"],"mappings":";AAAA,SAAS,kBAAAA,uBAAsB;;;ACA/B,SAAS,YAAY;AACrB,SAAS,2BAA2B;AAEpC,IAAM,UAAU,oBAAoB,EAAE,QAAQ,QAAQ,CAAC;AAGhD,SAAS,MAAM,QAA+C;AACjE,SAAO,QAAQ,KAAK,GAAG,MAAM,CAAC;AAClC;;;ACiBQ;AAZD,IAAM,cAAoC,CAAC,EAAE,UAAU,UAAU,MACpE;AAAA,EAAC;AAA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H,MAAM;AAAA,kBACN,QAAO;AAAA,kBACP,KAAI;AAAA,kBACJ,SAAS;AAAA,kBAER,iBAAO;AAAA;AAAA,cACZ;AAAA,cACA,gBAAAA;AAAA,gBAAC;AAAA;AAAA,kBACG,MAAK;AAAA,kBACL,SAAS,MAAM;AACX,0BAAM;AACN,2BAAO;AAAA,kBACX;AAAA,kBAEC,iBAAO;AAAA;AAAA,cACZ;AAAA;AAAA;AAAA,QACJ;AAAA;AAAA,IAER,GACJ;AAAA,KACJ;AAER;","names":["useAuthActions","jsx","jsx","jsx","jsx","useAuthState","jsx","useAuthState","useAccountProfile","useAuthState","jsx","useAuthState","jsx","useAuthState","Fragment","jsx","useAuthState","jsx","intentClasses","jsxs","useAuthState","jsx","jsxs","useAuthActions"]}