@pollinations/ui 0.1.0-alpha.0 → 0.1.0-alpha.10

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 (117) hide show
  1. package/README.md +162 -87
  2. package/dist/Button-BGqClaBr.d.cts +29 -0
  3. package/dist/Button-BGqClaBr.d.ts +29 -0
  4. package/dist/Chip-v-ADv6cz.d.cts +18 -0
  5. package/dist/Chip-v-ADv6cz.d.ts +18 -0
  6. package/dist/Dialog-D3Nqt8cE.d.cts +66 -0
  7. package/dist/Dialog-D3Nqt8cE.d.ts +66 -0
  8. package/dist/app-user-menu/sdk.cjs +938 -0
  9. package/dist/app-user-menu/sdk.cjs.map +1 -0
  10. package/dist/app-user-menu/sdk.d.cts +29 -0
  11. package/dist/app-user-menu/sdk.d.ts +29 -0
  12. package/dist/app-user-menu/sdk.js +917 -0
  13. package/dist/app-user-menu/sdk.js.map +1 -0
  14. package/dist/app.css +20 -32
  15. package/dist/auth/index.cjs +1372 -86
  16. package/dist/auth/index.cjs.map +1 -1
  17. package/dist/auth/index.d.cts +91 -6
  18. package/dist/auth/index.d.ts +91 -6
  19. package/dist/auth/index.js +1369 -85
  20. package/dist/auth/index.js.map +1 -1
  21. package/dist/auth/sdk.cjs +93 -64
  22. package/dist/auth/sdk.cjs.map +1 -1
  23. package/dist/auth/sdk.d.cts +2 -15
  24. package/dist/auth/sdk.d.ts +2 -15
  25. package/dist/auth/sdk.js +92 -61
  26. package/dist/auth/sdk.js.map +1 -1
  27. package/dist/brand/badge-made-with.svg +1 -0
  28. package/dist/brand/lockup-horizontal-black.png +0 -0
  29. package/dist/brand/lockup-horizontal-black.svg +4 -0
  30. package/dist/brand/lockup-horizontal-white.png +0 -0
  31. package/dist/brand/lockup-horizontal-white.svg +4 -0
  32. package/dist/brand/lockup-horizontal.svg +4 -0
  33. package/dist/brand/lockup-stacked-black.png +0 -0
  34. package/dist/brand/lockup-stacked-black.svg +4 -0
  35. package/dist/brand/lockup-stacked-white.png +0 -0
  36. package/dist/brand/lockup-stacked-white.svg +4 -0
  37. package/dist/brand/lockup-stacked.svg +4 -0
  38. package/dist/brand/mark-black.png +0 -0
  39. package/dist/brand/mark-black.svg +1 -0
  40. package/dist/brand/mark-white.png +0 -0
  41. package/dist/brand/mark-white.svg +1 -0
  42. package/dist/brand/mark.svg +1 -0
  43. package/dist/brand/polli/polli-lockup-horizontal-black.png +0 -0
  44. package/dist/brand/polli/polli-lockup-horizontal-white.png +0 -0
  45. package/dist/brand/polli/polli-lockup-stacked-black.png +0 -0
  46. package/dist/brand/polli/polli-lockup-stacked-white.png +0 -0
  47. package/dist/brand/polli/polli.png +0 -0
  48. package/dist/brand/wordmark-black.png +0 -0
  49. package/dist/brand/wordmark-black.svg +1 -0
  50. package/dist/brand/wordmark-white.png +0 -0
  51. package/dist/brand/wordmark-white.svg +1 -0
  52. package/dist/brand/wordmark.svg +1 -0
  53. package/dist/fonts/geist-pixel-square.woff2 +0 -0
  54. package/dist/gen/index.cjs +718 -0
  55. package/dist/gen/index.cjs.map +1 -0
  56. package/dist/gen/index.d.cts +91 -0
  57. package/dist/gen/index.d.ts +91 -0
  58. package/dist/gen/index.js +688 -0
  59. package/dist/gen/index.js.map +1 -0
  60. package/dist/index.browser.min.js +2 -0
  61. package/dist/index.browser.min.js.map +1 -0
  62. package/dist/index.cjs +4250 -1517
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +794 -221
  65. package/dist/index.d.ts +794 -221
  66. package/dist/index.js +4154 -1493
  67. package/dist/index.js.map +1 -1
  68. package/dist/licenses/Geist-OFL.txt +93 -0
  69. package/dist/markdown.cjs +836 -0
  70. package/dist/markdown.cjs.map +1 -0
  71. package/dist/markdown.d.cts +16 -0
  72. package/dist/markdown.d.ts +16 -0
  73. package/dist/markdown.js +807 -0
  74. package/dist/markdown.js.map +1 -0
  75. package/dist/styles.css +1 -1
  76. package/dist/theme.css +94 -0
  77. package/dist/types-CCy9JNu9.d.cts +6 -0
  78. package/dist/types-CCy9JNu9.d.ts +6 -0
  79. package/dist/wallet/index.cjs +298 -68
  80. package/dist/wallet/index.cjs.map +1 -1
  81. package/dist/wallet/index.d.cts +30 -7
  82. package/dist/wallet/index.d.ts +30 -7
  83. package/dist/wallet/index.js +297 -68
  84. package/dist/wallet/index.js.map +1 -1
  85. package/package.json +104 -102
  86. package/dist/Button-BvLF_Km2.d.cts +0 -26
  87. package/dist/Button-DQAZzvyQ.d.ts +0 -26
  88. package/dist/Chip-C5impfYd.d.ts +0 -20
  89. package/dist/Chip-SM52sUbZ.d.cts +0 -20
  90. package/dist/assets/logo-wordmark.svg +0 -1
  91. package/dist/assets/logo.svg +0 -4
  92. package/dist/compositions/app-user.cjs +0 -497
  93. package/dist/compositions/app-user.cjs.map +0 -1
  94. package/dist/compositions/app-user.d.cts +0 -18
  95. package/dist/compositions/app-user.d.ts +0 -18
  96. package/dist/compositions/app-user.js +0 -469
  97. package/dist/compositions/app-user.js.map +0 -1
  98. package/dist/modality/index.cjs +0 -86
  99. package/dist/modality/index.cjs.map +0 -1
  100. package/dist/modality/index.d.cts +0 -26
  101. package/dist/modality/index.d.ts +0 -26
  102. package/dist/modality/index.js +0 -59
  103. package/dist/modality/index.js.map +0 -1
  104. package/dist/models/index.cjs +0 -508
  105. package/dist/models/index.cjs.map +0 -1
  106. package/dist/models/index.d.cts +0 -22
  107. package/dist/models/index.d.ts +0 -22
  108. package/dist/models/index.js +0 -486
  109. package/dist/models/index.js.map +0 -1
  110. package/dist/theme-VMRlhqST.d.cts +0 -9
  111. package/dist/theme-VMRlhqST.d.ts +0 -9
  112. package/dist/wallet/sdk.cjs +0 -206
  113. package/dist/wallet/sdk.cjs.map +0 -1
  114. package/dist/wallet/sdk.d.cts +0 -33
  115. package/dist/wallet/sdk.d.ts +0 -33
  116. package/dist/wallet/sdk.js +0 -175
  117. package/dist/wallet/sdk.js.map +0 -1
@@ -1,206 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/modules/wallet/sdk.ts
21
- var sdk_exports = {};
22
- __export(sdk_exports, {
23
- Balance: () => Balance,
24
- KeyBudget: () => KeyBudget,
25
- KeyExpiry: () => KeyExpiry,
26
- KeyModels: () => KeyModels,
27
- KeyPrefix: () => KeyPrefix
28
- });
29
- module.exports = __toCommonJS(sdk_exports);
30
-
31
- // src/modules/wallet/Balance.tsx
32
- var import_react = require("@pollinations/sdk/react");
33
-
34
- // src/lib/cn.ts
35
- var import_clsx = require("clsx");
36
- var import_tailwind_merge = require("tailwind-merge");
37
- var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({ prefix: "polli" });
38
- function cn(...inputs) {
39
- return twMerge((0, import_clsx.clsx)(...inputs));
40
- }
41
-
42
- // src/primitives/Chip.tsx
43
- var import_jsx_runtime = require("react/jsx-runtime");
44
- var chipSizes = {
45
- sm: "polli:px-2 polli:py-0.5 polli:text-xs",
46
- md: "polli:px-2.5 polli:py-0.5 polli:text-sm",
47
- lg: "polli:px-3 polli:py-1 polli:text-sm"
48
- };
49
- var intentClasses = {
50
- news: "polli:bg-intent-news-bg-light polli:text-intent-news-text",
51
- alpha: "polli:bg-intent-alpha-bg-light polli:text-intent-alpha-text",
52
- neutral: "polli:border polli:border-gray-400/70 polli:bg-gray-100/80 polli:text-gray-900",
53
- success: "polli:border polli:border-intent-success-border polli:bg-intent-success-bg-light polli:text-intent-success-text",
54
- warning: "polli:border polli:border-intent-warning-border polli:bg-intent-warning-bg-light polli:text-intent-warning-text",
55
- danger: "polli:border polli:border-intent-danger-border polli:bg-intent-danger-bg-light polli:text-intent-danger-text"
56
- };
57
- var Chip = ({
58
- theme,
59
- intent,
60
- size = "md",
61
- className,
62
- children,
63
- ...rest
64
- }) => {
65
- const intentClass = intent ? intentClasses[intent] : "polli:bg-theme-bg-active polli:text-theme-text-strong";
66
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
- "span",
68
- {
69
- ...rest,
70
- "data-theme": theme,
71
- className: cn(
72
- "polli:inline-flex polli:shrink-0 polli:items-center polli:gap-1 polli:rounded-lg polli:font-medium polli:leading-normal",
73
- chipSizes[size],
74
- intentClass,
75
- className
76
- ),
77
- children
78
- }
79
- );
80
- };
81
-
82
- // src/modules/wallet/format-pollen.ts
83
- var BUDGET = 5;
84
- var MAX_DECIMALS = 4;
85
- var COMPACT_THRESHOLD = 1e5;
86
- function floorTo(value, decimals) {
87
- const factor = 10 ** decimals;
88
- return Math.floor(value * factor) / factor;
89
- }
90
- function formatCompact(value) {
91
- const abs = Math.abs(value);
92
- const sign = value < 0 ? "-" : "";
93
- const [unit, scale] = abs >= 1e9 ? ["B", 1e9] : abs >= 1e6 ? ["M", 1e6] : ["K", 1e3];
94
- const ratio = abs / scale;
95
- const intDigits = Math.max(1, Math.floor(Math.log10(ratio)) + 1);
96
- const decimals = Math.max(0, 3 - intDigits);
97
- const floored = floorTo(ratio, decimals);
98
- return `${sign}${Number(floored.toFixed(decimals)).toString()}${unit}`;
99
- }
100
- function formatPollen(value) {
101
- if (!Number.isFinite(value) || value === 0) return "0";
102
- const abs = Math.abs(value);
103
- if (abs >= COMPACT_THRESHOLD) return formatCompact(value);
104
- const intDigits = abs >= 1 ? Math.floor(Math.log10(abs)) + 1 : 1;
105
- const decimals = Math.min(MAX_DECIMALS, Math.max(0, BUDGET - intDigits));
106
- const floored = floorTo(value, decimals);
107
- if (floored === 0) return "0";
108
- return Number(floored.toFixed(decimals)).toString();
109
- }
110
-
111
- // src/modules/wallet/Balance.tsx
112
- var import_jsx_runtime2 = require("react/jsx-runtime");
113
- function Balance({ className } = {}) {
114
- const { isLoggedIn } = (0, import_react.useAuthState)();
115
- const { data: balance } = (0, import_react.useAccountBalance)({ enabled: isLoggedIn });
116
- if (!isLoggedIn || balance == null) return null;
117
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
118
- Chip,
119
- {
120
- "data-polli": "balance",
121
- className: cn("polli:tabular-nums", className),
122
- children: [
123
- formatPollen(balance.balance),
124
- " pollen"
125
- ]
126
- }
127
- );
128
- }
129
-
130
- // src/modules/wallet/KeyBudget.tsx
131
- var import_react2 = require("@pollinations/sdk/react");
132
- var import_jsx_runtime3 = require("react/jsx-runtime");
133
- function KeyBudget({ className } = {}) {
134
- const { isLoggedIn } = (0, import_react2.useAuthState)();
135
- const { data: key } = (0, import_react2.useAccountKey)({ enabled: isLoggedIn });
136
- const budget = key?.pollenBudget;
137
- if (!isLoggedIn || budget == null) return null;
138
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
139
- Chip,
140
- {
141
- "data-polli": "key-budget",
142
- className: cn("polli:tabular-nums", className),
143
- children: [
144
- formatPollen(budget),
145
- " pollen"
146
- ]
147
- }
148
- );
149
- }
150
-
151
- // src/modules/wallet/KeyExpiry.tsx
152
- var import_react3 = require("@pollinations/sdk/react");
153
- var import_jsx_runtime4 = require("react/jsx-runtime");
154
- function KeyExpiry({ className } = {}) {
155
- const { isLoggedIn } = (0, import_react3.useAuthState)();
156
- const { data: key } = (0, import_react3.useAccountKey)({ enabled: isLoggedIn });
157
- if (!isLoggedIn || !key?.expiresAt) return null;
158
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
159
- Chip,
160
- {
161
- "data-polli": "key-expiry",
162
- className: cn("polli:tabular-nums", className),
163
- children: key.expiresAt.slice(0, 10)
164
- }
165
- );
166
- }
167
-
168
- // src/modules/wallet/KeyModels.tsx
169
- var import_react4 = require("@pollinations/sdk/react");
170
- var import_jsx_runtime5 = require("react/jsx-runtime");
171
- function KeyModels({ className } = {}) {
172
- const { isLoggedIn } = (0, import_react4.useAuthState)();
173
- const { data: key } = (0, import_react4.useAccountKey)({ enabled: isLoggedIn });
174
- if (!isLoggedIn || !key) return null;
175
- const models = key.permissions?.models ?? null;
176
- const text = models === null ? "All models" : `${models.length} model${models.length === 1 ? "" : "s"}`;
177
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Chip, { "data-polli": "key-models", className, children: text });
178
- }
179
-
180
- // src/modules/wallet/KeyPrefix.tsx
181
- var import_react5 = require("@pollinations/sdk/react");
182
- var import_jsx_runtime6 = require("react/jsx-runtime");
183
- function KeyPrefix({ className } = {}) {
184
- const { apiKey } = (0, import_react5.useAuthState)();
185
- if (!apiKey) return null;
186
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
187
- Chip,
188
- {
189
- "data-polli": "key-prefix",
190
- className: cn("polli:font-mono polli:select-none", className),
191
- children: [
192
- apiKey.slice(0, 7),
193
- "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"
194
- ]
195
- }
196
- );
197
- }
198
- // Annotate the CommonJS export names for ESM import in node:
199
- 0 && (module.exports = {
200
- Balance,
201
- KeyBudget,
202
- KeyExpiry,
203
- KeyModels,
204
- KeyPrefix
205
- });
206
- //# sourceMappingURL=sdk.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/modules/wallet/sdk.ts","../../src/modules/wallet/Balance.tsx","../../src/lib/cn.ts","../../src/primitives/Chip.tsx","../../src/modules/wallet/format-pollen.ts","../../src/modules/wallet/KeyBudget.tsx","../../src/modules/wallet/KeyExpiry.tsx","../../src/modules/wallet/KeyModels.tsx","../../src/modules/wallet/KeyPrefix.tsx"],"sourcesContent":["export { Balance, type BalanceProps } from \"./Balance.tsx\";\nexport { KeyBudget, type KeyBudgetProps } from \"./KeyBudget.tsx\";\nexport { KeyExpiry, type KeyExpiryProps } from \"./KeyExpiry.tsx\";\nexport { KeyModels, type KeyModelsProps } from \"./KeyModels.tsx\";\nexport { KeyPrefix, type KeyPrefixProps } from \"./KeyPrefix.tsx\";\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 { 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 { 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:\n \"polli:border polli:border-gray-400/70 polli:bg-gray-100/80 polli:text-gray-900\",\n success:\n \"polli:border polli:border-intent-success-border polli:bg-intent-success-bg-light polli:text-intent-success-text\",\n warning:\n \"polli:border polli:border-intent-warning-border polli:bg-intent-warning-bg-light polli:text-intent-warning-text\",\n danger: \"polli:border polli:border-intent-danger-border 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","import { useAccountKey, 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 KeyBudgetProps = { className?: string };\n\n/** Renders the current delegated key's remaining budget. `null` until loaded. */\nexport function KeyBudget({ className }: KeyBudgetProps = {}) {\n const { isLoggedIn } = useAuthState();\n const { data: key } = useAccountKey({ enabled: isLoggedIn });\n const budget = key?.pollenBudget;\n if (!isLoggedIn || budget == null) return null;\n return (\n <Chip\n data-polli=\"key-budget\"\n className={cn(\"polli:tabular-nums\", className)}\n >\n {formatPollen(budget)} pollen\n </Chip>\n );\n}\n","import { useAccountKey, useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { Chip } from \"../../primitives/Chip.tsx\";\n\nexport type KeyExpiryProps = { className?: string };\n\n/** Renders the current delegated key's expiry date (YYYY-MM-DD) or `null`. */\nexport function KeyExpiry({ className }: KeyExpiryProps = {}) {\n const { isLoggedIn } = useAuthState();\n const { data: key } = useAccountKey({ enabled: isLoggedIn });\n if (!isLoggedIn || !key?.expiresAt) return null;\n return (\n <Chip\n data-polli=\"key-expiry\"\n className={cn(\"polli:tabular-nums\", className)}\n >\n {key.expiresAt.slice(0, 10)}\n </Chip>\n );\n}\n","import { useAccountKey, useAuthState } from \"@pollinations/sdk/react\";\nimport { Chip } from \"../../primitives/Chip.tsx\";\n\nexport type KeyModelsProps = { className?: string };\n\n/** Renders \"All models\" or \"N models\" for the current key. `null` until loaded. */\nexport function KeyModels({ className }: KeyModelsProps = {}) {\n const { isLoggedIn } = useAuthState();\n const { data: key } = useAccountKey({ enabled: isLoggedIn });\n if (!isLoggedIn || !key) return null;\n const models = key.permissions?.models ?? null;\n const text =\n models === null\n ? \"All models\"\n : `${models.length} model${models.length === 1 ? \"\" : \"s\"}`;\n return (\n <Chip data-polli=\"key-models\" className={className}>\n {text}\n </Chip>\n );\n}\n","import { useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { Chip } from \"../../primitives/Chip.tsx\";\n\nexport type KeyPrefixProps = { className?: string };\n\n/** Renders the first 7 chars of the API key followed by bullets. `null` when logged out. */\nexport function KeyPrefix({ className }: KeyPrefixProps = {}) {\n const { apiKey } = useAuthState();\n if (!apiKey) return null;\n return (\n <Chip\n data-polli=\"key-prefix\"\n className={cn(\"polli:font-mono polli:select-none\", className)}\n >\n {apiKey.slice(0, 7)}\n {\"••••••••\"}\n </Chip>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAgD;;;ACAhD,kBAAqB;AACrB,4BAAoC;AAEpC,IAAM,cAAU,2CAAoB,EAAE,QAAQ,QAAQ,CAAC;AAGhD,SAAS,MAAM,QAA+C;AACjE,SAAO,YAAQ,kBAAK,GAAG,MAAM,CAAC;AAClC;;;AC8CQ;AAzCR,IAAM,YAAY;AAAA,EACd,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACR;AAEA,IAAM,gBAA4C;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AU,EAAE,UAAU,IAAoB,CAAC,GAAG;AAC1D,QAAM,EAAE,WAAW,QAAI,4BAAa;AACpC,QAAM,EAAE,MAAM,IAAI,QAAI,6BAAc,EAAE,SAAS,WAAW,CAAC;AAC3D,MAAI,CAAC,cAAc,CAAC,KAAK,UAAW,QAAO;AAC3C,SACI;AAAA,IAAC;AAAA;AAAA,MACG,cAAW;AAAA,MACX,WAAW,GAAG,sBAAsB,SAAS;AAAA,MAE5C,cAAI,UAAU,MAAM,GAAG,EAAE;AAAA;AAAA,EAC9B;AAER;;;ACnBA,IAAAC,gBAA4C;AAgBpC,IAAAC,sBAAA;AAVD,SAAS,UAAU,EAAE,UAAU,IAAoB,CAAC,GAAG;AAC1D,QAAM,EAAE,WAAW,QAAI,4BAAa;AACpC,QAAM,EAAE,MAAM,IAAI,QAAI,6BAAc,EAAE,SAAS,WAAW,CAAC;AAC3D,MAAI,CAAC,cAAc,CAAC,IAAK,QAAO;AAChC,QAAM,SAAS,IAAI,aAAa,UAAU;AAC1C,QAAM,OACF,WAAW,OACL,eACA,GAAG,OAAO,MAAM,SAAS,OAAO,WAAW,IAAI,KAAK,GAAG;AACjE,SACI,6CAAC,QAAK,cAAW,cAAa,WACzB,gBACL;AAER;;;ACpBA,IAAAC,gBAA6B;AAWrB,IAAAC,sBAAA;AAJD,SAAS,UAAU,EAAE,UAAU,IAAoB,CAAC,GAAG;AAC1D,QAAM,EAAE,OAAO,QAAI,4BAAa;AAChC,MAAI,CAAC,OAAQ,QAAO;AACpB,SACI;AAAA,IAAC;AAAA;AAAA,MACG,cAAW;AAAA,MACX,WAAW,GAAG,qCAAqC,SAAS;AAAA,MAE3D;AAAA,eAAO,MAAM,GAAG,CAAC;AAAA,QACjB;AAAA;AAAA;AAAA,EACL;AAER;","names":["import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime","import_react","import_jsx_runtime"]}
@@ -1,33 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- type BalanceProps = {
4
- className?: string;
5
- };
6
- /** Renders the logged-in user's pollen balance. `null` until loaded. */
7
- declare function Balance({ className }?: BalanceProps): react_jsx_runtime.JSX.Element | null;
8
-
9
- type KeyBudgetProps = {
10
- className?: string;
11
- };
12
- /** Renders the current delegated key's remaining budget. `null` until loaded. */
13
- declare function KeyBudget({ className }?: KeyBudgetProps): react_jsx_runtime.JSX.Element | null;
14
-
15
- type KeyExpiryProps = {
16
- className?: string;
17
- };
18
- /** Renders the current delegated key's expiry date (YYYY-MM-DD) or `null`. */
19
- declare function KeyExpiry({ className }?: KeyExpiryProps): react_jsx_runtime.JSX.Element | null;
20
-
21
- type KeyModelsProps = {
22
- className?: string;
23
- };
24
- /** Renders "All models" or "N models" for the current key. `null` until loaded. */
25
- declare function KeyModels({ className }?: KeyModelsProps): react_jsx_runtime.JSX.Element | null;
26
-
27
- type KeyPrefixProps = {
28
- className?: string;
29
- };
30
- /** Renders the first 7 chars of the API key followed by bullets. `null` when logged out. */
31
- declare function KeyPrefix({ className }?: KeyPrefixProps): react_jsx_runtime.JSX.Element | null;
32
-
33
- export { Balance, type BalanceProps, KeyBudget, type KeyBudgetProps, KeyExpiry, type KeyExpiryProps, KeyModels, type KeyModelsProps, KeyPrefix, type KeyPrefixProps };
@@ -1,33 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- type BalanceProps = {
4
- className?: string;
5
- };
6
- /** Renders the logged-in user's pollen balance. `null` until loaded. */
7
- declare function Balance({ className }?: BalanceProps): react_jsx_runtime.JSX.Element | null;
8
-
9
- type KeyBudgetProps = {
10
- className?: string;
11
- };
12
- /** Renders the current delegated key's remaining budget. `null` until loaded. */
13
- declare function KeyBudget({ className }?: KeyBudgetProps): react_jsx_runtime.JSX.Element | null;
14
-
15
- type KeyExpiryProps = {
16
- className?: string;
17
- };
18
- /** Renders the current delegated key's expiry date (YYYY-MM-DD) or `null`. */
19
- declare function KeyExpiry({ className }?: KeyExpiryProps): react_jsx_runtime.JSX.Element | null;
20
-
21
- type KeyModelsProps = {
22
- className?: string;
23
- };
24
- /** Renders "All models" or "N models" for the current key. `null` until loaded. */
25
- declare function KeyModels({ className }?: KeyModelsProps): react_jsx_runtime.JSX.Element | null;
26
-
27
- type KeyPrefixProps = {
28
- className?: string;
29
- };
30
- /** Renders the first 7 chars of the API key followed by bullets. `null` when logged out. */
31
- declare function KeyPrefix({ className }?: KeyPrefixProps): react_jsx_runtime.JSX.Element | null;
32
-
33
- export { Balance, type BalanceProps, KeyBudget, type KeyBudgetProps, KeyExpiry, type KeyExpiryProps, KeyModels, type KeyModelsProps, KeyPrefix, type KeyPrefixProps };
@@ -1,175 +0,0 @@
1
- // src/modules/wallet/Balance.tsx
2
- import { useAccountBalance, useAuthState } 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/Chip.tsx
13
- import { jsx } from "react/jsx-runtime";
14
- var chipSizes = {
15
- sm: "polli:px-2 polli:py-0.5 polli:text-xs",
16
- md: "polli:px-2.5 polli:py-0.5 polli:text-sm",
17
- lg: "polli:px-3 polli:py-1 polli:text-sm"
18
- };
19
- var intentClasses = {
20
- news: "polli:bg-intent-news-bg-light polli:text-intent-news-text",
21
- alpha: "polli:bg-intent-alpha-bg-light polli:text-intent-alpha-text",
22
- neutral: "polli:border polli:border-gray-400/70 polli:bg-gray-100/80 polli:text-gray-900",
23
- success: "polli:border polli:border-intent-success-border polli:bg-intent-success-bg-light polli:text-intent-success-text",
24
- warning: "polli:border polli:border-intent-warning-border polli:bg-intent-warning-bg-light polli:text-intent-warning-text",
25
- danger: "polli:border polli:border-intent-danger-border polli:bg-intent-danger-bg-light polli:text-intent-danger-text"
26
- };
27
- var Chip = ({
28
- theme,
29
- intent,
30
- size = "md",
31
- className,
32
- children,
33
- ...rest
34
- }) => {
35
- const intentClass = intent ? intentClasses[intent] : "polli:bg-theme-bg-active polli:text-theme-text-strong";
36
- return /* @__PURE__ */ jsx(
37
- "span",
38
- {
39
- ...rest,
40
- "data-theme": theme,
41
- className: cn(
42
- "polli:inline-flex polli:shrink-0 polli:items-center polli:gap-1 polli:rounded-lg polli:font-medium polli:leading-normal",
43
- chipSizes[size],
44
- intentClass,
45
- className
46
- ),
47
- children
48
- }
49
- );
50
- };
51
-
52
- // src/modules/wallet/format-pollen.ts
53
- var BUDGET = 5;
54
- var MAX_DECIMALS = 4;
55
- var COMPACT_THRESHOLD = 1e5;
56
- function floorTo(value, decimals) {
57
- const factor = 10 ** decimals;
58
- return Math.floor(value * factor) / factor;
59
- }
60
- function formatCompact(value) {
61
- const abs = Math.abs(value);
62
- const sign = value < 0 ? "-" : "";
63
- const [unit, scale] = abs >= 1e9 ? ["B", 1e9] : abs >= 1e6 ? ["M", 1e6] : ["K", 1e3];
64
- const ratio = abs / scale;
65
- const intDigits = Math.max(1, Math.floor(Math.log10(ratio)) + 1);
66
- const decimals = Math.max(0, 3 - intDigits);
67
- const floored = floorTo(ratio, decimals);
68
- return `${sign}${Number(floored.toFixed(decimals)).toString()}${unit}`;
69
- }
70
- function formatPollen(value) {
71
- if (!Number.isFinite(value) || value === 0) return "0";
72
- const abs = Math.abs(value);
73
- if (abs >= COMPACT_THRESHOLD) return formatCompact(value);
74
- const intDigits = abs >= 1 ? Math.floor(Math.log10(abs)) + 1 : 1;
75
- const decimals = Math.min(MAX_DECIMALS, Math.max(0, BUDGET - intDigits));
76
- const floored = floorTo(value, decimals);
77
- if (floored === 0) return "0";
78
- return Number(floored.toFixed(decimals)).toString();
79
- }
80
-
81
- // src/modules/wallet/Balance.tsx
82
- import { jsxs } from "react/jsx-runtime";
83
- function Balance({ className } = {}) {
84
- const { isLoggedIn } = useAuthState();
85
- const { data: balance } = useAccountBalance({ enabled: isLoggedIn });
86
- if (!isLoggedIn || balance == null) return null;
87
- return /* @__PURE__ */ jsxs(
88
- Chip,
89
- {
90
- "data-polli": "balance",
91
- className: cn("polli:tabular-nums", className),
92
- children: [
93
- formatPollen(balance.balance),
94
- " pollen"
95
- ]
96
- }
97
- );
98
- }
99
-
100
- // src/modules/wallet/KeyBudget.tsx
101
- import { useAccountKey, useAuthState as useAuthState2 } from "@pollinations/sdk/react";
102
- import { jsxs as jsxs2 } from "react/jsx-runtime";
103
- function KeyBudget({ className } = {}) {
104
- const { isLoggedIn } = useAuthState2();
105
- const { data: key } = useAccountKey({ enabled: isLoggedIn });
106
- const budget = key?.pollenBudget;
107
- if (!isLoggedIn || budget == null) return null;
108
- return /* @__PURE__ */ jsxs2(
109
- Chip,
110
- {
111
- "data-polli": "key-budget",
112
- className: cn("polli:tabular-nums", className),
113
- children: [
114
- formatPollen(budget),
115
- " pollen"
116
- ]
117
- }
118
- );
119
- }
120
-
121
- // src/modules/wallet/KeyExpiry.tsx
122
- import { useAccountKey as useAccountKey2, useAuthState as useAuthState3 } from "@pollinations/sdk/react";
123
- import { jsx as jsx2 } from "react/jsx-runtime";
124
- function KeyExpiry({ className } = {}) {
125
- const { isLoggedIn } = useAuthState3();
126
- const { data: key } = useAccountKey2({ enabled: isLoggedIn });
127
- if (!isLoggedIn || !key?.expiresAt) return null;
128
- return /* @__PURE__ */ jsx2(
129
- Chip,
130
- {
131
- "data-polli": "key-expiry",
132
- className: cn("polli:tabular-nums", className),
133
- children: key.expiresAt.slice(0, 10)
134
- }
135
- );
136
- }
137
-
138
- // src/modules/wallet/KeyModels.tsx
139
- import { useAccountKey as useAccountKey3, useAuthState as useAuthState4 } from "@pollinations/sdk/react";
140
- import { jsx as jsx3 } from "react/jsx-runtime";
141
- function KeyModels({ className } = {}) {
142
- const { isLoggedIn } = useAuthState4();
143
- const { data: key } = useAccountKey3({ enabled: isLoggedIn });
144
- if (!isLoggedIn || !key) return null;
145
- const models = key.permissions?.models ?? null;
146
- const text = models === null ? "All models" : `${models.length} model${models.length === 1 ? "" : "s"}`;
147
- return /* @__PURE__ */ jsx3(Chip, { "data-polli": "key-models", className, children: text });
148
- }
149
-
150
- // src/modules/wallet/KeyPrefix.tsx
151
- import { useAuthState as useAuthState5 } from "@pollinations/sdk/react";
152
- import { jsxs as jsxs3 } from "react/jsx-runtime";
153
- function KeyPrefix({ className } = {}) {
154
- const { apiKey } = useAuthState5();
155
- if (!apiKey) return null;
156
- return /* @__PURE__ */ jsxs3(
157
- Chip,
158
- {
159
- "data-polli": "key-prefix",
160
- className: cn("polli:font-mono polli:select-none", className),
161
- children: [
162
- apiKey.slice(0, 7),
163
- "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"
164
- ]
165
- }
166
- );
167
- }
168
- export {
169
- Balance,
170
- KeyBudget,
171
- KeyExpiry,
172
- KeyModels,
173
- KeyPrefix
174
- };
175
- //# sourceMappingURL=sdk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/modules/wallet/Balance.tsx","../../src/lib/cn.ts","../../src/primitives/Chip.tsx","../../src/modules/wallet/format-pollen.ts","../../src/modules/wallet/KeyBudget.tsx","../../src/modules/wallet/KeyExpiry.tsx","../../src/modules/wallet/KeyModels.tsx","../../src/modules/wallet/KeyPrefix.tsx"],"sourcesContent":["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 { 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 { 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:\n \"polli:border polli:border-gray-400/70 polli:bg-gray-100/80 polli:text-gray-900\",\n success:\n \"polli:border polli:border-intent-success-border polli:bg-intent-success-bg-light polli:text-intent-success-text\",\n warning:\n \"polli:border polli:border-intent-warning-border polli:bg-intent-warning-bg-light polli:text-intent-warning-text\",\n danger: \"polli:border polli:border-intent-danger-border 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","import { useAccountKey, 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 KeyBudgetProps = { className?: string };\n\n/** Renders the current delegated key's remaining budget. `null` until loaded. */\nexport function KeyBudget({ className }: KeyBudgetProps = {}) {\n const { isLoggedIn } = useAuthState();\n const { data: key } = useAccountKey({ enabled: isLoggedIn });\n const budget = key?.pollenBudget;\n if (!isLoggedIn || budget == null) return null;\n return (\n <Chip\n data-polli=\"key-budget\"\n className={cn(\"polli:tabular-nums\", className)}\n >\n {formatPollen(budget)} pollen\n </Chip>\n );\n}\n","import { useAccountKey, useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { Chip } from \"../../primitives/Chip.tsx\";\n\nexport type KeyExpiryProps = { className?: string };\n\n/** Renders the current delegated key's expiry date (YYYY-MM-DD) or `null`. */\nexport function KeyExpiry({ className }: KeyExpiryProps = {}) {\n const { isLoggedIn } = useAuthState();\n const { data: key } = useAccountKey({ enabled: isLoggedIn });\n if (!isLoggedIn || !key?.expiresAt) return null;\n return (\n <Chip\n data-polli=\"key-expiry\"\n className={cn(\"polli:tabular-nums\", className)}\n >\n {key.expiresAt.slice(0, 10)}\n </Chip>\n );\n}\n","import { useAccountKey, useAuthState } from \"@pollinations/sdk/react\";\nimport { Chip } from \"../../primitives/Chip.tsx\";\n\nexport type KeyModelsProps = { className?: string };\n\n/** Renders \"All models\" or \"N models\" for the current key. `null` until loaded. */\nexport function KeyModels({ className }: KeyModelsProps = {}) {\n const { isLoggedIn } = useAuthState();\n const { data: key } = useAccountKey({ enabled: isLoggedIn });\n if (!isLoggedIn || !key) return null;\n const models = key.permissions?.models ?? null;\n const text =\n models === null\n ? \"All models\"\n : `${models.length} model${models.length === 1 ? \"\" : \"s\"}`;\n return (\n <Chip data-polli=\"key-models\" className={className}>\n {text}\n </Chip>\n );\n}\n","import { useAuthState } from \"@pollinations/sdk/react\";\nimport { cn } from \"../../lib/cn.ts\";\nimport { Chip } from \"../../primitives/Chip.tsx\";\n\nexport type KeyPrefixProps = { className?: string };\n\n/** Renders the first 7 chars of the API key followed by bullets. `null` when logged out. */\nexport function KeyPrefix({ className }: KeyPrefixProps = {}) {\n const { apiKey } = useAuthState();\n if (!apiKey) return null;\n return (\n <Chip\n data-polli=\"key-prefix\"\n className={cn(\"polli:font-mono polli:select-none\", className)}\n >\n {apiKey.slice(0, 7)}\n {\"••••••••\"}\n </Chip>\n );\n}\n"],"mappings":";AAAA,SAAS,mBAAmB,oBAAoB;;;ACAhD,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;;;AC8CQ;AAzCR,IAAM,YAAY;AAAA,EACd,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACR;AAEA,IAAM,gBAA4C;AAAA,EAC9C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SACI;AAAA,EACJ,SACI;AAAA,EACJ,SACI;AAAA,EACJ,QAAQ;AACZ;AAaO,IAAM,OAAsB,CAAC;AAAA,EAChC;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,GAAG;AACP,MAAM;AACF,QAAM,cAAc,SACd,cAAc,MAAM,IACpB;AACN,SACI;AAAA,IAAC;AAAA;AAAA,MACI,GAAG;AAAA,MACJ,cAAY;AAAA,MACZ,WAAW;AAAA,QACP;AAAA,QACA,UAAU,IAAI;AAAA,QACd;AAAA,QACA;AAAA,MACJ;AAAA,MAEC;AAAA;AAAA,EACL;AAER;;;AC9DA,IAAM,SAAS;AACf,IAAM,eAAe;AACrB,IAAM,oBAAoB;AAE1B,SAAS,QAAQ,OAAe,UAA0B;AACtD,QAAM,SAAS,MAAM;AACrB,SAAO,KAAK,MAAM,QAAQ,MAAM,IAAI;AACxC;AAEA,SAAS,cAAc,OAAuB;AAC1C,QAAM,MAAM,KAAK,IAAI,KAAK;AAC1B,QAAM,OAAO,QAA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ACF,WAAW,OACL,eACA,GAAG,OAAO,MAAM,SAAS,OAAO,WAAW,IAAI,KAAK,GAAG;AACjE,SACI,gBAAAF,KAAC,QAAK,cAAW,cAAa,WACzB,gBACL;AAER;;;ACpBA,SAAS,gBAAAG,qBAAoB;AAWrB,iBAAAC,aAAA;AAJD,SAAS,UAAU,EAAE,UAAU,IAAoB,CAAC,GAAG;AAC1D,QAAM,EAAE,OAAO,IAAIC,cAAa;AAChC,MAAI,CAAC,OAAQ,QAAO;AACpB,SACI,gBAAAD;AAAA,IAAC;AAAA;AAAA,MACG,cAAW;AAAA,MACX,WAAW,GAAG,qCAAqC,SAAS;AAAA,MAE3D;AAAA,eAAO,MAAM,GAAG,CAAC;AAAA,QACjB;AAAA;AAAA;AAAA,EACL;AAER;","names":["useAuthState","jsxs","useAuthState","useAccountKey","useAuthState","jsx","useAuthState","useAccountKey","useAccountKey","useAuthState","jsx","useAuthState","useAccountKey","useAuthState","jsxs","useAuthState"]}