@pollinations/ui 0.1.0-alpha.0 → 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 (64) hide show
  1. package/README.md +28 -65
  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/{compositions/app-user.cjs → app-user-menu/sdk.cjs} +148 -148
  5. package/dist/app-user-menu/sdk.cjs.map +1 -0
  6. package/dist/{compositions/app-user.js → app-user-menu/sdk.js} +127 -127
  7. package/dist/app-user-menu/sdk.js.map +1 -0
  8. package/dist/app.css +94 -3
  9. package/dist/auth/index.cjs +2 -2
  10. package/dist/auth/index.cjs.map +1 -1
  11. package/dist/auth/index.js +2 -2
  12. package/dist/auth/index.js.map +1 -1
  13. package/dist/{models → gen}/index.cjs +40 -71
  14. package/dist/gen/index.cjs.map +1 -0
  15. package/dist/gen/index.d.cts +35 -0
  16. package/dist/gen/index.d.ts +35 -0
  17. package/dist/{models → gen}/index.js +31 -66
  18. package/dist/gen/index.js.map +1 -0
  19. package/dist/index.cjs +1594 -1142
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +268 -178
  22. package/dist/index.d.ts +268 -178
  23. package/dist/index.js +1581 -1134
  24. package/dist/index.js.map +1 -1
  25. package/dist/styles.css +1 -1
  26. package/dist/theme-jRPPBmld.d.cts +20 -0
  27. package/dist/theme-jRPPBmld.d.ts +20 -0
  28. package/dist/wallet/index.cjs +4 -4
  29. package/dist/wallet/index.cjs.map +1 -1
  30. package/dist/wallet/index.d.cts +2 -2
  31. package/dist/wallet/index.d.ts +2 -2
  32. package/dist/wallet/index.js +4 -4
  33. package/dist/wallet/index.js.map +1 -1
  34. package/package.json +9 -24
  35. package/dist/Button-BvLF_Km2.d.cts +0 -26
  36. package/dist/Button-DQAZzvyQ.d.ts +0 -26
  37. package/dist/auth/sdk.cjs +0 -221
  38. package/dist/auth/sdk.cjs.map +0 -1
  39. package/dist/auth/sdk.d.cts +0 -53
  40. package/dist/auth/sdk.d.ts +0 -53
  41. package/dist/auth/sdk.js +0 -188
  42. package/dist/auth/sdk.js.map +0 -1
  43. package/dist/compositions/app-user.cjs.map +0 -1
  44. package/dist/compositions/app-user.js.map +0 -1
  45. package/dist/modality/index.cjs +0 -86
  46. package/dist/modality/index.cjs.map +0 -1
  47. package/dist/modality/index.d.cts +0 -26
  48. package/dist/modality/index.d.ts +0 -26
  49. package/dist/modality/index.js +0 -59
  50. package/dist/modality/index.js.map +0 -1
  51. package/dist/models/index.cjs.map +0 -1
  52. package/dist/models/index.d.cts +0 -22
  53. package/dist/models/index.d.ts +0 -22
  54. package/dist/models/index.js.map +0 -1
  55. package/dist/theme-VMRlhqST.d.cts +0 -9
  56. package/dist/theme-VMRlhqST.d.ts +0 -9
  57. package/dist/wallet/sdk.cjs +0 -206
  58. package/dist/wallet/sdk.cjs.map +0 -1
  59. package/dist/wallet/sdk.d.cts +0 -33
  60. package/dist/wallet/sdk.d.ts +0 -33
  61. package/dist/wallet/sdk.js +0 -175
  62. package/dist/wallet/sdk.js.map +0 -1
  63. /package/dist/{compositions/app-user.d.cts → app-user-menu/sdk.d.cts} +0 -0
  64. /package/dist/{compositions/app-user.d.ts → app-user-menu/sdk.d.ts} +0 -0
package/dist/auth/sdk.cjs DELETED
@@ -1,221 +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
- sm: "polli:px-2 polli:pt-0.5 polli:pb-1",
48
- md: "polli:px-4 polli:pt-1.5 polli:pb-2",
49
- lg: "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-intent-danger-bg-hover 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-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",
65
- disabled ? "polli:opacity-50 polli:cursor-not-allowed" : "polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer",
66
- colorClasses,
67
- sizes[size || "md"],
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
- "data-intent": intent,
87
- className: buttonClasses({
88
- theme,
89
- intent,
90
- size,
91
- className,
92
- disabled
93
- }),
94
- disabled,
95
- ...buttonProps,
96
- children
97
- }
98
- );
99
- }
100
-
101
- // src/modules/auth/LoginButton.tsx
102
- var import_jsx_runtime2 = require("react/jsx-runtime");
103
- function LoginButton({ children, ...buttonProps }) {
104
- const { isLoggedIn } = (0, import_react.useAuthState)();
105
- const { login } = (0, import_react.useAuthActions)();
106
- if (isLoggedIn) return null;
107
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { ...buttonProps, onClick: () => login(), children });
108
- }
109
-
110
- // src/modules/auth/LogoutButton.tsx
111
- var import_react2 = require("@pollinations/sdk/react");
112
- var import_jsx_runtime3 = require("react/jsx-runtime");
113
- function LogoutButton({ children, ...buttonProps }) {
114
- const { isLoggedIn } = (0, import_react2.useAuthState)();
115
- const { logout } = (0, import_react2.useAuthActions)();
116
- if (!isLoggedIn) return null;
117
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Button, { ...buttonProps, onClick: () => logout(), children });
118
- }
119
-
120
- // src/modules/auth/UserAvatar.tsx
121
- var import_react3 = require("@pollinations/sdk/react");
122
- var import_jsx_runtime4 = require("react/jsx-runtime");
123
- var sizeClass = {
124
- sm: "polli:w-6 polli:h-6 polli:text-xs",
125
- md: "polli:w-9 polli:h-9 polli:text-sm",
126
- lg: "polli:w-12 polli:h-12 polli:text-base"
127
- };
128
- function initials(name) {
129
- const parts = name.trim().split(/\s+/).filter(Boolean);
130
- if (parts.length === 0) return null;
131
- if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;
132
- const first = parts[0][0] ?? "";
133
- const last = parts[parts.length - 1][0] ?? "";
134
- return (first + last).toUpperCase() || null;
135
- }
136
- function UserAvatar({ size = "md", className }) {
137
- const { isLoggedIn } = (0, import_react3.useAuthState)();
138
- const { data: profile } = (0, import_react3.useAccountProfile)({ enabled: isLoggedIn });
139
- if (!isLoggedIn) return null;
140
- const base = cn(
141
- "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",
142
- sizeClass[size],
143
- className
144
- );
145
- if (profile?.image) {
146
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
147
- "img",
148
- {
149
- "data-polli": "user-avatar",
150
- src: profile.image,
151
- alt: profile.name ?? "",
152
- className: base
153
- }
154
- );
155
- }
156
- const label = profile?.name ? initials(profile.name) : null;
157
- if (!label) return null;
158
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
159
- "div",
160
- {
161
- "data-polli": "user-avatar",
162
- role: "img",
163
- "aria-label": profile?.name ?? void 0,
164
- className: base,
165
- children: label
166
- }
167
- );
168
- }
169
-
170
- // src/modules/auth/UserEmail.tsx
171
- var import_react4 = require("@pollinations/sdk/react");
172
- var import_jsx_runtime5 = require("react/jsx-runtime");
173
- function UserEmail({ className }) {
174
- const { isLoggedIn } = (0, import_react4.useAuthState)();
175
- const { data: profile } = (0, import_react4.useAccountProfile)({ enabled: isLoggedIn });
176
- if (!isLoggedIn || !profile?.email) return null;
177
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-polli": "user-email", className, children: profile.email });
178
- }
179
-
180
- // src/modules/auth/UserName.tsx
181
- var import_react5 = require("@pollinations/sdk/react");
182
- var import_jsx_runtime6 = require("react/jsx-runtime");
183
- function UserName({ className }) {
184
- const { isLoggedIn } = (0, import_react5.useAuthState)();
185
- const { data: profile } = (0, import_react5.useAccountProfile)({ enabled: isLoggedIn });
186
- if (!isLoggedIn || !profile) return null;
187
- const display = profile.name || profile.githubUsername;
188
- if (!display) return null;
189
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-polli": "user-name", className, children: display });
190
- }
191
-
192
- // src/modules/auth/WhenLoggedIn.tsx
193
- var import_react6 = require("@pollinations/sdk/react");
194
- var import_react7 = require("react");
195
- var import_jsx_runtime7 = require("react/jsx-runtime");
196
- function WhenLoggedIn({ children }) {
197
- const { isLoggedIn } = (0, import_react6.useAuthState)();
198
- if (!isLoggedIn) return null;
199
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.Fragment, { children });
200
- }
201
-
202
- // src/modules/auth/WhenLoggedOut.tsx
203
- var import_react8 = require("@pollinations/sdk/react");
204
- var import_react9 = require("react");
205
- var import_jsx_runtime8 = require("react/jsx-runtime");
206
- function WhenLoggedOut({ children }) {
207
- const { isLoggedIn } = (0, import_react8.useAuthState)();
208
- if (isLoggedIn) return null;
209
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react9.Fragment, { children });
210
- }
211
- // Annotate the CommonJS export names for ESM import in node:
212
- 0 && (module.exports = {
213
- LoginButton,
214
- LogoutButton,
215
- UserAvatar,
216
- UserEmail,
217
- UserName,
218
- WhenLoggedIn,
219
- WhenLoggedOut
220
- });
221
- //# 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 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 { 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,QAA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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-BvLF_Km2.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-DQAZzvyQ.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,188 +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
- sm: "polli:px-2 polli:pt-0.5 polli:pb-1",
16
- md: "polli:px-4 polli:pt-1.5 polli:pb-2",
17
- lg: "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-intent-danger-bg-hover 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-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",
33
- disabled ? "polli:opacity-50 polli:cursor-not-allowed" : "polli:hover:filter polli:hover:brightness-105 polli:cursor-pointer",
34
- colorClasses,
35
- sizes[size || "md"],
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
- "data-intent": intent,
55
- className: buttonClasses({
56
- theme,
57
- intent,
58
- size,
59
- className,
60
- disabled
61
- }),
62
- disabled,
63
- ...buttonProps,
64
- children
65
- }
66
- );
67
- }
68
-
69
- // src/modules/auth/LoginButton.tsx
70
- import { jsx as jsx2 } from "react/jsx-runtime";
71
- function LoginButton({ children, ...buttonProps }) {
72
- const { isLoggedIn } = useAuthState();
73
- const { login } = useAuthActions();
74
- if (isLoggedIn) return null;
75
- return /* @__PURE__ */ jsx2(Button, { ...buttonProps, onClick: () => login(), children });
76
- }
77
-
78
- // src/modules/auth/LogoutButton.tsx
79
- import { useAuthActions as useAuthActions2, useAuthState as useAuthState2 } from "@pollinations/sdk/react";
80
- import { jsx as jsx3 } from "react/jsx-runtime";
81
- function LogoutButton({ children, ...buttonProps }) {
82
- const { isLoggedIn } = useAuthState2();
83
- const { logout } = useAuthActions2();
84
- if (!isLoggedIn) return null;
85
- return /* @__PURE__ */ jsx3(Button, { ...buttonProps, onClick: () => logout(), children });
86
- }
87
-
88
- // src/modules/auth/UserAvatar.tsx
89
- import { useAccountProfile, useAuthState as useAuthState3 } from "@pollinations/sdk/react";
90
- import { jsx as jsx4 } from "react/jsx-runtime";
91
- var sizeClass = {
92
- sm: "polli:w-6 polli:h-6 polli:text-xs",
93
- md: "polli:w-9 polli:h-9 polli:text-sm",
94
- lg: "polli:w-12 polli:h-12 polli:text-base"
95
- };
96
- function initials(name) {
97
- const parts = name.trim().split(/\s+/).filter(Boolean);
98
- if (parts.length === 0) return null;
99
- if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase() || null;
100
- const first = parts[0][0] ?? "";
101
- const last = parts[parts.length - 1][0] ?? "";
102
- return (first + last).toUpperCase() || null;
103
- }
104
- function UserAvatar({ size = "md", className }) {
105
- const { isLoggedIn } = useAuthState3();
106
- const { data: profile } = useAccountProfile({ enabled: isLoggedIn });
107
- if (!isLoggedIn) return null;
108
- const base = cn(
109
- "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",
110
- sizeClass[size],
111
- className
112
- );
113
- if (profile?.image) {
114
- return /* @__PURE__ */ jsx4(
115
- "img",
116
- {
117
- "data-polli": "user-avatar",
118
- src: profile.image,
119
- alt: profile.name ?? "",
120
- className: base
121
- }
122
- );
123
- }
124
- const label = profile?.name ? initials(profile.name) : null;
125
- if (!label) return null;
126
- return /* @__PURE__ */ jsx4(
127
- "div",
128
- {
129
- "data-polli": "user-avatar",
130
- role: "img",
131
- "aria-label": profile?.name ?? void 0,
132
- className: base,
133
- children: label
134
- }
135
- );
136
- }
137
-
138
- // src/modules/auth/UserEmail.tsx
139
- import { useAccountProfile as useAccountProfile2, useAuthState as useAuthState4 } from "@pollinations/sdk/react";
140
- import { jsx as jsx5 } from "react/jsx-runtime";
141
- function UserEmail({ className }) {
142
- const { isLoggedIn } = useAuthState4();
143
- const { data: profile } = useAccountProfile2({ enabled: isLoggedIn });
144
- if (!isLoggedIn || !profile?.email) return null;
145
- return /* @__PURE__ */ jsx5("span", { "data-polli": "user-email", className, children: profile.email });
146
- }
147
-
148
- // src/modules/auth/UserName.tsx
149
- import { useAccountProfile as useAccountProfile3, useAuthState as useAuthState5 } from "@pollinations/sdk/react";
150
- import { jsx as jsx6 } from "react/jsx-runtime";
151
- function UserName({ className }) {
152
- const { isLoggedIn } = useAuthState5();
153
- const { data: profile } = useAccountProfile3({ enabled: isLoggedIn });
154
- if (!isLoggedIn || !profile) return null;
155
- const display = profile.name || profile.githubUsername;
156
- if (!display) return null;
157
- return /* @__PURE__ */ jsx6("span", { "data-polli": "user-name", className, children: display });
158
- }
159
-
160
- // src/modules/auth/WhenLoggedIn.tsx
161
- import { useAuthState as useAuthState6 } from "@pollinations/sdk/react";
162
- import { Fragment } from "react";
163
- import { jsx as jsx7 } from "react/jsx-runtime";
164
- function WhenLoggedIn({ children }) {
165
- const { isLoggedIn } = useAuthState6();
166
- if (!isLoggedIn) return null;
167
- return /* @__PURE__ */ jsx7(Fragment, { children });
168
- }
169
-
170
- // src/modules/auth/WhenLoggedOut.tsx
171
- import { useAuthState as useAuthState7 } from "@pollinations/sdk/react";
172
- import { Fragment as Fragment2 } from "react";
173
- import { jsx as jsx8 } from "react/jsx-runtime";
174
- function WhenLoggedOut({ children }) {
175
- const { isLoggedIn } = useAuthState7();
176
- if (isLoggedIn) return null;
177
- return /* @__PURE__ */ jsx8(Fragment2, { children });
178
- }
179
- export {
180
- LoginButton,
181
- LogoutButton,
182
- UserAvatar,
183
- UserEmail,
184
- UserName,
185
- WhenLoggedIn,
186
- WhenLoggedOut
187
- };
188
- //# 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 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 { 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,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACR;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,IAAI;AAAA,IAClB;AAAA,EACJ;AACJ;AAOO,SAAS,OAA+C;AAAA,EAC3D;AAAA,EACA;AAAA,E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AoB;AAgBxC,gBAAAC,YAAA;AAPD,SAAS,SAAS,EAAE,UAAU,GAAkB;AACnD,QAAM,EAAE,WAAW,IAAID,cAAa;AACpC,QAAM,EAAE,MAAM,QAAQ,IAAID,mBAAkB,EAAE,SAAS,WAAW,CAAC;AACnE,MAAI,CAAC,cAAc,CAAC,QAAS,QAAO;AACpC,QAAM,UAAU,QAAQ,QAAQ,QAAQ;AACxC,MAAI,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"]}