@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
package/dist/auth/sdk.cjs DELETED
@@ -1,220 +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/auth/sdk.ts
21
- var sdk_exports = {};
22
- __export(sdk_exports, {
23
- LoginButton: () => LoginButton,
24
- LogoutButton: () => LogoutButton,
25
- UserAvatar: () => UserAvatar,
26
- UserEmail: () => UserEmail,
27
- UserName: () => UserName,
28
- WhenLoggedIn: () => WhenLoggedIn,
29
- WhenLoggedOut: () => WhenLoggedOut
30
- });
31
- module.exports = __toCommonJS(sdk_exports);
32
-
33
- // src/modules/auth/LoginButton.tsx
34
- var import_react = require("@pollinations/sdk/react");
35
-
36
- // src/lib/cn.ts
37
- var import_clsx = require("clsx");
38
- var import_tailwind_merge = require("tailwind-merge");
39
- var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({ prefix: "polli" });
40
- function cn(...inputs) {
41
- return twMerge((0, import_clsx.clsx)(...inputs));
42
- }
43
-
44
- // src/primitives/Button.tsx
45
- var import_jsx_runtime = require("react/jsx-runtime");
46
- var sizes = {
47
- small: "polli:px-2 polli:pt-0.5 polli:pb-1",
48
- medium: "polli:px-4 polli:pt-1.5 polli:pb-2",
49
- large: "polli:px-6 polli:py-3"
50
- };
51
- var themeClasses = "polli:bg-theme-bg-active polli:text-theme-text-base polli:hover:bg-theme-bg-hover polli:transition-colors";
52
- var intentClasses = {
53
- danger: "polli:bg-intent-danger-bg-light polli:text-intent-danger-text polli:hover:bg-[oklch(0.88_0.075_25)] polli:transition-colors"
54
- };
55
- var buttonClasses = ({
56
- theme: _theme,
57
- intent,
58
- size,
59
- className,
60
- disabled
61
- }) => {
62
- const colorClasses = intent ? intentClasses[intent] : themeClasses;
63
- return cn(
64
- "polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:self-center polli:placeholder-green-950 polli:font-medium polli:leading-normal polli:box-border",
65
- disabled ? "polli:opacity-50 polli:cursor-not-allowed" : "polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer",
66
- colorClasses,
67
- sizes[size || "medium"],
68
- className
69
- );
70
- };
71
- function Button({
72
- as,
73
- children,
74
- theme,
75
- intent,
76
- size,
77
- className,
78
- disabled,
79
- ...buttonProps
80
- }) {
81
- const Component = as || "button";
82
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
- Component,
84
- {
85
- "data-theme": intent ? void 0 : theme,
86
- className: buttonClasses({
87
- theme,
88
- intent,
89
- size,
90
- className,
91
- disabled
92
- }),
93
- disabled,
94
- ...buttonProps,
95
- children
96
- }
97
- );
98
- }
99
-
100
- // src/modules/auth/LoginButton.tsx
101
- var import_jsx_runtime2 = require("react/jsx-runtime");
102
- function LoginButton({ children, ...buttonProps }) {
103
- const { isLoggedIn } = (0, import_react.useAuthState)();
104
- const { login } = (0, import_react.useAuthActions)();
105
- if (isLoggedIn) return null;
106
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { ...buttonProps, onClick: () => login(), children });
107
- }
108
-
109
- // src/modules/auth/LogoutButton.tsx
110
- var import_react2 = require("@pollinations/sdk/react");
111
- var import_jsx_runtime3 = require("react/jsx-runtime");
112
- function LogoutButton({ children, ...buttonProps }) {
113
- const { isLoggedIn } = (0, import_react2.useAuthState)();
114
- const { logout } = (0, import_react2.useAuthActions)();
115
- if (!isLoggedIn) return null;
116
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button, { ...buttonProps, onClick: () => logout(), children });
117
- }
118
-
119
- // src/modules/auth/UserAvatar.tsx
120
- var import_react3 = require("@pollinations/sdk/react");
121
- var import_jsx_runtime4 = require("react/jsx-runtime");
122
- var sizeClass = {
123
- sm: "polli:w-6 polli:h-6 polli:text-xs",
124
- md: "polli:w-9 polli:h-9 polli:text-sm",
125
- lg: "polli:w-12 polli:h-12 polli:text-base"
126
- };
127
- function initials(name) {
128
- const parts = name.trim().split(/\s+/).filter(Boolean);
129
- if (parts.length === 0) return null;
130
- if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;
131
- const first = parts[0][0] ?? "";
132
- const last = parts[parts.length - 1][0] ?? "";
133
- return (first + last).toUpperCase() || null;
134
- }
135
- function UserAvatar({ size = "md", className }) {
136
- const { isLoggedIn } = (0, import_react3.useAuthState)();
137
- const { data: profile } = (0, import_react3.useAccountProfile)({ enabled: isLoggedIn });
138
- if (!isLoggedIn) return null;
139
- const base = cn(
140
- "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",
141
- sizeClass[size],
142
- className
143
- );
144
- if (profile?.image) {
145
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
146
- "img",
147
- {
148
- "data-polli": "user-avatar",
149
- src: profile.image,
150
- alt: profile.name ?? "",
151
- className: base
152
- }
153
- );
154
- }
155
- const label = profile?.name ? initials(profile.name) : null;
156
- if (!label) return null;
157
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
158
- "div",
159
- {
160
- "data-polli": "user-avatar",
161
- role: "img",
162
- "aria-label": profile?.name ?? void 0,
163
- className: base,
164
- children: label
165
- }
166
- );
167
- }
168
-
169
- // src/modules/auth/UserEmail.tsx
170
- var import_react4 = require("@pollinations/sdk/react");
171
- var import_jsx_runtime5 = require("react/jsx-runtime");
172
- function UserEmail({ className }) {
173
- const { isLoggedIn } = (0, import_react4.useAuthState)();
174
- const { data: profile } = (0, import_react4.useAccountProfile)({ enabled: isLoggedIn });
175
- if (!isLoggedIn || !profile?.email) return null;
176
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-polli": "user-email", className, children: profile.email });
177
- }
178
-
179
- // src/modules/auth/UserName.tsx
180
- var import_react5 = require("@pollinations/sdk/react");
181
- var import_jsx_runtime6 = require("react/jsx-runtime");
182
- function UserName({ className }) {
183
- const { isLoggedIn } = (0, import_react5.useAuthState)();
184
- const { data: profile } = (0, import_react5.useAccountProfile)({ enabled: isLoggedIn });
185
- if (!isLoggedIn || !profile) return null;
186
- const display = profile.name || profile.githubUsername;
187
- if (!display) return null;
188
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-polli": "user-name", className, children: display });
189
- }
190
-
191
- // src/modules/auth/WhenLoggedIn.tsx
192
- var import_react6 = require("@pollinations/sdk/react");
193
- var import_react7 = require("react");
194
- var import_jsx_runtime7 = require("react/jsx-runtime");
195
- function WhenLoggedIn({ children }) {
196
- const { isLoggedIn } = (0, import_react6.useAuthState)();
197
- if (!isLoggedIn) return null;
198
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.Fragment, { children });
199
- }
200
-
201
- // src/modules/auth/WhenLoggedOut.tsx
202
- var import_react8 = require("@pollinations/sdk/react");
203
- var import_react9 = require("react");
204
- var import_jsx_runtime8 = require("react/jsx-runtime");
205
- function WhenLoggedOut({ children }) {
206
- const { isLoggedIn } = (0, import_react8.useAuthState)();
207
- if (isLoggedIn) return null;
208
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react9.Fragment, { children });
209
- }
210
- // Annotate the CommonJS export names for ESM import in node:
211
- 0 && (module.exports = {
212
- LoginButton,
213
- LogoutButton,
214
- UserAvatar,
215
- UserEmail,
216
- UserName,
217
- WhenLoggedIn,
218
- WhenLoggedOut
219
- });
220
- //# sourceMappingURL=sdk.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/modules/auth/sdk.ts","../../src/modules/auth/LoginButton.tsx","../../src/lib/cn.ts","../../src/primitives/Button.tsx","../../src/modules/auth/LogoutButton.tsx","../../src/modules/auth/UserAvatar.tsx","../../src/modules/auth/UserEmail.tsx","../../src/modules/auth/UserName.tsx","../../src/modules/auth/WhenLoggedIn.tsx","../../src/modules/auth/WhenLoggedOut.tsx"],"sourcesContent":["export { LoginButton, type LoginButtonProps } from \"./LoginButton.tsx\";\nexport { LogoutButton, type LogoutButtonProps } from \"./LogoutButton.tsx\";\nexport { UserAvatar, type UserAvatarProps } from \"./UserAvatar.tsx\";\nexport { UserEmail, type UserEmailProps } from \"./UserEmail.tsx\";\nexport { UserName, type UserNameProps } from \"./UserName.tsx\";\nexport { WhenLoggedIn, type WhenLoggedInProps } from \"./WhenLoggedIn.tsx\";\nexport { WhenLoggedOut, type WhenLoggedOutProps } from \"./WhenLoggedOut.tsx\";\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 { 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 { 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 small: \"polli:px-2 polli:pt-0.5 polli:pb-1\",\n medium: \"polli:px-4 polli:pt-1.5 polli:pb-2\",\n large: \"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-[oklch(0.88_0.075_25)] 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:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:self-center polli:placeholder-green-950 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 || \"medium\"],\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 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 { useAuthActions, useAuthState } from \"@pollinations/sdk/react\";\nimport type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"../../primitives/Button.tsx\";\n\nexport type LogoutButtonProps = Omit<\n ButtonProps<\"button\">,\n \"as\" | \"onClick\" | \"children\"\n> & {\n children: ReactNode;\n};\n\n/** Button that clears the session. `null` when logged out. */\nexport function LogoutButton({ children, ...buttonProps }: LogoutButtonProps) {\n const { isLoggedIn } = useAuthState();\n const { logout } = useAuthActions();\n if (!isLoggedIn) return null;\n return (\n <Button {...buttonProps} onClick={() => logout()}>\n {children}\n </Button>\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 UserEmailProps = { className?: string };\n\n/** Renders `profile.email`. `null` when logged out or the key lacks `profile` scope. */\nexport function UserEmail({ className }: UserEmailProps) {\n const { isLoggedIn } = useAuthState();\n const { data: profile } = useAccountProfile({ enabled: isLoggedIn });\n if (!isLoggedIn || !profile?.email) return null;\n return (\n <span data-polli=\"user-email\" className={className}>\n {profile.email}\n </span>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA6C;;;ACA7C,kBAAqB;AACrB,4BAAoC;AAEpC,IAAM,cAAU,2CAAoB,EAAE,QAAQ,QAAQ,CAAC;AAGhD,SAAS,MAAM,QAA+C;AACjE,SAAO,YAAQ,kBAAK,GAAG,MAAM,CAAC;AAClC;;;ACiEQ;AAlER,IAAM,QAAQ;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX;AAGA,IAAM,eACF;AAKJ,IAAM,gBAA8C;AAAA,EAChD,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MAAM,QAAQ,QAAI,iCAAkB,EAAE,SAAS,WAAW,CAAC;AACnE,MAAI,CAAC,cAAc,CAAC,SAAS,MAAO,QAAO;AAC3C,SACI,6CAAC,UAAK,cAAW,cAAa,WACzB,kBAAQ,OACb;AAER;;;ACdA,IAAAC,gBAAgD;AAgBxC,IAAAC,sBAAA;AAPD,SAAS,SAAS,EAAE,UAAU,GAAkB;AACnD,QAAM,EAAE,WAAW,QAAI,4BAAa;AACpC,QAAM,EAAE,MAAM,QAAQ,QAAI,iCAAkB,EAAE,SAAS,WAAW,CAAC;AACnE,MAAI,CAAC,cAAc,CAAC,QAAS,QAAO;AACpC,QAAM,UAAU,QAAQ,QAAQ,QAAQ;AACxC,MAAI,CAAC,QAAS,QAAO;AACrB,SACI,6CAAC,UAAK,cAAW,aAAY,WACxB,mBACL;AAER;;;ACpBA,IAAAC,gBAA6B;AAC7B,IAAAA,gBAAyC;AAQ9B,IAAAC,sBAAA;AAHJ,SAAS,aAAa,EAAE,SAAS,GAAsB;AAC1D,QAAM,EAAE,WAAW,QAAI,4BAAa;AACpC,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO,6CAAC,0BAAU,UAAS;AAC/B;;;ACVA,IAAAC,gBAA6B;AAC7B,IAAAA,gBAAyC;AAQ9B,IAAAC,sBAAA;AAHJ,SAAS,cAAc,EAAE,SAAS,GAAuB;AAC5D,QAAM,EAAE,WAAW,QAAI,4BAAa;AACpC,MAAI,WAAY,QAAO;AACvB,SAAO,6CAAC,0BAAU,UAAS;AAC/B;","names":["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","import_react","import_jsx_runtime"]}
@@ -1,53 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
- import { a as ButtonProps } from '../Button-CWUBCiIc.cjs';
4
- import '../theme-VMRlhqST.cjs';
5
-
6
- type LoginButtonProps = Omit<ButtonProps<"button">, "as" | "onClick" | "children"> & {
7
- children: ReactNode;
8
- };
9
- /** Button that kicks off the auth redirect. `null` when already logged in. */
10
- declare function LoginButton({ children, ...buttonProps }: LoginButtonProps): react_jsx_runtime.JSX.Element | null;
11
-
12
- type LogoutButtonProps = Omit<ButtonProps<"button">, "as" | "onClick" | "children"> & {
13
- children: ReactNode;
14
- };
15
- /** Button that clears the session. `null` when logged out. */
16
- declare function LogoutButton({ children, ...buttonProps }: LogoutButtonProps): react_jsx_runtime.JSX.Element | null;
17
-
18
- type UserAvatarProps = {
19
- size?: "sm" | "md" | "lg";
20
- className?: string;
21
- };
22
- /** Avatar from `profile.image`, or initials from `profile.name`. `null` otherwise. */
23
- declare function UserAvatar({ size, className }: UserAvatarProps): react_jsx_runtime.JSX.Element | null;
24
-
25
- type UserEmailProps = {
26
- className?: string;
27
- };
28
- /** Renders `profile.email`. `null` when logged out or the key lacks `profile` scope. */
29
- declare function UserEmail({ className }: UserEmailProps): react_jsx_runtime.JSX.Element | null;
30
-
31
- type UserNameProps = {
32
- className?: string;
33
- };
34
- /**
35
- * Renders the user's display name. Falls back to GitHub username when the
36
- * `profile` scope was not granted (or `name` is empty). `null` when logged
37
- * out, or when neither name nor GitHub username is available.
38
- */
39
- declare function UserName({ className }: UserNameProps): react_jsx_runtime.JSX.Element | null;
40
-
41
- type WhenLoggedInProps = {
42
- children: ReactNode;
43
- };
44
- /** Renders `children` only when a user is signed in. */
45
- declare function WhenLoggedIn({ children }: WhenLoggedInProps): react_jsx_runtime.JSX.Element | null;
46
-
47
- type WhenLoggedOutProps = {
48
- children: ReactNode;
49
- };
50
- /** Renders `children` only when no user is signed in. */
51
- declare function WhenLoggedOut({ children }: WhenLoggedOutProps): react_jsx_runtime.JSX.Element | null;
52
-
53
- export { LoginButton, type LoginButtonProps, LogoutButton, type LogoutButtonProps, UserAvatar, type UserAvatarProps, UserEmail, type UserEmailProps, UserName, type UserNameProps, WhenLoggedIn, type WhenLoggedInProps, WhenLoggedOut, type WhenLoggedOutProps };
@@ -1,53 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
- import { a as ButtonProps } from '../Button-Bn8pGg6N.js';
4
- import '../theme-VMRlhqST.js';
5
-
6
- type LoginButtonProps = Omit<ButtonProps<"button">, "as" | "onClick" | "children"> & {
7
- children: ReactNode;
8
- };
9
- /** Button that kicks off the auth redirect. `null` when already logged in. */
10
- declare function LoginButton({ children, ...buttonProps }: LoginButtonProps): react_jsx_runtime.JSX.Element | null;
11
-
12
- type LogoutButtonProps = Omit<ButtonProps<"button">, "as" | "onClick" | "children"> & {
13
- children: ReactNode;
14
- };
15
- /** Button that clears the session. `null` when logged out. */
16
- declare function LogoutButton({ children, ...buttonProps }: LogoutButtonProps): react_jsx_runtime.JSX.Element | null;
17
-
18
- type UserAvatarProps = {
19
- size?: "sm" | "md" | "lg";
20
- className?: string;
21
- };
22
- /** Avatar from `profile.image`, or initials from `profile.name`. `null` otherwise. */
23
- declare function UserAvatar({ size, className }: UserAvatarProps): react_jsx_runtime.JSX.Element | null;
24
-
25
- type UserEmailProps = {
26
- className?: string;
27
- };
28
- /** Renders `profile.email`. `null` when logged out or the key lacks `profile` scope. */
29
- declare function UserEmail({ className }: UserEmailProps): react_jsx_runtime.JSX.Element | null;
30
-
31
- type UserNameProps = {
32
- className?: string;
33
- };
34
- /**
35
- * Renders the user's display name. Falls back to GitHub username when the
36
- * `profile` scope was not granted (or `name` is empty). `null` when logged
37
- * out, or when neither name nor GitHub username is available.
38
- */
39
- declare function UserName({ className }: UserNameProps): react_jsx_runtime.JSX.Element | null;
40
-
41
- type WhenLoggedInProps = {
42
- children: ReactNode;
43
- };
44
- /** Renders `children` only when a user is signed in. */
45
- declare function WhenLoggedIn({ children }: WhenLoggedInProps): react_jsx_runtime.JSX.Element | null;
46
-
47
- type WhenLoggedOutProps = {
48
- children: ReactNode;
49
- };
50
- /** Renders `children` only when no user is signed in. */
51
- declare function WhenLoggedOut({ children }: WhenLoggedOutProps): react_jsx_runtime.JSX.Element | null;
52
-
53
- export { LoginButton, type LoginButtonProps, LogoutButton, type LogoutButtonProps, UserAvatar, type UserAvatarProps, UserEmail, type UserEmailProps, UserName, type UserNameProps, WhenLoggedIn, type WhenLoggedInProps, WhenLoggedOut, type WhenLoggedOutProps };
package/dist/auth/sdk.js DELETED
@@ -1,187 +0,0 @@
1
- // src/modules/auth/LoginButton.tsx
2
- import { useAuthActions, 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/Button.tsx
13
- import { jsx } from "react/jsx-runtime";
14
- var sizes = {
15
- small: "polli:px-2 polli:pt-0.5 polli:pb-1",
16
- medium: "polli:px-4 polli:pt-1.5 polli:pb-2",
17
- large: "polli:px-6 polli:py-3"
18
- };
19
- var themeClasses = "polli:bg-theme-bg-active polli:text-theme-text-base polli:hover:bg-theme-bg-hover polli:transition-colors";
20
- var intentClasses = {
21
- danger: "polli:bg-intent-danger-bg-light polli:text-intent-danger-text polli:hover:bg-[oklch(0.88_0.075_25)] polli:transition-colors"
22
- };
23
- var buttonClasses = ({
24
- theme: _theme,
25
- intent,
26
- size,
27
- className,
28
- disabled
29
- }) => {
30
- const colorClasses = intent ? intentClasses[intent] : themeClasses;
31
- return cn(
32
- "polli:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:self-center polli:placeholder-green-950 polli:font-medium polli:leading-normal polli:box-border",
33
- disabled ? "polli:opacity-50 polli:cursor-not-allowed" : "polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer",
34
- colorClasses,
35
- sizes[size || "medium"],
36
- className
37
- );
38
- };
39
- function Button({
40
- as,
41
- children,
42
- theme,
43
- intent,
44
- size,
45
- className,
46
- disabled,
47
- ...buttonProps
48
- }) {
49
- const Component = as || "button";
50
- return /* @__PURE__ */ jsx(
51
- Component,
52
- {
53
- "data-theme": intent ? void 0 : theme,
54
- className: buttonClasses({
55
- theme,
56
- intent,
57
- size,
58
- className,
59
- disabled
60
- }),
61
- disabled,
62
- ...buttonProps,
63
- children
64
- }
65
- );
66
- }
67
-
68
- // src/modules/auth/LoginButton.tsx
69
- import { jsx as jsx2 } from "react/jsx-runtime";
70
- function LoginButton({ children, ...buttonProps }) {
71
- const { isLoggedIn } = useAuthState();
72
- const { login } = useAuthActions();
73
- if (isLoggedIn) return null;
74
- return /* @__PURE__ */ jsx2(Button, { ...buttonProps, onClick: () => login(), children });
75
- }
76
-
77
- // src/modules/auth/LogoutButton.tsx
78
- import { useAuthActions as useAuthActions2, useAuthState as useAuthState2 } from "@pollinations/sdk/react";
79
- import { jsx as jsx3 } from "react/jsx-runtime";
80
- function LogoutButton({ children, ...buttonProps }) {
81
- const { isLoggedIn } = useAuthState2();
82
- const { logout } = useAuthActions2();
83
- if (!isLoggedIn) return null;
84
- return /* @__PURE__ */ jsx3(Button, { ...buttonProps, onClick: () => logout(), children });
85
- }
86
-
87
- // src/modules/auth/UserAvatar.tsx
88
- import { useAccountProfile, useAuthState as useAuthState3 } from "@pollinations/sdk/react";
89
- import { jsx as jsx4 } from "react/jsx-runtime";
90
- var sizeClass = {
91
- sm: "polli:w-6 polli:h-6 polli:text-xs",
92
- md: "polli:w-9 polli:h-9 polli:text-sm",
93
- lg: "polli:w-12 polli:h-12 polli:text-base"
94
- };
95
- function initials(name) {
96
- const parts = name.trim().split(/\s+/).filter(Boolean);
97
- if (parts.length === 0) return null;
98
- if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;
99
- const first = parts[0][0] ?? "";
100
- const last = parts[parts.length - 1][0] ?? "";
101
- return (first + last).toUpperCase() || null;
102
- }
103
- function UserAvatar({ size = "md", className }) {
104
- const { isLoggedIn } = useAuthState3();
105
- const { data: profile } = useAccountProfile({ enabled: isLoggedIn });
106
- if (!isLoggedIn) return null;
107
- const base = cn(
108
- "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",
109
- sizeClass[size],
110
- className
111
- );
112
- if (profile?.image) {
113
- return /* @__PURE__ */ jsx4(
114
- "img",
115
- {
116
- "data-polli": "user-avatar",
117
- src: profile.image,
118
- alt: profile.name ?? "",
119
- className: base
120
- }
121
- );
122
- }
123
- const label = profile?.name ? initials(profile.name) : null;
124
- if (!label) return null;
125
- return /* @__PURE__ */ jsx4(
126
- "div",
127
- {
128
- "data-polli": "user-avatar",
129
- role: "img",
130
- "aria-label": profile?.name ?? void 0,
131
- className: base,
132
- children: label
133
- }
134
- );
135
- }
136
-
137
- // src/modules/auth/UserEmail.tsx
138
- import { useAccountProfile as useAccountProfile2, useAuthState as useAuthState4 } from "@pollinations/sdk/react";
139
- import { jsx as jsx5 } from "react/jsx-runtime";
140
- function UserEmail({ className }) {
141
- const { isLoggedIn } = useAuthState4();
142
- const { data: profile } = useAccountProfile2({ enabled: isLoggedIn });
143
- if (!isLoggedIn || !profile?.email) return null;
144
- return /* @__PURE__ */ jsx5("span", { "data-polli": "user-email", className, children: profile.email });
145
- }
146
-
147
- // src/modules/auth/UserName.tsx
148
- import { useAccountProfile as useAccountProfile3, useAuthState as useAuthState5 } from "@pollinations/sdk/react";
149
- import { jsx as jsx6 } from "react/jsx-runtime";
150
- function UserName({ className }) {
151
- const { isLoggedIn } = useAuthState5();
152
- const { data: profile } = useAccountProfile3({ enabled: isLoggedIn });
153
- if (!isLoggedIn || !profile) return null;
154
- const display = profile.name || profile.githubUsername;
155
- if (!display) return null;
156
- return /* @__PURE__ */ jsx6("span", { "data-polli": "user-name", className, children: display });
157
- }
158
-
159
- // src/modules/auth/WhenLoggedIn.tsx
160
- import { useAuthState as useAuthState6 } from "@pollinations/sdk/react";
161
- import { Fragment } from "react";
162
- import { jsx as jsx7 } from "react/jsx-runtime";
163
- function WhenLoggedIn({ children }) {
164
- const { isLoggedIn } = useAuthState6();
165
- if (!isLoggedIn) return null;
166
- return /* @__PURE__ */ jsx7(Fragment, { children });
167
- }
168
-
169
- // src/modules/auth/WhenLoggedOut.tsx
170
- import { useAuthState as useAuthState7 } from "@pollinations/sdk/react";
171
- import { Fragment as Fragment2 } from "react";
172
- import { jsx as jsx8 } from "react/jsx-runtime";
173
- function WhenLoggedOut({ children }) {
174
- const { isLoggedIn } = useAuthState7();
175
- if (isLoggedIn) return null;
176
- return /* @__PURE__ */ jsx8(Fragment2, { children });
177
- }
178
- export {
179
- LoginButton,
180
- LogoutButton,
181
- UserAvatar,
182
- UserEmail,
183
- UserName,
184
- WhenLoggedIn,
185
- WhenLoggedOut
186
- };
187
- //# sourceMappingURL=sdk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/modules/auth/LoginButton.tsx","../../src/lib/cn.ts","../../src/primitives/Button.tsx","../../src/modules/auth/LogoutButton.tsx","../../src/modules/auth/UserAvatar.tsx","../../src/modules/auth/UserEmail.tsx","../../src/modules/auth/UserName.tsx","../../src/modules/auth/WhenLoggedIn.tsx","../../src/modules/auth/WhenLoggedOut.tsx"],"sourcesContent":["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 { 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 { 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 small: \"polli:px-2 polli:pt-0.5 polli:pb-1\",\n medium: \"polli:px-4 polli:pt-1.5 polli:pb-2\",\n large: \"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-[oklch(0.88_0.075_25)] 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:inline-flex polli:items-center polli:justify-center polli:rounded-full polli:self-center polli:placeholder-green-950 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 || \"medium\"],\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 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 { useAuthActions, useAuthState } from \"@pollinations/sdk/react\";\nimport type { ReactNode } from \"react\";\nimport { Button, type ButtonProps } from \"../../primitives/Button.tsx\";\n\nexport type LogoutButtonProps = Omit<\n ButtonProps<\"button\">,\n \"as\" | \"onClick\" | \"children\"\n> & {\n children: ReactNode;\n};\n\n/** Button that clears the session. `null` when logged out. */\nexport function LogoutButton({ children, ...buttonProps }: LogoutButtonProps) {\n const { isLoggedIn } = useAuthState();\n const { logout } = useAuthActions();\n if (!isLoggedIn) return null;\n return (\n <Button {...buttonProps} onClick={() => logout()}>\n {children}\n </Button>\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 UserEmailProps = { className?: string };\n\n/** Renders `profile.email`. `null` when logged out or the key lacks `profile` scope. */\nexport function UserEmail({ className }: UserEmailProps) {\n const { isLoggedIn } = useAuthState();\n const { data: profile } = useAccountProfile({ enabled: isLoggedIn });\n if (!isLoggedIn || !profile?.email) return null;\n return (\n <span data-polli=\"user-email\" className={className}>\n {profile.email}\n </span>\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"],"mappings":";AAAA,SAAS,gBAAgB,oBAAoB;;;ACA7C,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;;;ACiEQ;AAlER,IAAM,QAAQ;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX;AAGA,IAAM,eACF;AAKJ,IAAM,gBAA8C;AAAA,EAChD,QACI;AAER;AAYA,IAAM,gBAAgB,CAAC;AAAA,EACnB,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,MAAgD;AAC5C,QAAM,eAAe,SAAS,cAAc,MAAM,IAAI;AACtD,SAAO;AAAA,IACH;AAAA,IACA,WACM,8CACA;AAAA,IACN;AAAA,IACA,MAAM,QAAQ,QAAQ;AAAA,IACtB;AAAA,EACJ;AACJ;AAOO,SAAS,OAA+C;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACP,GAAmB;AACf,QAAM,YAA+B,MAAM;AAE3C,SACI;AAAA,IAAC;AAAA;AAAA,MAEG,cAAY,SAAS,SAAY;AAAA,MACjC,WAAW,cAAc;AAAA,QACrB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA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AI,CAAC,QAAS,QAAO;AACrB,SACI,gBAAAE,KAAC,UAAK,cAAW,aAAY,WACxB,mBACL;AAER;;;ACpBA,SAAS,gBAAAC,qBAAoB;AAC7B,SAAS,gBAAgC;AAQ9B,gBAAAC,YAAA;AAHJ,SAAS,aAAa,EAAE,SAAS,GAAsB;AAC1D,QAAM,EAAE,WAAW,IAAID,cAAa;AACpC,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO,gBAAAC,KAAC,YAAU,UAAS;AAC/B;;;ACVA,SAAS,gBAAAC,qBAAoB;AAC7B,SAAS,YAAAC,iBAAgC;AAQ9B,gBAAAC,YAAA;AAHJ,SAAS,cAAc,EAAE,SAAS,GAAuB;AAC5D,QAAM,EAAE,WAAW,IAAIF,cAAa;AACpC,MAAI,WAAY,QAAO;AACvB,SAAO,gBAAAE,KAACD,WAAA,EAAU,UAAS;AAC/B;","names":["jsx","useAuthActions","useAuthState","jsx","useAuthState","useAuthActions","useAuthState","jsx","useAuthState","useAccountProfile","useAuthState","jsx","useAccountProfile","useAuthState","jsx","useAuthState","jsx","useAuthState","Fragment","jsx"]}
@@ -1,83 +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/modality/index.ts
21
- var modality_exports = {};
22
- __export(modality_exports, {
23
- getModalityColors: () => getModalityColors
24
- });
25
- module.exports = __toCommonJS(modality_exports);
26
-
27
- // src/modules/modality/colors.ts
28
- var MODALITY_COLORS = {
29
- text: {
30
- theme: "blue",
31
- filled: "polli:bg-blue-200 polli:text-blue-900",
32
- hover: "polli:hover:bg-blue-100 polli:hover:text-blue-900",
33
- text: "polli:text-blue-800"
34
- },
35
- image: {
36
- theme: "pink",
37
- filled: "polli:bg-pink-200 polli:text-pink-900",
38
- hover: "polli:hover:bg-pink-100 polli:hover:text-pink-900",
39
- text: "polli:text-pink-800"
40
- },
41
- video: {
42
- theme: "teal",
43
- filled: "polli:bg-teal-200 polli:text-teal-900",
44
- hover: "polli:hover:bg-teal-100 polli:hover:text-teal-900",
45
- text: "polli:text-teal-800"
46
- },
47
- audio: {
48
- theme: "violet",
49
- filled: "polli:bg-violet-200 polli:text-violet-900",
50
- hover: "polli:hover:bg-violet-100 polli:hover:text-violet-900",
51
- text: "polli:text-violet-800"
52
- },
53
- realtime: {
54
- theme: "green",
55
- filled: "polli:bg-green-200 polli:text-green-900",
56
- hover: "polli:hover:bg-green-100 polli:hover:text-green-900",
57
- text: "polli:text-green-800"
58
- },
59
- embedding: {
60
- theme: "amber",
61
- filled: "polli:bg-amber-200 polli:text-amber-900",
62
- hover: "polli:hover:bg-amber-100 polli:hover:text-amber-900",
63
- text: "polli:text-amber-800"
64
- }
65
- };
66
- function normalize(category) {
67
- const lower = category.toLowerCase();
68
- if (lower === "images") return "image";
69
- if (lower === "embeddings") return "embedding";
70
- if (lower === "text" || lower === "image" || lower === "video" || lower === "audio" || lower === "realtime" || lower === "embedding") {
71
- return lower;
72
- }
73
- return null;
74
- }
75
- function getModalityColors(category) {
76
- const key = normalize(category);
77
- return key ? MODALITY_COLORS[key] : null;
78
- }
79
- // Annotate the CommonJS export names for ESM import in node:
80
- 0 && (module.exports = {
81
- getModalityColors
82
- });
83
- //# sourceMappingURL=index.cjs.map