@saas-support/react 0.2.0
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/README.md +732 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +491 -0
- package/dist/index.js +524 -0
- package/dist/react.cjs +593 -0
- package/dist/react.d.ts +783 -0
- package/dist/react.js +1908 -0
- package/package.json +52 -0
package/dist/react.js
ADDED
|
@@ -0,0 +1,1908 @@
|
|
|
1
|
+
import { jsx as e, jsxs as u, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Q, useContext as V, useState as m, useEffect as C, useRef as U, useCallback as S, useMemo as B } from "react";
|
|
3
|
+
import { SaaSSupport as Y, isMfaRequired as K, BillingClient as X, Transport as q, ReportClient as R } from "./index.js";
|
|
4
|
+
import { SaaSError as Qs } from "./index.js";
|
|
5
|
+
import { createPortal as Z } from "react-dom";
|
|
6
|
+
const H = Q(null);
|
|
7
|
+
function $() {
|
|
8
|
+
const s = V(H);
|
|
9
|
+
if (!s)
|
|
10
|
+
throw new Error("useSaaSContext must be used within a <SaaSProvider>");
|
|
11
|
+
return s;
|
|
12
|
+
}
|
|
13
|
+
function Ts({ publishableKey: s, apiKey: n, baseUrl: r, appearance: c, children: a }) {
|
|
14
|
+
const [i] = m(() => new Y({ publishableKey: s, apiKey: n, baseUrl: r })), [l, d] = m(null), [o, t] = m(!1), [g, p] = m(null);
|
|
15
|
+
return C(() => {
|
|
16
|
+
let h = !1;
|
|
17
|
+
i.load().then(async () => {
|
|
18
|
+
if (h) return;
|
|
19
|
+
const x = await i.auth.getUser(), b = await i.auth.getSettings();
|
|
20
|
+
d(x), p(b), t(!0);
|
|
21
|
+
});
|
|
22
|
+
const f = i.auth.onAuthStateChange((x) => {
|
|
23
|
+
h || d(x);
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
h = !0, f(), i.destroy();
|
|
27
|
+
};
|
|
28
|
+
}, [i]), /* @__PURE__ */ e(H.Provider, { value: { client: i, user: l, isLoaded: o, appearance: c, settings: g }, children: a });
|
|
29
|
+
}
|
|
30
|
+
const ss = {
|
|
31
|
+
colorPrimary: "#6366f1",
|
|
32
|
+
colorPrimaryHover: "#4f46e5",
|
|
33
|
+
colorBackground: "#ffffff",
|
|
34
|
+
colorText: "#1a1a2e",
|
|
35
|
+
colorTextSecondary: "#6b7280",
|
|
36
|
+
colorInputBackground: "#f9fafb",
|
|
37
|
+
colorInputBorder: "#d1d5db",
|
|
38
|
+
colorError: "#ef4444",
|
|
39
|
+
colorSuccess: "#22c55e",
|
|
40
|
+
colorWarning: "#f59e0b",
|
|
41
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
42
|
+
borderRadius: "8px"
|
|
43
|
+
}, es = {
|
|
44
|
+
colorPrimary: "#818cf8",
|
|
45
|
+
colorPrimaryHover: "#6366f1",
|
|
46
|
+
colorBackground: "#1e1e2e",
|
|
47
|
+
colorText: "#e2e8f0",
|
|
48
|
+
colorTextSecondary: "#94a3b8",
|
|
49
|
+
colorInputBackground: "#2a2a3e",
|
|
50
|
+
colorInputBorder: "#3f3f5e",
|
|
51
|
+
colorError: "#f87171",
|
|
52
|
+
colorSuccess: "#4ade80",
|
|
53
|
+
colorWarning: "#fbbf24",
|
|
54
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
55
|
+
borderRadius: "8px"
|
|
56
|
+
};
|
|
57
|
+
function M(s) {
|
|
58
|
+
const n = (s == null ? void 0 : s.baseTheme) === "dark" ? es : ss, r = s == null ? void 0 : s.variables;
|
|
59
|
+
return {
|
|
60
|
+
colorPrimary: (r == null ? void 0 : r.colorPrimary) ?? n.colorPrimary,
|
|
61
|
+
colorPrimaryHover: r != null && r.colorPrimary ? rs(r.colorPrimary, 10) : n.colorPrimaryHover,
|
|
62
|
+
colorBackground: (r == null ? void 0 : r.colorBackground) ?? n.colorBackground,
|
|
63
|
+
colorText: (r == null ? void 0 : r.colorText) ?? n.colorText,
|
|
64
|
+
colorTextSecondary: n.colorTextSecondary,
|
|
65
|
+
colorInputBackground: (r == null ? void 0 : r.colorInputBackground) ?? n.colorInputBackground,
|
|
66
|
+
colorInputBorder: (r == null ? void 0 : r.colorInputBorder) ?? n.colorInputBorder,
|
|
67
|
+
colorError: (r == null ? void 0 : r.colorError) ?? n.colorError,
|
|
68
|
+
colorSuccess: (r == null ? void 0 : r.colorSuccess) ?? n.colorSuccess,
|
|
69
|
+
colorWarning: (r == null ? void 0 : r.colorWarning) ?? n.colorWarning,
|
|
70
|
+
fontFamily: (r == null ? void 0 : r.fontFamily) ?? n.fontFamily,
|
|
71
|
+
borderRadius: (r == null ? void 0 : r.borderRadius) ?? n.borderRadius
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function rs(s, n) {
|
|
75
|
+
const r = parseInt(s.replace("#", ""), 16), c = Math.max(0, (r >> 16) - Math.round(2.55 * n)), a = Math.max(0, (r >> 8 & 255) - Math.round(2.55 * n)), i = Math.max(0, (r & 255) - Math.round(2.55 * n));
|
|
76
|
+
return `#${(c << 16 | a << 8 | i).toString(16).padStart(6, "0")}`;
|
|
77
|
+
}
|
|
78
|
+
function O(s) {
|
|
79
|
+
return `
|
|
80
|
+
:host {
|
|
81
|
+
all: initial;
|
|
82
|
+
font-family: ${s.fontFamily};
|
|
83
|
+
color: ${s.colorText};
|
|
84
|
+
line-height: 1.5;
|
|
85
|
+
-webkit-font-smoothing: antialiased;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
89
|
+
|
|
90
|
+
.ss-card {
|
|
91
|
+
background: ${s.colorBackground};
|
|
92
|
+
border-radius: ${s.borderRadius};
|
|
93
|
+
padding: 32px;
|
|
94
|
+
width: 100%;
|
|
95
|
+
max-width: 400px;
|
|
96
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
|
97
|
+
border: 1px solid ${s.colorInputBorder};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.ss-card-wide { max-width: 640px; }
|
|
101
|
+
|
|
102
|
+
.ss-title {
|
|
103
|
+
font-size: 22px;
|
|
104
|
+
font-weight: 700;
|
|
105
|
+
color: ${s.colorText};
|
|
106
|
+
text-align: center;
|
|
107
|
+
margin-bottom: 24px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.ss-subtitle {
|
|
111
|
+
font-size: 14px;
|
|
112
|
+
color: ${s.colorTextSecondary};
|
|
113
|
+
text-align: center;
|
|
114
|
+
margin-top: -16px;
|
|
115
|
+
margin-bottom: 24px;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.ss-field { margin-bottom: 16px; }
|
|
119
|
+
|
|
120
|
+
.ss-label {
|
|
121
|
+
display: block;
|
|
122
|
+
font-size: 14px;
|
|
123
|
+
font-weight: 500;
|
|
124
|
+
color: ${s.colorText};
|
|
125
|
+
margin-bottom: 6px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.ss-input {
|
|
129
|
+
width: 100%;
|
|
130
|
+
padding: 10px 12px;
|
|
131
|
+
font-size: 14px;
|
|
132
|
+
font-family: inherit;
|
|
133
|
+
border: 1px solid ${s.colorInputBorder};
|
|
134
|
+
border-radius: calc(${s.borderRadius} - 2px);
|
|
135
|
+
background: ${s.colorInputBackground};
|
|
136
|
+
color: ${s.colorText};
|
|
137
|
+
outline: none;
|
|
138
|
+
transition: border-color 0.15s;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.ss-input:focus {
|
|
142
|
+
border-color: ${s.colorPrimary};
|
|
143
|
+
box-shadow: 0 0 0 3px ${s.colorPrimary}22;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.ss-input.ss-input-error { border-color: ${s.colorError}; }
|
|
147
|
+
|
|
148
|
+
.ss-query-textarea {
|
|
149
|
+
resize: vertical;
|
|
150
|
+
min-height: 60px;
|
|
151
|
+
font-family: monospace;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.ss-error {
|
|
155
|
+
font-size: 13px;
|
|
156
|
+
color: ${s.colorError};
|
|
157
|
+
margin-top: 4px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.ss-global-error {
|
|
161
|
+
font-size: 13px;
|
|
162
|
+
color: ${s.colorError};
|
|
163
|
+
background: ${s.colorError}11;
|
|
164
|
+
border: 1px solid ${s.colorError}33;
|
|
165
|
+
border-radius: calc(${s.borderRadius} - 2px);
|
|
166
|
+
padding: 10px 12px;
|
|
167
|
+
margin-bottom: 16px;
|
|
168
|
+
text-align: center;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.ss-success-msg {
|
|
172
|
+
font-size: 13px;
|
|
173
|
+
color: ${s.colorSuccess};
|
|
174
|
+
background: ${s.colorSuccess}11;
|
|
175
|
+
border: 1px solid ${s.colorSuccess}33;
|
|
176
|
+
border-radius: calc(${s.borderRadius} - 2px);
|
|
177
|
+
padding: 10px 12px;
|
|
178
|
+
margin-bottom: 16px;
|
|
179
|
+
text-align: center;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.ss-loading {
|
|
183
|
+
text-align: center;
|
|
184
|
+
padding: 24px;
|
|
185
|
+
color: ${s.colorTextSecondary};
|
|
186
|
+
font-size: 14px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ss-empty {
|
|
190
|
+
text-align: center;
|
|
191
|
+
padding: 24px;
|
|
192
|
+
color: ${s.colorTextSecondary};
|
|
193
|
+
font-size: 14px;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* Buttons */
|
|
197
|
+
|
|
198
|
+
.ss-btn {
|
|
199
|
+
width: 100%;
|
|
200
|
+
padding: 10px 16px;
|
|
201
|
+
font-size: 14px;
|
|
202
|
+
font-weight: 600;
|
|
203
|
+
font-family: inherit;
|
|
204
|
+
border: none;
|
|
205
|
+
border-radius: calc(${s.borderRadius} - 2px);
|
|
206
|
+
cursor: pointer;
|
|
207
|
+
transition: background 0.15s, opacity 0.15s;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.ss-btn:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
211
|
+
|
|
212
|
+
.ss-btn-primary {
|
|
213
|
+
background: ${s.colorPrimary};
|
|
214
|
+
color: #fff;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.ss-btn-primary:hover:not(:disabled) { background: ${s.colorPrimaryHover}; }
|
|
218
|
+
|
|
219
|
+
.ss-btn-danger {
|
|
220
|
+
background: ${s.colorError};
|
|
221
|
+
color: #fff;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.ss-btn-danger:hover:not(:disabled) { opacity: 0.9; }
|
|
225
|
+
|
|
226
|
+
.ss-btn-current {
|
|
227
|
+
background: ${s.colorInputBackground};
|
|
228
|
+
color: ${s.colorTextSecondary};
|
|
229
|
+
border: 1px solid ${s.colorInputBorder};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.ss-btn-sm {
|
|
233
|
+
width: auto;
|
|
234
|
+
padding: 6px 12px;
|
|
235
|
+
font-size: 12px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.ss-btn-group {
|
|
239
|
+
display: flex;
|
|
240
|
+
gap: 8px;
|
|
241
|
+
margin-top: 16px;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.ss-btn-group .ss-btn { flex: 1; }
|
|
245
|
+
|
|
246
|
+
.ss-btn-org-switcher {
|
|
247
|
+
display: flex;
|
|
248
|
+
align-items: center;
|
|
249
|
+
gap: 8px;
|
|
250
|
+
background: ${s.colorInputBackground};
|
|
251
|
+
border: 1px solid ${s.colorInputBorder};
|
|
252
|
+
color: ${s.colorText};
|
|
253
|
+
padding: 8px 12px;
|
|
254
|
+
font-size: 14px;
|
|
255
|
+
font-family: inherit;
|
|
256
|
+
border-radius: calc(${s.borderRadius} - 2px);
|
|
257
|
+
cursor: pointer;
|
|
258
|
+
width: auto;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.ss-chevron { font-size: 10px; }
|
|
262
|
+
|
|
263
|
+
.ss-btn-social {
|
|
264
|
+
display: flex;
|
|
265
|
+
align-items: center;
|
|
266
|
+
justify-content: center;
|
|
267
|
+
gap: 10px;
|
|
268
|
+
width: 100%;
|
|
269
|
+
padding: 10px 16px;
|
|
270
|
+
font-size: 14px;
|
|
271
|
+
font-weight: 500;
|
|
272
|
+
font-family: inherit;
|
|
273
|
+
border: 1px solid ${s.colorInputBorder};
|
|
274
|
+
border-radius: calc(${s.borderRadius} - 2px);
|
|
275
|
+
background: ${s.colorInputBackground};
|
|
276
|
+
color: ${s.colorText};
|
|
277
|
+
cursor: pointer;
|
|
278
|
+
transition: background 0.15s;
|
|
279
|
+
margin-bottom: 8px;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.ss-btn-social:hover:not(:disabled) { background: ${s.colorInputBorder}; }
|
|
283
|
+
.ss-btn-social:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
284
|
+
.ss-btn-social svg { width: 18px; height: 18px; flex-shrink: 0; }
|
|
285
|
+
|
|
286
|
+
.ss-divider {
|
|
287
|
+
display: flex;
|
|
288
|
+
align-items: center;
|
|
289
|
+
gap: 12px;
|
|
290
|
+
margin: 20px 0;
|
|
291
|
+
color: ${s.colorTextSecondary};
|
|
292
|
+
font-size: 13px;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.ss-divider::before,
|
|
296
|
+
.ss-divider::after {
|
|
297
|
+
content: '';
|
|
298
|
+
flex: 1;
|
|
299
|
+
height: 1px;
|
|
300
|
+
background: ${s.colorInputBorder};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.ss-footer {
|
|
304
|
+
text-align: center;
|
|
305
|
+
margin-top: 20px;
|
|
306
|
+
font-size: 14px;
|
|
307
|
+
color: ${s.colorTextSecondary};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.ss-link {
|
|
311
|
+
color: ${s.colorPrimary};
|
|
312
|
+
text-decoration: none;
|
|
313
|
+
cursor: pointer;
|
|
314
|
+
font-weight: 500;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.ss-link:hover { text-decoration: underline; }
|
|
318
|
+
|
|
319
|
+
.ss-spinner {
|
|
320
|
+
display: inline-block;
|
|
321
|
+
width: 16px;
|
|
322
|
+
height: 16px;
|
|
323
|
+
border: 2px solid transparent;
|
|
324
|
+
border-top-color: currentColor;
|
|
325
|
+
border-radius: 50%;
|
|
326
|
+
animation: ss-spin 0.6s linear infinite;
|
|
327
|
+
margin-right: 8px;
|
|
328
|
+
vertical-align: middle;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
@keyframes ss-spin { to { transform: rotate(360deg); } }
|
|
332
|
+
|
|
333
|
+
/* UserButton / Dropdown */
|
|
334
|
+
|
|
335
|
+
.ss-user-btn { position: relative; display: inline-block; }
|
|
336
|
+
|
|
337
|
+
.ss-avatar {
|
|
338
|
+
width: 36px;
|
|
339
|
+
height: 36px;
|
|
340
|
+
border-radius: 50%;
|
|
341
|
+
background: ${s.colorPrimary};
|
|
342
|
+
color: #fff;
|
|
343
|
+
display: flex;
|
|
344
|
+
align-items: center;
|
|
345
|
+
justify-content: center;
|
|
346
|
+
font-size: 14px;
|
|
347
|
+
font-weight: 600;
|
|
348
|
+
cursor: pointer;
|
|
349
|
+
border: none;
|
|
350
|
+
font-family: inherit;
|
|
351
|
+
transition: box-shadow 0.15s;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.ss-avatar:hover { box-shadow: 0 0 0 3px ${s.colorPrimary}33; }
|
|
355
|
+
|
|
356
|
+
.ss-dropdown {
|
|
357
|
+
position: absolute;
|
|
358
|
+
top: calc(100% + 8px);
|
|
359
|
+
right: 0;
|
|
360
|
+
background: ${s.colorBackground};
|
|
361
|
+
border: 1px solid ${s.colorInputBorder};
|
|
362
|
+
border-radius: ${s.borderRadius};
|
|
363
|
+
padding: 8px 0;
|
|
364
|
+
min-width: 200px;
|
|
365
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
366
|
+
z-index: 9999;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.ss-dropdown-org { left: 0; right: auto; }
|
|
370
|
+
|
|
371
|
+
.ss-dropdown-header {
|
|
372
|
+
padding: 8px 16px 12px;
|
|
373
|
+
border-bottom: 1px solid ${s.colorInputBorder};
|
|
374
|
+
margin-bottom: 4px;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.ss-dropdown-email {
|
|
378
|
+
font-size: 13px;
|
|
379
|
+
color: ${s.colorTextSecondary};
|
|
380
|
+
word-break: break-all;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.ss-dropdown-item {
|
|
384
|
+
display: block;
|
|
385
|
+
width: 100%;
|
|
386
|
+
padding: 8px 16px;
|
|
387
|
+
font-size: 14px;
|
|
388
|
+
font-family: inherit;
|
|
389
|
+
color: ${s.colorText};
|
|
390
|
+
background: none;
|
|
391
|
+
border: none;
|
|
392
|
+
text-align: left;
|
|
393
|
+
cursor: pointer;
|
|
394
|
+
transition: background 0.1s;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.ss-dropdown-item:hover { background: ${s.colorInputBackground}; }
|
|
398
|
+
.ss-dropdown-item-danger { color: ${s.colorError}; }
|
|
399
|
+
.ss-dropdown-item-active { font-weight: 600; color: ${s.colorPrimary}; }
|
|
400
|
+
|
|
401
|
+
/* Badges */
|
|
402
|
+
|
|
403
|
+
.ss-badge {
|
|
404
|
+
display: inline-block;
|
|
405
|
+
padding: 2px 8px;
|
|
406
|
+
font-size: 11px;
|
|
407
|
+
font-weight: 600;
|
|
408
|
+
border-radius: 999px;
|
|
409
|
+
text-transform: uppercase;
|
|
410
|
+
letter-spacing: 0.3px;
|
|
411
|
+
background: ${s.colorInputBackground};
|
|
412
|
+
color: ${s.colorTextSecondary};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.ss-badge-active { background: ${s.colorSuccess}22; color: ${s.colorSuccess}; }
|
|
416
|
+
.ss-badge-trialing { background: ${s.colorPrimary}22; color: ${s.colorPrimary}; }
|
|
417
|
+
.ss-badge-past-due { background: ${s.colorError}22; color: ${s.colorError}; }
|
|
418
|
+
.ss-badge-paused { background: ${s.colorWarning}22; color: ${s.colorWarning}; }
|
|
419
|
+
.ss-badge-canceled { background: ${s.colorTextSecondary}22; color: ${s.colorTextSecondary}; }
|
|
420
|
+
|
|
421
|
+
/* Tabs */
|
|
422
|
+
|
|
423
|
+
.ss-tab-group {
|
|
424
|
+
display: flex;
|
|
425
|
+
border-bottom: 1px solid ${s.colorInputBorder};
|
|
426
|
+
margin-bottom: 24px;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.ss-tab-group-sm { margin-bottom: 16px; }
|
|
430
|
+
|
|
431
|
+
.ss-tab {
|
|
432
|
+
padding: 8px 16px;
|
|
433
|
+
font-size: 14px;
|
|
434
|
+
font-weight: 500;
|
|
435
|
+
font-family: inherit;
|
|
436
|
+
color: ${s.colorTextSecondary};
|
|
437
|
+
background: none;
|
|
438
|
+
border: none;
|
|
439
|
+
border-bottom: 2px solid transparent;
|
|
440
|
+
cursor: pointer;
|
|
441
|
+
transition: color 0.15s, border-color 0.15s;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.ss-tab:hover { color: ${s.colorText}; }
|
|
445
|
+
|
|
446
|
+
.ss-tab-active {
|
|
447
|
+
color: ${s.colorPrimary};
|
|
448
|
+
border-bottom-color: ${s.colorPrimary};
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.ss-tab-content .ss-card { box-shadow: none; border: none; padding: 0; }
|
|
452
|
+
|
|
453
|
+
/* Tables */
|
|
454
|
+
|
|
455
|
+
.ss-table-container { overflow-x: auto; }
|
|
456
|
+
|
|
457
|
+
.ss-table {
|
|
458
|
+
width: 100%;
|
|
459
|
+
border-collapse: collapse;
|
|
460
|
+
font-size: 14px;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.ss-th {
|
|
464
|
+
text-align: left;
|
|
465
|
+
padding: 10px 12px;
|
|
466
|
+
font-weight: 600;
|
|
467
|
+
color: ${s.colorTextSecondary};
|
|
468
|
+
border-bottom: 2px solid ${s.colorInputBorder};
|
|
469
|
+
white-space: nowrap;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.ss-th-sortable { cursor: pointer; user-select: none; }
|
|
473
|
+
.ss-th-sortable:hover { color: ${s.colorText}; }
|
|
474
|
+
|
|
475
|
+
.ss-sort-indicator { font-size: 10px; }
|
|
476
|
+
.ss-sorted-asc, .ss-sorted-desc { color: ${s.colorPrimary}; }
|
|
477
|
+
|
|
478
|
+
.ss-td {
|
|
479
|
+
padding: 10px 12px;
|
|
480
|
+
border-bottom: 1px solid ${s.colorInputBorder};
|
|
481
|
+
color: ${s.colorText};
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.ss-tr:hover .ss-td { background: ${s.colorInputBackground}; }
|
|
485
|
+
|
|
486
|
+
.ss-table-footer {
|
|
487
|
+
text-align: center;
|
|
488
|
+
padding: 8px;
|
|
489
|
+
font-size: 12px;
|
|
490
|
+
color: ${s.colorTextSecondary};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/* Pricing */
|
|
494
|
+
|
|
495
|
+
.ss-pricing-grid {
|
|
496
|
+
display: grid;
|
|
497
|
+
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
|
498
|
+
gap: 16px;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.ss-pricing-card {
|
|
502
|
+
background: ${s.colorBackground};
|
|
503
|
+
border: 1px solid ${s.colorInputBorder};
|
|
504
|
+
border-radius: ${s.borderRadius};
|
|
505
|
+
padding: 24px;
|
|
506
|
+
display: flex;
|
|
507
|
+
flex-direction: column;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
.ss-pricing-card-current { border-color: ${s.colorPrimary}; }
|
|
511
|
+
|
|
512
|
+
.ss-pricing-header {
|
|
513
|
+
display: flex;
|
|
514
|
+
align-items: center;
|
|
515
|
+
gap: 8px;
|
|
516
|
+
margin-bottom: 12px;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.ss-pricing-name {
|
|
520
|
+
font-size: 18px;
|
|
521
|
+
font-weight: 600;
|
|
522
|
+
color: ${s.colorText};
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.ss-pricing-price { margin-bottom: 12px; }
|
|
526
|
+
|
|
527
|
+
.ss-pricing-amount {
|
|
528
|
+
font-size: 32px;
|
|
529
|
+
font-weight: 700;
|
|
530
|
+
color: ${s.colorText};
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
.ss-pricing-interval {
|
|
534
|
+
font-size: 14px;
|
|
535
|
+
color: ${s.colorTextSecondary};
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.ss-pricing-desc {
|
|
539
|
+
font-size: 14px;
|
|
540
|
+
color: ${s.colorTextSecondary};
|
|
541
|
+
margin-bottom: 16px;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
.ss-pricing-features {
|
|
545
|
+
list-style: none;
|
|
546
|
+
flex: 1;
|
|
547
|
+
margin-bottom: 20px;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.ss-pricing-feature {
|
|
551
|
+
font-size: 14px;
|
|
552
|
+
color: ${s.colorText};
|
|
553
|
+
padding: 4px 0;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.ss-check { color: ${s.colorSuccess}; margin-right: 6px; }
|
|
557
|
+
|
|
558
|
+
/* Usage / Progress */
|
|
559
|
+
|
|
560
|
+
.ss-usage-item { margin-bottom: 16px; }
|
|
561
|
+
|
|
562
|
+
.ss-usage-header {
|
|
563
|
+
display: flex;
|
|
564
|
+
justify-content: space-between;
|
|
565
|
+
margin-bottom: 6px;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.ss-usage-metric {
|
|
569
|
+
font-size: 14px;
|
|
570
|
+
font-weight: 500;
|
|
571
|
+
color: ${s.colorText};
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.ss-usage-value {
|
|
575
|
+
font-size: 14px;
|
|
576
|
+
color: ${s.colorTextSecondary};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.ss-progress-bar {
|
|
580
|
+
width: 100%;
|
|
581
|
+
height: 8px;
|
|
582
|
+
background: ${s.colorInputBackground};
|
|
583
|
+
border-radius: 4px;
|
|
584
|
+
overflow: hidden;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.ss-progress-fill {
|
|
588
|
+
height: 100%;
|
|
589
|
+
background: ${s.colorPrimary};
|
|
590
|
+
border-radius: 4px;
|
|
591
|
+
transition: width 0.3s;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
.ss-progress-danger { background: ${s.colorError}; }
|
|
595
|
+
|
|
596
|
+
/* Chart */
|
|
597
|
+
|
|
598
|
+
.ss-chart-container { text-align: center; }
|
|
599
|
+
|
|
600
|
+
.ss-chart-title {
|
|
601
|
+
font-size: 16px;
|
|
602
|
+
font-weight: 600;
|
|
603
|
+
color: ${s.colorText};
|
|
604
|
+
margin-bottom: 12px;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/* Dashboard */
|
|
608
|
+
|
|
609
|
+
.ss-dashboard-grid {
|
|
610
|
+
display: grid;
|
|
611
|
+
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
|
612
|
+
gap: 16px;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
.ss-widget {
|
|
616
|
+
background: ${s.colorBackground};
|
|
617
|
+
border: 1px solid ${s.colorInputBorder};
|
|
618
|
+
border-radius: ${s.borderRadius};
|
|
619
|
+
padding: 16px;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
.ss-widget-header {
|
|
623
|
+
font-size: 14px;
|
|
624
|
+
font-weight: 600;
|
|
625
|
+
color: ${s.colorText};
|
|
626
|
+
margin-bottom: 12px;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/* Saved Queries */
|
|
630
|
+
|
|
631
|
+
.ss-saved-query-card {
|
|
632
|
+
padding: 12px 16px;
|
|
633
|
+
border: 1px solid ${s.colorInputBorder};
|
|
634
|
+
border-radius: calc(${s.borderRadius} - 2px);
|
|
635
|
+
margin-bottom: 8px;
|
|
636
|
+
cursor: pointer;
|
|
637
|
+
transition: border-color 0.15s;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
.ss-saved-query-card:hover { border-color: ${s.colorPrimary}; }
|
|
641
|
+
|
|
642
|
+
.ss-saved-query-header {
|
|
643
|
+
display: flex;
|
|
644
|
+
align-items: center;
|
|
645
|
+
justify-content: space-between;
|
|
646
|
+
margin-bottom: 4px;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
.ss-saved-query-name {
|
|
650
|
+
font-size: 14px;
|
|
651
|
+
font-weight: 600;
|
|
652
|
+
color: ${s.colorText};
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.ss-saved-query-desc {
|
|
656
|
+
font-size: 13px;
|
|
657
|
+
color: ${s.colorTextSecondary};
|
|
658
|
+
margin-bottom: 8px;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.ss-saved-query-footer {
|
|
662
|
+
display: flex;
|
|
663
|
+
align-items: center;
|
|
664
|
+
justify-content: space-between;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
.ss-saved-query-date {
|
|
668
|
+
font-size: 12px;
|
|
669
|
+
color: ${s.colorTextSecondary};
|
|
670
|
+
}
|
|
671
|
+
`;
|
|
672
|
+
}
|
|
673
|
+
function E({ children: s, appearance: n }) {
|
|
674
|
+
const r = U(null), [c, a] = m(null);
|
|
675
|
+
C(() => {
|
|
676
|
+
var g;
|
|
677
|
+
if (!r.current || r.current.shadowRoot) {
|
|
678
|
+
a(((g = r.current) == null ? void 0 : g.shadowRoot) ?? null);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
const l = r.current.attachShadow({ mode: "open" }), d = M(n), o = document.createElement("style");
|
|
682
|
+
o.textContent = O(d), l.appendChild(o);
|
|
683
|
+
const t = document.createElement("div");
|
|
684
|
+
l.appendChild(t), a(l);
|
|
685
|
+
}, []), C(() => {
|
|
686
|
+
if (!c) return;
|
|
687
|
+
const l = c.querySelector("style");
|
|
688
|
+
if (l) {
|
|
689
|
+
const d = M(n);
|
|
690
|
+
l.textContent = O(d);
|
|
691
|
+
}
|
|
692
|
+
}, [n, c]);
|
|
693
|
+
const i = (c == null ? void 0 : c.querySelector("div")) ?? null;
|
|
694
|
+
return /* @__PURE__ */ e("div", { ref: r, style: { display: "contents" }, children: i && Z(s, i) });
|
|
695
|
+
}
|
|
696
|
+
function W() {
|
|
697
|
+
const { client: s, user: n, isLoaded: r } = $();
|
|
698
|
+
return {
|
|
699
|
+
isLoaded: r,
|
|
700
|
+
isSignedIn: !!n,
|
|
701
|
+
user: n,
|
|
702
|
+
signOut: S(() => s.auth.signOut(), [s]),
|
|
703
|
+
getToken: S(() => s.auth.getToken(), [s])
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
function Is() {
|
|
707
|
+
const { user: s, isLoaded: n } = $();
|
|
708
|
+
return { user: s, isLoaded: n };
|
|
709
|
+
}
|
|
710
|
+
function _() {
|
|
711
|
+
const { client: s } = $(), [n, r] = m(!1), [c, a] = m(null), i = S(
|
|
712
|
+
async (o, t) => {
|
|
713
|
+
r(!0), a(null);
|
|
714
|
+
try {
|
|
715
|
+
return await s.auth.signIn(o, t);
|
|
716
|
+
} catch (g) {
|
|
717
|
+
return a(g instanceof Error ? g.message : "Sign in failed"), null;
|
|
718
|
+
} finally {
|
|
719
|
+
r(!1);
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
[s]
|
|
723
|
+
), l = S(
|
|
724
|
+
async (o) => {
|
|
725
|
+
r(!0), a(null);
|
|
726
|
+
try {
|
|
727
|
+
return await s.auth.signInWithOAuth(o);
|
|
728
|
+
} catch (t) {
|
|
729
|
+
return a(t instanceof Error ? t.message : "OAuth sign in failed"), null;
|
|
730
|
+
} finally {
|
|
731
|
+
r(!1);
|
|
732
|
+
}
|
|
733
|
+
},
|
|
734
|
+
[s]
|
|
735
|
+
), d = S(
|
|
736
|
+
async (o, t) => {
|
|
737
|
+
r(!0), a(null);
|
|
738
|
+
try {
|
|
739
|
+
return await s.auth.submitMfaCode(o, t);
|
|
740
|
+
} catch (g) {
|
|
741
|
+
return a(g instanceof Error ? g.message : "MFA verification failed"), null;
|
|
742
|
+
} finally {
|
|
743
|
+
r(!1);
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
[s]
|
|
747
|
+
);
|
|
748
|
+
return { signIn: i, signInWithOAuth: l, submitMfaCode: d, isLoading: n, error: c, setError: a };
|
|
749
|
+
}
|
|
750
|
+
function ns() {
|
|
751
|
+
const { client: s } = $(), [n, r] = m(!1), [c, a] = m(null);
|
|
752
|
+
return { signUp: S(
|
|
753
|
+
async (l, d) => {
|
|
754
|
+
r(!0), a(null);
|
|
755
|
+
try {
|
|
756
|
+
return await s.auth.signUp(l, d);
|
|
757
|
+
} catch (o) {
|
|
758
|
+
return a(o instanceof Error ? o.message : "Sign up failed"), null;
|
|
759
|
+
} finally {
|
|
760
|
+
r(!1);
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
[s]
|
|
764
|
+
), isLoading: n, error: c, setError: a };
|
|
765
|
+
}
|
|
766
|
+
function as() {
|
|
767
|
+
const { client: s } = $(), [n, r] = m([]), [c, a] = m(null), [i, l] = m([]), [d, o] = m(!1), [t, g] = m(null), p = S(async () => {
|
|
768
|
+
o(!0), g(null);
|
|
769
|
+
try {
|
|
770
|
+
const x = await s.auth.listOrgs();
|
|
771
|
+
r(x);
|
|
772
|
+
} catch (x) {
|
|
773
|
+
g(x instanceof Error ? x.message : "Failed to load organizations");
|
|
774
|
+
} finally {
|
|
775
|
+
o(!1);
|
|
776
|
+
}
|
|
777
|
+
}, [s]);
|
|
778
|
+
C(() => {
|
|
779
|
+
p();
|
|
780
|
+
}, [p]);
|
|
781
|
+
const h = S(async (x) => {
|
|
782
|
+
try {
|
|
783
|
+
const b = await s.auth.getOrg(x);
|
|
784
|
+
a(b);
|
|
785
|
+
const N = await s.auth.listMembers(x);
|
|
786
|
+
l(N);
|
|
787
|
+
} catch (b) {
|
|
788
|
+
g(b instanceof Error ? b.message : "Failed to load organization");
|
|
789
|
+
}
|
|
790
|
+
}, [s]), f = S(async (x, b) => {
|
|
791
|
+
try {
|
|
792
|
+
const N = await s.auth.createOrg(x, b);
|
|
793
|
+
return r((y) => [...y, N]), N;
|
|
794
|
+
} catch (N) {
|
|
795
|
+
return g(N instanceof Error ? N.message : "Failed to create organization"), null;
|
|
796
|
+
}
|
|
797
|
+
}, [s]);
|
|
798
|
+
return { orgs: n, selectedOrg: c, members: i, isLoading: d, error: t, refresh: p, selectOrg: h, createOrg: f };
|
|
799
|
+
}
|
|
800
|
+
const j = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>', G = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" fill="currentColor"/></svg>';
|
|
801
|
+
function Ls({ appearance: s, signUpUrl: n, onSignUp: r }) {
|
|
802
|
+
const { appearance: c, settings: a } = $(), { signIn: i, signInWithOAuth: l, submitMfaCode: d, isLoading: o, error: t, setError: g } = _(), p = s ?? c, [h, f] = m(""), [x, b] = m(""), [N, y] = m(!1), [v, w] = m(""), [k, T] = m(""), P = S(
|
|
803
|
+
async (L) => {
|
|
804
|
+
if (L.preventDefault(), N) {
|
|
805
|
+
await d(v, k);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const F = await i(h, x);
|
|
809
|
+
F && K(F) && (w(F.mfaToken), y(!0), g(null));
|
|
810
|
+
},
|
|
811
|
+
[h, x, N, v, k, i, d, g]
|
|
812
|
+
), I = S(
|
|
813
|
+
async (L) => {
|
|
814
|
+
await l(L);
|
|
815
|
+
},
|
|
816
|
+
[l]
|
|
817
|
+
), z = (a == null ? void 0 : a.googleEnabled) || (a == null ? void 0 : a.githubEnabled);
|
|
818
|
+
return /* @__PURE__ */ e(E, { appearance: p, children: /* @__PURE__ */ u("div", { className: "ss-card", children: [
|
|
819
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Sign in" }),
|
|
820
|
+
!N && /* @__PURE__ */ u(D, { children: [
|
|
821
|
+
(a == null ? void 0 : a.googleEnabled) && /* @__PURE__ */ u(
|
|
822
|
+
"button",
|
|
823
|
+
{
|
|
824
|
+
type: "button",
|
|
825
|
+
className: "ss-btn-social",
|
|
826
|
+
onClick: () => I("google"),
|
|
827
|
+
disabled: o,
|
|
828
|
+
children: [
|
|
829
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: j } }),
|
|
830
|
+
"Continue with Google"
|
|
831
|
+
]
|
|
832
|
+
}
|
|
833
|
+
),
|
|
834
|
+
(a == null ? void 0 : a.githubEnabled) && /* @__PURE__ */ u(
|
|
835
|
+
"button",
|
|
836
|
+
{
|
|
837
|
+
type: "button",
|
|
838
|
+
className: "ss-btn-social",
|
|
839
|
+
onClick: () => I("github"),
|
|
840
|
+
disabled: o,
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: G } }),
|
|
843
|
+
"Continue with GitHub"
|
|
844
|
+
]
|
|
845
|
+
}
|
|
846
|
+
),
|
|
847
|
+
z && /* @__PURE__ */ e("div", { className: "ss-divider", children: "or" })
|
|
848
|
+
] }),
|
|
849
|
+
t && /* @__PURE__ */ e("div", { className: "ss-global-error", children: t }),
|
|
850
|
+
/* @__PURE__ */ u("form", { onSubmit: P, children: [
|
|
851
|
+
N ? /* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
852
|
+
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-mfa-code", children: "Authentication code" }),
|
|
853
|
+
/* @__PURE__ */ e(
|
|
854
|
+
"input",
|
|
855
|
+
{
|
|
856
|
+
id: "ss-mfa-code",
|
|
857
|
+
className: "ss-input",
|
|
858
|
+
type: "text",
|
|
859
|
+
inputMode: "numeric",
|
|
860
|
+
autoComplete: "one-time-code",
|
|
861
|
+
placeholder: "Enter 6-digit code",
|
|
862
|
+
value: k,
|
|
863
|
+
onChange: (L) => T(L.target.value),
|
|
864
|
+
autoFocus: !0
|
|
865
|
+
}
|
|
866
|
+
)
|
|
867
|
+
] }) : /* @__PURE__ */ u(D, { children: [
|
|
868
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
869
|
+
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-email", children: "Email" }),
|
|
870
|
+
/* @__PURE__ */ e(
|
|
871
|
+
"input",
|
|
872
|
+
{
|
|
873
|
+
id: "ss-email",
|
|
874
|
+
className: "ss-input",
|
|
875
|
+
type: "email",
|
|
876
|
+
autoComplete: "email",
|
|
877
|
+
placeholder: "you@example.com",
|
|
878
|
+
value: h,
|
|
879
|
+
onChange: (L) => f(L.target.value),
|
|
880
|
+
required: !0
|
|
881
|
+
}
|
|
882
|
+
)
|
|
883
|
+
] }),
|
|
884
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
885
|
+
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-password", children: "Password" }),
|
|
886
|
+
/* @__PURE__ */ e(
|
|
887
|
+
"input",
|
|
888
|
+
{
|
|
889
|
+
id: "ss-password",
|
|
890
|
+
className: "ss-input",
|
|
891
|
+
type: "password",
|
|
892
|
+
autoComplete: "current-password",
|
|
893
|
+
placeholder: "Enter your password",
|
|
894
|
+
value: x,
|
|
895
|
+
onChange: (L) => b(L.target.value),
|
|
896
|
+
required: !0
|
|
897
|
+
}
|
|
898
|
+
)
|
|
899
|
+
] })
|
|
900
|
+
] }),
|
|
901
|
+
/* @__PURE__ */ u("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: o, children: [
|
|
902
|
+
o && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
903
|
+
N ? "Verify" : "Continue"
|
|
904
|
+
] })
|
|
905
|
+
] }),
|
|
906
|
+
N && /* @__PURE__ */ e("div", { className: "ss-footer", children: /* @__PURE__ */ e(
|
|
907
|
+
"span",
|
|
908
|
+
{
|
|
909
|
+
className: "ss-link",
|
|
910
|
+
onClick: () => {
|
|
911
|
+
y(!1), T(""), g(null);
|
|
912
|
+
},
|
|
913
|
+
children: "Back to sign in"
|
|
914
|
+
}
|
|
915
|
+
) }),
|
|
916
|
+
!N && /* @__PURE__ */ u("div", { className: "ss-footer", children: [
|
|
917
|
+
"Don't have an account?",
|
|
918
|
+
" ",
|
|
919
|
+
r ? /* @__PURE__ */ e("span", { className: "ss-link", onClick: r, children: "Sign up" }) : n ? /* @__PURE__ */ e("a", { className: "ss-link", href: n, children: "Sign up" }) : /* @__PURE__ */ e("span", { className: "ss-link", children: "Sign up" })
|
|
920
|
+
] })
|
|
921
|
+
] }) });
|
|
922
|
+
}
|
|
923
|
+
function Bs({ appearance: s, signInUrl: n, onSignIn: r }) {
|
|
924
|
+
const { appearance: c, settings: a } = $(), { signUp: i, isLoading: l, error: d, setError: o } = ns(), { signInWithOAuth: t } = _(), g = s ?? c, [p, h] = m(""), [f, x] = m(""), [b, N] = m(""), [y, v] = m(null), w = S(
|
|
925
|
+
async (I) => {
|
|
926
|
+
if (I.preventDefault(), v(null), f !== b) {
|
|
927
|
+
v("Passwords do not match");
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
const z = (a == null ? void 0 : a.passwordMinLength) ?? 8;
|
|
931
|
+
if (f.length < z) {
|
|
932
|
+
v(`Password must be at least ${z} characters`);
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
await i(p, f);
|
|
936
|
+
},
|
|
937
|
+
[p, f, b, a, i]
|
|
938
|
+
), k = S(
|
|
939
|
+
async (I) => {
|
|
940
|
+
await t(I);
|
|
941
|
+
},
|
|
942
|
+
[t]
|
|
943
|
+
), T = (a == null ? void 0 : a.googleEnabled) || (a == null ? void 0 : a.githubEnabled), P = y || d;
|
|
944
|
+
return /* @__PURE__ */ e(E, { appearance: g, children: /* @__PURE__ */ u("div", { className: "ss-card", children: [
|
|
945
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Create account" }),
|
|
946
|
+
(a == null ? void 0 : a.googleEnabled) && /* @__PURE__ */ u(
|
|
947
|
+
"button",
|
|
948
|
+
{
|
|
949
|
+
type: "button",
|
|
950
|
+
className: "ss-btn-social",
|
|
951
|
+
onClick: () => k("google"),
|
|
952
|
+
disabled: l,
|
|
953
|
+
children: [
|
|
954
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: j } }),
|
|
955
|
+
"Continue with Google"
|
|
956
|
+
]
|
|
957
|
+
}
|
|
958
|
+
),
|
|
959
|
+
(a == null ? void 0 : a.githubEnabled) && /* @__PURE__ */ u(
|
|
960
|
+
"button",
|
|
961
|
+
{
|
|
962
|
+
type: "button",
|
|
963
|
+
className: "ss-btn-social",
|
|
964
|
+
onClick: () => k("github"),
|
|
965
|
+
disabled: l,
|
|
966
|
+
children: [
|
|
967
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: G } }),
|
|
968
|
+
"Continue with GitHub"
|
|
969
|
+
]
|
|
970
|
+
}
|
|
971
|
+
),
|
|
972
|
+
T && /* @__PURE__ */ e("div", { className: "ss-divider", children: "or" }),
|
|
973
|
+
P && /* @__PURE__ */ e("div", { className: "ss-global-error", children: P }),
|
|
974
|
+
/* @__PURE__ */ u("form", { onSubmit: w, children: [
|
|
975
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
976
|
+
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-email", children: "Email" }),
|
|
977
|
+
/* @__PURE__ */ e(
|
|
978
|
+
"input",
|
|
979
|
+
{
|
|
980
|
+
id: "ss-signup-email",
|
|
981
|
+
className: "ss-input",
|
|
982
|
+
type: "email",
|
|
983
|
+
autoComplete: "email",
|
|
984
|
+
placeholder: "you@example.com",
|
|
985
|
+
value: p,
|
|
986
|
+
onChange: (I) => h(I.target.value),
|
|
987
|
+
required: !0
|
|
988
|
+
}
|
|
989
|
+
)
|
|
990
|
+
] }),
|
|
991
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
992
|
+
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-password", children: "Password" }),
|
|
993
|
+
/* @__PURE__ */ e(
|
|
994
|
+
"input",
|
|
995
|
+
{
|
|
996
|
+
id: "ss-signup-password",
|
|
997
|
+
className: "ss-input",
|
|
998
|
+
type: "password",
|
|
999
|
+
autoComplete: "new-password",
|
|
1000
|
+
placeholder: "Create a password",
|
|
1001
|
+
value: f,
|
|
1002
|
+
onChange: (I) => {
|
|
1003
|
+
x(I.target.value), v(null);
|
|
1004
|
+
},
|
|
1005
|
+
required: !0
|
|
1006
|
+
}
|
|
1007
|
+
)
|
|
1008
|
+
] }),
|
|
1009
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
1010
|
+
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-confirm", children: "Confirm password" }),
|
|
1011
|
+
/* @__PURE__ */ e(
|
|
1012
|
+
"input",
|
|
1013
|
+
{
|
|
1014
|
+
id: "ss-signup-confirm",
|
|
1015
|
+
className: "ss-input",
|
|
1016
|
+
type: "password",
|
|
1017
|
+
autoComplete: "new-password",
|
|
1018
|
+
placeholder: "Confirm your password",
|
|
1019
|
+
value: b,
|
|
1020
|
+
onChange: (I) => {
|
|
1021
|
+
N(I.target.value), v(null);
|
|
1022
|
+
},
|
|
1023
|
+
required: !0
|
|
1024
|
+
}
|
|
1025
|
+
)
|
|
1026
|
+
] }),
|
|
1027
|
+
/* @__PURE__ */ u("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l, children: [
|
|
1028
|
+
l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1029
|
+
"Create account"
|
|
1030
|
+
] })
|
|
1031
|
+
] }),
|
|
1032
|
+
/* @__PURE__ */ u("div", { className: "ss-footer", children: [
|
|
1033
|
+
"Already have an account?",
|
|
1034
|
+
" ",
|
|
1035
|
+
r ? /* @__PURE__ */ e("span", { className: "ss-link", onClick: r, children: "Sign in" }) : n ? /* @__PURE__ */ e("a", { className: "ss-link", href: n, children: "Sign in" }) : /* @__PURE__ */ e("span", { className: "ss-link", children: "Sign in" })
|
|
1036
|
+
] })
|
|
1037
|
+
] }) });
|
|
1038
|
+
}
|
|
1039
|
+
function Ps({ appearance: s }) {
|
|
1040
|
+
const { appearance: n } = $(), { user: r, signOut: c } = W(), a = s ?? n, [i, l] = m(!1), d = U(null), o = S((g) => {
|
|
1041
|
+
d.current && !d.current.contains(g.target) && l(!1);
|
|
1042
|
+
}, []);
|
|
1043
|
+
if (C(() => {
|
|
1044
|
+
if (i) {
|
|
1045
|
+
const g = setTimeout(() => {
|
|
1046
|
+
document.addEventListener("click", o);
|
|
1047
|
+
}, 0);
|
|
1048
|
+
return () => {
|
|
1049
|
+
clearTimeout(g), document.removeEventListener("click", o);
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
}, [i, o]), !r) return null;
|
|
1053
|
+
const t = r.email.charAt(0).toUpperCase();
|
|
1054
|
+
return /* @__PURE__ */ e(E, { appearance: a, children: /* @__PURE__ */ u("div", { className: "ss-user-btn", ref: d, children: [
|
|
1055
|
+
/* @__PURE__ */ e(
|
|
1056
|
+
"button",
|
|
1057
|
+
{
|
|
1058
|
+
type: "button",
|
|
1059
|
+
className: "ss-avatar",
|
|
1060
|
+
onClick: () => l(!i),
|
|
1061
|
+
"aria-label": "User menu",
|
|
1062
|
+
children: t
|
|
1063
|
+
}
|
|
1064
|
+
),
|
|
1065
|
+
i && /* @__PURE__ */ u("div", { className: "ss-dropdown", children: [
|
|
1066
|
+
/* @__PURE__ */ e("div", { className: "ss-dropdown-header", children: /* @__PURE__ */ e("div", { className: "ss-dropdown-email", children: r.email }) }),
|
|
1067
|
+
/* @__PURE__ */ e(
|
|
1068
|
+
"button",
|
|
1069
|
+
{
|
|
1070
|
+
type: "button",
|
|
1071
|
+
className: "ss-dropdown-item ss-dropdown-item-danger",
|
|
1072
|
+
onClick: async () => {
|
|
1073
|
+
l(!1), await c();
|
|
1074
|
+
},
|
|
1075
|
+
children: "Sign out"
|
|
1076
|
+
}
|
|
1077
|
+
)
|
|
1078
|
+
] })
|
|
1079
|
+
] }) });
|
|
1080
|
+
}
|
|
1081
|
+
function zs({ appearance: s }) {
|
|
1082
|
+
const { appearance: n } = $(), { user: r, signOut: c } = W(), a = s ?? n;
|
|
1083
|
+
return r ? /* @__PURE__ */ e(E, { appearance: a, children: /* @__PURE__ */ u("div", { className: "ss-card", children: [
|
|
1084
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Profile" }),
|
|
1085
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
1086
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Email" }),
|
|
1087
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "email", value: r.email, disabled: !0, readOnly: !0 })
|
|
1088
|
+
] }),
|
|
1089
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
1090
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Provider" }),
|
|
1091
|
+
/* @__PURE__ */ e(
|
|
1092
|
+
"input",
|
|
1093
|
+
{
|
|
1094
|
+
className: "ss-input",
|
|
1095
|
+
type: "text",
|
|
1096
|
+
value: r.provider,
|
|
1097
|
+
disabled: !0,
|
|
1098
|
+
readOnly: !0
|
|
1099
|
+
}
|
|
1100
|
+
)
|
|
1101
|
+
] }),
|
|
1102
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
1103
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Email verified" }),
|
|
1104
|
+
/* @__PURE__ */ e(
|
|
1105
|
+
"input",
|
|
1106
|
+
{
|
|
1107
|
+
className: "ss-input",
|
|
1108
|
+
type: "text",
|
|
1109
|
+
value: r.emailVerified ? "Yes" : "No",
|
|
1110
|
+
disabled: !0,
|
|
1111
|
+
readOnly: !0
|
|
1112
|
+
}
|
|
1113
|
+
)
|
|
1114
|
+
] }),
|
|
1115
|
+
/* @__PURE__ */ e("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ e(
|
|
1116
|
+
"button",
|
|
1117
|
+
{
|
|
1118
|
+
type: "button",
|
|
1119
|
+
className: "ss-btn ss-btn-primary",
|
|
1120
|
+
onClick: () => c(),
|
|
1121
|
+
style: { background: "#ef4444" },
|
|
1122
|
+
children: "Sign out"
|
|
1123
|
+
}
|
|
1124
|
+
) })
|
|
1125
|
+
] }) }) : null;
|
|
1126
|
+
}
|
|
1127
|
+
function Ds({ appearance: s, onOrgChange: n }) {
|
|
1128
|
+
const { appearance: r } = $(), { orgs: c, selectedOrg: a, selectOrg: i, isLoading: l } = as(), d = s ?? r, [o, t] = m(!1), g = U(null), p = S((f) => {
|
|
1129
|
+
g.current && !g.current.contains(f.target) && t(!1);
|
|
1130
|
+
}, []);
|
|
1131
|
+
if (C(() => {
|
|
1132
|
+
if (o) {
|
|
1133
|
+
const f = setTimeout(() => {
|
|
1134
|
+
document.addEventListener("click", p);
|
|
1135
|
+
}, 0);
|
|
1136
|
+
return () => {
|
|
1137
|
+
clearTimeout(f), document.removeEventListener("click", p);
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
}, [o, p]), l || c.length === 0) return null;
|
|
1141
|
+
const h = (a == null ? void 0 : a.name) ?? "Select organization";
|
|
1142
|
+
return /* @__PURE__ */ e(E, { appearance: d, children: /* @__PURE__ */ u("div", { className: "ss-user-btn", ref: g, children: [
|
|
1143
|
+
/* @__PURE__ */ u(
|
|
1144
|
+
"button",
|
|
1145
|
+
{
|
|
1146
|
+
type: "button",
|
|
1147
|
+
className: "ss-btn ss-btn-org-switcher",
|
|
1148
|
+
onClick: () => t(!o),
|
|
1149
|
+
children: [
|
|
1150
|
+
h,
|
|
1151
|
+
/* @__PURE__ */ e("span", { className: "ss-chevron", children: o ? "▲" : "▼" })
|
|
1152
|
+
]
|
|
1153
|
+
}
|
|
1154
|
+
),
|
|
1155
|
+
o && /* @__PURE__ */ e("div", { className: "ss-dropdown ss-dropdown-org", children: c.map((f) => /* @__PURE__ */ e(
|
|
1156
|
+
"button",
|
|
1157
|
+
{
|
|
1158
|
+
type: "button",
|
|
1159
|
+
className: `ss-dropdown-item ${(a == null ? void 0 : a.id) === f.id ? "ss-dropdown-item-active" : ""}`,
|
|
1160
|
+
onClick: async () => {
|
|
1161
|
+
t(!1), await i(f.id), n == null || n(f);
|
|
1162
|
+
},
|
|
1163
|
+
children: f.name
|
|
1164
|
+
},
|
|
1165
|
+
f.id
|
|
1166
|
+
)) })
|
|
1167
|
+
] }) });
|
|
1168
|
+
}
|
|
1169
|
+
function os(s, n = "USD") {
|
|
1170
|
+
return new Intl.NumberFormat("en-US", {
|
|
1171
|
+
style: "currency",
|
|
1172
|
+
currency: n,
|
|
1173
|
+
minimumFractionDigits: s % 100 === 0 ? 0 : 2
|
|
1174
|
+
}).format(s / 100);
|
|
1175
|
+
}
|
|
1176
|
+
function qs({ plans: s, currentPlanId: n, onSelectPlan: r, interval: c, appearance: a }) {
|
|
1177
|
+
const { appearance: i } = $(), l = a ?? i, d = c ? s.filter((o) => o.interval === c || o.isFree) : s;
|
|
1178
|
+
return /* @__PURE__ */ e(E, { appearance: l, children: /* @__PURE__ */ e("div", { className: "ss-pricing-grid", children: d.map((o) => {
|
|
1179
|
+
const t = o.id === n;
|
|
1180
|
+
return /* @__PURE__ */ u("div", { className: `ss-pricing-card ${t ? "ss-pricing-card-current" : ""}`, children: [
|
|
1181
|
+
/* @__PURE__ */ u("div", { className: "ss-pricing-header", children: [
|
|
1182
|
+
/* @__PURE__ */ e("h3", { className: "ss-pricing-name", children: o.name }),
|
|
1183
|
+
o.trialDays > 0 && /* @__PURE__ */ u("span", { className: "ss-badge ss-badge-trialing", children: [
|
|
1184
|
+
o.trialDays,
|
|
1185
|
+
"-day trial"
|
|
1186
|
+
] }),
|
|
1187
|
+
o.isFree && /* @__PURE__ */ e("span", { className: "ss-badge ss-badge-active", children: "Free" })
|
|
1188
|
+
] }),
|
|
1189
|
+
/* @__PURE__ */ e("div", { className: "ss-pricing-price", children: o.isFree ? /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: "Free" }) : /* @__PURE__ */ u(D, { children: [
|
|
1190
|
+
/* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: os(o.amountCents, o.currency) }),
|
|
1191
|
+
/* @__PURE__ */ u("span", { className: "ss-pricing-interval", children: [
|
|
1192
|
+
"/",
|
|
1193
|
+
o.interval
|
|
1194
|
+
] })
|
|
1195
|
+
] }) }),
|
|
1196
|
+
o.description && /* @__PURE__ */ e("p", { className: "ss-pricing-desc", children: o.description }),
|
|
1197
|
+
o.features.length > 0 && /* @__PURE__ */ e("ul", { className: "ss-pricing-features", children: o.features.map((g, p) => /* @__PURE__ */ u("li", { className: "ss-pricing-feature", children: [
|
|
1198
|
+
/* @__PURE__ */ e("span", { className: "ss-check", children: "✓" }),
|
|
1199
|
+
" ",
|
|
1200
|
+
g
|
|
1201
|
+
] }, p)) }),
|
|
1202
|
+
/* @__PURE__ */ e(
|
|
1203
|
+
"button",
|
|
1204
|
+
{
|
|
1205
|
+
type: "button",
|
|
1206
|
+
className: `ss-btn ${t ? "ss-btn-current" : "ss-btn-primary"}`,
|
|
1207
|
+
disabled: t,
|
|
1208
|
+
onClick: () => r(o.id),
|
|
1209
|
+
children: t ? "Current plan" : "Select plan"
|
|
1210
|
+
}
|
|
1211
|
+
)
|
|
1212
|
+
] }, o.id);
|
|
1213
|
+
}) }) });
|
|
1214
|
+
}
|
|
1215
|
+
function As() {
|
|
1216
|
+
const { client: s } = $();
|
|
1217
|
+
return { billing: s.billing };
|
|
1218
|
+
}
|
|
1219
|
+
function A(s) {
|
|
1220
|
+
const { client: n } = $();
|
|
1221
|
+
return B(() => {
|
|
1222
|
+
if (s) {
|
|
1223
|
+
const r = new q("https://api.saas-support.com/v1", { type: "portalToken", token: s });
|
|
1224
|
+
return new X(r);
|
|
1225
|
+
}
|
|
1226
|
+
return n.billing;
|
|
1227
|
+
}, [n, s]);
|
|
1228
|
+
}
|
|
1229
|
+
function ts(s, n) {
|
|
1230
|
+
const r = A(n), [c, a] = m(null), [i, l] = m(!0), [d, o] = m(null), t = S(async () => {
|
|
1231
|
+
l(!0), o(null);
|
|
1232
|
+
try {
|
|
1233
|
+
const g = await r.getCustomer(s);
|
|
1234
|
+
a(g);
|
|
1235
|
+
} catch (g) {
|
|
1236
|
+
o(g instanceof Error ? g.message : "Failed to load subscription");
|
|
1237
|
+
} finally {
|
|
1238
|
+
l(!1);
|
|
1239
|
+
}
|
|
1240
|
+
}, [r, s]);
|
|
1241
|
+
return C(() => {
|
|
1242
|
+
t();
|
|
1243
|
+
}, [t]), { customer: c, isLoading: i, error: d, refresh: t };
|
|
1244
|
+
}
|
|
1245
|
+
function cs(s, n) {
|
|
1246
|
+
const r = A(n), [c, a] = m([]), [i, l] = m(!0), [d, o] = m(null), t = S(async () => {
|
|
1247
|
+
l(!0), o(null);
|
|
1248
|
+
try {
|
|
1249
|
+
const g = await r.getInvoices(s);
|
|
1250
|
+
a(g);
|
|
1251
|
+
} catch (g) {
|
|
1252
|
+
o(g instanceof Error ? g.message : "Failed to load invoices");
|
|
1253
|
+
} finally {
|
|
1254
|
+
l(!1);
|
|
1255
|
+
}
|
|
1256
|
+
}, [r, s]);
|
|
1257
|
+
return C(() => {
|
|
1258
|
+
t();
|
|
1259
|
+
}, [t]), { invoices: c, isLoading: i, error: d, refresh: t };
|
|
1260
|
+
}
|
|
1261
|
+
function ls(s, n) {
|
|
1262
|
+
const r = A(n), [c, a] = m([]), [i, l] = m(!0), [d, o] = m(null), t = S(async () => {
|
|
1263
|
+
l(!0), o(null);
|
|
1264
|
+
try {
|
|
1265
|
+
const g = await r.getCurrentUsage(s);
|
|
1266
|
+
a(g);
|
|
1267
|
+
} catch (g) {
|
|
1268
|
+
o(g instanceof Error ? g.message : "Failed to load usage");
|
|
1269
|
+
} finally {
|
|
1270
|
+
l(!1);
|
|
1271
|
+
}
|
|
1272
|
+
}, [r, s]);
|
|
1273
|
+
return C(() => {
|
|
1274
|
+
t();
|
|
1275
|
+
}, [t]), { usage: c, isLoading: i, error: d, refresh: t };
|
|
1276
|
+
}
|
|
1277
|
+
const is = {
|
|
1278
|
+
active: "ss-badge-active"
|
|
1279
|
+
};
|
|
1280
|
+
function ds({
|
|
1281
|
+
customerId: s,
|
|
1282
|
+
portalToken: n,
|
|
1283
|
+
onChangePlan: r,
|
|
1284
|
+
onCancel: c,
|
|
1285
|
+
appearance: a
|
|
1286
|
+
}) {
|
|
1287
|
+
const { appearance: i } = $(), { customer: l, isLoading: d, error: o } = ts(s, n);
|
|
1288
|
+
return /* @__PURE__ */ e(E, { appearance: a ?? i, children: /* @__PURE__ */ u("div", { className: "ss-card", children: [
|
|
1289
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Subscription" }),
|
|
1290
|
+
d && /* @__PURE__ */ u("div", { className: "ss-loading", children: [
|
|
1291
|
+
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1292
|
+
" Loading..."
|
|
1293
|
+
] }),
|
|
1294
|
+
o && /* @__PURE__ */ e("div", { className: "ss-global-error", children: o }),
|
|
1295
|
+
l && !d && /* @__PURE__ */ u(D, { children: [
|
|
1296
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
1297
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Customer" }),
|
|
1298
|
+
/* @__PURE__ */ e("input", { className: "ss-input", value: l.name || l.email, disabled: !0, readOnly: !0 })
|
|
1299
|
+
] }),
|
|
1300
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
1301
|
+
/* @__PURE__ */ e("label", { className: "ss-label", children: "Status" }),
|
|
1302
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("span", { className: `ss-badge ${is.active}`, children: "Active" }) })
|
|
1303
|
+
] }),
|
|
1304
|
+
/* @__PURE__ */ u("div", { className: "ss-btn-group", children: [
|
|
1305
|
+
r && /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-primary", onClick: r, children: "Change plan" }),
|
|
1306
|
+
c && /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: c, children: "Cancel subscription" })
|
|
1307
|
+
] })
|
|
1308
|
+
] })
|
|
1309
|
+
] }) });
|
|
1310
|
+
}
|
|
1311
|
+
const us = {
|
|
1312
|
+
paid: "ss-badge-active",
|
|
1313
|
+
open: "ss-badge-trialing",
|
|
1314
|
+
draft: "ss-badge-paused",
|
|
1315
|
+
void: "ss-badge-canceled",
|
|
1316
|
+
uncollectible: "ss-badge-past-due"
|
|
1317
|
+
};
|
|
1318
|
+
function ps(s) {
|
|
1319
|
+
return new Date(s).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
|
|
1320
|
+
}
|
|
1321
|
+
function gs(s) {
|
|
1322
|
+
return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", minimumFractionDigits: 2 }).format(s / 100);
|
|
1323
|
+
}
|
|
1324
|
+
function ms({ customerId: s, portalToken: n, appearance: r }) {
|
|
1325
|
+
const { appearance: c } = $(), { invoices: a, isLoading: i, error: l } = cs(s, n), d = r ?? c, o = [...a].sort((t, g) => new Date(g.createdAt).getTime() - new Date(t.createdAt).getTime());
|
|
1326
|
+
return /* @__PURE__ */ e(E, { appearance: d, children: /* @__PURE__ */ u("div", { className: "ss-card ss-card-wide", children: [
|
|
1327
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Invoices" }),
|
|
1328
|
+
i && /* @__PURE__ */ u("div", { className: "ss-loading", children: [
|
|
1329
|
+
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1330
|
+
" Loading..."
|
|
1331
|
+
] }),
|
|
1332
|
+
l && /* @__PURE__ */ e("div", { className: "ss-global-error", children: l }),
|
|
1333
|
+
!i && o.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No invoices yet." }),
|
|
1334
|
+
!i && o.length > 0 && /* @__PURE__ */ u("table", { className: "ss-table", children: [
|
|
1335
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ u("tr", { children: [
|
|
1336
|
+
/* @__PURE__ */ e("th", { className: "ss-th", children: "Date" }),
|
|
1337
|
+
/* @__PURE__ */ e("th", { className: "ss-th", children: "Amount" }),
|
|
1338
|
+
/* @__PURE__ */ e("th", { className: "ss-th", children: "Status" }),
|
|
1339
|
+
/* @__PURE__ */ e("th", { className: "ss-th", children: "PDF" })
|
|
1340
|
+
] }) }),
|
|
1341
|
+
/* @__PURE__ */ e("tbody", { children: o.map((t) => /* @__PURE__ */ u("tr", { className: "ss-tr", children: [
|
|
1342
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: ps(t.createdAt) }),
|
|
1343
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: gs(t.amountCents) }),
|
|
1344
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: /* @__PURE__ */ e("span", { className: `ss-badge ${us[t.status] || ""}`, children: t.status }) }),
|
|
1345
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: t.pdfUrl ? /* @__PURE__ */ e("a", { className: "ss-link", href: t.pdfUrl, target: "_blank", rel: "noopener noreferrer", children: "Download" }) : "—" })
|
|
1346
|
+
] }, t.id)) })
|
|
1347
|
+
] })
|
|
1348
|
+
] }) });
|
|
1349
|
+
}
|
|
1350
|
+
function bs({ customerId: s, limits: n, portalToken: r, appearance: c }) {
|
|
1351
|
+
const { appearance: a } = $(), { usage: i, isLoading: l, error: d } = ls(s, r);
|
|
1352
|
+
return /* @__PURE__ */ e(E, { appearance: c ?? a, children: /* @__PURE__ */ u("div", { className: "ss-card", children: [
|
|
1353
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Usage" }),
|
|
1354
|
+
l && /* @__PURE__ */ u("div", { className: "ss-loading", children: [
|
|
1355
|
+
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1356
|
+
" Loading..."
|
|
1357
|
+
] }),
|
|
1358
|
+
d && /* @__PURE__ */ e("div", { className: "ss-global-error", children: d }),
|
|
1359
|
+
!l && i.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No usage data." }),
|
|
1360
|
+
!l && i.map((t) => {
|
|
1361
|
+
const g = n == null ? void 0 : n[t.metric], p = g ? Math.min(100, t.total / g * 100) : null;
|
|
1362
|
+
return /* @__PURE__ */ u("div", { className: "ss-usage-item", children: [
|
|
1363
|
+
/* @__PURE__ */ u("div", { className: "ss-usage-header", children: [
|
|
1364
|
+
/* @__PURE__ */ e("span", { className: "ss-usage-metric", children: t.metric }),
|
|
1365
|
+
/* @__PURE__ */ u("span", { className: "ss-usage-value", children: [
|
|
1366
|
+
t.total.toLocaleString(),
|
|
1367
|
+
g ? ` / ${g.toLocaleString()}` : ""
|
|
1368
|
+
] })
|
|
1369
|
+
] }),
|
|
1370
|
+
p !== null && /* @__PURE__ */ e("div", { className: "ss-progress-bar", children: /* @__PURE__ */ e(
|
|
1371
|
+
"div",
|
|
1372
|
+
{
|
|
1373
|
+
className: `ss-progress-fill ${p > 90 ? "ss-progress-danger" : ""}`,
|
|
1374
|
+
style: { width: `${p}%` }
|
|
1375
|
+
}
|
|
1376
|
+
) })
|
|
1377
|
+
] }, t.metric);
|
|
1378
|
+
})
|
|
1379
|
+
] }) });
|
|
1380
|
+
}
|
|
1381
|
+
function Fs({
|
|
1382
|
+
customerId: s,
|
|
1383
|
+
portalToken: n,
|
|
1384
|
+
limits: r,
|
|
1385
|
+
onChangePlan: c,
|
|
1386
|
+
onCancel: a,
|
|
1387
|
+
appearance: i
|
|
1388
|
+
}) {
|
|
1389
|
+
const { appearance: l } = $(), d = i ?? l, [o, t] = m("subscription");
|
|
1390
|
+
return /* @__PURE__ */ e(E, { appearance: d, children: /* @__PURE__ */ u("div", { className: "ss-card ss-card-wide", children: [
|
|
1391
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Billing" }),
|
|
1392
|
+
/* @__PURE__ */ e("div", { className: "ss-tab-group", children: [
|
|
1393
|
+
{ id: "subscription", label: "Subscription" },
|
|
1394
|
+
{ id: "invoices", label: "Invoices" },
|
|
1395
|
+
{ id: "usage", label: "Usage" }
|
|
1396
|
+
].map((p) => /* @__PURE__ */ e(
|
|
1397
|
+
"button",
|
|
1398
|
+
{
|
|
1399
|
+
type: "button",
|
|
1400
|
+
className: `ss-tab ${o === p.id ? "ss-tab-active" : ""}`,
|
|
1401
|
+
onClick: () => t(p.id),
|
|
1402
|
+
children: p.label
|
|
1403
|
+
},
|
|
1404
|
+
p.id
|
|
1405
|
+
)) }),
|
|
1406
|
+
/* @__PURE__ */ u("div", { className: "ss-tab-content", children: [
|
|
1407
|
+
o === "subscription" && /* @__PURE__ */ e(
|
|
1408
|
+
ds,
|
|
1409
|
+
{
|
|
1410
|
+
customerId: s,
|
|
1411
|
+
portalToken: n,
|
|
1412
|
+
onChangePlan: c,
|
|
1413
|
+
onCancel: a
|
|
1414
|
+
}
|
|
1415
|
+
),
|
|
1416
|
+
o === "invoices" && /* @__PURE__ */ e(ms, { customerId: s, portalToken: n }),
|
|
1417
|
+
o === "usage" && /* @__PURE__ */ e(bs, { customerId: s, portalToken: n, limits: r })
|
|
1418
|
+
] })
|
|
1419
|
+
] }) });
|
|
1420
|
+
}
|
|
1421
|
+
function Ms({ customerId: s, portalToken: n, onApplied: r, appearance: c }) {
|
|
1422
|
+
const { appearance: a } = $(), i = A(n), l = c ?? a, [d, o] = m(""), [t, g] = m(!1), [p, h] = m(null), [f, x] = m(null), b = S(async (N) => {
|
|
1423
|
+
if (N.preventDefault(), !!d.trim()) {
|
|
1424
|
+
g(!0), h(null), x(null);
|
|
1425
|
+
try {
|
|
1426
|
+
const y = await i.applyCoupon(s, d.trim());
|
|
1427
|
+
x(`Coupon applied! ${y.discountType === "percent" ? `${y.amount}% off` : `$${(y.amount / 100).toFixed(2)} off`}`), o(""), r == null || r(y);
|
|
1428
|
+
} catch (y) {
|
|
1429
|
+
h(y instanceof Error ? y.message : "Invalid coupon code");
|
|
1430
|
+
} finally {
|
|
1431
|
+
g(!1);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
}, [i, s, d, r]);
|
|
1435
|
+
return /* @__PURE__ */ e(E, { appearance: l, children: /* @__PURE__ */ u("div", { className: "ss-card", children: [
|
|
1436
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Apply coupon" }),
|
|
1437
|
+
p && /* @__PURE__ */ e("div", { className: "ss-global-error", children: p }),
|
|
1438
|
+
f && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: f }),
|
|
1439
|
+
/* @__PURE__ */ u("form", { onSubmit: b, children: [
|
|
1440
|
+
/* @__PURE__ */ u("div", { className: "ss-field", children: [
|
|
1441
|
+
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-coupon-code", children: "Coupon code" }),
|
|
1442
|
+
/* @__PURE__ */ e(
|
|
1443
|
+
"input",
|
|
1444
|
+
{
|
|
1445
|
+
id: "ss-coupon-code",
|
|
1446
|
+
className: "ss-input",
|
|
1447
|
+
type: "text",
|
|
1448
|
+
placeholder: "Enter coupon code",
|
|
1449
|
+
value: d,
|
|
1450
|
+
onChange: (N) => o(N.target.value),
|
|
1451
|
+
required: !0
|
|
1452
|
+
}
|
|
1453
|
+
)
|
|
1454
|
+
] }),
|
|
1455
|
+
/* @__PURE__ */ u("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: t || !d.trim(), children: [
|
|
1456
|
+
t && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1457
|
+
"Apply"
|
|
1458
|
+
] })
|
|
1459
|
+
] })
|
|
1460
|
+
] }) });
|
|
1461
|
+
}
|
|
1462
|
+
function Os() {
|
|
1463
|
+
const { client: s } = $();
|
|
1464
|
+
return { report: s.report };
|
|
1465
|
+
}
|
|
1466
|
+
function J() {
|
|
1467
|
+
const { client: s } = $(), [n, r] = m(null), [c, a] = m(!1), [i, l] = m(null), d = S(async (o) => {
|
|
1468
|
+
a(!0), l(null);
|
|
1469
|
+
try {
|
|
1470
|
+
const t = await s.report.executeQuery(o);
|
|
1471
|
+
return r(t), t;
|
|
1472
|
+
} catch (t) {
|
|
1473
|
+
return l(t instanceof Error ? t.message : "Query failed"), null;
|
|
1474
|
+
} finally {
|
|
1475
|
+
a(!1);
|
|
1476
|
+
}
|
|
1477
|
+
}, [s]);
|
|
1478
|
+
return { result: n, execute: d, isLoading: c, error: i };
|
|
1479
|
+
}
|
|
1480
|
+
function hs(s) {
|
|
1481
|
+
const { client: n } = $(), [r, c] = m(null), [a, i] = m(!0), [l, d] = m(null), o = S(async () => {
|
|
1482
|
+
i(!0), d(null);
|
|
1483
|
+
try {
|
|
1484
|
+
const t = await n.report.listQueries(s);
|
|
1485
|
+
c(t);
|
|
1486
|
+
} catch (t) {
|
|
1487
|
+
d(t instanceof Error ? t.message : "Failed to load queries");
|
|
1488
|
+
} finally {
|
|
1489
|
+
i(!1);
|
|
1490
|
+
}
|
|
1491
|
+
}, [n, s]);
|
|
1492
|
+
return C(() => {
|
|
1493
|
+
o();
|
|
1494
|
+
}, [o]), { queries: (r == null ? void 0 : r.data) ?? [], meta: r == null ? void 0 : r.meta, isLoading: a, error: l, refresh: o };
|
|
1495
|
+
}
|
|
1496
|
+
function Us(s) {
|
|
1497
|
+
const { client: n } = $(), [r, c] = m(null), [a, i] = m(!0), [l, d] = m(null), o = S(async () => {
|
|
1498
|
+
i(!0), d(null);
|
|
1499
|
+
try {
|
|
1500
|
+
const t = await n.report.getDashboard(s);
|
|
1501
|
+
c(t);
|
|
1502
|
+
} catch (t) {
|
|
1503
|
+
d(t instanceof Error ? t.message : "Failed to load dashboard");
|
|
1504
|
+
} finally {
|
|
1505
|
+
i(!1);
|
|
1506
|
+
}
|
|
1507
|
+
}, [n, s]);
|
|
1508
|
+
return C(() => {
|
|
1509
|
+
o();
|
|
1510
|
+
}, [o]), { dashboard: r, isLoading: a, error: l, refresh: o };
|
|
1511
|
+
}
|
|
1512
|
+
function Rs(s, n, r = "https://api.saas-support.com/v1") {
|
|
1513
|
+
const c = B(() => {
|
|
1514
|
+
const p = new q(r, { type: "embedToken", token: s });
|
|
1515
|
+
return new R(p);
|
|
1516
|
+
}, [s, r]), [a, i] = m(null), [l, d] = m(!0), [o, t] = m(null), g = S(async () => {
|
|
1517
|
+
d(!0), t(null);
|
|
1518
|
+
try {
|
|
1519
|
+
const p = await c.getDashboard(n);
|
|
1520
|
+
i(p);
|
|
1521
|
+
} catch (p) {
|
|
1522
|
+
t(p instanceof Error ? p.message : "Failed to load dashboard");
|
|
1523
|
+
} finally {
|
|
1524
|
+
d(!1);
|
|
1525
|
+
}
|
|
1526
|
+
}, [c, n]);
|
|
1527
|
+
return C(() => {
|
|
1528
|
+
g();
|
|
1529
|
+
}, [g]), { dashboard: a, reportClient: c, isLoading: l, error: o, refresh: g };
|
|
1530
|
+
}
|
|
1531
|
+
function Hs({ onResult: s, mode: n = "both", placeholder: r, appearance: c }) {
|
|
1532
|
+
const { appearance: a } = $(), { execute: i, isLoading: l, error: d } = J(), o = c ?? a, [t, g] = m(""), [p, h] = m(n === "sql" ? "sql" : "nl"), f = S(async (x) => {
|
|
1533
|
+
if (x.preventDefault(), !t.trim()) return;
|
|
1534
|
+
const N = await i(p === "sql" ? { sql: t } : { naturalLanguage: t });
|
|
1535
|
+
N && (s == null || s(N));
|
|
1536
|
+
}, [t, p, i, s]);
|
|
1537
|
+
return /* @__PURE__ */ e(E, { appearance: o, children: /* @__PURE__ */ u("div", { className: "ss-card ss-card-wide", children: [
|
|
1538
|
+
n === "both" && /* @__PURE__ */ u("div", { className: "ss-tab-group ss-tab-group-sm", children: [
|
|
1539
|
+
/* @__PURE__ */ e(
|
|
1540
|
+
"button",
|
|
1541
|
+
{
|
|
1542
|
+
type: "button",
|
|
1543
|
+
className: `ss-tab ${p === "nl" ? "ss-tab-active" : ""}`,
|
|
1544
|
+
onClick: () => h("nl"),
|
|
1545
|
+
children: "Natural Language"
|
|
1546
|
+
}
|
|
1547
|
+
),
|
|
1548
|
+
/* @__PURE__ */ e(
|
|
1549
|
+
"button",
|
|
1550
|
+
{
|
|
1551
|
+
type: "button",
|
|
1552
|
+
className: `ss-tab ${p === "sql" ? "ss-tab-active" : ""}`,
|
|
1553
|
+
onClick: () => h("sql"),
|
|
1554
|
+
children: "SQL"
|
|
1555
|
+
}
|
|
1556
|
+
)
|
|
1557
|
+
] }),
|
|
1558
|
+
d && /* @__PURE__ */ e("div", { className: "ss-global-error", children: d }),
|
|
1559
|
+
/* @__PURE__ */ u("form", { onSubmit: f, children: [
|
|
1560
|
+
/* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
|
|
1561
|
+
"textarea",
|
|
1562
|
+
{
|
|
1563
|
+
className: "ss-input ss-query-textarea",
|
|
1564
|
+
placeholder: r ?? (p === "sql" ? "SELECT ..." : "Ask a question about your data..."),
|
|
1565
|
+
value: t,
|
|
1566
|
+
onChange: (x) => g(x.target.value),
|
|
1567
|
+
rows: 3
|
|
1568
|
+
}
|
|
1569
|
+
) }),
|
|
1570
|
+
/* @__PURE__ */ u("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l || !t.trim(), children: [
|
|
1571
|
+
l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1572
|
+
"Run query"
|
|
1573
|
+
] })
|
|
1574
|
+
] })
|
|
1575
|
+
] }) });
|
|
1576
|
+
}
|
|
1577
|
+
function fs({ columns: s, rows: n, sortable: r = !0, maxRows: c, appearance: a }) {
|
|
1578
|
+
const { appearance: i } = $(), l = a ?? i, [d, o] = m(null), [t, g] = m("asc"), p = B(() => d ? [...n].sort((b, N) => {
|
|
1579
|
+
const y = b[d], v = N[d];
|
|
1580
|
+
if (y == null && v == null) return 0;
|
|
1581
|
+
if (y == null) return 1;
|
|
1582
|
+
if (v == null) return -1;
|
|
1583
|
+
if (typeof y == "number" && typeof v == "number")
|
|
1584
|
+
return t === "asc" ? y - v : v - y;
|
|
1585
|
+
const w = String(y), k = String(v);
|
|
1586
|
+
return t === "asc" ? w.localeCompare(k) : k.localeCompare(w);
|
|
1587
|
+
}) : n, [n, d, t]), h = c ? p.slice(0, c) : p, f = (b) => {
|
|
1588
|
+
r && (d === b ? g((N) => N === "asc" ? "desc" : "asc") : (o(b), g("asc")));
|
|
1589
|
+
};
|
|
1590
|
+
function x(b) {
|
|
1591
|
+
return b == null ? "" : typeof b == "object" ? JSON.stringify(b) : String(b);
|
|
1592
|
+
}
|
|
1593
|
+
return /* @__PURE__ */ e(E, { appearance: l, children: /* @__PURE__ */ u("div", { className: "ss-table-container", children: [
|
|
1594
|
+
/* @__PURE__ */ u("table", { className: "ss-table", children: [
|
|
1595
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: s.map((b) => /* @__PURE__ */ u(
|
|
1596
|
+
"th",
|
|
1597
|
+
{
|
|
1598
|
+
className: `ss-th ${r ? "ss-th-sortable" : ""} ${d === b ? t === "asc" ? "ss-sorted-asc" : "ss-sorted-desc" : ""}`,
|
|
1599
|
+
onClick: () => f(b),
|
|
1600
|
+
children: [
|
|
1601
|
+
b,
|
|
1602
|
+
d === b && /* @__PURE__ */ e("span", { className: "ss-sort-indicator", children: t === "asc" ? " ▲" : " ▼" })
|
|
1603
|
+
]
|
|
1604
|
+
},
|
|
1605
|
+
b
|
|
1606
|
+
)) }) }),
|
|
1607
|
+
/* @__PURE__ */ e("tbody", { children: h.map((b, N) => /* @__PURE__ */ e("tr", { className: "ss-tr", children: s.map((y) => /* @__PURE__ */ e("td", { className: "ss-td", children: x(b[y]) }, y)) }, N)) })
|
|
1608
|
+
] }),
|
|
1609
|
+
c && n.length > c && /* @__PURE__ */ u("div", { className: "ss-table-footer", children: [
|
|
1610
|
+
"Showing ",
|
|
1611
|
+
c,
|
|
1612
|
+
" of ",
|
|
1613
|
+
n.length,
|
|
1614
|
+
" rows"
|
|
1615
|
+
] })
|
|
1616
|
+
] }) });
|
|
1617
|
+
}
|
|
1618
|
+
function ys(s, n = "#6366f1") {
|
|
1619
|
+
const r = parseInt(n.replace("#", "").slice(0, 2), 16), c = [];
|
|
1620
|
+
for (let a = 0; a < s; a++) {
|
|
1621
|
+
const i = (r + a * Math.floor(360 / Math.max(s, 1))) % 360;
|
|
1622
|
+
c.push(`hsl(${i}, 65%, 55%)`);
|
|
1623
|
+
}
|
|
1624
|
+
return c;
|
|
1625
|
+
}
|
|
1626
|
+
function xs({ labels: s, values: n, w: r, h: c, colors: a }) {
|
|
1627
|
+
const i = Math.max(...n, 1), l = 40, d = r - l * 2, o = c - l * 2, t = Math.max(1, d / s.length - 4);
|
|
1628
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
1629
|
+
/* @__PURE__ */ e("line", { x1: l, y1: c - l, x2: r - l, y2: c - l, stroke: "#ccc", strokeWidth: 1 }),
|
|
1630
|
+
n.map((g, p) => {
|
|
1631
|
+
const h = g / i * o, f = l + d / s.length * p + 2, x = c - l - h;
|
|
1632
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
1633
|
+
/* @__PURE__ */ e("rect", { x: f, y: x, width: t, height: h, fill: a[p % a.length], rx: 2 }),
|
|
1634
|
+
/* @__PURE__ */ e("text", { x: f + t / 2, y: c - l + 14, textAnchor: "middle", fontSize: 10, fill: "#666", children: s[p].length > 8 ? s[p].slice(0, 8) + "..." : s[p] })
|
|
1635
|
+
] }, p);
|
|
1636
|
+
})
|
|
1637
|
+
] });
|
|
1638
|
+
}
|
|
1639
|
+
function Ns({ labels: s, values: n, w: r, h: c, colors: a }) {
|
|
1640
|
+
const i = Math.max(...n, 1), l = 40, d = r - l * 2, o = c - l * 2, t = s.length > 1 ? d / (s.length - 1) : 0, g = n.map((p, h) => {
|
|
1641
|
+
const f = l + t * h, x = c - l - p / i * o;
|
|
1642
|
+
return `${f},${x}`;
|
|
1643
|
+
});
|
|
1644
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
1645
|
+
[0.25, 0.5, 0.75, 1].map((p) => {
|
|
1646
|
+
const h = c - l - p * o;
|
|
1647
|
+
return /* @__PURE__ */ e("line", { x1: l, y1: h, x2: r - l, y2: h, stroke: "#eee", strokeWidth: 1 }, p);
|
|
1648
|
+
}),
|
|
1649
|
+
/* @__PURE__ */ e("polyline", { points: g.join(" "), fill: "none", stroke: a[0], strokeWidth: 2 }),
|
|
1650
|
+
n.map((p, h) => {
|
|
1651
|
+
const f = l + t * h, x = c - l - p / i * o;
|
|
1652
|
+
return /* @__PURE__ */ e("circle", { cx: f, cy: x, r: 4, fill: a[0] }, h);
|
|
1653
|
+
})
|
|
1654
|
+
] });
|
|
1655
|
+
}
|
|
1656
|
+
function vs({ labels: s, values: n, w: r, h: c, colors: a }) {
|
|
1657
|
+
const i = n.reduce((h, f) => h + f, 0) || 1, l = r / 2, d = c / 2 - 20, o = Math.min(r, c) / 2 - 40, t = 2 * Math.PI * o;
|
|
1658
|
+
let g = 0;
|
|
1659
|
+
const p = n.map((h, f) => {
|
|
1660
|
+
const x = h / i, b = x * t, N = { dash: b, offset: g, color: a[f % a.length], label: s[f], pct: x };
|
|
1661
|
+
return g += b, N;
|
|
1662
|
+
});
|
|
1663
|
+
return /* @__PURE__ */ u("g", { children: [
|
|
1664
|
+
p.map((h, f) => /* @__PURE__ */ e(
|
|
1665
|
+
"circle",
|
|
1666
|
+
{
|
|
1667
|
+
cx: l,
|
|
1668
|
+
cy: d,
|
|
1669
|
+
r: o,
|
|
1670
|
+
fill: "none",
|
|
1671
|
+
stroke: h.color,
|
|
1672
|
+
strokeWidth: o * 0.6,
|
|
1673
|
+
strokeDasharray: `${h.dash} ${t - h.dash}`,
|
|
1674
|
+
strokeDashoffset: -h.offset,
|
|
1675
|
+
transform: `rotate(-90 ${l} ${d})`
|
|
1676
|
+
},
|
|
1677
|
+
f
|
|
1678
|
+
)),
|
|
1679
|
+
/* @__PURE__ */ e("g", { transform: `translate(${l - s.length * 30}, ${c - 20})`, children: p.slice(0, 6).map((h, f) => /* @__PURE__ */ u("g", { transform: `translate(${f * 60}, 0)`, children: [
|
|
1680
|
+
/* @__PURE__ */ e("rect", { width: 10, height: 10, fill: h.color, rx: 2 }),
|
|
1681
|
+
/* @__PURE__ */ e("text", { x: 14, y: 9, fontSize: 9, fill: "#666", children: h.label.length > 6 ? h.label.slice(0, 6) + ".." : h.label })
|
|
1682
|
+
] }, f)) })
|
|
1683
|
+
] });
|
|
1684
|
+
}
|
|
1685
|
+
function ws({ type: s, data: n, title: r, width: c = 400, height: a = 300, appearance: i }) {
|
|
1686
|
+
const { appearance: l } = $(), d = i ?? l, o = B(() => ys(n.labels.length), [n.labels.length]);
|
|
1687
|
+
return /* @__PURE__ */ e(E, { appearance: d, children: /* @__PURE__ */ u("div", { className: "ss-chart-container", children: [
|
|
1688
|
+
r && /* @__PURE__ */ e("h3", { className: "ss-chart-title", children: r }),
|
|
1689
|
+
/* @__PURE__ */ u("svg", { viewBox: `0 0 ${c} ${a}`, width: "100%", style: { maxWidth: c }, children: [
|
|
1690
|
+
s === "bar" && /* @__PURE__ */ e(xs, { labels: n.labels, values: n.values, w: c, h: a, colors: o }),
|
|
1691
|
+
s === "line" && /* @__PURE__ */ e(Ns, { labels: n.labels, values: n.values, w: c, h: a, colors: o }),
|
|
1692
|
+
s === "pie" && /* @__PURE__ */ e(vs, { labels: n.labels, values: n.values, w: c, h: a, colors: o })
|
|
1693
|
+
] })
|
|
1694
|
+
] }) });
|
|
1695
|
+
}
|
|
1696
|
+
function Ws({ dashboardId: s, embedToken: n, baseUrl: r, refreshInterval: c, appearance: a }) {
|
|
1697
|
+
const i = $(), l = a ?? (i == null ? void 0 : i.appearance), d = B(() => {
|
|
1698
|
+
if (n) {
|
|
1699
|
+
const y = r ?? "https://api.saas-support.com/v1", v = new q(y, { type: "embedToken", token: n });
|
|
1700
|
+
return new R(v);
|
|
1701
|
+
}
|
|
1702
|
+
return i.client.report;
|
|
1703
|
+
}, [n, r, i]), [o, t] = m([]), [g, p] = m({}), [h, f] = m(!0), [x, b] = m(null), N = S(async () => {
|
|
1704
|
+
f(!0), b(null);
|
|
1705
|
+
try {
|
|
1706
|
+
const y = await d.getDashboard(s), v = JSON.parse(y.layoutJson || "[]");
|
|
1707
|
+
t(v);
|
|
1708
|
+
const w = {};
|
|
1709
|
+
for (const k of v)
|
|
1710
|
+
try {
|
|
1711
|
+
const T = await d.listQueries({ search: k.queryId, perPage: 1 });
|
|
1712
|
+
if (T.data.length > 0 && T.data[0].generatedSql) {
|
|
1713
|
+
const P = await d.executeQuery({ sql: T.data[0].generatedSql });
|
|
1714
|
+
w[k.queryId] = P;
|
|
1715
|
+
}
|
|
1716
|
+
} catch {
|
|
1717
|
+
}
|
|
1718
|
+
p(w);
|
|
1719
|
+
} catch (y) {
|
|
1720
|
+
b(y instanceof Error ? y.message : "Failed to load dashboard");
|
|
1721
|
+
} finally {
|
|
1722
|
+
f(!1);
|
|
1723
|
+
}
|
|
1724
|
+
}, [d, s]);
|
|
1725
|
+
return C(() => {
|
|
1726
|
+
N();
|
|
1727
|
+
}, [N]), C(() => {
|
|
1728
|
+
if (!c || c <= 0) return;
|
|
1729
|
+
const y = setInterval(N, c * 1e3);
|
|
1730
|
+
return () => clearInterval(y);
|
|
1731
|
+
}, [c, N]), /* @__PURE__ */ e(E, { appearance: l, children: /* @__PURE__ */ u("div", { className: "ss-dashboard-grid", children: [
|
|
1732
|
+
h && /* @__PURE__ */ u("div", { className: "ss-loading", children: [
|
|
1733
|
+
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1734
|
+
" Loading dashboard..."
|
|
1735
|
+
] }),
|
|
1736
|
+
x && /* @__PURE__ */ e("div", { className: "ss-global-error", children: x }),
|
|
1737
|
+
!h && o.map((y, v) => {
|
|
1738
|
+
const w = g[y.queryId];
|
|
1739
|
+
if (!w) return null;
|
|
1740
|
+
const k = w.columns.length >= 2 ? {
|
|
1741
|
+
labels: w.rows.map((T) => String(T[w.columns[0]] ?? "")),
|
|
1742
|
+
values: w.rows.map((T) => Number(T[w.columns[1]] ?? 0))
|
|
1743
|
+
} : { labels: [], values: [] };
|
|
1744
|
+
return /* @__PURE__ */ u("div", { className: "ss-widget", children: [
|
|
1745
|
+
y.title && /* @__PURE__ */ e("h4", { className: "ss-widget-header", children: y.title }),
|
|
1746
|
+
y.chartType === "table" ? /* @__PURE__ */ e(fs, { columns: w.columns, rows: w.rows, maxRows: 50 }) : /* @__PURE__ */ e(
|
|
1747
|
+
ws,
|
|
1748
|
+
{
|
|
1749
|
+
type: y.chartType || "bar",
|
|
1750
|
+
data: k,
|
|
1751
|
+
width: y.w,
|
|
1752
|
+
height: y.h
|
|
1753
|
+
}
|
|
1754
|
+
)
|
|
1755
|
+
] }, v);
|
|
1756
|
+
})
|
|
1757
|
+
] }) });
|
|
1758
|
+
}
|
|
1759
|
+
function Ss(s) {
|
|
1760
|
+
return new Date(s).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
|
|
1761
|
+
}
|
|
1762
|
+
function _s({ onSelectQuery: s, onRunQuery: n, appearance: r }) {
|
|
1763
|
+
const { appearance: c } = $(), { queries: a, isLoading: i, error: l } = hs(), { execute: d, isLoading: o } = J(), t = r ?? c, g = S(async (p) => {
|
|
1764
|
+
if (!p.generatedSql) return;
|
|
1765
|
+
const h = await d({ sql: p.generatedSql });
|
|
1766
|
+
h && (n == null || n(h));
|
|
1767
|
+
}, [d, n]);
|
|
1768
|
+
return /* @__PURE__ */ e(E, { appearance: t, children: /* @__PURE__ */ u("div", { className: "ss-card ss-card-wide", children: [
|
|
1769
|
+
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Saved Queries" }),
|
|
1770
|
+
i && /* @__PURE__ */ u("div", { className: "ss-loading", children: [
|
|
1771
|
+
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1772
|
+
" Loading..."
|
|
1773
|
+
] }),
|
|
1774
|
+
l && /* @__PURE__ */ e("div", { className: "ss-global-error", children: l }),
|
|
1775
|
+
!i && a.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No saved queries." }),
|
|
1776
|
+
!i && a.map((p) => /* @__PURE__ */ u(
|
|
1777
|
+
"div",
|
|
1778
|
+
{
|
|
1779
|
+
className: "ss-saved-query-card",
|
|
1780
|
+
onClick: () => s == null ? void 0 : s(p),
|
|
1781
|
+
children: [
|
|
1782
|
+
/* @__PURE__ */ u("div", { className: "ss-saved-query-header", children: [
|
|
1783
|
+
/* @__PURE__ */ e("span", { className: "ss-saved-query-name", children: p.name }),
|
|
1784
|
+
p.chartType && /* @__PURE__ */ e("span", { className: "ss-badge", children: p.chartType })
|
|
1785
|
+
] }),
|
|
1786
|
+
p.naturalLanguage && /* @__PURE__ */ e("p", { className: "ss-saved-query-desc", children: p.naturalLanguage }),
|
|
1787
|
+
/* @__PURE__ */ u("div", { className: "ss-saved-query-footer", children: [
|
|
1788
|
+
/* @__PURE__ */ e("span", { className: "ss-saved-query-date", children: Ss(p.createdAt) }),
|
|
1789
|
+
/* @__PURE__ */ e(
|
|
1790
|
+
"button",
|
|
1791
|
+
{
|
|
1792
|
+
type: "button",
|
|
1793
|
+
className: "ss-btn ss-btn-sm ss-btn-primary",
|
|
1794
|
+
disabled: o || !p.generatedSql,
|
|
1795
|
+
onClick: (h) => {
|
|
1796
|
+
h.stopPropagation(), g(p);
|
|
1797
|
+
},
|
|
1798
|
+
children: o ? /* @__PURE__ */ e("span", { className: "ss-spinner" }) : "Run"
|
|
1799
|
+
}
|
|
1800
|
+
)
|
|
1801
|
+
] })
|
|
1802
|
+
]
|
|
1803
|
+
},
|
|
1804
|
+
p.id
|
|
1805
|
+
))
|
|
1806
|
+
] }) });
|
|
1807
|
+
}
|
|
1808
|
+
function js({ embedToken: s, dashboardId: n, baseUrl: r = "https://api.saas-support.com/v1", refreshInterval: c, appearance: a }) {
|
|
1809
|
+
const i = B(() => {
|
|
1810
|
+
const b = new q(r, { type: "embedToken", token: s });
|
|
1811
|
+
return new R(b);
|
|
1812
|
+
}, [s, r]), [l, d] = m([]), [o, t] = m(!0), [g, p] = m(null), h = B(() => M(a), [a]), f = B(() => O(h), [h]), x = S(async () => {
|
|
1813
|
+
t(!0), p(null);
|
|
1814
|
+
try {
|
|
1815
|
+
const b = await i.getDashboard(n), N = JSON.parse(b.layoutJson || "[]"), y = await Promise.all(
|
|
1816
|
+
N.map(async (v) => {
|
|
1817
|
+
try {
|
|
1818
|
+
const w = await i.listQueries({ search: v.queryId, perPage: 1 });
|
|
1819
|
+
if (w.data.length > 0 && w.data[0].generatedSql) {
|
|
1820
|
+
const k = await i.executeQuery({ sql: w.data[0].generatedSql });
|
|
1821
|
+
return { ...v, result: k };
|
|
1822
|
+
}
|
|
1823
|
+
} catch {
|
|
1824
|
+
}
|
|
1825
|
+
return v;
|
|
1826
|
+
})
|
|
1827
|
+
);
|
|
1828
|
+
d(y);
|
|
1829
|
+
} catch (b) {
|
|
1830
|
+
p(b instanceof Error ? b.message : "Failed to load dashboard");
|
|
1831
|
+
} finally {
|
|
1832
|
+
t(!1);
|
|
1833
|
+
}
|
|
1834
|
+
}, [i, n]);
|
|
1835
|
+
return C(() => {
|
|
1836
|
+
x();
|
|
1837
|
+
}, [x]), C(() => {
|
|
1838
|
+
if (!c || c <= 0) return;
|
|
1839
|
+
const b = setInterval(x, c * 1e3);
|
|
1840
|
+
return () => clearInterval(b);
|
|
1841
|
+
}, [c, x]), /* @__PURE__ */ e(
|
|
1842
|
+
"div",
|
|
1843
|
+
{
|
|
1844
|
+
ref: (b) => {
|
|
1845
|
+
if (!b || b.shadowRoot) return;
|
|
1846
|
+
const N = b.attachShadow({ mode: "open" }), y = document.createElement("style");
|
|
1847
|
+
y.textContent = f, N.appendChild(y);
|
|
1848
|
+
const v = document.createElement("div");
|
|
1849
|
+
N.appendChild(v);
|
|
1850
|
+
},
|
|
1851
|
+
style: { display: "contents" },
|
|
1852
|
+
children: /* @__PURE__ */ u("div", { className: "ss-dashboard-grid", children: [
|
|
1853
|
+
o && /* @__PURE__ */ e("div", { className: "ss-loading", children: "Loading dashboard..." }),
|
|
1854
|
+
g && /* @__PURE__ */ e("div", { className: "ss-global-error", children: g }),
|
|
1855
|
+
!o && l.map((b, N) => {
|
|
1856
|
+
if (!b.result) return null;
|
|
1857
|
+
const { columns: y, rows: v } = b.result;
|
|
1858
|
+
return /* @__PURE__ */ u("div", { className: "ss-widget", children: [
|
|
1859
|
+
b.title && /* @__PURE__ */ e("h4", { className: "ss-widget-header", children: b.title }),
|
|
1860
|
+
/* @__PURE__ */ u("table", { className: "ss-table", children: [
|
|
1861
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: y.map((w) => /* @__PURE__ */ e("th", { className: "ss-th", children: w }, w)) }) }),
|
|
1862
|
+
/* @__PURE__ */ e("tbody", { children: v.slice(0, 50).map((w, k) => /* @__PURE__ */ e("tr", { className: "ss-tr", children: y.map((T) => /* @__PURE__ */ e("td", { className: "ss-td", children: String(w[T] ?? "") }, T)) }, k)) })
|
|
1863
|
+
] })
|
|
1864
|
+
] }, N);
|
|
1865
|
+
})
|
|
1866
|
+
] })
|
|
1867
|
+
}
|
|
1868
|
+
);
|
|
1869
|
+
}
|
|
1870
|
+
export {
|
|
1871
|
+
ws as Chart,
|
|
1872
|
+
Ms as CouponInput,
|
|
1873
|
+
Ws as DashboardView,
|
|
1874
|
+
fs as DataTable,
|
|
1875
|
+
ms as InvoiceHistory,
|
|
1876
|
+
Ds as OrgSwitcher,
|
|
1877
|
+
Fs as PaymentPortal,
|
|
1878
|
+
qs as PricingTable,
|
|
1879
|
+
Hs as QueryInput,
|
|
1880
|
+
js as ReportEmbed,
|
|
1881
|
+
H as SaaSContext,
|
|
1882
|
+
Qs as SaaSError,
|
|
1883
|
+
Ts as SaaSProvider,
|
|
1884
|
+
Y as SaaSSupport,
|
|
1885
|
+
_s as SavedQueryList,
|
|
1886
|
+
Ls as SignIn,
|
|
1887
|
+
Bs as SignUp,
|
|
1888
|
+
ds as SubscriptionStatus,
|
|
1889
|
+
bs as UsageDisplay,
|
|
1890
|
+
Ps as UserButton,
|
|
1891
|
+
zs as UserProfile,
|
|
1892
|
+
K as isMfaRequired,
|
|
1893
|
+
W as useAuth,
|
|
1894
|
+
As as useBilling,
|
|
1895
|
+
Us as useDashboard,
|
|
1896
|
+
Rs as useEmbedDashboard,
|
|
1897
|
+
cs as useInvoices,
|
|
1898
|
+
as as useOrg,
|
|
1899
|
+
J as useQuery,
|
|
1900
|
+
Os as useReport,
|
|
1901
|
+
$ as useSaaSContext,
|
|
1902
|
+
hs as useSavedQueries,
|
|
1903
|
+
_ as useSignIn,
|
|
1904
|
+
ns as useSignUp,
|
|
1905
|
+
ts as useSubscription,
|
|
1906
|
+
ls as useUsage,
|
|
1907
|
+
Is as useUser
|
|
1908
|
+
};
|