@hanzo/ui 8.0.13 → 8.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-VGGGGXWS.cjs +1280 -0
- package/dist/chunk-VGGGGXWS.cjs.map +1 -0
- package/dist/chunk-YAYUPOE3.js +1229 -0
- package/dist/chunk-YAYUPOE3.js.map +1 -0
- package/dist/product/index.cjs +222 -1291
- package/dist/product/index.cjs.map +1 -1
- package/dist/product/index.js +21 -1239
- package/dist/product/index.js.map +1 -1
- package/dist/product/social/index.cjs +109 -0
- package/dist/product/social/index.cjs.map +1 -0
- package/dist/product/social/index.js +4 -0
- package/dist/product/social/index.js.map +1 -0
- package/package.json +8 -2
|
@@ -0,0 +1,1280 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var gui = require('@hanzo/gui');
|
|
6
|
+
var lucideIcons2 = require('@hanzogui/lucide-icons-2');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
// src/product/social/api.ts
|
|
10
|
+
var enc = encodeURIComponent;
|
|
11
|
+
var str = (v) => typeof v === "string" ? v : v == null ? "" : String(v);
|
|
12
|
+
var num = (v) => {
|
|
13
|
+
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
14
|
+
if (typeof v === "string" && v.trim() !== "" && Number.isFinite(Number(v))) return Number(v);
|
|
15
|
+
return 0;
|
|
16
|
+
};
|
|
17
|
+
var strs = (v) => Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
|
|
18
|
+
var asRecord = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
19
|
+
var rows = (payload) => {
|
|
20
|
+
if (Array.isArray(payload)) return payload.filter((x) => x && typeof x === "object");
|
|
21
|
+
if (payload && typeof payload === "object") {
|
|
22
|
+
for (const k of ["data", "items", "rows"]) {
|
|
23
|
+
const v = payload[k];
|
|
24
|
+
if (Array.isArray(v)) return v.filter((x) => x && typeof x === "object");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
};
|
|
29
|
+
var PROVIDERS = ["x", "facebook", "instagram", "linkedin", "tiktok", "youtube", "threads"];
|
|
30
|
+
var ACCOUNT_STATUSES = ["connected", "disconnected", "error"];
|
|
31
|
+
var POST_STATUSES = ["draft", "scheduled", "published", "failed"];
|
|
32
|
+
function normalizeAccount(raw) {
|
|
33
|
+
const r = asRecord(raw);
|
|
34
|
+
return {
|
|
35
|
+
id: str(r.id),
|
|
36
|
+
provider: str(r.provider) || "x",
|
|
37
|
+
handle: str(r.handle),
|
|
38
|
+
status: str(r.status) || "connected",
|
|
39
|
+
createdAt: num(r.createdAt),
|
|
40
|
+
updatedAt: num(r.updatedAt)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function normalizePost(raw) {
|
|
44
|
+
const r = asRecord(raw);
|
|
45
|
+
return {
|
|
46
|
+
id: str(r.id),
|
|
47
|
+
content: str(r.content),
|
|
48
|
+
channel: str(r.channel) || "x",
|
|
49
|
+
status: str(r.status) || "draft",
|
|
50
|
+
scheduleAt: num(r.scheduleAt),
|
|
51
|
+
media: strs(r.media),
|
|
52
|
+
accountId: str(r.accountId) || void 0,
|
|
53
|
+
externalId: str(r.externalId) || void 0,
|
|
54
|
+
error: str(r.error) || void 0,
|
|
55
|
+
createdAt: num(r.createdAt),
|
|
56
|
+
updatedAt: num(r.updatedAt)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function normalizeSummary(raw) {
|
|
60
|
+
const r = asRecord(raw);
|
|
61
|
+
return { posts: num(r.posts), scheduled: num(r.scheduled), published: num(r.published), accounts: num(r.accounts) };
|
|
62
|
+
}
|
|
63
|
+
function normalizeProviderCapability(raw) {
|
|
64
|
+
const r = asRecord(raw);
|
|
65
|
+
return {
|
|
66
|
+
provider: str(r.provider),
|
|
67
|
+
credentialsConfigured: Boolean(r.credentialsConfigured),
|
|
68
|
+
missingCredentials: strs(r.missingCredentials)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
var normalizeAccounts = (p) => rows(p).map(normalizeAccount).filter((a) => a.id);
|
|
72
|
+
var normalizePosts = (p) => rows(p).map(normalizePost).filter((x) => x.id);
|
|
73
|
+
var normalizeProviders = (p) => rows(p).map(normalizeProviderCapability).filter((c) => c.provider);
|
|
74
|
+
function createSocialApi(rest) {
|
|
75
|
+
return {
|
|
76
|
+
summary: () => rest.get("summary").then(normalizeSummary),
|
|
77
|
+
/** Publish-readiness per network (+ the exact missing OAuth-app credentials). */
|
|
78
|
+
providers: () => rest.get("providers").then(normalizeProviders),
|
|
79
|
+
accounts: {
|
|
80
|
+
list: (provider) => rest.get(`accounts${provider ? `?provider=${enc(provider)}` : ""}`).then(normalizeAccounts),
|
|
81
|
+
get: (id) => rest.get(`accounts/${enc(id)}`).then(normalizeAccount),
|
|
82
|
+
create: (body) => rest.post("accounts", body).then(normalizeAccount),
|
|
83
|
+
update: (id, body) => rest.put(`accounts/${enc(id)}`, body).then(normalizeAccount),
|
|
84
|
+
remove: (id) => rest.del(`accounts/${enc(id)}`)
|
|
85
|
+
},
|
|
86
|
+
posts: {
|
|
87
|
+
list: (status) => rest.get(`posts${status ? `?status=${enc(status)}` : ""}`).then(normalizePosts),
|
|
88
|
+
get: (id) => rest.get(`posts/${enc(id)}`).then(normalizePost),
|
|
89
|
+
create: (body) => rest.post("posts", body).then(normalizePost),
|
|
90
|
+
update: (id, body) => rest.put(`posts/${enc(id)}`, body).then(normalizePost),
|
|
91
|
+
remove: (id) => rest.del(`posts/${enc(id)}`),
|
|
92
|
+
/** Publish a post NOW to its channel's connected accounts. */
|
|
93
|
+
publish: (id) => rest.post(`posts/${enc(id)}/publish`).then(normalizePost)
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
var HostCtx = react.createContext({});
|
|
98
|
+
var HostProvider = ({ actions, children }) => /* @__PURE__ */ jsxRuntime.jsx(HostCtx.Provider, { value: actions, children });
|
|
99
|
+
var useHost = () => react.useContext(HostCtx);
|
|
100
|
+
function classifyBackend(e) {
|
|
101
|
+
const status = typeof e?.status === "number" ? e.status : 0;
|
|
102
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
103
|
+
if (status === 503) return { kind: "not-initialized", message };
|
|
104
|
+
if (status === 404 || status === 405) return { kind: "unavailable", message };
|
|
105
|
+
if (status === 501) return { kind: "not-implemented", message };
|
|
106
|
+
if (status === 402) return { kind: "billing", message };
|
|
107
|
+
if (status === 401) return { kind: "signin", message };
|
|
108
|
+
if (status === 403) return { kind: "access", message };
|
|
109
|
+
return { kind: "error", message };
|
|
110
|
+
}
|
|
111
|
+
function classifyRead(e) {
|
|
112
|
+
const s = classifyBackend(e);
|
|
113
|
+
return s.kind === "billing" ? null : s;
|
|
114
|
+
}
|
|
115
|
+
var TITLES = {
|
|
116
|
+
"not-initialized": "Backend not initialized",
|
|
117
|
+
unavailable: "Not available on this deployment yet",
|
|
118
|
+
"not-implemented": "Not yet available",
|
|
119
|
+
access: "Not enabled for your account",
|
|
120
|
+
signin: "Your session expired",
|
|
121
|
+
billing: "Add credits to continue",
|
|
122
|
+
error: "Could not reach the backend"
|
|
123
|
+
};
|
|
124
|
+
var BODIES = {
|
|
125
|
+
"not-initialized": "The /v1 route is mounted but its runtime (or the console API key it proxies to) is not configured on this deployment yet. Real data appears here once it is \u2014 no placeholder data is shown.",
|
|
126
|
+
unavailable: "This endpoint is not mounted at the gateway on this host yet. The view lights up automatically once the route is live.",
|
|
127
|
+
// 501 — a real, planned capability whose body ships in a later phase.
|
|
128
|
+
"not-implemented": "This capability is planned but not wired yet. The backend answers honestly rather than pretending it worked \u2014 nothing here is fabricated, and the view lights up automatically once it ships.",
|
|
129
|
+
// 403 for a SIGNED-IN user — never "sign in".
|
|
130
|
+
access: "You're signed in, but this isn't enabled for your organization on this deployment, or it's an admin-only surface. It appears here automatically once your account has access \u2014 nothing is fabricated.",
|
|
131
|
+
// 401 — the session itself lapsed; re-auth returns to this exact page.
|
|
132
|
+
signin: "Your session has expired or isn\u2019t recognized here. Sign in again to continue where you left off.",
|
|
133
|
+
// Empty → the card shows the backend's own message (the honest "Insufficient
|
|
134
|
+
// balance. Please add credits…" from the gateway billing gate).
|
|
135
|
+
billing: "",
|
|
136
|
+
error: ""
|
|
137
|
+
};
|
|
138
|
+
function BackendStateCard({
|
|
139
|
+
state,
|
|
140
|
+
onRetry,
|
|
141
|
+
hint
|
|
142
|
+
}) {
|
|
143
|
+
const { signIn, addCredits } = useHost();
|
|
144
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.Card, { borderWidth: 1, borderColor: "$borderColor", p: "$4", gap: "$2", maxWidth: 640, children: [
|
|
145
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: "$2", items: "center", children: [
|
|
146
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.TriangleAlert, { size: 16 }),
|
|
147
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$4", fontWeight: "700", children: TITLES[state.kind] })
|
|
148
|
+
] }),
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", color: "$color11", children: BODIES[state.kind] || state.message }),
|
|
150
|
+
hint ? /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$color10", children: hint }) : null,
|
|
151
|
+
state.kind === "signin" && signIn ? /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { size: "$2", theme: "light", self: "flex-start", onPress: signIn, children: "Sign in again" }) : state.kind === "billing" && addCredits ? (
|
|
152
|
+
// 402 — the org has no funded balance. Offer a top-up CTA (and keep Retry so
|
|
153
|
+
// a returning, funded caller can reload in place).
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: "$2", items: "center", flexWrap: "wrap", children: [
|
|
155
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Button, { size: "$2", theme: "light", self: "flex-start", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.CreditCard, { size: 14 }), onPress: addCredits, children: "Add credits" }),
|
|
156
|
+
onRetry ? /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { size: "$2", self: "flex-start", onPress: onRetry, children: "Retry" }) : null
|
|
157
|
+
] })
|
|
158
|
+
) : onRetry ? /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { size: "$2", self: "flex-start", onPress: onRetry, children: "Retry" }) : null
|
|
159
|
+
] });
|
|
160
|
+
}
|
|
161
|
+
function SkeletonRows({ columns, count = 6 }) {
|
|
162
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { children: Array.from({ length: count }).map((_, r) => /* @__PURE__ */ jsxRuntime.jsx(gui.XStack, { py: "$2.5", px: "$3", gap: "$3", borderTopWidth: 1, borderColor: "$borderColor", items: "center", children: columns.map((c, i) => /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { width: c.width, flex: c.width ? void 0 : 1, minW: c.width ? void 0 : FLEX_MIN_COL_W, items: c.align === "right" ? "flex-end" : "flex-start", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
163
|
+
"div",
|
|
164
|
+
{
|
|
165
|
+
className: "hz-skeleton",
|
|
166
|
+
style: { height: 12, borderRadius: 6, width: `${[62, 40, 54, 34, 48][(i + r) % 5]}%` },
|
|
167
|
+
"aria-hidden": true
|
|
168
|
+
}
|
|
169
|
+
) }, c.key)) }, r)) });
|
|
170
|
+
}
|
|
171
|
+
function DataTable({
|
|
172
|
+
columns,
|
|
173
|
+
rows: rows2,
|
|
174
|
+
loading,
|
|
175
|
+
empty = "Nothing here yet.",
|
|
176
|
+
rowKey,
|
|
177
|
+
onRowPress,
|
|
178
|
+
isRowExpanded,
|
|
179
|
+
renderExpanded,
|
|
180
|
+
sort,
|
|
181
|
+
onSortChange
|
|
182
|
+
}) {
|
|
183
|
+
const minTableW = columns.reduce((sum, c) => sum + (c.width ?? FLEX_MIN_COL_W), 0) + (columns.length + 1) * 12;
|
|
184
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", overflow: "hidden", children: [
|
|
185
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { style: { overflowX: "auto", overflowY: "visible" }, children: /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { minW: minTableW, children: [
|
|
186
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.XStack, { bg: "$color1", py: "$2.5", px: "$3", gap: "$3", borderBottomWidth: 1, borderColor: "$borderColor", role: "row", children: columns.map((c) => {
|
|
187
|
+
const sortable = c.sortable === true && !!onSortChange;
|
|
188
|
+
const active = sortable && sort?.key === c.key;
|
|
189
|
+
const Caret = !sortable ? null : !active ? lucideIcons2.ChevronsUpDown : sort?.dir === "asc" ? lucideIcons2.ChevronUp : lucideIcons2.ChevronDown;
|
|
190
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
191
|
+
gui.XStack,
|
|
192
|
+
{
|
|
193
|
+
width: c.width,
|
|
194
|
+
flex: c.width ? void 0 : 1,
|
|
195
|
+
minW: c.width ? void 0 : FLEX_MIN_COL_W,
|
|
196
|
+
items: "center",
|
|
197
|
+
gap: "$1",
|
|
198
|
+
justify: c.align === "right" ? "flex-end" : "flex-start",
|
|
199
|
+
role: "columnheader",
|
|
200
|
+
"aria-sort": sortable ? active ? sort?.dir === "asc" ? "ascending" : "descending" : "none" : void 0,
|
|
201
|
+
"aria-label": sortable ? `Sort by ${c.header}` : void 0,
|
|
202
|
+
cursor: sortable ? "pointer" : void 0,
|
|
203
|
+
hoverStyle: sortable ? { opacity: 0.75 } : void 0,
|
|
204
|
+
onPress: sortable ? () => onSortChange?.(c.key) : void 0,
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
207
|
+
gui.Text,
|
|
208
|
+
{
|
|
209
|
+
fontSize: "$1",
|
|
210
|
+
fontWeight: "500",
|
|
211
|
+
color: active ? "$color12" : "$color10",
|
|
212
|
+
text: c.align === "right" ? "right" : "left",
|
|
213
|
+
className: c.mono ? "hz-tnum" : void 0,
|
|
214
|
+
children: c.header
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
Caret ? /* @__PURE__ */ jsxRuntime.jsx(Caret, { size: 12, color: active ? "$color12" : "$color9" }) : null
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
c.key
|
|
221
|
+
);
|
|
222
|
+
}) }),
|
|
223
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx(SkeletonRows, { columns }) : rows2.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { children: rows2.map((row) => {
|
|
224
|
+
const expanded = (isRowExpanded?.(row) ?? false) && !!renderExpanded;
|
|
225
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { children: [
|
|
226
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
227
|
+
gui.XStack,
|
|
228
|
+
{
|
|
229
|
+
className: "hz-row",
|
|
230
|
+
py: "$2.5",
|
|
231
|
+
px: "$3",
|
|
232
|
+
gap: "$3",
|
|
233
|
+
borderTopWidth: 1,
|
|
234
|
+
borderColor: "$borderColor",
|
|
235
|
+
items: "center",
|
|
236
|
+
bg: expanded ? "$color2" : void 0,
|
|
237
|
+
hoverStyle: onRowPress ? { bg: "$color2" } : void 0,
|
|
238
|
+
cursor: onRowPress ? "pointer" : void 0,
|
|
239
|
+
onPress: onRowPress ? () => onRowPress(row) : void 0,
|
|
240
|
+
children: columns.map((c) => {
|
|
241
|
+
const cell = c.render ? c.render(row) : String(row[c.key] ?? "");
|
|
242
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
243
|
+
gui.YStack,
|
|
244
|
+
{
|
|
245
|
+
width: c.width,
|
|
246
|
+
flex: c.width ? void 0 : 1,
|
|
247
|
+
minW: c.width ? void 0 : FLEX_MIN_COL_W,
|
|
248
|
+
justify: "center",
|
|
249
|
+
items: c.align === "right" ? "flex-end" : "flex-start",
|
|
250
|
+
children: typeof cell === "string" || typeof cell === "number" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
251
|
+
gui.Text,
|
|
252
|
+
{
|
|
253
|
+
fontSize: "$3",
|
|
254
|
+
numberOfLines: 1,
|
|
255
|
+
color: "$color12",
|
|
256
|
+
text: c.align === "right" ? "right" : "left",
|
|
257
|
+
className: c.mono ? "hz-mono" : void 0,
|
|
258
|
+
children: cell
|
|
259
|
+
}
|
|
260
|
+
) : cell
|
|
261
|
+
},
|
|
262
|
+
c.key
|
|
263
|
+
);
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
),
|
|
267
|
+
expanded && renderExpanded ? /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { borderTopWidth: 1, borderColor: "$borderColor", bg: "$color1", children: renderExpanded(row) }) : null
|
|
268
|
+
] }, rowKey(row));
|
|
269
|
+
}) }) : null
|
|
270
|
+
] }) }),
|
|
271
|
+
!loading && rows2.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { py: "$8", px: "$4", items: "center", gap: "$1", borderTopWidth: 1, borderColor: "$borderColor", children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { color: "$color10", fontSize: "$3", text: "center", children: empty }) }) : null
|
|
272
|
+
] });
|
|
273
|
+
}
|
|
274
|
+
var FLEX_MIN_COL_W = 120;
|
|
275
|
+
function isHexColor(v) {
|
|
276
|
+
return typeof v === "string" && /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(v.trim());
|
|
277
|
+
}
|
|
278
|
+
function resolveAccent(theme) {
|
|
279
|
+
if (!theme || !theme.isEnabled) return null;
|
|
280
|
+
const hex = (theme.colorPrimary ?? "").trim();
|
|
281
|
+
return isHexColor(hex) ? hex : null;
|
|
282
|
+
}
|
|
283
|
+
function expandHex(hex) {
|
|
284
|
+
const h = hex.trim().toLowerCase();
|
|
285
|
+
if (h.length === 4) return `#${h[1]}${h[1]}${h[2]}${h[2]}${h[3]}${h[3]}`;
|
|
286
|
+
return h;
|
|
287
|
+
}
|
|
288
|
+
function contrastText(hex) {
|
|
289
|
+
if (!isHexColor(hex)) return "#ffffff";
|
|
290
|
+
const h = expandHex(hex);
|
|
291
|
+
const r = parseInt(h.slice(1, 3), 16) / 255;
|
|
292
|
+
const g = parseInt(h.slice(3, 5), 16) / 255;
|
|
293
|
+
const b = parseInt(h.slice(5, 7), 16) / 255;
|
|
294
|
+
const lin = (c) => c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
295
|
+
const luminance = 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b);
|
|
296
|
+
return luminance > 0.5 ? "#000000" : "#ffffff";
|
|
297
|
+
}
|
|
298
|
+
function accentFor(theme) {
|
|
299
|
+
const hex = resolveAccent(theme);
|
|
300
|
+
return { accent: hex, contrast: hex ? contrastText(hex) : "#ffffff" };
|
|
301
|
+
}
|
|
302
|
+
var DEFAULT = { accent: null, contrast: "#ffffff" };
|
|
303
|
+
var current = DEFAULT;
|
|
304
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
305
|
+
function setOrgAccent(theme) {
|
|
306
|
+
const next = accentFor(theme);
|
|
307
|
+
if (next.accent === current.accent) return;
|
|
308
|
+
current = next.accent ? next : DEFAULT;
|
|
309
|
+
for (const l of listeners) l();
|
|
310
|
+
}
|
|
311
|
+
function subscribe(cb) {
|
|
312
|
+
listeners.add(cb);
|
|
313
|
+
return () => {
|
|
314
|
+
listeners.delete(cb);
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function useAccent() {
|
|
318
|
+
return react.useSyncExternalStore(
|
|
319
|
+
subscribe,
|
|
320
|
+
() => current,
|
|
321
|
+
() => DEFAULT
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
function PrimaryButton(props) {
|
|
325
|
+
const { accent, contrast } = useAccent();
|
|
326
|
+
if (accent) {
|
|
327
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { style: { backgroundColor: accent, color: contrast, borderColor: accent }, ...props });
|
|
328
|
+
}
|
|
329
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { theme: "light", ...props });
|
|
330
|
+
}
|
|
331
|
+
function openHref(href) {
|
|
332
|
+
if (typeof window !== "undefined") window.open(href, "_blank", "noopener");
|
|
333
|
+
}
|
|
334
|
+
function EmptyState({
|
|
335
|
+
icon: Icon,
|
|
336
|
+
title,
|
|
337
|
+
description,
|
|
338
|
+
bullets,
|
|
339
|
+
primary,
|
|
340
|
+
secondary
|
|
341
|
+
}) {
|
|
342
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
343
|
+
gui.Card,
|
|
344
|
+
{
|
|
345
|
+
borderWidth: 1,
|
|
346
|
+
borderColor: "$borderColor",
|
|
347
|
+
borderStyle: "dashed",
|
|
348
|
+
p: "$6",
|
|
349
|
+
gap: "$4",
|
|
350
|
+
items: "center",
|
|
351
|
+
maxWidth: 640,
|
|
352
|
+
self: "center",
|
|
353
|
+
width: "100%",
|
|
354
|
+
children: [
|
|
355
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
356
|
+
gui.YStack,
|
|
357
|
+
{
|
|
358
|
+
width: 48,
|
|
359
|
+
height: 48,
|
|
360
|
+
items: "center",
|
|
361
|
+
justify: "center",
|
|
362
|
+
rounded: "$4",
|
|
363
|
+
bg: "$color3",
|
|
364
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 24 })
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$2", items: "center", maxW: 480, children: [
|
|
368
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$6", fontWeight: "500", text: "center", letterSpacing: -0.3, children: title }),
|
|
369
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", color: "$color11", text: "center", children: description })
|
|
370
|
+
] }),
|
|
371
|
+
bullets && bullets.length ? /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { gap: "$2", self: "stretch", maxW: 420, mx: "auto", children: bullets.map((b) => /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: "$2", items: "flex-start", children: [
|
|
372
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { pt: "$1", children: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Check, { size: 14, color: "$color10" }) }),
|
|
373
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", color: "$color11", flex: 1, children: b })
|
|
374
|
+
] }, b)) }) : null,
|
|
375
|
+
primary || secondary ? /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: "$2", items: "center", flexWrap: "wrap", justify: "center", children: [
|
|
376
|
+
primary ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
377
|
+
PrimaryButton,
|
|
378
|
+
{
|
|
379
|
+
icon: primary.icon,
|
|
380
|
+
iconAfter: primary.href ? /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.ExternalLink, { size: 15 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.ArrowRight, { size: 15 }),
|
|
381
|
+
onPress: () => primary.href ? openHref(primary.href) : primary.onPress?.(),
|
|
382
|
+
children: primary.label
|
|
383
|
+
}
|
|
384
|
+
) : null,
|
|
385
|
+
secondary ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
386
|
+
gui.Button,
|
|
387
|
+
{
|
|
388
|
+
chromeless: true,
|
|
389
|
+
icon: secondary.icon,
|
|
390
|
+
iconAfter: secondary.href ? /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.ExternalLink, { size: 14 }) : void 0,
|
|
391
|
+
onPress: () => secondary.href ? openHref(secondary.href) : secondary.onPress?.(),
|
|
392
|
+
children: secondary.label
|
|
393
|
+
}
|
|
394
|
+
) : null
|
|
395
|
+
] }) : null
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
function FieldRow({ label, children }) {
|
|
401
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: "$3", items: "flex-start", flexWrap: "wrap", children: [
|
|
402
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Label, { width: "100%", pt: "$2", color: "$color11", fontSize: "$3", $md: { width: 180 }, children: label }),
|
|
403
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { flex: 1, minW: 0, $md: { minW: 240 }, children })
|
|
404
|
+
] });
|
|
405
|
+
}
|
|
406
|
+
function FieldText({
|
|
407
|
+
value,
|
|
408
|
+
onChange,
|
|
409
|
+
disabled,
|
|
410
|
+
secure,
|
|
411
|
+
placeholder
|
|
412
|
+
}) {
|
|
413
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
414
|
+
gui.Input,
|
|
415
|
+
{
|
|
416
|
+
value,
|
|
417
|
+
onChangeText: onChange,
|
|
418
|
+
disabled,
|
|
419
|
+
secureTextEntry: secure,
|
|
420
|
+
placeholder,
|
|
421
|
+
autoCapitalize: "none"
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
function FieldTextArea({
|
|
426
|
+
value,
|
|
427
|
+
onChange,
|
|
428
|
+
disabled,
|
|
429
|
+
rows: rows2 = 6
|
|
430
|
+
}) {
|
|
431
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.TextArea, { value, onChangeText: onChange, disabled, numberOfLines: rows2 });
|
|
432
|
+
}
|
|
433
|
+
function FieldSwitch({
|
|
434
|
+
checked,
|
|
435
|
+
onChange,
|
|
436
|
+
disabled
|
|
437
|
+
}) {
|
|
438
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.Switch, { checked, onCheckedChange: onChange, disabled, size: "$3", children: /* @__PURE__ */ jsxRuntime.jsx(gui.Switch.Thumb, {}) });
|
|
439
|
+
}
|
|
440
|
+
var CHEVRON = `data:image/svg+xml,${encodeURIComponent(
|
|
441
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#9a9a9a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>'
|
|
442
|
+
)}`;
|
|
443
|
+
function selectStyle(disabled) {
|
|
444
|
+
return {
|
|
445
|
+
width: "100%",
|
|
446
|
+
boxSizing: "border-box",
|
|
447
|
+
appearance: "none",
|
|
448
|
+
WebkitAppearance: "none",
|
|
449
|
+
MozAppearance: "none",
|
|
450
|
+
background: `var(--background) url("${CHEVRON}") no-repeat right 10px center`,
|
|
451
|
+
color: "var(--color12)",
|
|
452
|
+
border: "1px solid var(--borderColor)",
|
|
453
|
+
borderRadius: 9,
|
|
454
|
+
padding: "9px 34px 9px 12px",
|
|
455
|
+
fontSize: 14,
|
|
456
|
+
lineHeight: "20px",
|
|
457
|
+
fontFamily: "inherit",
|
|
458
|
+
height: 40,
|
|
459
|
+
outline: "none",
|
|
460
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
461
|
+
opacity: disabled ? 0.5 : 1
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
var OPTION_STYLE = { background: "var(--color2)", color: "var(--color12)" };
|
|
465
|
+
function FieldSelect({
|
|
466
|
+
value,
|
|
467
|
+
options,
|
|
468
|
+
onChange,
|
|
469
|
+
disabled,
|
|
470
|
+
placeholder = "Select\u2026"
|
|
471
|
+
}) {
|
|
472
|
+
const showPlaceholder = value === "" || !options.includes(value);
|
|
473
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
474
|
+
"select",
|
|
475
|
+
{
|
|
476
|
+
value: showPlaceholder ? "" : value,
|
|
477
|
+
onChange: (e) => onChange(e.currentTarget.value),
|
|
478
|
+
disabled,
|
|
479
|
+
"aria-label": placeholder,
|
|
480
|
+
style: selectStyle(disabled),
|
|
481
|
+
children: [
|
|
482
|
+
showPlaceholder ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, style: OPTION_STYLE, children: placeholder }) : null,
|
|
483
|
+
options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, style: OPTION_STYLE, children: opt }, opt))
|
|
484
|
+
]
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
function FieldSlider({
|
|
489
|
+
value,
|
|
490
|
+
min,
|
|
491
|
+
max,
|
|
492
|
+
step,
|
|
493
|
+
onChange,
|
|
494
|
+
disabled
|
|
495
|
+
}) {
|
|
496
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: "$3", items: "center", children: [
|
|
497
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { width: 56, fontSize: "$3", color: "$color11", children: value }),
|
|
498
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
499
|
+
gui.Slider,
|
|
500
|
+
{
|
|
501
|
+
flex: 1,
|
|
502
|
+
min,
|
|
503
|
+
max,
|
|
504
|
+
step,
|
|
505
|
+
value: [value],
|
|
506
|
+
onValueChange: (v) => onChange(v[0] ?? min),
|
|
507
|
+
disabled,
|
|
508
|
+
children: [
|
|
509
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Slider.Track, { children: /* @__PURE__ */ jsxRuntime.jsx(gui.Slider.TrackActive, {}) }),
|
|
510
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Slider.Thumb, { index: 0, circular: true })
|
|
511
|
+
]
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
] });
|
|
515
|
+
}
|
|
516
|
+
function PageHeader({
|
|
517
|
+
title,
|
|
518
|
+
subtitle,
|
|
519
|
+
actions
|
|
520
|
+
}) {
|
|
521
|
+
return (
|
|
522
|
+
// flexWrap lets the actions drop below the title on narrow screens; flex={1}
|
|
523
|
+
// minW={0} lets the title column shrink so a long subtitle WRAPS instead of
|
|
524
|
+
// running off the viewport (a flex child defaults to min-width:auto = content
|
|
525
|
+
// width, which would overflow on mobile).
|
|
526
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { justify: "space-between", items: "flex-start", gap: "$3", flexWrap: "wrap", children: [
|
|
527
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$1", flex: 1, minW: 200, children: [
|
|
528
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$7", fontWeight: "500", letterSpacing: -0.4, children: title }),
|
|
529
|
+
subtitle ? /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", color: "$color11", children: subtitle }) : null
|
|
530
|
+
] }),
|
|
531
|
+
actions ? /* @__PURE__ */ jsxRuntime.jsx(gui.XStack, { gap: "$2", items: "center", flexWrap: "wrap", width: "100%", $md: { width: "auto", justify: "flex-end" }, children: actions }) : null
|
|
532
|
+
] })
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
var toneOf = (status) => {
|
|
536
|
+
const s = status.toLowerCase();
|
|
537
|
+
if (s === "green") return "green";
|
|
538
|
+
if (s === "yellow") return "yellow";
|
|
539
|
+
if (s === "red") return "red";
|
|
540
|
+
if (["ready", "active", "running", "available", "ok", "live", "succeeded", "connected", "synced", "imported"].includes(s)) return "green";
|
|
541
|
+
if (["creating", "provisioning", "pending", "updating", "attaching", "building", "deploying", "queued", "importing"].includes(s))
|
|
542
|
+
return "yellow";
|
|
543
|
+
if (["error", "failed", "degraded", "down", "canceled", "conflict"].includes(s)) return "red";
|
|
544
|
+
return "neutral";
|
|
545
|
+
};
|
|
546
|
+
var TONE_BG = {
|
|
547
|
+
green: "$color5",
|
|
548
|
+
yellow: "$color4",
|
|
549
|
+
red: "$color4",
|
|
550
|
+
neutral: "$color3"
|
|
551
|
+
};
|
|
552
|
+
var TONE_FG = {
|
|
553
|
+
green: "$color12",
|
|
554
|
+
yellow: "$color12",
|
|
555
|
+
red: "$color12",
|
|
556
|
+
neutral: "$color11"
|
|
557
|
+
};
|
|
558
|
+
function StatusTag({ status }) {
|
|
559
|
+
const tone = toneOf(status ?? "");
|
|
560
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$1", px: "$2", py: "$1", rounded: "$2", bg: TONE_BG[tone], color: TONE_FG[tone], children: status || "unknown" });
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// src/product/color.ts
|
|
564
|
+
var asColor = (hex) => hex;
|
|
565
|
+
var LG = 1024;
|
|
566
|
+
var lockCount = 0;
|
|
567
|
+
var savedOverflow = "";
|
|
568
|
+
function lockScroll() {
|
|
569
|
+
if (typeof document === "undefined") return;
|
|
570
|
+
if (lockCount === 0) {
|
|
571
|
+
savedOverflow = document.body.style.overflow;
|
|
572
|
+
document.body.style.overflow = "hidden";
|
|
573
|
+
}
|
|
574
|
+
lockCount++;
|
|
575
|
+
}
|
|
576
|
+
function unlockScroll() {
|
|
577
|
+
if (typeof document === "undefined") return;
|
|
578
|
+
lockCount = Math.max(0, lockCount - 1);
|
|
579
|
+
if (lockCount === 0) document.body.style.overflow = savedOverflow;
|
|
580
|
+
}
|
|
581
|
+
function SlideOver({
|
|
582
|
+
open,
|
|
583
|
+
onClose,
|
|
584
|
+
side = "right",
|
|
585
|
+
size = 420,
|
|
586
|
+
title,
|
|
587
|
+
icon: Icon,
|
|
588
|
+
iconColor,
|
|
589
|
+
headerRight,
|
|
590
|
+
ariaLabel,
|
|
591
|
+
zIndex = 1e3,
|
|
592
|
+
children
|
|
593
|
+
}) {
|
|
594
|
+
const panelRef = react.useRef(null);
|
|
595
|
+
const openerRef = react.useRef(null);
|
|
596
|
+
react.useEffect(() => {
|
|
597
|
+
if (!open) return;
|
|
598
|
+
openerRef.current = typeof document !== "undefined" ? document.activeElement : null;
|
|
599
|
+
lockScroll();
|
|
600
|
+
const t = window.setTimeout(() => {
|
|
601
|
+
const el = panelRef.current;
|
|
602
|
+
if (el && typeof el.focus === "function") el.focus();
|
|
603
|
+
}, 0);
|
|
604
|
+
return () => {
|
|
605
|
+
window.clearTimeout(t);
|
|
606
|
+
unlockScroll();
|
|
607
|
+
const opener = openerRef.current;
|
|
608
|
+
if (opener && opener instanceof HTMLElement && typeof opener.focus === "function") opener.focus();
|
|
609
|
+
};
|
|
610
|
+
}, [open]);
|
|
611
|
+
react.useEffect(() => {
|
|
612
|
+
if (!open) return;
|
|
613
|
+
const onKey = (e) => {
|
|
614
|
+
if (e.key === "Escape") {
|
|
615
|
+
e.stopPropagation();
|
|
616
|
+
onClose();
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
window.addEventListener("keydown", onKey);
|
|
620
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
621
|
+
}, [open, onClose]);
|
|
622
|
+
const offscreen = side === "right" ? "translateX(100%)" : "translateX(-100%)";
|
|
623
|
+
const edge = side === "right" ? { r: 0 } : { l: 0 };
|
|
624
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
625
|
+
gui.YStack,
|
|
626
|
+
{
|
|
627
|
+
overflow: "hidden",
|
|
628
|
+
pointerEvents: open ? "auto" : "none",
|
|
629
|
+
"aria-hidden": !open,
|
|
630
|
+
style: { position: "fixed", inset: 0, zIndex },
|
|
631
|
+
children: [
|
|
632
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
633
|
+
gui.YStack,
|
|
634
|
+
{
|
|
635
|
+
position: "absolute",
|
|
636
|
+
t: 0,
|
|
637
|
+
l: 0,
|
|
638
|
+
r: 0,
|
|
639
|
+
b: 0,
|
|
640
|
+
bg: "rgba(0,0,0,0.55)",
|
|
641
|
+
className: "hz-fade",
|
|
642
|
+
style: { opacity: open ? 1 : 0 },
|
|
643
|
+
onPress: onClose
|
|
644
|
+
}
|
|
645
|
+
),
|
|
646
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
647
|
+
gui.YStack,
|
|
648
|
+
{
|
|
649
|
+
ref: panelRef,
|
|
650
|
+
tabIndex: -1,
|
|
651
|
+
role: "dialog",
|
|
652
|
+
"aria-modal": open ? true : void 0,
|
|
653
|
+
"aria-label": typeof title === "string" ? title : ariaLabel,
|
|
654
|
+
position: "absolute",
|
|
655
|
+
t: 0,
|
|
656
|
+
b: 0,
|
|
657
|
+
...edge,
|
|
658
|
+
width: "100%",
|
|
659
|
+
$lg: { width: size, maxW: "100vw" },
|
|
660
|
+
bg: "$color1",
|
|
661
|
+
borderLeftWidth: side === "right" ? 1 : 0,
|
|
662
|
+
borderRightWidth: side === "left" ? 1 : 0,
|
|
663
|
+
borderColor: "$borderColor",
|
|
664
|
+
className: "hz-slide hz-elevation-4",
|
|
665
|
+
style: {
|
|
666
|
+
transform: open ? "translateX(0)" : offscreen,
|
|
667
|
+
height: "100dvh",
|
|
668
|
+
paddingTop: "env(safe-area-inset-top)",
|
|
669
|
+
paddingBottom: "env(safe-area-inset-bottom)"
|
|
670
|
+
},
|
|
671
|
+
children: title !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
672
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
673
|
+
gui.XStack,
|
|
674
|
+
{
|
|
675
|
+
items: "center",
|
|
676
|
+
gap: "$2.5",
|
|
677
|
+
px: "$4",
|
|
678
|
+
height: 56,
|
|
679
|
+
borderBottomWidth: 1,
|
|
680
|
+
borderColor: "$borderColor",
|
|
681
|
+
children: [
|
|
682
|
+
Icon ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 18, color: iconColor ? asColor(iconColor) : void 0 }) : null,
|
|
683
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { flex: 1, fontSize: "$5", fontWeight: "700", color: "$color12", numberOfLines: 1, children: title }),
|
|
684
|
+
headerRight,
|
|
685
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Button, { chromeless: true, width: 44, height: 44, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.X, { size: 18 }), onPress: onClose, "aria-label": "Close" })
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
),
|
|
689
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.ScrollView, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { flex: 1, p: "$4", gap: "$3", children }) })
|
|
690
|
+
] }) : (
|
|
691
|
+
// Bare mode — the caller owns the full panel layout (e.g. the nav drawer
|
|
692
|
+
// renders its own header + scroll + footer).
|
|
693
|
+
children
|
|
694
|
+
)
|
|
695
|
+
}
|
|
696
|
+
)
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// src/product/social/format.ts
|
|
703
|
+
function formatPostTime(unix) {
|
|
704
|
+
if (!unix) return "\u2014";
|
|
705
|
+
return new Date(unix * 1e3).toLocaleString(void 0, {
|
|
706
|
+
month: "short",
|
|
707
|
+
day: "numeric",
|
|
708
|
+
hour: "2-digit",
|
|
709
|
+
minute: "2-digit"
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
function postDayBucket(unix) {
|
|
713
|
+
const d = new Date(unix * 1e3);
|
|
714
|
+
const key = `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
|
|
715
|
+
const label = d.toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" });
|
|
716
|
+
return { key, label };
|
|
717
|
+
}
|
|
718
|
+
function postPreview(s) {
|
|
719
|
+
const t = s.trim();
|
|
720
|
+
return t.length > 72 ? `${t.slice(0, 72)}\u2026` : t || "\u2014";
|
|
721
|
+
}
|
|
722
|
+
function parsePostTime(dt) {
|
|
723
|
+
const ms = Date.parse(dt.trim());
|
|
724
|
+
return Number.isFinite(ms) && ms > 0 ? Math.floor(ms / 1e3) : 0;
|
|
725
|
+
}
|
|
726
|
+
function PostAgenda({ posts, onOpen }) {
|
|
727
|
+
const days = react.useMemo(() => {
|
|
728
|
+
const timed = posts.filter((p) => (p.scheduleAt ?? 0) > 0).sort((a, b) => (a.scheduleAt ?? 0) - (b.scheduleAt ?? 0));
|
|
729
|
+
const groups = [];
|
|
730
|
+
const index = /* @__PURE__ */ new Map();
|
|
731
|
+
for (const p of timed) {
|
|
732
|
+
const { key, label } = postDayBucket(p.scheduleAt ?? 0);
|
|
733
|
+
let i = index.get(key);
|
|
734
|
+
if (i === void 0) {
|
|
735
|
+
i = groups.length;
|
|
736
|
+
index.set(key, i);
|
|
737
|
+
groups.push({ label, items: [] });
|
|
738
|
+
}
|
|
739
|
+
groups[i].items.push(p);
|
|
740
|
+
}
|
|
741
|
+
return groups;
|
|
742
|
+
}, [posts]);
|
|
743
|
+
if (days.length === 0) {
|
|
744
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
745
|
+
EmptyState,
|
|
746
|
+
{
|
|
747
|
+
icon: lucideIcons2.Calendar,
|
|
748
|
+
title: "Nothing on the calendar",
|
|
749
|
+
description: "Scheduled and timed posts appear here, grouped by day. Compose a post and pick Schedule to plan ahead."
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { gap: "$4", children: days.map((d) => /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$2", children: [
|
|
754
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", fontWeight: "500", color: "$color11", children: d.label }),
|
|
755
|
+
d.items.map((p) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
756
|
+
gui.XStack,
|
|
757
|
+
{
|
|
758
|
+
items: "center",
|
|
759
|
+
justify: "space-between",
|
|
760
|
+
gap: "$3",
|
|
761
|
+
borderWidth: 1,
|
|
762
|
+
borderColor: "$borderColor",
|
|
763
|
+
rounded: "$4",
|
|
764
|
+
px: "$4",
|
|
765
|
+
py: "$3",
|
|
766
|
+
cursor: "pointer",
|
|
767
|
+
hoverStyle: { bg: "$color2" },
|
|
768
|
+
onPress: () => onOpen(p),
|
|
769
|
+
children: [
|
|
770
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$1", flex: 1, children: [
|
|
771
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", children: postPreview(p.content) }),
|
|
772
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: "$2", items: "center", children: [
|
|
773
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$1", color: "$color10", children: p.channel }),
|
|
774
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: "$1", color: "$color10", children: [
|
|
775
|
+
"\xB7 ",
|
|
776
|
+
formatPostTime(p.scheduleAt ?? 0)
|
|
777
|
+
] })
|
|
778
|
+
] })
|
|
779
|
+
] }),
|
|
780
|
+
/* @__PURE__ */ jsxRuntime.jsx(StatusTag, { status: p.status })
|
|
781
|
+
]
|
|
782
|
+
},
|
|
783
|
+
p.id
|
|
784
|
+
))
|
|
785
|
+
] }, d.label)) });
|
|
786
|
+
}
|
|
787
|
+
var COMPOSE_MODES = ["draft", "schedule", "now"];
|
|
788
|
+
var COMPOSE_LABEL = {
|
|
789
|
+
draft: "Save draft",
|
|
790
|
+
schedule: "Schedule",
|
|
791
|
+
now: "Publish now"
|
|
792
|
+
};
|
|
793
|
+
function PostComposer({
|
|
794
|
+
channels,
|
|
795
|
+
providers,
|
|
796
|
+
onSubmit
|
|
797
|
+
}) {
|
|
798
|
+
const [content, setContent] = react.useState("");
|
|
799
|
+
const [channel, setChannel] = react.useState(channels[0] ?? "x");
|
|
800
|
+
const [mode, setMode] = react.useState("draft");
|
|
801
|
+
const [scheduleAt, setScheduleAt] = react.useState("");
|
|
802
|
+
const [saving, setSaving] = react.useState(false);
|
|
803
|
+
const [error, setError] = react.useState(null);
|
|
804
|
+
const cap = providers.find((p) => p.provider === channel);
|
|
805
|
+
const unconfigured = (mode === "now" || mode === "schedule") && !!cap && !cap.credentialsConfigured;
|
|
806
|
+
const submit = async () => {
|
|
807
|
+
if (!content.trim()) {
|
|
808
|
+
setError("Content is required.");
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
let status = "draft";
|
|
812
|
+
let at = 0;
|
|
813
|
+
if (mode === "schedule") {
|
|
814
|
+
at = parsePostTime(scheduleAt);
|
|
815
|
+
if (at <= Math.floor(Date.now() / 1e3)) {
|
|
816
|
+
setError("Pick a future date and time to schedule.");
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
status = "scheduled";
|
|
820
|
+
} else if (mode === "now") {
|
|
821
|
+
status = "scheduled";
|
|
822
|
+
}
|
|
823
|
+
setSaving(true);
|
|
824
|
+
setError(null);
|
|
825
|
+
const message = await onSubmit({ content: content.trim(), channel, status, scheduleAt: at }, mode);
|
|
826
|
+
if (message) {
|
|
827
|
+
setError(message);
|
|
828
|
+
setSaving(false);
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$3", p: "$4", children: [
|
|
832
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Content", children: /* @__PURE__ */ jsxRuntime.jsx(FieldTextArea, { value: content, onChange: setContent, disabled: saving }) }),
|
|
833
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Channel", children: /* @__PURE__ */ jsxRuntime.jsx(FieldSelect, { value: channel, options: channels, onChange: setChannel, disabled: saving }) }),
|
|
834
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "When", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
835
|
+
FieldSelect,
|
|
836
|
+
{
|
|
837
|
+
value: mode,
|
|
838
|
+
options: [...COMPOSE_MODES],
|
|
839
|
+
onChange: (v) => setMode(v),
|
|
840
|
+
disabled: saving
|
|
841
|
+
}
|
|
842
|
+
) }),
|
|
843
|
+
mode === "schedule" ? /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Schedule at", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
844
|
+
FieldText,
|
|
845
|
+
{
|
|
846
|
+
value: scheduleAt,
|
|
847
|
+
onChange: setScheduleAt,
|
|
848
|
+
placeholder: "2026-07-15 09:00",
|
|
849
|
+
disabled: saving
|
|
850
|
+
}
|
|
851
|
+
) }) : null,
|
|
852
|
+
unconfigured ? /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "flex-start", gap: "$2", children: [
|
|
853
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.AlertTriangle, { size: 14, color: "var(--yellow10)" }),
|
|
854
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: "$1", color: "$color10", children: [
|
|
855
|
+
channel,
|
|
856
|
+
" isn\u2019t configured to publish yet \u2014 needs ",
|
|
857
|
+
cap?.missingCredentials.join(", "),
|
|
858
|
+
". The post is saved and marked failed on publish until credentials are supplied."
|
|
859
|
+
] })
|
|
860
|
+
] }) : null,
|
|
861
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$red10", children: error }) : null,
|
|
862
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onPress: submit, disabled: saving, children: saving ? "Working\u2026" : COMPOSE_LABEL[mode] })
|
|
863
|
+
] });
|
|
864
|
+
}
|
|
865
|
+
function ProviderReadinessList({ providers }) {
|
|
866
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$2", children: [
|
|
867
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$color10", children: "Network publish-readiness" }),
|
|
868
|
+
providers.map((p) => /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", justify: "space-between", gap: "$3", py: "$1", children: [
|
|
869
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", gap: "$2", children: [
|
|
870
|
+
p.credentialsConfigured ? /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.CheckCircle2, { size: 14, color: "var(--green10)" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.AlertTriangle, { size: 14, color: "var(--yellow10)" }),
|
|
871
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", children: p.provider })
|
|
872
|
+
] }),
|
|
873
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$1", color: "$color10", children: p.credentialsConfigured ? "Ready" : `needs ${p.missingCredentials.join(", ")}` })
|
|
874
|
+
] }, p.provider))
|
|
875
|
+
] });
|
|
876
|
+
}
|
|
877
|
+
function SocialSummaryBar({ summary }) {
|
|
878
|
+
const cells = [
|
|
879
|
+
{ label: "Posts", value: summary.posts },
|
|
880
|
+
{ label: "Scheduled", value: summary.scheduled },
|
|
881
|
+
{ label: "Published", value: summary.published },
|
|
882
|
+
{ label: "Accounts", value: summary.accounts }
|
|
883
|
+
];
|
|
884
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.XStack, { gap: "$3", flexWrap: "wrap", children: cells.map((c) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
885
|
+
gui.YStack,
|
|
886
|
+
{
|
|
887
|
+
gap: "$1",
|
|
888
|
+
borderWidth: 1,
|
|
889
|
+
borderColor: "$borderColor",
|
|
890
|
+
rounded: "$4",
|
|
891
|
+
px: "$4",
|
|
892
|
+
py: "$3",
|
|
893
|
+
minW: 140,
|
|
894
|
+
children: [
|
|
895
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$1", color: "$color10", children: c.label }),
|
|
896
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$6", fontWeight: "500", className: "hz-tnum", children: c.value })
|
|
897
|
+
]
|
|
898
|
+
},
|
|
899
|
+
c.label
|
|
900
|
+
)) });
|
|
901
|
+
}
|
|
902
|
+
var OPTIONS = [
|
|
903
|
+
{ id: "list", label: "List", icon: lucideIcons2.List },
|
|
904
|
+
{ id: "calendar", label: "Calendar", icon: lucideIcons2.Calendar }
|
|
905
|
+
];
|
|
906
|
+
function ViewToggle({
|
|
907
|
+
view,
|
|
908
|
+
onChange
|
|
909
|
+
}) {
|
|
910
|
+
return /* @__PURE__ */ jsxRuntime.jsx(gui.XStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$4", overflow: "hidden", children: OPTIONS.map((o) => {
|
|
911
|
+
const Icon = o.icon;
|
|
912
|
+
const active = view === o.id;
|
|
913
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
914
|
+
gui.XStack,
|
|
915
|
+
{
|
|
916
|
+
items: "center",
|
|
917
|
+
gap: "$2",
|
|
918
|
+
px: "$3",
|
|
919
|
+
py: "$2",
|
|
920
|
+
cursor: "pointer",
|
|
921
|
+
bg: active ? "$color4" : "transparent",
|
|
922
|
+
hoverStyle: { bg: active ? "$color4" : "$color2" },
|
|
923
|
+
onPress: () => onChange(o.id),
|
|
924
|
+
children: [
|
|
925
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 14 }),
|
|
926
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", fontWeight: active ? "500" : "400", children: o.label })
|
|
927
|
+
]
|
|
928
|
+
},
|
|
929
|
+
o.id
|
|
930
|
+
);
|
|
931
|
+
}) });
|
|
932
|
+
}
|
|
933
|
+
var POST_COLUMNS = [
|
|
934
|
+
{ key: "content", header: "Post", render: (p) => postPreview(p.content) },
|
|
935
|
+
{ key: "channel", header: "Channel", render: (p) => p.channel || "\u2014" },
|
|
936
|
+
{ key: "status", header: "Status", render: (p) => /* @__PURE__ */ jsxRuntime.jsx(StatusTag, { status: p.status }) },
|
|
937
|
+
{ key: "scheduleAt", header: "Scheduled", render: (p) => formatPostTime(p.scheduleAt) }
|
|
938
|
+
];
|
|
939
|
+
var ACCOUNT_COLUMNS = [
|
|
940
|
+
{ key: "handle", header: "Account", render: (a) => a.handle || "\u2014" },
|
|
941
|
+
{ key: "provider", header: "Network", render: (a) => a.provider || "\u2014" },
|
|
942
|
+
{ key: "status", header: "Status", render: (a) => /* @__PURE__ */ jsxRuntime.jsx(StatusTag, { status: a.status }) }
|
|
943
|
+
];
|
|
944
|
+
function PostDetail({ api, post, onChanged }) {
|
|
945
|
+
const [publishing, setPublishing] = react.useState(false);
|
|
946
|
+
const [error, setError] = react.useState(null);
|
|
947
|
+
const canPublish = post.status === "draft" || post.status === "scheduled" || post.status === "failed";
|
|
948
|
+
const publish = async () => {
|
|
949
|
+
setPublishing(true);
|
|
950
|
+
setError(null);
|
|
951
|
+
try {
|
|
952
|
+
await api.posts.publish(post.id);
|
|
953
|
+
onChanged();
|
|
954
|
+
} catch (e) {
|
|
955
|
+
setError(classifyBackend(e).message || "Publish failed.");
|
|
956
|
+
} finally {
|
|
957
|
+
setPublishing(false);
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$3", p: "$4", children: [
|
|
961
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Content", children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", children: post.content || "\u2014" }) }),
|
|
962
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Channel", children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", children: post.channel }) }),
|
|
963
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Status", children: /* @__PURE__ */ jsxRuntime.jsx(StatusTag, { status: post.status }) }),
|
|
964
|
+
post.scheduleAt > 0 ? /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Scheduled", children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", children: formatPostTime(post.scheduleAt) }) }) : null,
|
|
965
|
+
post.media.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Media", children: /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { gap: "$1", children: post.media.map((m) => /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$color11", children: m }, m)) }) }) : null,
|
|
966
|
+
post.externalId ? /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "External id", children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", className: "hz-tnum", children: post.externalId }) }) : null,
|
|
967
|
+
post.error ? /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Last error", children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$red10", children: post.error }) }) : null,
|
|
968
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$red10", children: error }) : null,
|
|
969
|
+
canPublish ? /* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onPress: publish, disabled: publishing, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Send, { size: 16 }), children: publishing ? "Publishing\u2026" : "Publish now" }) : null
|
|
970
|
+
] });
|
|
971
|
+
}
|
|
972
|
+
function ConnectAccount({
|
|
973
|
+
api,
|
|
974
|
+
providers,
|
|
975
|
+
onCreated
|
|
976
|
+
}) {
|
|
977
|
+
const [provider, setProvider] = react.useState("x");
|
|
978
|
+
const [handle, setHandle] = react.useState("");
|
|
979
|
+
const [saving, setSaving] = react.useState(false);
|
|
980
|
+
const [error, setError] = react.useState(null);
|
|
981
|
+
const submit = async () => {
|
|
982
|
+
setSaving(true);
|
|
983
|
+
setError(null);
|
|
984
|
+
try {
|
|
985
|
+
await api.accounts.create({ provider, handle: handle.trim(), status: "connected" });
|
|
986
|
+
onCreated();
|
|
987
|
+
} catch (e) {
|
|
988
|
+
setError(classifyBackend(e).message || "Failed to connect account.");
|
|
989
|
+
} finally {
|
|
990
|
+
setSaving(false);
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$4", p: "$4", children: [
|
|
994
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProviderReadinessList, { providers }),
|
|
995
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$3", children: [
|
|
996
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Network", children: /* @__PURE__ */ jsxRuntime.jsx(FieldSelect, { value: provider, options: [...PROVIDERS], onChange: setProvider, disabled: saving }) }),
|
|
997
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Handle", children: /* @__PURE__ */ jsxRuntime.jsx(FieldText, { value: handle, onChange: setHandle, placeholder: "@hanzo", disabled: saving }) }),
|
|
998
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$red10", children: error }) : null,
|
|
999
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onPress: submit, disabled: saving, children: saving ? "Connecting\u2026" : "Connect account" })
|
|
1000
|
+
] })
|
|
1001
|
+
] });
|
|
1002
|
+
}
|
|
1003
|
+
function SocialResource({
|
|
1004
|
+
api,
|
|
1005
|
+
title = "Publish",
|
|
1006
|
+
subtitle = "Compose, schedule and publish your content across networks \u2014 per org, over the native /v1/social engine."
|
|
1007
|
+
}) {
|
|
1008
|
+
const [state, setState] = react.useState({ phase: "loading" });
|
|
1009
|
+
const [view, setView] = react.useState("list");
|
|
1010
|
+
const [composing, setComposing] = react.useState(false);
|
|
1011
|
+
const [connecting, setConnecting] = react.useState(false);
|
|
1012
|
+
const [openPost, setOpenPost] = react.useState(null);
|
|
1013
|
+
const load = react.useCallback(async () => {
|
|
1014
|
+
setState({ phase: "loading" });
|
|
1015
|
+
try {
|
|
1016
|
+
const [summary, posts2, accounts2, providers2] = await Promise.all([
|
|
1017
|
+
api.summary(),
|
|
1018
|
+
api.posts.list(),
|
|
1019
|
+
api.accounts.list(),
|
|
1020
|
+
api.providers()
|
|
1021
|
+
]);
|
|
1022
|
+
setState({ phase: "ready", data: { summary, posts: posts2, accounts: accounts2, providers: providers2 } });
|
|
1023
|
+
} catch (e) {
|
|
1024
|
+
setState({ phase: "error", error: classifyBackend(e) });
|
|
1025
|
+
}
|
|
1026
|
+
}, [api]);
|
|
1027
|
+
react.useEffect(() => {
|
|
1028
|
+
void load();
|
|
1029
|
+
}, [load]);
|
|
1030
|
+
const providers = state.phase === "ready" ? state.data.providers : [];
|
|
1031
|
+
const posts = state.phase === "ready" ? state.data.posts : [];
|
|
1032
|
+
const accounts = state.phase === "ready" ? state.data.accounts : [];
|
|
1033
|
+
const empty = state.phase === "ready" && posts.length === 0 && accounts.length === 0;
|
|
1034
|
+
const submitDraft = async (draft, mode) => {
|
|
1035
|
+
try {
|
|
1036
|
+
const created = await api.posts.create(draft);
|
|
1037
|
+
if (mode === "now" && created.status === "failed") return created.error || "Publish failed.";
|
|
1038
|
+
} catch (e) {
|
|
1039
|
+
return classifyBackend(e).message || "Failed to create post.";
|
|
1040
|
+
}
|
|
1041
|
+
setComposing(false);
|
|
1042
|
+
void load();
|
|
1043
|
+
return null;
|
|
1044
|
+
};
|
|
1045
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$4", p: "$4", children: [
|
|
1046
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1047
|
+
PageHeader,
|
|
1048
|
+
{
|
|
1049
|
+
title,
|
|
1050
|
+
subtitle,
|
|
1051
|
+
actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1052
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onPress: () => setComposing(true), icon: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Plus, { size: 16 }), children: "New post" }),
|
|
1053
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onPress: () => setConnecting(true), icon: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Link2, { size: 16 }), children: "Connect account" }),
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onPress: () => void load(), icon: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.RefreshCw, { size: 16 }), children: "Refresh" })
|
|
1055
|
+
] })
|
|
1056
|
+
}
|
|
1057
|
+
),
|
|
1058
|
+
state.phase === "error" ? /* @__PURE__ */ jsxRuntime.jsx(BackendStateCard, { state: state.error, onRetry: () => void load() }) : empty ? /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$4", children: [
|
|
1059
|
+
state.phase === "ready" ? /* @__PURE__ */ jsxRuntime.jsx(SocialSummaryBar, { summary: state.data.summary }) : null,
|
|
1060
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1061
|
+
EmptyState,
|
|
1062
|
+
{
|
|
1063
|
+
icon: lucideIcons2.Share2,
|
|
1064
|
+
title: "No posts or accounts yet",
|
|
1065
|
+
description: "Connect a social account, then compose, schedule and publish across X, Instagram, LinkedIn, TikTok and more.",
|
|
1066
|
+
primary: { label: "New post", onPress: () => setComposing(true) }
|
|
1067
|
+
}
|
|
1068
|
+
)
|
|
1069
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$5", children: [
|
|
1070
|
+
state.phase === "ready" ? /* @__PURE__ */ jsxRuntime.jsx(SocialSummaryBar, { summary: state.data.summary }) : null,
|
|
1071
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$3", children: [
|
|
1072
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [
|
|
1073
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", gap: "$2", children: [
|
|
1074
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Send, { size: 16 }),
|
|
1075
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$5", fontWeight: "500", children: "Posts" })
|
|
1076
|
+
] }),
|
|
1077
|
+
/* @__PURE__ */ jsxRuntime.jsx(ViewToggle, { view, onChange: setView })
|
|
1078
|
+
] }),
|
|
1079
|
+
view === "list" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1080
|
+
DataTable,
|
|
1081
|
+
{
|
|
1082
|
+
columns: POST_COLUMNS,
|
|
1083
|
+
rows: posts,
|
|
1084
|
+
loading: state.phase === "loading",
|
|
1085
|
+
empty: "No posts yet.",
|
|
1086
|
+
rowKey: (p) => p.id,
|
|
1087
|
+
onRowPress: (p) => setOpenPost(p)
|
|
1088
|
+
}
|
|
1089
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(PostAgenda, { posts, onOpen: (p) => setOpenPost(p) })
|
|
1090
|
+
] }),
|
|
1091
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$2", children: [
|
|
1092
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", gap: "$2", children: [
|
|
1093
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Link2, { size: 16 }),
|
|
1094
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$5", fontWeight: "500", children: "Accounts" })
|
|
1095
|
+
] }),
|
|
1096
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1097
|
+
DataTable,
|
|
1098
|
+
{
|
|
1099
|
+
columns: ACCOUNT_COLUMNS,
|
|
1100
|
+
rows: accounts,
|
|
1101
|
+
loading: state.phase === "loading",
|
|
1102
|
+
empty: "No accounts connected yet.",
|
|
1103
|
+
rowKey: (a) => a.id
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
] })
|
|
1107
|
+
] }),
|
|
1108
|
+
/* @__PURE__ */ jsxRuntime.jsx(SlideOver, { open: composing, onClose: () => setComposing(false), title: "New post", icon: lucideIcons2.Send, ariaLabel: "New post", children: /* @__PURE__ */ jsxRuntime.jsx(PostComposer, { channels: [...PROVIDERS], providers, onSubmit: submitDraft }) }),
|
|
1109
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1110
|
+
SlideOver,
|
|
1111
|
+
{
|
|
1112
|
+
open: connecting,
|
|
1113
|
+
onClose: () => setConnecting(false),
|
|
1114
|
+
title: "Connect account",
|
|
1115
|
+
icon: lucideIcons2.Link2,
|
|
1116
|
+
ariaLabel: "Connect account",
|
|
1117
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1118
|
+
ConnectAccount,
|
|
1119
|
+
{
|
|
1120
|
+
api,
|
|
1121
|
+
providers,
|
|
1122
|
+
onCreated: () => {
|
|
1123
|
+
setConnecting(false);
|
|
1124
|
+
void load();
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
)
|
|
1128
|
+
}
|
|
1129
|
+
),
|
|
1130
|
+
/* @__PURE__ */ jsxRuntime.jsx(SlideOver, { open: openPost !== null, onClose: () => setOpenPost(null), title: "Post", icon: lucideIcons2.Send, ariaLabel: "Post detail", children: openPost ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1131
|
+
PostDetail,
|
|
1132
|
+
{
|
|
1133
|
+
api,
|
|
1134
|
+
post: openPost,
|
|
1135
|
+
onChanged: () => {
|
|
1136
|
+
setOpenPost(null);
|
|
1137
|
+
void load();
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
) : null })
|
|
1141
|
+
] });
|
|
1142
|
+
}
|
|
1143
|
+
var META = {
|
|
1144
|
+
x: { label: "X", bg: "#0f0f12", fg: "#e6e6ea", mark: "\u{1D54F}" },
|
|
1145
|
+
facebook: { label: "Facebook", bg: "#1877f2", fg: "#ffffff", mark: "f" },
|
|
1146
|
+
instagram: { label: "Instagram", bg: "#e1306c", fg: "#ffffff", mark: "IG" },
|
|
1147
|
+
linkedin: { label: "LinkedIn", bg: "#0a66c2", fg: "#ffffff", mark: "in" },
|
|
1148
|
+
tiktok: { label: "TikTok", bg: "#111114", fg: "#25f4ee", mark: "TT" },
|
|
1149
|
+
youtube: { label: "YouTube", bg: "#ff0000", fg: "#ffffff", mark: "\u25B6" },
|
|
1150
|
+
threads: { label: "Threads", bg: "#111114", fg: "#e6e6ea", mark: "@" }
|
|
1151
|
+
};
|
|
1152
|
+
function ChannelBadge({
|
|
1153
|
+
channel,
|
|
1154
|
+
showLabel = false,
|
|
1155
|
+
size = 22
|
|
1156
|
+
}) {
|
|
1157
|
+
const m = META[channel] ?? META.x;
|
|
1158
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", gap: "$2", children: [
|
|
1159
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1160
|
+
gui.YStack,
|
|
1161
|
+
{
|
|
1162
|
+
width: size,
|
|
1163
|
+
height: size,
|
|
1164
|
+
items: "center",
|
|
1165
|
+
justify: "center",
|
|
1166
|
+
rounded: "$2",
|
|
1167
|
+
bg: m.bg,
|
|
1168
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$1", fontWeight: "800", color: m.fg, children: m.mark })
|
|
1169
|
+
}
|
|
1170
|
+
),
|
|
1171
|
+
showLabel ? /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", color: "$color12", children: m.label }) : null
|
|
1172
|
+
] });
|
|
1173
|
+
}
|
|
1174
|
+
var money = (cents) => `$${Math.round((cents || 0) / 100).toLocaleString()}`;
|
|
1175
|
+
function CampaignCard({ campaign }) {
|
|
1176
|
+
const pct = campaign.budget > 0 ? Math.min(100, campaign.spend / campaign.budget * 100) : 0;
|
|
1177
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.Card, { p: "$4", gap: "$3", borderWidth: 1, borderColor: "$borderColor", width: "100%", children: [
|
|
1178
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "flex-start", justify: "space-between", gap: "$2", children: [
|
|
1179
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$1", children: [
|
|
1180
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$4", fontWeight: "700", children: campaign.name }),
|
|
1181
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$color11", children: campaign.channel })
|
|
1182
|
+
] }),
|
|
1183
|
+
/* @__PURE__ */ jsxRuntime.jsx(StatusTag, { status: campaign.status })
|
|
1184
|
+
] }),
|
|
1185
|
+
campaign.objective ? /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$2", color: "$color11", children: campaign.objective }) : null,
|
|
1186
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.YStack, { gap: "$1.5", children: [
|
|
1187
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { justify: "space-between", children: [
|
|
1188
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: "$1", color: "$color11", children: [
|
|
1189
|
+
money(campaign.spend),
|
|
1190
|
+
" spent"
|
|
1191
|
+
] }),
|
|
1192
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: "$1", color: "$color11", children: [
|
|
1193
|
+
money(campaign.budget),
|
|
1194
|
+
" budget"
|
|
1195
|
+
] })
|
|
1196
|
+
] }),
|
|
1197
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { height: 6, rounded: "$2", bg: "$color3", overflow: "hidden", children: /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, { height: 6, rounded: "$2", bg: "$color9", width: `${pct}%` }) })
|
|
1198
|
+
] })
|
|
1199
|
+
] });
|
|
1200
|
+
}
|
|
1201
|
+
function PostCard({
|
|
1202
|
+
post,
|
|
1203
|
+
onEdit,
|
|
1204
|
+
onDelete
|
|
1205
|
+
}) {
|
|
1206
|
+
const mediaCount = post.media?.length ?? 0;
|
|
1207
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(gui.Card, { p: "$3", gap: "$2.5", borderWidth: 1, borderColor: "$borderColor", width: "100%", children: [
|
|
1208
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", justify: "space-between", gap: "$2", children: [
|
|
1209
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", gap: "$2", children: [
|
|
1210
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChannelBadge, { channel: post.channel }),
|
|
1211
|
+
/* @__PURE__ */ jsxRuntime.jsx(StatusTag, { status: post.status })
|
|
1212
|
+
] }),
|
|
1213
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { gap: "$1", children: [
|
|
1214
|
+
onEdit ? /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Pencil, { size: 15 }), onPress: () => onEdit(post) }) : null,
|
|
1215
|
+
onDelete ? /* @__PURE__ */ jsxRuntime.jsx(gui.Button, { size: "$2", chromeless: true, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideIcons2.Trash2, { size: 15 }), onPress: () => onDelete(post) }) : null
|
|
1216
|
+
] })
|
|
1217
|
+
] }),
|
|
1218
|
+
/* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$3", color: "$color12", children: post.content }),
|
|
1219
|
+
/* @__PURE__ */ jsxRuntime.jsxs(gui.XStack, { items: "center", justify: "space-between", gap: "$2", children: [
|
|
1220
|
+
post.scheduleAt ? /* @__PURE__ */ jsxRuntime.jsx(gui.Text, { fontSize: "$1", color: "$color11", children: formatPostTime(post.scheduleAt) }) : /* @__PURE__ */ jsxRuntime.jsx(gui.YStack, {}),
|
|
1221
|
+
mediaCount ? /* @__PURE__ */ jsxRuntime.jsxs(gui.Text, { fontSize: "$1", color: "$color10", children: [
|
|
1222
|
+
mediaCount,
|
|
1223
|
+
" media"
|
|
1224
|
+
] }) : null
|
|
1225
|
+
] })
|
|
1226
|
+
] });
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
exports.ACCOUNT_STATUSES = ACCOUNT_STATUSES;
|
|
1230
|
+
exports.BackendStateCard = BackendStateCard;
|
|
1231
|
+
exports.COMPOSE_MODES = COMPOSE_MODES;
|
|
1232
|
+
exports.CampaignCard = CampaignCard;
|
|
1233
|
+
exports.ChannelBadge = ChannelBadge;
|
|
1234
|
+
exports.DataTable = DataTable;
|
|
1235
|
+
exports.EmptyState = EmptyState;
|
|
1236
|
+
exports.FieldRow = FieldRow;
|
|
1237
|
+
exports.FieldSelect = FieldSelect;
|
|
1238
|
+
exports.FieldSlider = FieldSlider;
|
|
1239
|
+
exports.FieldSwitch = FieldSwitch;
|
|
1240
|
+
exports.FieldText = FieldText;
|
|
1241
|
+
exports.FieldTextArea = FieldTextArea;
|
|
1242
|
+
exports.HostProvider = HostProvider;
|
|
1243
|
+
exports.LG = LG;
|
|
1244
|
+
exports.POST_STATUSES = POST_STATUSES;
|
|
1245
|
+
exports.PROVIDERS = PROVIDERS;
|
|
1246
|
+
exports.PageHeader = PageHeader;
|
|
1247
|
+
exports.PostAgenda = PostAgenda;
|
|
1248
|
+
exports.PostCard = PostCard;
|
|
1249
|
+
exports.PostComposer = PostComposer;
|
|
1250
|
+
exports.PrimaryButton = PrimaryButton;
|
|
1251
|
+
exports.ProviderReadinessList = ProviderReadinessList;
|
|
1252
|
+
exports.SlideOver = SlideOver;
|
|
1253
|
+
exports.SocialResource = SocialResource;
|
|
1254
|
+
exports.SocialSummaryBar = SocialSummaryBar;
|
|
1255
|
+
exports.StatusTag = StatusTag;
|
|
1256
|
+
exports.ViewToggle = ViewToggle;
|
|
1257
|
+
exports.accentFor = accentFor;
|
|
1258
|
+
exports.asColor = asColor;
|
|
1259
|
+
exports.classifyBackend = classifyBackend;
|
|
1260
|
+
exports.classifyRead = classifyRead;
|
|
1261
|
+
exports.contrastText = contrastText;
|
|
1262
|
+
exports.createSocialApi = createSocialApi;
|
|
1263
|
+
exports.formatPostTime = formatPostTime;
|
|
1264
|
+
exports.isHexColor = isHexColor;
|
|
1265
|
+
exports.normalizeAccount = normalizeAccount;
|
|
1266
|
+
exports.normalizeAccounts = normalizeAccounts;
|
|
1267
|
+
exports.normalizePost = normalizePost;
|
|
1268
|
+
exports.normalizePosts = normalizePosts;
|
|
1269
|
+
exports.normalizeProviderCapability = normalizeProviderCapability;
|
|
1270
|
+
exports.normalizeProviders = normalizeProviders;
|
|
1271
|
+
exports.normalizeSummary = normalizeSummary;
|
|
1272
|
+
exports.parsePostTime = parsePostTime;
|
|
1273
|
+
exports.postDayBucket = postDayBucket;
|
|
1274
|
+
exports.postPreview = postPreview;
|
|
1275
|
+
exports.resolveAccent = resolveAccent;
|
|
1276
|
+
exports.setOrgAccent = setOrgAccent;
|
|
1277
|
+
exports.useAccent = useAccent;
|
|
1278
|
+
exports.useHost = useHost;
|
|
1279
|
+
//# sourceMappingURL=chunk-VGGGGXWS.cjs.map
|
|
1280
|
+
//# sourceMappingURL=chunk-VGGGGXWS.cjs.map
|