@saas-support/react 0.3.2 → 0.4.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/index.cjs +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +79 -44
- package/dist/react.cjs +107 -2
- package/dist/react.d.ts +14 -0
- package/dist/react.js +965 -661
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { SaaSSupport as
|
|
4
|
-
import { SaaSError as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const s =
|
|
1
|
+
import { jsx as e, jsxs as l, Fragment as W } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ts, useContext as ns, useState as h, useEffect as B, useRef as R, useCallback as C, useMemo as q } from "react";
|
|
3
|
+
import { SaaSSupport as os, isMfaRequired as ls, BillingClient as is, Transport as H, ReportClient as J } from "./index.js";
|
|
4
|
+
import { SaaSError as oe } from "./index.js";
|
|
5
|
+
import { createPortal as cs } from "react-dom";
|
|
6
|
+
const Q = ts(null);
|
|
7
|
+
function E() {
|
|
8
|
+
const s = ns(Q);
|
|
9
9
|
if (!s)
|
|
10
10
|
throw new Error("useSaaSContext must be used within a <SaaSProvider>");
|
|
11
11
|
return s;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const [
|
|
15
|
-
return
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
u(
|
|
13
|
+
function Rs({ publishableKey: s, apiKey: a, baseUrl: r, appearance: c, children: t }) {
|
|
14
|
+
const [i] = h(() => new os({ publishableKey: s, apiKey: a, baseUrl: r })), [d, u] = h(null), [o, n] = h(!1), [m, p] = h(null);
|
|
15
|
+
return B(() => {
|
|
16
|
+
let b = !1;
|
|
17
|
+
i.load().then(async () => {
|
|
18
|
+
if (b) return;
|
|
19
|
+
const x = await i.auth.getUser(), y = await i.auth.getSettings();
|
|
20
|
+
u(x), p(y), n(!0);
|
|
21
21
|
});
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const f = i.auth.onAuthStateChange((x) => {
|
|
23
|
+
b || u(x);
|
|
24
24
|
});
|
|
25
25
|
return () => {
|
|
26
|
-
|
|
26
|
+
b = !0, f(), i.destroy();
|
|
27
27
|
};
|
|
28
|
-
}, [
|
|
28
|
+
}, [i]), /* @__PURE__ */ e(Q.Provider, { value: { client: i, user: d, isLoaded: o, appearance: c, settings: m }, children: t });
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const ds = {
|
|
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
|
-
},
|
|
43
|
+
}, us = {
|
|
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
|
|
58
|
-
const a = (s == null ? void 0 : s.baseTheme) === "dark" ?
|
|
57
|
+
function V(s) {
|
|
58
|
+
const a = (s == null ? void 0 : s.baseTheme) === "dark" ? us : ds, r = s == null ? void 0 : s.variables;
|
|
59
59
|
return {
|
|
60
60
|
colorPrimary: (r == null ? void 0 : r.colorPrimary) ?? a.colorPrimary,
|
|
61
|
-
colorPrimaryHover: r != null && r.colorPrimary ?
|
|
61
|
+
colorPrimaryHover: r != null && r.colorPrimary ? ps(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,11 +71,11 @@ function U(s) {
|
|
|
71
71
|
borderRadius: (r == null ? void 0 : r.borderRadius) ?? a.borderRadius
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
function
|
|
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)),
|
|
76
|
-
return `#${(c << 16 | t << 8 |
|
|
74
|
+
function ps(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)), i = Math.max(0, (r & 255) - Math.round(2.55 * a));
|
|
76
|
+
return `#${(c << 16 | t << 8 | i).toString(16).padStart(6, "0")}`;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function G(s) {
|
|
79
79
|
return `
|
|
80
80
|
:host {
|
|
81
81
|
all: initial;
|
|
@@ -773,6 +773,111 @@ function O(s) {
|
|
|
773
773
|
object-fit: cover;
|
|
774
774
|
}
|
|
775
775
|
|
|
776
|
+
/* Avatar hover overlay */
|
|
777
|
+
.ss-avatar-hoverable {
|
|
778
|
+
position: relative;
|
|
779
|
+
cursor: pointer;
|
|
780
|
+
transition: filter 0.15s;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
.ss-avatar-overlay {
|
|
784
|
+
position: absolute;
|
|
785
|
+
inset: 0;
|
|
786
|
+
border-radius: 50%;
|
|
787
|
+
background: rgba(0, 0, 0, 0.5);
|
|
788
|
+
display: flex;
|
|
789
|
+
align-items: center;
|
|
790
|
+
justify-content: center;
|
|
791
|
+
opacity: 0;
|
|
792
|
+
transition: opacity 0.15s;
|
|
793
|
+
color: #fff;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
.ss-avatar-hoverable:hover .ss-avatar-overlay {
|
|
797
|
+
opacity: 1;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/* Avatar cropper */
|
|
801
|
+
.ss-avatar-cropper {
|
|
802
|
+
display: flex;
|
|
803
|
+
flex-direction: column;
|
|
804
|
+
align-items: center;
|
|
805
|
+
gap: 16px;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
.ss-avatar-canvas {
|
|
809
|
+
border-radius: ${s.borderRadius};
|
|
810
|
+
background: #111;
|
|
811
|
+
touch-action: none;
|
|
812
|
+
max-width: 100%;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
.ss-avatar-zoom {
|
|
816
|
+
display: flex;
|
|
817
|
+
align-items: center;
|
|
818
|
+
gap: 12px;
|
|
819
|
+
width: 100%;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
.ss-avatar-zoom-label {
|
|
823
|
+
font-size: 13px;
|
|
824
|
+
color: ${s.colorTextSecondary};
|
|
825
|
+
flex-shrink: 0;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
.ss-avatar-zoom-slider {
|
|
829
|
+
flex: 1;
|
|
830
|
+
height: 4px;
|
|
831
|
+
-webkit-appearance: none;
|
|
832
|
+
appearance: none;
|
|
833
|
+
background: ${s.colorInputBorder};
|
|
834
|
+
border-radius: 2px;
|
|
835
|
+
outline: none;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
.ss-avatar-zoom-slider::-webkit-slider-thumb {
|
|
839
|
+
-webkit-appearance: none;
|
|
840
|
+
width: 16px;
|
|
841
|
+
height: 16px;
|
|
842
|
+
border-radius: 50%;
|
|
843
|
+
background: ${s.colorPrimary};
|
|
844
|
+
cursor: pointer;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
.ss-avatar-zoom-slider::-moz-range-thumb {
|
|
848
|
+
width: 16px;
|
|
849
|
+
height: 16px;
|
|
850
|
+
border-radius: 50%;
|
|
851
|
+
background: ${s.colorPrimary};
|
|
852
|
+
cursor: pointer;
|
|
853
|
+
border: none;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/* Dropzone */
|
|
857
|
+
.ss-avatar-dropzone {
|
|
858
|
+
border: 2px dashed ${s.colorInputBorder};
|
|
859
|
+
border-radius: ${s.borderRadius};
|
|
860
|
+
padding: 40px 24px;
|
|
861
|
+
text-align: center;
|
|
862
|
+
cursor: pointer;
|
|
863
|
+
transition: border-color 0.15s, background 0.15s;
|
|
864
|
+
color: ${s.colorTextSecondary};
|
|
865
|
+
display: flex;
|
|
866
|
+
flex-direction: column;
|
|
867
|
+
align-items: center;
|
|
868
|
+
gap: 12px;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
.ss-avatar-dropzone:hover,
|
|
872
|
+
.ss-avatar-dropzone-active {
|
|
873
|
+
border-color: ${s.colorPrimary};
|
|
874
|
+
background: ${s.colorPrimary}08;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
.ss-avatar-dropzone svg {
|
|
878
|
+
opacity: 0.5;
|
|
879
|
+
}
|
|
880
|
+
|
|
776
881
|
.ss-input-readonly {
|
|
777
882
|
opacity: 0.6;
|
|
778
883
|
cursor: not-allowed;
|
|
@@ -805,45 +910,45 @@ function O(s) {
|
|
|
805
910
|
}
|
|
806
911
|
`;
|
|
807
912
|
}
|
|
808
|
-
function
|
|
809
|
-
const r = R(null), [c, t] =
|
|
810
|
-
|
|
913
|
+
function D({ children: s, appearance: a }) {
|
|
914
|
+
const r = R(null), [c, t] = h(null);
|
|
915
|
+
B(() => {
|
|
811
916
|
var m;
|
|
812
917
|
if (!r.current || r.current.shadowRoot) {
|
|
813
918
|
t(((m = r.current) == null ? void 0 : m.shadowRoot) ?? null);
|
|
814
919
|
return;
|
|
815
920
|
}
|
|
816
|
-
const
|
|
817
|
-
o.textContent =
|
|
921
|
+
const d = r.current.attachShadow({ mode: "open" }), u = V(a), o = document.createElement("style");
|
|
922
|
+
o.textContent = G(u), d.appendChild(o);
|
|
818
923
|
const n = document.createElement("div");
|
|
819
|
-
|
|
820
|
-
}, []),
|
|
924
|
+
d.appendChild(n), t(d);
|
|
925
|
+
}, []), B(() => {
|
|
821
926
|
if (!c) return;
|
|
822
|
-
const
|
|
823
|
-
if (
|
|
824
|
-
const u =
|
|
825
|
-
|
|
927
|
+
const d = c.querySelector("style");
|
|
928
|
+
if (d) {
|
|
929
|
+
const u = V(a);
|
|
930
|
+
d.textContent = G(u);
|
|
826
931
|
}
|
|
827
932
|
}, [a, c]);
|
|
828
|
-
const
|
|
829
|
-
return /* @__PURE__ */ e("div", { ref: r, style: { display: "contents" }, children:
|
|
933
|
+
const i = (c == null ? void 0 : c.querySelector("div")) ?? null;
|
|
934
|
+
return /* @__PURE__ */ e("div", { ref: r, style: { display: "contents" }, children: i && cs(s, i) });
|
|
830
935
|
}
|
|
831
|
-
function
|
|
832
|
-
const { client: s, user: a, isLoaded: r } =
|
|
936
|
+
function Y() {
|
|
937
|
+
const { client: s, user: a, isLoaded: r } = E();
|
|
833
938
|
return {
|
|
834
939
|
isLoaded: r,
|
|
835
940
|
isSignedIn: !!a,
|
|
836
941
|
user: a,
|
|
837
|
-
signOut:
|
|
838
|
-
getToken:
|
|
942
|
+
signOut: C(() => s.auth.signOut(), [s]),
|
|
943
|
+
getToken: C(() => s.auth.getToken(), [s])
|
|
839
944
|
};
|
|
840
945
|
}
|
|
841
|
-
function
|
|
842
|
-
const { user: s, isLoaded: a } =
|
|
946
|
+
function Os() {
|
|
947
|
+
const { user: s, isLoaded: a } = E();
|
|
843
948
|
return { user: s, isLoaded: a };
|
|
844
949
|
}
|
|
845
|
-
function
|
|
846
|
-
const { client: s } =
|
|
950
|
+
function Z() {
|
|
951
|
+
const { client: s } = E(), [a, r] = h(!1), [c, t] = h(null), i = C(
|
|
847
952
|
async (o, n) => {
|
|
848
953
|
r(!0), t(null);
|
|
849
954
|
try {
|
|
@@ -855,7 +960,7 @@ function _() {
|
|
|
855
960
|
}
|
|
856
961
|
},
|
|
857
962
|
[s]
|
|
858
|
-
),
|
|
963
|
+
), d = C(
|
|
859
964
|
async (o) => {
|
|
860
965
|
r(!0), t(null);
|
|
861
966
|
try {
|
|
@@ -867,7 +972,7 @@ function _() {
|
|
|
867
972
|
}
|
|
868
973
|
},
|
|
869
974
|
[s]
|
|
870
|
-
), u =
|
|
975
|
+
), u = C(
|
|
871
976
|
async (o, n) => {
|
|
872
977
|
r(!0), t(null);
|
|
873
978
|
try {
|
|
@@ -880,15 +985,15 @@ function _() {
|
|
|
880
985
|
},
|
|
881
986
|
[s]
|
|
882
987
|
);
|
|
883
|
-
return { signIn:
|
|
988
|
+
return { signIn: i, signInWithOAuth: d, submitMfaCode: u, isLoading: a, error: c, setError: t };
|
|
884
989
|
}
|
|
885
|
-
function
|
|
886
|
-
const { client: s } =
|
|
887
|
-
return { signUp:
|
|
888
|
-
async (
|
|
990
|
+
function ms() {
|
|
991
|
+
const { client: s } = E(), [a, r] = h(!1), [c, t] = h(null);
|
|
992
|
+
return { signUp: C(
|
|
993
|
+
async (d, u) => {
|
|
889
994
|
r(!0), t(null);
|
|
890
995
|
try {
|
|
891
|
-
return await s.auth.signUp(
|
|
996
|
+
return await s.auth.signUp(d, u);
|
|
892
997
|
} catch (o) {
|
|
893
998
|
return t(o instanceof Error ? o.message : "Sign up failed"), null;
|
|
894
999
|
} finally {
|
|
@@ -898,121 +1003,134 @@ function ts() {
|
|
|
898
1003
|
[s]
|
|
899
1004
|
), isLoading: a, error: c, setError: t };
|
|
900
1005
|
}
|
|
901
|
-
function
|
|
902
|
-
const { client: s } =
|
|
1006
|
+
function gs() {
|
|
1007
|
+
const { client: s } = E(), [a, r] = h([]), [c, t] = h(null), [i, d] = h([]), [u, o] = h(!1), [n, m] = h(null), p = C(async () => {
|
|
903
1008
|
o(!0), m(null);
|
|
904
1009
|
try {
|
|
905
|
-
const
|
|
906
|
-
r(
|
|
907
|
-
} catch (
|
|
908
|
-
m(
|
|
1010
|
+
const x = await s.auth.listOrgs();
|
|
1011
|
+
r(x);
|
|
1012
|
+
} catch (x) {
|
|
1013
|
+
m(x instanceof Error ? x.message : "Failed to load organizations");
|
|
909
1014
|
} finally {
|
|
910
1015
|
o(!1);
|
|
911
1016
|
}
|
|
912
1017
|
}, [s]);
|
|
913
|
-
|
|
1018
|
+
B(() => {
|
|
914
1019
|
p();
|
|
915
1020
|
}, [p]);
|
|
916
|
-
const
|
|
1021
|
+
const b = C(async (x) => {
|
|
917
1022
|
try {
|
|
918
|
-
const
|
|
919
|
-
t(
|
|
920
|
-
const
|
|
921
|
-
|
|
922
|
-
} catch (
|
|
923
|
-
m(
|
|
924
|
-
}
|
|
925
|
-
}, [s]),
|
|
1023
|
+
const y = await s.auth.getOrg(x);
|
|
1024
|
+
t(y);
|
|
1025
|
+
const w = await s.auth.listMembers(x);
|
|
1026
|
+
d(w);
|
|
1027
|
+
} catch (y) {
|
|
1028
|
+
m(y instanceof Error ? y.message : "Failed to load organization");
|
|
1029
|
+
}
|
|
1030
|
+
}, [s]), f = C(async (x, y) => {
|
|
926
1031
|
try {
|
|
927
|
-
const
|
|
928
|
-
return r((
|
|
929
|
-
} catch (
|
|
930
|
-
return m(
|
|
1032
|
+
const w = await s.auth.createOrg(x, y);
|
|
1033
|
+
return r((v) => [...v, w]), w;
|
|
1034
|
+
} catch (w) {
|
|
1035
|
+
return m(w instanceof Error ? w.message : "Failed to create organization"), null;
|
|
931
1036
|
}
|
|
932
1037
|
}, [s]);
|
|
933
|
-
return { orgs: a, selectedOrg: c, members:
|
|
1038
|
+
return { orgs: a, selectedOrg: c, members: i, isLoading: u, error: n, refresh: p, selectOrg: b, createOrg: f };
|
|
934
1039
|
}
|
|
935
|
-
function
|
|
936
|
-
const { client: s, user: a } =
|
|
937
|
-
async (
|
|
938
|
-
c(!0),
|
|
1040
|
+
function X() {
|
|
1041
|
+
const { client: s, user: a } = E(), [r, c] = h(!1), [t, i] = h(null), [d, u] = h(null), o = C(
|
|
1042
|
+
async (p) => {
|
|
1043
|
+
c(!0), i(null), u(null);
|
|
1044
|
+
try {
|
|
1045
|
+
const b = await s.auth.updateProfile(p);
|
|
1046
|
+
return u("Profile updated"), b;
|
|
1047
|
+
} catch (b) {
|
|
1048
|
+
return i(b instanceof Error ? b.message : "Failed to update profile"), null;
|
|
1049
|
+
} finally {
|
|
1050
|
+
c(!1);
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
[s]
|
|
1054
|
+
), n = C(
|
|
1055
|
+
async (p, b) => {
|
|
1056
|
+
c(!0), i(null), u(null);
|
|
939
1057
|
try {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
return d(p instanceof Error ? p.message : "Failed to update profile"), null;
|
|
1058
|
+
return await s.auth.changePassword(p, b), u("Password changed successfully"), !0;
|
|
1059
|
+
} catch (f) {
|
|
1060
|
+
return i(f instanceof Error ? f.message : "Failed to change password"), !1;
|
|
944
1061
|
} finally {
|
|
945
1062
|
c(!1);
|
|
946
1063
|
}
|
|
947
1064
|
},
|
|
948
1065
|
[s]
|
|
949
|
-
),
|
|
950
|
-
async (
|
|
951
|
-
c(!0),
|
|
1066
|
+
), m = C(
|
|
1067
|
+
async (p) => {
|
|
1068
|
+
c(!0), i(null), u(null);
|
|
952
1069
|
try {
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1070
|
+
const b = await s.auth.uploadAvatar(p);
|
|
1071
|
+
return u("Avatar updated"), b;
|
|
1072
|
+
} catch (b) {
|
|
1073
|
+
return i(b instanceof Error ? b.message : "Failed to upload avatar"), null;
|
|
956
1074
|
} finally {
|
|
957
1075
|
c(!1);
|
|
958
1076
|
}
|
|
959
1077
|
},
|
|
960
1078
|
[s]
|
|
961
1079
|
);
|
|
962
|
-
return { user: a, updateProfile: o, changePassword: n, isLoading: r, error: t, success:
|
|
1080
|
+
return { user: a, updateProfile: o, uploadAvatar: m, changePassword: n, isLoading: r, error: t, success: d, setError: i, setSuccess: u };
|
|
963
1081
|
}
|
|
964
|
-
const
|
|
965
|
-
function
|
|
966
|
-
const { appearance: c, settings: t } =
|
|
967
|
-
async (
|
|
968
|
-
if (
|
|
969
|
-
await u(
|
|
1082
|
+
const K = '<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>', ss = '<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>';
|
|
1083
|
+
function Ws({ appearance: s, signUpUrl: a, onSignUp: r }) {
|
|
1084
|
+
const { appearance: c, settings: t } = E(), { signIn: i, signInWithOAuth: d, submitMfaCode: u, isLoading: o, error: n, setError: m } = Z(), p = s ?? c, [b, f] = h(""), [x, y] = h(""), [w, v] = h(!1), [g, N] = h(""), [S, k] = h(""), z = C(
|
|
1085
|
+
async (T) => {
|
|
1086
|
+
if (T.preventDefault(), w) {
|
|
1087
|
+
await u(g, S);
|
|
970
1088
|
return;
|
|
971
1089
|
}
|
|
972
|
-
const
|
|
973
|
-
|
|
1090
|
+
const $ = await i(b, x);
|
|
1091
|
+
$ && ls($) && (N($.mfaToken), v(!0), m(null));
|
|
974
1092
|
},
|
|
975
|
-
[
|
|
976
|
-
),
|
|
977
|
-
async (
|
|
978
|
-
await
|
|
1093
|
+
[b, x, w, g, S, i, u, m]
|
|
1094
|
+
), P = C(
|
|
1095
|
+
async (T) => {
|
|
1096
|
+
await d(T);
|
|
979
1097
|
},
|
|
980
|
-
[
|
|
981
|
-
),
|
|
982
|
-
return /* @__PURE__ */ e(
|
|
1098
|
+
[d]
|
|
1099
|
+
), A = (t == null ? void 0 : t.googleEnabled) || (t == null ? void 0 : t.githubEnabled);
|
|
1100
|
+
return /* @__PURE__ */ e(D, { appearance: p, children: /* @__PURE__ */ l("div", { className: "ss-card", children: [
|
|
983
1101
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Sign in" }),
|
|
984
|
-
!
|
|
985
|
-
(t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */
|
|
1102
|
+
!w && /* @__PURE__ */ l(W, { children: [
|
|
1103
|
+
(t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */ l(
|
|
986
1104
|
"button",
|
|
987
1105
|
{
|
|
988
1106
|
type: "button",
|
|
989
1107
|
className: "ss-btn-social",
|
|
990
|
-
onClick: () =>
|
|
1108
|
+
onClick: () => P("google"),
|
|
991
1109
|
disabled: o,
|
|
992
1110
|
children: [
|
|
993
|
-
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html:
|
|
1111
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: K } }),
|
|
994
1112
|
"Continue with Google"
|
|
995
1113
|
]
|
|
996
1114
|
}
|
|
997
1115
|
),
|
|
998
|
-
(t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */
|
|
1116
|
+
(t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */ l(
|
|
999
1117
|
"button",
|
|
1000
1118
|
{
|
|
1001
1119
|
type: "button",
|
|
1002
1120
|
className: "ss-btn-social",
|
|
1003
|
-
onClick: () =>
|
|
1121
|
+
onClick: () => P("github"),
|
|
1004
1122
|
disabled: o,
|
|
1005
1123
|
children: [
|
|
1006
|
-
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html:
|
|
1124
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: ss } }),
|
|
1007
1125
|
"Continue with GitHub"
|
|
1008
1126
|
]
|
|
1009
1127
|
}
|
|
1010
1128
|
),
|
|
1011
|
-
|
|
1129
|
+
A && /* @__PURE__ */ e("div", { className: "ss-divider", children: "or" })
|
|
1012
1130
|
] }),
|
|
1013
1131
|
n && /* @__PURE__ */ e("div", { className: "ss-global-error", children: n }),
|
|
1014
|
-
/* @__PURE__ */
|
|
1015
|
-
|
|
1132
|
+
/* @__PURE__ */ l("form", { onSubmit: z, children: [
|
|
1133
|
+
w ? /* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1016
1134
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-mfa-code", children: "Authentication code" }),
|
|
1017
1135
|
/* @__PURE__ */ e(
|
|
1018
1136
|
"input",
|
|
@@ -1023,13 +1141,13 @@ function qs({ appearance: s, signUpUrl: a, onSignUp: r }) {
|
|
|
1023
1141
|
inputMode: "numeric",
|
|
1024
1142
|
autoComplete: "one-time-code",
|
|
1025
1143
|
placeholder: "Enter 6-digit code",
|
|
1026
|
-
value:
|
|
1027
|
-
onChange: (
|
|
1144
|
+
value: S,
|
|
1145
|
+
onChange: (T) => k(T.target.value),
|
|
1028
1146
|
autoFocus: !0
|
|
1029
1147
|
}
|
|
1030
1148
|
)
|
|
1031
|
-
] }) : /* @__PURE__ */
|
|
1032
|
-
/* @__PURE__ */
|
|
1149
|
+
] }) : /* @__PURE__ */ l(W, { children: [
|
|
1150
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1033
1151
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-email", children: "Email" }),
|
|
1034
1152
|
/* @__PURE__ */ e(
|
|
1035
1153
|
"input",
|
|
@@ -1039,13 +1157,13 @@ function qs({ appearance: s, signUpUrl: a, onSignUp: r }) {
|
|
|
1039
1157
|
type: "email",
|
|
1040
1158
|
autoComplete: "email",
|
|
1041
1159
|
placeholder: "you@example.com",
|
|
1042
|
-
value:
|
|
1043
|
-
onChange: (
|
|
1160
|
+
value: b,
|
|
1161
|
+
onChange: (T) => f(T.target.value),
|
|
1044
1162
|
required: !0
|
|
1045
1163
|
}
|
|
1046
1164
|
)
|
|
1047
1165
|
] }),
|
|
1048
|
-
/* @__PURE__ */
|
|
1166
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1049
1167
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-password", children: "Password" }),
|
|
1050
1168
|
/* @__PURE__ */ e(
|
|
1051
1169
|
"input",
|
|
@@ -1055,88 +1173,88 @@ function qs({ appearance: s, signUpUrl: a, onSignUp: r }) {
|
|
|
1055
1173
|
type: "password",
|
|
1056
1174
|
autoComplete: "current-password",
|
|
1057
1175
|
placeholder: "Enter your password",
|
|
1058
|
-
value:
|
|
1059
|
-
onChange: (
|
|
1176
|
+
value: x,
|
|
1177
|
+
onChange: (T) => y(T.target.value),
|
|
1060
1178
|
required: !0
|
|
1061
1179
|
}
|
|
1062
1180
|
)
|
|
1063
1181
|
] })
|
|
1064
1182
|
] }),
|
|
1065
|
-
/* @__PURE__ */
|
|
1183
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: o, children: [
|
|
1066
1184
|
o && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1067
|
-
|
|
1185
|
+
w ? "Verify" : "Continue"
|
|
1068
1186
|
] })
|
|
1069
1187
|
] }),
|
|
1070
|
-
|
|
1188
|
+
w && /* @__PURE__ */ e("div", { className: "ss-footer", children: /* @__PURE__ */ e(
|
|
1071
1189
|
"span",
|
|
1072
1190
|
{
|
|
1073
1191
|
className: "ss-link",
|
|
1074
1192
|
onClick: () => {
|
|
1075
|
-
|
|
1193
|
+
v(!1), k(""), m(null);
|
|
1076
1194
|
},
|
|
1077
1195
|
children: "Back to sign in"
|
|
1078
1196
|
}
|
|
1079
1197
|
) }),
|
|
1080
|
-
!
|
|
1198
|
+
!w && /* @__PURE__ */ l("div", { className: "ss-footer", children: [
|
|
1081
1199
|
"Don't have an account?",
|
|
1082
1200
|
" ",
|
|
1083
1201
|
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" })
|
|
1084
1202
|
] })
|
|
1085
1203
|
] }) });
|
|
1086
1204
|
}
|
|
1087
|
-
function
|
|
1088
|
-
const { appearance: c, settings: t } =
|
|
1089
|
-
async (
|
|
1090
|
-
if (
|
|
1091
|
-
|
|
1205
|
+
function Hs({ appearance: s, signInUrl: a, onSignIn: r }) {
|
|
1206
|
+
const { appearance: c, settings: t } = E(), { signUp: i, isLoading: d, error: u, setError: o } = ms(), { signInWithOAuth: n } = Z(), m = s ?? c, [p, b] = h(""), [f, x] = h(""), [y, w] = h(""), [v, g] = h(null), N = C(
|
|
1207
|
+
async (P) => {
|
|
1208
|
+
if (P.preventDefault(), g(null), f !== y) {
|
|
1209
|
+
g("Passwords do not match");
|
|
1092
1210
|
return;
|
|
1093
1211
|
}
|
|
1094
|
-
const
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1212
|
+
const A = (t == null ? void 0 : t.passwordMinLength) ?? 8;
|
|
1213
|
+
if (f.length < A) {
|
|
1214
|
+
g(`Password must be at least ${A} characters`);
|
|
1097
1215
|
return;
|
|
1098
1216
|
}
|
|
1099
|
-
await
|
|
1217
|
+
await i(p, f);
|
|
1100
1218
|
},
|
|
1101
|
-
[p,
|
|
1102
|
-
),
|
|
1103
|
-
async (
|
|
1104
|
-
await n(
|
|
1219
|
+
[p, f, y, t, i]
|
|
1220
|
+
), S = C(
|
|
1221
|
+
async (P) => {
|
|
1222
|
+
await n(P);
|
|
1105
1223
|
},
|
|
1106
1224
|
[n]
|
|
1107
|
-
),
|
|
1108
|
-
return /* @__PURE__ */ e(
|
|
1225
|
+
), k = (t == null ? void 0 : t.googleEnabled) || (t == null ? void 0 : t.githubEnabled), z = v || u;
|
|
1226
|
+
return /* @__PURE__ */ e(D, { appearance: m, children: /* @__PURE__ */ l("div", { className: "ss-card", children: [
|
|
1109
1227
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Create account" }),
|
|
1110
|
-
(t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */
|
|
1228
|
+
(t == null ? void 0 : t.googleEnabled) && /* @__PURE__ */ l(
|
|
1111
1229
|
"button",
|
|
1112
1230
|
{
|
|
1113
1231
|
type: "button",
|
|
1114
1232
|
className: "ss-btn-social",
|
|
1115
|
-
onClick: () =>
|
|
1116
|
-
disabled:
|
|
1233
|
+
onClick: () => S("google"),
|
|
1234
|
+
disabled: d,
|
|
1117
1235
|
children: [
|
|
1118
|
-
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html:
|
|
1236
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: K } }),
|
|
1119
1237
|
"Continue with Google"
|
|
1120
1238
|
]
|
|
1121
1239
|
}
|
|
1122
1240
|
),
|
|
1123
|
-
(t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */
|
|
1241
|
+
(t == null ? void 0 : t.githubEnabled) && /* @__PURE__ */ l(
|
|
1124
1242
|
"button",
|
|
1125
1243
|
{
|
|
1126
1244
|
type: "button",
|
|
1127
1245
|
className: "ss-btn-social",
|
|
1128
|
-
onClick: () =>
|
|
1129
|
-
disabled:
|
|
1246
|
+
onClick: () => S("github"),
|
|
1247
|
+
disabled: d,
|
|
1130
1248
|
children: [
|
|
1131
|
-
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html:
|
|
1249
|
+
/* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: ss } }),
|
|
1132
1250
|
"Continue with GitHub"
|
|
1133
1251
|
]
|
|
1134
1252
|
}
|
|
1135
1253
|
),
|
|
1136
|
-
|
|
1254
|
+
k && /* @__PURE__ */ e("div", { className: "ss-divider", children: "or" }),
|
|
1137
1255
|
z && /* @__PURE__ */ e("div", { className: "ss-global-error", children: z }),
|
|
1138
|
-
/* @__PURE__ */
|
|
1139
|
-
/* @__PURE__ */
|
|
1256
|
+
/* @__PURE__ */ l("form", { onSubmit: N, children: [
|
|
1257
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1140
1258
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-email", children: "Email" }),
|
|
1141
1259
|
/* @__PURE__ */ e(
|
|
1142
1260
|
"input",
|
|
@@ -1147,12 +1265,12 @@ function As({ appearance: s, signInUrl: a, onSignIn: r }) {
|
|
|
1147
1265
|
autoComplete: "email",
|
|
1148
1266
|
placeholder: "you@example.com",
|
|
1149
1267
|
value: p,
|
|
1150
|
-
onChange: (
|
|
1268
|
+
onChange: (P) => b(P.target.value),
|
|
1151
1269
|
required: !0
|
|
1152
1270
|
}
|
|
1153
1271
|
)
|
|
1154
1272
|
] }),
|
|
1155
|
-
/* @__PURE__ */
|
|
1273
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1156
1274
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-password", children: "Password" }),
|
|
1157
1275
|
/* @__PURE__ */ e(
|
|
1158
1276
|
"input",
|
|
@@ -1162,15 +1280,15 @@ function As({ appearance: s, signInUrl: a, onSignIn: r }) {
|
|
|
1162
1280
|
type: "password",
|
|
1163
1281
|
autoComplete: "new-password",
|
|
1164
1282
|
placeholder: "Create a password",
|
|
1165
|
-
value:
|
|
1166
|
-
onChange: (
|
|
1167
|
-
|
|
1283
|
+
value: f,
|
|
1284
|
+
onChange: (P) => {
|
|
1285
|
+
x(P.target.value), g(null);
|
|
1168
1286
|
},
|
|
1169
1287
|
required: !0
|
|
1170
1288
|
}
|
|
1171
1289
|
)
|
|
1172
1290
|
] }),
|
|
1173
|
-
/* @__PURE__ */
|
|
1291
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1174
1292
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-signup-confirm", children: "Confirm password" }),
|
|
1175
1293
|
/* @__PURE__ */ e(
|
|
1176
1294
|
"input",
|
|
@@ -1180,54 +1298,200 @@ function As({ appearance: s, signInUrl: a, onSignIn: r }) {
|
|
|
1180
1298
|
type: "password",
|
|
1181
1299
|
autoComplete: "new-password",
|
|
1182
1300
|
placeholder: "Confirm your password",
|
|
1183
|
-
value:
|
|
1184
|
-
onChange: (
|
|
1185
|
-
|
|
1301
|
+
value: y,
|
|
1302
|
+
onChange: (P) => {
|
|
1303
|
+
w(P.target.value), g(null);
|
|
1186
1304
|
},
|
|
1187
1305
|
required: !0
|
|
1188
1306
|
}
|
|
1189
1307
|
)
|
|
1190
1308
|
] }),
|
|
1191
|
-
/* @__PURE__ */
|
|
1192
|
-
|
|
1309
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: d, children: [
|
|
1310
|
+
d && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1193
1311
|
"Create account"
|
|
1194
1312
|
] })
|
|
1195
1313
|
] }),
|
|
1196
|
-
/* @__PURE__ */
|
|
1314
|
+
/* @__PURE__ */ l("div", { className: "ss-footer", children: [
|
|
1197
1315
|
"Already have an account?",
|
|
1198
1316
|
" ",
|
|
1199
1317
|
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" })
|
|
1200
1318
|
] })
|
|
1201
1319
|
] }) });
|
|
1202
1320
|
}
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1321
|
+
const I = 256, F = 112;
|
|
1322
|
+
function hs({ file: s, onCrop: a, onCancel: r }) {
|
|
1323
|
+
const c = R(null), t = R(null), [i, d] = h(1), [u, o] = h({ x: 0, y: 0 }), [n, m] = h(!1), p = R({ x: 0, y: 0, ox: 0, oy: 0 }), [b, f] = h(!1);
|
|
1324
|
+
B(() => {
|
|
1325
|
+
const g = new Image(), N = URL.createObjectURL(s);
|
|
1326
|
+
return g.onload = () => {
|
|
1327
|
+
t.current = g, f(!0), o({ x: 0, y: 0 }), d(1);
|
|
1328
|
+
}, g.src = N, () => URL.revokeObjectURL(N);
|
|
1329
|
+
}, [s]), B(() => {
|
|
1330
|
+
if (!b || !t.current || !c.current) return;
|
|
1331
|
+
const g = c.current.getContext("2d");
|
|
1332
|
+
if (!g) return;
|
|
1333
|
+
const N = t.current;
|
|
1334
|
+
g.clearRect(0, 0, I, I), g.fillStyle = "#111", g.fillRect(0, 0, I, I);
|
|
1335
|
+
const S = Math.max(I / N.width, I / N.height) * i, k = N.width * S, z = N.height * S, P = (I - k) / 2 + u.x, A = (I - z) / 2 + u.y;
|
|
1336
|
+
g.save(), g.beginPath(), g.arc(I / 2, I / 2, F, 0, Math.PI * 2), g.clip(), g.drawImage(N, P, A, k, z), g.restore(), g.save(), g.fillStyle = "rgba(0, 0, 0, 0.6)", g.fillRect(0, 0, I, I), g.globalCompositeOperation = "destination-out", g.beginPath(), g.arc(I / 2, I / 2, F, 0, Math.PI * 2), g.fill(), g.restore(), g.save(), g.beginPath(), g.arc(I / 2, I / 2, F, 0, Math.PI * 2), g.clip(), g.drawImage(N, P, A, k, z), g.restore(), g.strokeStyle = "rgba(255, 255, 255, 0.6)", g.lineWidth = 2, g.beginPath(), g.arc(I / 2, I / 2, F, 0, Math.PI * 2), g.stroke();
|
|
1337
|
+
}, [i, u, b]);
|
|
1338
|
+
const x = C(
|
|
1339
|
+
(g) => {
|
|
1340
|
+
m(!0), p.current = { x: g.clientX, y: g.clientY, ox: u.x, oy: u.y }, g.target.setPointerCapture(g.pointerId);
|
|
1341
|
+
},
|
|
1342
|
+
[u]
|
|
1343
|
+
), y = C(
|
|
1344
|
+
(g) => {
|
|
1345
|
+
n && o({
|
|
1346
|
+
x: p.current.ox + (g.clientX - p.current.x),
|
|
1347
|
+
y: p.current.oy + (g.clientY - p.current.y)
|
|
1348
|
+
});
|
|
1349
|
+
},
|
|
1350
|
+
[n]
|
|
1351
|
+
), w = C(() => m(!1), []), v = C(() => {
|
|
1352
|
+
if (!t.current) return;
|
|
1353
|
+
const g = document.createElement("canvas"), N = F * 2;
|
|
1354
|
+
g.width = N, g.height = N;
|
|
1355
|
+
const S = g.getContext("2d");
|
|
1356
|
+
if (!S) return;
|
|
1357
|
+
const k = t.current, z = Math.max(I / k.width, I / k.height) * i, P = k.width * z, A = k.height * z, T = (I - P) / 2 + u.x - (I / 2 - F), $ = (I - A) / 2 + u.y - (I / 2 - F);
|
|
1358
|
+
S.beginPath(), S.arc(F, F, F, 0, Math.PI * 2), S.clip(), S.drawImage(k, T, $, P, A), g.toBlob((M) => {
|
|
1359
|
+
M && a(M);
|
|
1360
|
+
}, "image/png");
|
|
1361
|
+
}, [i, u, a]);
|
|
1362
|
+
return /* @__PURE__ */ l("div", { className: "ss-avatar-cropper", children: [
|
|
1363
|
+
/* @__PURE__ */ e(
|
|
1364
|
+
"canvas",
|
|
1365
|
+
{
|
|
1366
|
+
ref: c,
|
|
1367
|
+
width: I,
|
|
1368
|
+
height: I,
|
|
1369
|
+
className: "ss-avatar-canvas",
|
|
1370
|
+
onPointerDown: x,
|
|
1371
|
+
onPointerMove: y,
|
|
1372
|
+
onPointerUp: w,
|
|
1373
|
+
style: { cursor: n ? "grabbing" : "grab" }
|
|
1374
|
+
}
|
|
1375
|
+
),
|
|
1376
|
+
/* @__PURE__ */ l("div", { className: "ss-avatar-zoom", children: [
|
|
1377
|
+
/* @__PURE__ */ e("span", { className: "ss-avatar-zoom-label", children: "Zoom" }),
|
|
1378
|
+
/* @__PURE__ */ e(
|
|
1379
|
+
"input",
|
|
1380
|
+
{
|
|
1381
|
+
type: "range",
|
|
1382
|
+
min: "1",
|
|
1383
|
+
max: "3",
|
|
1384
|
+
step: "0.01",
|
|
1385
|
+
value: i,
|
|
1386
|
+
onChange: (g) => d(parseFloat(g.target.value)),
|
|
1387
|
+
className: "ss-avatar-zoom-slider"
|
|
1388
|
+
}
|
|
1389
|
+
)
|
|
1390
|
+
] }),
|
|
1391
|
+
/* @__PURE__ */ l("div", { className: "ss-btn-group", children: [
|
|
1392
|
+
/* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger ss-btn-sm", onClick: r, children: "Cancel" }),
|
|
1393
|
+
/* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-primary ss-btn-sm", onClick: v, children: "Save" })
|
|
1394
|
+
] })
|
|
1395
|
+
] });
|
|
1396
|
+
}
|
|
1397
|
+
function es({ onUpload: s, onClose: a, isLoading: r }) {
|
|
1398
|
+
const [c, t] = h(null), [i, d] = h(!1), [u, o] = h(null), n = R(null), m = C((f) => {
|
|
1399
|
+
if (!f.type.startsWith("image/")) {
|
|
1400
|
+
o("Please select an image file");
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
if (f.size > 5 * 1024 * 1024) {
|
|
1404
|
+
o("Image must be smaller than 5 MB");
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
o(null), t(f);
|
|
1408
|
+
}, []), p = C(
|
|
1409
|
+
(f) => {
|
|
1410
|
+
f.preventDefault(), d(!1);
|
|
1411
|
+
const x = f.dataTransfer.files[0];
|
|
1412
|
+
x && m(x);
|
|
1413
|
+
},
|
|
1414
|
+
[m]
|
|
1415
|
+
), b = C(
|
|
1416
|
+
async (f) => {
|
|
1417
|
+
await s(f);
|
|
1418
|
+
},
|
|
1419
|
+
[s]
|
|
1420
|
+
);
|
|
1421
|
+
return /* @__PURE__ */ e("div", { className: "ss-modal-overlay", onClick: (f) => {
|
|
1422
|
+
f.target === f.currentTarget && a();
|
|
1423
|
+
}, children: /* @__PURE__ */ l("div", { className: "ss-modal", children: [
|
|
1424
|
+
/* @__PURE__ */ l("div", { className: "ss-modal-header", children: [
|
|
1425
|
+
/* @__PURE__ */ e("span", { className: "ss-modal-title", children: "Upload Avatar" }),
|
|
1426
|
+
/* @__PURE__ */ e("button", { type: "button", className: "ss-modal-close", onClick: a, children: "✕" })
|
|
1427
|
+
] }),
|
|
1428
|
+
u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
|
|
1429
|
+
c ? /* @__PURE__ */ e(hs, { file: c, onCrop: b, onCancel: () => t(null) }) : /* @__PURE__ */ l(
|
|
1430
|
+
"div",
|
|
1431
|
+
{
|
|
1432
|
+
className: `ss-avatar-dropzone${i ? " ss-avatar-dropzone-active" : ""}`,
|
|
1433
|
+
onDragOver: (f) => {
|
|
1434
|
+
f.preventDefault(), d(!0);
|
|
1435
|
+
},
|
|
1436
|
+
onDragLeave: () => d(!1),
|
|
1437
|
+
onDrop: p,
|
|
1438
|
+
onClick: () => {
|
|
1439
|
+
var f;
|
|
1440
|
+
return (f = n.current) == null ? void 0 : f.click();
|
|
1441
|
+
},
|
|
1442
|
+
children: [
|
|
1443
|
+
/* @__PURE__ */ l("svg", { width: "40", height: "40", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
1444
|
+
/* @__PURE__ */ e("path", { d: "M12 16a4 4 0 100-8 4 4 0 000 8z" }),
|
|
1445
|
+
/* @__PURE__ */ e("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" })
|
|
1446
|
+
] }),
|
|
1447
|
+
/* @__PURE__ */ e("span", { children: "Drop image here or click to browse" }),
|
|
1448
|
+
/* @__PURE__ */ e(
|
|
1449
|
+
"input",
|
|
1450
|
+
{
|
|
1451
|
+
ref: n,
|
|
1452
|
+
type: "file",
|
|
1453
|
+
accept: "image/*",
|
|
1454
|
+
style: { display: "none" },
|
|
1455
|
+
onChange: (f) => {
|
|
1456
|
+
var x;
|
|
1457
|
+
(x = f.target.files) != null && x[0] && m(f.target.files[0]);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
)
|
|
1461
|
+
]
|
|
1462
|
+
}
|
|
1463
|
+
),
|
|
1464
|
+
r && /* @__PURE__ */ e("div", { className: "ss-loading", children: "Uploading..." })
|
|
1465
|
+
] }) });
|
|
1466
|
+
}
|
|
1467
|
+
function js({ appearance: s }) {
|
|
1468
|
+
const { appearance: a } = E(), { user: r, signOut: c } = Y(), t = s ?? a, [i, d] = h(!1), [u, o] = h(!1), n = R(null), m = C((b) => {
|
|
1469
|
+
n.current && !b.composedPath().includes(n.current) && d(!1);
|
|
1206
1470
|
}, []);
|
|
1207
|
-
if (
|
|
1208
|
-
if (
|
|
1209
|
-
const
|
|
1471
|
+
if (B(() => {
|
|
1472
|
+
if (i) {
|
|
1473
|
+
const b = setTimeout(() => {
|
|
1210
1474
|
document.addEventListener("click", m);
|
|
1211
1475
|
}, 0);
|
|
1212
1476
|
return () => {
|
|
1213
|
-
clearTimeout(
|
|
1477
|
+
clearTimeout(b), document.removeEventListener("click", m);
|
|
1214
1478
|
};
|
|
1215
1479
|
}
|
|
1216
|
-
}, [
|
|
1480
|
+
}, [i, m]), !r) return null;
|
|
1217
1481
|
const p = (r.name || r.email).charAt(0).toUpperCase();
|
|
1218
|
-
return /* @__PURE__ */ e(
|
|
1482
|
+
return /* @__PURE__ */ e(D, { appearance: t, children: /* @__PURE__ */ l("div", { className: "ss-user-btn", ref: n, children: [
|
|
1219
1483
|
/* @__PURE__ */ e(
|
|
1220
1484
|
"button",
|
|
1221
1485
|
{
|
|
1222
1486
|
type: "button",
|
|
1223
1487
|
className: "ss-avatar",
|
|
1224
|
-
onClick: () =>
|
|
1488
|
+
onClick: () => d(!i),
|
|
1225
1489
|
"aria-label": "User menu",
|
|
1226
1490
|
children: r.avatarUrl ? /* @__PURE__ */ e("img", { src: r.avatarUrl, alt: "", style: { width: "100%", height: "100%", borderRadius: "50%", objectFit: "cover" } }) : p
|
|
1227
1491
|
}
|
|
1228
1492
|
),
|
|
1229
|
-
|
|
1230
|
-
/* @__PURE__ */
|
|
1493
|
+
i && /* @__PURE__ */ l("div", { className: "ss-dropdown", children: [
|
|
1494
|
+
/* @__PURE__ */ l("div", { className: "ss-dropdown-header", children: [
|
|
1231
1495
|
r.name && /* @__PURE__ */ e("div", { style: { fontWeight: 600, fontSize: "14px", color: "inherit" }, children: r.name }),
|
|
1232
1496
|
/* @__PURE__ */ e("div", { className: "ss-dropdown-email", children: r.email })
|
|
1233
1497
|
] }),
|
|
@@ -1237,7 +1501,7 @@ function Ds({ appearance: s }) {
|
|
|
1237
1501
|
type: "button",
|
|
1238
1502
|
className: "ss-dropdown-item",
|
|
1239
1503
|
onClick: () => {
|
|
1240
|
-
|
|
1504
|
+
d(!1), o(!0);
|
|
1241
1505
|
},
|
|
1242
1506
|
children: "Profile"
|
|
1243
1507
|
}
|
|
@@ -1248,47 +1512,67 @@ function Ds({ appearance: s }) {
|
|
|
1248
1512
|
type: "button",
|
|
1249
1513
|
className: "ss-dropdown-item ss-dropdown-item-danger",
|
|
1250
1514
|
onClick: async () => {
|
|
1251
|
-
|
|
1515
|
+
d(!1), await c();
|
|
1252
1516
|
},
|
|
1253
1517
|
children: "Sign out"
|
|
1254
1518
|
}
|
|
1255
1519
|
)
|
|
1256
1520
|
] }),
|
|
1257
|
-
u && /* @__PURE__ */ e(
|
|
1521
|
+
u && /* @__PURE__ */ e(bs, { onClose: () => o(!1) })
|
|
1258
1522
|
] }) });
|
|
1259
1523
|
}
|
|
1260
|
-
function
|
|
1261
|
-
const { user: a, updateProfile: r,
|
|
1262
|
-
async (
|
|
1263
|
-
|
|
1524
|
+
function bs({ onClose: s }) {
|
|
1525
|
+
const { user: a, updateProfile: r, uploadAvatar: c, changePassword: t, isLoading: i, error: d, success: u, setError: o, setSuccess: n } = X(), [m, p] = h((a == null ? void 0 : a.name) ?? ""), [b, f] = h((a == null ? void 0 : a.avatarUrl) ?? ""), [x, y] = h(!1), [w, v] = h(""), [g, N] = h(""), [S, k] = h(""), [z, P] = h(null), A = C(
|
|
1526
|
+
async (L) => {
|
|
1527
|
+
L.preventDefault(), o(null), n(null), await r({ name: m, avatarUrl: b || void 0 });
|
|
1264
1528
|
},
|
|
1265
|
-
[
|
|
1266
|
-
),
|
|
1267
|
-
async (
|
|
1268
|
-
|
|
1269
|
-
|
|
1529
|
+
[m, b, r, o, n]
|
|
1530
|
+
), T = C(
|
|
1531
|
+
async (L) => {
|
|
1532
|
+
const O = await c(L);
|
|
1533
|
+
O && (f(O.avatarUrl), y(!1));
|
|
1534
|
+
},
|
|
1535
|
+
[c]
|
|
1536
|
+
), $ = C(
|
|
1537
|
+
async (L) => {
|
|
1538
|
+
if (L.preventDefault(), P(null), o(null), n(null), g !== S) {
|
|
1539
|
+
P("Passwords do not match");
|
|
1270
1540
|
return;
|
|
1271
1541
|
}
|
|
1272
|
-
if (
|
|
1273
|
-
|
|
1542
|
+
if (g.length < 8) {
|
|
1543
|
+
P("Password must be at least 8 characters");
|
|
1274
1544
|
return;
|
|
1275
1545
|
}
|
|
1276
|
-
await
|
|
1546
|
+
await t(w, g) && (v(""), N(""), k(""));
|
|
1277
1547
|
},
|
|
1278
|
-
[
|
|
1279
|
-
),
|
|
1280
|
-
return /* @__PURE__ */ e("div", { className: "ss-modal-overlay", onClick: (
|
|
1281
|
-
|
|
1282
|
-
}, children: /* @__PURE__ */
|
|
1283
|
-
/* @__PURE__ */
|
|
1548
|
+
[w, g, S, t, o, n]
|
|
1549
|
+
), M = (a == null ? void 0 : a.provider) === "email";
|
|
1550
|
+
return /* @__PURE__ */ e("div", { className: "ss-modal-overlay", onClick: (L) => {
|
|
1551
|
+
L.target === L.currentTarget && s();
|
|
1552
|
+
}, children: /* @__PURE__ */ l("div", { className: "ss-modal", children: [
|
|
1553
|
+
/* @__PURE__ */ l("div", { className: "ss-modal-header", children: [
|
|
1284
1554
|
/* @__PURE__ */ e("span", { className: "ss-modal-title", children: "Profile" }),
|
|
1285
1555
|
/* @__PURE__ */ e("button", { type: "button", className: "ss-modal-close", onClick: s, children: "✕" })
|
|
1286
1556
|
] }),
|
|
1287
1557
|
d && /* @__PURE__ */ e("div", { className: "ss-global-error", children: d }),
|
|
1288
|
-
|
|
1289
|
-
/* @__PURE__ */
|
|
1290
|
-
|
|
1291
|
-
|
|
1558
|
+
u && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: u }),
|
|
1559
|
+
/* @__PURE__ */ l(
|
|
1560
|
+
"div",
|
|
1561
|
+
{
|
|
1562
|
+
className: "ss-avatar-preview ss-avatar-hoverable",
|
|
1563
|
+
onClick: () => y(!0),
|
|
1564
|
+
title: "Click to change avatar",
|
|
1565
|
+
children: [
|
|
1566
|
+
b ? /* @__PURE__ */ e("img", { src: b, alt: "" }) : (m || (a == null ? void 0 : a.email) || "?").charAt(0).toUpperCase(),
|
|
1567
|
+
/* @__PURE__ */ e("div", { className: "ss-avatar-overlay", children: /* @__PURE__ */ l("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1568
|
+
/* @__PURE__ */ e("path", { d: "M12 16a4 4 0 100-8 4 4 0 000 8z" }),
|
|
1569
|
+
/* @__PURE__ */ e("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" })
|
|
1570
|
+
] }) })
|
|
1571
|
+
]
|
|
1572
|
+
}
|
|
1573
|
+
),
|
|
1574
|
+
/* @__PURE__ */ l("form", { onSubmit: A, children: [
|
|
1575
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1292
1576
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Name" }),
|
|
1293
1577
|
/* @__PURE__ */ e(
|
|
1294
1578
|
"input",
|
|
@@ -1296,236 +1580,256 @@ function ls({ onClose: s }) {
|
|
|
1296
1580
|
className: "ss-input",
|
|
1297
1581
|
type: "text",
|
|
1298
1582
|
placeholder: "Your name",
|
|
1299
|
-
value:
|
|
1300
|
-
onChange: (
|
|
1301
|
-
}
|
|
1302
|
-
)
|
|
1303
|
-
] }),
|
|
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)
|
|
1583
|
+
value: m,
|
|
1584
|
+
onChange: (L) => p(L.target.value)
|
|
1314
1585
|
}
|
|
1315
1586
|
)
|
|
1316
1587
|
] }),
|
|
1317
|
-
/* @__PURE__ */
|
|
1588
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1318
1589
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Email" }),
|
|
1319
1590
|
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "email", value: (a == null ? void 0 : a.email) ?? "", disabled: !0, readOnly: !0 })
|
|
1320
1591
|
] }),
|
|
1321
|
-
/* @__PURE__ */
|
|
1592
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1322
1593
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Provider" }),
|
|
1323
1594
|
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: (a == null ? void 0 : a.provider) ?? "", disabled: !0, readOnly: !0 })
|
|
1324
1595
|
] }),
|
|
1325
|
-
/* @__PURE__ */
|
|
1326
|
-
|
|
1596
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: i, children: [
|
|
1597
|
+
i && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1327
1598
|
"Save changes"
|
|
1328
1599
|
] })
|
|
1329
1600
|
] }),
|
|
1330
|
-
|
|
1601
|
+
M && /* @__PURE__ */ l("div", { className: "ss-modal-section", children: [
|
|
1331
1602
|
/* @__PURE__ */ e("div", { className: "ss-modal-section-title", children: "Change password" }),
|
|
1332
|
-
|
|
1333
|
-
/* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1603
|
+
z && /* @__PURE__ */ e("div", { className: "ss-global-error", children: z }),
|
|
1604
|
+
/* @__PURE__ */ l("form", { onSubmit: $, children: [
|
|
1605
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1335
1606
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Current password" }),
|
|
1336
1607
|
/* @__PURE__ */ e(
|
|
1337
1608
|
"input",
|
|
1338
1609
|
{
|
|
1339
1610
|
className: "ss-input",
|
|
1340
1611
|
type: "password",
|
|
1341
|
-
value:
|
|
1342
|
-
onChange: (
|
|
1612
|
+
value: w,
|
|
1613
|
+
onChange: (L) => v(L.target.value),
|
|
1343
1614
|
required: !0
|
|
1344
1615
|
}
|
|
1345
1616
|
)
|
|
1346
1617
|
] }),
|
|
1347
|
-
/* @__PURE__ */
|
|
1618
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1348
1619
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "New password" }),
|
|
1349
1620
|
/* @__PURE__ */ e(
|
|
1350
1621
|
"input",
|
|
1351
1622
|
{
|
|
1352
1623
|
className: "ss-input",
|
|
1353
1624
|
type: "password",
|
|
1354
|
-
value:
|
|
1355
|
-
onChange: (
|
|
1625
|
+
value: g,
|
|
1626
|
+
onChange: (L) => N(L.target.value),
|
|
1356
1627
|
required: !0
|
|
1357
1628
|
}
|
|
1358
1629
|
)
|
|
1359
1630
|
] }),
|
|
1360
|
-
/* @__PURE__ */
|
|
1631
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1361
1632
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Confirm new password" }),
|
|
1362
1633
|
/* @__PURE__ */ e(
|
|
1363
1634
|
"input",
|
|
1364
1635
|
{
|
|
1365
1636
|
className: "ss-input",
|
|
1366
1637
|
type: "password",
|
|
1367
|
-
value:
|
|
1368
|
-
onChange: (
|
|
1638
|
+
value: S,
|
|
1639
|
+
onChange: (L) => k(L.target.value),
|
|
1369
1640
|
required: !0
|
|
1370
1641
|
}
|
|
1371
1642
|
)
|
|
1372
1643
|
] }),
|
|
1373
|
-
/* @__PURE__ */
|
|
1374
|
-
|
|
1644
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: i, children: [
|
|
1645
|
+
i && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1375
1646
|
"Update password"
|
|
1376
1647
|
] })
|
|
1377
1648
|
] })
|
|
1378
|
-
] })
|
|
1649
|
+
] }),
|
|
1650
|
+
x && /* @__PURE__ */ e(
|
|
1651
|
+
es,
|
|
1652
|
+
{
|
|
1653
|
+
onUpload: T,
|
|
1654
|
+
onClose: () => y(!1),
|
|
1655
|
+
isLoading: i
|
|
1656
|
+
}
|
|
1657
|
+
)
|
|
1379
1658
|
] }) });
|
|
1380
1659
|
}
|
|
1381
|
-
function
|
|
1382
|
-
const { appearance: a } =
|
|
1383
|
-
async (
|
|
1384
|
-
|
|
1660
|
+
function _s({ appearance: s }) {
|
|
1661
|
+
const { appearance: a } = E(), { user: r, signOut: c } = Y(), { updateProfile: t, uploadAvatar: i, changePassword: d, isLoading: u, error: o, success: n, setError: m, setSuccess: p } = X(), b = s ?? a, [f, x] = h((r == null ? void 0 : r.name) ?? ""), [y, w] = h((r == null ? void 0 : r.avatarUrl) ?? ""), [v, g] = h(!1), [N, S] = h(""), [k, z] = h(""), [P, A] = h(""), [T, $] = h(null), M = C(
|
|
1662
|
+
async (U) => {
|
|
1663
|
+
U.preventDefault(), m(null), p(null), await t({ name: f, avatarUrl: y || void 0 });
|
|
1664
|
+
},
|
|
1665
|
+
[f, y, t, m, p]
|
|
1666
|
+
), L = C(
|
|
1667
|
+
async (U) => {
|
|
1668
|
+
const _ = await i(U);
|
|
1669
|
+
_ && (w(_.avatarUrl), g(!1));
|
|
1385
1670
|
},
|
|
1386
|
-
[
|
|
1387
|
-
),
|
|
1388
|
-
async (
|
|
1389
|
-
if (
|
|
1390
|
-
|
|
1671
|
+
[i]
|
|
1672
|
+
), O = C(
|
|
1673
|
+
async (U) => {
|
|
1674
|
+
if (U.preventDefault(), $(null), m(null), p(null), k !== P) {
|
|
1675
|
+
$("Passwords do not match");
|
|
1391
1676
|
return;
|
|
1392
1677
|
}
|
|
1393
|
-
if (
|
|
1394
|
-
|
|
1678
|
+
if (k.length < 8) {
|
|
1679
|
+
$("Password must be at least 8 characters");
|
|
1395
1680
|
return;
|
|
1396
1681
|
}
|
|
1397
|
-
await d(
|
|
1682
|
+
await d(N, k) && (S(""), z(""), A(""));
|
|
1398
1683
|
},
|
|
1399
|
-
[
|
|
1684
|
+
[N, k, P, d, m, p]
|
|
1400
1685
|
);
|
|
1401
1686
|
if (!r) return null;
|
|
1402
|
-
const
|
|
1403
|
-
return /* @__PURE__ */ e(
|
|
1687
|
+
const as = r.provider === "email";
|
|
1688
|
+
return /* @__PURE__ */ e(D, { appearance: b, children: /* @__PURE__ */ l("div", { className: "ss-card ss-card-wide", children: [
|
|
1404
1689
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Profile" }),
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
/* @__PURE__ */
|
|
1408
|
-
|
|
1409
|
-
|
|
1690
|
+
o && /* @__PURE__ */ e("div", { className: "ss-global-error", children: o }),
|
|
1691
|
+
n && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: n }),
|
|
1692
|
+
/* @__PURE__ */ l(
|
|
1693
|
+
"div",
|
|
1694
|
+
{
|
|
1695
|
+
className: "ss-avatar-preview ss-avatar-hoverable",
|
|
1696
|
+
style: { margin: "0 auto 16px" },
|
|
1697
|
+
onClick: () => g(!0),
|
|
1698
|
+
title: "Click to change avatar",
|
|
1699
|
+
children: [
|
|
1700
|
+
y ? /* @__PURE__ */ e("img", { src: y, alt: "" }) : (f || r.email).charAt(0).toUpperCase(),
|
|
1701
|
+
/* @__PURE__ */ e("div", { className: "ss-avatar-overlay", children: /* @__PURE__ */ l("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
1702
|
+
/* @__PURE__ */ e("path", { d: "M12 16a4 4 0 100-8 4 4 0 000 8z" }),
|
|
1703
|
+
/* @__PURE__ */ e("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" })
|
|
1704
|
+
] }) })
|
|
1705
|
+
]
|
|
1706
|
+
}
|
|
1707
|
+
),
|
|
1708
|
+
/* @__PURE__ */ l("form", { onSubmit: M, children: [
|
|
1709
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1410
1710
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Name" }),
|
|
1411
|
-
/* @__PURE__ */ e("input", { className: "ss-input", type: "text", placeholder: "Your name", value:
|
|
1711
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "text", placeholder: "Your name", value: f, onChange: (U) => x(U.target.value) })
|
|
1412
1712
|
] }),
|
|
1413
|
-
/* @__PURE__ */
|
|
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) })
|
|
1416
|
-
] }),
|
|
1417
|
-
/* @__PURE__ */ i("div", { className: "ss-field", children: [
|
|
1713
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1418
1714
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Email" }),
|
|
1419
1715
|
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "email", value: r.email, disabled: !0, readOnly: !0 })
|
|
1420
1716
|
] }),
|
|
1421
|
-
/* @__PURE__ */
|
|
1717
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1422
1718
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Provider" }),
|
|
1423
1719
|
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: r.provider, disabled: !0, readOnly: !0 })
|
|
1424
1720
|
] }),
|
|
1425
|
-
/* @__PURE__ */
|
|
1721
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1426
1722
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Email verified" }),
|
|
1427
1723
|
/* @__PURE__ */ e("input", { className: "ss-input ss-input-readonly", type: "text", value: r.emailVerified ? "Yes" : "No", disabled: !0, readOnly: !0 })
|
|
1428
1724
|
] }),
|
|
1429
|
-
/* @__PURE__ */
|
|
1430
|
-
|
|
1725
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: u, children: [
|
|
1726
|
+
u && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1431
1727
|
"Save changes"
|
|
1432
1728
|
] })
|
|
1433
1729
|
] }),
|
|
1434
|
-
|
|
1730
|
+
as && /* @__PURE__ */ l("div", { className: "ss-modal-section", children: [
|
|
1435
1731
|
/* @__PURE__ */ e("div", { className: "ss-modal-section-title", children: "Change password" }),
|
|
1436
|
-
|
|
1437
|
-
/* @__PURE__ */
|
|
1438
|
-
/* @__PURE__ */
|
|
1732
|
+
T && /* @__PURE__ */ e("div", { className: "ss-global-error", children: T }),
|
|
1733
|
+
/* @__PURE__ */ l("form", { onSubmit: O, children: [
|
|
1734
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1439
1735
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Current password" }),
|
|
1440
|
-
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value:
|
|
1736
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: N, onChange: (U) => S(U.target.value), required: !0 })
|
|
1441
1737
|
] }),
|
|
1442
|
-
/* @__PURE__ */
|
|
1738
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1443
1739
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "New password" }),
|
|
1444
|
-
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value:
|
|
1740
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: k, onChange: (U) => z(U.target.value), required: !0 })
|
|
1445
1741
|
] }),
|
|
1446
|
-
/* @__PURE__ */
|
|
1742
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1447
1743
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Confirm new password" }),
|
|
1448
|
-
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value:
|
|
1744
|
+
/* @__PURE__ */ e("input", { className: "ss-input", type: "password", value: P, onChange: (U) => A(U.target.value), required: !0 })
|
|
1449
1745
|
] }),
|
|
1450
|
-
/* @__PURE__ */
|
|
1451
|
-
|
|
1746
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: u, children: [
|
|
1747
|
+
u && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1452
1748
|
"Update password"
|
|
1453
1749
|
] })
|
|
1454
1750
|
] })
|
|
1455
1751
|
] }),
|
|
1456
|
-
/* @__PURE__ */ e("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: () => c(), children: "Sign out" }) })
|
|
1752
|
+
/* @__PURE__ */ e("div", { style: { marginTop: "24px" }, children: /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: () => c(), children: "Sign out" }) }),
|
|
1753
|
+
v && /* @__PURE__ */ e(
|
|
1754
|
+
es,
|
|
1755
|
+
{
|
|
1756
|
+
onUpload: L,
|
|
1757
|
+
onClose: () => g(!1),
|
|
1758
|
+
isLoading: u
|
|
1759
|
+
}
|
|
1760
|
+
)
|
|
1457
1761
|
] }) });
|
|
1458
1762
|
}
|
|
1459
|
-
function
|
|
1460
|
-
const { appearance: r } =
|
|
1461
|
-
|
|
1763
|
+
function Vs({ appearance: s, onOrgChange: a }) {
|
|
1764
|
+
const { appearance: r } = E(), { orgs: c, selectedOrg: t, selectOrg: i, createOrg: d, isLoading: u } = gs(), o = s ?? r, [n, m] = h(!1), [p, b] = h(!1), [f, x] = h(""), [y, w] = h(""), [v, g] = h(null), [N, S] = h(!1), k = R(null), z = C(($) => {
|
|
1765
|
+
k.current && !$.composedPath().includes(k.current) && (m(!1), b(!1));
|
|
1462
1766
|
}, []);
|
|
1463
|
-
|
|
1767
|
+
B(() => {
|
|
1464
1768
|
if (n) {
|
|
1465
|
-
const
|
|
1769
|
+
const $ = setTimeout(() => {
|
|
1466
1770
|
document.addEventListener("click", z);
|
|
1467
1771
|
}, 0);
|
|
1468
1772
|
return () => {
|
|
1469
|
-
clearTimeout(
|
|
1773
|
+
clearTimeout($), document.removeEventListener("click", z);
|
|
1470
1774
|
};
|
|
1471
1775
|
}
|
|
1472
1776
|
}, [n, z]);
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
}, []),
|
|
1476
|
-
async (
|
|
1477
|
-
|
|
1777
|
+
const P = C(($) => {
|
|
1778
|
+
x($), w($.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""));
|
|
1779
|
+
}, []), A = C(
|
|
1780
|
+
async ($) => {
|
|
1781
|
+
$.preventDefault(), g(null), S(!0);
|
|
1478
1782
|
try {
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
-
} catch (
|
|
1482
|
-
|
|
1783
|
+
const M = await d(f, y);
|
|
1784
|
+
M && (await i(M.id), a == null || a(M), b(!1), x(""), w(""), m(!1));
|
|
1785
|
+
} catch (M) {
|
|
1786
|
+
g(M instanceof Error ? M.message : "Failed to create organization");
|
|
1483
1787
|
} finally {
|
|
1484
|
-
|
|
1788
|
+
S(!1);
|
|
1485
1789
|
}
|
|
1486
1790
|
},
|
|
1487
|
-
[
|
|
1791
|
+
[f, y, d, i, a]
|
|
1488
1792
|
);
|
|
1489
1793
|
if (u) return null;
|
|
1490
|
-
const
|
|
1491
|
-
return /* @__PURE__ */ e(
|
|
1492
|
-
/* @__PURE__ */
|
|
1794
|
+
const T = (t == null ? void 0 : t.name) ?? (c.length === 0 ? "No organization" : "Select organization");
|
|
1795
|
+
return /* @__PURE__ */ e(D, { appearance: o, children: /* @__PURE__ */ l("div", { className: "ss-user-btn", ref: k, children: [
|
|
1796
|
+
/* @__PURE__ */ l(
|
|
1493
1797
|
"button",
|
|
1494
1798
|
{
|
|
1495
1799
|
type: "button",
|
|
1496
1800
|
className: "ss-btn ss-btn-org-switcher",
|
|
1497
1801
|
onClick: () => m(!n),
|
|
1498
1802
|
children: [
|
|
1499
|
-
|
|
1803
|
+
T,
|
|
1500
1804
|
/* @__PURE__ */ e("span", { className: "ss-chevron", children: n ? "▲" : "▼" })
|
|
1501
1805
|
]
|
|
1502
1806
|
}
|
|
1503
1807
|
),
|
|
1504
|
-
n && /* @__PURE__ */
|
|
1505
|
-
c.map((
|
|
1808
|
+
n && /* @__PURE__ */ l("div", { className: "ss-dropdown ss-dropdown-org", children: [
|
|
1809
|
+
c.map(($) => /* @__PURE__ */ e(
|
|
1506
1810
|
"button",
|
|
1507
1811
|
{
|
|
1508
1812
|
type: "button",
|
|
1509
|
-
className: `ss-dropdown-item ${(t == null ? void 0 : t.id) ===
|
|
1813
|
+
className: `ss-dropdown-item ${(t == null ? void 0 : t.id) === $.id ? "ss-dropdown-item-active" : ""}`,
|
|
1510
1814
|
onClick: async () => {
|
|
1511
|
-
m(!1),
|
|
1815
|
+
m(!1), b(!1), await i($.id), a == null || a($);
|
|
1512
1816
|
},
|
|
1513
|
-
children:
|
|
1817
|
+
children: $.name
|
|
1514
1818
|
},
|
|
1515
|
-
|
|
1819
|
+
$.id
|
|
1516
1820
|
)),
|
|
1517
1821
|
/* @__PURE__ */ e("div", { className: "ss-dropdown-divider" }),
|
|
1518
|
-
p ? /* @__PURE__ */
|
|
1519
|
-
|
|
1520
|
-
/* @__PURE__ */
|
|
1822
|
+
p ? /* @__PURE__ */ l("div", { className: "ss-inline-form", children: [
|
|
1823
|
+
v && /* @__PURE__ */ e("div", { className: "ss-global-error", style: { marginBottom: "8px", fontSize: "12px" }, children: v }),
|
|
1824
|
+
/* @__PURE__ */ l("form", { onSubmit: A, children: [
|
|
1521
1825
|
/* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
|
|
1522
1826
|
"input",
|
|
1523
1827
|
{
|
|
1524
1828
|
className: "ss-input",
|
|
1525
1829
|
type: "text",
|
|
1526
1830
|
placeholder: "Organization name",
|
|
1527
|
-
value:
|
|
1528
|
-
onChange: (
|
|
1831
|
+
value: f,
|
|
1832
|
+
onChange: ($) => P($.target.value),
|
|
1529
1833
|
required: !0,
|
|
1530
1834
|
autoFocus: !0
|
|
1531
1835
|
}
|
|
@@ -1536,31 +1840,31 @@ function Ms({ appearance: s, onOrgChange: a }) {
|
|
|
1536
1840
|
className: "ss-input",
|
|
1537
1841
|
type: "text",
|
|
1538
1842
|
placeholder: "org-slug",
|
|
1539
|
-
value:
|
|
1540
|
-
onChange: (
|
|
1843
|
+
value: y,
|
|
1844
|
+
onChange: ($) => w($.target.value),
|
|
1541
1845
|
required: !0
|
|
1542
1846
|
}
|
|
1543
1847
|
) }),
|
|
1544
|
-
/* @__PURE__ */
|
|
1848
|
+
/* @__PURE__ */ l("div", { className: "ss-btn-group", style: { marginTop: "8px" }, children: [
|
|
1545
1849
|
/* @__PURE__ */ e(
|
|
1546
1850
|
"button",
|
|
1547
1851
|
{
|
|
1548
1852
|
type: "button",
|
|
1549
1853
|
className: "ss-btn ss-btn-sm ss-btn-current",
|
|
1550
1854
|
onClick: () => {
|
|
1551
|
-
|
|
1855
|
+
b(!1), g(null);
|
|
1552
1856
|
},
|
|
1553
1857
|
children: "Cancel"
|
|
1554
1858
|
}
|
|
1555
1859
|
),
|
|
1556
|
-
/* @__PURE__ */
|
|
1860
|
+
/* @__PURE__ */ l(
|
|
1557
1861
|
"button",
|
|
1558
1862
|
{
|
|
1559
1863
|
type: "submit",
|
|
1560
1864
|
className: "ss-btn ss-btn-sm ss-btn-primary",
|
|
1561
|
-
disabled:
|
|
1865
|
+
disabled: N,
|
|
1562
1866
|
children: [
|
|
1563
|
-
|
|
1867
|
+
N && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1564
1868
|
"Create"
|
|
1565
1869
|
]
|
|
1566
1870
|
}
|
|
@@ -1572,7 +1876,7 @@ function Ms({ appearance: s, onOrgChange: a }) {
|
|
|
1572
1876
|
{
|
|
1573
1877
|
type: "button",
|
|
1574
1878
|
className: "ss-dropdown-item",
|
|
1575
|
-
onClick: () =>
|
|
1879
|
+
onClick: () => b(!0),
|
|
1576
1880
|
style: { fontWeight: 500 },
|
|
1577
1881
|
children: "+ Create organization"
|
|
1578
1882
|
}
|
|
@@ -1580,35 +1884,35 @@ function Ms({ appearance: s, onOrgChange: a }) {
|
|
|
1580
1884
|
] })
|
|
1581
1885
|
] }) });
|
|
1582
1886
|
}
|
|
1583
|
-
function
|
|
1887
|
+
function fs(s, a = "USD") {
|
|
1584
1888
|
return new Intl.NumberFormat("en-US", {
|
|
1585
1889
|
style: "currency",
|
|
1586
1890
|
currency: a,
|
|
1587
1891
|
minimumFractionDigits: s % 100 === 0 ? 0 : 2
|
|
1588
1892
|
}).format(s / 100);
|
|
1589
1893
|
}
|
|
1590
|
-
function
|
|
1591
|
-
const { appearance:
|
|
1592
|
-
return /* @__PURE__ */ e(
|
|
1894
|
+
function Gs({ plans: s, currentPlanId: a, onSelectPlan: r, interval: c, appearance: t }) {
|
|
1895
|
+
const { appearance: i } = E(), d = t ?? i, u = c ? s.filter((o) => o.interval === c || o.isFree) : s;
|
|
1896
|
+
return /* @__PURE__ */ e(D, { appearance: d, children: /* @__PURE__ */ e("div", { className: "ss-pricing-grid", children: u.map((o) => {
|
|
1593
1897
|
const n = o.id === a;
|
|
1594
|
-
return /* @__PURE__ */
|
|
1595
|
-
/* @__PURE__ */
|
|
1898
|
+
return /* @__PURE__ */ l("div", { className: `ss-pricing-card ${n ? "ss-pricing-card-current" : ""}`, children: [
|
|
1899
|
+
/* @__PURE__ */ l("div", { className: "ss-pricing-header", children: [
|
|
1596
1900
|
/* @__PURE__ */ e("h3", { className: "ss-pricing-name", children: o.name }),
|
|
1597
|
-
o.trialDays > 0 && /* @__PURE__ */
|
|
1901
|
+
o.trialDays > 0 && /* @__PURE__ */ l("span", { className: "ss-badge ss-badge-trialing", children: [
|
|
1598
1902
|
o.trialDays,
|
|
1599
1903
|
"-day trial"
|
|
1600
1904
|
] }),
|
|
1601
1905
|
o.isFree && /* @__PURE__ */ e("span", { className: "ss-badge ss-badge-active", children: "Free" })
|
|
1602
1906
|
] }),
|
|
1603
|
-
/* @__PURE__ */ e("div", { className: "ss-pricing-price", children: o.isFree ? /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: "Free" }) : /* @__PURE__ */
|
|
1604
|
-
/* @__PURE__ */ e("span", { className: "ss-pricing-amount", children:
|
|
1605
|
-
/* @__PURE__ */
|
|
1907
|
+
/* @__PURE__ */ e("div", { className: "ss-pricing-price", children: o.isFree ? /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: "Free" }) : /* @__PURE__ */ l(W, { children: [
|
|
1908
|
+
/* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: fs(o.amountCents, o.currency) }),
|
|
1909
|
+
/* @__PURE__ */ l("span", { className: "ss-pricing-interval", children: [
|
|
1606
1910
|
"/",
|
|
1607
1911
|
o.interval
|
|
1608
1912
|
] })
|
|
1609
1913
|
] }) }),
|
|
1610
1914
|
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__ */
|
|
1915
|
+
o.features.length > 0 && /* @__PURE__ */ e("ul", { className: "ss-pricing-features", children: o.features.map((m, p) => /* @__PURE__ */ l("li", { className: "ss-pricing-feature", children: [
|
|
1612
1916
|
/* @__PURE__ */ e("span", { className: "ss-check", children: "✓" }),
|
|
1613
1917
|
" ",
|
|
1614
1918
|
m
|
|
@@ -1626,157 +1930,157 @@ function Us({ plans: s, currentPlanId: a, onSelectPlan: r, interval: c, appearan
|
|
|
1626
1930
|
] }, o.id);
|
|
1627
1931
|
}) }) });
|
|
1628
1932
|
}
|
|
1629
|
-
function
|
|
1630
|
-
const { client: s } =
|
|
1933
|
+
function Js() {
|
|
1934
|
+
const { client: s } = E();
|
|
1631
1935
|
return { billing: s.billing };
|
|
1632
1936
|
}
|
|
1633
|
-
function
|
|
1634
|
-
const { client: a } =
|
|
1635
|
-
return
|
|
1937
|
+
function j(s) {
|
|
1938
|
+
const { client: a } = E();
|
|
1939
|
+
return q(() => {
|
|
1636
1940
|
if (s) {
|
|
1637
|
-
const r = new
|
|
1638
|
-
return new
|
|
1941
|
+
const r = new H("https://api.saas-support.com/v1", { type: "portalToken", token: s });
|
|
1942
|
+
return new is(r);
|
|
1639
1943
|
}
|
|
1640
1944
|
return a.billing;
|
|
1641
1945
|
}, [a, s]);
|
|
1642
1946
|
}
|
|
1643
|
-
function
|
|
1644
|
-
const r =
|
|
1645
|
-
|
|
1947
|
+
function ys(s, a) {
|
|
1948
|
+
const r = j(a), [c, t] = h(null), [i, d] = h(!0), [u, o] = h(null), n = C(async () => {
|
|
1949
|
+
d(!0), o(null);
|
|
1646
1950
|
try {
|
|
1647
1951
|
const m = await r.getCustomer(s);
|
|
1648
1952
|
t(m);
|
|
1649
1953
|
} catch (m) {
|
|
1650
1954
|
o(m instanceof Error ? m.message : "Failed to load subscription");
|
|
1651
1955
|
} finally {
|
|
1652
|
-
|
|
1956
|
+
d(!1);
|
|
1653
1957
|
}
|
|
1654
1958
|
}, [r, s]);
|
|
1655
|
-
return
|
|
1959
|
+
return B(() => {
|
|
1656
1960
|
n();
|
|
1657
|
-
}, [n]), { customer: c, isLoading:
|
|
1961
|
+
}, [n]), { customer: c, isLoading: i, error: u, refresh: n };
|
|
1658
1962
|
}
|
|
1659
|
-
function
|
|
1660
|
-
const r =
|
|
1661
|
-
|
|
1963
|
+
function xs(s, a) {
|
|
1964
|
+
const r = j(a), [c, t] = h([]), [i, d] = h(!0), [u, o] = h(null), n = C(async () => {
|
|
1965
|
+
d(!0), o(null);
|
|
1662
1966
|
try {
|
|
1663
1967
|
const m = await r.getInvoices(s);
|
|
1664
1968
|
t(m);
|
|
1665
1969
|
} catch (m) {
|
|
1666
1970
|
o(m instanceof Error ? m.message : "Failed to load invoices");
|
|
1667
1971
|
} finally {
|
|
1668
|
-
|
|
1972
|
+
d(!1);
|
|
1669
1973
|
}
|
|
1670
1974
|
}, [r, s]);
|
|
1671
|
-
return
|
|
1975
|
+
return B(() => {
|
|
1672
1976
|
n();
|
|
1673
|
-
}, [n]), { invoices: c, isLoading:
|
|
1977
|
+
}, [n]), { invoices: c, isLoading: i, error: u, refresh: n };
|
|
1674
1978
|
}
|
|
1675
|
-
function
|
|
1676
|
-
const r =
|
|
1677
|
-
|
|
1979
|
+
function vs(s, a) {
|
|
1980
|
+
const r = j(a), [c, t] = h([]), [i, d] = h(!0), [u, o] = h(null), n = C(async () => {
|
|
1981
|
+
d(!0), o(null);
|
|
1678
1982
|
try {
|
|
1679
1983
|
const m = await r.getCurrentUsage(s);
|
|
1680
1984
|
t(m);
|
|
1681
1985
|
} catch (m) {
|
|
1682
1986
|
o(m instanceof Error ? m.message : "Failed to load usage");
|
|
1683
1987
|
} finally {
|
|
1684
|
-
|
|
1988
|
+
d(!1);
|
|
1685
1989
|
}
|
|
1686
1990
|
}, [r, s]);
|
|
1687
|
-
return
|
|
1991
|
+
return B(() => {
|
|
1688
1992
|
n();
|
|
1689
|
-
}, [n]), { usage: c, isLoading:
|
|
1993
|
+
}, [n]), { usage: c, isLoading: i, error: u, refresh: n };
|
|
1690
1994
|
}
|
|
1691
|
-
const
|
|
1995
|
+
const ws = {
|
|
1692
1996
|
active: "ss-badge-active"
|
|
1693
1997
|
};
|
|
1694
|
-
function
|
|
1998
|
+
function Ns({
|
|
1695
1999
|
customerId: s,
|
|
1696
2000
|
portalToken: a,
|
|
1697
2001
|
onChangePlan: r,
|
|
1698
2002
|
onCancel: c,
|
|
1699
2003
|
appearance: t
|
|
1700
2004
|
}) {
|
|
1701
|
-
const { appearance:
|
|
1702
|
-
return /* @__PURE__ */ e(
|
|
2005
|
+
const { appearance: i } = E(), { customer: d, isLoading: u, error: o } = ys(s, a);
|
|
2006
|
+
return /* @__PURE__ */ e(D, { appearance: t ?? i, children: /* @__PURE__ */ l("div", { className: "ss-card", children: [
|
|
1703
2007
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Subscription" }),
|
|
1704
|
-
u && /* @__PURE__ */
|
|
2008
|
+
u && /* @__PURE__ */ l("div", { className: "ss-loading", children: [
|
|
1705
2009
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1706
2010
|
" Loading..."
|
|
1707
2011
|
] }),
|
|
1708
2012
|
o && /* @__PURE__ */ e("div", { className: "ss-global-error", children: o }),
|
|
1709
|
-
|
|
1710
|
-
/* @__PURE__ */
|
|
2013
|
+
d && !u && /* @__PURE__ */ l(W, { children: [
|
|
2014
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1711
2015
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Customer" }),
|
|
1712
|
-
/* @__PURE__ */ e("input", { className: "ss-input", value:
|
|
2016
|
+
/* @__PURE__ */ e("input", { className: "ss-input", value: d.name || d.email, disabled: !0, readOnly: !0 })
|
|
1713
2017
|
] }),
|
|
1714
|
-
/* @__PURE__ */
|
|
2018
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1715
2019
|
/* @__PURE__ */ e("label", { className: "ss-label", children: "Status" }),
|
|
1716
|
-
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("span", { className: `ss-badge ${
|
|
2020
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("span", { className: `ss-badge ${ws.active}`, children: "Active" }) })
|
|
1717
2021
|
] }),
|
|
1718
|
-
/* @__PURE__ */
|
|
2022
|
+
/* @__PURE__ */ l("div", { className: "ss-btn-group", children: [
|
|
1719
2023
|
r && /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-primary", onClick: r, children: "Change plan" }),
|
|
1720
2024
|
c && /* @__PURE__ */ e("button", { type: "button", className: "ss-btn ss-btn-danger", onClick: c, children: "Cancel subscription" })
|
|
1721
2025
|
] })
|
|
1722
2026
|
] })
|
|
1723
2027
|
] }) });
|
|
1724
2028
|
}
|
|
1725
|
-
const
|
|
2029
|
+
const Cs = {
|
|
1726
2030
|
paid: "ss-badge-active",
|
|
1727
2031
|
open: "ss-badge-trialing",
|
|
1728
2032
|
draft: "ss-badge-paused",
|
|
1729
2033
|
void: "ss-badge-canceled",
|
|
1730
2034
|
uncollectible: "ss-badge-past-due"
|
|
1731
2035
|
};
|
|
1732
|
-
function
|
|
2036
|
+
function ks(s) {
|
|
1733
2037
|
return new Date(s).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
|
|
1734
2038
|
}
|
|
1735
|
-
function
|
|
2039
|
+
function Ss(s) {
|
|
1736
2040
|
return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", minimumFractionDigits: 2 }).format(s / 100);
|
|
1737
2041
|
}
|
|
1738
|
-
function
|
|
1739
|
-
const { appearance: c } =
|
|
1740
|
-
return /* @__PURE__ */ e(
|
|
2042
|
+
function $s({ customerId: s, portalToken: a, appearance: r }) {
|
|
2043
|
+
const { appearance: c } = E(), { invoices: t, isLoading: i, error: d } = xs(s, a), u = r ?? c, o = [...t].sort((n, m) => new Date(m.createdAt).getTime() - new Date(n.createdAt).getTime());
|
|
2044
|
+
return /* @__PURE__ */ e(D, { appearance: u, children: /* @__PURE__ */ l("div", { className: "ss-card ss-card-wide", children: [
|
|
1741
2045
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Invoices" }),
|
|
1742
|
-
|
|
2046
|
+
i && /* @__PURE__ */ l("div", { className: "ss-loading", children: [
|
|
1743
2047
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1744
2048
|
" Loading..."
|
|
1745
2049
|
] }),
|
|
1746
|
-
|
|
1747
|
-
!
|
|
1748
|
-
!
|
|
1749
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */
|
|
2050
|
+
d && /* @__PURE__ */ e("div", { className: "ss-global-error", children: d }),
|
|
2051
|
+
!i && o.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No invoices yet." }),
|
|
2052
|
+
!i && o.length > 0 && /* @__PURE__ */ l("table", { className: "ss-table", children: [
|
|
2053
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { children: [
|
|
1750
2054
|
/* @__PURE__ */ e("th", { className: "ss-th", children: "Date" }),
|
|
1751
2055
|
/* @__PURE__ */ e("th", { className: "ss-th", children: "Amount" }),
|
|
1752
2056
|
/* @__PURE__ */ e("th", { className: "ss-th", children: "Status" }),
|
|
1753
2057
|
/* @__PURE__ */ e("th", { className: "ss-th", children: "PDF" })
|
|
1754
2058
|
] }) }),
|
|
1755
|
-
/* @__PURE__ */ e("tbody", { children: o.map((n) => /* @__PURE__ */
|
|
1756
|
-
/* @__PURE__ */ e("td", { className: "ss-td", children:
|
|
1757
|
-
/* @__PURE__ */ e("td", { className: "ss-td", children:
|
|
1758
|
-
/* @__PURE__ */ e("td", { className: "ss-td", children: /* @__PURE__ */ e("span", { className: `ss-badge ${
|
|
2059
|
+
/* @__PURE__ */ e("tbody", { children: o.map((n) => /* @__PURE__ */ l("tr", { className: "ss-tr", children: [
|
|
2060
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: ks(n.createdAt) }),
|
|
2061
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: Ss(n.amountCents) }),
|
|
2062
|
+
/* @__PURE__ */ e("td", { className: "ss-td", children: /* @__PURE__ */ e("span", { className: `ss-badge ${Cs[n.status] || ""}`, children: n.status }) }),
|
|
1759
2063
|
/* @__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
2064
|
] }, n.id)) })
|
|
1761
2065
|
] })
|
|
1762
2066
|
] }) });
|
|
1763
2067
|
}
|
|
1764
|
-
function
|
|
1765
|
-
const { appearance: t } =
|
|
1766
|
-
return /* @__PURE__ */ e(
|
|
2068
|
+
function Ps({ customerId: s, limits: a, portalToken: r, appearance: c }) {
|
|
2069
|
+
const { appearance: t } = E(), { usage: i, isLoading: d, error: u } = vs(s, r);
|
|
2070
|
+
return /* @__PURE__ */ e(D, { appearance: c ?? t, children: /* @__PURE__ */ l("div", { className: "ss-card", children: [
|
|
1767
2071
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Usage" }),
|
|
1768
|
-
|
|
2072
|
+
d && /* @__PURE__ */ l("div", { className: "ss-loading", children: [
|
|
1769
2073
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1770
2074
|
" Loading..."
|
|
1771
2075
|
] }),
|
|
1772
2076
|
u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
|
|
1773
|
-
!
|
|
1774
|
-
!
|
|
2077
|
+
!d && i.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No usage data." }),
|
|
2078
|
+
!d && i.map((n) => {
|
|
1775
2079
|
const m = a == null ? void 0 : a[n.metric], p = m ? Math.min(100, n.total / m * 100) : null;
|
|
1776
|
-
return /* @__PURE__ */
|
|
1777
|
-
/* @__PURE__ */
|
|
2080
|
+
return /* @__PURE__ */ l("div", { className: "ss-usage-item", children: [
|
|
2081
|
+
/* @__PURE__ */ l("div", { className: "ss-usage-header", children: [
|
|
1778
2082
|
/* @__PURE__ */ e("span", { className: "ss-usage-metric", children: n.metric }),
|
|
1779
|
-
/* @__PURE__ */
|
|
2083
|
+
/* @__PURE__ */ l("span", { className: "ss-usage-value", children: [
|
|
1780
2084
|
n.total.toLocaleString(),
|
|
1781
2085
|
m ? ` / ${m.toLocaleString()}` : ""
|
|
1782
2086
|
] })
|
|
@@ -1792,16 +2096,16 @@ function ys({ customerId: s, limits: a, portalToken: r, appearance: c }) {
|
|
|
1792
2096
|
})
|
|
1793
2097
|
] }) });
|
|
1794
2098
|
}
|
|
1795
|
-
function
|
|
2099
|
+
function Qs({
|
|
1796
2100
|
customerId: s,
|
|
1797
2101
|
portalToken: a,
|
|
1798
2102
|
limits: r,
|
|
1799
2103
|
onChangePlan: c,
|
|
1800
2104
|
onCancel: t,
|
|
1801
|
-
appearance:
|
|
2105
|
+
appearance: i
|
|
1802
2106
|
}) {
|
|
1803
|
-
const { appearance:
|
|
1804
|
-
return /* @__PURE__ */ e(
|
|
2107
|
+
const { appearance: d } = E(), u = i ?? d, [o, n] = h("subscription");
|
|
2108
|
+
return /* @__PURE__ */ e(D, { appearance: u, children: /* @__PURE__ */ l("div", { className: "ss-card ss-card-wide", children: [
|
|
1805
2109
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Billing" }),
|
|
1806
2110
|
/* @__PURE__ */ e("div", { className: "ss-tab-group", children: [
|
|
1807
2111
|
{ id: "subscription", label: "Subscription" },
|
|
@@ -1817,9 +2121,9 @@ function Rs({
|
|
|
1817
2121
|
},
|
|
1818
2122
|
p.id
|
|
1819
2123
|
)) }),
|
|
1820
|
-
/* @__PURE__ */
|
|
2124
|
+
/* @__PURE__ */ l("div", { className: "ss-tab-content", children: [
|
|
1821
2125
|
o === "subscription" && /* @__PURE__ */ e(
|
|
1822
|
-
|
|
2126
|
+
Ns,
|
|
1823
2127
|
{
|
|
1824
2128
|
customerId: s,
|
|
1825
2129
|
portalToken: a,
|
|
@@ -1827,31 +2131,31 @@ function Rs({
|
|
|
1827
2131
|
onCancel: t
|
|
1828
2132
|
}
|
|
1829
2133
|
),
|
|
1830
|
-
o === "invoices" && /* @__PURE__ */ e(
|
|
1831
|
-
o === "usage" && /* @__PURE__ */ e(
|
|
2134
|
+
o === "invoices" && /* @__PURE__ */ e($s, { customerId: s, portalToken: a }),
|
|
2135
|
+
o === "usage" && /* @__PURE__ */ e(Ps, { customerId: s, portalToken: a, limits: r })
|
|
1832
2136
|
] })
|
|
1833
2137
|
] }) });
|
|
1834
2138
|
}
|
|
1835
|
-
function
|
|
1836
|
-
const { appearance: t } =
|
|
1837
|
-
if (
|
|
1838
|
-
m(!0),
|
|
2139
|
+
function Ys({ customerId: s, portalToken: a, onApplied: r, appearance: c }) {
|
|
2140
|
+
const { appearance: t } = E(), i = j(a), d = c ?? t, [u, o] = h(""), [n, m] = h(!1), [p, b] = h(null), [f, x] = h(null), y = C(async (w) => {
|
|
2141
|
+
if (w.preventDefault(), !!u.trim()) {
|
|
2142
|
+
m(!0), b(null), x(null);
|
|
1839
2143
|
try {
|
|
1840
|
-
const
|
|
1841
|
-
|
|
1842
|
-
} catch (
|
|
1843
|
-
|
|
2144
|
+
const v = await i.applyCoupon(s, u.trim());
|
|
2145
|
+
x(`Coupon applied! ${v.discountType === "percent" ? `${v.amount}% off` : `$${(v.amount / 100).toFixed(2)} off`}`), o(""), r == null || r(v);
|
|
2146
|
+
} catch (v) {
|
|
2147
|
+
b(v instanceof Error ? v.message : "Invalid coupon code");
|
|
1844
2148
|
} finally {
|
|
1845
2149
|
m(!1);
|
|
1846
2150
|
}
|
|
1847
2151
|
}
|
|
1848
|
-
}, [
|
|
1849
|
-
return /* @__PURE__ */ e(
|
|
2152
|
+
}, [i, s, u, r]);
|
|
2153
|
+
return /* @__PURE__ */ e(D, { appearance: d, children: /* @__PURE__ */ l("div", { className: "ss-card", children: [
|
|
1850
2154
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Apply coupon" }),
|
|
1851
2155
|
p && /* @__PURE__ */ e("div", { className: "ss-global-error", children: p }),
|
|
1852
|
-
|
|
1853
|
-
/* @__PURE__ */
|
|
1854
|
-
/* @__PURE__ */
|
|
2156
|
+
f && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: f }),
|
|
2157
|
+
/* @__PURE__ */ l("form", { onSubmit: y, children: [
|
|
2158
|
+
/* @__PURE__ */ l("div", { className: "ss-field", children: [
|
|
1855
2159
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-coupon-code", children: "Coupon code" }),
|
|
1856
2160
|
/* @__PURE__ */ e(
|
|
1857
2161
|
"input",
|
|
@@ -1861,101 +2165,101 @@ function Ws({ customerId: s, portalToken: a, onApplied: r, appearance: c }) {
|
|
|
1861
2165
|
type: "text",
|
|
1862
2166
|
placeholder: "Enter coupon code",
|
|
1863
2167
|
value: u,
|
|
1864
|
-
onChange: (
|
|
2168
|
+
onChange: (w) => o(w.target.value),
|
|
1865
2169
|
required: !0
|
|
1866
2170
|
}
|
|
1867
2171
|
)
|
|
1868
2172
|
] }),
|
|
1869
|
-
/* @__PURE__ */
|
|
2173
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: n || !u.trim(), children: [
|
|
1870
2174
|
n && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1871
2175
|
"Apply"
|
|
1872
2176
|
] })
|
|
1873
2177
|
] })
|
|
1874
2178
|
] }) });
|
|
1875
2179
|
}
|
|
1876
|
-
function
|
|
1877
|
-
const { client: s } =
|
|
2180
|
+
function Zs() {
|
|
2181
|
+
const { client: s } = E();
|
|
1878
2182
|
return { report: s.report };
|
|
1879
2183
|
}
|
|
1880
|
-
function
|
|
1881
|
-
const { client: s } =
|
|
1882
|
-
t(!0),
|
|
2184
|
+
function rs() {
|
|
2185
|
+
const { client: s } = E(), [a, r] = h(null), [c, t] = h(!1), [i, d] = h(null), u = C(async (o) => {
|
|
2186
|
+
t(!0), d(null);
|
|
1883
2187
|
try {
|
|
1884
2188
|
const n = await s.report.executeQuery(o);
|
|
1885
2189
|
return r(n), n;
|
|
1886
2190
|
} catch (n) {
|
|
1887
|
-
return
|
|
2191
|
+
return d(n instanceof Error ? n.message : "Query failed"), null;
|
|
1888
2192
|
} finally {
|
|
1889
2193
|
t(!1);
|
|
1890
2194
|
}
|
|
1891
2195
|
}, [s]);
|
|
1892
|
-
return { result: a, execute: u, isLoading: c, error:
|
|
2196
|
+
return { result: a, execute: u, isLoading: c, error: i };
|
|
1893
2197
|
}
|
|
1894
|
-
function
|
|
1895
|
-
const { client: a } =
|
|
1896
|
-
|
|
2198
|
+
function Es(s) {
|
|
2199
|
+
const { client: a } = E(), [r, c] = h(null), [t, i] = h(!0), [d, u] = h(null), o = C(async () => {
|
|
2200
|
+
i(!0), u(null);
|
|
1897
2201
|
try {
|
|
1898
2202
|
const n = await a.report.listQueries(s);
|
|
1899
2203
|
c(n);
|
|
1900
2204
|
} catch (n) {
|
|
1901
2205
|
u(n instanceof Error ? n.message : "Failed to load queries");
|
|
1902
2206
|
} finally {
|
|
1903
|
-
|
|
2207
|
+
i(!1);
|
|
1904
2208
|
}
|
|
1905
2209
|
}, [a, s]);
|
|
1906
|
-
return
|
|
2210
|
+
return B(() => {
|
|
1907
2211
|
o();
|
|
1908
|
-
}, [o]), { queries: (r == null ? void 0 : r.data) ?? [], meta: r == null ? void 0 : r.meta, isLoading: t, error:
|
|
2212
|
+
}, [o]), { queries: (r == null ? void 0 : r.data) ?? [], meta: r == null ? void 0 : r.meta, isLoading: t, error: d, refresh: o };
|
|
1909
2213
|
}
|
|
1910
|
-
function
|
|
1911
|
-
const { client: a } =
|
|
1912
|
-
|
|
2214
|
+
function Xs(s) {
|
|
2215
|
+
const { client: a } = E(), [r, c] = h(null), [t, i] = h(!0), [d, u] = h(null), o = C(async () => {
|
|
2216
|
+
i(!0), u(null);
|
|
1913
2217
|
try {
|
|
1914
2218
|
const n = await a.report.getDashboard(s);
|
|
1915
2219
|
c(n);
|
|
1916
2220
|
} catch (n) {
|
|
1917
2221
|
u(n instanceof Error ? n.message : "Failed to load dashboard");
|
|
1918
2222
|
} finally {
|
|
1919
|
-
|
|
2223
|
+
i(!1);
|
|
1920
2224
|
}
|
|
1921
2225
|
}, [a, s]);
|
|
1922
|
-
return
|
|
2226
|
+
return B(() => {
|
|
1923
2227
|
o();
|
|
1924
|
-
}, [o]), { dashboard: r, isLoading: t, error:
|
|
2228
|
+
}, [o]), { dashboard: r, isLoading: t, error: d, refresh: o };
|
|
1925
2229
|
}
|
|
1926
|
-
function
|
|
1927
|
-
const c =
|
|
1928
|
-
const p = new
|
|
1929
|
-
return new
|
|
1930
|
-
}, [s, r]), [t,
|
|
2230
|
+
function Ks(s, a, r = "https://api.saas-support.com/v1") {
|
|
2231
|
+
const c = q(() => {
|
|
2232
|
+
const p = new H(r, { type: "embedToken", token: s });
|
|
2233
|
+
return new J(p);
|
|
2234
|
+
}, [s, r]), [t, i] = h(null), [d, u] = h(!0), [o, n] = h(null), m = C(async () => {
|
|
1931
2235
|
u(!0), n(null);
|
|
1932
2236
|
try {
|
|
1933
2237
|
const p = await c.getDashboard(a);
|
|
1934
|
-
|
|
2238
|
+
i(p);
|
|
1935
2239
|
} catch (p) {
|
|
1936
2240
|
n(p instanceof Error ? p.message : "Failed to load dashboard");
|
|
1937
2241
|
} finally {
|
|
1938
2242
|
u(!1);
|
|
1939
2243
|
}
|
|
1940
2244
|
}, [c, a]);
|
|
1941
|
-
return
|
|
2245
|
+
return B(() => {
|
|
1942
2246
|
m();
|
|
1943
|
-
}, [m]), { dashboard: t, reportClient: c, isLoading:
|
|
2247
|
+
}, [m]), { dashboard: t, reportClient: c, isLoading: d, error: o, refresh: m };
|
|
1944
2248
|
}
|
|
1945
|
-
function
|
|
1946
|
-
const { appearance: t } =
|
|
1947
|
-
if (
|
|
1948
|
-
const
|
|
1949
|
-
|
|
1950
|
-
}, [n, p,
|
|
1951
|
-
return /* @__PURE__ */ e(
|
|
1952
|
-
a === "both" && /* @__PURE__ */
|
|
2249
|
+
function se({ onResult: s, mode: a = "both", placeholder: r, appearance: c }) {
|
|
2250
|
+
const { appearance: t } = E(), { execute: i, isLoading: d, error: u } = rs(), o = c ?? t, [n, m] = h(""), [p, b] = h(a === "sql" ? "sql" : "nl"), f = C(async (x) => {
|
|
2251
|
+
if (x.preventDefault(), !n.trim()) return;
|
|
2252
|
+
const w = await i(p === "sql" ? { sql: n } : { naturalLanguage: n });
|
|
2253
|
+
w && (s == null || s(w));
|
|
2254
|
+
}, [n, p, i, s]);
|
|
2255
|
+
return /* @__PURE__ */ e(D, { appearance: o, children: /* @__PURE__ */ l("div", { className: "ss-card ss-card-wide", children: [
|
|
2256
|
+
a === "both" && /* @__PURE__ */ l("div", { className: "ss-tab-group ss-tab-group-sm", children: [
|
|
1953
2257
|
/* @__PURE__ */ e(
|
|
1954
2258
|
"button",
|
|
1955
2259
|
{
|
|
1956
2260
|
type: "button",
|
|
1957
2261
|
className: `ss-tab ${p === "nl" ? "ss-tab-active" : ""}`,
|
|
1958
|
-
onClick: () =>
|
|
2262
|
+
onClick: () => b("nl"),
|
|
1959
2263
|
children: "Natural Language"
|
|
1960
2264
|
}
|
|
1961
2265
|
),
|
|
@@ -1964,63 +2268,63 @@ function Gs({ onResult: s, mode: a = "both", placeholder: r, appearance: c }) {
|
|
|
1964
2268
|
{
|
|
1965
2269
|
type: "button",
|
|
1966
2270
|
className: `ss-tab ${p === "sql" ? "ss-tab-active" : ""}`,
|
|
1967
|
-
onClick: () =>
|
|
2271
|
+
onClick: () => b("sql"),
|
|
1968
2272
|
children: "SQL"
|
|
1969
2273
|
}
|
|
1970
2274
|
)
|
|
1971
2275
|
] }),
|
|
1972
2276
|
u && /* @__PURE__ */ e("div", { className: "ss-global-error", children: u }),
|
|
1973
|
-
/* @__PURE__ */
|
|
2277
|
+
/* @__PURE__ */ l("form", { onSubmit: f, children: [
|
|
1974
2278
|
/* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
|
|
1975
2279
|
"textarea",
|
|
1976
2280
|
{
|
|
1977
2281
|
className: "ss-input ss-query-textarea",
|
|
1978
2282
|
placeholder: r ?? (p === "sql" ? "SELECT ..." : "Ask a question about your data..."),
|
|
1979
2283
|
value: n,
|
|
1980
|
-
onChange: (
|
|
2284
|
+
onChange: (x) => m(x.target.value),
|
|
1981
2285
|
rows: 3
|
|
1982
2286
|
}
|
|
1983
2287
|
) }),
|
|
1984
|
-
/* @__PURE__ */
|
|
1985
|
-
|
|
2288
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "ss-btn ss-btn-primary", disabled: d || !n.trim(), children: [
|
|
2289
|
+
d && /* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
1986
2290
|
"Run query"
|
|
1987
2291
|
] })
|
|
1988
2292
|
] })
|
|
1989
2293
|
] }) });
|
|
1990
2294
|
}
|
|
1991
|
-
function
|
|
1992
|
-
const { appearance:
|
|
1993
|
-
const
|
|
1994
|
-
if (
|
|
1995
|
-
if (
|
|
1996
|
-
if (
|
|
1997
|
-
if (typeof
|
|
1998
|
-
return n === "asc" ?
|
|
1999
|
-
const
|
|
2000
|
-
return n === "asc" ?
|
|
2001
|
-
}) : a, [a, u, n]),
|
|
2002
|
-
r && (u ===
|
|
2295
|
+
function Is({ columns: s, rows: a, sortable: r = !0, maxRows: c, appearance: t }) {
|
|
2296
|
+
const { appearance: i } = E(), d = t ?? i, [u, o] = h(null), [n, m] = h("asc"), p = q(() => u ? [...a].sort((y, w) => {
|
|
2297
|
+
const v = y[u], g = w[u];
|
|
2298
|
+
if (v == null && g == null) return 0;
|
|
2299
|
+
if (v == null) return 1;
|
|
2300
|
+
if (g == null) return -1;
|
|
2301
|
+
if (typeof v == "number" && typeof g == "number")
|
|
2302
|
+
return n === "asc" ? v - g : g - v;
|
|
2303
|
+
const N = String(v), S = String(g);
|
|
2304
|
+
return n === "asc" ? N.localeCompare(S) : S.localeCompare(N);
|
|
2305
|
+
}) : a, [a, u, n]), b = c ? p.slice(0, c) : p, f = (y) => {
|
|
2306
|
+
r && (u === y ? m((w) => w === "asc" ? "desc" : "asc") : (o(y), m("asc")));
|
|
2003
2307
|
};
|
|
2004
|
-
function y
|
|
2005
|
-
return
|
|
2308
|
+
function x(y) {
|
|
2309
|
+
return y == null ? "" : typeof y == "object" ? JSON.stringify(y) : String(y);
|
|
2006
2310
|
}
|
|
2007
|
-
return /* @__PURE__ */ e(
|
|
2008
|
-
/* @__PURE__ */
|
|
2009
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: s.map((
|
|
2311
|
+
return /* @__PURE__ */ e(D, { appearance: d, children: /* @__PURE__ */ l("div", { className: "ss-table-container", children: [
|
|
2312
|
+
/* @__PURE__ */ l("table", { className: "ss-table", children: [
|
|
2313
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: s.map((y) => /* @__PURE__ */ l(
|
|
2010
2314
|
"th",
|
|
2011
2315
|
{
|
|
2012
|
-
className: `ss-th ${r ? "ss-th-sortable" : ""} ${u ===
|
|
2013
|
-
onClick: () =>
|
|
2316
|
+
className: `ss-th ${r ? "ss-th-sortable" : ""} ${u === y ? n === "asc" ? "ss-sorted-asc" : "ss-sorted-desc" : ""}`,
|
|
2317
|
+
onClick: () => f(y),
|
|
2014
2318
|
children: [
|
|
2015
|
-
|
|
2016
|
-
u ===
|
|
2319
|
+
y,
|
|
2320
|
+
u === y && /* @__PURE__ */ e("span", { className: "ss-sort-indicator", children: n === "asc" ? " ▲" : " ▼" })
|
|
2017
2321
|
]
|
|
2018
2322
|
},
|
|
2019
|
-
|
|
2323
|
+
y
|
|
2020
2324
|
)) }) }),
|
|
2021
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
2325
|
+
/* @__PURE__ */ e("tbody", { children: b.map((y, w) => /* @__PURE__ */ e("tr", { className: "ss-tr", children: s.map((v) => /* @__PURE__ */ e("td", { className: "ss-td", children: x(y[v]) }, v)) }, w)) })
|
|
2022
2326
|
] }),
|
|
2023
|
-
c && a.length > c && /* @__PURE__ */
|
|
2327
|
+
c && a.length > c && /* @__PURE__ */ l("div", { className: "ss-table-footer", children: [
|
|
2024
2328
|
"Showing ",
|
|
2025
2329
|
c,
|
|
2026
2330
|
" of ",
|
|
@@ -2029,185 +2333,185 @@ function vs({ columns: s, rows: a, sortable: r = !0, maxRows: c, appearance: t }
|
|
|
2029
2333
|
] })
|
|
2030
2334
|
] }) });
|
|
2031
2335
|
}
|
|
2032
|
-
function
|
|
2336
|
+
function zs(s, a = "#6366f1") {
|
|
2033
2337
|
const r = parseInt(a.replace("#", "").slice(0, 2), 16), c = [];
|
|
2034
2338
|
for (let t = 0; t < s; t++) {
|
|
2035
|
-
const
|
|
2036
|
-
c.push(`hsl(${
|
|
2339
|
+
const i = (r + t * Math.floor(360 / Math.max(s, 1))) % 360;
|
|
2340
|
+
c.push(`hsl(${i}, 65%, 55%)`);
|
|
2037
2341
|
}
|
|
2038
2342
|
return c;
|
|
2039
2343
|
}
|
|
2040
|
-
function
|
|
2041
|
-
const
|
|
2042
|
-
return /* @__PURE__ */
|
|
2043
|
-
/* @__PURE__ */ e("line", { x1:
|
|
2344
|
+
function Ts({ labels: s, values: a, w: r, h: c, colors: t }) {
|
|
2345
|
+
const i = Math.max(...a, 1), d = 40, u = r - d * 2, o = c - d * 2, n = Math.max(1, u / s.length - 4);
|
|
2346
|
+
return /* @__PURE__ */ l("g", { children: [
|
|
2347
|
+
/* @__PURE__ */ e("line", { x1: d, y1: c - d, x2: r - d, y2: c - d, stroke: "#ccc", strokeWidth: 1 }),
|
|
2044
2348
|
a.map((m, p) => {
|
|
2045
|
-
const
|
|
2046
|
-
return /* @__PURE__ */
|
|
2047
|
-
/* @__PURE__ */ e("rect", { x:
|
|
2048
|
-
/* @__PURE__ */ e("text", { x:
|
|
2349
|
+
const b = m / i * o, f = d + u / s.length * p + 2, x = c - d - b;
|
|
2350
|
+
return /* @__PURE__ */ l("g", { children: [
|
|
2351
|
+
/* @__PURE__ */ e("rect", { x: f, y: x, width: n, height: b, fill: t[p % t.length], rx: 2 }),
|
|
2352
|
+
/* @__PURE__ */ e("text", { x: f + n / 2, y: c - d + 14, textAnchor: "middle", fontSize: 10, fill: "#666", children: s[p].length > 8 ? s[p].slice(0, 8) + "..." : s[p] })
|
|
2049
2353
|
] }, p);
|
|
2050
2354
|
})
|
|
2051
2355
|
] });
|
|
2052
2356
|
}
|
|
2053
|
-
function
|
|
2054
|
-
const
|
|
2055
|
-
const
|
|
2056
|
-
return `${
|
|
2357
|
+
function Ls({ labels: s, values: a, w: r, h: c, colors: t }) {
|
|
2358
|
+
const i = Math.max(...a, 1), d = 40, u = r - d * 2, o = c - d * 2, n = s.length > 1 ? u / (s.length - 1) : 0, m = a.map((p, b) => {
|
|
2359
|
+
const f = d + n * b, x = c - d - p / i * o;
|
|
2360
|
+
return `${f},${x}`;
|
|
2057
2361
|
});
|
|
2058
|
-
return /* @__PURE__ */
|
|
2362
|
+
return /* @__PURE__ */ l("g", { children: [
|
|
2059
2363
|
[0.25, 0.5, 0.75, 1].map((p) => {
|
|
2060
|
-
const
|
|
2061
|
-
return /* @__PURE__ */ e("line", { x1:
|
|
2364
|
+
const b = c - d - p * o;
|
|
2365
|
+
return /* @__PURE__ */ e("line", { x1: d, y1: b, x2: r - d, y2: b, stroke: "#eee", strokeWidth: 1 }, p);
|
|
2062
2366
|
}),
|
|
2063
2367
|
/* @__PURE__ */ e("polyline", { points: m.join(" "), fill: "none", stroke: t[0], strokeWidth: 2 }),
|
|
2064
|
-
a.map((p,
|
|
2065
|
-
const
|
|
2066
|
-
return /* @__PURE__ */ e("circle", { cx:
|
|
2368
|
+
a.map((p, b) => {
|
|
2369
|
+
const f = d + n * b, x = c - d - p / i * o;
|
|
2370
|
+
return /* @__PURE__ */ e("circle", { cx: f, cy: x, r: 4, fill: t[0] }, b);
|
|
2067
2371
|
})
|
|
2068
2372
|
] });
|
|
2069
2373
|
}
|
|
2070
|
-
function
|
|
2071
|
-
const
|
|
2374
|
+
function Bs({ labels: s, values: a, w: r, h: c, colors: t }) {
|
|
2375
|
+
const i = a.reduce((b, f) => b + f, 0) || 1, d = r / 2, u = c / 2 - 20, o = Math.min(r, c) / 2 - 40, n = 2 * Math.PI * o;
|
|
2072
2376
|
let m = 0;
|
|
2073
|
-
const p = a.map((
|
|
2074
|
-
const
|
|
2075
|
-
return m +=
|
|
2377
|
+
const p = a.map((b, f) => {
|
|
2378
|
+
const x = b / i, y = x * n, w = { dash: y, offset: m, color: t[f % t.length], label: s[f], pct: x };
|
|
2379
|
+
return m += y, w;
|
|
2076
2380
|
});
|
|
2077
|
-
return /* @__PURE__ */
|
|
2078
|
-
p.map((
|
|
2381
|
+
return /* @__PURE__ */ l("g", { children: [
|
|
2382
|
+
p.map((b, f) => /* @__PURE__ */ e(
|
|
2079
2383
|
"circle",
|
|
2080
2384
|
{
|
|
2081
|
-
cx:
|
|
2385
|
+
cx: d,
|
|
2082
2386
|
cy: u,
|
|
2083
2387
|
r: o,
|
|
2084
2388
|
fill: "none",
|
|
2085
|
-
stroke:
|
|
2389
|
+
stroke: b.color,
|
|
2086
2390
|
strokeWidth: o * 0.6,
|
|
2087
|
-
strokeDasharray: `${
|
|
2088
|
-
strokeDashoffset: -
|
|
2089
|
-
transform: `rotate(-90 ${
|
|
2391
|
+
strokeDasharray: `${b.dash} ${n - b.dash}`,
|
|
2392
|
+
strokeDashoffset: -b.offset,
|
|
2393
|
+
transform: `rotate(-90 ${d} ${u})`
|
|
2090
2394
|
},
|
|
2091
|
-
|
|
2395
|
+
f
|
|
2092
2396
|
)),
|
|
2093
|
-
/* @__PURE__ */ e("g", { transform: `translate(${
|
|
2094
|
-
/* @__PURE__ */ e("rect", { width: 10, height: 10, fill:
|
|
2095
|
-
/* @__PURE__ */ e("text", { x: 14, y: 9, fontSize: 9, fill: "#666", children:
|
|
2096
|
-
] },
|
|
2397
|
+
/* @__PURE__ */ e("g", { transform: `translate(${d - s.length * 30}, ${c - 20})`, children: p.slice(0, 6).map((b, f) => /* @__PURE__ */ l("g", { transform: `translate(${f * 60}, 0)`, children: [
|
|
2398
|
+
/* @__PURE__ */ e("rect", { width: 10, height: 10, fill: b.color, rx: 2 }),
|
|
2399
|
+
/* @__PURE__ */ e("text", { x: 14, y: 9, fontSize: 9, fill: "#666", children: b.label.length > 6 ? b.label.slice(0, 6) + ".." : b.label })
|
|
2400
|
+
] }, f)) })
|
|
2097
2401
|
] });
|
|
2098
2402
|
}
|
|
2099
|
-
function
|
|
2100
|
-
const { appearance:
|
|
2101
|
-
return /* @__PURE__ */ e(
|
|
2403
|
+
function As({ type: s, data: a, title: r, width: c = 400, height: t = 300, appearance: i }) {
|
|
2404
|
+
const { appearance: d } = E(), u = i ?? d, o = q(() => zs(a.labels.length), [a.labels.length]);
|
|
2405
|
+
return /* @__PURE__ */ e(D, { appearance: u, children: /* @__PURE__ */ l("div", { className: "ss-chart-container", children: [
|
|
2102
2406
|
r && /* @__PURE__ */ e("h3", { className: "ss-chart-title", children: r }),
|
|
2103
|
-
/* @__PURE__ */
|
|
2104
|
-
s === "bar" && /* @__PURE__ */ e(
|
|
2105
|
-
s === "line" && /* @__PURE__ */ e(
|
|
2106
|
-
s === "pie" && /* @__PURE__ */ e(
|
|
2407
|
+
/* @__PURE__ */ l("svg", { viewBox: `0 0 ${c} ${t}`, width: "100%", style: { maxWidth: c }, children: [
|
|
2408
|
+
s === "bar" && /* @__PURE__ */ e(Ts, { labels: a.labels, values: a.values, w: c, h: t, colors: o }),
|
|
2409
|
+
s === "line" && /* @__PURE__ */ e(Ls, { labels: a.labels, values: a.values, w: c, h: t, colors: o }),
|
|
2410
|
+
s === "pie" && /* @__PURE__ */ e(Bs, { labels: a.labels, values: a.values, w: c, h: t, colors: o })
|
|
2107
2411
|
] })
|
|
2108
2412
|
] }) });
|
|
2109
2413
|
}
|
|
2110
|
-
function
|
|
2111
|
-
const
|
|
2414
|
+
function ee({ dashboardId: s, embedToken: a, baseUrl: r, refreshInterval: c, appearance: t }) {
|
|
2415
|
+
const i = E(), d = t ?? (i == null ? void 0 : i.appearance), u = q(() => {
|
|
2112
2416
|
if (a) {
|
|
2113
|
-
const
|
|
2114
|
-
return new
|
|
2417
|
+
const v = r ?? "https://api.saas-support.com/v1", g = new H(v, { type: "embedToken", token: a });
|
|
2418
|
+
return new J(g);
|
|
2115
2419
|
}
|
|
2116
|
-
return
|
|
2117
|
-
}, [a, r,
|
|
2118
|
-
|
|
2420
|
+
return i.client.report;
|
|
2421
|
+
}, [a, r, i]), [o, n] = h([]), [m, p] = h({}), [b, f] = h(!0), [x, y] = h(null), w = C(async () => {
|
|
2422
|
+
f(!0), y(null);
|
|
2119
2423
|
try {
|
|
2120
|
-
const
|
|
2121
|
-
n(
|
|
2122
|
-
const
|
|
2123
|
-
for (const
|
|
2424
|
+
const v = await u.getDashboard(s), g = JSON.parse(v.layoutJson || "[]");
|
|
2425
|
+
n(g);
|
|
2426
|
+
const N = {};
|
|
2427
|
+
for (const S of g)
|
|
2124
2428
|
try {
|
|
2125
|
-
const
|
|
2126
|
-
if (
|
|
2127
|
-
const z = await u.executeQuery({ sql:
|
|
2128
|
-
|
|
2429
|
+
const k = await u.listQueries({ search: S.queryId, perPage: 1 });
|
|
2430
|
+
if (k.data.length > 0 && k.data[0].generatedSql) {
|
|
2431
|
+
const z = await u.executeQuery({ sql: k.data[0].generatedSql });
|
|
2432
|
+
N[S.queryId] = z;
|
|
2129
2433
|
}
|
|
2130
2434
|
} catch {
|
|
2131
2435
|
}
|
|
2132
|
-
p(
|
|
2133
|
-
} catch (
|
|
2134
|
-
|
|
2436
|
+
p(N);
|
|
2437
|
+
} catch (v) {
|
|
2438
|
+
y(v instanceof Error ? v.message : "Failed to load dashboard");
|
|
2135
2439
|
} finally {
|
|
2136
|
-
|
|
2440
|
+
f(!1);
|
|
2137
2441
|
}
|
|
2138
2442
|
}, [u, s]);
|
|
2139
|
-
return
|
|
2140
|
-
|
|
2141
|
-
}, [
|
|
2443
|
+
return B(() => {
|
|
2444
|
+
w();
|
|
2445
|
+
}, [w]), B(() => {
|
|
2142
2446
|
if (!c || c <= 0) return;
|
|
2143
|
-
const
|
|
2144
|
-
return () => clearInterval(
|
|
2145
|
-
}, [c,
|
|
2146
|
-
|
|
2447
|
+
const v = setInterval(w, c * 1e3);
|
|
2448
|
+
return () => clearInterval(v);
|
|
2449
|
+
}, [c, w]), /* @__PURE__ */ e(D, { appearance: d, children: /* @__PURE__ */ l("div", { className: "ss-dashboard-grid", children: [
|
|
2450
|
+
b && /* @__PURE__ */ l("div", { className: "ss-loading", children: [
|
|
2147
2451
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
2148
2452
|
" Loading dashboard..."
|
|
2149
2453
|
] }),
|
|
2150
|
-
|
|
2151
|
-
!
|
|
2152
|
-
const
|
|
2153
|
-
if (!
|
|
2154
|
-
const
|
|
2155
|
-
labels:
|
|
2156
|
-
values:
|
|
2454
|
+
x && /* @__PURE__ */ e("div", { className: "ss-global-error", children: x }),
|
|
2455
|
+
!b && o.map((v, g) => {
|
|
2456
|
+
const N = m[v.queryId];
|
|
2457
|
+
if (!N) return null;
|
|
2458
|
+
const S = N.columns.length >= 2 ? {
|
|
2459
|
+
labels: N.rows.map((k) => String(k[N.columns[0]] ?? "")),
|
|
2460
|
+
values: N.rows.map((k) => Number(k[N.columns[1]] ?? 0))
|
|
2157
2461
|
} : { labels: [], values: [] };
|
|
2158
|
-
return /* @__PURE__ */
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2462
|
+
return /* @__PURE__ */ l("div", { className: "ss-widget", children: [
|
|
2463
|
+
v.title && /* @__PURE__ */ e("h4", { className: "ss-widget-header", children: v.title }),
|
|
2464
|
+
v.chartType === "table" ? /* @__PURE__ */ e(Is, { columns: N.columns, rows: N.rows, maxRows: 50 }) : /* @__PURE__ */ e(
|
|
2465
|
+
As,
|
|
2162
2466
|
{
|
|
2163
|
-
type:
|
|
2164
|
-
data:
|
|
2165
|
-
width:
|
|
2166
|
-
height:
|
|
2467
|
+
type: v.chartType || "bar",
|
|
2468
|
+
data: S,
|
|
2469
|
+
width: v.w,
|
|
2470
|
+
height: v.h
|
|
2167
2471
|
}
|
|
2168
2472
|
)
|
|
2169
|
-
] },
|
|
2473
|
+
] }, g);
|
|
2170
2474
|
})
|
|
2171
2475
|
] }) });
|
|
2172
2476
|
}
|
|
2173
|
-
function
|
|
2477
|
+
function Ds(s) {
|
|
2174
2478
|
return new Date(s).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
|
|
2175
2479
|
}
|
|
2176
|
-
function
|
|
2177
|
-
const { appearance: c } =
|
|
2480
|
+
function re({ onSelectQuery: s, onRunQuery: a, appearance: r }) {
|
|
2481
|
+
const { appearance: c } = E(), { queries: t, isLoading: i, error: d } = Es(), { execute: u, isLoading: o } = rs(), n = r ?? c, m = C(async (p) => {
|
|
2178
2482
|
if (!p.generatedSql) return;
|
|
2179
|
-
const
|
|
2180
|
-
|
|
2483
|
+
const b = await u({ sql: p.generatedSql });
|
|
2484
|
+
b && (a == null || a(b));
|
|
2181
2485
|
}, [u, a]);
|
|
2182
|
-
return /* @__PURE__ */ e(
|
|
2486
|
+
return /* @__PURE__ */ e(D, { appearance: n, children: /* @__PURE__ */ l("div", { className: "ss-card ss-card-wide", children: [
|
|
2183
2487
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Saved Queries" }),
|
|
2184
|
-
|
|
2488
|
+
i && /* @__PURE__ */ l("div", { className: "ss-loading", children: [
|
|
2185
2489
|
/* @__PURE__ */ e("span", { className: "ss-spinner" }),
|
|
2186
2490
|
" Loading..."
|
|
2187
2491
|
] }),
|
|
2188
|
-
|
|
2189
|
-
!
|
|
2190
|
-
!
|
|
2492
|
+
d && /* @__PURE__ */ e("div", { className: "ss-global-error", children: d }),
|
|
2493
|
+
!i && t.length === 0 && /* @__PURE__ */ e("p", { className: "ss-empty", children: "No saved queries." }),
|
|
2494
|
+
!i && t.map((p) => /* @__PURE__ */ l(
|
|
2191
2495
|
"div",
|
|
2192
2496
|
{
|
|
2193
2497
|
className: "ss-saved-query-card",
|
|
2194
2498
|
onClick: () => s == null ? void 0 : s(p),
|
|
2195
2499
|
children: [
|
|
2196
|
-
/* @__PURE__ */
|
|
2500
|
+
/* @__PURE__ */ l("div", { className: "ss-saved-query-header", children: [
|
|
2197
2501
|
/* @__PURE__ */ e("span", { className: "ss-saved-query-name", children: p.name }),
|
|
2198
2502
|
p.chartType && /* @__PURE__ */ e("span", { className: "ss-badge", children: p.chartType })
|
|
2199
2503
|
] }),
|
|
2200
2504
|
p.naturalLanguage && /* @__PURE__ */ e("p", { className: "ss-saved-query-desc", children: p.naturalLanguage }),
|
|
2201
|
-
/* @__PURE__ */
|
|
2202
|
-
/* @__PURE__ */ e("span", { className: "ss-saved-query-date", children:
|
|
2505
|
+
/* @__PURE__ */ l("div", { className: "ss-saved-query-footer", children: [
|
|
2506
|
+
/* @__PURE__ */ e("span", { className: "ss-saved-query-date", children: Ds(p.createdAt) }),
|
|
2203
2507
|
/* @__PURE__ */ e(
|
|
2204
2508
|
"button",
|
|
2205
2509
|
{
|
|
2206
2510
|
type: "button",
|
|
2207
2511
|
className: "ss-btn ss-btn-sm ss-btn-primary",
|
|
2208
2512
|
disabled: o || !p.generatedSql,
|
|
2209
|
-
onClick: (
|
|
2210
|
-
|
|
2513
|
+
onClick: (b) => {
|
|
2514
|
+
b.stopPropagation(), m(p);
|
|
2211
2515
|
},
|
|
2212
2516
|
children: o ? /* @__PURE__ */ e("span", { className: "ss-spinner" }) : "Run"
|
|
2213
2517
|
}
|
|
@@ -2219,105 +2523,105 @@ function Qs({ onSelectQuery: s, onRunQuery: a, appearance: r }) {
|
|
|
2219
2523
|
))
|
|
2220
2524
|
] }) });
|
|
2221
2525
|
}
|
|
2222
|
-
function
|
|
2223
|
-
const
|
|
2224
|
-
const
|
|
2225
|
-
return new
|
|
2226
|
-
}, [s, r]), [
|
|
2526
|
+
function ae({ embedToken: s, dashboardId: a, baseUrl: r = "https://api.saas-support.com/v1", refreshInterval: c, appearance: t }) {
|
|
2527
|
+
const i = q(() => {
|
|
2528
|
+
const y = new H(r, { type: "embedToken", token: s });
|
|
2529
|
+
return new J(y);
|
|
2530
|
+
}, [s, r]), [d, u] = h([]), [o, n] = h(!0), [m, p] = h(null), b = q(() => V(t), [t]), f = q(() => G(b), [b]), x = C(async () => {
|
|
2227
2531
|
n(!0), p(null);
|
|
2228
2532
|
try {
|
|
2229
|
-
const
|
|
2230
|
-
|
|
2533
|
+
const y = await i.getDashboard(a), w = JSON.parse(y.layoutJson || "[]"), v = await Promise.all(
|
|
2534
|
+
w.map(async (g) => {
|
|
2231
2535
|
try {
|
|
2232
|
-
const
|
|
2233
|
-
if (
|
|
2234
|
-
const
|
|
2235
|
-
return { ...
|
|
2536
|
+
const N = await i.listQueries({ search: g.queryId, perPage: 1 });
|
|
2537
|
+
if (N.data.length > 0 && N.data[0].generatedSql) {
|
|
2538
|
+
const S = await i.executeQuery({ sql: N.data[0].generatedSql });
|
|
2539
|
+
return { ...g, result: S };
|
|
2236
2540
|
}
|
|
2237
2541
|
} catch {
|
|
2238
2542
|
}
|
|
2239
|
-
return
|
|
2543
|
+
return g;
|
|
2240
2544
|
})
|
|
2241
2545
|
);
|
|
2242
|
-
u(
|
|
2243
|
-
} catch (
|
|
2244
|
-
p(
|
|
2546
|
+
u(v);
|
|
2547
|
+
} catch (y) {
|
|
2548
|
+
p(y instanceof Error ? y.message : "Failed to load dashboard");
|
|
2245
2549
|
} finally {
|
|
2246
2550
|
n(!1);
|
|
2247
2551
|
}
|
|
2248
|
-
}, [
|
|
2249
|
-
return
|
|
2250
|
-
|
|
2251
|
-
}, [
|
|
2552
|
+
}, [i, a]);
|
|
2553
|
+
return B(() => {
|
|
2554
|
+
x();
|
|
2555
|
+
}, [x]), B(() => {
|
|
2252
2556
|
if (!c || c <= 0) return;
|
|
2253
|
-
const
|
|
2254
|
-
return () => clearInterval(
|
|
2255
|
-
}, [c,
|
|
2557
|
+
const y = setInterval(x, c * 1e3);
|
|
2558
|
+
return () => clearInterval(y);
|
|
2559
|
+
}, [c, x]), /* @__PURE__ */ e(
|
|
2256
2560
|
"div",
|
|
2257
2561
|
{
|
|
2258
|
-
ref: (
|
|
2259
|
-
if (!
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2262
|
-
const
|
|
2263
|
-
|
|
2562
|
+
ref: (y) => {
|
|
2563
|
+
if (!y || y.shadowRoot) return;
|
|
2564
|
+
const w = y.attachShadow({ mode: "open" }), v = document.createElement("style");
|
|
2565
|
+
v.textContent = f, w.appendChild(v);
|
|
2566
|
+
const g = document.createElement("div");
|
|
2567
|
+
w.appendChild(g);
|
|
2264
2568
|
},
|
|
2265
2569
|
style: { display: "contents" },
|
|
2266
|
-
children: /* @__PURE__ */
|
|
2570
|
+
children: /* @__PURE__ */ l("div", { className: "ss-dashboard-grid", children: [
|
|
2267
2571
|
o && /* @__PURE__ */ e("div", { className: "ss-loading", children: "Loading dashboard..." }),
|
|
2268
2572
|
m && /* @__PURE__ */ e("div", { className: "ss-global-error", children: m }),
|
|
2269
|
-
!o &&
|
|
2270
|
-
if (!
|
|
2271
|
-
const { columns:
|
|
2272
|
-
return /* @__PURE__ */
|
|
2273
|
-
|
|
2274
|
-
/* @__PURE__ */
|
|
2275
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children:
|
|
2276
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
2573
|
+
!o && d.map((y, w) => {
|
|
2574
|
+
if (!y.result) return null;
|
|
2575
|
+
const { columns: v, rows: g } = y.result;
|
|
2576
|
+
return /* @__PURE__ */ l("div", { className: "ss-widget", children: [
|
|
2577
|
+
y.title && /* @__PURE__ */ e("h4", { className: "ss-widget-header", children: y.title }),
|
|
2578
|
+
/* @__PURE__ */ l("table", { className: "ss-table", children: [
|
|
2579
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: v.map((N) => /* @__PURE__ */ e("th", { className: "ss-th", children: N }, N)) }) }),
|
|
2580
|
+
/* @__PURE__ */ e("tbody", { children: g.slice(0, 50).map((N, S) => /* @__PURE__ */ e("tr", { className: "ss-tr", children: v.map((k) => /* @__PURE__ */ e("td", { className: "ss-td", children: String(N[k] ?? "") }, k)) }, S)) })
|
|
2277
2581
|
] })
|
|
2278
|
-
] },
|
|
2582
|
+
] }, w);
|
|
2279
2583
|
})
|
|
2280
2584
|
] })
|
|
2281
2585
|
}
|
|
2282
2586
|
);
|
|
2283
2587
|
}
|
|
2284
2588
|
export {
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2589
|
+
As as Chart,
|
|
2590
|
+
Ys as CouponInput,
|
|
2591
|
+
ee as DashboardView,
|
|
2592
|
+
Is as DataTable,
|
|
2593
|
+
$s as InvoiceHistory,
|
|
2594
|
+
Vs as OrgSwitcher,
|
|
2595
|
+
Qs as PaymentPortal,
|
|
2596
|
+
Gs as PricingTable,
|
|
2597
|
+
se as QueryInput,
|
|
2598
|
+
ae as ReportEmbed,
|
|
2599
|
+
Q as SaaSContext,
|
|
2600
|
+
oe as SaaSError,
|
|
2601
|
+
Rs as SaaSProvider,
|
|
2602
|
+
os as SaaSSupport,
|
|
2603
|
+
re as SavedQueryList,
|
|
2604
|
+
Ws as SignIn,
|
|
2605
|
+
Hs as SignUp,
|
|
2606
|
+
Ns as SubscriptionStatus,
|
|
2607
|
+
Ps as UsageDisplay,
|
|
2608
|
+
js as UserButton,
|
|
2609
|
+
_s as UserProfile,
|
|
2610
|
+
ls as isMfaRequired,
|
|
2611
|
+
Y as useAuth,
|
|
2612
|
+
Js as useBilling,
|
|
2613
|
+
Xs as useDashboard,
|
|
2614
|
+
Ks as useEmbedDashboard,
|
|
2615
|
+
xs as useInvoices,
|
|
2616
|
+
gs as useOrg,
|
|
2617
|
+
X as useProfile,
|
|
2618
|
+
rs as useQuery,
|
|
2619
|
+
Zs as useReport,
|
|
2620
|
+
E as useSaaSContext,
|
|
2621
|
+
Es as useSavedQueries,
|
|
2622
|
+
Z as useSignIn,
|
|
2623
|
+
ms as useSignUp,
|
|
2624
|
+
ys as useSubscription,
|
|
2625
|
+
vs as useUsage,
|
|
2626
|
+
Os as useUser
|
|
2323
2627
|
};
|