@saas-support/react 0.3.2 → 0.5.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/dist/react.js CHANGED
@@ -1,33 +1,33 @@
1
- import { jsx as e, jsxs as i, Fragment as D } from "react/jsx-runtime";
2
- import { createContext as Y, useContext as K, useState as g, useEffect as L, useRef as R, useCallback as S, useMemo as A } from "react";
3
- import { SaaSSupport as X, isMfaRequired as Z, BillingClient as ss, Transport as F, ReportClient as W } from "./index.js";
4
- import { SaaSError as Xs } from "./index.js";
5
- import { createPortal as es } from "react-dom";
6
- const H = Y(null);
7
- function k() {
8
- const s = K(H);
9
- if (!s)
1
+ import { jsx as s, jsxs as n, Fragment as G } from "react/jsx-runtime";
2
+ import { createContext as ge, useContext as he, useState as m, useEffect as U, useRef as j, useCallback as N, useMemo as _ } from "react";
3
+ import { SaaSSupport as fe, isMfaRequired as be, BillingClient as ye, Transport as J, ReportClient as K } from "./index.js";
4
+ import { SaaSError as bs } from "./index.js";
5
+ import { createPortal as ve } from "react-dom";
6
+ const se = ge(null);
7
+ function L() {
8
+ const e = he(se);
9
+ if (!e)
10
10
  throw new Error("useSaaSContext must be used within a <SaaSProvider>");
11
- return s;
11
+ return e;
12
12
  }
13
- function Bs({ publishableKey: s, apiKey: a, baseUrl: r, appearance: c, children: t }) {
14
- const [d] = g(() => new X({ publishableKey: s, apiKey: a, baseUrl: r })), [l, u] = g(null), [o, n] = g(!1), [m, p] = g(null);
15
- return L(() => {
16
- let h = !1;
17
- d.load().then(async () => {
18
- if (h) return;
19
- const y = await d.auth.getUser(), b = await d.auth.getSettings();
20
- u(y), p(b), n(!0);
13
+ function Ze({ publishableKey: e, apiKey: a, baseUrl: r, appearance: o, children: t }) {
14
+ const [u] = m(() => new fe({ publishableKey: e, apiKey: a, baseUrl: r })), [i, c] = m(null), [d, l] = m(!1), [g, p] = m(null);
15
+ return U(() => {
16
+ let f = !1;
17
+ u.load().then(async () => {
18
+ if (f) return;
19
+ const k = await u.auth.getUser(), v = await u.auth.getSettings();
20
+ c(k), p(v), l(!0);
21
21
  });
22
- const v = d.auth.onAuthStateChange((y) => {
23
- h || u(y);
22
+ const b = u.auth.onAuthStateChange((k) => {
23
+ f || c(k);
24
24
  });
25
25
  return () => {
26
- h = !0, v(), d.destroy();
26
+ f = !0, b(), u.destroy();
27
27
  };
28
- }, [d]), /* @__PURE__ */ e(H.Provider, { value: { client: d, user: l, isLoaded: o, appearance: c, settings: m }, children: t });
28
+ }, [u]), /* @__PURE__ */ s(se.Provider, { value: { client: u, user: i, isLoaded: d, appearance: o, settings: g }, children: t });
29
29
  }
30
- const rs = {
30
+ const xe = {
31
31
  colorPrimary: "#6366f1",
32
32
  colorPrimaryHover: "#4f46e5",
33
33
  colorBackground: "#ffffff",
@@ -40,7 +40,7 @@ const rs = {
40
40
  colorWarning: "#f59e0b",
41
41
  fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
42
42
  borderRadius: "8px"
43
- }, as = {
43
+ }, we = {
44
44
  colorPrimary: "#818cf8",
45
45
  colorPrimaryHover: "#6366f1",
46
46
  colorBackground: "#1e1e2e",
@@ -54,11 +54,11 @@ const rs = {
54
54
  fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
55
55
  borderRadius: "8px"
56
56
  };
57
- function U(s) {
58
- const a = (s == null ? void 0 : s.baseTheme) === "dark" ? as : rs, r = s == null ? void 0 : s.variables;
57
+ function Z(e) {
58
+ const a = (e == null ? void 0 : e.baseTheme) === "dark" ? we : xe, r = e == null ? void 0 : e.variables;
59
59
  return {
60
60
  colorPrimary: (r == null ? void 0 : r.colorPrimary) ?? a.colorPrimary,
61
- colorPrimaryHover: r != null && r.colorPrimary ? ns(r.colorPrimary, 10) : a.colorPrimaryHover,
61
+ colorPrimaryHover: r != null && r.colorPrimary ? Ne(r.colorPrimary, 10) : a.colorPrimaryHover,
62
62
  colorBackground: (r == null ? void 0 : r.colorBackground) ?? a.colorBackground,
63
63
  colorText: (r == null ? void 0 : r.colorText) ?? a.colorText,
64
64
  colorTextSecondary: a.colorTextSecondary,
@@ -71,16 +71,16 @@ function U(s) {
71
71
  borderRadius: (r == null ? void 0 : r.borderRadius) ?? a.borderRadius
72
72
  };
73
73
  }
74
- function ns(s, a) {
75
- const r = parseInt(s.replace("#", ""), 16), c = Math.max(0, (r >> 16) - Math.round(2.55 * a)), t = Math.max(0, (r >> 8 & 255) - Math.round(2.55 * a)), d = Math.max(0, (r & 255) - Math.round(2.55 * a));
76
- return `#${(c << 16 | t << 8 | d).toString(16).padStart(6, "0")}`;
74
+ function Ne(e, a) {
75
+ const r = parseInt(e.replace("#", ""), 16), o = Math.max(0, (r >> 16) - Math.round(2.55 * a)), t = Math.max(0, (r >> 8 & 255) - Math.round(2.55 * a)), u = Math.max(0, (r & 255) - Math.round(2.55 * a));
76
+ return `#${(o << 16 | t << 8 | u).toString(16).padStart(6, "0")}`;
77
77
  }
78
- function O(s) {
78
+ function X(e) {
79
79
  return `
80
80
  :host {
81
81
  all: initial;
82
- font-family: ${s.fontFamily};
83
- color: ${s.colorText};
82
+ font-family: ${e.fontFamily};
83
+ color: ${e.colorText};
84
84
  line-height: 1.5;
85
85
  -webkit-font-smoothing: antialiased;
86
86
  }
@@ -88,13 +88,13 @@ function O(s) {
88
88
  * { box-sizing: border-box; margin: 0; padding: 0; }
89
89
 
90
90
  .ss-card {
91
- background: ${s.colorBackground};
92
- border-radius: ${s.borderRadius};
91
+ background: ${e.colorBackground};
92
+ border-radius: ${e.borderRadius};
93
93
  padding: 32px;
94
94
  width: 100%;
95
- max-width: 400px;
95
+ max-width: 480px;
96
96
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
97
- border: 1px solid ${s.colorInputBorder};
97
+ border: 1px solid ${e.colorInputBorder};
98
98
  }
99
99
 
100
100
  .ss-card-wide { max-width: 640px; }
@@ -102,14 +102,14 @@ function O(s) {
102
102
  .ss-title {
103
103
  font-size: 22px;
104
104
  font-weight: 700;
105
- color: ${s.colorText};
105
+ color: ${e.colorText};
106
106
  text-align: center;
107
107
  margin-bottom: 24px;
108
108
  }
109
109
 
110
110
  .ss-subtitle {
111
111
  font-size: 14px;
112
- color: ${s.colorTextSecondary};
112
+ color: ${e.colorTextSecondary};
113
113
  text-align: center;
114
114
  margin-top: -16px;
115
115
  margin-bottom: 24px;
@@ -121,7 +121,7 @@ function O(s) {
121
121
  display: block;
122
122
  font-size: 14px;
123
123
  font-weight: 500;
124
- color: ${s.colorText};
124
+ color: ${e.colorText};
125
125
  margin-bottom: 6px;
126
126
  }
127
127
 
@@ -130,20 +130,20 @@ function O(s) {
130
130
  padding: 10px 12px;
131
131
  font-size: 14px;
132
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};
133
+ border: 1px solid ${e.colorInputBorder};
134
+ border-radius: calc(${e.borderRadius} - 2px);
135
+ background: ${e.colorInputBackground};
136
+ color: ${e.colorText};
137
137
  outline: none;
138
138
  transition: border-color 0.15s;
139
139
  }
140
140
 
141
141
  .ss-input:focus {
142
- border-color: ${s.colorPrimary};
143
- box-shadow: 0 0 0 3px ${s.colorPrimary}22;
142
+ border-color: ${e.colorPrimary};
143
+ box-shadow: 0 0 0 3px ${e.colorPrimary}22;
144
144
  }
145
145
 
146
- .ss-input.ss-input-error { border-color: ${s.colorError}; }
146
+ .ss-input.ss-input-error { border-color: ${e.colorError}; }
147
147
 
148
148
  .ss-query-textarea {
149
149
  resize: vertical;
@@ -153,16 +153,16 @@ function O(s) {
153
153
 
154
154
  .ss-error {
155
155
  font-size: 13px;
156
- color: ${s.colorError};
156
+ color: ${e.colorError};
157
157
  margin-top: 4px;
158
158
  }
159
159
 
160
160
  .ss-global-error {
161
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);
162
+ color: ${e.colorError};
163
+ background: ${e.colorError}11;
164
+ border: 1px solid ${e.colorError}33;
165
+ border-radius: calc(${e.borderRadius} - 2px);
166
166
  padding: 10px 12px;
167
167
  margin-bottom: 16px;
168
168
  text-align: center;
@@ -170,10 +170,10 @@ function O(s) {
170
170
 
171
171
  .ss-success-msg {
172
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);
173
+ color: ${e.colorSuccess};
174
+ background: ${e.colorSuccess}11;
175
+ border: 1px solid ${e.colorSuccess}33;
176
+ border-radius: calc(${e.borderRadius} - 2px);
177
177
  padding: 10px 12px;
178
178
  margin-bottom: 16px;
179
179
  text-align: center;
@@ -182,14 +182,14 @@ function O(s) {
182
182
  .ss-loading {
183
183
  text-align: center;
184
184
  padding: 24px;
185
- color: ${s.colorTextSecondary};
185
+ color: ${e.colorTextSecondary};
186
186
  font-size: 14px;
187
187
  }
188
188
 
189
189
  .ss-empty {
190
190
  text-align: center;
191
191
  padding: 24px;
192
- color: ${s.colorTextSecondary};
192
+ color: ${e.colorTextSecondary};
193
193
  font-size: 14px;
194
194
  }
195
195
 
@@ -202,7 +202,7 @@ function O(s) {
202
202
  font-weight: 600;
203
203
  font-family: inherit;
204
204
  border: none;
205
- border-radius: calc(${s.borderRadius} - 2px);
205
+ border-radius: calc(${e.borderRadius} - 2px);
206
206
  cursor: pointer;
207
207
  transition: background 0.15s, opacity 0.15s;
208
208
  }
@@ -210,23 +210,23 @@ function O(s) {
210
210
  .ss-btn:disabled { opacity: 0.6; cursor: not-allowed; }
211
211
 
212
212
  .ss-btn-primary {
213
- background: ${s.colorPrimary};
213
+ background: ${e.colorPrimary};
214
214
  color: #fff;
215
215
  }
216
216
 
217
- .ss-btn-primary:hover:not(:disabled) { background: ${s.colorPrimaryHover}; }
217
+ .ss-btn-primary:hover:not(:disabled) { background: ${e.colorPrimaryHover}; }
218
218
 
219
219
  .ss-btn-danger {
220
- background: ${s.colorError};
220
+ background: ${e.colorError};
221
221
  color: #fff;
222
222
  }
223
223
 
224
224
  .ss-btn-danger:hover:not(:disabled) { opacity: 0.9; }
225
225
 
226
226
  .ss-btn-current {
227
- background: ${s.colorInputBackground};
228
- color: ${s.colorTextSecondary};
229
- border: 1px solid ${s.colorInputBorder};
227
+ background: ${e.colorInputBackground};
228
+ color: ${e.colorTextSecondary};
229
+ border: 1px solid ${e.colorInputBorder};
230
230
  }
231
231
 
232
232
  .ss-btn-sm {
@@ -247,13 +247,13 @@ function O(s) {
247
247
  display: flex;
248
248
  align-items: center;
249
249
  gap: 8px;
250
- background: ${s.colorInputBackground};
251
- border: 1px solid ${s.colorInputBorder};
252
- color: ${s.colorText};
250
+ background: ${e.colorInputBackground};
251
+ border: 1px solid ${e.colorInputBorder};
252
+ color: ${e.colorText};
253
253
  padding: 8px 12px;
254
254
  font-size: 14px;
255
255
  font-family: inherit;
256
- border-radius: calc(${s.borderRadius} - 2px);
256
+ border-radius: calc(${e.borderRadius} - 2px);
257
257
  cursor: pointer;
258
258
  width: auto;
259
259
  }
@@ -270,16 +270,16 @@ function O(s) {
270
270
  font-size: 14px;
271
271
  font-weight: 500;
272
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};
273
+ border: 1px solid ${e.colorInputBorder};
274
+ border-radius: calc(${e.borderRadius} - 2px);
275
+ background: ${e.colorInputBackground};
276
+ color: ${e.colorText};
277
277
  cursor: pointer;
278
278
  transition: background 0.15s;
279
279
  margin-bottom: 8px;
280
280
  }
281
281
 
282
- .ss-btn-social:hover:not(:disabled) { background: ${s.colorInputBorder}; }
282
+ .ss-btn-social:hover:not(:disabled) { background: ${e.colorInputBorder}; }
283
283
  .ss-btn-social:disabled { opacity: 0.6; cursor: not-allowed; }
284
284
  .ss-btn-social svg { width: 18px; height: 18px; flex-shrink: 0; }
285
285
 
@@ -288,7 +288,7 @@ function O(s) {
288
288
  align-items: center;
289
289
  gap: 12px;
290
290
  margin: 20px 0;
291
- color: ${s.colorTextSecondary};
291
+ color: ${e.colorTextSecondary};
292
292
  font-size: 13px;
293
293
  }
294
294
 
@@ -297,18 +297,18 @@ function O(s) {
297
297
  content: '';
298
298
  flex: 1;
299
299
  height: 1px;
300
- background: ${s.colorInputBorder};
300
+ background: ${e.colorInputBorder};
301
301
  }
302
302
 
303
303
  .ss-footer {
304
304
  text-align: center;
305
305
  margin-top: 20px;
306
306
  font-size: 14px;
307
- color: ${s.colorTextSecondary};
307
+ color: ${e.colorTextSecondary};
308
308
  }
309
309
 
310
310
  .ss-link {
311
- color: ${s.colorPrimary};
311
+ color: ${e.colorPrimary};
312
312
  text-decoration: none;
313
313
  cursor: pointer;
314
314
  font-weight: 500;
@@ -338,7 +338,7 @@ function O(s) {
338
338
  width: 36px;
339
339
  height: 36px;
340
340
  border-radius: 50%;
341
- background: ${s.colorPrimary};
341
+ background: ${e.colorPrimary};
342
342
  color: #fff;
343
343
  display: flex;
344
344
  align-items: center;
@@ -351,15 +351,15 @@ function O(s) {
351
351
  transition: box-shadow 0.15s;
352
352
  }
353
353
 
354
- .ss-avatar:hover { box-shadow: 0 0 0 3px ${s.colorPrimary}33; }
354
+ .ss-avatar:hover { box-shadow: 0 0 0 3px ${e.colorPrimary}33; }
355
355
 
356
356
  .ss-dropdown {
357
357
  position: absolute;
358
358
  top: calc(100% + 8px);
359
359
  right: 0;
360
- background: ${s.colorBackground};
361
- border: 1px solid ${s.colorInputBorder};
362
- border-radius: ${s.borderRadius};
360
+ background: ${e.colorBackground};
361
+ border: 1px solid ${e.colorInputBorder};
362
+ border-radius: ${e.borderRadius};
363
363
  padding: 8px 0;
364
364
  min-width: 200px;
365
365
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
@@ -370,13 +370,13 @@ function O(s) {
370
370
 
371
371
  .ss-dropdown-header {
372
372
  padding: 8px 16px 12px;
373
- border-bottom: 1px solid ${s.colorInputBorder};
373
+ border-bottom: 1px solid ${e.colorInputBorder};
374
374
  margin-bottom: 4px;
375
375
  }
376
376
 
377
377
  .ss-dropdown-email {
378
378
  font-size: 13px;
379
- color: ${s.colorTextSecondary};
379
+ color: ${e.colorTextSecondary};
380
380
  word-break: break-all;
381
381
  }
382
382
 
@@ -386,7 +386,7 @@ function O(s) {
386
386
  padding: 8px 16px;
387
387
  font-size: 14px;
388
388
  font-family: inherit;
389
- color: ${s.colorText};
389
+ color: ${e.colorText};
390
390
  background: none;
391
391
  border: none;
392
392
  text-align: left;
@@ -394,9 +394,29 @@ function O(s) {
394
394
  transition: background 0.1s;
395
395
  }
396
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}; }
397
+ .ss-dropdown-item:hover { background: ${e.colorInputBackground}; }
398
+ .ss-dropdown-item-danger { color: ${e.colorError}; }
399
+ .ss-dropdown-item-active { font-weight: 600; color: ${e.colorPrimary}; }
400
+
401
+ .ss-dropdown-section-title {
402
+ padding: 8px 16px 4px;
403
+ font-size: 11px;
404
+ font-weight: 600;
405
+ text-transform: uppercase;
406
+ letter-spacing: 0.5px;
407
+ color: ${e.colorTextSecondary};
408
+ }
409
+
410
+ .ss-org-check {
411
+ margin-right: 6px;
412
+ font-size: 12px;
413
+ }
414
+
415
+ .ss-danger-zone {
416
+ padding-top: 20px;
417
+ margin-top: 20px;
418
+ border-top: 2px solid ${e.colorError}33;
419
+ }
400
420
 
401
421
  /* Badges */
402
422
 
@@ -408,21 +428,21 @@ function O(s) {
408
428
  border-radius: 999px;
409
429
  text-transform: uppercase;
410
430
  letter-spacing: 0.3px;
411
- background: ${s.colorInputBackground};
412
- color: ${s.colorTextSecondary};
431
+ background: ${e.colorInputBackground};
432
+ color: ${e.colorTextSecondary};
413
433
  }
414
434
 
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}; }
435
+ .ss-badge-active { background: ${e.colorSuccess}22; color: ${e.colorSuccess}; }
436
+ .ss-badge-trialing { background: ${e.colorPrimary}22; color: ${e.colorPrimary}; }
437
+ .ss-badge-past-due { background: ${e.colorError}22; color: ${e.colorError}; }
438
+ .ss-badge-paused { background: ${e.colorWarning}22; color: ${e.colorWarning}; }
439
+ .ss-badge-canceled { background: ${e.colorTextSecondary}22; color: ${e.colorTextSecondary}; }
420
440
 
421
441
  /* Tabs */
422
442
 
423
443
  .ss-tab-group {
424
444
  display: flex;
425
- border-bottom: 1px solid ${s.colorInputBorder};
445
+ border-bottom: 1px solid ${e.colorInputBorder};
426
446
  margin-bottom: 24px;
427
447
  }
428
448
 
@@ -433,7 +453,7 @@ function O(s) {
433
453
  font-size: 14px;
434
454
  font-weight: 500;
435
455
  font-family: inherit;
436
- color: ${s.colorTextSecondary};
456
+ color: ${e.colorTextSecondary};
437
457
  background: none;
438
458
  border: none;
439
459
  border-bottom: 2px solid transparent;
@@ -441,11 +461,11 @@ function O(s) {
441
461
  transition: color 0.15s, border-color 0.15s;
442
462
  }
443
463
 
444
- .ss-tab:hover { color: ${s.colorText}; }
464
+ .ss-tab:hover { color: ${e.colorText}; }
445
465
 
446
466
  .ss-tab-active {
447
- color: ${s.colorPrimary};
448
- border-bottom-color: ${s.colorPrimary};
467
+ color: ${e.colorPrimary};
468
+ border-bottom-color: ${e.colorPrimary};
449
469
  }
450
470
 
451
471
  .ss-tab-content .ss-card { box-shadow: none; border: none; padding: 0; }
@@ -464,30 +484,30 @@ function O(s) {
464
484
  text-align: left;
465
485
  padding: 10px 12px;
466
486
  font-weight: 600;
467
- color: ${s.colorTextSecondary};
468
- border-bottom: 2px solid ${s.colorInputBorder};
487
+ color: ${e.colorTextSecondary};
488
+ border-bottom: 2px solid ${e.colorInputBorder};
469
489
  white-space: nowrap;
470
490
  }
471
491
 
472
492
  .ss-th-sortable { cursor: pointer; user-select: none; }
473
- .ss-th-sortable:hover { color: ${s.colorText}; }
493
+ .ss-th-sortable:hover { color: ${e.colorText}; }
474
494
 
475
495
  .ss-sort-indicator { font-size: 10px; }
476
- .ss-sorted-asc, .ss-sorted-desc { color: ${s.colorPrimary}; }
496
+ .ss-sorted-asc, .ss-sorted-desc { color: ${e.colorPrimary}; }
477
497
 
478
498
  .ss-td {
479
499
  padding: 10px 12px;
480
- border-bottom: 1px solid ${s.colorInputBorder};
481
- color: ${s.colorText};
500
+ border-bottom: 1px solid ${e.colorInputBorder};
501
+ color: ${e.colorText};
482
502
  }
483
503
 
484
- .ss-tr:hover .ss-td { background: ${s.colorInputBackground}; }
504
+ .ss-tr:hover .ss-td { background: ${e.colorInputBackground}; }
485
505
 
486
506
  .ss-table-footer {
487
507
  text-align: center;
488
508
  padding: 8px;
489
509
  font-size: 12px;
490
- color: ${s.colorTextSecondary};
510
+ color: ${e.colorTextSecondary};
491
511
  }
492
512
 
493
513
  /* Pricing */
@@ -499,15 +519,15 @@ function O(s) {
499
519
  }
500
520
 
501
521
  .ss-pricing-card {
502
- background: ${s.colorBackground};
503
- border: 1px solid ${s.colorInputBorder};
504
- border-radius: ${s.borderRadius};
522
+ background: ${e.colorBackground};
523
+ border: 1px solid ${e.colorInputBorder};
524
+ border-radius: ${e.borderRadius};
505
525
  padding: 24px;
506
526
  display: flex;
507
527
  flex-direction: column;
508
528
  }
509
529
 
510
- .ss-pricing-card-current { border-color: ${s.colorPrimary}; }
530
+ .ss-pricing-card-current { border-color: ${e.colorPrimary}; }
511
531
 
512
532
  .ss-pricing-header {
513
533
  display: flex;
@@ -519,7 +539,7 @@ function O(s) {
519
539
  .ss-pricing-name {
520
540
  font-size: 18px;
521
541
  font-weight: 600;
522
- color: ${s.colorText};
542
+ color: ${e.colorText};
523
543
  }
524
544
 
525
545
  .ss-pricing-price { margin-bottom: 12px; }
@@ -527,17 +547,17 @@ function O(s) {
527
547
  .ss-pricing-amount {
528
548
  font-size: 32px;
529
549
  font-weight: 700;
530
- color: ${s.colorText};
550
+ color: ${e.colorText};
531
551
  }
532
552
 
533
553
  .ss-pricing-interval {
534
554
  font-size: 14px;
535
- color: ${s.colorTextSecondary};
555
+ color: ${e.colorTextSecondary};
536
556
  }
537
557
 
538
558
  .ss-pricing-desc {
539
559
  font-size: 14px;
540
- color: ${s.colorTextSecondary};
560
+ color: ${e.colorTextSecondary};
541
561
  margin-bottom: 16px;
542
562
  }
543
563
 
@@ -549,11 +569,11 @@ function O(s) {
549
569
 
550
570
  .ss-pricing-feature {
551
571
  font-size: 14px;
552
- color: ${s.colorText};
572
+ color: ${e.colorText};
553
573
  padding: 4px 0;
554
574
  }
555
575
 
556
- .ss-check { color: ${s.colorSuccess}; margin-right: 6px; }
576
+ .ss-check { color: ${e.colorSuccess}; margin-right: 6px; }
557
577
 
558
578
  /* Usage / Progress */
559
579
 
@@ -568,30 +588,30 @@ function O(s) {
568
588
  .ss-usage-metric {
569
589
  font-size: 14px;
570
590
  font-weight: 500;
571
- color: ${s.colorText};
591
+ color: ${e.colorText};
572
592
  }
573
593
 
574
594
  .ss-usage-value {
575
595
  font-size: 14px;
576
- color: ${s.colorTextSecondary};
596
+ color: ${e.colorTextSecondary};
577
597
  }
578
598
 
579
599
  .ss-progress-bar {
580
600
  width: 100%;
581
601
  height: 8px;
582
- background: ${s.colorInputBackground};
602
+ background: ${e.colorInputBackground};
583
603
  border-radius: 4px;
584
604
  overflow: hidden;
585
605
  }
586
606
 
587
607
  .ss-progress-fill {
588
608
  height: 100%;
589
- background: ${s.colorPrimary};
609
+ background: ${e.colorPrimary};
590
610
  border-radius: 4px;
591
611
  transition: width 0.3s;
592
612
  }
593
613
 
594
- .ss-progress-danger { background: ${s.colorError}; }
614
+ .ss-progress-danger { background: ${e.colorError}; }
595
615
 
596
616
  /* Chart */
597
617
 
@@ -600,7 +620,7 @@ function O(s) {
600
620
  .ss-chart-title {
601
621
  font-size: 16px;
602
622
  font-weight: 600;
603
- color: ${s.colorText};
623
+ color: ${e.colorText};
604
624
  margin-bottom: 12px;
605
625
  }
606
626
 
@@ -613,16 +633,16 @@ function O(s) {
613
633
  }
614
634
 
615
635
  .ss-widget {
616
- background: ${s.colorBackground};
617
- border: 1px solid ${s.colorInputBorder};
618
- border-radius: ${s.borderRadius};
636
+ background: ${e.colorBackground};
637
+ border: 1px solid ${e.colorInputBorder};
638
+ border-radius: ${e.borderRadius};
619
639
  padding: 16px;
620
640
  }
621
641
 
622
642
  .ss-widget-header {
623
643
  font-size: 14px;
624
644
  font-weight: 600;
625
- color: ${s.colorText};
645
+ color: ${e.colorText};
626
646
  margin-bottom: 12px;
627
647
  }
628
648
 
@@ -630,14 +650,14 @@ function O(s) {
630
650
 
631
651
  .ss-saved-query-card {
632
652
  padding: 12px 16px;
633
- border: 1px solid ${s.colorInputBorder};
634
- border-radius: calc(${s.borderRadius} - 2px);
653
+ border: 1px solid ${e.colorInputBorder};
654
+ border-radius: calc(${e.borderRadius} - 2px);
635
655
  margin-bottom: 8px;
636
656
  cursor: pointer;
637
657
  transition: border-color 0.15s;
638
658
  }
639
659
 
640
- .ss-saved-query-card:hover { border-color: ${s.colorPrimary}; }
660
+ .ss-saved-query-card:hover { border-color: ${e.colorPrimary}; }
641
661
 
642
662
  .ss-saved-query-header {
643
663
  display: flex;
@@ -649,12 +669,12 @@ function O(s) {
649
669
  .ss-saved-query-name {
650
670
  font-size: 14px;
651
671
  font-weight: 600;
652
- color: ${s.colorText};
672
+ color: ${e.colorText};
653
673
  }
654
674
 
655
675
  .ss-saved-query-desc {
656
676
  font-size: 13px;
657
- color: ${s.colorTextSecondary};
677
+ color: ${e.colorTextSecondary};
658
678
  margin-bottom: 8px;
659
679
  }
660
680
 
@@ -666,7 +686,7 @@ function O(s) {
666
686
 
667
687
  .ss-saved-query-date {
668
688
  font-size: 12px;
669
- color: ${s.colorTextSecondary};
689
+ color: ${e.colorTextSecondary};
670
690
  }
671
691
 
672
692
  /* Modal Overlay */
@@ -691,15 +711,15 @@ function O(s) {
691
711
  }
692
712
 
693
713
  .ss-modal {
694
- background: ${s.colorBackground};
695
- border-radius: ${s.borderRadius};
714
+ background: ${e.colorBackground};
715
+ border-radius: ${e.borderRadius};
696
716
  padding: 32px;
697
717
  width: 90%;
698
718
  max-width: 480px;
699
719
  max-height: 90vh;
700
720
  overflow-y: auto;
701
721
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.2);
702
- border: 1px solid ${s.colorInputBorder};
722
+ border: 1px solid ${e.colorInputBorder};
703
723
  animation: ss-scale-in 0.15s ease-out;
704
724
  }
705
725
 
@@ -718,14 +738,14 @@ function O(s) {
718
738
  .ss-modal-title {
719
739
  font-size: 18px;
720
740
  font-weight: 700;
721
- color: ${s.colorText};
741
+ color: ${e.colorText};
722
742
  }
723
743
 
724
744
  .ss-modal-close {
725
745
  background: none;
726
746
  border: none;
727
747
  font-size: 20px;
728
- color: ${s.colorTextSecondary};
748
+ color: ${e.colorTextSecondary};
729
749
  cursor: pointer;
730
750
  padding: 4px;
731
751
  line-height: 1;
@@ -735,20 +755,20 @@ function O(s) {
735
755
  }
736
756
 
737
757
  .ss-modal-close:hover {
738
- background: ${s.colorInputBackground};
739
- color: ${s.colorText};
758
+ background: ${e.colorInputBackground};
759
+ color: ${e.colorText};
740
760
  }
741
761
 
742
762
  .ss-modal-section {
743
763
  padding-top: 20px;
744
764
  margin-top: 20px;
745
- border-top: 1px solid ${s.colorInputBorder};
765
+ border-top: 1px solid ${e.colorInputBorder};
746
766
  }
747
767
 
748
768
  .ss-modal-section-title {
749
769
  font-size: 15px;
750
770
  font-weight: 600;
751
- color: ${s.colorText};
771
+ color: ${e.colorText};
752
772
  margin-bottom: 16px;
753
773
  }
754
774
 
@@ -756,7 +776,7 @@ function O(s) {
756
776
  width: 64px;
757
777
  height: 64px;
758
778
  border-radius: 50%;
759
- background: ${s.colorPrimary};
779
+ background: ${e.colorPrimary};
760
780
  color: #fff;
761
781
  display: flex;
762
782
  align-items: center;
@@ -773,6 +793,111 @@ function O(s) {
773
793
  object-fit: cover;
774
794
  }
775
795
 
796
+ /* Avatar hover overlay */
797
+ .ss-avatar-hoverable {
798
+ position: relative;
799
+ cursor: pointer;
800
+ transition: filter 0.15s;
801
+ }
802
+
803
+ .ss-avatar-overlay {
804
+ position: absolute;
805
+ inset: 0;
806
+ border-radius: 50%;
807
+ background: rgba(0, 0, 0, 0.5);
808
+ display: flex;
809
+ align-items: center;
810
+ justify-content: center;
811
+ opacity: 0;
812
+ transition: opacity 0.15s;
813
+ color: #fff;
814
+ }
815
+
816
+ .ss-avatar-hoverable:hover .ss-avatar-overlay {
817
+ opacity: 1;
818
+ }
819
+
820
+ /* Avatar cropper */
821
+ .ss-avatar-cropper {
822
+ display: flex;
823
+ flex-direction: column;
824
+ align-items: center;
825
+ gap: 16px;
826
+ }
827
+
828
+ .ss-avatar-canvas {
829
+ border-radius: ${e.borderRadius};
830
+ background: #111;
831
+ touch-action: none;
832
+ max-width: 100%;
833
+ }
834
+
835
+ .ss-avatar-zoom {
836
+ display: flex;
837
+ align-items: center;
838
+ gap: 12px;
839
+ width: 100%;
840
+ }
841
+
842
+ .ss-avatar-zoom-label {
843
+ font-size: 13px;
844
+ color: ${e.colorTextSecondary};
845
+ flex-shrink: 0;
846
+ }
847
+
848
+ .ss-avatar-zoom-slider {
849
+ flex: 1;
850
+ height: 4px;
851
+ -webkit-appearance: none;
852
+ appearance: none;
853
+ background: ${e.colorInputBorder};
854
+ border-radius: 2px;
855
+ outline: none;
856
+ }
857
+
858
+ .ss-avatar-zoom-slider::-webkit-slider-thumb {
859
+ -webkit-appearance: none;
860
+ width: 16px;
861
+ height: 16px;
862
+ border-radius: 50%;
863
+ background: ${e.colorPrimary};
864
+ cursor: pointer;
865
+ }
866
+
867
+ .ss-avatar-zoom-slider::-moz-range-thumb {
868
+ width: 16px;
869
+ height: 16px;
870
+ border-radius: 50%;
871
+ background: ${e.colorPrimary};
872
+ cursor: pointer;
873
+ border: none;
874
+ }
875
+
876
+ /* Dropzone */
877
+ .ss-avatar-dropzone {
878
+ border: 2px dashed ${e.colorInputBorder};
879
+ border-radius: ${e.borderRadius};
880
+ padding: 40px 24px;
881
+ text-align: center;
882
+ cursor: pointer;
883
+ transition: border-color 0.15s, background 0.15s;
884
+ color: ${e.colorTextSecondary};
885
+ display: flex;
886
+ flex-direction: column;
887
+ align-items: center;
888
+ gap: 12px;
889
+ }
890
+
891
+ .ss-avatar-dropzone:hover,
892
+ .ss-avatar-dropzone-active {
893
+ border-color: ${e.colorPrimary};
894
+ background: ${e.colorPrimary}08;
895
+ }
896
+
897
+ .ss-avatar-dropzone svg {
898
+ opacity: 0.5;
899
+ }
900
+
776
901
  .ss-input-readonly {
777
902
  opacity: 0.6;
778
903
  cursor: not-allowed;
@@ -782,7 +907,7 @@ function O(s) {
782
907
 
783
908
  .ss-dropdown-divider {
784
909
  height: 1px;
785
- background: ${s.colorInputBorder};
910
+ background: ${e.colorInputBorder};
786
911
  margin: 4px 0;
787
912
  }
788
913
 
@@ -805,216 +930,335 @@ function O(s) {
805
930
  }
806
931
  `;
807
932
  }
808
- function B({ children: s, appearance: a }) {
809
- const r = R(null), [c, t] = g(null);
810
- L(() => {
811
- var m;
933
+ function q({ children: e, appearance: a }) {
934
+ const r = j(null), [o, t] = m(null);
935
+ U(() => {
936
+ var g;
812
937
  if (!r.current || r.current.shadowRoot) {
813
- t(((m = r.current) == null ? void 0 : m.shadowRoot) ?? null);
938
+ t(((g = r.current) == null ? void 0 : g.shadowRoot) ?? null);
814
939
  return;
815
940
  }
816
- const l = r.current.attachShadow({ mode: "open" }), u = U(a), o = document.createElement("style");
817
- o.textContent = O(u), l.appendChild(o);
818
- const n = document.createElement("div");
819
- l.appendChild(n), t(l);
820
- }, []), L(() => {
821
- if (!c) return;
822
- const l = c.querySelector("style");
823
- if (l) {
824
- const u = U(a);
825
- l.textContent = O(u);
826
- }
827
- }, [a, c]);
828
- const d = (c == null ? void 0 : c.querySelector("div")) ?? null;
829
- return /* @__PURE__ */ e("div", { ref: r, style: { display: "contents" }, children: d && es(s, d) });
941
+ const i = r.current.attachShadow({ mode: "open" }), c = Z(a), d = document.createElement("style");
942
+ d.textContent = X(c), i.appendChild(d);
943
+ const l = document.createElement("div");
944
+ i.appendChild(l), t(i);
945
+ }, []), U(() => {
946
+ if (!o) return;
947
+ const i = o.querySelector("style");
948
+ if (i) {
949
+ const c = Z(a);
950
+ i.textContent = X(c);
951
+ }
952
+ }, [a, o]);
953
+ const u = (o == null ? void 0 : o.querySelector("div")) ?? null;
954
+ return /* @__PURE__ */ s("div", { ref: r, style: { display: "contents" }, children: u && ve(e, u) });
830
955
  }
831
- function j() {
832
- const { client: s, user: a, isLoaded: r } = k();
956
+ function ee() {
957
+ const { client: e, user: a, isLoaded: r } = L();
833
958
  return {
834
959
  isLoaded: r,
835
960
  isSignedIn: !!a,
836
961
  user: a,
837
- signOut: S(() => s.auth.signOut(), [s]),
838
- getToken: S(() => s.auth.getToken(), [s])
962
+ signOut: N(() => e.auth.signOut(), [e]),
963
+ getToken: N(() => e.auth.getToken(), [e])
839
964
  };
840
965
  }
841
- function zs() {
842
- const { user: s, isLoaded: a } = k();
843
- return { user: s, isLoaded: a };
966
+ function Xe() {
967
+ const { user: e, isLoaded: a } = L();
968
+ return { user: e, isLoaded: a };
844
969
  }
845
- function _() {
846
- const { client: s } = k(), [a, r] = g(!1), [c, t] = g(null), d = S(
847
- async (o, n) => {
970
+ function re() {
971
+ const { client: e } = L(), [a, r] = m(!1), [o, t] = m(null), u = N(
972
+ async (d, l) => {
848
973
  r(!0), t(null);
849
974
  try {
850
- return await s.auth.signIn(o, n);
851
- } catch (m) {
852
- return t(m instanceof Error ? m.message : "Sign in failed"), null;
975
+ return await e.auth.signIn(d, l);
976
+ } catch (g) {
977
+ return t(g instanceof Error ? g.message : "Sign in failed"), null;
853
978
  } finally {
854
979
  r(!1);
855
980
  }
856
981
  },
857
- [s]
858
- ), l = S(
859
- async (o) => {
982
+ [e]
983
+ ), i = N(
984
+ async (d) => {
860
985
  r(!0), t(null);
861
986
  try {
862
- return await s.auth.signInWithOAuth(o);
863
- } catch (n) {
864
- return t(n instanceof Error ? n.message : "OAuth sign in failed"), null;
987
+ return await e.auth.signInWithOAuth(d);
988
+ } catch (l) {
989
+ return t(l instanceof Error ? l.message : "OAuth sign in failed"), null;
865
990
  } finally {
866
991
  r(!1);
867
992
  }
868
993
  },
869
- [s]
870
- ), u = S(
871
- async (o, n) => {
994
+ [e]
995
+ ), c = N(
996
+ async (d, l) => {
872
997
  r(!0), t(null);
873
998
  try {
874
- return await s.auth.submitMfaCode(o, n);
875
- } catch (m) {
876
- return t(m instanceof Error ? m.message : "MFA verification failed"), null;
999
+ return await e.auth.submitMfaCode(d, l);
1000
+ } catch (g) {
1001
+ return t(g instanceof Error ? g.message : "MFA verification failed"), null;
877
1002
  } finally {
878
1003
  r(!1);
879
1004
  }
880
1005
  },
881
- [s]
1006
+ [e]
882
1007
  );
883
- return { signIn: d, signInWithOAuth: l, submitMfaCode: u, isLoading: a, error: c, setError: t };
1008
+ return { signIn: u, signInWithOAuth: i, submitMfaCode: c, isLoading: a, error: o, setError: t };
884
1009
  }
885
- function ts() {
886
- const { client: s } = k(), [a, r] = g(!1), [c, t] = g(null);
887
- return { signUp: S(
888
- async (l, u) => {
1010
+ function Ce() {
1011
+ const { client: e } = L(), [a, r] = m(!1), [o, t] = m(null);
1012
+ return { signUp: N(
1013
+ async (i, c) => {
889
1014
  r(!0), t(null);
890
1015
  try {
891
- return await s.auth.signUp(l, u);
892
- } catch (o) {
893
- return t(o instanceof Error ? o.message : "Sign up failed"), null;
1016
+ return await e.auth.signUp(i, c);
1017
+ } catch (d) {
1018
+ return t(d instanceof Error ? d.message : "Sign up failed"), null;
894
1019
  } finally {
895
1020
  r(!1);
896
1021
  }
897
1022
  },
898
- [s]
899
- ), isLoading: a, error: c, setError: t };
1023
+ [e]
1024
+ ), isLoading: a, error: o, setError: t };
900
1025
  }
901
- function os() {
902
- const { client: s } = k(), [a, r] = g([]), [c, t] = g(null), [d, l] = g([]), [u, o] = g(!1), [n, m] = g(null), p = S(async () => {
903
- o(!0), m(null);
1026
+ function ae() {
1027
+ const { client: e } = L(), [a, r] = m([]), [o, t] = m(null), [u, i] = m([]), [c, d] = m([]), [l, g] = m(!1), [p, f] = m(null), b = N(async () => {
1028
+ g(!0), f(null);
904
1029
  try {
905
- const y = await s.auth.listOrgs();
906
- r(y);
907
- } catch (y) {
908
- m(y instanceof Error ? y.message : "Failed to load organizations");
1030
+ const w = await e.auth.listOrgs();
1031
+ r(w);
1032
+ const $ = typeof window < "u" ? localStorage.getItem("ss_selected_org") : null;
1033
+ if ($ && w.some((y) => y.id === $) && !o) {
1034
+ const y = w.find((E) => E.id === $);
1035
+ t(y);
1036
+ try {
1037
+ const E = await e.auth.listMembers(y.id);
1038
+ i(E);
1039
+ } catch {
1040
+ }
1041
+ }
1042
+ } catch (w) {
1043
+ f(w instanceof Error ? w.message : "Failed to load organizations");
909
1044
  } finally {
910
- o(!1);
1045
+ g(!1);
911
1046
  }
912
- }, [s]);
913
- L(() => {
914
- p();
915
- }, [p]);
916
- const h = S(async (y) => {
1047
+ }, [e, o]);
1048
+ U(() => {
1049
+ b();
1050
+ }, [b]);
1051
+ const k = N(async (w) => {
917
1052
  try {
918
- const b = await s.auth.getOrg(y);
919
- t(b);
920
- const x = await s.auth.listMembers(y);
921
- l(x);
922
- } catch (b) {
923
- m(b instanceof Error ? b.message : "Failed to load organization");
924
- }
925
- }, [s]), v = S(async (y, b) => {
1053
+ const $ = await e.auth.getOrg(w);
1054
+ t($), typeof window < "u" && localStorage.setItem("ss_selected_org", w);
1055
+ const y = await e.auth.listMembers(w);
1056
+ i(y);
1057
+ } catch ($) {
1058
+ f($ instanceof Error ? $.message : "Failed to load organization");
1059
+ }
1060
+ }, [e]), v = N(async (w, $) => {
926
1061
  try {
927
- const x = await s.auth.createOrg(y, b);
928
- return r((f) => [...f, x]), x;
929
- } catch (x) {
930
- return m(x instanceof Error ? x.message : "Failed to create organization"), null;
1062
+ const y = await e.auth.createOrg(w, $);
1063
+ return r((E) => [...E, y]), y;
1064
+ } catch (y) {
1065
+ return f(y instanceof Error ? y.message : "Failed to create organization"), null;
1066
+ }
1067
+ }, [e]), C = N(async (w, $) => {
1068
+ try {
1069
+ const y = await e.auth.updateOrg(w, $);
1070
+ return r((E) => E.map((M) => M.id === w ? y : M)), (o == null ? void 0 : o.id) === w && t(y), y;
1071
+ } catch (y) {
1072
+ return f(y instanceof Error ? y.message : "Failed to update organization"), null;
1073
+ }
1074
+ }, [e, o]), x = N(async (w) => {
1075
+ try {
1076
+ return await e.auth.deleteOrg(w), r(($) => $.filter((y) => y.id !== w)), (o == null ? void 0 : o.id) === w && (t(null), i([]), d([]), typeof window < "u" && localStorage.removeItem("ss_selected_org")), !0;
1077
+ } catch ($) {
1078
+ return f($ instanceof Error ? $.message : "Failed to delete organization"), !1;
1079
+ }
1080
+ }, [e, o]), h = N(async (w, $, y) => {
1081
+ try {
1082
+ return await e.auth.sendInvite(w, $, y);
1083
+ } catch (E) {
1084
+ return f(E instanceof Error ? E.message : "Failed to send invite"), null;
1085
+ }
1086
+ }, [e]), S = N(async (w) => {
1087
+ try {
1088
+ const $ = await e.auth.listInvites(w);
1089
+ d($);
1090
+ } catch ($) {
1091
+ f($ instanceof Error ? $.message : "Failed to load invites");
1092
+ }
1093
+ }, [e]), z = N(async (w, $) => {
1094
+ try {
1095
+ return await e.auth.revokeInvite(w, $), d((y) => y.filter((E) => E.id !== $)), !0;
1096
+ } catch (y) {
1097
+ return f(y instanceof Error ? y.message : "Failed to revoke invite"), !1;
1098
+ }
1099
+ }, [e]), P = N(async (w, $, y) => {
1100
+ try {
1101
+ return await e.auth.updateMemberRole(w, $, y), i((E) => E.map((M) => M.userId === $ ? { ...M, role: y } : M)), !0;
1102
+ } catch (E) {
1103
+ return f(E instanceof Error ? E.message : "Failed to update member role"), !1;
1104
+ }
1105
+ }, [e]), I = N(async (w, $) => {
1106
+ try {
1107
+ return await e.auth.removeMember(w, $), i((y) => y.filter((E) => E.userId !== $)), !0;
1108
+ } catch (y) {
1109
+ return f(y instanceof Error ? y.message : "Failed to remove member"), !1;
931
1110
  }
932
- }, [s]);
933
- return { orgs: a, selectedOrg: c, members: d, isLoading: u, error: n, refresh: p, selectOrg: h, createOrg: v };
1111
+ }, [e]), T = N(async (w) => {
1112
+ try {
1113
+ const $ = await e.auth.listMembers(w);
1114
+ i($);
1115
+ } catch ($) {
1116
+ f($ instanceof Error ? $.message : "Failed to load members");
1117
+ }
1118
+ }, [e]);
1119
+ return {
1120
+ orgs: a,
1121
+ selectedOrg: o,
1122
+ members: u,
1123
+ invites: c,
1124
+ isLoading: l,
1125
+ error: p,
1126
+ setError: f,
1127
+ refresh: b,
1128
+ selectOrg: k,
1129
+ createOrg: v,
1130
+ updateOrg: C,
1131
+ deleteOrg: x,
1132
+ sendInvite: h,
1133
+ refreshInvites: S,
1134
+ revokeInvite: z,
1135
+ updateMemberRole: P,
1136
+ removeMember: I,
1137
+ refreshMembers: T
1138
+ };
1139
+ }
1140
+ function ke() {
1141
+ const { client: e } = L(), [a, r] = m(!1), [o, t] = m(null);
1142
+ return { deleteAccount: N(async () => {
1143
+ r(!0), t(null);
1144
+ try {
1145
+ return await e.auth.deleteAccount(), !0;
1146
+ } catch (i) {
1147
+ return t(i instanceof Error ? i.message : "Failed to delete account"), !1;
1148
+ } finally {
1149
+ r(!1);
1150
+ }
1151
+ }, [e]), isLoading: a, error: o, setError: t };
934
1152
  }
935
- function G() {
936
- const { client: s, user: a } = k(), [r, c] = g(!1), [t, d] = g(null), [l, u] = g(null), o = S(
937
- async (m) => {
938
- c(!0), d(null), u(null);
1153
+ function te() {
1154
+ const { client: e, user: a } = L(), [r, o] = m(!1), [t, u] = m(null), [i, c] = m(null), d = N(
1155
+ async (p) => {
1156
+ o(!0), u(null), c(null);
939
1157
  try {
940
- const p = await s.auth.updateProfile(m);
941
- return u("Profile updated"), p;
942
- } catch (p) {
943
- return d(p instanceof Error ? p.message : "Failed to update profile"), null;
1158
+ const f = await e.auth.updateProfile(p);
1159
+ return c("Profile updated"), f;
1160
+ } catch (f) {
1161
+ return u(f instanceof Error ? f.message : "Failed to update profile"), null;
1162
+ } finally {
1163
+ o(!1);
1164
+ }
1165
+ },
1166
+ [e]
1167
+ ), l = N(
1168
+ async (p, f) => {
1169
+ o(!0), u(null), c(null);
1170
+ try {
1171
+ return await e.auth.changePassword(p, f), c("Password changed successfully"), !0;
1172
+ } catch (b) {
1173
+ return u(b instanceof Error ? b.message : "Failed to change password"), !1;
944
1174
  } finally {
945
- c(!1);
1175
+ o(!1);
946
1176
  }
947
1177
  },
948
- [s]
949
- ), n = S(
950
- async (m, p) => {
951
- c(!0), d(null), u(null);
1178
+ [e]
1179
+ ), g = N(
1180
+ async (p) => {
1181
+ o(!0), u(null), c(null);
952
1182
  try {
953
- return await s.auth.changePassword(m, p), u("Password changed successfully"), !0;
954
- } catch (h) {
955
- return d(h instanceof Error ? h.message : "Failed to change password"), !1;
1183
+ const f = await e.auth.uploadAvatar(p);
1184
+ return c("Avatar updated"), f;
1185
+ } catch (f) {
1186
+ return u(f instanceof Error ? f.message : "Failed to upload avatar"), null;
956
1187
  } finally {
957
- c(!1);
1188
+ o(!1);
958
1189
  }
959
1190
  },
960
- [s]
1191
+ [e]
961
1192
  );
962
- return { user: a, updateProfile: o, changePassword: n, isLoading: r, error: t, success: l, setError: d, setSuccess: u };
1193
+ return { user: a, updateProfile: d, uploadAvatar: g, changePassword: l, isLoading: r, error: t, success: i, setError: u, setSuccess: c };
963
1194
  }
964
- 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>', Q = '<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>';
965
- function qs({ appearance: s, signUpUrl: a, onSignUp: r }) {
966
- const { appearance: c, settings: t } = k(), { signIn: d, signInWithOAuth: l, submitMfaCode: u, isLoading: o, error: n, setError: m } = _(), p = s ?? c, [h, v] = g(""), [y, b] = g(""), [x, f] = g(!1), [N, w] = g(""), [$, E] = g(""), z = S(
967
- async (q) => {
968
- if (q.preventDefault(), x) {
969
- await u(N, $);
1195
+ const ne = '<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>', oe = '<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>', Se = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z" fill="currentColor"/></svg>';
1196
+ function Ke({ appearance: e, signUpUrl: a, onSignUp: r }) {
1197
+ const { appearance: o, settings: t } = L(), { signIn: u, signInWithOAuth: i, submitMfaCode: c, isLoading: d, error: l, setError: g } = re(), p = e ?? o, [f, b] = m(""), [k, v] = m(""), [C, x] = m(!1), [h, S] = m(""), [z, P] = m(""), [I, T] = m(!1), w = N(
1198
+ async (E) => {
1199
+ if (E.preventDefault(), C) {
1200
+ await c(h, z);
970
1201
  return;
971
1202
  }
972
- const P = await d(h, y);
973
- P && Z(P) && (w(P.mfaToken), f(!0), m(null));
1203
+ const M = await u(f, k);
1204
+ M && be(M) && (S(M.mfaToken), x(!0), g(null));
974
1205
  },
975
- [h, y, x, N, $, d, u, m]
976
- ), T = S(
977
- async (q) => {
978
- await l(q);
1206
+ [f, k, C, h, z, u, c, g]
1207
+ ), $ = N(
1208
+ async (E) => {
1209
+ await i(E);
979
1210
  },
980
- [l]
981
- ), C = (t == null ? void 0 : t.googleEnabled) || (t == null ? void 0 : t.githubEnabled);
982
- return /* @__PURE__ */ e(B, { appearance: p, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
983
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Sign in" }),
984
- !x && /* @__PURE__ */ i(D, { children: [
985
- (t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */ i(
1211
+ [i]
1212
+ ), y = (t == null ? void 0 : t.googleEnabled) || (t == null ? void 0 : t.githubEnabled);
1213
+ return /* @__PURE__ */ s(q, { appearance: p, children: /* @__PURE__ */ n("div", { className: "ss-card", children: [
1214
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Sign in" }),
1215
+ !C && /* @__PURE__ */ n(G, { children: [
1216
+ (t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */ n(
986
1217
  "button",
987
1218
  {
988
1219
  type: "button",
989
1220
  className: "ss-btn-social",
990
- onClick: () => T("google"),
991
- disabled: o,
1221
+ onClick: () => $("google"),
1222
+ disabled: d,
992
1223
  children: [
993
- /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: J } }),
1224
+ /* @__PURE__ */ s("span", { dangerouslySetInnerHTML: { __html: ne } }),
994
1225
  "Continue with Google"
995
1226
  ]
996
1227
  }
997
1228
  ),
998
- (t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */ i(
1229
+ (t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */ n(
999
1230
  "button",
1000
1231
  {
1001
1232
  type: "button",
1002
1233
  className: "ss-btn-social",
1003
- onClick: () => T("github"),
1004
- disabled: o,
1234
+ onClick: () => $("github"),
1235
+ disabled: d,
1005
1236
  children: [
1006
- /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: Q } }),
1237
+ /* @__PURE__ */ s("span", { dangerouslySetInnerHTML: { __html: oe } }),
1007
1238
  "Continue with GitHub"
1008
1239
  ]
1009
1240
  }
1010
1241
  ),
1011
- C && /* @__PURE__ */ e("div", { className: "ss-divider", children: "or" })
1242
+ y && !I && /* @__PURE__ */ s("div", { className: "ss-divider", children: "or" }),
1243
+ y && !I && /* @__PURE__ */ n(
1244
+ "button",
1245
+ {
1246
+ type: "button",
1247
+ className: "ss-btn-social",
1248
+ onClick: () => T(!0),
1249
+ children: [
1250
+ /* @__PURE__ */ s("span", { dangerouslySetInnerHTML: { __html: Se } }),
1251
+ "Login with email"
1252
+ ]
1253
+ }
1254
+ ),
1255
+ y && I && /* @__PURE__ */ s("div", { className: "ss-divider", children: "or" })
1012
1256
  ] }),
1013
- n && /* @__PURE__ */ e("div", { className: "ss-global-error", children: n }),
1014
- /* @__PURE__ */ i("form", { onSubmit: z, children: [
1015
- x ? /* @__PURE__ */ i("div", { className: "ss-field", children: [
1016
- /* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-mfa-code", children: "Authentication code" }),
1017
- /* @__PURE__ */ e(
1257
+ l && /* @__PURE__ */ s("div", { className: "ss-global-error", children: l }),
1258
+ (I || C || !y) && /* @__PURE__ */ n("form", { onSubmit: w, children: [
1259
+ C ? /* @__PURE__ */ n("div", { className: "ss-field", children: [
1260
+ /* @__PURE__ */ s("label", { className: "ss-label", htmlFor: "ss-mfa-code", children: "Authentication code" }),
1261
+ /* @__PURE__ */ s(
1018
1262
  "input",
1019
1263
  {
1020
1264
  id: "ss-mfa-code",
@@ -1023,15 +1267,15 @@ function qs({ appearance: s, signUpUrl: a, onSignUp: r }) {
1023
1267
  inputMode: "numeric",
1024
1268
  autoComplete: "one-time-code",
1025
1269
  placeholder: "Enter 6-digit code",
1026
- value: $,
1027
- onChange: (q) => E(q.target.value),
1270
+ value: z,
1271
+ onChange: (E) => P(E.target.value),
1028
1272
  autoFocus: !0
1029
1273
  }
1030
1274
  )
1031
- ] }) : /* @__PURE__ */ i(D, { children: [
1032
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1033
- /* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-email", children: "Email" }),
1034
- /* @__PURE__ */ e(
1275
+ ] }) : /* @__PURE__ */ n(G, { children: [
1276
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1277
+ /* @__PURE__ */ s("label", { className: "ss-label", htmlFor: "ss-email", children: "Email" }),
1278
+ /* @__PURE__ */ s(
1035
1279
  "input",
1036
1280
  {
1037
1281
  id: "ss-email",
@@ -1039,15 +1283,15 @@ function qs({ appearance: s, signUpUrl: a, onSignUp: r }) {
1039
1283
  type: "email",
1040
1284
  autoComplete: "email",
1041
1285
  placeholder: "you@example.com",
1042
- value: h,
1043
- onChange: (q) => v(q.target.value),
1286
+ value: f,
1287
+ onChange: (E) => b(E.target.value),
1044
1288
  required: !0
1045
1289
  }
1046
1290
  )
1047
1291
  ] }),
1048
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1049
- /* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-password", children: "Password" }),
1050
- /* @__PURE__ */ e(
1292
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1293
+ /* @__PURE__ */ s("label", { className: "ss-label", htmlFor: "ss-password", children: "Password" }),
1294
+ /* @__PURE__ */ s(
1051
1295
  "input",
1052
1296
  {
1053
1297
  id: "ss-password",
@@ -1055,90 +1299,90 @@ function qs({ appearance: s, signUpUrl: a, onSignUp: r }) {
1055
1299
  type: "password",
1056
1300
  autoComplete: "current-password",
1057
1301
  placeholder: "Enter your password",
1058
- value: y,
1059
- onChange: (q) => b(q.target.value),
1302
+ value: k,
1303
+ onChange: (E) => v(E.target.value),
1060
1304
  required: !0
1061
1305
  }
1062
1306
  )
1063
1307
  ] })
1064
1308
  ] }),
1065
- /* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: o, children: [
1066
- o && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
1067
- x ? "Verify" : "Continue"
1309
+ /* @__PURE__ */ n("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: d, children: [
1310
+ d && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1311
+ C ? "Verify" : "Continue"
1068
1312
  ] })
1069
1313
  ] }),
1070
- x && /* @__PURE__ */ e("div", { className: "ss-footer", children: /* @__PURE__ */ e(
1314
+ C && /* @__PURE__ */ s("div", { className: "ss-footer", children: /* @__PURE__ */ s(
1071
1315
  "span",
1072
1316
  {
1073
1317
  className: "ss-link",
1074
1318
  onClick: () => {
1075
- f(!1), E(""), m(null);
1319
+ x(!1), P(""), g(null);
1076
1320
  },
1077
1321
  children: "Back to sign in"
1078
1322
  }
1079
1323
  ) }),
1080
- !x && /* @__PURE__ */ i("div", { className: "ss-footer", children: [
1324
+ !C && /* @__PURE__ */ n("div", { className: "ss-footer", children: [
1081
1325
  "Don't have an account?",
1082
1326
  " ",
1083
- r ? /* @__PURE__ */ e("span", { className: "ss-link", onClick: r, children: "Sign up" }) : a ? /* @__PURE__ */ e("a", { className: "ss-link", href: a, children: "Sign up" }) : /* @__PURE__ */ e("span", { className: "ss-link", children: "Sign up" })
1327
+ r ? /* @__PURE__ */ s("span", { className: "ss-link", onClick: r, children: "Sign up" }) : a ? /* @__PURE__ */ s("a", { className: "ss-link", href: a, children: "Sign up" }) : /* @__PURE__ */ s("span", { className: "ss-link", children: "Sign up" })
1084
1328
  ] })
1085
1329
  ] }) });
1086
1330
  }
1087
- function As({ appearance: s, signInUrl: a, onSignIn: r }) {
1088
- const { appearance: c, settings: t } = k(), { signUp: d, isLoading: l, error: u, setError: o } = ts(), { signInWithOAuth: n } = _(), m = s ?? c, [p, h] = g(""), [v, y] = g(""), [b, x] = g(""), [f, N] = g(null), w = S(
1331
+ function es({ appearance: e, signInUrl: a, onSignIn: r }) {
1332
+ const { appearance: o, settings: t } = L(), { signUp: u, isLoading: i, error: c, setError: d } = Ce(), { signInWithOAuth: l } = re(), g = e ?? o, [p, f] = m(""), [b, k] = m(""), [v, C] = m(""), [x, h] = m(null), S = N(
1089
1333
  async (T) => {
1090
- if (T.preventDefault(), N(null), v !== b) {
1091
- N("Passwords do not match");
1334
+ if (T.preventDefault(), h(null), b !== v) {
1335
+ h("Passwords do not match");
1092
1336
  return;
1093
1337
  }
1094
- const C = (t == null ? void 0 : t.passwordMinLength) ?? 8;
1095
- if (v.length < C) {
1096
- N(`Password must be at least ${C} characters`);
1338
+ const w = (t == null ? void 0 : t.passwordMinLength) ?? 8;
1339
+ if (b.length < w) {
1340
+ h(`Password must be at least ${w} characters`);
1097
1341
  return;
1098
1342
  }
1099
- await d(p, v);
1343
+ await u(p, b);
1100
1344
  },
1101
- [p, v, b, t, d]
1102
- ), $ = S(
1345
+ [p, b, v, t, u]
1346
+ ), z = N(
1103
1347
  async (T) => {
1104
- await n(T);
1348
+ await l(T);
1105
1349
  },
1106
- [n]
1107
- ), E = (t == null ? void 0 : t.googleEnabled) || (t == null ? void 0 : t.githubEnabled), z = f || u;
1108
- return /* @__PURE__ */ e(B, { appearance: m, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
1109
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Create account" }),
1110
- (t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */ i(
1350
+ [l]
1351
+ ), P = (t == null ? void 0 : t.googleEnabled) || (t == null ? void 0 : t.githubEnabled), I = x || c;
1352
+ return /* @__PURE__ */ s(q, { appearance: g, children: /* @__PURE__ */ n("div", { className: "ss-card", children: [
1353
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Create account" }),
1354
+ (t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */ n(
1111
1355
  "button",
1112
1356
  {
1113
1357
  type: "button",
1114
1358
  className: "ss-btn-social",
1115
- onClick: () => $("google"),
1116
- disabled: l,
1359
+ onClick: () => z("google"),
1360
+ disabled: i,
1117
1361
  children: [
1118
- /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: J } }),
1362
+ /* @__PURE__ */ s("span", { dangerouslySetInnerHTML: { __html: ne } }),
1119
1363
  "Continue with Google"
1120
1364
  ]
1121
1365
  }
1122
1366
  ),
1123
- (t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */ i(
1367
+ (t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */ n(
1124
1368
  "button",
1125
1369
  {
1126
1370
  type: "button",
1127
1371
  className: "ss-btn-social",
1128
- onClick: () => $("github"),
1129
- disabled: l,
1372
+ onClick: () => z("github"),
1373
+ disabled: i,
1130
1374
  children: [
1131
- /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: Q } }),
1375
+ /* @__PURE__ */ s("span", { dangerouslySetInnerHTML: { __html: oe } }),
1132
1376
  "Continue with GitHub"
1133
1377
  ]
1134
1378
  }
1135
1379
  ),
1136
- E && /* @__PURE__ */ e("div", { className: "ss-divider", children: "or" }),
1137
- z && /* @__PURE__ */ e("div", { className: "ss-global-error", children: z }),
1138
- /* @__PURE__ */ i("form", { onSubmit: w, children: [
1139
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1140
- /* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-email", children: "Email" }),
1141
- /* @__PURE__ */ e(
1380
+ P && /* @__PURE__ */ s("div", { className: "ss-divider", children: "or" }),
1381
+ I && /* @__PURE__ */ s("div", { className: "ss-global-error", children: I }),
1382
+ /* @__PURE__ */ n("form", { onSubmit: S, children: [
1383
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1384
+ /* @__PURE__ */ s("label", { className: "ss-label", htmlFor: "ss-signup-email", children: "Email" }),
1385
+ /* @__PURE__ */ s(
1142
1386
  "input",
1143
1387
  {
1144
1388
  id: "ss-signup-email",
@@ -1147,14 +1391,14 @@ function As({ appearance: s, signInUrl: a, onSignIn: r }) {
1147
1391
  autoComplete: "email",
1148
1392
  placeholder: "you@example.com",
1149
1393
  value: p,
1150
- onChange: (T) => h(T.target.value),
1394
+ onChange: (T) => f(T.target.value),
1151
1395
  required: !0
1152
1396
  }
1153
1397
  )
1154
1398
  ] }),
1155
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1156
- /* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-password", children: "Password" }),
1157
- /* @__PURE__ */ e(
1399
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1400
+ /* @__PURE__ */ s("label", { className: "ss-label", htmlFor: "ss-signup-password", children: "Password" }),
1401
+ /* @__PURE__ */ s(
1158
1402
  "input",
1159
1403
  {
1160
1404
  id: "ss-signup-password",
@@ -1162,17 +1406,17 @@ function As({ appearance: s, signInUrl: a, onSignIn: r }) {
1162
1406
  type: "password",
1163
1407
  autoComplete: "new-password",
1164
1408
  placeholder: "Create a password",
1165
- value: v,
1409
+ value: b,
1166
1410
  onChange: (T) => {
1167
- y(T.target.value), N(null);
1411
+ k(T.target.value), h(null);
1168
1412
  },
1169
1413
  required: !0
1170
1414
  }
1171
1415
  )
1172
1416
  ] }),
1173
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1174
- /* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-confirm", children: "Confirm password" }),
1175
- /* @__PURE__ */ e(
1417
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1418
+ /* @__PURE__ */ s("label", { className: "ss-label", htmlFor: "ss-signup-confirm", children: "Confirm password" }),
1419
+ /* @__PURE__ */ s(
1176
1420
  "input",
1177
1421
  {
1178
1422
  id: "ss-signup-confirm",
@@ -1180,399 +1424,765 @@ function As({ appearance: s, signInUrl: a, onSignIn: r }) {
1180
1424
  type: "password",
1181
1425
  autoComplete: "new-password",
1182
1426
  placeholder: "Confirm your password",
1183
- value: b,
1427
+ value: v,
1184
1428
  onChange: (T) => {
1185
- x(T.target.value), N(null);
1429
+ C(T.target.value), h(null);
1186
1430
  },
1187
1431
  required: !0
1188
1432
  }
1189
1433
  )
1190
1434
  ] }),
1191
- /* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l, children: [
1192
- l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
1435
+ /* @__PURE__ */ n("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: i, children: [
1436
+ i && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1193
1437
  "Create account"
1194
1438
  ] })
1195
1439
  ] }),
1196
- /* @__PURE__ */ i("div", { className: "ss-footer", children: [
1440
+ /* @__PURE__ */ n("div", { className: "ss-footer", children: [
1197
1441
  "Already have an account?",
1198
1442
  " ",
1199
- r ? /* @__PURE__ */ e("span", { className: "ss-link", onClick: r, children: "Sign in" }) : a ? /* @__PURE__ */ e("a", { className: "ss-link", href: a, children: "Sign in" }) : /* @__PURE__ */ e("span", { className: "ss-link", children: "Sign in" })
1443
+ r ? /* @__PURE__ */ s("span", { className: "ss-link", onClick: r, children: "Sign in" }) : a ? /* @__PURE__ */ s("a", { className: "ss-link", href: a, children: "Sign in" }) : /* @__PURE__ */ s("span", { className: "ss-link", children: "Sign in" })
1444
+ ] })
1445
+ ] }) });
1446
+ }
1447
+ const B = 256, R = 112;
1448
+ function $e({ file: e, onCrop: a, onCancel: r }) {
1449
+ const o = j(null), t = j(null), [u, i] = m(1), [c, d] = m({ x: 0, y: 0 }), [l, g] = m(!1), p = j({ x: 0, y: 0, ox: 0, oy: 0 }), [f, b] = m(!1);
1450
+ U(() => {
1451
+ const h = new Image(), S = URL.createObjectURL(e);
1452
+ return h.onload = () => {
1453
+ t.current = h, b(!0), d({ x: 0, y: 0 }), i(1);
1454
+ }, h.src = S, () => URL.revokeObjectURL(S);
1455
+ }, [e]), U(() => {
1456
+ if (!f || !t.current || !o.current) return;
1457
+ const h = o.current.getContext("2d");
1458
+ if (!h) return;
1459
+ const S = t.current;
1460
+ h.clearRect(0, 0, B, B), h.fillStyle = "#111", h.fillRect(0, 0, B, B);
1461
+ const z = Math.max(B / S.width, B / S.height) * u, P = S.width * z, I = S.height * z, T = (B - P) / 2 + c.x, w = (B - I) / 2 + c.y;
1462
+ h.save(), h.beginPath(), h.arc(B / 2, B / 2, R, 0, Math.PI * 2), h.clip(), h.drawImage(S, T, w, P, I), h.restore(), h.save(), h.fillStyle = "rgba(0, 0, 0, 0.6)", h.fillRect(0, 0, B, B), h.globalCompositeOperation = "destination-out", h.beginPath(), h.arc(B / 2, B / 2, R, 0, Math.PI * 2), h.fill(), h.restore(), h.save(), h.beginPath(), h.arc(B / 2, B / 2, R, 0, Math.PI * 2), h.clip(), h.drawImage(S, T, w, P, I), h.restore(), h.strokeStyle = "rgba(255, 255, 255, 0.6)", h.lineWidth = 2, h.beginPath(), h.arc(B / 2, B / 2, R, 0, Math.PI * 2), h.stroke();
1463
+ }, [u, c, f]);
1464
+ const k = N(
1465
+ (h) => {
1466
+ g(!0), p.current = { x: h.clientX, y: h.clientY, ox: c.x, oy: c.y }, h.target.setPointerCapture(h.pointerId);
1467
+ },
1468
+ [c]
1469
+ ), v = N(
1470
+ (h) => {
1471
+ l && d({
1472
+ x: p.current.ox + (h.clientX - p.current.x),
1473
+ y: p.current.oy + (h.clientY - p.current.y)
1474
+ });
1475
+ },
1476
+ [l]
1477
+ ), C = N(() => g(!1), []), x = N(() => {
1478
+ if (!t.current) return;
1479
+ const h = document.createElement("canvas"), S = R * 2;
1480
+ h.width = S, h.height = S;
1481
+ const z = h.getContext("2d");
1482
+ if (!z) return;
1483
+ const P = t.current, I = Math.max(B / P.width, B / P.height) * u, T = P.width * I, w = P.height * I, $ = (B - T) / 2 + c.x - (B / 2 - R), y = (B - w) / 2 + c.y - (B / 2 - R);
1484
+ z.beginPath(), z.arc(R, R, R, 0, Math.PI * 2), z.clip(), z.drawImage(P, $, y, T, w), h.toBlob((E) => {
1485
+ E && a(E);
1486
+ }, "image/png");
1487
+ }, [u, c, a]);
1488
+ return /* @__PURE__ */ n("div", { className: "ss-avatar-cropper", children: [
1489
+ /* @__PURE__ */ s(
1490
+ "canvas",
1491
+ {
1492
+ ref: o,
1493
+ width: B,
1494
+ height: B,
1495
+ className: "ss-avatar-canvas",
1496
+ onPointerDown: k,
1497
+ onPointerMove: v,
1498
+ onPointerUp: C,
1499
+ style: { cursor: l ? "grabbing" : "grab" }
1500
+ }
1501
+ ),
1502
+ /* @__PURE__ */ n("div", { className: "ss-avatar-zoom", children: [
1503
+ /* @__PURE__ */ s("span", { className: "ss-avatar-zoom-label", children: "Zoom" }),
1504
+ /* @__PURE__ */ s(
1505
+ "input",
1506
+ {
1507
+ type: "range",
1508
+ min: "1",
1509
+ max: "3",
1510
+ step: "0.01",
1511
+ value: u,
1512
+ onChange: (h) => i(parseFloat(h.target.value)),
1513
+ className: "ss-avatar-zoom-slider"
1514
+ }
1515
+ )
1516
+ ] }),
1517
+ /* @__PURE__ */ n("div", { className: "ss-btn-group", children: [
1518
+ /* @__PURE__ */ s("button", { type: "button", className: "ss-btn ss-btn-danger ss-btn-sm", onClick: r, children: "Cancel" }),
1519
+ /* @__PURE__ */ s("button", { type: "button", className: "ss-btn ss-btn-primary ss-btn-sm", onClick: x, children: "Save" })
1200
1520
  ] })
1521
+ ] });
1522
+ }
1523
+ function le({ onUpload: e, onClose: a, isLoading: r }) {
1524
+ const [o, t] = m(null), [u, i] = m(!1), [c, d] = m(null), l = j(null), g = N((b) => {
1525
+ if (!b.type.startsWith("image/")) {
1526
+ d("Please select an image file");
1527
+ return;
1528
+ }
1529
+ if (b.size > 5 * 1024 * 1024) {
1530
+ d("Image must be smaller than 5 MB");
1531
+ return;
1532
+ }
1533
+ d(null), t(b);
1534
+ }, []), p = N(
1535
+ (b) => {
1536
+ b.preventDefault(), i(!1);
1537
+ const k = b.dataTransfer.files[0];
1538
+ k && g(k);
1539
+ },
1540
+ [g]
1541
+ ), f = N(
1542
+ async (b) => {
1543
+ await e(b);
1544
+ },
1545
+ [e]
1546
+ );
1547
+ return /* @__PURE__ */ s("div", { className: "ss-modal-overlay", onClick: (b) => {
1548
+ b.target === b.currentTarget && a();
1549
+ }, children: /* @__PURE__ */ n("div", { className: "ss-modal", children: [
1550
+ /* @__PURE__ */ n("div", { className: "ss-modal-header", children: [
1551
+ /* @__PURE__ */ s("span", { className: "ss-modal-title", children: "Upload Avatar" }),
1552
+ /* @__PURE__ */ s("button", { type: "button", className: "ss-modal-close", onClick: a, children: "✕" })
1553
+ ] }),
1554
+ c && /* @__PURE__ */ s("div", { className: "ss-global-error", children: c }),
1555
+ o ? /* @__PURE__ */ s($e, { file: o, onCrop: f, onCancel: () => t(null) }) : /* @__PURE__ */ n(
1556
+ "div",
1557
+ {
1558
+ className: `ss-avatar-dropzone${u ? " ss-avatar-dropzone-active" : ""}`,
1559
+ onDragOver: (b) => {
1560
+ b.preventDefault(), i(!0);
1561
+ },
1562
+ onDragLeave: () => i(!1),
1563
+ onDrop: p,
1564
+ onClick: () => {
1565
+ var b;
1566
+ return (b = l.current) == null ? void 0 : b.click();
1567
+ },
1568
+ children: [
1569
+ /* @__PURE__ */ n("svg", { width: "40", height: "40", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
1570
+ /* @__PURE__ */ s("path", { d: "M12 16a4 4 0 100-8 4 4 0 000 8z" }),
1571
+ /* @__PURE__ */ s("path", { d: "M3 16.8V9.2c0-1.12 0-1.68.218-2.108a2 2 0 01.874-.874C4.52 6 5.08 6 6.2 6h.382c.246 0 .37 0 .482-.022a1 1 0 00.513-.29c.08-.082.148-.186.284-.392l.079-.118C8.08 4.968 8.15 4.863 8.234 4.77a2 2 0 01.965-.61C9.346 4.1 9.508 4.1 9.834 4.1h4.332c.326 0 .488 0 .636.06a2 2 0 01.965.61c.083.094.153.198.293.408l.079.118c.136.206.204.31.284.392a1 1 0 00.513.29c.112.022.236.022.482.022h.382c1.12 0 1.68 0 2.108.218a2 2 0 01.874.874C21 7.52 21 8.08 21 9.2v7.6c0 1.12 0 1.68-.218 2.108a2 2 0 01-.874.874C19.48 20 18.92 20 17.8 20H6.2c-1.12 0-1.68 0-2.108-.218a2 2 0 01-.874-.874C3 18.48 3 17.92 3 16.8z" })
1572
+ ] }),
1573
+ /* @__PURE__ */ s("span", { children: "Drop image here or click to browse" }),
1574
+ /* @__PURE__ */ s(
1575
+ "input",
1576
+ {
1577
+ ref: l,
1578
+ type: "file",
1579
+ accept: "image/*",
1580
+ style: { display: "none" },
1581
+ onChange: (b) => {
1582
+ var k;
1583
+ (k = b.target.files) != null && k[0] && g(b.target.files[0]);
1584
+ }
1585
+ }
1586
+ )
1587
+ ]
1588
+ }
1589
+ ),
1590
+ r && /* @__PURE__ */ s("div", { className: "ss-loading", children: "Uploading..." })
1201
1591
  ] }) });
1202
1592
  }
1203
- function Ds({ appearance: s }) {
1204
- const { appearance: a } = k(), { user: r, signOut: c } = j(), t = s ?? a, [d, l] = g(!1), [u, o] = g(!1), n = R(null), m = S((h) => {
1205
- n.current && !h.composedPath().includes(n.current) && l(!1);
1593
+ function ss({
1594
+ appearance: e,
1595
+ afterSignOutUrl: a,
1596
+ afterDeleteAccountUrl: r,
1597
+ showOrgSwitcher: o = !0,
1598
+ onOrgChange: t,
1599
+ onOrgSettingsClick: u
1600
+ }) {
1601
+ const { appearance: i } = L(), { user: c, signOut: d } = ee(), l = e ?? i, [g, p] = m(!1), [f, b] = m(!1), [k, v] = m(!1), [C, x] = m(""), [h, S] = m(""), [z, P] = m(null), [I, T] = m(!1), w = j(null), { orgs: $, selectedOrg: y, selectOrg: E, createOrg: M } = ae(), O = N((D) => {
1602
+ w.current && !D.composedPath().includes(w.current) && (p(!1), v(!1));
1206
1603
  }, []);
1207
- if (L(() => {
1208
- if (d) {
1209
- const h = setTimeout(() => {
1210
- document.addEventListener("click", m);
1604
+ U(() => {
1605
+ if (g) {
1606
+ const D = setTimeout(() => {
1607
+ document.addEventListener("click", O);
1211
1608
  }, 0);
1212
1609
  return () => {
1213
- clearTimeout(h), document.removeEventListener("click", m);
1610
+ clearTimeout(D), document.removeEventListener("click", O);
1214
1611
  };
1215
1612
  }
1216
- }, [d, m]), !r) return null;
1217
- const p = (r.name || r.email).charAt(0).toUpperCase();
1218
- return /* @__PURE__ */ e(B, { appearance: t, children: /* @__PURE__ */ i("div", { className: "ss-user-btn", ref: n, children: [
1219
- /* @__PURE__ */ e(
1613
+ }, [g, O]);
1614
+ const V = N((D) => {
1615
+ x(D), S(D.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""));
1616
+ }, []), F = N(
1617
+ async (D) => {
1618
+ D.preventDefault(), P(null), T(!0);
1619
+ try {
1620
+ const H = await M(C, h);
1621
+ H && (await E(H.id), t == null || t(H), v(!1), x(""), S(""), p(!1));
1622
+ } catch (H) {
1623
+ P(H instanceof Error ? H.message : "Failed to create organization");
1624
+ } finally {
1625
+ T(!1);
1626
+ }
1627
+ },
1628
+ [C, h, M, E, t]
1629
+ );
1630
+ if (!c) return null;
1631
+ const W = (c.name || c.email).charAt(0).toUpperCase();
1632
+ return /* @__PURE__ */ s(q, { appearance: l, children: /* @__PURE__ */ n("div", { className: "ss-user-btn", ref: w, children: [
1633
+ /* @__PURE__ */ s(
1220
1634
  "button",
1221
1635
  {
1222
1636
  type: "button",
1223
1637
  className: "ss-avatar",
1224
- onClick: () => l(!d),
1638
+ onClick: () => p(!g),
1225
1639
  "aria-label": "User menu",
1226
- children: r.avatarUrl ? /* @__PURE__ */ e("img", { src: r.avatarUrl, alt: "", style: { width: "100%", height: "100%", borderRadius: "50%", objectFit: "cover" } }) : p
1640
+ children: c.avatarUrl ? /* @__PURE__ */ s("img", { src: c.avatarUrl, alt: "", style: { width: "100%", height: "100%", borderRadius: "50%", objectFit: "cover" } }) : W
1227
1641
  }
1228
1642
  ),
1229
- d && /* @__PURE__ */ i("div", { className: "ss-dropdown", children: [
1230
- /* @__PURE__ */ i("div", { className: "ss-dropdown-header", children: [
1231
- r.name && /* @__PURE__ */ e("div", { style: { fontWeight: 600, fontSize: "14px", color: "inherit" }, children: r.name }),
1232
- /* @__PURE__ */ e("div", { className: "ss-dropdown-email", children: r.email })
1643
+ g && /* @__PURE__ */ n("div", { className: "ss-dropdown", children: [
1644
+ /* @__PURE__ */ n("div", { className: "ss-dropdown-header", children: [
1645
+ c.name && /* @__PURE__ */ s("div", { style: { fontWeight: 600, fontSize: "14px", color: "inherit" }, children: c.name }),
1646
+ /* @__PURE__ */ s("div", { className: "ss-dropdown-email", children: c.email })
1233
1647
  ] }),
1234
- /* @__PURE__ */ e(
1648
+ /* @__PURE__ */ s(
1235
1649
  "button",
1236
1650
  {
1237
1651
  type: "button",
1238
1652
  className: "ss-dropdown-item",
1239
1653
  onClick: () => {
1240
- l(!1), o(!0);
1654
+ p(!1), b(!0);
1241
1655
  },
1242
1656
  children: "Profile"
1243
1657
  }
1244
1658
  ),
1245
- /* @__PURE__ */ e(
1659
+ o && /* @__PURE__ */ n(G, { children: [
1660
+ /* @__PURE__ */ s("div", { className: "ss-dropdown-divider" }),
1661
+ /* @__PURE__ */ s("div", { className: "ss-dropdown-section-title", children: "Organizations" }),
1662
+ $.map((D) => /* @__PURE__ */ n(
1663
+ "button",
1664
+ {
1665
+ type: "button",
1666
+ className: `ss-dropdown-item${(y == null ? void 0 : y.id) === D.id ? " ss-dropdown-item-active" : ""}`,
1667
+ onClick: async () => {
1668
+ p(!1), v(!1), await E(D.id), t == null || t(D);
1669
+ },
1670
+ children: [
1671
+ (y == null ? void 0 : y.id) === D.id && /* @__PURE__ */ s("span", { className: "ss-org-check", children: "✓" }),
1672
+ D.name
1673
+ ]
1674
+ },
1675
+ D.id
1676
+ )),
1677
+ k ? /* @__PURE__ */ n("div", { className: "ss-inline-form", children: [
1678
+ z && /* @__PURE__ */ s("div", { className: "ss-global-error", style: { marginBottom: "8px", fontSize: "12px" }, children: z }),
1679
+ /* @__PURE__ */ n("form", { onSubmit: F, children: [
1680
+ /* @__PURE__ */ s("div", { className: "ss-field", children: /* @__PURE__ */ s(
1681
+ "input",
1682
+ {
1683
+ className: "ss-input",
1684
+ type: "text",
1685
+ placeholder: "Organization name",
1686
+ value: C,
1687
+ onChange: (D) => V(D.target.value),
1688
+ required: !0,
1689
+ autoFocus: !0
1690
+ }
1691
+ ) }),
1692
+ /* @__PURE__ */ s("div", { className: "ss-field", children: /* @__PURE__ */ s(
1693
+ "input",
1694
+ {
1695
+ className: "ss-input",
1696
+ type: "text",
1697
+ placeholder: "org-slug",
1698
+ value: h,
1699
+ onChange: (D) => S(D.target.value),
1700
+ required: !0
1701
+ }
1702
+ ) }),
1703
+ /* @__PURE__ */ n("div", { className: "ss-btn-group", style: { marginTop: "8px" }, children: [
1704
+ /* @__PURE__ */ s(
1705
+ "button",
1706
+ {
1707
+ type: "button",
1708
+ className: "ss-btn ss-btn-sm ss-btn-current",
1709
+ onClick: () => {
1710
+ v(!1), P(null);
1711
+ },
1712
+ children: "Cancel"
1713
+ }
1714
+ ),
1715
+ /* @__PURE__ */ n(
1716
+ "button",
1717
+ {
1718
+ type: "submit",
1719
+ className: "ss-btn ss-btn-sm ss-btn-primary",
1720
+ disabled: I,
1721
+ children: [
1722
+ I && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1723
+ "Create"
1724
+ ]
1725
+ }
1726
+ )
1727
+ ] })
1728
+ ] })
1729
+ ] }) : /* @__PURE__ */ s(
1730
+ "button",
1731
+ {
1732
+ type: "button",
1733
+ className: "ss-dropdown-item",
1734
+ onClick: () => v(!0),
1735
+ style: { fontWeight: 500 },
1736
+ children: "+ Create organization"
1737
+ }
1738
+ ),
1739
+ y && u && /* @__PURE__ */ s(
1740
+ "button",
1741
+ {
1742
+ type: "button",
1743
+ className: "ss-dropdown-item",
1744
+ onClick: () => {
1745
+ p(!1), u(y);
1746
+ },
1747
+ children: "Org settings"
1748
+ }
1749
+ )
1750
+ ] }),
1751
+ /* @__PURE__ */ s("div", { className: "ss-dropdown-divider" }),
1752
+ /* @__PURE__ */ s(
1246
1753
  "button",
1247
1754
  {
1248
1755
  type: "button",
1249
1756
  className: "ss-dropdown-item ss-dropdown-item-danger",
1250
1757
  onClick: async () => {
1251
- l(!1), await c();
1758
+ p(!1), await d(), a && (window.location.href = a);
1252
1759
  },
1253
1760
  children: "Sign out"
1254
1761
  }
1255
1762
  )
1256
1763
  ] }),
1257
- u && /* @__PURE__ */ e(ls, { onClose: () => o(!1) })
1764
+ f && /* @__PURE__ */ s(
1765
+ Ee,
1766
+ {
1767
+ onClose: () => b(!1),
1768
+ afterDeleteAccountUrl: r
1769
+ }
1770
+ )
1258
1771
  ] }) });
1259
1772
  }
1260
- function ls({ onClose: s }) {
1261
- const { user: a, updateProfile: r, changePassword: c, isLoading: t, error: d, success: l, setError: u, setSuccess: o } = G(), [n, m] = g((a == null ? void 0 : a.name) ?? ""), [p, h] = g((a == null ? void 0 : a.avatarUrl) ?? ""), [v, y] = g(""), [b, x] = g(""), [f, N] = g(""), [w, $] = g(null), E = S(
1262
- async (C) => {
1263
- C.preventDefault(), u(null), o(null), await r({ name: n, avatarUrl: p });
1773
+ function Ee({ onClose: e, afterDeleteAccountUrl: a }) {
1774
+ const { user: r, updateProfile: o, uploadAvatar: t, changePassword: u, isLoading: i, error: c, success: d, setError: l, setSuccess: g } = te(), { signOut: p } = ee(), { deleteAccount: f, isLoading: b, error: k, setError: v } = ke(), [C, x] = m((r == null ? void 0 : r.name) ?? ""), [h, S] = m((r == null ? void 0 : r.avatarUrl) ?? ""), [z, P] = m(!1), [I, T] = m(""), [w, $] = m(""), [y, E] = m(""), [M, O] = m(null), [V, F] = m(!1), [W, D] = m(""), H = N(
1775
+ async (A) => {
1776
+ A.preventDefault(), l(null), g(null), await o({ name: C, avatarUrl: h || void 0 });
1264
1777
  },
1265
- [n, p, r, u, o]
1266
- ), z = S(
1267
- async (C) => {
1268
- if (C.preventDefault(), $(null), u(null), o(null), b !== f) {
1269
- $("Passwords do not match");
1778
+ [C, h, o, l, g]
1779
+ ), ce = N(
1780
+ async (A) => {
1781
+ const Y = await t(A);
1782
+ Y && (S(Y.avatarUrl), P(!1));
1783
+ },
1784
+ [t]
1785
+ ), de = N(
1786
+ async (A) => {
1787
+ if (A.preventDefault(), O(null), l(null), g(null), w !== y) {
1788
+ O("Passwords do not match");
1270
1789
  return;
1271
1790
  }
1272
- if (b.length < 8) {
1273
- $("Password must be at least 8 characters");
1791
+ if (w.length < 8) {
1792
+ O("Password must be at least 8 characters");
1274
1793
  return;
1275
1794
  }
1276
- await c(v, b) && (y(""), x(""), N(""));
1795
+ await u(I, w) && (T(""), $(""), E(""));
1277
1796
  },
1278
- [v, b, f, c, u, o]
1279
- ), T = (a == null ? void 0 : a.provider) === "email";
1280
- return /* @__PURE__ */ e("div", { className: "ss-modal-overlay", onClick: (C) => {
1281
- C.target === C.currentTarget && s();
1282
- }, children: /* @__PURE__ */ i("div", { className: "ss-modal", children: [
1283
- /* @__PURE__ */ i("div", { className: "ss-modal-header", children: [
1284
- /* @__PURE__ */ e("span", { className: "ss-modal-title", children: "Profile" }),
1285
- /* @__PURE__ */ e("button", { type: "button", className: "ss-modal-close", onClick: s, children: "✕" })
1797
+ [I, w, y, u, l, g]
1798
+ ), ue = N(async () => {
1799
+ await f() && (await p(), a && (window.location.href = a));
1800
+ }, [f, p, a]), pe = (r == null ? void 0 : r.provider) === "email", me = W === (r == null ? void 0 : r.email);
1801
+ return /* @__PURE__ */ s("div", { className: "ss-modal-overlay", onClick: (A) => {
1802
+ A.target === A.currentTarget && e();
1803
+ }, children: /* @__PURE__ */ n("div", { className: "ss-modal", children: [
1804
+ /* @__PURE__ */ n("div", { className: "ss-modal-header", children: [
1805
+ /* @__PURE__ */ s("span", { className: "ss-modal-title", children: "Profile" }),
1806
+ /* @__PURE__ */ s("button", { type: "button", className: "ss-modal-close", onClick: e, children: "✕" })
1286
1807
  ] }),
1287
- d && /* @__PURE__ */ e("div", { className: "ss-global-error", children: d }),
1288
- l && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: l }),
1289
- /* @__PURE__ */ e("div", { className: "ss-avatar-preview", children: p ? /* @__PURE__ */ e("img", { src: p, alt: "" }) : (n || (a == null ? void 0 : a.email) || "?").charAt(0).toUpperCase() }),
1290
- /* @__PURE__ */ i("form", { onSubmit: E, children: [
1291
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1292
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Name" }),
1293
- /* @__PURE__ */ e(
1808
+ c && /* @__PURE__ */ s("div", { className: "ss-global-error", children: c }),
1809
+ d && /* @__PURE__ */ s("div", { className: "ss-success-msg", children: d }),
1810
+ /* @__PURE__ */ n(
1811
+ "div",
1812
+ {
1813
+ className: "ss-avatar-preview ss-avatar-hoverable",
1814
+ onClick: () => P(!0),
1815
+ title: "Click to change avatar",
1816
+ children: [
1817
+ h ? /* @__PURE__ */ s("img", { src: h, alt: "" }) : (C || (r == null ? void 0 : r.email) || "?").charAt(0).toUpperCase(),
1818
+ /* @__PURE__ */ s("div", { className: "ss-avatar-overlay", children: /* @__PURE__ */ n("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1819
+ /* @__PURE__ */ s("path", { d: "M12 16a4 4 0 100-8 4 4 0 000 8z" }),
1820
+ /* @__PURE__ */ s("path", { d: "M3 16.8V9.2c0-1.12 0-1.68.218-2.108a2 2 0 01.874-.874C4.52 6 5.08 6 6.2 6h.382c.246 0 .37 0 .482-.022a1 1 0 00.513-.29c.08-.082.148-.186.284-.392l.079-.118C8.08 4.968 8.15 4.863 8.234 4.77a2 2 0 01.965-.61C9.346 4.1 9.508 4.1 9.834 4.1h4.332c.326 0 .488 0 .636.06a2 2 0 01.965.61c.083.094.153.198.293.408l.079.118c.136.206.204.31.284.392a1 1 0 00.513.29c.112.022.236.022.482.022h.382c1.12 0 1.68 0 2.108.218a2 2 0 01.874.874C21 7.52 21 8.08 21 9.2v7.6c0 1.12 0 1.68-.218 2.108a2 2 0 01-.874.874C19.48 20 18.92 20 17.8 20H6.2c-1.12 0-1.68 0-2.108-.218a2 2 0 01-.874-.874C3 18.48 3 17.92 3 16.8z" })
1821
+ ] }) })
1822
+ ]
1823
+ }
1824
+ ),
1825
+ /* @__PURE__ */ n("form", { onSubmit: H, children: [
1826
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1827
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Name" }),
1828
+ /* @__PURE__ */ s(
1294
1829
  "input",
1295
1830
  {
1296
1831
  className: "ss-input",
1297
1832
  type: "text",
1298
1833
  placeholder: "Your name",
1299
- value: n,
1300
- onChange: (C) => m(C.target.value)
1834
+ value: C,
1835
+ onChange: (A) => x(A.target.value)
1301
1836
  }
1302
1837
  )
1303
1838
  ] }),
1304
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1305
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Avatar URL" }),
1306
- /* @__PURE__ */ e(
1307
- "input",
1308
- {
1309
- className: "ss-input",
1310
- type: "url",
1311
- placeholder: "https://example.com/avatar.jpg",
1312
- value: p,
1313
- onChange: (C) => h(C.target.value)
1314
- }
1315
- )
1839
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1840
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Email" }),
1841
+ /* @__PURE__ */ s("input", { className: "ss-input ss-input-readonly", type: "email", value: (r == null ? void 0 : r.email) ?? "", disabled: !0, readOnly: !0 })
1316
1842
  ] }),
1317
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1318
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Email" }),
1319
- /* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "email", value: (a == null ? void 0 : a.email) ?? "", disabled: !0, readOnly: !0 })
1843
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1844
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Provider" }),
1845
+ /* @__PURE__ */ s("input", { className: "ss-input ss-input-readonly", type: "text", value: (r == null ? void 0 : r.provider) ?? "", disabled: !0, readOnly: !0 })
1320
1846
  ] }),
1321
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1322
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Provider" }),
1323
- /* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: (a == null ? void 0 : a.provider) ?? "", disabled: !0, readOnly: !0 })
1324
- ] }),
1325
- /* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: t, children: [
1326
- t && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
1847
+ /* @__PURE__ */ n("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: i, children: [
1848
+ i && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1327
1849
  "Save changes"
1328
1850
  ] })
1329
1851
  ] }),
1330
- T && /* @__PURE__ */ i("div", { className: "ss-modal-section", children: [
1331
- /* @__PURE__ */ e("div", { className: "ss-modal-section-title", children: "Change password" }),
1332
- w && /* @__PURE__ */ e("div", { className: "ss-global-error", children: w }),
1333
- /* @__PURE__ */ i("form", { onSubmit: z, children: [
1334
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1335
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Current password" }),
1336
- /* @__PURE__ */ e(
1852
+ pe && /* @__PURE__ */ n("div", { className: "ss-modal-section", children: [
1853
+ /* @__PURE__ */ s("div", { className: "ss-modal-section-title", children: "Change password" }),
1854
+ M && /* @__PURE__ */ s("div", { className: "ss-global-error", children: M }),
1855
+ /* @__PURE__ */ n("form", { onSubmit: de, children: [
1856
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1857
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Current password" }),
1858
+ /* @__PURE__ */ s(
1337
1859
  "input",
1338
1860
  {
1339
1861
  className: "ss-input",
1340
1862
  type: "password",
1341
- value: v,
1342
- onChange: (C) => y(C.target.value),
1863
+ value: I,
1864
+ onChange: (A) => T(A.target.value),
1343
1865
  required: !0
1344
1866
  }
1345
1867
  )
1346
1868
  ] }),
1347
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1348
- /* @__PURE__ */ e("label", { className: "ss-label", children: "New password" }),
1349
- /* @__PURE__ */ e(
1869
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1870
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "New password" }),
1871
+ /* @__PURE__ */ s(
1350
1872
  "input",
1351
1873
  {
1352
1874
  className: "ss-input",
1353
1875
  type: "password",
1354
- value: b,
1355
- onChange: (C) => x(C.target.value),
1876
+ value: w,
1877
+ onChange: (A) => $(A.target.value),
1356
1878
  required: !0
1357
1879
  }
1358
1880
  )
1359
1881
  ] }),
1360
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1361
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Confirm new password" }),
1362
- /* @__PURE__ */ e(
1882
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1883
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Confirm new password" }),
1884
+ /* @__PURE__ */ s(
1363
1885
  "input",
1364
1886
  {
1365
1887
  className: "ss-input",
1366
1888
  type: "password",
1367
- value: f,
1368
- onChange: (C) => N(C.target.value),
1889
+ value: y,
1890
+ onChange: (A) => E(A.target.value),
1369
1891
  required: !0
1370
1892
  }
1371
1893
  )
1372
1894
  ] }),
1373
- /* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: t, children: [
1374
- t && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
1895
+ /* @__PURE__ */ n("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: i, children: [
1896
+ i && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1375
1897
  "Update password"
1376
1898
  ] })
1377
1899
  ] })
1378
- ] })
1900
+ ] }),
1901
+ /* @__PURE__ */ n("div", { className: "ss-danger-zone", children: [
1902
+ /* @__PURE__ */ s("div", { className: "ss-modal-section-title", children: "Danger zone" }),
1903
+ /* @__PURE__ */ s("p", { style: { fontSize: "13px", margin: "0 0 12px 0", opacity: 0.8 }, children: "Deleting your account is permanent. All organizations you own will also be deleted." }),
1904
+ k && /* @__PURE__ */ s("div", { className: "ss-global-error", children: k }),
1905
+ V ? /* @__PURE__ */ n("div", { children: [
1906
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
1907
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Type your email to confirm" }),
1908
+ /* @__PURE__ */ s(
1909
+ "input",
1910
+ {
1911
+ className: "ss-input",
1912
+ type: "email",
1913
+ placeholder: r == null ? void 0 : r.email,
1914
+ value: W,
1915
+ onChange: (A) => D(A.target.value),
1916
+ autoFocus: !0
1917
+ }
1918
+ )
1919
+ ] }),
1920
+ /* @__PURE__ */ n("div", { className: "ss-btn-group", style: { marginTop: "8px" }, children: [
1921
+ /* @__PURE__ */ s(
1922
+ "button",
1923
+ {
1924
+ type: "button",
1925
+ className: "ss-btn ss-btn-sm ss-btn-current",
1926
+ onClick: () => {
1927
+ F(!1), D(""), v(null);
1928
+ },
1929
+ children: "Cancel"
1930
+ }
1931
+ ),
1932
+ /* @__PURE__ */ n(
1933
+ "button",
1934
+ {
1935
+ type: "button",
1936
+ className: "ss-btn ss-btn-sm ss-btn-danger",
1937
+ disabled: !me || b,
1938
+ onClick: ue,
1939
+ children: [
1940
+ b && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1941
+ "Delete account"
1942
+ ]
1943
+ }
1944
+ )
1945
+ ] })
1946
+ ] }) : /* @__PURE__ */ s(
1947
+ "button",
1948
+ {
1949
+ type: "button",
1950
+ className: "ss-btn ss-btn-danger",
1951
+ onClick: () => F(!0),
1952
+ children: "Delete my account"
1953
+ }
1954
+ )
1955
+ ] }),
1956
+ z && /* @__PURE__ */ s(
1957
+ le,
1958
+ {
1959
+ onUpload: ce,
1960
+ onClose: () => P(!1),
1961
+ isLoading: i
1962
+ }
1963
+ )
1379
1964
  ] }) });
1380
1965
  }
1381
- function Fs({ appearance: s }) {
1382
- const { appearance: a } = k(), { user: r, signOut: c } = j(), { updateProfile: t, changePassword: d, isLoading: l, error: u, success: o, setError: n, setSuccess: m } = G(), p = s ?? a, [h, v] = g((r == null ? void 0 : r.name) ?? ""), [y, b] = g((r == null ? void 0 : r.avatarUrl) ?? ""), [x, f] = g(""), [N, w] = g(""), [$, E] = g(""), [z, T] = g(null), C = S(
1383
- async (I) => {
1384
- I.preventDefault(), n(null), m(null), await t({ name: h, avatarUrl: y });
1966
+ function rs({ appearance: e }) {
1967
+ const { appearance: a } = L(), { user: r, signOut: o } = ee(), { updateProfile: t, uploadAvatar: u, changePassword: i, isLoading: c, error: d, success: l, setError: g, setSuccess: p } = te(), f = e ?? a, [b, k] = m((r == null ? void 0 : r.name) ?? ""), [v, C] = m((r == null ? void 0 : r.avatarUrl) ?? ""), [x, h] = m(!1), [S, z] = m(""), [P, I] = m(""), [T, w] = m(""), [$, y] = m(null), E = N(
1968
+ async (F) => {
1969
+ F.preventDefault(), g(null), p(null), await t({ name: b, avatarUrl: v || void 0 });
1970
+ },
1971
+ [b, v, t, g, p]
1972
+ ), M = N(
1973
+ async (F) => {
1974
+ const W = await u(F);
1975
+ W && (C(W.avatarUrl), h(!1));
1385
1976
  },
1386
- [h, y, t, n, m]
1387
- ), q = S(
1388
- async (I) => {
1389
- if (I.preventDefault(), T(null), n(null), m(null), N !== $) {
1390
- T("Passwords do not match");
1977
+ [u]
1978
+ ), O = N(
1979
+ async (F) => {
1980
+ if (F.preventDefault(), y(null), g(null), p(null), P !== T) {
1981
+ y("Passwords do not match");
1391
1982
  return;
1392
1983
  }
1393
- if (N.length < 8) {
1394
- T("Password must be at least 8 characters");
1984
+ if (P.length < 8) {
1985
+ y("Password must be at least 8 characters");
1395
1986
  return;
1396
1987
  }
1397
- await d(x, N) && (f(""), w(""), E(""));
1988
+ await i(S, P) && (z(""), I(""), w(""));
1398
1989
  },
1399
- [x, N, $, d, n, m]
1990
+ [S, P, T, i, g, p]
1400
1991
  );
1401
1992
  if (!r) return null;
1402
- const P = r.provider === "email";
1403
- return /* @__PURE__ */ e(B, { appearance: p, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
1404
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Profile" }),
1405
- u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
1406
- o && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: o }),
1407
- /* @__PURE__ */ e("div", { className: "ss-avatar-preview", style: { margin: "0 auto 16px" }, children: y ? /* @__PURE__ */ e("img", { src: y, alt: "" }) : (h || r.email).charAt(0).toUpperCase() }),
1408
- /* @__PURE__ */ i("form", { onSubmit: C, children: [
1409
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1410
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Name" }),
1411
- /* @__PURE__ */ e("input", { className: "ss-input", type: "text", placeholder: "Your name", value: h, onChange: (I) => v(I.target.value) })
1412
- ] }),
1413
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1414
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Avatar URL" }),
1415
- /* @__PURE__ */ e("input", { className: "ss-input", type: "url", placeholder: "https://example.com/avatar.jpg", value: y, onChange: (I) => b(I.target.value) })
1993
+ const V = r.provider === "email";
1994
+ return /* @__PURE__ */ s(q, { appearance: f, children: /* @__PURE__ */ n("div", { className: "ss-card ss-card-wide", children: [
1995
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Profile" }),
1996
+ d && /* @__PURE__ */ s("div", { className: "ss-global-error", children: d }),
1997
+ l && /* @__PURE__ */ s("div", { className: "ss-success-msg", children: l }),
1998
+ /* @__PURE__ */ n(
1999
+ "div",
2000
+ {
2001
+ className: "ss-avatar-preview ss-avatar-hoverable",
2002
+ style: { margin: "0 auto 16px" },
2003
+ onClick: () => h(!0),
2004
+ title: "Click to change avatar",
2005
+ children: [
2006
+ v ? /* @__PURE__ */ s("img", { src: v, alt: "" }) : (b || r.email).charAt(0).toUpperCase(),
2007
+ /* @__PURE__ */ s("div", { className: "ss-avatar-overlay", children: /* @__PURE__ */ n("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
2008
+ /* @__PURE__ */ s("path", { d: "M12 16a4 4 0 100-8 4 4 0 000 8z" }),
2009
+ /* @__PURE__ */ s("path", { d: "M3 16.8V9.2c0-1.12 0-1.68.218-2.108a2 2 0 01.874-.874C4.52 6 5.08 6 6.2 6h.382c.246 0 .37 0 .482-.022a1 1 0 00.513-.29c.08-.082.148-.186.284-.392l.079-.118C8.08 4.968 8.15 4.863 8.234 4.77a2 2 0 01.965-.61C9.346 4.1 9.508 4.1 9.834 4.1h4.332c.326 0 .488 0 .636.06a2 2 0 01.965.61c.083.094.153.198.293.408l.079.118c.136.206.204.31.284.392a1 1 0 00.513.29c.112.022.236.022.482.022h.382c1.12 0 1.68 0 2.108.218a2 2 0 01.874.874C21 7.52 21 8.08 21 9.2v7.6c0 1.12 0 1.68-.218 2.108a2 2 0 01-.874.874C19.48 20 18.92 20 17.8 20H6.2c-1.12 0-1.68 0-2.108-.218a2 2 0 01-.874-.874C3 18.48 3 17.92 3 16.8z" })
2010
+ ] }) })
2011
+ ]
2012
+ }
2013
+ ),
2014
+ /* @__PURE__ */ n("form", { onSubmit: E, children: [
2015
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2016
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Name" }),
2017
+ /* @__PURE__ */ s("input", { className: "ss-input", type: "text", placeholder: "Your name", value: b, onChange: (F) => k(F.target.value) })
1416
2018
  ] }),
1417
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1418
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Email" }),
1419
- /* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "email", value: r.email, disabled: !0, readOnly: !0 })
2019
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2020
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Email" }),
2021
+ /* @__PURE__ */ s("input", { className: "ss-input ss-input-readonly", type: "email", value: r.email, disabled: !0, readOnly: !0 })
1420
2022
  ] }),
1421
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1422
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Provider" }),
1423
- /* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: r.provider, disabled: !0, readOnly: !0 })
2023
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2024
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Provider" }),
2025
+ /* @__PURE__ */ s("input", { className: "ss-input ss-input-readonly", type: "text", value: r.provider, disabled: !0, readOnly: !0 })
1424
2026
  ] }),
1425
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1426
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Email verified" }),
1427
- /* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: r.emailVerified ? "Yes" : "No", disabled: !0, readOnly: !0 })
2027
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2028
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Email verified" }),
2029
+ /* @__PURE__ */ s("input", { className: "ss-input ss-input-readonly", type: "text", value: r.emailVerified ? "Yes" : "No", disabled: !0, readOnly: !0 })
1428
2030
  ] }),
1429
- /* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l, children: [
1430
- l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2031
+ /* @__PURE__ */ n("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: c, children: [
2032
+ c && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1431
2033
  "Save changes"
1432
2034
  ] })
1433
2035
  ] }),
1434
- P && /* @__PURE__ */ i("div", { className: "ss-modal-section", children: [
1435
- /* @__PURE__ */ e("div", { className: "ss-modal-section-title", children: "Change password" }),
1436
- z && /* @__PURE__ */ e("div", { className: "ss-global-error", children: z }),
1437
- /* @__PURE__ */ i("form", { onSubmit: q, children: [
1438
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1439
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Current password" }),
1440
- /* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: x, onChange: (I) => f(I.target.value), required: !0 })
2036
+ V && /* @__PURE__ */ n("div", { className: "ss-modal-section", children: [
2037
+ /* @__PURE__ */ s("div", { className: "ss-modal-section-title", children: "Change password" }),
2038
+ $ && /* @__PURE__ */ s("div", { className: "ss-global-error", children: $ }),
2039
+ /* @__PURE__ */ n("form", { onSubmit: O, children: [
2040
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2041
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Current password" }),
2042
+ /* @__PURE__ */ s("input", { className: "ss-input", type: "password", value: S, onChange: (F) => z(F.target.value), required: !0 })
1441
2043
  ] }),
1442
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1443
- /* @__PURE__ */ e("label", { className: "ss-label", children: "New password" }),
1444
- /* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: N, onChange: (I) => w(I.target.value), required: !0 })
2044
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2045
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "New password" }),
2046
+ /* @__PURE__ */ s("input", { className: "ss-input", type: "password", value: P, onChange: (F) => I(F.target.value), required: !0 })
1445
2047
  ] }),
1446
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1447
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Confirm new password" }),
1448
- /* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: $, onChange: (I) => E(I.target.value), required: !0 })
2048
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2049
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Confirm new password" }),
2050
+ /* @__PURE__ */ s("input", { className: "ss-input", type: "password", value: T, onChange: (F) => w(F.target.value), required: !0 })
1449
2051
  ] }),
1450
- /* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l, children: [
1451
- l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2052
+ /* @__PURE__ */ n("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: c, children: [
2053
+ c && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1452
2054
  "Update password"
1453
2055
  ] })
1454
2056
  ] })
1455
2057
  ] }),
1456
- /* @__PURE__ */ e("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: () => c(), children: "Sign out" }) })
2058
+ /* @__PURE__ */ s("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ s("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: () => o(), children: "Sign out" }) }),
2059
+ x && /* @__PURE__ */ s(
2060
+ le,
2061
+ {
2062
+ onUpload: M,
2063
+ onClose: () => h(!1),
2064
+ isLoading: c
2065
+ }
2066
+ )
1457
2067
  ] }) });
1458
2068
  }
1459
- function Ms({ appearance: s, onOrgChange: a }) {
1460
- const { appearance: r } = k(), { orgs: c, selectedOrg: t, selectOrg: d, createOrg: l, isLoading: u } = os(), o = s ?? r, [n, m] = g(!1), [p, h] = g(!1), [v, y] = g(""), [b, x] = g(""), [f, N] = g(null), [w, $] = g(!1), E = R(null), z = S((P) => {
1461
- E.current && !P.composedPath().includes(E.current) && (m(!1), h(!1));
2069
+ function as({ appearance: e, onOrgChange: a }) {
2070
+ const { appearance: r } = L(), { orgs: o, selectedOrg: t, selectOrg: u, createOrg: i, isLoading: c } = ae(), d = e ?? r, [l, g] = m(!1), [p, f] = m(!1), [b, k] = m(""), [v, C] = m(""), [x, h] = m(null), [S, z] = m(!1), P = j(null), I = N((y) => {
2071
+ P.current && !y.composedPath().includes(P.current) && (g(!1), f(!1));
1462
2072
  }, []);
1463
- L(() => {
1464
- if (n) {
1465
- const P = setTimeout(() => {
1466
- document.addEventListener("click", z);
2073
+ U(() => {
2074
+ if (l) {
2075
+ const y = setTimeout(() => {
2076
+ document.addEventListener("click", I);
1467
2077
  }, 0);
1468
2078
  return () => {
1469
- clearTimeout(P), document.removeEventListener("click", z);
2079
+ clearTimeout(y), document.removeEventListener("click", I);
1470
2080
  };
1471
2081
  }
1472
- }, [n, z]);
1473
- const T = S((P) => {
1474
- y(P), x(P.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""));
1475
- }, []), C = S(
1476
- async (P) => {
1477
- P.preventDefault(), N(null), $(!0);
2082
+ }, [l, I]);
2083
+ const T = N((y) => {
2084
+ k(y), C(y.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""));
2085
+ }, []), w = N(
2086
+ async (y) => {
2087
+ y.preventDefault(), h(null), z(!0);
1478
2088
  try {
1479
- const I = await l(v, b);
1480
- I && (await d(I.id), a == null || a(I), h(!1), y(""), x(""), m(!1));
1481
- } catch (I) {
1482
- N(I instanceof Error ? I.message : "Failed to create organization");
2089
+ const E = await i(b, v);
2090
+ E && (await u(E.id), a == null || a(E), f(!1), k(""), C(""), g(!1));
2091
+ } catch (E) {
2092
+ h(E instanceof Error ? E.message : "Failed to create organization");
1483
2093
  } finally {
1484
- $(!1);
2094
+ z(!1);
1485
2095
  }
1486
2096
  },
1487
- [v, b, l, d, a]
2097
+ [b, v, i, u, a]
1488
2098
  );
1489
- if (u) return null;
1490
- const q = (t == null ? void 0 : t.name) ?? (c.length === 0 ? "No organization" : "Select organization");
1491
- return /* @__PURE__ */ e(B, { appearance: o, children: /* @__PURE__ */ i("div", { className: "ss-user-btn", ref: E, children: [
1492
- /* @__PURE__ */ i(
2099
+ if (c) return null;
2100
+ const $ = (t == null ? void 0 : t.name) ?? (o.length === 0 ? "No organization" : "Select organization");
2101
+ return /* @__PURE__ */ s(q, { appearance: d, children: /* @__PURE__ */ n("div", { className: "ss-user-btn", ref: P, children: [
2102
+ /* @__PURE__ */ n(
1493
2103
  "button",
1494
2104
  {
1495
2105
  type: "button",
1496
2106
  className: "ss-btn ss-btn-org-switcher",
1497
- onClick: () => m(!n),
2107
+ onClick: () => g(!l),
1498
2108
  children: [
1499
- q,
1500
- /* @__PURE__ */ e("span", { className: "ss-chevron", children: n ? "▲" : "▼" })
2109
+ $,
2110
+ /* @__PURE__ */ s("span", { className: "ss-chevron", children: l ? "▲" : "▼" })
1501
2111
  ]
1502
2112
  }
1503
2113
  ),
1504
- n && /* @__PURE__ */ i("div", { className: "ss-dropdown ss-dropdown-org", children: [
1505
- c.map((P) => /* @__PURE__ */ e(
2114
+ l && /* @__PURE__ */ n("div", { className: "ss-dropdown ss-dropdown-org", children: [
2115
+ o.map((y) => /* @__PURE__ */ s(
1506
2116
  "button",
1507
2117
  {
1508
2118
  type: "button",
1509
- className: `ss-dropdown-item ${(t == null ? void 0 : t.id) === P.id ? "ss-dropdown-item-active" : ""}`,
2119
+ className: `ss-dropdown-item ${(t == null ? void 0 : t.id) === y.id ? "ss-dropdown-item-active" : ""}`,
1510
2120
  onClick: async () => {
1511
- m(!1), h(!1), await d(P.id), a == null || a(P);
2121
+ g(!1), f(!1), await u(y.id), a == null || a(y);
1512
2122
  },
1513
- children: P.name
2123
+ children: y.name
1514
2124
  },
1515
- P.id
2125
+ y.id
1516
2126
  )),
1517
- /* @__PURE__ */ e("div", { className: "ss-dropdown-divider" }),
1518
- p ? /* @__PURE__ */ i("div", { className: "ss-inline-form", children: [
1519
- f && /* @__PURE__ */ e("div", { className: "ss-global-error", style: { marginBottom: "8px", fontSize: "12px" }, children: f }),
1520
- /* @__PURE__ */ i("form", { onSubmit: C, children: [
1521
- /* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
2127
+ /* @__PURE__ */ s("div", { className: "ss-dropdown-divider" }),
2128
+ p ? /* @__PURE__ */ n("div", { className: "ss-inline-form", children: [
2129
+ x && /* @__PURE__ */ s("div", { className: "ss-global-error", style: { marginBottom: "8px", fontSize: "12px" }, children: x }),
2130
+ /* @__PURE__ */ n("form", { onSubmit: w, children: [
2131
+ /* @__PURE__ */ s("div", { className: "ss-field", children: /* @__PURE__ */ s(
1522
2132
  "input",
1523
2133
  {
1524
2134
  className: "ss-input",
1525
2135
  type: "text",
1526
2136
  placeholder: "Organization name",
1527
- value: v,
1528
- onChange: (P) => T(P.target.value),
2137
+ value: b,
2138
+ onChange: (y) => T(y.target.value),
1529
2139
  required: !0,
1530
2140
  autoFocus: !0
1531
2141
  }
1532
2142
  ) }),
1533
- /* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
2143
+ /* @__PURE__ */ s("div", { className: "ss-field", children: /* @__PURE__ */ s(
1534
2144
  "input",
1535
2145
  {
1536
2146
  className: "ss-input",
1537
2147
  type: "text",
1538
2148
  placeholder: "org-slug",
1539
- value: b,
1540
- onChange: (P) => x(P.target.value),
2149
+ value: v,
2150
+ onChange: (y) => C(y.target.value),
1541
2151
  required: !0
1542
2152
  }
1543
2153
  ) }),
1544
- /* @__PURE__ */ i("div", { className: "ss-btn-group", style: { marginTop: "8px" }, children: [
1545
- /* @__PURE__ */ e(
2154
+ /* @__PURE__ */ n("div", { className: "ss-btn-group", style: { marginTop: "8px" }, children: [
2155
+ /* @__PURE__ */ s(
1546
2156
  "button",
1547
2157
  {
1548
2158
  type: "button",
1549
2159
  className: "ss-btn ss-btn-sm ss-btn-current",
1550
2160
  onClick: () => {
1551
- h(!1), N(null);
2161
+ f(!1), h(null);
1552
2162
  },
1553
2163
  children: "Cancel"
1554
2164
  }
1555
2165
  ),
1556
- /* @__PURE__ */ i(
2166
+ /* @__PURE__ */ n(
1557
2167
  "button",
1558
2168
  {
1559
2169
  type: "submit",
1560
2170
  className: "ss-btn ss-btn-sm ss-btn-primary",
1561
- disabled: w,
2171
+ disabled: S,
1562
2172
  children: [
1563
- w && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2173
+ S && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1564
2174
  "Create"
1565
2175
  ]
1566
2176
  }
1567
2177
  )
1568
2178
  ] })
1569
2179
  ] })
1570
- ] }) : /* @__PURE__ */ e(
2180
+ ] }) : /* @__PURE__ */ s(
1571
2181
  "button",
1572
2182
  {
1573
2183
  type: "button",
1574
2184
  className: "ss-dropdown-item",
1575
- onClick: () => h(!0),
2185
+ onClick: () => f(!0),
1576
2186
  style: { fontWeight: 500 },
1577
2187
  children: "+ Create organization"
1578
2188
  }
@@ -1580,636 +2190,636 @@ function Ms({ appearance: s, onOrgChange: a }) {
1580
2190
  ] })
1581
2191
  ] }) });
1582
2192
  }
1583
- function is(s, a = "USD") {
2193
+ function Pe(e, a = "USD") {
1584
2194
  return new Intl.NumberFormat("en-US", {
1585
2195
  style: "currency",
1586
2196
  currency: a,
1587
- minimumFractionDigits: s % 100 === 0 ? 0 : 2
1588
- }).format(s / 100);
2197
+ minimumFractionDigits: e % 100 === 0 ? 0 : 2
2198
+ }).format(e / 100);
1589
2199
  }
1590
- function Us({ plans: s, currentPlanId: a, onSelectPlan: r, interval: c, appearance: t }) {
1591
- const { appearance: d } = k(), l = t ?? d, u = c ? s.filter((o) => o.interval === c || o.isFree) : s;
1592
- return /* @__PURE__ */ e(B, { appearance: l, children: /* @__PURE__ */ e("div", { className: "ss-pricing-grid", children: u.map((o) => {
1593
- const n = o.id === a;
1594
- return /* @__PURE__ */ i("div", { className: `ss-pricing-card ${n ? "ss-pricing-card-current" : ""}`, children: [
1595
- /* @__PURE__ */ i("div", { className: "ss-pricing-header", children: [
1596
- /* @__PURE__ */ e("h3", { className: "ss-pricing-name", children: o.name }),
1597
- o.trialDays > 0 && /* @__PURE__ */ i("span", { className: "ss-badge ss-badge-trialing", children: [
1598
- o.trialDays,
2200
+ function ts({ plans: e, currentPlanId: a, onSelectPlan: r, interval: o, appearance: t }) {
2201
+ const { appearance: u } = L(), i = t ?? u, c = o ? e.filter((d) => d.interval === o || d.isFree) : e;
2202
+ return /* @__PURE__ */ s(q, { appearance: i, children: /* @__PURE__ */ s("div", { className: "ss-pricing-grid", children: c.map((d) => {
2203
+ const l = d.id === a;
2204
+ return /* @__PURE__ */ n("div", { className: `ss-pricing-card ${l ? "ss-pricing-card-current" : ""}`, children: [
2205
+ /* @__PURE__ */ n("div", { className: "ss-pricing-header", children: [
2206
+ /* @__PURE__ */ s("h3", { className: "ss-pricing-name", children: d.name }),
2207
+ d.trialDays > 0 && /* @__PURE__ */ n("span", { className: "ss-badge ss-badge-trialing", children: [
2208
+ d.trialDays,
1599
2209
  "-day trial"
1600
2210
  ] }),
1601
- o.isFree && /* @__PURE__ */ e("span", { className: "ss-badge ss-badge-active", children: "Free" })
2211
+ d.isFree && /* @__PURE__ */ s("span", { className: "ss-badge ss-badge-active", children: "Free" })
1602
2212
  ] }),
1603
- /* @__PURE__ */ e("div", { className: "ss-pricing-price", children: o.isFree ? /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: "Free" }) : /* @__PURE__ */ i(D, { children: [
1604
- /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: is(o.amountCents, o.currency) }),
1605
- /* @__PURE__ */ i("span", { className: "ss-pricing-interval", children: [
2213
+ /* @__PURE__ */ s("div", { className: "ss-pricing-price", children: d.isFree ? /* @__PURE__ */ s("span", { className: "ss-pricing-amount", children: "Free" }) : /* @__PURE__ */ n(G, { children: [
2214
+ /* @__PURE__ */ s("span", { className: "ss-pricing-amount", children: Pe(d.amountCents, d.currency) }),
2215
+ /* @__PURE__ */ n("span", { className: "ss-pricing-interval", children: [
1606
2216
  "/",
1607
- o.interval
2217
+ d.interval
1608
2218
  ] })
1609
2219
  ] }) }),
1610
- o.description && /* @__PURE__ */ e("p", { className: "ss-pricing-desc", children: o.description }),
1611
- o.features.length > 0 && /* @__PURE__ */ e("ul", { className: "ss-pricing-features", children: o.features.map((m, p) => /* @__PURE__ */ i("li", { className: "ss-pricing-feature", children: [
1612
- /* @__PURE__ */ e("span", { className: "ss-check", children: "✓" }),
2220
+ d.description && /* @__PURE__ */ s("p", { className: "ss-pricing-desc", children: d.description }),
2221
+ d.features.length > 0 && /* @__PURE__ */ s("ul", { className: "ss-pricing-features", children: d.features.map((g, p) => /* @__PURE__ */ n("li", { className: "ss-pricing-feature", children: [
2222
+ /* @__PURE__ */ s("span", { className: "ss-check", children: "✓" }),
1613
2223
  " ",
1614
- m
2224
+ g
1615
2225
  ] }, p)) }),
1616
- /* @__PURE__ */ e(
2226
+ /* @__PURE__ */ s(
1617
2227
  "button",
1618
2228
  {
1619
2229
  type: "button",
1620
- className: `ss-btn ${n ? "ss-btn-current" : "ss-btn-primary"}`,
1621
- disabled: n,
1622
- onClick: () => r(o.id),
1623
- children: n ? "Current plan" : "Select plan"
2230
+ className: `ss-btn ${l ? "ss-btn-current" : "ss-btn-primary"}`,
2231
+ disabled: l,
2232
+ onClick: () => r(d.id),
2233
+ children: l ? "Current plan" : "Select plan"
1624
2234
  }
1625
2235
  )
1626
- ] }, o.id);
2236
+ ] }, d.id);
1627
2237
  }) }) });
1628
2238
  }
1629
- function Os() {
1630
- const { client: s } = k();
1631
- return { billing: s.billing };
2239
+ function ns() {
2240
+ const { client: e } = L();
2241
+ return { billing: e.billing };
1632
2242
  }
1633
- function M(s) {
1634
- const { client: a } = k();
1635
- return A(() => {
1636
- if (s) {
1637
- const r = new F("https://api.saas-support.com/v1", { type: "portalToken", token: s });
1638
- return new ss(r);
2243
+ function Q(e) {
2244
+ const { client: a } = L();
2245
+ return _(() => {
2246
+ if (e) {
2247
+ const r = new J("https://api.saas-support.com/v1", { type: "portalToken", token: e });
2248
+ return new ye(r);
1639
2249
  }
1640
2250
  return a.billing;
1641
- }, [a, s]);
2251
+ }, [a, e]);
1642
2252
  }
1643
- function cs(s, a) {
1644
- const r = M(a), [c, t] = g(null), [d, l] = g(!0), [u, o] = g(null), n = S(async () => {
1645
- l(!0), o(null);
2253
+ function ze(e, a) {
2254
+ const r = Q(a), [o, t] = m(null), [u, i] = m(!0), [c, d] = m(null), l = N(async () => {
2255
+ i(!0), d(null);
1646
2256
  try {
1647
- const m = await r.getCustomer(s);
1648
- t(m);
1649
- } catch (m) {
1650
- o(m instanceof Error ? m.message : "Failed to load subscription");
2257
+ const g = await r.getCustomer(e);
2258
+ t(g);
2259
+ } catch (g) {
2260
+ d(g instanceof Error ? g.message : "Failed to load subscription");
1651
2261
  } finally {
1652
- l(!1);
2262
+ i(!1);
1653
2263
  }
1654
- }, [r, s]);
1655
- return L(() => {
1656
- n();
1657
- }, [n]), { customer: c, isLoading: d, error: u, refresh: n };
2264
+ }, [r, e]);
2265
+ return U(() => {
2266
+ l();
2267
+ }, [l]), { customer: o, isLoading: u, error: c, refresh: l };
1658
2268
  }
1659
- function ds(s, a) {
1660
- const r = M(a), [c, t] = g([]), [d, l] = g(!0), [u, o] = g(null), n = S(async () => {
1661
- l(!0), o(null);
2269
+ function Ie(e, a) {
2270
+ const r = Q(a), [o, t] = m([]), [u, i] = m(!0), [c, d] = m(null), l = N(async () => {
2271
+ i(!0), d(null);
1662
2272
  try {
1663
- const m = await r.getInvoices(s);
1664
- t(m);
1665
- } catch (m) {
1666
- o(m instanceof Error ? m.message : "Failed to load invoices");
2273
+ const g = await r.getInvoices(e);
2274
+ t(g);
2275
+ } catch (g) {
2276
+ d(g instanceof Error ? g.message : "Failed to load invoices");
1667
2277
  } finally {
1668
- l(!1);
2278
+ i(!1);
1669
2279
  }
1670
- }, [r, s]);
1671
- return L(() => {
1672
- n();
1673
- }, [n]), { invoices: c, isLoading: d, error: u, refresh: n };
2280
+ }, [r, e]);
2281
+ return U(() => {
2282
+ l();
2283
+ }, [l]), { invoices: o, isLoading: u, error: c, refresh: l };
1674
2284
  }
1675
- function us(s, a) {
1676
- const r = M(a), [c, t] = g([]), [d, l] = g(!0), [u, o] = g(null), n = S(async () => {
1677
- l(!0), o(null);
2285
+ function Te(e, a) {
2286
+ const r = Q(a), [o, t] = m([]), [u, i] = m(!0), [c, d] = m(null), l = N(async () => {
2287
+ i(!0), d(null);
1678
2288
  try {
1679
- const m = await r.getCurrentUsage(s);
1680
- t(m);
1681
- } catch (m) {
1682
- o(m instanceof Error ? m.message : "Failed to load usage");
2289
+ const g = await r.getCurrentUsage(e);
2290
+ t(g);
2291
+ } catch (g) {
2292
+ d(g instanceof Error ? g.message : "Failed to load usage");
1683
2293
  } finally {
1684
- l(!1);
2294
+ i(!1);
1685
2295
  }
1686
- }, [r, s]);
1687
- return L(() => {
1688
- n();
1689
- }, [n]), { usage: c, isLoading: d, error: u, refresh: n };
2296
+ }, [r, e]);
2297
+ return U(() => {
2298
+ l();
2299
+ }, [l]), { usage: o, isLoading: u, error: c, refresh: l };
1690
2300
  }
1691
- const ps = {
2301
+ const Le = {
1692
2302
  active: "ss-badge-active"
1693
2303
  };
1694
- function ms({
1695
- customerId: s,
2304
+ function Be({
2305
+ customerId: e,
1696
2306
  portalToken: a,
1697
2307
  onChangePlan: r,
1698
- onCancel: c,
2308
+ onCancel: o,
1699
2309
  appearance: t
1700
2310
  }) {
1701
- const { appearance: d } = k(), { customer: l, isLoading: u, error: o } = cs(s, a);
1702
- return /* @__PURE__ */ e(B, { appearance: t ?? d, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
1703
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Subscription" }),
1704
- u && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
1705
- /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2311
+ const { appearance: u } = L(), { customer: i, isLoading: c, error: d } = ze(e, a);
2312
+ return /* @__PURE__ */ s(q, { appearance: t ?? u, children: /* @__PURE__ */ n("div", { className: "ss-card", children: [
2313
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Subscription" }),
2314
+ c && /* @__PURE__ */ n("div", { className: "ss-loading", children: [
2315
+ /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1706
2316
  " Loading..."
1707
2317
  ] }),
1708
- o && /* @__PURE__ */ e("div", { className: "ss-global-error", children: o }),
1709
- l && !u && /* @__PURE__ */ i(D, { children: [
1710
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1711
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Customer" }),
1712
- /* @__PURE__ */ e("input", { className: "ss-input", value: l.name || l.email, disabled: !0, readOnly: !0 })
2318
+ d && /* @__PURE__ */ s("div", { className: "ss-global-error", children: d }),
2319
+ i && !c && /* @__PURE__ */ n(G, { children: [
2320
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2321
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Customer" }),
2322
+ /* @__PURE__ */ s("input", { className: "ss-input", value: i.name || i.email, disabled: !0, readOnly: !0 })
1713
2323
  ] }),
1714
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1715
- /* @__PURE__ */ e("label", { className: "ss-label", children: "Status" }),
1716
- /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("span", { className: `ss-badge ${ps.active}`, children: "Active" }) })
2324
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2325
+ /* @__PURE__ */ s("label", { className: "ss-label", children: "Status" }),
2326
+ /* @__PURE__ */ s("div", { children: /* @__PURE__ */ s("span", { className: `ss-badge ${Le.active}`, children: "Active" }) })
1717
2327
  ] }),
1718
- /* @__PURE__ */ i("div", { className: "ss-btn-group", children: [
1719
- r && /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-primary", onClick: r, children: "Change plan" }),
1720
- c && /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: c, children: "Cancel subscription" })
2328
+ /* @__PURE__ */ n("div", { className: "ss-btn-group", children: [
2329
+ r && /* @__PURE__ */ s("button", { type: "button", className: "ss-btn ss-btn-primary", onClick: r, children: "Change plan" }),
2330
+ o && /* @__PURE__ */ s("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: o, children: "Cancel subscription" })
1721
2331
  ] })
1722
2332
  ] })
1723
2333
  ] }) });
1724
2334
  }
1725
- const gs = {
2335
+ const De = {
1726
2336
  paid: "ss-badge-active",
1727
2337
  open: "ss-badge-trialing",
1728
2338
  draft: "ss-badge-paused",
1729
2339
  void: "ss-badge-canceled",
1730
2340
  uncollectible: "ss-badge-past-due"
1731
2341
  };
1732
- function hs(s) {
1733
- return new Date(s).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
2342
+ function Ae(e) {
2343
+ return new Date(e).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
1734
2344
  }
1735
- function bs(s) {
1736
- return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", minimumFractionDigits: 2 }).format(s / 100);
2345
+ function Me(e) {
2346
+ return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", minimumFractionDigits: 2 }).format(e / 100);
1737
2347
  }
1738
- function fs({ customerId: s, portalToken: a, appearance: r }) {
1739
- const { appearance: c } = k(), { invoices: t, isLoading: d, error: l } = ds(s, a), u = r ?? c, o = [...t].sort((n, m) => new Date(m.createdAt).getTime() - new Date(n.createdAt).getTime());
1740
- return /* @__PURE__ */ e(B, { appearance: u, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
1741
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Invoices" }),
1742
- d && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
1743
- /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2348
+ function Fe({ customerId: e, portalToken: a, appearance: r }) {
2349
+ const { appearance: o } = L(), { invoices: t, isLoading: u, error: i } = Ie(e, a), c = r ?? o, d = [...t].sort((l, g) => new Date(g.createdAt).getTime() - new Date(l.createdAt).getTime());
2350
+ return /* @__PURE__ */ s(q, { appearance: c, children: /* @__PURE__ */ n("div", { className: "ss-card ss-card-wide", children: [
2351
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Invoices" }),
2352
+ u && /* @__PURE__ */ n("div", { className: "ss-loading", children: [
2353
+ /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1744
2354
  " Loading..."
1745
2355
  ] }),
1746
- l && /* @__PURE__ */ e("div", { className: "ss-global-error", children: l }),
1747
- !d && o.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No invoices yet." }),
1748
- !d && o.length > 0 && /* @__PURE__ */ i("table", { className: "ss-table", children: [
1749
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { children: [
1750
- /* @__PURE__ */ e("th", { className: "ss-th", children: "Date" }),
1751
- /* @__PURE__ */ e("th", { className: "ss-th", children: "Amount" }),
1752
- /* @__PURE__ */ e("th", { className: "ss-th", children: "Status" }),
1753
- /* @__PURE__ */ e("th", { className: "ss-th", children: "PDF" })
2356
+ i && /* @__PURE__ */ s("div", { className: "ss-global-error", children: i }),
2357
+ !u && d.length === 0 && /* @__PURE__ */ s("p", { className: "ss-empty", children: "No invoices yet." }),
2358
+ !u && d.length > 0 && /* @__PURE__ */ n("table", { className: "ss-table", children: [
2359
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ n("tr", { children: [
2360
+ /* @__PURE__ */ s("th", { className: "ss-th", children: "Date" }),
2361
+ /* @__PURE__ */ s("th", { className: "ss-th", children: "Amount" }),
2362
+ /* @__PURE__ */ s("th", { className: "ss-th", children: "Status" }),
2363
+ /* @__PURE__ */ s("th", { className: "ss-th", children: "PDF" })
1754
2364
  ] }) }),
1755
- /* @__PURE__ */ e("tbody", { children: o.map((n) => /* @__PURE__ */ i("tr", { className: "ss-tr", children: [
1756
- /* @__PURE__ */ e("td", { className: "ss-td", children: hs(n.createdAt) }),
1757
- /* @__PURE__ */ e("td", { className: "ss-td", children: bs(n.amountCents) }),
1758
- /* @__PURE__ */ e("td", { className: "ss-td", children: /* @__PURE__ */ e("span", { className: `ss-badge ${gs[n.status] || ""}`, children: n.status }) }),
1759
- /* @__PURE__ */ e("td", { className: "ss-td", children: n.pdfUrl ? /* @__PURE__ */ e("a", { className: "ss-link", href: n.pdfUrl, target: "_blank", rel: "noopener noreferrer", children: "Download" }) : "—" })
1760
- ] }, n.id)) })
2365
+ /* @__PURE__ */ s("tbody", { children: d.map((l) => /* @__PURE__ */ n("tr", { className: "ss-tr", children: [
2366
+ /* @__PURE__ */ s("td", { className: "ss-td", children: Ae(l.createdAt) }),
2367
+ /* @__PURE__ */ s("td", { className: "ss-td", children: Me(l.amountCents) }),
2368
+ /* @__PURE__ */ s("td", { className: "ss-td", children: /* @__PURE__ */ s("span", { className: `ss-badge ${De[l.status] || ""}`, children: l.status }) }),
2369
+ /* @__PURE__ */ s("td", { className: "ss-td", children: l.pdfUrl ? /* @__PURE__ */ s("a", { className: "ss-link", href: l.pdfUrl, target: "_blank", rel: "noopener noreferrer", children: "Download" }) : "—" })
2370
+ ] }, l.id)) })
1761
2371
  ] })
1762
2372
  ] }) });
1763
2373
  }
1764
- function ys({ customerId: s, limits: a, portalToken: r, appearance: c }) {
1765
- const { appearance: t } = k(), { usage: d, isLoading: l, error: u } = us(s, r);
1766
- return /* @__PURE__ */ e(B, { appearance: c ?? t, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
1767
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Usage" }),
1768
- l && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
1769
- /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2374
+ function Ue({ customerId: e, limits: a, portalToken: r, appearance: o }) {
2375
+ const { appearance: t } = L(), { usage: u, isLoading: i, error: c } = Te(e, r);
2376
+ return /* @__PURE__ */ s(q, { appearance: o ?? t, children: /* @__PURE__ */ n("div", { className: "ss-card", children: [
2377
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Usage" }),
2378
+ i && /* @__PURE__ */ n("div", { className: "ss-loading", children: [
2379
+ /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1770
2380
  " Loading..."
1771
2381
  ] }),
1772
- u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
1773
- !l && d.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No usage data." }),
1774
- !l && d.map((n) => {
1775
- const m = a == null ? void 0 : a[n.metric], p = m ? Math.min(100, n.total / m * 100) : null;
1776
- return /* @__PURE__ */ i("div", { className: "ss-usage-item", children: [
1777
- /* @__PURE__ */ i("div", { className: "ss-usage-header", children: [
1778
- /* @__PURE__ */ e("span", { className: "ss-usage-metric", children: n.metric }),
1779
- /* @__PURE__ */ i("span", { className: "ss-usage-value", children: [
1780
- n.total.toLocaleString(),
1781
- m ? ` / ${m.toLocaleString()}` : ""
2382
+ c && /* @__PURE__ */ s("div", { className: "ss-global-error", children: c }),
2383
+ !i && u.length === 0 && /* @__PURE__ */ s("p", { className: "ss-empty", children: "No usage data." }),
2384
+ !i && u.map((l) => {
2385
+ const g = a == null ? void 0 : a[l.metric], p = g ? Math.min(100, l.total / g * 100) : null;
2386
+ return /* @__PURE__ */ n("div", { className: "ss-usage-item", children: [
2387
+ /* @__PURE__ */ n("div", { className: "ss-usage-header", children: [
2388
+ /* @__PURE__ */ s("span", { className: "ss-usage-metric", children: l.metric }),
2389
+ /* @__PURE__ */ n("span", { className: "ss-usage-value", children: [
2390
+ l.total.toLocaleString(),
2391
+ g ? ` / ${g.toLocaleString()}` : ""
1782
2392
  ] })
1783
2393
  ] }),
1784
- p !== null && /* @__PURE__ */ e("div", { className: "ss-progress-bar", children: /* @__PURE__ */ e(
2394
+ p !== null && /* @__PURE__ */ s("div", { className: "ss-progress-bar", children: /* @__PURE__ */ s(
1785
2395
  "div",
1786
2396
  {
1787
2397
  className: `ss-progress-fill ${p > 90 ? "ss-progress-danger" : ""}`,
1788
2398
  style: { width: `${p}%` }
1789
2399
  }
1790
2400
  ) })
1791
- ] }, n.metric);
2401
+ ] }, l.metric);
1792
2402
  })
1793
2403
  ] }) });
1794
2404
  }
1795
- function Rs({
1796
- customerId: s,
2405
+ function os({
2406
+ customerId: e,
1797
2407
  portalToken: a,
1798
2408
  limits: r,
1799
- onChangePlan: c,
2409
+ onChangePlan: o,
1800
2410
  onCancel: t,
1801
- appearance: d
2411
+ appearance: u
1802
2412
  }) {
1803
- const { appearance: l } = k(), u = d ?? l, [o, n] = g("subscription");
1804
- return /* @__PURE__ */ e(B, { appearance: u, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
1805
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Billing" }),
1806
- /* @__PURE__ */ e("div", { className: "ss-tab-group", children: [
2413
+ const { appearance: i } = L(), c = u ?? i, [d, l] = m("subscription");
2414
+ return /* @__PURE__ */ s(q, { appearance: c, children: /* @__PURE__ */ n("div", { className: "ss-card ss-card-wide", children: [
2415
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Billing" }),
2416
+ /* @__PURE__ */ s("div", { className: "ss-tab-group", children: [
1807
2417
  { id: "subscription", label: "Subscription" },
1808
2418
  { id: "invoices", label: "Invoices" },
1809
2419
  { id: "usage", label: "Usage" }
1810
- ].map((p) => /* @__PURE__ */ e(
2420
+ ].map((p) => /* @__PURE__ */ s(
1811
2421
  "button",
1812
2422
  {
1813
2423
  type: "button",
1814
- className: `ss-tab ${o === p.id ? "ss-tab-active" : ""}`,
1815
- onClick: () => n(p.id),
2424
+ className: `ss-tab ${d === p.id ? "ss-tab-active" : ""}`,
2425
+ onClick: () => l(p.id),
1816
2426
  children: p.label
1817
2427
  },
1818
2428
  p.id
1819
2429
  )) }),
1820
- /* @__PURE__ */ i("div", { className: "ss-tab-content", children: [
1821
- o === "subscription" && /* @__PURE__ */ e(
1822
- ms,
2430
+ /* @__PURE__ */ n("div", { className: "ss-tab-content", children: [
2431
+ d === "subscription" && /* @__PURE__ */ s(
2432
+ Be,
1823
2433
  {
1824
- customerId: s,
2434
+ customerId: e,
1825
2435
  portalToken: a,
1826
- onChangePlan: c,
2436
+ onChangePlan: o,
1827
2437
  onCancel: t
1828
2438
  }
1829
2439
  ),
1830
- o === "invoices" && /* @__PURE__ */ e(fs, { customerId: s, portalToken: a }),
1831
- o === "usage" && /* @__PURE__ */ e(ys, { customerId: s, portalToken: a, limits: r })
2440
+ d === "invoices" && /* @__PURE__ */ s(Fe, { customerId: e, portalToken: a }),
2441
+ d === "usage" && /* @__PURE__ */ s(Ue, { customerId: e, portalToken: a, limits: r })
1832
2442
  ] })
1833
2443
  ] }) });
1834
2444
  }
1835
- function Ws({ customerId: s, portalToken: a, onApplied: r, appearance: c }) {
1836
- const { appearance: t } = k(), d = M(a), l = c ?? t, [u, o] = g(""), [n, m] = g(!1), [p, h] = g(null), [v, y] = g(null), b = S(async (x) => {
1837
- if (x.preventDefault(), !!u.trim()) {
1838
- m(!0), h(null), y(null);
2445
+ function ls({ customerId: e, portalToken: a, onApplied: r, appearance: o }) {
2446
+ const { appearance: t } = L(), u = Q(a), i = o ?? t, [c, d] = m(""), [l, g] = m(!1), [p, f] = m(null), [b, k] = m(null), v = N(async (C) => {
2447
+ if (C.preventDefault(), !!c.trim()) {
2448
+ g(!0), f(null), k(null);
1839
2449
  try {
1840
- const f = await d.applyCoupon(s, u.trim());
1841
- y(`Coupon applied! ${f.discountType === "percent" ? `${f.amount}% off` : `$${(f.amount / 100).toFixed(2)} off`}`), o(""), r == null || r(f);
1842
- } catch (f) {
1843
- h(f instanceof Error ? f.message : "Invalid coupon code");
2450
+ const x = await u.applyCoupon(e, c.trim());
2451
+ k(`Coupon applied! ${x.discountType === "percent" ? `${x.amount}% off` : `$${(x.amount / 100).toFixed(2)} off`}`), d(""), r == null || r(x);
2452
+ } catch (x) {
2453
+ f(x instanceof Error ? x.message : "Invalid coupon code");
1844
2454
  } finally {
1845
- m(!1);
2455
+ g(!1);
1846
2456
  }
1847
2457
  }
1848
- }, [d, s, u, r]);
1849
- return /* @__PURE__ */ e(B, { appearance: l, children: /* @__PURE__ */ i("div", { className: "ss-card", children: [
1850
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Apply coupon" }),
1851
- p && /* @__PURE__ */ e("div", { className: "ss-global-error", children: p }),
1852
- v && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: v }),
1853
- /* @__PURE__ */ i("form", { onSubmit: b, children: [
1854
- /* @__PURE__ */ i("div", { className: "ss-field", children: [
1855
- /* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-coupon-code", children: "Coupon code" }),
1856
- /* @__PURE__ */ e(
2458
+ }, [u, e, c, r]);
2459
+ return /* @__PURE__ */ s(q, { appearance: i, children: /* @__PURE__ */ n("div", { className: "ss-card", children: [
2460
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Apply coupon" }),
2461
+ p && /* @__PURE__ */ s("div", { className: "ss-global-error", children: p }),
2462
+ b && /* @__PURE__ */ s("div", { className: "ss-success-msg", children: b }),
2463
+ /* @__PURE__ */ n("form", { onSubmit: v, children: [
2464
+ /* @__PURE__ */ n("div", { className: "ss-field", children: [
2465
+ /* @__PURE__ */ s("label", { className: "ss-label", htmlFor: "ss-coupon-code", children: "Coupon code" }),
2466
+ /* @__PURE__ */ s(
1857
2467
  "input",
1858
2468
  {
1859
2469
  id: "ss-coupon-code",
1860
2470
  className: "ss-input",
1861
2471
  type: "text",
1862
2472
  placeholder: "Enter coupon code",
1863
- value: u,
1864
- onChange: (x) => o(x.target.value),
2473
+ value: c,
2474
+ onChange: (C) => d(C.target.value),
1865
2475
  required: !0
1866
2476
  }
1867
2477
  )
1868
2478
  ] }),
1869
- /* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: n || !u.trim(), children: [
1870
- n && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2479
+ /* @__PURE__ */ n("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l || !c.trim(), children: [
2480
+ l && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1871
2481
  "Apply"
1872
2482
  ] })
1873
2483
  ] })
1874
2484
  ] }) });
1875
2485
  }
1876
- function Hs() {
1877
- const { client: s } = k();
1878
- return { report: s.report };
2486
+ function is() {
2487
+ const { client: e } = L();
2488
+ return { report: e.report };
1879
2489
  }
1880
- function V() {
1881
- const { client: s } = k(), [a, r] = g(null), [c, t] = g(!1), [d, l] = g(null), u = S(async (o) => {
1882
- t(!0), l(null);
2490
+ function ie() {
2491
+ const { client: e } = L(), [a, r] = m(null), [o, t] = m(!1), [u, i] = m(null), c = N(async (d) => {
2492
+ t(!0), i(null);
1883
2493
  try {
1884
- const n = await s.report.executeQuery(o);
1885
- return r(n), n;
1886
- } catch (n) {
1887
- return l(n instanceof Error ? n.message : "Query failed"), null;
2494
+ const l = await e.report.executeQuery(d);
2495
+ return r(l), l;
2496
+ } catch (l) {
2497
+ return i(l instanceof Error ? l.message : "Query failed"), null;
1888
2498
  } finally {
1889
2499
  t(!1);
1890
2500
  }
1891
- }, [s]);
1892
- return { result: a, execute: u, isLoading: c, error: d };
2501
+ }, [e]);
2502
+ return { result: a, execute: c, isLoading: o, error: u };
1893
2503
  }
1894
- function xs(s) {
1895
- const { client: a } = k(), [r, c] = g(null), [t, d] = g(!0), [l, u] = g(null), o = S(async () => {
1896
- d(!0), u(null);
2504
+ function qe(e) {
2505
+ const { client: a } = L(), [r, o] = m(null), [t, u] = m(!0), [i, c] = m(null), d = N(async () => {
2506
+ u(!0), c(null);
1897
2507
  try {
1898
- const n = await a.report.listQueries(s);
1899
- c(n);
1900
- } catch (n) {
1901
- u(n instanceof Error ? n.message : "Failed to load queries");
2508
+ const l = await a.report.listQueries(e);
2509
+ o(l);
2510
+ } catch (l) {
2511
+ c(l instanceof Error ? l.message : "Failed to load queries");
1902
2512
  } finally {
1903
- d(!1);
2513
+ u(!1);
1904
2514
  }
1905
- }, [a, s]);
1906
- return L(() => {
1907
- o();
1908
- }, [o]), { queries: (r == null ? void 0 : r.data) ?? [], meta: r == null ? void 0 : r.meta, isLoading: t, error: l, refresh: o };
2515
+ }, [a, e]);
2516
+ return U(() => {
2517
+ d();
2518
+ }, [d]), { queries: (r == null ? void 0 : r.data) ?? [], meta: r == null ? void 0 : r.meta, isLoading: t, error: i, refresh: d };
1909
2519
  }
1910
- function js(s) {
1911
- const { client: a } = k(), [r, c] = g(null), [t, d] = g(!0), [l, u] = g(null), o = S(async () => {
1912
- d(!0), u(null);
2520
+ function cs(e) {
2521
+ const { client: a } = L(), [r, o] = m(null), [t, u] = m(!0), [i, c] = m(null), d = N(async () => {
2522
+ u(!0), c(null);
1913
2523
  try {
1914
- const n = await a.report.getDashboard(s);
1915
- c(n);
1916
- } catch (n) {
1917
- u(n instanceof Error ? n.message : "Failed to load dashboard");
2524
+ const l = await a.report.getDashboard(e);
2525
+ o(l);
2526
+ } catch (l) {
2527
+ c(l instanceof Error ? l.message : "Failed to load dashboard");
1918
2528
  } finally {
1919
- d(!1);
2529
+ u(!1);
1920
2530
  }
1921
- }, [a, s]);
1922
- return L(() => {
1923
- o();
1924
- }, [o]), { dashboard: r, isLoading: t, error: l, refresh: o };
2531
+ }, [a, e]);
2532
+ return U(() => {
2533
+ d();
2534
+ }, [d]), { dashboard: r, isLoading: t, error: i, refresh: d };
1925
2535
  }
1926
- function _s(s, a, r = "https://api.saas-support.com/v1") {
1927
- const c = A(() => {
1928
- const p = new F(r, { type: "embedToken", token: s });
1929
- return new W(p);
1930
- }, [s, r]), [t, d] = g(null), [l, u] = g(!0), [o, n] = g(null), m = S(async () => {
1931
- u(!0), n(null);
2536
+ function ds(e, a, r = "https://api.saas-support.com/v1") {
2537
+ const o = _(() => {
2538
+ const p = new J(r, { type: "embedToken", token: e });
2539
+ return new K(p);
2540
+ }, [e, r]), [t, u] = m(null), [i, c] = m(!0), [d, l] = m(null), g = N(async () => {
2541
+ c(!0), l(null);
1932
2542
  try {
1933
- const p = await c.getDashboard(a);
1934
- d(p);
2543
+ const p = await o.getDashboard(a);
2544
+ u(p);
1935
2545
  } catch (p) {
1936
- n(p instanceof Error ? p.message : "Failed to load dashboard");
2546
+ l(p instanceof Error ? p.message : "Failed to load dashboard");
1937
2547
  } finally {
1938
- u(!1);
2548
+ c(!1);
1939
2549
  }
1940
- }, [c, a]);
1941
- return L(() => {
1942
- m();
1943
- }, [m]), { dashboard: t, reportClient: c, isLoading: l, error: o, refresh: m };
2550
+ }, [o, a]);
2551
+ return U(() => {
2552
+ g();
2553
+ }, [g]), { dashboard: t, reportClient: o, isLoading: i, error: d, refresh: g };
1944
2554
  }
1945
- function Gs({ onResult: s, mode: a = "both", placeholder: r, appearance: c }) {
1946
- const { appearance: t } = k(), { execute: d, isLoading: l, error: u } = V(), o = c ?? t, [n, m] = g(""), [p, h] = g(a === "sql" ? "sql" : "nl"), v = S(async (y) => {
1947
- if (y.preventDefault(), !n.trim()) return;
1948
- const x = await d(p === "sql" ? { sql: n } : { naturalLanguage: n });
1949
- x && (s == null || s(x));
1950
- }, [n, p, d, s]);
1951
- return /* @__PURE__ */ e(B, { appearance: o, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
1952
- a === "both" && /* @__PURE__ */ i("div", { className: "ss-tab-group ss-tab-group-sm", children: [
1953
- /* @__PURE__ */ e(
2555
+ function us({ onResult: e, mode: a = "both", placeholder: r, appearance: o }) {
2556
+ const { appearance: t } = L(), { execute: u, isLoading: i, error: c } = ie(), d = o ?? t, [l, g] = m(""), [p, f] = m(a === "sql" ? "sql" : "nl"), b = N(async (k) => {
2557
+ if (k.preventDefault(), !l.trim()) return;
2558
+ const C = await u(p === "sql" ? { sql: l } : { naturalLanguage: l });
2559
+ C && (e == null || e(C));
2560
+ }, [l, p, u, e]);
2561
+ return /* @__PURE__ */ s(q, { appearance: d, children: /* @__PURE__ */ n("div", { className: "ss-card ss-card-wide", children: [
2562
+ a === "both" && /* @__PURE__ */ n("div", { className: "ss-tab-group ss-tab-group-sm", children: [
2563
+ /* @__PURE__ */ s(
1954
2564
  "button",
1955
2565
  {
1956
2566
  type: "button",
1957
2567
  className: `ss-tab ${p === "nl" ? "ss-tab-active" : ""}`,
1958
- onClick: () => h("nl"),
2568
+ onClick: () => f("nl"),
1959
2569
  children: "Natural Language"
1960
2570
  }
1961
2571
  ),
1962
- /* @__PURE__ */ e(
2572
+ /* @__PURE__ */ s(
1963
2573
  "button",
1964
2574
  {
1965
2575
  type: "button",
1966
2576
  className: `ss-tab ${p === "sql" ? "ss-tab-active" : ""}`,
1967
- onClick: () => h("sql"),
2577
+ onClick: () => f("sql"),
1968
2578
  children: "SQL"
1969
2579
  }
1970
2580
  )
1971
2581
  ] }),
1972
- u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
1973
- /* @__PURE__ */ i("form", { onSubmit: v, children: [
1974
- /* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
2582
+ c && /* @__PURE__ */ s("div", { className: "ss-global-error", children: c }),
2583
+ /* @__PURE__ */ n("form", { onSubmit: b, children: [
2584
+ /* @__PURE__ */ s("div", { className: "ss-field", children: /* @__PURE__ */ s(
1975
2585
  "textarea",
1976
2586
  {
1977
2587
  className: "ss-input ss-query-textarea",
1978
2588
  placeholder: r ?? (p === "sql" ? "SELECT ..." : "Ask a question about your data..."),
1979
- value: n,
1980
- onChange: (y) => m(y.target.value),
2589
+ value: l,
2590
+ onChange: (k) => g(k.target.value),
1981
2591
  rows: 3
1982
2592
  }
1983
2593
  ) }),
1984
- /* @__PURE__ */ i("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: l || !n.trim(), children: [
1985
- l && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2594
+ /* @__PURE__ */ n("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: i || !l.trim(), children: [
2595
+ i && /* @__PURE__ */ s("span", { className: "ss-spinner" }),
1986
2596
  "Run query"
1987
2597
  ] })
1988
2598
  ] })
1989
2599
  ] }) });
1990
2600
  }
1991
- function vs({ columns: s, rows: a, sortable: r = !0, maxRows: c, appearance: t }) {
1992
- const { appearance: d } = k(), l = t ?? d, [u, o] = g(null), [n, m] = g("asc"), p = A(() => u ? [...a].sort((b, x) => {
1993
- const f = b[u], N = x[u];
1994
- if (f == null && N == null) return 0;
1995
- if (f == null) return 1;
1996
- if (N == null) return -1;
1997
- if (typeof f == "number" && typeof N == "number")
1998
- return n === "asc" ? f - N : N - f;
1999
- const w = String(f), $ = String(N);
2000
- return n === "asc" ? w.localeCompare($) : $.localeCompare(w);
2001
- }) : a, [a, u, n]), h = c ? p.slice(0, c) : p, v = (b) => {
2002
- r && (u === b ? m((x) => x === "asc" ? "desc" : "asc") : (o(b), m("asc")));
2601
+ function Re({ columns: e, rows: a, sortable: r = !0, maxRows: o, appearance: t }) {
2602
+ const { appearance: u } = L(), i = t ?? u, [c, d] = m(null), [l, g] = m("asc"), p = _(() => c ? [...a].sort((v, C) => {
2603
+ const x = v[c], h = C[c];
2604
+ if (x == null && h == null) return 0;
2605
+ if (x == null) return 1;
2606
+ if (h == null) return -1;
2607
+ if (typeof x == "number" && typeof h == "number")
2608
+ return l === "asc" ? x - h : h - x;
2609
+ const S = String(x), z = String(h);
2610
+ return l === "asc" ? S.localeCompare(z) : z.localeCompare(S);
2611
+ }) : a, [a, c, l]), f = o ? p.slice(0, o) : p, b = (v) => {
2612
+ r && (c === v ? g((C) => C === "asc" ? "desc" : "asc") : (d(v), g("asc")));
2003
2613
  };
2004
- function y(b) {
2005
- return b == null ? "" : typeof b == "object" ? JSON.stringify(b) : String(b);
2614
+ function k(v) {
2615
+ return v == null ? "" : typeof v == "object" ? JSON.stringify(v) : String(v);
2006
2616
  }
2007
- return /* @__PURE__ */ e(B, { appearance: l, children: /* @__PURE__ */ i("div", { className: "ss-table-container", children: [
2008
- /* @__PURE__ */ i("table", { className: "ss-table", children: [
2009
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: s.map((b) => /* @__PURE__ */ i(
2617
+ return /* @__PURE__ */ s(q, { appearance: i, children: /* @__PURE__ */ n("div", { className: "ss-table-container", children: [
2618
+ /* @__PURE__ */ n("table", { className: "ss-table", children: [
2619
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ s("tr", { children: e.map((v) => /* @__PURE__ */ n(
2010
2620
  "th",
2011
2621
  {
2012
- className: `ss-th ${r ? "ss-th-sortable" : ""} ${u === b ? n === "asc" ? "ss-sorted-asc" : "ss-sorted-desc" : ""}`,
2013
- onClick: () => v(b),
2622
+ className: `ss-th ${r ? "ss-th-sortable" : ""} ${c === v ? l === "asc" ? "ss-sorted-asc" : "ss-sorted-desc" : ""}`,
2623
+ onClick: () => b(v),
2014
2624
  children: [
2015
- b,
2016
- u === b && /* @__PURE__ */ e("span", { className: "ss-sort-indicator", children: n === "asc" ? " ▲" : " ▼" })
2625
+ v,
2626
+ c === v && /* @__PURE__ */ s("span", { className: "ss-sort-indicator", children: l === "asc" ? " ▲" : " ▼" })
2017
2627
  ]
2018
2628
  },
2019
- b
2629
+ v
2020
2630
  )) }) }),
2021
- /* @__PURE__ */ e("tbody", { children: h.map((b, x) => /* @__PURE__ */ e("tr", { className: "ss-tr", children: s.map((f) => /* @__PURE__ */ e("td", { className: "ss-td", children: y(b[f]) }, f)) }, x)) })
2631
+ /* @__PURE__ */ s("tbody", { children: f.map((v, C) => /* @__PURE__ */ s("tr", { className: "ss-tr", children: e.map((x) => /* @__PURE__ */ s("td", { className: "ss-td", children: k(v[x]) }, x)) }, C)) })
2022
2632
  ] }),
2023
- c && a.length > c && /* @__PURE__ */ i("div", { className: "ss-table-footer", children: [
2633
+ o && a.length > o && /* @__PURE__ */ n("div", { className: "ss-table-footer", children: [
2024
2634
  "Showing ",
2025
- c,
2635
+ o,
2026
2636
  " of ",
2027
2637
  a.length,
2028
2638
  " rows"
2029
2639
  ] })
2030
2640
  ] }) });
2031
2641
  }
2032
- function Ns(s, a = "#6366f1") {
2033
- const r = parseInt(a.replace("#", "").slice(0, 2), 16), c = [];
2034
- for (let t = 0; t < s; t++) {
2035
- const d = (r + t * Math.floor(360 / Math.max(s, 1))) % 360;
2036
- c.push(`hsl(${d}, 65%, 55%)`);
2642
+ function Oe(e, a = "#6366f1") {
2643
+ const r = parseInt(a.replace("#", "").slice(0, 2), 16), o = [];
2644
+ for (let t = 0; t < e; t++) {
2645
+ const u = (r + t * Math.floor(360 / Math.max(e, 1))) % 360;
2646
+ o.push(`hsl(${u}, 65%, 55%)`);
2037
2647
  }
2038
- return c;
2648
+ return o;
2039
2649
  }
2040
- function ws({ labels: s, values: a, w: r, h: c, colors: t }) {
2041
- const d = Math.max(...a, 1), l = 40, u = r - l * 2, o = c - l * 2, n = Math.max(1, u / s.length - 4);
2042
- return /* @__PURE__ */ i("g", { children: [
2043
- /* @__PURE__ */ e("line", { x1: l, y1: c - l, x2: r - l, y2: c - l, stroke: "#ccc", strokeWidth: 1 }),
2044
- a.map((m, p) => {
2045
- const h = m / d * o, v = l + u / s.length * p + 2, y = c - l - h;
2046
- return /* @__PURE__ */ i("g", { children: [
2047
- /* @__PURE__ */ e("rect", { x: v, y, width: n, height: h, fill: t[p % t.length], rx: 2 }),
2048
- /* @__PURE__ */ e("text", { x: v + n / 2, y: c - l + 14, textAnchor: "middle", fontSize: 10, fill: "#666", children: s[p].length > 8 ? s[p].slice(0, 8) + "..." : s[p] })
2650
+ function We({ labels: e, values: a, w: r, h: o, colors: t }) {
2651
+ const u = Math.max(...a, 1), i = 40, c = r - i * 2, d = o - i * 2, l = Math.max(1, c / e.length - 4);
2652
+ return /* @__PURE__ */ n("g", { children: [
2653
+ /* @__PURE__ */ s("line", { x1: i, y1: o - i, x2: r - i, y2: o - i, stroke: "#ccc", strokeWidth: 1 }),
2654
+ a.map((g, p) => {
2655
+ const f = g / u * d, b = i + c / e.length * p + 2, k = o - i - f;
2656
+ return /* @__PURE__ */ n("g", { children: [
2657
+ /* @__PURE__ */ s("rect", { x: b, y: k, width: l, height: f, fill: t[p % t.length], rx: 2 }),
2658
+ /* @__PURE__ */ s("text", { x: b + l / 2, y: o - i + 14, textAnchor: "middle", fontSize: 10, fill: "#666", children: e[p].length > 8 ? e[p].slice(0, 8) + "..." : e[p] })
2049
2659
  ] }, p);
2050
2660
  })
2051
2661
  ] });
2052
2662
  }
2053
- function Ss({ labels: s, values: a, w: r, h: c, colors: t }) {
2054
- const d = Math.max(...a, 1), l = 40, u = r - l * 2, o = c - l * 2, n = s.length > 1 ? u / (s.length - 1) : 0, m = a.map((p, h) => {
2055
- const v = l + n * h, y = c - l - p / d * o;
2056
- return `${v},${y}`;
2663
+ function He({ labels: e, values: a, w: r, h: o, colors: t }) {
2664
+ const u = Math.max(...a, 1), i = 40, c = r - i * 2, d = o - i * 2, l = e.length > 1 ? c / (e.length - 1) : 0, g = a.map((p, f) => {
2665
+ const b = i + l * f, k = o - i - p / u * d;
2666
+ return `${b},${k}`;
2057
2667
  });
2058
- return /* @__PURE__ */ i("g", { children: [
2668
+ return /* @__PURE__ */ n("g", { children: [
2059
2669
  [0.25, 0.5, 0.75, 1].map((p) => {
2060
- const h = c - l - p * o;
2061
- return /* @__PURE__ */ e("line", { x1: l, y1: h, x2: r - l, y2: h, stroke: "#eee", strokeWidth: 1 }, p);
2670
+ const f = o - i - p * d;
2671
+ return /* @__PURE__ */ s("line", { x1: i, y1: f, x2: r - i, y2: f, stroke: "#eee", strokeWidth: 1 }, p);
2062
2672
  }),
2063
- /* @__PURE__ */ e("polyline", { points: m.join(" "), fill: "none", stroke: t[0], strokeWidth: 2 }),
2064
- a.map((p, h) => {
2065
- const v = l + n * h, y = c - l - p / d * o;
2066
- return /* @__PURE__ */ e("circle", { cx: v, cy: y, r: 4, fill: t[0] }, h);
2673
+ /* @__PURE__ */ s("polyline", { points: g.join(" "), fill: "none", stroke: t[0], strokeWidth: 2 }),
2674
+ a.map((p, f) => {
2675
+ const b = i + l * f, k = o - i - p / u * d;
2676
+ return /* @__PURE__ */ s("circle", { cx: b, cy: k, r: 4, fill: t[0] }, f);
2067
2677
  })
2068
2678
  ] });
2069
2679
  }
2070
- function $s({ labels: s, values: a, w: r, h: c, colors: t }) {
2071
- const d = a.reduce((h, v) => h + v, 0) || 1, l = r / 2, u = c / 2 - 20, o = Math.min(r, c) / 2 - 40, n = 2 * Math.PI * o;
2072
- let m = 0;
2073
- const p = a.map((h, v) => {
2074
- const y = h / d, b = y * n, x = { dash: b, offset: m, color: t[v % t.length], label: s[v], pct: y };
2075
- return m += b, x;
2680
+ function _e({ labels: e, values: a, w: r, h: o, colors: t }) {
2681
+ const u = a.reduce((f, b) => f + b, 0) || 1, i = r / 2, c = o / 2 - 20, d = Math.min(r, o) / 2 - 40, l = 2 * Math.PI * d;
2682
+ let g = 0;
2683
+ const p = a.map((f, b) => {
2684
+ const k = f / u, v = k * l, C = { dash: v, offset: g, color: t[b % t.length], label: e[b], pct: k };
2685
+ return g += v, C;
2076
2686
  });
2077
- return /* @__PURE__ */ i("g", { children: [
2078
- p.map((h, v) => /* @__PURE__ */ e(
2687
+ return /* @__PURE__ */ n("g", { children: [
2688
+ p.map((f, b) => /* @__PURE__ */ s(
2079
2689
  "circle",
2080
2690
  {
2081
- cx: l,
2082
- cy: u,
2083
- r: o,
2691
+ cx: i,
2692
+ cy: c,
2693
+ r: d,
2084
2694
  fill: "none",
2085
- stroke: h.color,
2086
- strokeWidth: o * 0.6,
2087
- strokeDasharray: `${h.dash} ${n - h.dash}`,
2088
- strokeDashoffset: -h.offset,
2089
- transform: `rotate(-90 ${l} ${u})`
2695
+ stroke: f.color,
2696
+ strokeWidth: d * 0.6,
2697
+ strokeDasharray: `${f.dash} ${l - f.dash}`,
2698
+ strokeDashoffset: -f.offset,
2699
+ transform: `rotate(-90 ${i} ${c})`
2090
2700
  },
2091
- v
2701
+ b
2092
2702
  )),
2093
- /* @__PURE__ */ e("g", { transform: `translate(${l - s.length * 30}, ${c - 20})`, children: p.slice(0, 6).map((h, v) => /* @__PURE__ */ i("g", { transform: `translate(${v * 60}, 0)`, children: [
2094
- /* @__PURE__ */ e("rect", { width: 10, height: 10, fill: h.color, rx: 2 }),
2095
- /* @__PURE__ */ e("text", { x: 14, y: 9, fontSize: 9, fill: "#666", children: h.label.length > 6 ? h.label.slice(0, 6) + ".." : h.label })
2096
- ] }, v)) })
2703
+ /* @__PURE__ */ s("g", { transform: `translate(${i - e.length * 30}, ${o - 20})`, children: p.slice(0, 6).map((f, b) => /* @__PURE__ */ n("g", { transform: `translate(${b * 60}, 0)`, children: [
2704
+ /* @__PURE__ */ s("rect", { width: 10, height: 10, fill: f.color, rx: 2 }),
2705
+ /* @__PURE__ */ s("text", { x: 14, y: 9, fontSize: 9, fill: "#666", children: f.label.length > 6 ? f.label.slice(0, 6) + ".." : f.label })
2706
+ ] }, b)) })
2097
2707
  ] });
2098
2708
  }
2099
- function ks({ type: s, data: a, title: r, width: c = 400, height: t = 300, appearance: d }) {
2100
- const { appearance: l } = k(), u = d ?? l, o = A(() => Ns(a.labels.length), [a.labels.length]);
2101
- return /* @__PURE__ */ e(B, { appearance: u, children: /* @__PURE__ */ i("div", { className: "ss-chart-container", children: [
2102
- r && /* @__PURE__ */ e("h3", { className: "ss-chart-title", children: r }),
2103
- /* @__PURE__ */ i("svg", { viewBox: `0 0 ${c} ${t}`, width: "100%", style: { maxWidth: c }, children: [
2104
- s === "bar" && /* @__PURE__ */ e(ws, { labels: a.labels, values: a.values, w: c, h: t, colors: o }),
2105
- s === "line" && /* @__PURE__ */ e(Ss, { labels: a.labels, values: a.values, w: c, h: t, colors: o }),
2106
- s === "pie" && /* @__PURE__ */ e($s, { labels: a.labels, values: a.values, w: c, h: t, colors: o })
2709
+ function je({ type: e, data: a, title: r, width: o = 400, height: t = 300, appearance: u }) {
2710
+ const { appearance: i } = L(), c = u ?? i, d = _(() => Oe(a.labels.length), [a.labels.length]);
2711
+ return /* @__PURE__ */ s(q, { appearance: c, children: /* @__PURE__ */ n("div", { className: "ss-chart-container", children: [
2712
+ r && /* @__PURE__ */ s("h3", { className: "ss-chart-title", children: r }),
2713
+ /* @__PURE__ */ n("svg", { viewBox: `0 0 ${o} ${t}`, width: "100%", style: { maxWidth: o }, children: [
2714
+ e === "bar" && /* @__PURE__ */ s(We, { labels: a.labels, values: a.values, w: o, h: t, colors: d }),
2715
+ e === "line" && /* @__PURE__ */ s(He, { labels: a.labels, values: a.values, w: o, h: t, colors: d }),
2716
+ e === "pie" && /* @__PURE__ */ s(_e, { labels: a.labels, values: a.values, w: o, h: t, colors: d })
2107
2717
  ] })
2108
2718
  ] }) });
2109
2719
  }
2110
- function Js({ dashboardId: s, embedToken: a, baseUrl: r, refreshInterval: c, appearance: t }) {
2111
- const d = k(), l = t ?? (d == null ? void 0 : d.appearance), u = A(() => {
2720
+ function ps({ dashboardId: e, embedToken: a, baseUrl: r, refreshInterval: o, appearance: t }) {
2721
+ const u = L(), i = t ?? (u == null ? void 0 : u.appearance), c = _(() => {
2112
2722
  if (a) {
2113
- const f = r ?? "https://api.saas-support.com/v1", N = new F(f, { type: "embedToken", token: a });
2114
- return new W(N);
2723
+ const x = r ?? "https://api.saas-support.com/v1", h = new J(x, { type: "embedToken", token: a });
2724
+ return new K(h);
2115
2725
  }
2116
- return d.client.report;
2117
- }, [a, r, d]), [o, n] = g([]), [m, p] = g({}), [h, v] = g(!0), [y, b] = g(null), x = S(async () => {
2118
- v(!0), b(null);
2726
+ return u.client.report;
2727
+ }, [a, r, u]), [d, l] = m([]), [g, p] = m({}), [f, b] = m(!0), [k, v] = m(null), C = N(async () => {
2728
+ b(!0), v(null);
2119
2729
  try {
2120
- const f = await u.getDashboard(s), N = JSON.parse(f.layoutJson || "[]");
2121
- n(N);
2122
- const w = {};
2123
- for (const $ of N)
2730
+ const x = await c.getDashboard(e), h = JSON.parse(x.layoutJson || "[]");
2731
+ l(h);
2732
+ const S = {};
2733
+ for (const z of h)
2124
2734
  try {
2125
- const E = await u.listQueries({ search: $.queryId, perPage: 1 });
2126
- if (E.data.length > 0 && E.data[0].generatedSql) {
2127
- const z = await u.executeQuery({ sql: E.data[0].generatedSql });
2128
- w[$.queryId] = z;
2735
+ const P = await c.listQueries({ search: z.queryId, perPage: 1 });
2736
+ if (P.data.length > 0 && P.data[0].generatedSql) {
2737
+ const I = await c.executeQuery({ sql: P.data[0].generatedSql });
2738
+ S[z.queryId] = I;
2129
2739
  }
2130
2740
  } catch {
2131
2741
  }
2132
- p(w);
2133
- } catch (f) {
2134
- b(f instanceof Error ? f.message : "Failed to load dashboard");
2742
+ p(S);
2743
+ } catch (x) {
2744
+ v(x instanceof Error ? x.message : "Failed to load dashboard");
2135
2745
  } finally {
2136
- v(!1);
2137
- }
2138
- }, [u, s]);
2139
- return L(() => {
2140
- x();
2141
- }, [x]), L(() => {
2142
- if (!c || c <= 0) return;
2143
- const f = setInterval(x, c * 1e3);
2144
- return () => clearInterval(f);
2145
- }, [c, x]), /* @__PURE__ */ e(B, { appearance: l, children: /* @__PURE__ */ i("div", { className: "ss-dashboard-grid", children: [
2146
- h && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
2147
- /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2746
+ b(!1);
2747
+ }
2748
+ }, [c, e]);
2749
+ return U(() => {
2750
+ C();
2751
+ }, [C]), U(() => {
2752
+ if (!o || o <= 0) return;
2753
+ const x = setInterval(C, o * 1e3);
2754
+ return () => clearInterval(x);
2755
+ }, [o, C]), /* @__PURE__ */ s(q, { appearance: i, children: /* @__PURE__ */ n("div", { className: "ss-dashboard-grid", children: [
2756
+ f && /* @__PURE__ */ n("div", { className: "ss-loading", children: [
2757
+ /* @__PURE__ */ s("span", { className: "ss-spinner" }),
2148
2758
  " Loading dashboard..."
2149
2759
  ] }),
2150
- y && /* @__PURE__ */ e("div", { className: "ss-global-error", children: y }),
2151
- !h && o.map((f, N) => {
2152
- const w = m[f.queryId];
2153
- if (!w) return null;
2154
- const $ = w.columns.length >= 2 ? {
2155
- labels: w.rows.map((E) => String(E[w.columns[0]] ?? "")),
2156
- values: w.rows.map((E) => Number(E[w.columns[1]] ?? 0))
2760
+ k && /* @__PURE__ */ s("div", { className: "ss-global-error", children: k }),
2761
+ !f && d.map((x, h) => {
2762
+ const S = g[x.queryId];
2763
+ if (!S) return null;
2764
+ const z = S.columns.length >= 2 ? {
2765
+ labels: S.rows.map((P) => String(P[S.columns[0]] ?? "")),
2766
+ values: S.rows.map((P) => Number(P[S.columns[1]] ?? 0))
2157
2767
  } : { labels: [], values: [] };
2158
- return /* @__PURE__ */ i("div", { className: "ss-widget", children: [
2159
- f.title && /* @__PURE__ */ e("h4", { className: "ss-widget-header", children: f.title }),
2160
- f.chartType === "table" ? /* @__PURE__ */ e(vs, { columns: w.columns, rows: w.rows, maxRows: 50 }) : /* @__PURE__ */ e(
2161
- ks,
2768
+ return /* @__PURE__ */ n("div", { className: "ss-widget", children: [
2769
+ x.title && /* @__PURE__ */ s("h4", { className: "ss-widget-header", children: x.title }),
2770
+ x.chartType === "table" ? /* @__PURE__ */ s(Re, { columns: S.columns, rows: S.rows, maxRows: 50 }) : /* @__PURE__ */ s(
2771
+ je,
2162
2772
  {
2163
- type: f.chartType || "bar",
2164
- data: $,
2165
- width: f.w,
2166
- height: f.h
2773
+ type: x.chartType || "bar",
2774
+ data: z,
2775
+ width: x.w,
2776
+ height: x.h
2167
2777
  }
2168
2778
  )
2169
- ] }, N);
2779
+ ] }, h);
2170
2780
  })
2171
2781
  ] }) });
2172
2782
  }
2173
- function Cs(s) {
2174
- return new Date(s).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
2783
+ function Ve(e) {
2784
+ return new Date(e).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
2175
2785
  }
2176
- function Qs({ onSelectQuery: s, onRunQuery: a, appearance: r }) {
2177
- const { appearance: c } = k(), { queries: t, isLoading: d, error: l } = xs(), { execute: u, isLoading: o } = V(), n = r ?? c, m = S(async (p) => {
2786
+ function ms({ onSelectQuery: e, onRunQuery: a, appearance: r }) {
2787
+ const { appearance: o } = L(), { queries: t, isLoading: u, error: i } = qe(), { execute: c, isLoading: d } = ie(), l = r ?? o, g = N(async (p) => {
2178
2788
  if (!p.generatedSql) return;
2179
- const h = await u({ sql: p.generatedSql });
2180
- h && (a == null || a(h));
2181
- }, [u, a]);
2182
- return /* @__PURE__ */ e(B, { appearance: n, children: /* @__PURE__ */ i("div", { className: "ss-card ss-card-wide", children: [
2183
- /* @__PURE__ */ e("h2", { className: "ss-title", children: "Saved Queries" }),
2184
- d && /* @__PURE__ */ i("div", { className: "ss-loading", children: [
2185
- /* @__PURE__ */ e("span", { className: "ss-spinner" }),
2789
+ const f = await c({ sql: p.generatedSql });
2790
+ f && (a == null || a(f));
2791
+ }, [c, a]);
2792
+ return /* @__PURE__ */ s(q, { appearance: l, children: /* @__PURE__ */ n("div", { className: "ss-card ss-card-wide", children: [
2793
+ /* @__PURE__ */ s("h2", { className: "ss-title", children: "Saved Queries" }),
2794
+ u && /* @__PURE__ */ n("div", { className: "ss-loading", children: [
2795
+ /* @__PURE__ */ s("span", { className: "ss-spinner" }),
2186
2796
  " Loading..."
2187
2797
  ] }),
2188
- l && /* @__PURE__ */ e("div", { className: "ss-global-error", children: l }),
2189
- !d && t.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No saved queries." }),
2190
- !d && t.map((p) => /* @__PURE__ */ i(
2798
+ i && /* @__PURE__ */ s("div", { className: "ss-global-error", children: i }),
2799
+ !u && t.length === 0 && /* @__PURE__ */ s("p", { className: "ss-empty", children: "No saved queries." }),
2800
+ !u && t.map((p) => /* @__PURE__ */ n(
2191
2801
  "div",
2192
2802
  {
2193
2803
  className: "ss-saved-query-card",
2194
- onClick: () => s == null ? void 0 : s(p),
2804
+ onClick: () => e == null ? void 0 : e(p),
2195
2805
  children: [
2196
- /* @__PURE__ */ i("div", { className: "ss-saved-query-header", children: [
2197
- /* @__PURE__ */ e("span", { className: "ss-saved-query-name", children: p.name }),
2198
- p.chartType && /* @__PURE__ */ e("span", { className: "ss-badge", children: p.chartType })
2806
+ /* @__PURE__ */ n("div", { className: "ss-saved-query-header", children: [
2807
+ /* @__PURE__ */ s("span", { className: "ss-saved-query-name", children: p.name }),
2808
+ p.chartType && /* @__PURE__ */ s("span", { className: "ss-badge", children: p.chartType })
2199
2809
  ] }),
2200
- p.naturalLanguage && /* @__PURE__ */ e("p", { className: "ss-saved-query-desc", children: p.naturalLanguage }),
2201
- /* @__PURE__ */ i("div", { className: "ss-saved-query-footer", children: [
2202
- /* @__PURE__ */ e("span", { className: "ss-saved-query-date", children: Cs(p.createdAt) }),
2203
- /* @__PURE__ */ e(
2810
+ p.naturalLanguage && /* @__PURE__ */ s("p", { className: "ss-saved-query-desc", children: p.naturalLanguage }),
2811
+ /* @__PURE__ */ n("div", { className: "ss-saved-query-footer", children: [
2812
+ /* @__PURE__ */ s("span", { className: "ss-saved-query-date", children: Ve(p.createdAt) }),
2813
+ /* @__PURE__ */ s(
2204
2814
  "button",
2205
2815
  {
2206
2816
  type: "button",
2207
2817
  className: "ss-btn ss-btn-sm ss-btn-primary",
2208
- disabled: o || !p.generatedSql,
2209
- onClick: (h) => {
2210
- h.stopPropagation(), m(p);
2818
+ disabled: d || !p.generatedSql,
2819
+ onClick: (f) => {
2820
+ f.stopPropagation(), g(p);
2211
2821
  },
2212
- children: o ? /* @__PURE__ */ e("span", { className: "ss-spinner" }) : "Run"
2822
+ children: d ? /* @__PURE__ */ s("span", { className: "ss-spinner" }) : "Run"
2213
2823
  }
2214
2824
  )
2215
2825
  ] })
@@ -2219,105 +2829,106 @@ function Qs({ onSelectQuery: s, onRunQuery: a, appearance: r }) {
2219
2829
  ))
2220
2830
  ] }) });
2221
2831
  }
2222
- function Vs({ embedToken: s, dashboardId: a, baseUrl: r = "https://api.saas-support.com/v1", refreshInterval: c, appearance: t }) {
2223
- const d = A(() => {
2224
- const b = new F(r, { type: "embedToken", token: s });
2225
- return new W(b);
2226
- }, [s, r]), [l, u] = g([]), [o, n] = g(!0), [m, p] = g(null), h = A(() => U(t), [t]), v = A(() => O(h), [h]), y = S(async () => {
2227
- n(!0), p(null);
2832
+ function gs({ embedToken: e, dashboardId: a, baseUrl: r = "https://api.saas-support.com/v1", refreshInterval: o, appearance: t }) {
2833
+ const u = _(() => {
2834
+ const v = new J(r, { type: "embedToken", token: e });
2835
+ return new K(v);
2836
+ }, [e, r]), [i, c] = m([]), [d, l] = m(!0), [g, p] = m(null), f = _(() => Z(t), [t]), b = _(() => X(f), [f]), k = N(async () => {
2837
+ l(!0), p(null);
2228
2838
  try {
2229
- const b = await d.getDashboard(a), x = JSON.parse(b.layoutJson || "[]"), f = await Promise.all(
2230
- x.map(async (N) => {
2839
+ const v = await u.getDashboard(a), C = JSON.parse(v.layoutJson || "[]"), x = await Promise.all(
2840
+ C.map(async (h) => {
2231
2841
  try {
2232
- const w = await d.listQueries({ search: N.queryId, perPage: 1 });
2233
- if (w.data.length > 0 && w.data[0].generatedSql) {
2234
- const $ = await d.executeQuery({ sql: w.data[0].generatedSql });
2235
- return { ...N, result: $ };
2842
+ const S = await u.listQueries({ search: h.queryId, perPage: 1 });
2843
+ if (S.data.length > 0 && S.data[0].generatedSql) {
2844
+ const z = await u.executeQuery({ sql: S.data[0].generatedSql });
2845
+ return { ...h, result: z };
2236
2846
  }
2237
2847
  } catch {
2238
2848
  }
2239
- return N;
2849
+ return h;
2240
2850
  })
2241
2851
  );
2242
- u(f);
2243
- } catch (b) {
2244
- p(b instanceof Error ? b.message : "Failed to load dashboard");
2852
+ c(x);
2853
+ } catch (v) {
2854
+ p(v instanceof Error ? v.message : "Failed to load dashboard");
2245
2855
  } finally {
2246
- n(!1);
2247
- }
2248
- }, [d, a]);
2249
- return L(() => {
2250
- y();
2251
- }, [y]), L(() => {
2252
- if (!c || c <= 0) return;
2253
- const b = setInterval(y, c * 1e3);
2254
- return () => clearInterval(b);
2255
- }, [c, y]), /* @__PURE__ */ e(
2856
+ l(!1);
2857
+ }
2858
+ }, [u, a]);
2859
+ return U(() => {
2860
+ k();
2861
+ }, [k]), U(() => {
2862
+ if (!o || o <= 0) return;
2863
+ const v = setInterval(k, o * 1e3);
2864
+ return () => clearInterval(v);
2865
+ }, [o, k]), /* @__PURE__ */ s(
2256
2866
  "div",
2257
2867
  {
2258
- ref: (b) => {
2259
- if (!b || b.shadowRoot) return;
2260
- const x = b.attachShadow({ mode: "open" }), f = document.createElement("style");
2261
- f.textContent = v, x.appendChild(f);
2262
- const N = document.createElement("div");
2263
- x.appendChild(N);
2868
+ ref: (v) => {
2869
+ if (!v || v.shadowRoot) return;
2870
+ const C = v.attachShadow({ mode: "open" }), x = document.createElement("style");
2871
+ x.textContent = b, C.appendChild(x);
2872
+ const h = document.createElement("div");
2873
+ C.appendChild(h);
2264
2874
  },
2265
2875
  style: { display: "contents" },
2266
- children: /* @__PURE__ */ i("div", { className: "ss-dashboard-grid", children: [
2267
- o && /* @__PURE__ */ e("div", { className: "ss-loading", children: "Loading dashboard..." }),
2268
- m && /* @__PURE__ */ e("div", { className: "ss-global-error", children: m }),
2269
- !o && l.map((b, x) => {
2270
- if (!b.result) return null;
2271
- const { columns: f, rows: N } = b.result;
2272
- return /* @__PURE__ */ i("div", { className: "ss-widget", children: [
2273
- b.title && /* @__PURE__ */ e("h4", { className: "ss-widget-header", children: b.title }),
2274
- /* @__PURE__ */ i("table", { className: "ss-table", children: [
2275
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: f.map((w) => /* @__PURE__ */ e("th", { className: "ss-th", children: w }, w)) }) }),
2276
- /* @__PURE__ */ e("tbody", { children: N.slice(0, 50).map((w, $) => /* @__PURE__ */ e("tr", { className: "ss-tr", children: f.map((E) => /* @__PURE__ */ e("td", { className: "ss-td", children: String(w[E] ?? "") }, E)) }, $)) })
2876
+ children: /* @__PURE__ */ n("div", { className: "ss-dashboard-grid", children: [
2877
+ d && /* @__PURE__ */ s("div", { className: "ss-loading", children: "Loading dashboard..." }),
2878
+ g && /* @__PURE__ */ s("div", { className: "ss-global-error", children: g }),
2879
+ !d && i.map((v, C) => {
2880
+ if (!v.result) return null;
2881
+ const { columns: x, rows: h } = v.result;
2882
+ return /* @__PURE__ */ n("div", { className: "ss-widget", children: [
2883
+ v.title && /* @__PURE__ */ s("h4", { className: "ss-widget-header", children: v.title }),
2884
+ /* @__PURE__ */ n("table", { className: "ss-table", children: [
2885
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ s("tr", { children: x.map((S) => /* @__PURE__ */ s("th", { className: "ss-th", children: S }, S)) }) }),
2886
+ /* @__PURE__ */ s("tbody", { children: h.slice(0, 50).map((S, z) => /* @__PURE__ */ s("tr", { className: "ss-tr", children: x.map((P) => /* @__PURE__ */ s("td", { className: "ss-td", children: String(S[P] ?? "") }, P)) }, z)) })
2277
2887
  ] })
2278
- ] }, x);
2888
+ ] }, C);
2279
2889
  })
2280
2890
  ] })
2281
2891
  }
2282
2892
  );
2283
2893
  }
2284
2894
  export {
2285
- ks as Chart,
2286
- Ws as CouponInput,
2287
- Js as DashboardView,
2288
- vs as DataTable,
2289
- fs as InvoiceHistory,
2290
- Ms as OrgSwitcher,
2291
- Rs as PaymentPortal,
2292
- Us as PricingTable,
2293
- Gs as QueryInput,
2294
- Vs as ReportEmbed,
2295
- H as SaaSContext,
2296
- Xs as SaaSError,
2297
- Bs as SaaSProvider,
2298
- X as SaaSSupport,
2299
- Qs as SavedQueryList,
2300
- qs as SignIn,
2301
- As as SignUp,
2302
- ms as SubscriptionStatus,
2303
- ys as UsageDisplay,
2304
- Ds as UserButton,
2305
- Fs as UserProfile,
2306
- Z as isMfaRequired,
2307
- j as useAuth,
2308
- Os as useBilling,
2309
- js as useDashboard,
2310
- _s as useEmbedDashboard,
2311
- ds as useInvoices,
2312
- os as useOrg,
2313
- G as useProfile,
2314
- V as useQuery,
2315
- Hs as useReport,
2316
- k as useSaaSContext,
2317
- xs as useSavedQueries,
2318
- _ as useSignIn,
2319
- ts as useSignUp,
2320
- cs as useSubscription,
2321
- us as useUsage,
2322
- zs as useUser
2895
+ je as Chart,
2896
+ ls as CouponInput,
2897
+ ps as DashboardView,
2898
+ Re as DataTable,
2899
+ Fe as InvoiceHistory,
2900
+ as as OrgSwitcher,
2901
+ os as PaymentPortal,
2902
+ ts as PricingTable,
2903
+ us as QueryInput,
2904
+ gs as ReportEmbed,
2905
+ se as SaaSContext,
2906
+ bs as SaaSError,
2907
+ Ze as SaaSProvider,
2908
+ fe as SaaSSupport,
2909
+ ms as SavedQueryList,
2910
+ Ke as SignIn,
2911
+ es as SignUp,
2912
+ Be as SubscriptionStatus,
2913
+ Ue as UsageDisplay,
2914
+ ss as UserButton,
2915
+ rs as UserProfile,
2916
+ be as isMfaRequired,
2917
+ ee as useAuth,
2918
+ ns as useBilling,
2919
+ cs as useDashboard,
2920
+ ke as useDeleteAccount,
2921
+ ds as useEmbedDashboard,
2922
+ Ie as useInvoices,
2923
+ ae as useOrg,
2924
+ te as useProfile,
2925
+ ie as useQuery,
2926
+ is as useReport,
2927
+ L as useSaaSContext,
2928
+ qe as useSavedQueries,
2929
+ re as useSignIn,
2930
+ Ce as useSignUp,
2931
+ ze as useSubscription,
2932
+ Te as useUsage,
2933
+ Xe as useUser
2323
2934
  };