@yackey-labs/yauth-ui-solidjs 0.12.2 → 0.12.4

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.js CHANGED
@@ -1,17 +1,259 @@
1
- import { Show as e, addEventListener as t, createComponent as n, delegateEvents as r, effect as i, insert as a, memo as o, template as s } from "solid-js/web";
2
- import { For as c, Show as l, createContext as u, createEffect as d, createResource as f, createSignal as p, useContext as m } from "solid-js";
3
- import { startAuthentication as h, startRegistration as g } from "@simplewebauthn/browser";
1
+ import { Show as e, addEventListener as t, classList as n, className as r, createComponent as i, delegateEvents as a, effect as o, insert as s, memo as c, setAttribute as l, template as u, use as d } from "solid-js/web";
2
+ import { For as f, Show as p, createContext as m, createEffect as h, createMemo as g, createResource as _, createSignal as v, onCleanup as y, useContext as b } from "solid-js";
3
+ import { auditExportCreateDestination as x, auditExportDeleteDestination as S, auditExportListDestinationOutbox as C, auditExportListDestinations as w, auditExportUpdateDestination as T } from "@yackey-labs/yauth-client";
4
+ import { startAuthentication as E, startRegistration as D } from "@simplewebauthn/browser";
5
+ //#region src/hooks/create-audit-destinations.ts
6
+ function O(e, t = {}) {
7
+ let [n, r] = v([]), [i, a] = v(!1), [o, s] = v(!1), [c, l] = v(null), u = async () => {
8
+ a(!0), l(null);
9
+ try {
10
+ let t = e?.();
11
+ r(await w(t ? { organization_id: t } : { scope: "deployment" }));
12
+ } catch (e) {
13
+ l(e instanceof Error ? e.message : "failed to load destinations"), r([]);
14
+ } finally {
15
+ a(!1);
16
+ }
17
+ };
18
+ return h(() => {
19
+ e?.(), u();
20
+ }), {
21
+ destinations: n,
22
+ loading: i,
23
+ submitting: o,
24
+ error: c,
25
+ refresh: u,
26
+ create: async (e) => {
27
+ s(!0), l(null);
28
+ try {
29
+ let t = await x(e);
30
+ return await u(), t;
31
+ } catch (e) {
32
+ return l(e instanceof Error ? e.message : "create failed"), null;
33
+ } finally {
34
+ s(!1);
35
+ }
36
+ },
37
+ disable: async (e) => {
38
+ s(!0);
39
+ try {
40
+ await T(e, { status: "disabled" }), await u();
41
+ } finally {
42
+ s(!1);
43
+ }
44
+ },
45
+ remove: async (e) => {
46
+ s(!0);
47
+ try {
48
+ await S(e), await u();
49
+ } finally {
50
+ s(!1);
51
+ }
52
+ },
53
+ outbox: async (e, t = 50) => await C(e, { limit: String(t) })
54
+ };
55
+ }
56
+ //#endregion
57
+ //#region src/components/audit-destination-create.tsx
58
+ var k = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), ee = /* @__PURE__ */ u("<fieldset class=space-y-2><label class=block><span class=\"text-xs font-medium\">URL</span><input type=url required placeholder=https://hooks.example.com/yauth-audit class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"></label><label class=block><span class=\"text-xs font-medium\">Format</span><select class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"><option value=json>JSON</option><option value=cef>CEF</option><option value=rfc5424>RFC 5424 syslog body</option></select></label><label class=block><span class=\"text-xs font-medium\">HMAC secret (optional)</span><input type=password placeholder=\"cryptographic random, 32 bytes recommended\"class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"><p class=\"mt-1 text-xs text-muted-foreground\">When set, each request carries <code class=font-mono>X-Yauth-Signature: t=&lt;unix&gt;,v1=&lt;hex&gt;</code>. See <code>docs/audit-export/webhook.md</code> for the verifier helper (Node + Python)."), A = /* @__PURE__ */ u("<fieldset class=space-y-2><label class=block><span class=\"text-xs font-medium\">Host</span><input type=text required placeholder=siem.example.internal class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"></label><label class=block><span class=\"text-xs font-medium\">Port</span><input type=number required min=1 max=65535 class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"></label><label class=block><span class=\"text-xs font-medium\">Transport</span><select class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"><option value=tcp>TCP (RFC 6587 octet-counted)</option><option value=udp>UDP (unauthenticated, not recommended)</option><option value=tls>TCP + TLS (port 6514)</option></select></label><label class=block><span class=\"text-xs font-medium\">Facility (0–23)</span><input type=number required min=0 max=23 class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\">"), j = /* @__PURE__ */ u("<fieldset class=space-y-2><label class=block><span class=\"text-xs font-medium\">Bucket</span><input type=text required class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"></label><label class=block><span class=\"text-xs font-medium\">Prefix</span><input type=text class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"></label><label class=block><span class=\"text-xs font-medium\">Region</span><input type=text required class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"></label><label class=block><span class=\"text-xs font-medium\">Partition</span><select class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"><option value=by_date>By date</option><option value=by_org>By org</option><option value=by_date_and_org>By date and org"), te = /* @__PURE__ */ u("<fieldset class=space-y-2><label class=block><span class=\"text-xs font-medium\">HEC URL</span><input type=url required placeholder=https://splunk.example.com:8088 class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"></label><label class=block><span class=\"text-xs font-medium\">HEC token</span><input type=password required class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\">"), M = /* @__PURE__ */ u("<fieldset class=space-y-2><label class=block><span class=\"text-xs font-medium\">Site</span><select class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\"><option value=datadoghq.com>datadoghq.com (US1)</option><option value=us3.datadoghq.com>us3.datadoghq.com (US3)</option><option value=us5.datadoghq.com>us5.datadoghq.com (US5)</option><option value=datadoghq.eu>datadoghq.eu (EU)</option><option value=ap1.datadoghq.com>ap1.datadoghq.com (AP1)</option><option value=ddog-gov.com>ddog-gov.com (US1-FED)</option></select></label><label class=block><span class=\"text-xs font-medium\">API key</span><input type=password required class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm\">"), N = /* @__PURE__ */ u("<form class=\"space-y-3 rounded-md border border-border p-4\"><h3 class=\"text-base font-semibold\">Add destination</h3><label class=block><span class=\"text-xs font-medium\">Name</span><input type=text required class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring\"></label><label class=block><span class=\"text-xs font-medium\">Kind</span><select class=\"mt-1 block w-full rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring\"><option value=webhook>Webhook (HTTPS POST)</option><option value=syslog>Syslog (RFC 5424)</option><option value=s3>S3-compatible object storage</option><option value=splunk>Splunk HEC</option><option value=datadog>Datadog logs</option></select></label><button type=submit class=\"inline-flex h-9 cursor-pointer items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground shadow hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50\">Add destination");
59
+ function P(e) {
60
+ let { create: t, submitting: n, error: r } = O(() => e.organizationId ?? null), [a, c] = v("webhook"), [l, u] = v(""), [d, f] = v(""), [m, h] = v("json"), [g, _] = v(""), [y, b] = v(""), [x, S] = v(6514), [C, w] = v("tcp"), [T, E] = v(13), [D, P] = v(""), [F, I] = v("audit"), [L, R] = v("us-east-1"), [z, B] = v("by_date"), [V, H] = v(""), [U, W] = v(""), [G, K] = v("datadoghq.com"), [q, J] = v(""), ne = async (n) => {
61
+ n.preventDefault();
62
+ let r;
63
+ switch (a()) {
64
+ case "webhook":
65
+ r = {
66
+ type: "webhook",
67
+ url: d().trim(),
68
+ format: m(),
69
+ hmac_secret: g().trim() || void 0
70
+ };
71
+ break;
72
+ case "syslog":
73
+ r = {
74
+ type: "syslog",
75
+ host: y().trim(),
76
+ port: x(),
77
+ transport: C(),
78
+ facility: T()
79
+ };
80
+ break;
81
+ case "s3":
82
+ r = {
83
+ type: "s3",
84
+ bucket: D().trim(),
85
+ prefix: F().trim(),
86
+ region: L().trim(),
87
+ partition: z()
88
+ };
89
+ break;
90
+ case "splunk":
91
+ r = {
92
+ type: "splunk",
93
+ hec_url: V().trim(),
94
+ hec_token: U().trim()
95
+ };
96
+ break;
97
+ case "datadog":
98
+ r = {
99
+ type: "datadog",
100
+ site: G().trim(),
101
+ api_key: q().trim()
102
+ };
103
+ break;
104
+ }
105
+ await t({
106
+ name: l().trim(),
107
+ organization_id: e.organizationId ?? null,
108
+ kind: r
109
+ }) && (e.onCreated?.(), u(""), f(""), _(""), b(""), P(""), H(""), W(""), J(""));
110
+ };
111
+ return (() => {
112
+ var e = N(), t = e.firstChild.nextSibling, v = t.firstChild.nextSibling, O = t.nextSibling, Y = O.firstChild.nextSibling, X = O.nextSibling;
113
+ return e.addEventListener("submit", ne), s(e, i(p, {
114
+ get when() {
115
+ return r();
116
+ },
117
+ get children() {
118
+ var e = k();
119
+ return s(e, r), e;
120
+ }
121
+ }), t), v.$$input = (e) => u(e.currentTarget.value), Y.addEventListener("change", (e) => c(e.currentTarget.value)), s(e, i(p, {
122
+ get when() {
123
+ return a() === "webhook";
124
+ },
125
+ get children() {
126
+ var e = ee(), t = e.firstChild, n = t.firstChild.nextSibling, r = t.nextSibling, i = r.firstChild.nextSibling, a = r.nextSibling.firstChild.nextSibling;
127
+ return n.$$input = (e) => f(e.currentTarget.value), i.addEventListener("change", (e) => h(e.currentTarget.value)), a.$$input = (e) => _(e.currentTarget.value), o(() => n.value = d()), o(() => i.value = m()), o(() => a.value = g()), e;
128
+ }
129
+ }), X), s(e, i(p, {
130
+ get when() {
131
+ return a() === "syslog";
132
+ },
133
+ get children() {
134
+ var e = A(), t = e.firstChild, n = t.firstChild.nextSibling, r = t.nextSibling, i = r.firstChild.nextSibling, a = r.nextSibling, s = a.firstChild.nextSibling, c = a.nextSibling.firstChild.nextSibling;
135
+ return n.$$input = (e) => b(e.currentTarget.value), i.$$input = (e) => S(Number(e.currentTarget.value) || 0), s.addEventListener("change", (e) => w(e.currentTarget.value)), c.$$input = (e) => E(Number(e.currentTarget.value) || 0), o(() => n.value = y()), o(() => i.value = x()), o(() => s.value = C()), o(() => c.value = T()), e;
136
+ }
137
+ }), X), s(e, i(p, {
138
+ get when() {
139
+ return a() === "s3";
140
+ },
141
+ get children() {
142
+ var e = j(), t = e.firstChild, n = t.firstChild.nextSibling, r = t.nextSibling, i = r.firstChild.nextSibling, a = r.nextSibling, s = a.firstChild.nextSibling, c = a.nextSibling.firstChild.nextSibling;
143
+ return n.$$input = (e) => P(e.currentTarget.value), i.$$input = (e) => I(e.currentTarget.value), s.$$input = (e) => R(e.currentTarget.value), c.addEventListener("change", (e) => B(e.currentTarget.value)), o(() => n.value = D()), o(() => i.value = F()), o(() => s.value = L()), o(() => c.value = z()), e;
144
+ }
145
+ }), X), s(e, i(p, {
146
+ get when() {
147
+ return a() === "splunk";
148
+ },
149
+ get children() {
150
+ var e = te(), t = e.firstChild, n = t.firstChild.nextSibling, r = t.nextSibling.firstChild.nextSibling;
151
+ return n.$$input = (e) => H(e.currentTarget.value), r.$$input = (e) => W(e.currentTarget.value), o(() => n.value = V()), o(() => r.value = U()), e;
152
+ }
153
+ }), X), s(e, i(p, {
154
+ get when() {
155
+ return a() === "datadog";
156
+ },
157
+ get children() {
158
+ var e = M(), t = e.firstChild, n = t.firstChild.nextSibling, r = t.nextSibling.firstChild.nextSibling;
159
+ return n.addEventListener("change", (e) => K(e.currentTarget.value)), r.$$input = (e) => J(e.currentTarget.value), o(() => n.value = G()), o(() => r.value = q()), e;
160
+ }
161
+ }), X), o(() => X.disabled = n()), o(() => v.value = l()), o(() => Y.value = a()), e;
162
+ })();
163
+ }
164
+ a(["input"]);
165
+ //#endregion
166
+ //#region src/components/audit-destination-list.tsx
167
+ var F = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), I = /* @__PURE__ */ u("<p class=\"text-sm text-muted-foreground\">Loading…"), L = /* @__PURE__ */ u("<ul class=\"divide-y divide-border\">"), R = /* @__PURE__ */ u("<section class=space-y-4><header class=\"flex items-center justify-between\"><h2 class=\"text-lg font-semibold\"></h2><button type=button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-transparent px-3 text-xs font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50\">Refresh"), z = /* @__PURE__ */ u("<p class=\"text-sm text-muted-foreground\">No destinations configured. Use the “Add destination” form below."), B = /* @__PURE__ */ u("<button type=button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-transparent px-3 text-xs font-medium shadow-sm hover:bg-accent disabled:pointer-events-none disabled:opacity-50\">Disable"), V = /* @__PURE__ */ u("<li class=\"flex items-start justify-between gap-3 py-3\"><div class=\"min-w-0 flex-1 space-y-1\"><div class=\"flex flex-wrap items-center gap-2\"><span class=font-medium></span><span class=\"rounded-full bg-muted px-2 py-0.5 text-xs uppercase text-muted-foreground\"></span><span></span></div><pre class=\"overflow-x-auto rounded-md bg-muted/50 p-2 text-xs leading-snug\"></pre><p class=\"text-xs text-muted-foreground\">Last success: <!> · Last failure: </p></div><div class=\"flex flex-col gap-2\"><button type=button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-destructive bg-transparent px-3 text-xs font-medium text-destructive shadow-sm hover:bg-destructive/10 disabled:pointer-events-none disabled:opacity-50\">Delete");
168
+ function H(e) {
169
+ if (!e) return "—";
170
+ try {
171
+ return new Date(e).toLocaleString();
172
+ } catch {
173
+ return e;
174
+ }
175
+ }
176
+ function U(e) {
177
+ let t = g(() => e.organizationId ?? null), { destinations: r, loading: a, error: l, disable: u, remove: d, submitting: m, refresh: h } = O(() => t());
178
+ return (() => {
179
+ var t = R(), g = t.firstChild.firstChild, _ = g.nextSibling;
180
+ return s(g, () => e.organizationId ? "Per-org SIEM destinations" : "Deployment-wide SIEM destinations"), _.$$click = () => void h(), s(t, i(p, {
181
+ get when() {
182
+ return l();
183
+ },
184
+ get children() {
185
+ var e = F();
186
+ return s(e, l), e;
187
+ }
188
+ }), null), s(t, i(p, {
189
+ get when() {
190
+ return a();
191
+ },
192
+ get children() {
193
+ return I();
194
+ }
195
+ }), null), s(t, i(p, {
196
+ get when() {
197
+ return c(() => !a())() && r().length > 0;
198
+ },
199
+ get fallback() {
200
+ return i(p, {
201
+ get when() {
202
+ return !a();
203
+ },
204
+ get children() {
205
+ return z();
206
+ }
207
+ });
208
+ },
209
+ get children() {
210
+ var e = L();
211
+ return s(e, i(f, {
212
+ get each() {
213
+ return r();
214
+ },
215
+ children: (e) => (() => {
216
+ var t = V(), r = t.firstChild, a = r.firstChild, c = a.firstChild, l = c.nextSibling, f = l.nextSibling, h = a.nextSibling, g = h.nextSibling, _ = g.firstChild.nextSibling;
217
+ _.nextSibling;
218
+ var v = r.nextSibling, y = v.firstChild;
219
+ return s(c, () => e.name), s(l, () => e.kind_tag), s(f, () => e.status), s(h, () => JSON.stringify(e.kind, null, 2)), s(g, () => H(e.last_success_at), _), s(g, () => H(e.last_failure_at), null), s(v, i(p, {
220
+ get when() {
221
+ return e.status === "active";
222
+ },
223
+ get children() {
224
+ var t = B();
225
+ return t.$$click = () => void u(e.id), o(() => t.disabled = m()), t;
226
+ }
227
+ }), y), y.$$click = () => void d(e.id), o((t) => {
228
+ var r = {
229
+ "rounded-full px-2 py-0.5 text-xs": !0,
230
+ "bg-emerald-500/10 text-emerald-700": e.status === "active",
231
+ "bg-muted text-muted-foreground": e.status === "disabled"
232
+ }, i = m();
233
+ return t.e = n(f, r, t.e), i !== t.t && (y.disabled = t.t = i), t;
234
+ }, {
235
+ e: void 0,
236
+ t: void 0
237
+ }), t;
238
+ })()
239
+ })), e;
240
+ }
241
+ }), null), o(() => _.disabled = a() || m()), t;
242
+ })();
243
+ }
244
+ a(["click"]);
245
+ //#endregion
4
246
  //#region src/provider.tsx
5
- var _ = u(), v = (e) => {
247
+ var W = m(), G = (e) => {
6
248
  if (!e.client && !e.baseUrl) throw Error("YAuthProvider requires either a `client` or `baseUrl` prop");
7
- let [t, r] = p(e.client ?? null);
249
+ let [t, n] = v(e.client ?? null);
8
250
  if (!e.client && e.baseUrl) {
9
251
  let t = e.baseUrl;
10
252
  import("@yackey-labs/yauth-client").then((e) => {
11
- r(() => e.createYAuthClient({ baseUrl: t }));
253
+ n(() => e.createYAuthClient({ baseUrl: t }));
12
254
  });
13
255
  }
14
- let i = null, [a, { refetch: o }] = f(async () => {
256
+ let r = null, [a, { refetch: o }] = _(async () => {
15
257
  let e = t();
16
258
  if (!e) return null;
17
259
  try {
@@ -20,23 +262,23 @@ var _ = u(), v = (e) => {
20
262
  return null;
21
263
  }
22
264
  });
23
- d(() => {
265
+ h(() => {
24
266
  t() && o();
25
- }), d(() => {
26
- if (!a.loading && i) {
27
- let e = i;
28
- i = null, e(a() ?? null);
267
+ }), h(() => {
268
+ if (!a.loading && r) {
269
+ let e = r;
270
+ r = null, e(a() ?? null);
29
271
  }
30
272
  });
31
273
  let s = () => new Promise((e) => {
32
- i = e, o();
274
+ r = e, o();
33
275
  });
34
- return n(l, {
276
+ return i(p, {
35
277
  get when() {
36
278
  return t();
37
279
  },
38
280
  fallback: null,
39
- children: (t) => n(_.Provider, {
281
+ children: (t) => i(W.Provider, {
40
282
  get value() {
41
283
  return {
42
284
  client: t(),
@@ -51,70 +293,70 @@ var _ = u(), v = (e) => {
51
293
  })
52
294
  });
53
295
  };
54
- function y() {
55
- let e = m(_);
296
+ function K() {
297
+ let e = b(W);
56
298
  if (!e) throw Error("useYAuth must be used within a <YAuthProvider>");
57
299
  return e;
58
300
  }
59
301
  //#endregion
60
302
  //#region src/components/change-password-form.tsx
61
- var b = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), x = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Password changed successfully."), S = /* @__PURE__ */ s("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-current-password>Current password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-current-password name=current_password type=password required autocomplete=current-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-new-password>New password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-new-password name=new_password type=password required autocomplete=new-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-confirm-password>Confirm new password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-confirm-password name=confirm_password type=password required autocomplete=new-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), C = (t) => {
62
- let { client: r } = y(), o = r?.emailPassword;
63
- if (!o) return null;
64
- let [s, c] = p(""), [l, u] = p(""), [d, f] = p(""), [m, h] = p(null), [g, _] = p(!1), [v, C] = p(!1), w = async (e) => {
65
- e.preventDefault(), h(null), _(!1);
66
- let n = e.currentTarget, r = new FormData(n), i = r.get("current_password") || s(), a = r.get("new_password") || l();
67
- if (a !== (r.get("confirm_password") || d())) {
68
- h("Passwords do not match");
303
+ var q = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), J = /* @__PURE__ */ u("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Password changed successfully."), ne = /* @__PURE__ */ u("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-current-password>Current password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-current-password name=current_password type=password required autocomplete=current-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-new-password>New password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-new-password name=new_password type=password required autocomplete=new-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-confirm-password>Confirm new password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-confirm-password name=confirm_password type=password required autocomplete=new-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Y = (t) => {
304
+ let { client: n } = K(), r = n?.emailPassword;
305
+ if (!r) return null;
306
+ let [a, c] = v(""), [l, u] = v(""), [d, f] = v(""), [p, m] = v(null), [h, g] = v(!1), [_, y] = v(!1), b = async (e) => {
307
+ e.preventDefault(), m(null), g(!1);
308
+ let n = e.currentTarget, i = new FormData(n), o = i.get("current_password") || a(), s = i.get("new_password") || l();
309
+ if (s !== (i.get("confirm_password") || d())) {
310
+ m("Passwords do not match");
69
311
  return;
70
312
  }
71
- C(!0);
313
+ y(!0);
72
314
  try {
73
- await o.changePassword({
74
- current_password: i,
75
- new_password: a
76
- }), _(!0), c(""), u(""), f(""), t.onSuccess?.();
315
+ await r.changePassword({
316
+ current_password: o,
317
+ new_password: s
318
+ }), g(!0), c(""), u(""), f(""), t.onSuccess?.();
77
319
  } catch (e) {
78
320
  let n = e instanceof Error ? e : Error(String(e));
79
- h(n.message), t.onError?.(n);
321
+ m(n.message), t.onError?.(n);
80
322
  } finally {
81
- C(!1);
323
+ y(!1);
82
324
  }
83
325
  };
84
326
  return (() => {
85
- var t = S(), r = t.firstChild, o = r.firstChild.nextSibling, p = r.nextSibling, h = p.firstChild.nextSibling, _ = p.nextSibling, y = _.firstChild.nextSibling, C = _.nextSibling;
86
- return t.addEventListener("submit", w), a(t, n(e, {
327
+ var t = ne(), n = t.firstChild, r = n.firstChild.nextSibling, m = n.nextSibling, g = m.firstChild.nextSibling, v = m.nextSibling, y = v.firstChild.nextSibling, x = v.nextSibling;
328
+ return t.addEventListener("submit", b), s(t, i(e, {
87
329
  get when() {
88
- return m();
330
+ return p();
89
331
  },
90
332
  get children() {
91
- var e = b();
92
- return a(e, m), e;
333
+ var e = q();
334
+ return s(e, p), e;
93
335
  }
94
- }), r), a(t, n(e, {
336
+ }), n), s(t, i(e, {
95
337
  get when() {
96
- return g();
338
+ return h();
97
339
  },
98
340
  get children() {
99
- return x();
341
+ return J();
100
342
  }
101
- }), r), o.$$input = (e) => c(e.currentTarget.value), h.$$input = (e) => u(e.currentTarget.value), y.$$input = (e) => f(e.currentTarget.value), a(C, () => v() ? "Changing password..." : "Change password"), i((e) => {
102
- var t = v(), n = v(), r = v(), i = v();
103
- return t !== e.e && (o.disabled = e.e = t), n !== e.t && (h.disabled = e.t = n), r !== e.a && (y.disabled = e.a = r), i !== e.o && (C.disabled = e.o = i), e;
343
+ }), n), r.$$input = (e) => c(e.currentTarget.value), g.$$input = (e) => u(e.currentTarget.value), y.$$input = (e) => f(e.currentTarget.value), s(x, () => _() ? "Changing password..." : "Change password"), o((e) => {
344
+ var t = _(), n = _(), i = _(), a = _();
345
+ return t !== e.e && (r.disabled = e.e = t), n !== e.t && (g.disabled = e.t = n), i !== e.a && (y.disabled = e.a = i), a !== e.o && (x.disabled = e.o = a), e;
104
346
  }, {
105
347
  e: void 0,
106
348
  t: void 0,
107
349
  a: void 0,
108
350
  o: void 0
109
- }), i(() => o.value = s()), i(() => h.value = l()), i(() => y.value = d()), t;
351
+ }), o(() => r.value = a()), o(() => g.value = l()), o(() => y.value = d()), t;
110
352
  })();
111
353
  };
112
- r(["input"]);
354
+ a(["input"]);
113
355
  //#endregion
114
356
  //#region src/components/consent-screen.tsx
115
- var w = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), T = /* @__PURE__ */ s("<div class=\"rounded-md border p-4 space-y-3\"><p class=\"text-sm font-medium\">This application is requesting the following permissions:</p><ul class=space-y-2>"), E = /* @__PURE__ */ s("<div class=\"mx-auto max-w-md space-y-6 p-6\"><div class=\"space-y-2 text-center\"><h2 class=\"text-2xl font-semibold tracking-tight\">Authorize </h2><p class=\"text-sm text-muted-foreground\"><strong></strong> is requesting access to your account.</p></div><div class=\"flex gap-3\"><button class=\"inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>Deny</button><button class=\"inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button></button></div><p class=\"text-center text-xs text-muted-foreground\">By authorizing, you allow this application to access your account with the permissions listed above."), D = /* @__PURE__ */ s("<li class=\"flex items-center gap-2 text-sm\"><svg class=\"h-4 w-4 text-primary\"fill=none stroke=currentColor viewBox=\"0 0 24 24\"aria-label=Checkmark role=img><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\"></path></svg><span>"), O = (t) => {
116
- let [r, s] = p(!1), [l, u] = p(null), d = async (e) => {
117
- u(null), s(!0);
357
+ var X = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), re = /* @__PURE__ */ u("<div class=\"rounded-md border p-4 space-y-3\"><p class=\"text-sm font-medium\">This application is requesting the following permissions:</p><ul class=space-y-2>"), ie = /* @__PURE__ */ u("<div class=\"mx-auto max-w-md space-y-6 p-6\"><div class=\"space-y-2 text-center\"><h2 class=\"text-2xl font-semibold tracking-tight\">Authorize </h2><p class=\"text-sm text-muted-foreground\"><strong></strong> is requesting access to your account.</p></div><div class=\"flex gap-3\"><button class=\"inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>Deny</button><button class=\"inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button></button></div><p class=\"text-center text-xs text-muted-foreground\">By authorizing, you allow this application to access your account with the permissions listed above."), ae = /* @__PURE__ */ u("<li class=\"flex items-center gap-2 text-sm\"><svg class=\"h-4 w-4 text-primary\"fill=none stroke=currentColor viewBox=\"0 0 24 24\"aria-label=Checkmark role=img><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\"></path></svg><span>"), oe = (t) => {
358
+ let [n, r] = v(!1), [a, l] = v(null), u = async (e) => {
359
+ l(null), r(!0);
118
360
  try {
119
361
  let n = t.authBaseUrl ?? "/api/auth", r = await fetch(`${n}/authorize`, {
120
362
  method: "POST",
@@ -147,116 +389,623 @@ var w = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 t
147
389
  t.onSubmit?.(e);
148
390
  } catch (e) {
149
391
  let n = e instanceof Error ? e : Error(String(e));
150
- u(n.message), t.onError?.(n);
392
+ l(n.message), t.onError?.(n);
151
393
  } finally {
152
- s(!1);
394
+ r(!1);
153
395
  }
154
- }, f = () => t.clientName ?? t.clientId;
396
+ }, d = () => t.clientName ?? t.clientId;
155
397
  return (() => {
156
- var s = E(), u = s.firstChild, p = u.firstChild;
398
+ var r = ie(), l = r.firstChild, p = l.firstChild;
157
399
  p.firstChild;
158
- var m = p.nextSibling.firstChild, h = u.nextSibling, g = h.firstChild, _ = g.nextSibling;
159
- return a(p, f, null), a(m, f), a(s, n(e, {
400
+ var m = p.nextSibling.firstChild, h = l.nextSibling, g = h.firstChild, _ = g.nextSibling;
401
+ return s(p, d, null), s(m, d), s(r, i(e, {
160
402
  get when() {
161
- return l();
403
+ return a();
162
404
  },
163
405
  get children() {
164
- var e = w();
165
- return a(e, l), e;
406
+ var e = X();
407
+ return s(e, a), e;
166
408
  }
167
- }), h), a(s, n(e, {
409
+ }), h), s(r, i(e, {
168
410
  get when() {
169
- return o(() => !!t.scopes)() && t.scopes.length > 0;
411
+ return c(() => !!t.scopes)() && t.scopes.length > 0;
170
412
  },
171
413
  get children() {
172
- var e = T(), r = e.firstChild.nextSibling;
173
- return a(r, n(c, {
414
+ var e = re(), n = e.firstChild.nextSibling;
415
+ return s(n, i(f, {
174
416
  get each() {
175
417
  return t.scopes;
176
418
  },
177
419
  children: (e) => (() => {
178
- var t = D(), n = t.firstChild.nextSibling;
179
- return a(n, e), t;
420
+ var t = ae(), n = t.firstChild.nextSibling;
421
+ return s(n, e), t;
180
422
  })()
181
423
  })), e;
182
424
  }
183
- }), h), g.$$click = () => d(!1), _.$$click = () => d(!0), a(_, () => r() ? "Authorizing..." : "Authorize"), i((e) => {
184
- var t = r(), n = r();
185
- return t !== e.e && (g.disabled = e.e = t), n !== e.t && (_.disabled = e.t = n), e;
425
+ }), h), g.$$click = () => u(!1), _.$$click = () => u(!0), s(_, () => n() ? "Authorizing..." : "Authorize"), o((e) => {
426
+ var t = n(), r = n();
427
+ return t !== e.e && (g.disabled = e.e = t), r !== e.t && (_.disabled = e.t = r), e;
186
428
  }, {
187
429
  e: void 0,
188
430
  t: void 0
189
- }), s;
431
+ }), r;
190
432
  })();
191
433
  };
192
- r(["click"]);
434
+ a(["click"]);
435
+ //#endregion
436
+ //#region src/hooks/create-organizations.ts
437
+ function Z(e) {
438
+ return e.toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 64);
439
+ }
440
+ function Q() {
441
+ let { client: e } = K(), [t, n] = v([]), [r, i] = v(!1), [a, o] = v(null), s = async () => {
442
+ if (!e?.organizations) {
443
+ o("Organizations feature is not enabled on this server.");
444
+ return;
445
+ }
446
+ i(!0), o(null);
447
+ try {
448
+ n(await e.organizations.list());
449
+ } catch (e) {
450
+ o(e instanceof Error ? e.message : String(e));
451
+ } finally {
452
+ i(!1);
453
+ }
454
+ };
455
+ return s(), {
456
+ organizations: t,
457
+ loading: r,
458
+ error: a,
459
+ refetch: s,
460
+ create: async (r) => {
461
+ if (!e?.organizations) return o("Organizations feature is not enabled on this server."), null;
462
+ o(null);
463
+ try {
464
+ let i = await e.organizations.create(r);
465
+ return n([...t(), i]), i;
466
+ } catch (e) {
467
+ return o(e instanceof Error ? e.message : String(e)), null;
468
+ }
469
+ },
470
+ remove: async (r) => {
471
+ if (!e?.organizations) return o("Organizations feature is not enabled on this server."), !1;
472
+ o(null);
473
+ try {
474
+ return await e.organizations.delete(r), n(t().filter((e) => e.id !== r)), !0;
475
+ } catch (e) {
476
+ return o(e instanceof Error ? e.message : String(e)), !1;
477
+ }
478
+ }
479
+ };
480
+ }
481
+ function se(e) {
482
+ let { client: t } = K(), [n, r] = v(null), [i, a] = v(!1), [o, s] = v(null), c = async () => {
483
+ let n = e();
484
+ if (!n) {
485
+ r(null);
486
+ return;
487
+ }
488
+ if (!t?.organizations) {
489
+ s("Organizations feature is not enabled on this server.");
490
+ return;
491
+ }
492
+ a(!0), s(null);
493
+ try {
494
+ r(await t.organizations.get(n));
495
+ } catch (e) {
496
+ s(e instanceof Error ? e.message : String(e)), r(null);
497
+ } finally {
498
+ a(!1);
499
+ }
500
+ };
501
+ return c(), {
502
+ organization: n,
503
+ loading: i,
504
+ error: o,
505
+ refetch: c,
506
+ update: async (n) => {
507
+ let i = e();
508
+ if (!i || !t?.organizations) return null;
509
+ s(null);
510
+ try {
511
+ let e = await t.organizations.update(i, n);
512
+ return r(e), e;
513
+ } catch (e) {
514
+ return s(e instanceof Error ? e.message : String(e)), null;
515
+ }
516
+ }
517
+ };
518
+ }
519
+ function ce(e) {
520
+ let { client: t } = K(), [n, r] = v([]), [i, a] = v(!1), [o, s] = v(null), c = async () => {
521
+ let n = e();
522
+ if (!n) {
523
+ r([]);
524
+ return;
525
+ }
526
+ if (!t?.organizations) {
527
+ s("Organizations feature is not enabled on this server.");
528
+ return;
529
+ }
530
+ a(!0), s(null);
531
+ try {
532
+ r(await t.organizations.listMembers(n));
533
+ } catch (e) {
534
+ s(e instanceof Error ? e.message : String(e));
535
+ } finally {
536
+ a(!1);
537
+ }
538
+ };
539
+ return c(), {
540
+ members: n,
541
+ loading: i,
542
+ error: o,
543
+ refetch: c,
544
+ invite: async (n) => {
545
+ let r = e();
546
+ if (!r || !t?.organizations) return null;
547
+ s(null);
548
+ try {
549
+ return await t.organizations.createInvitation(r, n);
550
+ } catch (e) {
551
+ return s(e instanceof Error ? e.message : String(e)), null;
552
+ }
553
+ }
554
+ };
555
+ }
556
+ function le() {
557
+ let { client: e } = K(), [t, n] = v(!1), [r, i] = v(null);
558
+ return {
559
+ submitting: t,
560
+ error: r,
561
+ accept: async (t) => {
562
+ if (!e?.organizations) return i("Organizations feature is not enabled on this server."), null;
563
+ if (!t.trim()) return i("Invitation token is required."), null;
564
+ n(!0), i(null);
565
+ try {
566
+ return await e.organizations.acceptInvitation({ token: t });
567
+ } catch (e) {
568
+ return i(e instanceof Error ? e.message : String(e)), null;
569
+ } finally {
570
+ n(!1);
571
+ }
572
+ }
573
+ };
574
+ }
575
+ var $ = {
576
+ OWNER: "owner",
577
+ ADMIN: "admin",
578
+ BILLING_ADMIN: "billing_admin",
579
+ MEMBER: "member",
580
+ VIEWER: "viewer"
581
+ };
582
+ function ue(e) {
583
+ let { client: t } = K(), [n, r] = v(null), [i, a] = v(!1), [o, s] = v(null), c = async () => {
584
+ let n = e();
585
+ if (!n) {
586
+ r(null);
587
+ return;
588
+ }
589
+ if (!t?.organizations) {
590
+ s("Organizations feature is not enabled on this server.");
591
+ return;
592
+ }
593
+ a(!0), s(null);
594
+ try {
595
+ r(await t.organizations.listPermissions(n));
596
+ } catch (e) {
597
+ s(e instanceof Error ? e.message : String(e));
598
+ } finally {
599
+ a(!1);
600
+ }
601
+ };
602
+ return h(() => {
603
+ e(), c();
604
+ }), {
605
+ permissions: n,
606
+ loading: i,
607
+ error: o,
608
+ refetch: c,
609
+ hasPermission: (e) => n()?.permissions.includes(e) ?? !1,
610
+ isRole: (e) => n()?.role === e
611
+ };
612
+ }
613
+ function de(e) {
614
+ let { client: t } = K(), [n, r] = v(!1), [i, a] = v(null);
615
+ return {
616
+ submitting: n,
617
+ error: i,
618
+ changeRole: async (n, i) => {
619
+ let o = e();
620
+ if (!o || !t?.organizations) return null;
621
+ r(!0), a(null);
622
+ try {
623
+ return await t.organizations.changeRole(o, n, i);
624
+ } catch (e) {
625
+ return a(e instanceof Error ? e.message : String(e)), null;
626
+ } finally {
627
+ r(!1);
628
+ }
629
+ },
630
+ removeMember: async (n) => {
631
+ let i = e();
632
+ if (!i || !t?.organizations) return !1;
633
+ r(!0), a(null);
634
+ try {
635
+ return await t.organizations.removeMember(i, n), !0;
636
+ } catch (e) {
637
+ return a(e instanceof Error ? e.message : String(e)), !1;
638
+ } finally {
639
+ r(!1);
640
+ }
641
+ },
642
+ transferOwnership: async (n) => {
643
+ let i = e();
644
+ if (!i || !t?.organizations) return !1;
645
+ r(!0), a(null);
646
+ try {
647
+ return await t.organizations.transferOwnership(i, n), !0;
648
+ } catch (e) {
649
+ return a(e instanceof Error ? e.message : String(e)), !1;
650
+ } finally {
651
+ r(!1);
652
+ }
653
+ }
654
+ };
655
+ }
656
+ function fe(e) {
657
+ let { client: t } = K(), [n, r] = v([]), [i, a] = v(!1), [o, s] = v(!1), [c, l] = v(null), [u, d] = v(null), f = async () => {
658
+ let n = e();
659
+ if (!n) {
660
+ r([]);
661
+ return;
662
+ }
663
+ if (!t?.organizations) {
664
+ l("Organizations feature is not enabled on this server.");
665
+ return;
666
+ }
667
+ a(!0), l(null);
668
+ try {
669
+ r(await t.organizations.listDomains(n));
670
+ } catch (e) {
671
+ l(e instanceof Error ? e.message : String(e));
672
+ } finally {
673
+ a(!1);
674
+ }
675
+ };
676
+ return h(() => {
677
+ e(), f();
678
+ }), {
679
+ domains: n,
680
+ loading: i,
681
+ submitting: o,
682
+ error: c,
683
+ lastCreated: u,
684
+ refetch: f,
685
+ claim: async (n) => {
686
+ let r = e();
687
+ if (!r || !t?.organizations) return null;
688
+ s(!0), l(null);
689
+ try {
690
+ let e = await t.organizations.createDomain(r, n);
691
+ return d(e), await f(), e;
692
+ } catch (e) {
693
+ return l(e instanceof Error ? e.message : String(e)), null;
694
+ } finally {
695
+ s(!1);
696
+ }
697
+ },
698
+ verify: async (n) => {
699
+ let r = e();
700
+ if (!r || !t?.organizations) return null;
701
+ s(!0), l(null);
702
+ try {
703
+ let e = await t.organizations.verifyDomain(r, n);
704
+ return await f(), e;
705
+ } catch (e) {
706
+ return l(e instanceof Error ? e.message : String(e)), null;
707
+ } finally {
708
+ s(!1);
709
+ }
710
+ },
711
+ update: async (n, r) => {
712
+ let i = e();
713
+ if (!i || !t?.organizations) return null;
714
+ s(!0), l(null);
715
+ try {
716
+ let e = await t.organizations.updateDomain(i, n, r);
717
+ return await f(), e;
718
+ } catch (e) {
719
+ return l(e instanceof Error ? e.message : String(e)), null;
720
+ } finally {
721
+ s(!1);
722
+ }
723
+ },
724
+ remove: async (n) => {
725
+ let r = e();
726
+ if (!r || !t?.organizations) return !1;
727
+ s(!0), l(null);
728
+ try {
729
+ return await t.organizations.deleteDomain(r, n), await f(), !0;
730
+ } catch (e) {
731
+ return l(e instanceof Error ? e.message : String(e)), !1;
732
+ } finally {
733
+ s(!1);
734
+ }
735
+ }
736
+ };
737
+ }
193
738
  //#endregion
194
- //#region src/components/forgot-password-form.tsx
195
- var k = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), A = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), j = /* @__PURE__ */ s("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-forgot-password-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-forgot-password-email name=email type=email required autocomplete=email></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), M = (t) => {
196
- let { client: r } = y(), o = r?.emailPassword;
197
- if (!o) return null;
198
- let [s, c] = p(""), [l, u] = p(null), [d, f] = p(null), [m, h] = p(!1), g = async (e) => {
199
- e.preventDefault(), u(null), f(null), h(!0);
739
+ //#region src/components/domain-claim.tsx
740
+ var pe = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), me = /* @__PURE__ */ u("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-domain-input>Domain</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-domain-input name=domain type=text placeholder=acme.com required autocomplete=off></div><label class=\"flex items-center gap-2 text-sm\"><input type=checkbox>Auto-join matching users on signup</label><label class=\"flex items-center gap-2 text-sm\"><input type=checkbox>Require verified email before auto-join</label><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), he = /* @__PURE__ */ u("<div class=\"rounded-md border border-input bg-muted/40 p-3 space-y-2\"><p class=\"text-xs text-muted-foreground\">Publish the following DNS TXT record to verify ownership. The token is shown ONCE — copy it now.</p><div><span class=\"text-xs font-medium\">Record</span><code class=\"mt-1 block break-all font-mono text-xs\"></code></div><div><span class=\"text-xs font-medium\">Value</span><code class=\"mt-1 block break-all font-mono text-xs\">"), ge = (e) => /^[a-z0-9.-]+\.[a-z]{2,}$/i.test(e.trim()), _e = (e) => {
741
+ let { claim: n, lastCreated: r, error: a, submitting: c } = fe(() => e.organizationId), [l, u] = v(""), [d, f] = v(!1), [m, h] = v(!0), g = async (t) => {
742
+ t.preventDefault();
743
+ let r = l().trim().toLowerCase();
744
+ if (!ge(r)) return;
745
+ let i = await n({
746
+ domain: r,
747
+ auto_join_on_signup: d(),
748
+ require_email_verified: m()
749
+ });
750
+ i ? (u(""), e.onSuccess?.(i)) : a() && e.onError?.(Error(a()));
751
+ };
752
+ return (() => {
753
+ var e = me(), n = e.firstChild, _ = n.firstChild.nextSibling, v = n.nextSibling, y = v.firstChild, b = v.nextSibling, x = b.firstChild, S = b.nextSibling;
754
+ return t(e, "submit", g), s(e, i(p, {
755
+ get when() {
756
+ return a();
757
+ },
758
+ get children() {
759
+ var e = pe();
760
+ return s(e, a), e;
761
+ }
762
+ }), n), t(_, "input", (e) => u(e.currentTarget.value)), t(y, "change", (e) => f(e.currentTarget.checked)), t(x, "change", (e) => h(e.currentTarget.checked)), s(S, () => c() ? "Claiming…" : "Claim domain"), s(e, i(p, {
763
+ get when() {
764
+ return r();
765
+ },
766
+ children: (e) => (() => {
767
+ var t = he(), n = t.firstChild.nextSibling, r = n.firstChild.nextSibling, i = n.nextSibling.firstChild.nextSibling;
768
+ return s(r, () => e().dns_record_name), s(i, () => e().verification_token), t;
769
+ })()
770
+ }), null), o((e) => {
771
+ var t = c(), n = c(), r = c(), i = c() || !ge(l().trim());
772
+ return t !== e.e && (_.disabled = e.e = t), n !== e.t && (y.disabled = e.t = n), r !== e.a && (x.disabled = e.a = r), i !== e.o && (S.disabled = e.o = i), e;
773
+ }, {
774
+ e: void 0,
775
+ t: void 0,
776
+ a: void 0,
777
+ o: void 0
778
+ }), o(() => _.value = l()), o(() => y.checked = d()), o(() => x.checked = m()), e;
779
+ })();
780
+ }, ve = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), ye = /* @__PURE__ */ u("<p class=\"text-sm text-muted-foreground\">Loading domains…"), be = /* @__PURE__ */ u("<p class=\"text-sm text-muted-foreground\">No domains claimed yet."), xe = /* @__PURE__ */ u("<div class=space-y-3><ul class=\"divide-y divide-border\">"), Se = /* @__PURE__ */ u("<button type=button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-transparent px-3 text-xs font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50\">Verify"), Ce = /* @__PURE__ */ u("<li class=\"flex items-center justify-between gap-3 py-2\"><div class=\"min-w-0 flex-1\"><div class=\"flex items-center gap-2\"><code class=\"font-mono text-sm\"></code><span></span></div><p class=\"text-xs text-muted-foreground\">Auto-join <!> · default role </p></div><div class=\"flex gap-2\"><button type=button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-transparent px-3 text-xs font-medium text-destructive shadow-sm transition-colors hover:bg-destructive/10 disabled:pointer-events-none disabled:opacity-50\">Remove"), we = {
781
+ pending: "Pending verification",
782
+ verified: "Verified",
783
+ failed: "Verification failed"
784
+ }, Te = (e) => {
785
+ let { domains: n, loading: a, error: l, verify: u, remove: d, submitting: m } = fe(() => e.organizationId);
786
+ return (() => {
787
+ var e = xe(), h = e.firstChild;
788
+ return s(e, i(p, {
789
+ get when() {
790
+ return l();
791
+ },
792
+ get children() {
793
+ var e = ve();
794
+ return s(e, l), e;
795
+ }
796
+ }), h), s(e, i(p, {
797
+ get when() {
798
+ return a();
799
+ },
800
+ get children() {
801
+ return ye();
802
+ }
803
+ }), h), s(e, i(p, {
804
+ get when() {
805
+ return c(() => !a())() && n().length === 0;
806
+ },
807
+ get children() {
808
+ return be();
809
+ }
810
+ }), h), s(h, i(f, {
811
+ get each() {
812
+ return n();
813
+ },
814
+ children: (e) => (() => {
815
+ var n = Ce(), a = n.firstChild, c = a.firstChild, l = c.firstChild, f = l.nextSibling, h = c.nextSibling, g = h.firstChild.nextSibling;
816
+ g.nextSibling;
817
+ var _ = a.nextSibling, v = _.firstChild;
818
+ return s(l, () => e.domain), s(f, () => we[e.status] ?? e.status), s(h, () => e.auto_join_on_signup ? "on" : "off", g), s(h, () => e.default_role_on_auto_join, null), s(_, i(p, {
819
+ get when() {
820
+ return e.status !== "verified";
821
+ },
822
+ get children() {
823
+ var n = Se();
824
+ return t(n, "click", () => u(e.id)), o(() => n.disabled = m()), n;
825
+ }
826
+ }), v), t(v, "click", () => d(e.id)), o((t) => {
827
+ var n = `rounded-full px-2 py-0.5 text-xs ${e.status === "verified" ? "bg-emerald-500/10 text-emerald-700" : e.status === "failed" ? "bg-destructive/10 text-destructive" : "bg-muted text-muted-foreground"}`, i = m();
828
+ return n !== t.e && r(f, t.e = n), i !== t.t && (v.disabled = t.t = i), t;
829
+ }, {
830
+ e: void 0,
831
+ t: void 0
832
+ }), n;
833
+ })()
834
+ })), e;
835
+ })();
836
+ }, Ee = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), De = /* @__PURE__ */ u("<div class=\"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-700\">Verification did not find the expected DNS TXT record. Double-check the record name + value, then retry."), Oe = /* @__PURE__ */ u("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700\">Domain verified. JIT auto-join is now active for matching users."), ke = /* @__PURE__ */ u("<div class=space-y-3><div class=\"rounded-md border border-input bg-muted/40 p-3 space-y-2\"><p class=\"text-xs text-muted-foreground\">Publish the following DNS TXT record at your DNS provider, then click \"Run verification\". Some DNS providers can take up to 60 seconds to propagate.</p><div><span class=\"text-xs font-medium\">Record</span><code class=\"mt-1 block break-all font-mono text-xs\"></code></div><div><span class=\"text-xs font-medium\">Value</span><code class=\"mt-1 block break-all font-mono text-xs\"></code></div></div><button type=button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 disabled:pointer-events-none disabled:opacity-50\">"), Ae = (e) => {
837
+ let { verify: n, error: r, submitting: a } = fe(() => e.organizationId), [l, u] = v(null), d = async () => {
838
+ let t = await n(e.claim.domain.id);
839
+ u(t), t?.verified && e.onVerified?.(t);
840
+ };
841
+ return (() => {
842
+ var n = ke(), u = n.firstChild, f = u.firstChild.nextSibling, m = f.firstChild.nextSibling, h = f.nextSibling.firstChild.nextSibling, g = u.nextSibling;
843
+ return s(m, () => e.claim.dns_record_name), s(h, () => e.claim.verification_token), s(n, i(p, {
844
+ get when() {
845
+ return r();
846
+ },
847
+ get children() {
848
+ var e = Ee();
849
+ return s(e, r), e;
850
+ }
851
+ }), g), s(n, i(p, {
852
+ get when() {
853
+ return c(() => !!l())() && !l()?.verified;
854
+ },
855
+ get children() {
856
+ return De();
857
+ }
858
+ }), g), s(n, i(p, {
859
+ get when() {
860
+ return l()?.verified;
861
+ },
862
+ get children() {
863
+ return Oe();
864
+ }
865
+ }), g), t(g, "click", d), s(g, () => a() ? "Verifying…" : "Run verification"), o(() => g.disabled = a()), n;
866
+ })();
867
+ }, je = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Me = /* @__PURE__ */ u("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), Ne = /* @__PURE__ */ u("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-forgot-password-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-forgot-password-email name=email type=email required autocomplete=email></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Pe = (t) => {
868
+ let { client: n } = K(), r = n?.emailPassword;
869
+ if (!r) return null;
870
+ let [a, c] = v(""), [l, u] = v(null), [d, f] = v(null), [p, m] = v(!1), h = async (e) => {
871
+ e.preventDefault(), u(null), f(null), m(!0);
200
872
  try {
201
- let n = e.currentTarget, r = new FormData(n), i = await o.forgotPassword({ email: r.get("email") || s() });
202
- f(i.message), t.onSuccess?.(i.message);
873
+ let n = e.currentTarget, i = new FormData(n), o = await r.forgotPassword({ email: i.get("email") || a() });
874
+ f(o.message), t.onSuccess?.(o.message);
203
875
  } catch (e) {
204
876
  u((e instanceof Error ? e : Error(String(e))).message);
205
877
  } finally {
206
- h(!1);
878
+ m(!1);
207
879
  }
208
880
  };
209
881
  return (() => {
210
- var t = j(), r = t.firstChild, o = r.firstChild.nextSibling, u = r.nextSibling;
211
- return t.addEventListener("submit", g), a(t, n(e, {
882
+ var t = Ne(), n = t.firstChild, r = n.firstChild.nextSibling, u = n.nextSibling;
883
+ return t.addEventListener("submit", h), s(t, i(e, {
212
884
  get when() {
213
885
  return l();
214
886
  },
215
887
  get children() {
216
- var e = k();
217
- return a(e, l), e;
888
+ var e = je();
889
+ return s(e, l), e;
218
890
  }
219
- }), r), a(t, n(e, {
891
+ }), n), s(t, i(e, {
220
892
  get when() {
221
893
  return d();
222
894
  },
223
895
  get children() {
224
- var e = A();
225
- return a(e, d), e;
896
+ var e = Me();
897
+ return s(e, d), e;
226
898
  }
227
- }), r), o.$$input = (e) => c(e.currentTarget.value), a(u, () => m() ? "Sending..." : "Send reset link"), i((e) => {
228
- var t = m(), n = m();
229
- return t !== e.e && (o.disabled = e.e = t), n !== e.t && (u.disabled = e.t = n), e;
899
+ }), n), r.$$input = (e) => c(e.currentTarget.value), s(u, () => p() ? "Sending..." : "Send reset link"), o((e) => {
900
+ var t = p(), n = p();
901
+ return t !== e.e && (r.disabled = e.e = t), n !== e.t && (u.disabled = e.t = n), e;
230
902
  }, {
231
903
  e: void 0,
232
904
  t: void 0
233
- }), i(() => o.value = s()), t;
905
+ }), o(() => r.value = a()), t;
234
906
  })();
235
907
  };
236
- r(["input"]);
908
+ a(["input"]);
237
909
  //#endregion
238
- //#region src/components/passkey-button.tsx
239
- var N = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), P = /* @__PURE__ */ s("<div class=space-y-2><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), F = (t) => {
240
- let { client: r } = y(), s = r?.passkey;
241
- if (!s) return null;
242
- let [c, l] = p(null), [u, d] = p(!1), f = async () => {
243
- let e = await s.loginBegin({ email: t.email ?? void 0 }), n = await h({ optionsJSON: e.options.publicKey });
244
- await s.loginFinish({
910
+ //#region src/components/invitation-accept.tsx
911
+ var Fe = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), Ie = /* @__PURE__ */ u("<div class=\"rounded-md bg-primary/10 px-3 py-2 text-sm\"role=status aria-live=polite>Invitation accepted. Welcome to the organization!"), Le = /* @__PURE__ */ u("<div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-invitation-accept-token>Invitation token</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 font-mono text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-invitation-accept-token name=token type=text required autocomplete=off>"), Re = /* @__PURE__ */ u("<button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), ze = /* @__PURE__ */ u("<form class=space-y-4>"), Be = (n) => {
912
+ let { accept: r, submitting: a, error: c } = le(), [l, u] = v(n.token ?? ""), [d, f] = v(null), p = async (e) => {
913
+ e.preventDefault();
914
+ let t = await r(l().trim());
915
+ t ? (f(t), n.onSuccess?.(t)) : c() && n.onError?.(Error(c()));
916
+ };
917
+ return (() => {
918
+ var n = ze();
919
+ return t(n, "submit", p), s(n, i(e, {
920
+ get when() {
921
+ return c();
922
+ },
923
+ get children() {
924
+ var e = Fe();
925
+ return s(e, c), e;
926
+ }
927
+ }), null), s(n, i(e, {
928
+ get when() {
929
+ return d();
930
+ },
931
+ get children() {
932
+ return Ie();
933
+ }
934
+ }), null), s(n, i(e, {
935
+ get when() {
936
+ return !d();
937
+ },
938
+ get children() {
939
+ return [(() => {
940
+ var e = Le(), n = e.firstChild.nextSibling;
941
+ return t(n, "input", (e) => u(e.currentTarget.value)), o(() => n.disabled = a()), o(() => n.value = l()), e;
942
+ })(), (() => {
943
+ var e = Re();
944
+ return s(e, () => a() ? "Accepting…" : "Accept invitation"), o(() => e.disabled = a() || !l().trim()), e;
945
+ })()];
946
+ }
947
+ }), null), n;
948
+ })();
949
+ }, Ve = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), He = /* @__PURE__ */ u("<div class=\"rounded-md border border-input bg-muted/40 p-3\"><p class=\"text-xs text-muted-foreground\">Invitation created. Deliver this token to the invitee — it will not be shown again.</p><code class=\"mt-2 block break-all font-mono text-xs\">"), Ue = /* @__PURE__ */ u("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-invite-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-invite-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-invite-role>Role</label><select class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-invite-role name=role><option value=member>Member</option><option value=admin>Admin</option></select></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), We = (e) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e), Ge = (n) => {
950
+ let { invite: r, error: a } = ce(() => n.organizationId), [c, l] = v(""), [u, d] = v("member"), [f, p] = v(!1), [m, h] = v(null), g = async (e) => {
951
+ e.preventDefault();
952
+ let t = c().trim();
953
+ if (!We(t)) return;
954
+ p(!0);
955
+ let i = await r({
956
+ email: t,
957
+ role: u()
958
+ });
959
+ p(!1), i ? (h(i.token), l(""), n.onSuccess?.(i)) : a() && n.onError?.(Error(a()));
960
+ };
961
+ return (() => {
962
+ var n = Ue(), r = n.firstChild, p = r.firstChild.nextSibling, h = r.nextSibling, _ = h.firstChild.nextSibling, v = h.nextSibling;
963
+ return t(n, "submit", g), s(n, i(e, {
964
+ get when() {
965
+ return a();
966
+ },
967
+ get children() {
968
+ var e = Ve();
969
+ return s(e, a), e;
970
+ }
971
+ }), r), t(p, "input", (e) => l(e.currentTarget.value)), t(_, "change", (e) => d(e.currentTarget.value)), s(v, () => f() ? "Sending…" : "Send invitation"), s(n, i(e, {
972
+ get when() {
973
+ return m();
974
+ },
975
+ get children() {
976
+ var e = He(), t = e.firstChild.nextSibling;
977
+ return s(t, m), e;
978
+ }
979
+ }), null), o((e) => {
980
+ var t = f(), n = f(), r = f() || !We(c().trim());
981
+ return t !== e.e && (p.disabled = e.e = t), n !== e.t && (_.disabled = e.t = n), r !== e.a && (v.disabled = e.a = r), e;
982
+ }, {
983
+ e: void 0,
984
+ t: void 0,
985
+ a: void 0
986
+ }), o(() => p.value = c()), o(() => _.value = u()), n;
987
+ })();
988
+ }, Ke = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), qe = /* @__PURE__ */ u("<div class=space-y-2><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), Je = (t) => {
989
+ let { client: n } = K(), r = n?.passkey;
990
+ if (!r) return null;
991
+ let [a, l] = v(null), [u, d] = v(!1), f = async () => {
992
+ let e = await r.loginBegin({ email: t.email ?? void 0 }), i = await E({ optionsJSON: e.options.publicKey });
993
+ await r.loginFinish({
245
994
  challenge_id: e.challenge_id,
246
- credential: n
995
+ credential: i
247
996
  });
248
- let i = await r.getSession();
249
- t.onSuccess?.(i.user);
250
- }, m = async () => {
251
- let e = await g({ optionsJSON: (await s.registerBegin()).publicKey });
252
- await s.registerFinish({
997
+ let a = await n.getSession();
998
+ t.onSuccess?.(a.user);
999
+ }, p = async () => {
1000
+ let e = await D({ optionsJSON: (await r.registerBegin()).publicKey });
1001
+ await r.registerFinish({
253
1002
  credential: e,
254
1003
  name: "Passkey"
255
1004
  }), t.onSuccess?.(void 0);
256
- }, _ = async () => {
1005
+ }, m = async () => {
257
1006
  l(null), d(!0);
258
1007
  try {
259
- t.mode === "login" ? await f() : await m();
1008
+ t.mode === "login" ? await f() : await p();
260
1009
  } catch (e) {
261
1010
  let n = e instanceof Error ? e : Error(String(e));
262
1011
  console.error("[yauth] Passkey error:", n), l(n.name === "NotAllowedError" ? "Passkey authentication was cancelled or not available on this device." : n.message), t.onError?.(n);
@@ -265,145 +1014,285 @@ var N = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 t
265
1014
  }
266
1015
  };
267
1016
  return (() => {
268
- var r = P(), s = r.firstChild;
269
- return a(r, n(e, {
1017
+ var n = qe(), r = n.firstChild;
1018
+ return s(n, i(e, {
270
1019
  get when() {
271
- return c();
1020
+ return a();
272
1021
  },
273
1022
  get children() {
274
- var e = N();
275
- return a(e, c), e;
1023
+ var e = Ke();
1024
+ return s(e, a), e;
276
1025
  }
277
- }), s), s.$$click = _, a(s, (() => {
278
- var e = o(() => !!u());
1026
+ }), r), r.$$click = m, s(r, (() => {
1027
+ var e = c(() => !!u());
279
1028
  return () => e() ? t.mode === "login" ? "Authenticating..." : "Registering..." : t.mode === "login" ? "Sign in with passkey" : "Register passkey";
280
- })()), i(() => s.disabled = u()), r;
1029
+ })()), o(() => r.disabled = u()), n;
281
1030
  })();
282
1031
  };
283
- r(["click"]);
1032
+ a(["click"]);
284
1033
  //#endregion
285
1034
  //#region src/components/login-form.tsx
286
- var I = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), L = /* @__PURE__ */ s("<div class=relative><div class=\"absolute inset-0 flex items-center\"style=pointer-events:none><span class=\"w-full border-t\"></span></div><div class=\"relative flex justify-center text-xs uppercase\"><span class=\"bg-background px-2 text-muted-foreground\">or"), R = /* @__PURE__ */ s("<form class=space-y-6><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-login-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-login-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-login-password>Password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-login-password name=password type=password required autocomplete=current-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), z = (r) => {
287
- let { client: o, refetch: s } = y(), c = o?.emailPassword;
1035
+ var Ye = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Xe = /* @__PURE__ */ u("<div class=relative><div class=\"absolute inset-0 flex items-center\"style=pointer-events:none><span class=\"w-full border-t\"></span></div><div class=\"relative flex justify-center text-xs uppercase\"><span class=\"bg-background px-2 text-muted-foreground\">or"), Ze = /* @__PURE__ */ u("<form class=space-y-6><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-login-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-login-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-login-password>Password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-login-password name=password type=password required autocomplete=current-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Qe = (n) => {
1036
+ let { client: r, refetch: a } = K(), c = r?.emailPassword;
288
1037
  if (!c) return null;
289
- let [l, u] = p(""), [d, f] = p(""), [m, h] = p(null), [g, _] = p(!1), v = async (e) => {
290
- e.preventDefault(), h(null), _(!0);
1038
+ let [l, u] = v(""), [d, f] = v(""), [p, m] = v(null), [h, g] = v(!1), _ = async (e) => {
1039
+ e.preventDefault(), m(null), g(!0);
291
1040
  try {
292
- let t = e.currentTarget, n = new FormData(t);
1041
+ let t = e.currentTarget, r = new FormData(t);
293
1042
  await c.login({
294
- email: n.get("email") || l(),
295
- password: n.get("password") || d()
1043
+ email: r.get("email") || l(),
1044
+ password: r.get("password") || d()
296
1045
  });
297
- let i = await s();
298
- r.onSuccess?.(i);
1046
+ let i = await a();
1047
+ n.onSuccess?.(i);
299
1048
  } catch (e) {
300
1049
  let t = e instanceof Error ? e : Error(String(e));
301
- h(t.message), r.onError?.(t);
1050
+ m(t.message), n.onError?.(t);
302
1051
  } finally {
303
- _(!1);
1052
+ g(!1);
304
1053
  }
305
1054
  };
306
1055
  return (() => {
307
- var o = R(), c = o.firstChild, p = c.firstChild.nextSibling, h = c.nextSibling, _ = h.firstChild.nextSibling, y = h.nextSibling;
308
- return t(o, "submit", v), a(o, n(e, {
1056
+ var r = Ze(), c = r.firstChild, m = c.firstChild.nextSibling, g = c.nextSibling, v = g.firstChild.nextSibling, y = g.nextSibling;
1057
+ return t(r, "submit", _), s(r, i(e, {
309
1058
  get when() {
310
- return m();
1059
+ return p();
311
1060
  },
312
1061
  get children() {
313
- var e = I();
314
- return a(e, m), e;
1062
+ var e = Ye();
1063
+ return s(e, p), e;
315
1064
  }
316
- }), c), t(p, "input", (e) => u(e.currentTarget.value)), t(_, "input", (e) => f(e.currentTarget.value)), a(y, () => g() ? "Signing in..." : "Sign in"), a(o, n(e, {
1065
+ }), c), t(m, "input", (e) => u(e.currentTarget.value)), t(v, "input", (e) => f(e.currentTarget.value)), s(y, () => h() ? "Signing in..." : "Sign in"), s(r, i(e, {
317
1066
  get when() {
318
- return r.showPasskey;
1067
+ return n.showPasskey;
319
1068
  },
320
1069
  get children() {
321
- return [L(), n(F, {
1070
+ return [Xe(), i(Je, {
322
1071
  mode: "login",
323
1072
  get email() {
324
1073
  return l();
325
1074
  },
326
1075
  onSuccess: (e) => {
327
- s(), r.onSuccess?.(e);
1076
+ a(), n.onSuccess?.(e);
328
1077
  },
329
1078
  get onError() {
330
- return r.onError;
1079
+ return n.onError;
331
1080
  }
332
1081
  })];
333
1082
  }
334
- }), null), i((e) => {
335
- var t = g(), n = g(), r = g();
336
- return t !== e.e && (p.disabled = e.e = t), n !== e.t && (_.disabled = e.t = n), r !== e.a && (y.disabled = e.a = r), e;
1083
+ }), null), o((e) => {
1084
+ var t = h(), n = h(), r = h();
1085
+ return t !== e.e && (m.disabled = e.e = t), n !== e.t && (v.disabled = e.t = n), r !== e.a && (y.disabled = e.a = r), e;
337
1086
  }, {
338
1087
  e: void 0,
339
1088
  t: void 0,
340
1089
  a: void 0
341
- }), i(() => p.value = l()), i(() => _.value = d()), o;
1090
+ }), o(() => m.value = l()), o(() => v.value = d()), r;
342
1091
  })();
343
- }, B = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), V = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), H = /* @__PURE__ */ s("<div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-magic-link-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-magic-link-email name=email type=email required autocomplete=email placeholder=you@example.com>"), U = /* @__PURE__ */ s("<button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), W = /* @__PURE__ */ s("<form class=space-y-4>"), G = (t) => {
344
- let { client: r } = y(), o = r?.magicLink;
345
- if (!o) return null;
346
- let [s, c] = p(""), [l, u] = p(null), [d, f] = p(null), [m, h] = p(!1), g = async (e) => {
347
- e.preventDefault(), u(null), f(null), h(!0);
1092
+ }, $e = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), et = /* @__PURE__ */ u("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), tt = /* @__PURE__ */ u("<div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-magic-link-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-magic-link-email name=email type=email required autocomplete=email placeholder=you@example.com>"), nt = /* @__PURE__ */ u("<button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), rt = /* @__PURE__ */ u("<form class=space-y-4>"), it = (t) => {
1093
+ let { client: n } = K(), r = n?.magicLink;
1094
+ if (!r) return null;
1095
+ let [a, c] = v(""), [l, u] = v(null), [d, f] = v(null), [p, m] = v(!1), h = async (e) => {
1096
+ e.preventDefault(), u(null), f(null), m(!0);
348
1097
  try {
349
- let n = e.currentTarget, r = new FormData(n), i = await o.send({ email: r.get("email") || s() });
350
- f(i.message), t.onSuccess?.(i.message);
1098
+ let n = e.currentTarget, i = new FormData(n), o = await r.send({ email: i.get("email") || a() });
1099
+ f(o.message), t.onSuccess?.(o.message);
351
1100
  } catch (e) {
352
1101
  u((e instanceof Error ? e : Error(String(e))).message);
353
1102
  } finally {
354
- h(!1);
1103
+ m(!1);
355
1104
  }
356
1105
  };
357
1106
  return (() => {
358
- var t = W();
359
- return t.addEventListener("submit", g), a(t, n(e, {
1107
+ var t = rt();
1108
+ return t.addEventListener("submit", h), s(t, i(e, {
360
1109
  get when() {
361
1110
  return l();
362
1111
  },
363
1112
  get children() {
364
- var e = B();
365
- return a(e, l), e;
1113
+ var e = $e();
1114
+ return s(e, l), e;
366
1115
  }
367
- }), null), a(t, n(e, {
1116
+ }), null), s(t, i(e, {
368
1117
  get when() {
369
1118
  return d();
370
1119
  },
371
1120
  get children() {
372
- var e = V();
373
- return a(e, d), e;
1121
+ var e = et();
1122
+ return s(e, d), e;
1123
+ }
1124
+ }), null), s(t, i(e, {
1125
+ get when() {
1126
+ return !d();
1127
+ },
1128
+ get children() {
1129
+ return [(() => {
1130
+ var e = tt(), t = e.firstChild.nextSibling;
1131
+ return t.$$input = (e) => c(e.currentTarget.value), o(() => t.disabled = p()), o(() => t.value = a()), e;
1132
+ })(), (() => {
1133
+ var e = nt();
1134
+ return s(e, () => p() ? "Sending..." : "Send magic link"), o(() => e.disabled = p()), e;
1135
+ })()];
1136
+ }
1137
+ }), null), t;
1138
+ })();
1139
+ };
1140
+ a(["input"]);
1141
+ //#endregion
1142
+ //#region src/components/role-selector.tsx
1143
+ var at = /* @__PURE__ */ u("<select class=\"rounded-md border border-input bg-background px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-ring\"aria-label=\"Member role\"><option>Admin</option><option>Billing admin</option><option>Member</option><option>Viewer"), ot = (e) => (() => {
1144
+ var t = at(), n = t.firstChild, r = n.nextSibling, i = r.nextSibling, a = i.nextSibling;
1145
+ return t.addEventListener("change", (t) => e.onChange(t.currentTarget.value)), o(() => t.disabled = e.disabled), o(() => n.value = $.ADMIN), o(() => r.value = $.BILLING_ADMIN), o(() => i.value = $.MEMBER), o(() => a.value = $.VIEWER), o(() => t.value = e.value), t;
1146
+ })(), st = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), ct = /* @__PURE__ */ u("<div class=\"text-sm text-muted-foreground\">Loading members…"), lt = /* @__PURE__ */ u("<th scope=col class=\"py-2 pr-4 text-right\">Actions"), ut = /* @__PURE__ */ u("<table class=\"w-full text-sm\"aria-label=\"Organization members\"><thead><tr class=\"border-b border-input text-left text-xs font-medium text-muted-foreground\"><th scope=col class=\"py-2 pr-4\">User</th><th scope=col class=\"py-2 pr-4\">Role</th><th scope=col class=\"py-2 pr-4\">Status</th><th scope=col class=\"py-2 pr-4\">Joined</th></tr></thead><tbody>"), dt = /* @__PURE__ */ u("<div class=\"rounded-md border border-dashed border-input px-4 py-6 text-center text-sm text-muted-foreground\">No members yet."), ft = /* @__PURE__ */ u("<div class=space-y-3>"), pt = /* @__PURE__ */ u("<span>"), mt = /* @__PURE__ */ u("<button type=button class=\"rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50\">Save"), ht = /* @__PURE__ */ u("<button type=button class=\"rounded-md border border-input px-2 py-1 text-xs hover:bg-secondary\">Cancel"), gt = /* @__PURE__ */ u("<td class=\"py-2 pr-4 text-right\"><div class=\"inline-flex gap-2\">"), _t = /* @__PURE__ */ u("<tr class=\"border-b border-input/40\"><td class=\"py-2 pr-4 font-mono text-xs\"></td><td class=\"py-2 pr-4\"></td><td class=\"py-2 pr-4 text-xs text-muted-foreground\"></td><td class=\"py-2 pr-4 text-xs text-muted-foreground\">"), vt = /* @__PURE__ */ u("<button type=button class=\"rounded-md border border-input px-2 py-1 text-xs hover:bg-secondary\">Change role"), yt = /* @__PURE__ */ u("<button type=button class=\"rounded-md border border-destructive/40 px-2 py-1 text-xs text-destructive hover:bg-destructive/10\">Remove"), bt = (e) => {
1147
+ if (!e) return "—";
1148
+ let t = new Date(e);
1149
+ return Number.isNaN(t.getTime()) ? "—" : t.toLocaleDateString();
1150
+ }, xt = (e) => {
1151
+ switch (e) {
1152
+ case $.OWNER: return "bg-amber-500/15 text-amber-700 dark:text-amber-300";
1153
+ case $.ADMIN: return "bg-blue-500/15 text-blue-700 dark:text-blue-300";
1154
+ case $.BILLING_ADMIN: return "bg-purple-500/15 text-purple-700 dark:text-purple-300";
1155
+ case $.MEMBER: return "bg-secondary text-secondary-foreground";
1156
+ case $.VIEWER: return "bg-muted text-muted-foreground";
1157
+ default: return "bg-secondary text-secondary-foreground";
1158
+ }
1159
+ }, St = (e) => {
1160
+ let { members: t, loading: n, error: a, refetch: l } = ce(() => e.organizationId), { hasPermission: u } = ue(() => e.organizationId), { submitting: d, error: m, changeRole: h, removeMember: g } = de(() => e.organizationId), [_, y] = v(null), [b, x] = v(""), S = (e, t) => {
1161
+ y(e), x(t);
1162
+ }, C = () => {
1163
+ y(null), x("");
1164
+ }, w = async (e) => {
1165
+ await h(e, { role: b() }) && (await l(), C());
1166
+ }, T = async (e) => {
1167
+ confirm("Remove this member from the organization?") && await g(e) && await l();
1168
+ }, E = () => u("members:change_role") || u("members:remove");
1169
+ return (() => {
1170
+ var e = ft();
1171
+ return s(e, i(p, {
1172
+ get when() {
1173
+ return a() || m();
1174
+ },
1175
+ get children() {
1176
+ var e = st();
1177
+ return s(e, () => a() || m()), e;
1178
+ }
1179
+ }), null), s(e, i(p, {
1180
+ get when() {
1181
+ return c(() => !!n())() && t().length === 0;
1182
+ },
1183
+ get children() {
1184
+ return ct();
1185
+ }
1186
+ }), null), s(e, i(p, {
1187
+ get when() {
1188
+ return t().length > 0;
1189
+ },
1190
+ get children() {
1191
+ var e = ut(), n = e.firstChild, a = n.firstChild;
1192
+ a.firstChild.nextSibling.nextSibling.nextSibling;
1193
+ var l = n.nextSibling;
1194
+ return s(a, i(p, {
1195
+ get when() {
1196
+ return E();
1197
+ },
1198
+ get children() {
1199
+ return lt();
1200
+ }
1201
+ }), null), s(l, i(f, {
1202
+ get each() {
1203
+ return t();
1204
+ },
1205
+ children: (e) => (() => {
1206
+ var t = _t(), n = t.firstChild, a = n.nextSibling, l = a.nextSibling, f = l.nextSibling;
1207
+ return s(n, () => e.user_id), s(a, i(p, {
1208
+ get when() {
1209
+ return _() !== e.user_id;
1210
+ },
1211
+ get fallback() {
1212
+ return i(ot, {
1213
+ get value() {
1214
+ return b();
1215
+ },
1216
+ get disabled() {
1217
+ return d();
1218
+ },
1219
+ onChange: x
1220
+ });
1221
+ },
1222
+ get children() {
1223
+ var t = pt();
1224
+ return s(t, () => e.role), o(() => r(t, `inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${xt(e.role)}`)), t;
1225
+ }
1226
+ })), s(l, () => e.status), s(f, () => bt(e.joined_at)), s(t, i(p, {
1227
+ get when() {
1228
+ return E();
1229
+ },
1230
+ get children() {
1231
+ var t = gt(), n = t.firstChild;
1232
+ return s(n, i(p, {
1233
+ get when() {
1234
+ return _() === e.user_id;
1235
+ },
1236
+ get fallback() {
1237
+ return [i(p, {
1238
+ get when() {
1239
+ return c(() => !!u("members:change_role"))() && e.role !== $.OWNER;
1240
+ },
1241
+ get children() {
1242
+ var t = vt();
1243
+ return t.$$click = () => S(e.user_id, e.role), t;
1244
+ }
1245
+ }), i(p, {
1246
+ get when() {
1247
+ return c(() => !!u("members:remove"))() && e.role !== $.OWNER;
1248
+ },
1249
+ get children() {
1250
+ var t = yt();
1251
+ return t.$$click = () => T(e.user_id), o(() => t.disabled = d()), t;
1252
+ }
1253
+ })];
1254
+ },
1255
+ get children() {
1256
+ return [(() => {
1257
+ var t = mt();
1258
+ return t.$$click = () => w(e.user_id), o(() => t.disabled = d()), t;
1259
+ })(), (() => {
1260
+ var e = ht();
1261
+ return e.$$click = C, o(() => e.disabled = d()), e;
1262
+ })()];
1263
+ }
1264
+ })), t;
1265
+ }
1266
+ }), null), t;
1267
+ })()
1268
+ })), e;
374
1269
  }
375
- }), null), a(t, n(e, {
1270
+ }), null), s(e, i(p, {
376
1271
  get when() {
377
- return !d();
1272
+ return c(() => !n())() && t().length === 0;
378
1273
  },
379
1274
  get children() {
380
- return [(() => {
381
- var e = H(), t = e.firstChild.nextSibling;
382
- return t.$$input = (e) => c(e.currentTarget.value), i(() => t.disabled = m()), i(() => t.value = s()), e;
383
- })(), (() => {
384
- var e = U();
385
- return a(e, () => m() ? "Sending..." : "Send magic link"), i(() => e.disabled = m()), e;
386
- })()];
1275
+ return dt();
387
1276
  }
388
- }), null), t;
1277
+ }), null), e;
389
1278
  })();
390
1279
  };
391
- r(["input"]);
1280
+ a(["click"]);
392
1281
  //#endregion
393
1282
  //#region src/components/mfa-challenge.tsx
394
- var K = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), q = /* @__PURE__ */ s("<form class=space-y-4><p class=\"text-sm text-muted-foreground\">Enter the code from your authenticator app, or use a backup code.</p><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-mfa-challenge-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-mfa-challenge-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), ee = (t) => {
395
- let { client: r } = y(), o = r?.mfa;
396
- if (!o) return null;
397
- let [s, c] = p(""), [l, u] = p(null), [d, f] = p(!1), m = async (e) => {
1283
+ var Ct = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), wt = /* @__PURE__ */ u("<form class=space-y-4><p class=\"text-sm text-muted-foreground\">Enter the code from your authenticator app, or use a backup code.</p><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-mfa-challenge-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-mfa-challenge-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Tt = (t) => {
1284
+ let { client: n } = K(), r = n?.mfa;
1285
+ if (!r) return null;
1286
+ let [a, c] = v(""), [l, u] = v(null), [d, f] = v(!1), p = async (e) => {
398
1287
  e.preventDefault(), u(null), f(!0);
399
1288
  try {
400
- let n = e.currentTarget, i = new FormData(n);
401
- await o.verify({
1289
+ let i = e.currentTarget, o = new FormData(i);
1290
+ await r.verify({
402
1291
  pending_session_id: t.pendingSessionId,
403
- code: i.get("code") || s()
1292
+ code: o.get("code") || a()
404
1293
  });
405
- let a = await r.getSession();
406
- t.onSuccess?.(a.user);
1294
+ let s = await n.getSession();
1295
+ t.onSuccess?.(s.user);
407
1296
  } catch (e) {
408
1297
  let n = e instanceof Error ? e : Error(String(e));
409
1298
  u(n.message), t.onError?.(n);
@@ -412,259 +1301,528 @@ var K = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 t
412
1301
  }
413
1302
  };
414
1303
  return (() => {
415
- var t = q(), r = t.firstChild, o = r.nextSibling, u = o.firstChild.nextSibling, f = o.nextSibling;
416
- return t.addEventListener("submit", m), a(t, n(e, {
1304
+ var t = wt(), n = t.firstChild, r = n.nextSibling, u = r.firstChild.nextSibling, f = r.nextSibling;
1305
+ return t.addEventListener("submit", p), s(t, i(e, {
417
1306
  get when() {
418
1307
  return l();
419
1308
  },
420
1309
  get children() {
421
- var e = K();
422
- return a(e, l), e;
1310
+ var e = Ct();
1311
+ return s(e, l), e;
423
1312
  }
424
- }), r), u.$$input = (e) => c(e.currentTarget.value), a(f, () => d() ? "Verifying..." : "Verify"), i((e) => {
1313
+ }), n), u.$$input = (e) => c(e.currentTarget.value), s(f, () => d() ? "Verifying..." : "Verify"), o((e) => {
425
1314
  var t = d(), n = d();
426
1315
  return t !== e.e && (u.disabled = e.e = t), n !== e.t && (f.disabled = e.t = n), e;
427
1316
  }, {
428
1317
  e: void 0,
429
1318
  t: void 0
430
- }), i(() => u.value = s()), t;
1319
+ }), o(() => u.value = a()), t;
431
1320
  })();
432
1321
  };
433
- r(["input"]);
1322
+ a(["input"]);
434
1323
  //#endregion
435
1324
  //#region src/components/mfa-setup.tsx
436
- var te = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), ne = /* @__PURE__ */ s("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Set up two-factor authentication to secure your account.</p><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), re = /* @__PURE__ */ s("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Add this account to your authenticator app using the URI below, then enter the verification code.</p><div class=space-y-1><span class=\"text-sm font-medium leading-none\">OTP Auth URI</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs\"></code></div><div class=space-y-1><span class=\"text-sm font-medium leading-none\">Manual entry key</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider\"></code></div><form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-mfa-setup-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-mfa-setup-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), J = /* @__PURE__ */ s("<div class=space-y-4><div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Two-factor authentication has been enabled. Save these backup codes in a safe place. Each code can only be used once.</div><ul class=space-y-1>"), Y = /* @__PURE__ */ s("<div class=space-y-4>"), X = /* @__PURE__ */ s("<li class=\"rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider\">"), ie = (t) => {
437
- let { client: r } = y(), o = r?.mfa;
438
- if (!o) return null;
439
- let [s, l] = p("begin"), [u, d] = p(""), [f, m] = p(""), [h, g] = p(""), [_, v] = p([]), [b, x] = p(null), [S, C] = p(!1), w = async () => {
440
- x(null), C(!0);
1325
+ var Et = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Dt = /* @__PURE__ */ u("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Set up two-factor authentication to secure your account.</p><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), Ot = /* @__PURE__ */ u("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Add this account to your authenticator app using the URI below, then enter the verification code.</p><div class=space-y-1><span class=\"text-sm font-medium leading-none\">OTP Auth URI</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs\"></code></div><div class=space-y-1><span class=\"text-sm font-medium leading-none\">Manual entry key</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider\"></code></div><form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-mfa-setup-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-mfa-setup-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), kt = /* @__PURE__ */ u("<div class=space-y-4><div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Two-factor authentication has been enabled. Save these backup codes in a safe place. Each code can only be used once.</div><ul class=space-y-1>"), At = /* @__PURE__ */ u("<div class=space-y-4>"), jt = /* @__PURE__ */ u("<li class=\"rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider\">"), Mt = (t) => {
1326
+ let { client: n } = K(), r = n?.mfa;
1327
+ if (!r) return null;
1328
+ let [a, c] = v("begin"), [l, u] = v(""), [d, p] = v(""), [m, h] = v(""), [g, _] = v([]), [y, b] = v(null), [x, S] = v(!1), C = async () => {
1329
+ b(null), S(!0);
441
1330
  try {
442
- let e = await o.setup();
443
- d(e.otpauth_url), m(e.secret), v(e.backup_codes), l("confirm");
1331
+ let e = await r.setup();
1332
+ u(e.otpauth_url), p(e.secret), _(e.backup_codes), c("confirm");
444
1333
  } catch (e) {
445
- x((e instanceof Error ? e : Error(String(e))).message);
1334
+ b((e instanceof Error ? e : Error(String(e))).message);
446
1335
  } finally {
447
- C(!1);
1336
+ S(!1);
448
1337
  }
449
- }, T = async (e) => {
450
- e.preventDefault(), x(null), C(!0);
1338
+ }, w = async (e) => {
1339
+ e.preventDefault(), b(null), S(!0);
451
1340
  try {
452
- let n = e.currentTarget, r = new FormData(n);
453
- await o.confirm({ code: r.get("code") || h() }), l("done"), t.onComplete?.(_());
1341
+ let n = e.currentTarget, i = new FormData(n);
1342
+ await r.confirm({ code: i.get("code") || m() }), c("done"), t.onComplete?.(g());
454
1343
  } catch (e) {
455
- x((e instanceof Error ? e : Error(String(e))).message);
1344
+ b((e instanceof Error ? e : Error(String(e))).message);
456
1345
  } finally {
457
- C(!1);
1346
+ S(!1);
458
1347
  }
459
1348
  };
460
1349
  return (() => {
461
- var t = Y();
462
- return a(t, n(e, {
1350
+ var t = At();
1351
+ return s(t, i(e, {
463
1352
  get when() {
464
- return b();
1353
+ return y();
465
1354
  },
466
1355
  get children() {
467
- var e = te();
468
- return a(e, b), e;
1356
+ var e = Et();
1357
+ return s(e, y), e;
469
1358
  }
470
- }), null), a(t, n(e, {
1359
+ }), null), s(t, i(e, {
471
1360
  get when() {
472
- return s() === "begin";
1361
+ return a() === "begin";
473
1362
  },
474
1363
  get children() {
475
- var e = ne(), t = e.firstChild.nextSibling;
476
- return t.$$click = w, a(t, () => S() ? "Setting up..." : "Set up 2FA"), i(() => t.disabled = S()), e;
1364
+ var e = Dt(), t = e.firstChild.nextSibling;
1365
+ return t.$$click = C, s(t, () => x() ? "Setting up..." : "Set up 2FA"), o(() => t.disabled = x()), e;
477
1366
  }
478
- }), null), a(t, n(e, {
1367
+ }), null), s(t, i(e, {
479
1368
  get when() {
480
- return s() === "confirm";
1369
+ return a() === "confirm";
481
1370
  },
482
1371
  get children() {
483
- var e = re(), t = e.firstChild.nextSibling, n = t.firstChild.nextSibling, r = t.nextSibling, o = r.firstChild.nextSibling, s = r.nextSibling, c = s.firstChild, l = c.firstChild.nextSibling, d = c.nextSibling;
484
- return a(n, u), a(o, f), s.addEventListener("submit", T), l.$$input = (e) => g(e.currentTarget.value), a(d, () => S() ? "Verifying..." : "Verify and enable"), i((e) => {
485
- var t = S(), n = S();
486
- return t !== e.e && (l.disabled = e.e = t), n !== e.t && (d.disabled = e.t = n), e;
1372
+ var e = Ot(), t = e.firstChild.nextSibling, n = t.firstChild.nextSibling, r = t.nextSibling, i = r.firstChild.nextSibling, a = r.nextSibling, c = a.firstChild, u = c.firstChild.nextSibling, f = c.nextSibling;
1373
+ return s(n, l), s(i, d), a.addEventListener("submit", w), u.$$input = (e) => h(e.currentTarget.value), s(f, () => x() ? "Verifying..." : "Verify and enable"), o((e) => {
1374
+ var t = x(), n = x();
1375
+ return t !== e.e && (u.disabled = e.e = t), n !== e.t && (f.disabled = e.t = n), e;
487
1376
  }, {
488
1377
  e: void 0,
489
1378
  t: void 0
490
- }), i(() => l.value = h()), e;
1379
+ }), o(() => u.value = m()), e;
491
1380
  }
492
- }), null), a(t, n(e, {
1381
+ }), null), s(t, i(e, {
493
1382
  get when() {
494
- return s() === "done";
1383
+ return a() === "done";
495
1384
  },
496
1385
  get children() {
497
- var e = J(), t = e.firstChild.nextSibling;
498
- return a(t, n(c, {
1386
+ var e = kt(), t = e.firstChild.nextSibling;
1387
+ return s(t, i(f, {
499
1388
  get each() {
500
- return _();
1389
+ return g();
501
1390
  },
502
1391
  children: (e) => (() => {
503
- var t = X();
504
- return a(t, e), t;
1392
+ var t = jt();
1393
+ return s(t, e), t;
505
1394
  })()
506
1395
  })), e;
507
1396
  }
508
1397
  }), null), t;
509
1398
  })();
510
1399
  };
511
- r(["click", "input"]);
1400
+ a(["click", "input"]);
512
1401
  //#endregion
513
1402
  //#region src/components/oauth-buttons.tsx
514
- var ae = /* @__PURE__ */ s("<div class=space-y-2>"), oe = /* @__PURE__ */ s("<button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>Sign in with "), se = (e) => {
515
- let { client: t } = y(), r = t?.oauth;
516
- if (!r) return null;
517
- let i = (e) => {
518
- window.location.href = r.authorize(e);
1403
+ var Nt = /* @__PURE__ */ u("<div class=space-y-2>"), Pt = /* @__PURE__ */ u("<button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>Sign in with "), Ft = (e) => {
1404
+ let { client: t } = K(), n = t?.oauth;
1405
+ if (!n) return null;
1406
+ let r = (e) => {
1407
+ window.location.href = n.authorize(e);
519
1408
  };
520
1409
  return (() => {
521
- var t = ae();
522
- return a(t, n(c, {
1410
+ var t = Nt();
1411
+ return s(t, i(f, {
523
1412
  get each() {
524
1413
  return e.providers;
525
1414
  },
526
1415
  children: (e) => (() => {
527
- var t = oe();
528
- return t.firstChild, t.$$click = () => i(e), a(t, () => e.charAt(0).toUpperCase() + e.slice(1), null), t;
1416
+ var t = Pt();
1417
+ return t.firstChild, t.$$click = () => r(e), s(t, () => e.charAt(0).toUpperCase() + e.slice(1), null), t;
529
1418
  })()
530
1419
  })), t;
531
1420
  })();
532
1421
  };
533
- r(["click"]);
1422
+ a(["click"]);
1423
+ //#endregion
1424
+ //#region src/components/organization-card.tsx
1425
+ var It = /* @__PURE__ */ u("<span class=\"rounded-full bg-secondary px-2 py-0.5 text-xs font-medium text-secondary-foreground\">"), Lt = /* @__PURE__ */ u("<div class=\"shrink-0 text-xs text-muted-foreground\"> "), Rt = /* @__PURE__ */ u("<button class=\"flex w-full items-start justify-between gap-4 rounded-md border border-input bg-card px-4 py-3 text-left text-card-foreground shadow-sm transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"type=button><div class=\"min-w-0 flex-1\"><div class=\"flex items-center gap-2\"><span class=\"truncate text-sm font-medium\"></span></div><div class=\"mt-1 truncate text-xs text-muted-foreground\">@"), zt = (n) => (() => {
1426
+ var r = Rt(), a = r.firstChild.firstChild, o = a.firstChild, l = a.nextSibling;
1427
+ return l.firstChild, t(r, "click", () => n.onSelect?.(n.organization)), s(o, () => n.organization.display_name || n.organization.name), s(a, i(e, {
1428
+ get when() {
1429
+ return n.role;
1430
+ },
1431
+ get children() {
1432
+ var e = It();
1433
+ return s(e, () => n.role), e;
1434
+ }
1435
+ }), null), s(l, () => n.organization.slug, null), s(r, i(e, {
1436
+ get when() {
1437
+ return c(() => n.memberCount !== null)() && n.memberCount !== void 0;
1438
+ },
1439
+ get children() {
1440
+ var e = Lt(), t = e.firstChild;
1441
+ return s(e, () => n.memberCount, t), s(e, () => n.memberCount === 1 ? "member" : "members", null), e;
1442
+ }
1443
+ }), null), r;
1444
+ })(), Bt = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), Vt = /* @__PURE__ */ u("<form class=space-y-6><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-org-create-name>Organization name</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-org-create-name name=name type=text required maxlength=120 autocomplete=organization></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-org-create-slug>Slug</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 font-mono text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-org-create-slug name=slug type=text required pattern=[a-z0-9-]+ maxlength=64 aria-describedby=yauth-org-create-slug-hint><p id=yauth-org-create-slug-hint class=\"text-xs text-muted-foreground\">URL-safe identifier. Lowercase letters, numbers, and hyphens only.</p></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-org-create-display-name>Display name (optional)</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-org-create-display-name name=display_name type=text maxlength=120></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Ht = (n) => {
1445
+ let { create: r, error: a } = Q(), [c, l] = v(""), [u, d] = v(""), [f, p] = v(""), [m, g] = v(!1), [_, y] = v(!1);
1446
+ h(() => {
1447
+ let e = Z(c());
1448
+ m() || p(e);
1449
+ });
1450
+ let b = (e) => {
1451
+ g(!0), p(Z(e.currentTarget.value));
1452
+ }, x = async (e) => {
1453
+ if (e.preventDefault(), !c().trim() || !f().trim()) return;
1454
+ y(!0);
1455
+ let t = await r({
1456
+ name: c().trim(),
1457
+ slug: f().trim(),
1458
+ display_name: u().trim() || void 0
1459
+ });
1460
+ y(!1), t ? (n.onSuccess?.(t), l(""), d(""), p(""), g(!1)) : a() && n.onError?.(Error(a()));
1461
+ };
1462
+ return (() => {
1463
+ var n = Vt(), r = n.firstChild, p = r.firstChild.nextSibling, m = r.nextSibling, h = m.firstChild.nextSibling, g = m.nextSibling, v = g.firstChild.nextSibling, y = g.nextSibling;
1464
+ return t(n, "submit", x), s(n, i(e, {
1465
+ get when() {
1466
+ return a();
1467
+ },
1468
+ get children() {
1469
+ var e = Bt();
1470
+ return s(e, a), e;
1471
+ }
1472
+ }), r), t(p, "input", (e) => l(e.currentTarget.value)), t(h, "input", b), t(v, "input", (e) => d(e.currentTarget.value)), s(y, () => _() ? "Creating…" : "Create organization"), o((e) => {
1473
+ var t = _(), n = _(), r = _(), i = _() || !c().trim() || !f().trim();
1474
+ return t !== e.e && (p.disabled = e.e = t), n !== e.t && (h.disabled = e.t = n), r !== e.a && (v.disabled = e.a = r), i !== e.o && (y.disabled = e.o = i), e;
1475
+ }, {
1476
+ e: void 0,
1477
+ t: void 0,
1478
+ a: void 0,
1479
+ o: void 0
1480
+ }), o(() => p.value = c()), o(() => h.value = f()), o(() => v.value = u()), n;
1481
+ })();
1482
+ }, Ut = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), Wt = /* @__PURE__ */ u("<div class=\"text-sm text-muted-foreground\">Loading organization…"), Gt = /* @__PURE__ */ u("<section class=space-y-6>"), Kt = /* @__PURE__ */ u("<div class=space-y-2><h2 class=\"text-lg font-semibold\"></h2><p class=\"font-mono text-xs text-muted-foreground\">@"), qt = /* @__PURE__ */ u("<div class=space-y-3><h3 class=\"text-sm font-semibold uppercase tracking-wide text-muted-foreground\">Members"), Jt = /* @__PURE__ */ u("<div class=space-y-3><h3 class=\"text-sm font-semibold uppercase tracking-wide text-muted-foreground\">Invite a member"), Yt = (t) => {
1483
+ let { organization: n, loading: r, error: a } = se(() => t.organizationId);
1484
+ return (() => {
1485
+ var o = Gt();
1486
+ return s(o, i(e, {
1487
+ get when() {
1488
+ return a();
1489
+ },
1490
+ get children() {
1491
+ var e = Ut();
1492
+ return s(e, a), e;
1493
+ }
1494
+ }), null), s(o, i(e, {
1495
+ get when() {
1496
+ return c(() => !!r())() && !n();
1497
+ },
1498
+ get children() {
1499
+ return Wt();
1500
+ }
1501
+ }), null), s(o, i(e, {
1502
+ get when() {
1503
+ return n();
1504
+ },
1505
+ children: (n) => [
1506
+ (() => {
1507
+ var e = Kt(), t = e.firstChild, r = t.nextSibling;
1508
+ return r.firstChild, s(t, () => n().display_name || n().name), s(r, () => n().slug, null), e;
1509
+ })(),
1510
+ (() => {
1511
+ var e = qt();
1512
+ return e.firstChild, s(e, i(St, { get organizationId() {
1513
+ return n().id;
1514
+ } }), null), e;
1515
+ })(),
1516
+ i(e, {
1517
+ get when() {
1518
+ return t.canInvite !== !1;
1519
+ },
1520
+ get children() {
1521
+ var e = Jt();
1522
+ return e.firstChild, s(e, i(Ge, { get organizationId() {
1523
+ return n().id;
1524
+ } }), null), e;
1525
+ }
1526
+ })
1527
+ ]
1528
+ }), null), o;
1529
+ })();
1530
+ }, Xt = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert aria-live=polite>"), Zt = /* @__PURE__ */ u("<div class=\"text-sm text-muted-foreground\">Loading organizations…"), Qt = /* @__PURE__ */ u("<div class=\"rounded-md border border-dashed border-input px-4 py-6 text-center text-sm text-muted-foreground\">You're not in any organizations yet."), $t = /* @__PURE__ */ u("<ul class=space-y-2>"), en = /* @__PURE__ */ u("<div class=space-y-3>"), tn = /* @__PURE__ */ u("<li>"), nn = (t) => {
1531
+ let { organizations: n, loading: r, error: a } = Q();
1532
+ return (() => {
1533
+ var o = en();
1534
+ return s(o, i(e, {
1535
+ get when() {
1536
+ return a();
1537
+ },
1538
+ get children() {
1539
+ var e = Xt();
1540
+ return s(e, a), e;
1541
+ }
1542
+ }), null), s(o, i(e, {
1543
+ get when() {
1544
+ return c(() => !!r())() && n().length === 0;
1545
+ },
1546
+ get children() {
1547
+ return Zt();
1548
+ }
1549
+ }), null), s(o, i(e, {
1550
+ get when() {
1551
+ return c(() => !r())() && n().length === 0;
1552
+ },
1553
+ get children() {
1554
+ return Qt();
1555
+ }
1556
+ }), null), s(o, i(e, {
1557
+ get when() {
1558
+ return n().length > 0;
1559
+ },
1560
+ get children() {
1561
+ var e = $t();
1562
+ return s(e, i(f, {
1563
+ get each() {
1564
+ return n();
1565
+ },
1566
+ children: (e) => (() => {
1567
+ var n = tn();
1568
+ return s(n, i(zt, {
1569
+ organization: e,
1570
+ get onSelect() {
1571
+ return t.onSelect;
1572
+ }
1573
+ })), n;
1574
+ })()
1575
+ })), e;
1576
+ }
1577
+ }), null), o;
1578
+ })();
1579
+ };
1580
+ //#endregion
1581
+ //#region src/hooks/create-active-org.ts
1582
+ function rn() {
1583
+ let { client: e } = K(), [t, n] = v(null), [r, i] = v([]), [a, o] = v(!1), [s, c] = v(null), l = (e) => {
1584
+ n(e.active_org_id ?? null), i(e.orgs);
1585
+ }, u = async () => {
1586
+ if (!e?.organizations) {
1587
+ c("Organizations feature is not enabled on this server.");
1588
+ return;
1589
+ }
1590
+ o(!0), c(null);
1591
+ try {
1592
+ l(await e.organizations.getActiveOrg());
1593
+ } catch (e) {
1594
+ c(e instanceof Error ? e.message : String(e));
1595
+ } finally {
1596
+ o(!1);
1597
+ }
1598
+ };
1599
+ return u(), {
1600
+ activeOrgId: t,
1601
+ orgs: r,
1602
+ loading: a,
1603
+ error: s,
1604
+ refetch: u,
1605
+ switchTo: async (t) => {
1606
+ if (!e?.organizations) return c("Organizations feature is not enabled on this server."), null;
1607
+ o(!0), c(null);
1608
+ try {
1609
+ let n = { organization_id: t }, r = await e.organizations.setActiveOrg(n);
1610
+ return l(r), r.bearer_access_token ?? null;
1611
+ } catch (e) {
1612
+ return c(e instanceof Error ? e.message : String(e)), null;
1613
+ } finally {
1614
+ o(!1);
1615
+ }
1616
+ },
1617
+ clear: async () => {
1618
+ if (!e?.organizations) return c("Organizations feature is not enabled on this server."), null;
1619
+ o(!0), c(null);
1620
+ try {
1621
+ let t = await e.organizations.clearActiveOrg();
1622
+ return l(t), t.bearer_access_token ?? null;
1623
+ } catch (e) {
1624
+ return c(e instanceof Error ? e.message : String(e)), null;
1625
+ } finally {
1626
+ o(!1);
1627
+ }
1628
+ }
1629
+ };
1630
+ }
534
1631
  //#endregion
535
- //#region src/components/profile-settings.tsx
536
- var ce = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading profile..."), le = /* @__PURE__ */ s("<div class=space-y-8>"), ue = /* @__PURE__ */ s("<dt class=\"font-medium text-muted-foreground\">Display name"), de = /* @__PURE__ */ s("<dd>"), fe = /* @__PURE__ */ s("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Profile</h2><dl class=\"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm\"><dt class=\"font-medium text-muted-foreground\">Email</dt><dd></dd><dt class=\"font-medium text-muted-foreground\">Email verified</dt><dd></dd><dt class=\"font-medium text-muted-foreground\">Role</dt><dd>"), Z = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), pe = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading passkeys..."), me = /* @__PURE__ */ s("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Passkeys"), he = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading accounts..."), ge = /* @__PURE__ */ s("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Connected accounts"), _e = /* @__PURE__ */ s("<div class=\"flex gap-2\"><button class=\"inline-flex h-9 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button></button><button class=\"inline-flex h-9 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), ve = /* @__PURE__ */ s("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Add this account to your authenticator app, then enter the verification code.</p><div class=space-y-1><span class=\"text-sm font-medium leading-none\">OTP Auth URI</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs\"></code></div><div class=space-y-1><span class=\"text-sm font-medium leading-none\">Manual entry key</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider\"></code></div><form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-profile-mfa-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-profile-mfa-code name=mfa_code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), ye = /* @__PURE__ */ s("<div class=space-y-4><div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Two-factor authentication is enabled. Save these backup codes in a safe place.</div><ul class=space-y-1>"), be = /* @__PURE__ */ s("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Two-factor authentication"), Q = /* @__PURE__ */ s("<ul class=space-y-2>"), xe = /* @__PURE__ */ s("<p class=\"text-sm text-muted-foreground\">No passkeys registered."), Se = /* @__PURE__ */ s("<li class=\"flex items-center justify-between rounded-md border border-input px-3 py-2\"><div class=space-y-0.5><span class=\"text-sm font-medium\"></span><span class=\"block text-xs text-muted-foreground\">Added </span></div><button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), Ce = /* @__PURE__ */ s("<p class=\"text-sm text-muted-foreground\">No connected accounts."), we = /* @__PURE__ */ s("<li class=\"flex items-center justify-between rounded-md border border-input px-3 py-2\"><div class=space-y-0.5><span class=\"text-sm font-medium\"></span><span class=\"block text-xs text-muted-foreground\">Connected </span></div><button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), Te = /* @__PURE__ */ s("<li class=\"rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider\">"), Ee = () => {
537
- let { client: t, user: r, loading: o } = y(), s = t?.passkey, l = t?.oauth, u = t?.mfa, d = !!s, m = !!l, h = !!u, [g, { refetch: _ }] = f(async () => {
538
- if (!s) return [];
1632
+ //#region src/components/organization-switcher.tsx
1633
+ var an = /* @__PURE__ */ u("<div class=\"px-3 py-2 text-sm text-muted-foreground\">No organizations."), on = /* @__PURE__ */ u("<div class=\"absolute z-50 mt-1 max-h-64 w-full overflow-auto rounded-md border border-input bg-popover text-popover-foreground shadow-md\"role=listbox>"), sn = /* @__PURE__ */ u("<div class=\"relative inline-block w-full\"><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"type=button aria-haspopup=listbox aria-label=\"Switch organization\"><span class=truncate></span><svg class=\"h-4 w-4 shrink-0 opacity-50\"viewBox=\"0 0 24 24\"fill=none stroke=currentColor stroke-width=2 aria-hidden=true><polyline points=\"6 9 12 15 18 9\">"), cn = /* @__PURE__ */ u("<div class=\"truncate font-mono text-xs text-muted-foreground\">@"), ln = /* @__PURE__ */ u("<svg class=\"h-4 w-4 shrink-0\"viewBox=\"0 0 24 24\"fill=none stroke=currentColor stroke-width=2 aria-hidden=true><polyline points=\"20 6 9 17 4 12\">"), un = /* @__PURE__ */ u("<button class=\"flex w-full cursor-pointer items-center justify-between gap-2 px-3 py-2 text-left text-sm hover:bg-accent focus-visible:bg-accent focus-visible:outline-none\"type=button role=option><div class=\"min-w-0 flex-1\"><div class=\"truncate font-medium\">"), dn = (n) => {
1634
+ let { activeOrgId: r, orgs: a, loading: c, switchTo: u } = rn(), [p, m] = v(!1), h, g = () => n.activeId === void 0 ? r() : n.activeId, _ = () => a().find((e) => e.organization_id === g()) ?? null, b = (e) => {
1635
+ h && (h.contains(e.target) || (m(!1), document.removeEventListener("mousedown", b)));
1636
+ }, x = () => {
1637
+ let e = !p();
1638
+ m(e), e ? document.addEventListener("mousedown", b) : document.removeEventListener("mousedown", b);
1639
+ }, S = async (e) => {
1640
+ m(!1), document.removeEventListener("mousedown", b);
1641
+ let t = await u(e.organization_id);
1642
+ n.onSwitch?.(e, t);
1643
+ };
1644
+ return y(() => {
1645
+ document.removeEventListener("mousedown", b);
1646
+ }), (() => {
1647
+ var n = sn(), r = n.firstChild, u = r.firstChild, m = h;
1648
+ return typeof m == "function" ? d(m, n) : h = n, t(r, "click", x), s(u, () => _()?.display_name || _()?.slug || (c() ? "Loading…" : "Select organization")), s(n, i(e, {
1649
+ get when() {
1650
+ return p();
1651
+ },
1652
+ get children() {
1653
+ var n = on();
1654
+ return s(n, i(f, {
1655
+ get each() {
1656
+ return a();
1657
+ },
1658
+ children: (n) => (() => {
1659
+ var r = un(), a = r.firstChild, c = a.firstChild;
1660
+ return t(r, "click", () => void S(n)), s(c, () => n.display_name || n.slug || n.organization_id), s(a, i(e, {
1661
+ get when() {
1662
+ return n.slug;
1663
+ },
1664
+ get children() {
1665
+ var e = cn();
1666
+ return e.firstChild, s(e, () => n.slug, null), e;
1667
+ }
1668
+ }), null), s(r, i(e, {
1669
+ get when() {
1670
+ return n.organization_id === g();
1671
+ },
1672
+ get children() {
1673
+ return ln();
1674
+ }
1675
+ }), null), o(() => l(r, "aria-selected", n.organization_id === g())), r;
1676
+ })()
1677
+ }), null), s(n, i(e, {
1678
+ get when() {
1679
+ return a().length === 0;
1680
+ },
1681
+ get children() {
1682
+ return an();
1683
+ }
1684
+ }), null), n;
1685
+ }
1686
+ }), null), o((e) => {
1687
+ var t = p(), n = c() && a().length === 0;
1688
+ return t !== e.e && l(r, "aria-expanded", e.e = t), n !== e.t && (r.disabled = e.t = n), e;
1689
+ }, {
1690
+ e: void 0,
1691
+ t: void 0
1692
+ }), n;
1693
+ })();
1694
+ }, fn = /* @__PURE__ */ u("<div class=\"text-sm text-muted-foreground\">Loading profile..."), pn = /* @__PURE__ */ u("<div class=space-y-8>"), mn = /* @__PURE__ */ u("<dt class=\"font-medium text-muted-foreground\">Display name"), hn = /* @__PURE__ */ u("<dd>"), gn = /* @__PURE__ */ u("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Profile</h2><dl class=\"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm\"><dt class=\"font-medium text-muted-foreground\">Email</dt><dd></dd><dt class=\"font-medium text-muted-foreground\">Email verified</dt><dd></dd><dt class=\"font-medium text-muted-foreground\">Role</dt><dd>"), _n = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), vn = /* @__PURE__ */ u("<div class=\"text-sm text-muted-foreground\">Loading passkeys..."), yn = /* @__PURE__ */ u("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Passkeys"), bn = /* @__PURE__ */ u("<div class=\"text-sm text-muted-foreground\">Loading accounts..."), xn = /* @__PURE__ */ u("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Connected accounts"), Sn = /* @__PURE__ */ u("<div class=\"flex gap-2\"><button class=\"inline-flex h-9 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button></button><button class=\"inline-flex h-9 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), Cn = /* @__PURE__ */ u("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Add this account to your authenticator app, then enter the verification code.</p><div class=space-y-1><span class=\"text-sm font-medium leading-none\">OTP Auth URI</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs\"></code></div><div class=space-y-1><span class=\"text-sm font-medium leading-none\">Manual entry key</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider\"></code></div><form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-profile-mfa-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-profile-mfa-code name=mfa_code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), wn = /* @__PURE__ */ u("<div class=space-y-4><div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Two-factor authentication is enabled. Save these backup codes in a safe place.</div><ul class=space-y-1>"), Tn = /* @__PURE__ */ u("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Two-factor authentication"), En = /* @__PURE__ */ u("<ul class=space-y-2>"), Dn = /* @__PURE__ */ u("<p class=\"text-sm text-muted-foreground\">No passkeys registered."), On = /* @__PURE__ */ u("<li class=\"flex items-center justify-between rounded-md border border-input px-3 py-2\"><div class=space-y-0.5><span class=\"text-sm font-medium\"></span><span class=\"block text-xs text-muted-foreground\">Added </span></div><button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), kn = /* @__PURE__ */ u("<p class=\"text-sm text-muted-foreground\">No connected accounts."), An = /* @__PURE__ */ u("<li class=\"flex items-center justify-between rounded-md border border-input px-3 py-2\"><div class=space-y-0.5><span class=\"text-sm font-medium\"></span><span class=\"block text-xs text-muted-foreground\">Connected </span></div><button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), jn = /* @__PURE__ */ u("<li class=\"rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider\">"), Mn = () => {
1695
+ let { client: t, user: n, loading: r } = K(), a = t?.passkey, c = t?.oauth, l = t?.mfa, u = !!a, d = !!c, p = !!l, [m, { refetch: h }] = _(async () => {
1696
+ if (!a) return [];
539
1697
  try {
540
- return (await s.list()).items;
1698
+ return (await a.list()).items;
541
1699
  } catch {
542
1700
  return [];
543
1701
  }
544
- }), [v, b] = p(null), [x, S] = p(null), [C, { refetch: w }] = f(async () => {
545
- if (!l) return [];
1702
+ }), [g, y] = v(null), [b, x] = v(null), [S, { refetch: C }] = _(async () => {
1703
+ if (!c) return [];
546
1704
  try {
547
- return (await l.accounts()).items;
1705
+ return (await c.accounts()).items;
548
1706
  } catch {
549
1707
  return [];
550
1708
  }
551
- }), [T, E] = p(null), [D, O] = p(null), [k, A] = p(""), [j, M] = p(""), [N, P] = p(""), [F, I] = p([]), [L, R] = p("idle"), [z, B] = p(null), [V, H] = p(!1), U = async (e) => {
552
- b(null), S(e);
1709
+ }), [w, T] = v(null), [E, D] = v(null), [O, k] = v(""), [ee, A] = v(""), [j, te] = v(""), [M, N] = v([]), [P, F] = v("idle"), [I, L] = v(null), [R, z] = v(!1), B = async (e) => {
1710
+ y(null), x(e);
553
1711
  try {
554
- await s.delete(e), _();
1712
+ await a.delete(e), h();
555
1713
  } catch (e) {
556
- b((e instanceof Error ? e : Error(String(e))).message);
1714
+ y((e instanceof Error ? e : Error(String(e))).message);
557
1715
  } finally {
558
- S(null);
1716
+ x(null);
559
1717
  }
560
- }, W = async (e) => {
561
- E(null), O(e);
1718
+ }, V = async (e) => {
1719
+ T(null), D(e);
562
1720
  try {
563
- await l.unlink(e), w();
1721
+ await c.unlink(e), C();
564
1722
  } catch (e) {
565
- E((e instanceof Error ? e : Error(String(e))).message);
1723
+ T((e instanceof Error ? e : Error(String(e))).message);
566
1724
  } finally {
567
- O(null);
1725
+ D(null);
568
1726
  }
569
- }, G = async () => {
570
- B(null), H(!0);
1727
+ }, H = async () => {
1728
+ L(null), z(!0);
571
1729
  try {
572
- let e = await u.setup();
573
- A(e.otpauth_url), M(e.secret), I(e.backup_codes), R("confirm");
1730
+ let e = await l.setup();
1731
+ k(e.otpauth_url), A(e.secret), N(e.backup_codes), F("confirm");
574
1732
  } catch (e) {
575
- B((e instanceof Error ? e : Error(String(e))).message);
1733
+ L((e instanceof Error ? e : Error(String(e))).message);
576
1734
  } finally {
577
- H(!1);
1735
+ z(!1);
578
1736
  }
579
- }, K = async (e) => {
580
- e.preventDefault(), B(null), H(!0);
1737
+ }, U = async (e) => {
1738
+ e.preventDefault(), L(null), z(!0);
581
1739
  try {
582
1740
  let t = e.currentTarget, n = new FormData(t);
583
- await u.confirm({ code: n.get("mfa_code") || N() }), R("done");
1741
+ await l.confirm({ code: n.get("mfa_code") || j() }), F("done");
584
1742
  } catch (e) {
585
- B((e instanceof Error ? e : Error(String(e))).message);
1743
+ L((e instanceof Error ? e : Error(String(e))).message);
586
1744
  } finally {
587
- H(!1);
1745
+ z(!1);
588
1746
  }
589
- }, q = async () => {
590
- B(null), H(!0);
1747
+ }, W = async () => {
1748
+ L(null), z(!0);
591
1749
  try {
592
- await u.disable(), R("idle"), A(""), M(""), P(""), I([]);
1750
+ await l.disable(), F("idle"), k(""), A(""), te(""), N([]);
593
1751
  } catch (e) {
594
- B((e instanceof Error ? e : Error(String(e))).message);
1752
+ L((e instanceof Error ? e : Error(String(e))).message);
595
1753
  } finally {
596
- H(!1);
1754
+ z(!1);
597
1755
  }
598
1756
  };
599
1757
  return (() => {
600
- var t = le();
601
- return a(t, n(e, {
1758
+ var t = pn();
1759
+ return s(t, i(e, {
602
1760
  get when() {
603
- return o();
1761
+ return r();
604
1762
  },
605
1763
  get children() {
606
- return ce();
1764
+ return fn();
607
1765
  }
608
- }), null), a(t, n(e, {
1766
+ }), null), s(t, i(e, {
609
1767
  get when() {
610
- return r();
1768
+ return n();
611
1769
  },
612
1770
  children: (t) => [
613
1771
  (() => {
614
- var r = fe(), i = r.firstChild.nextSibling, o = i.firstChild.nextSibling, s = o.nextSibling, c = s.nextSibling, l = c.nextSibling.nextSibling;
615
- return a(o, () => t().email), a(i, n(e, {
1772
+ var n = gn(), r = n.firstChild.nextSibling, a = r.firstChild.nextSibling, o = a.nextSibling, c = o.nextSibling, l = c.nextSibling.nextSibling;
1773
+ return s(a, () => t().email), s(r, i(e, {
616
1774
  get when() {
617
1775
  return t().display_name;
618
1776
  },
619
1777
  get children() {
620
- return [ue(), (() => {
621
- var e = de();
622
- return a(e, () => t().display_name), e;
1778
+ return [mn(), (() => {
1779
+ var e = hn();
1780
+ return s(e, () => t().display_name), e;
623
1781
  })()];
624
1782
  }
625
- }), s), a(c, () => t().email_verified ? "Yes" : "No"), a(l, () => t().role), r;
1783
+ }), o), s(c, () => t().email_verified ? "Yes" : "No"), s(l, () => t().role), n;
626
1784
  })(),
627
- n(e, {
628
- when: d,
1785
+ i(e, {
1786
+ when: u,
629
1787
  get children() {
630
- var t = me();
631
- return t.firstChild, a(t, n(e, {
1788
+ var t = yn();
1789
+ return t.firstChild, s(t, i(e, {
632
1790
  get when() {
633
- return v();
1791
+ return g();
634
1792
  },
635
1793
  get children() {
636
- var e = Z();
637
- return a(e, v), e;
1794
+ var e = _n();
1795
+ return s(e, g), e;
638
1796
  }
639
- }), null), a(t, n(e, {
1797
+ }), null), s(t, i(e, {
640
1798
  get when() {
641
- return g.loading;
1799
+ return m.loading;
642
1800
  },
643
1801
  get children() {
644
- return pe();
1802
+ return vn();
645
1803
  }
646
- }), null), a(t, n(e, {
1804
+ }), null), s(t, i(e, {
647
1805
  get when() {
648
- return g();
1806
+ return m();
649
1807
  },
650
- children: (t) => n(e, {
1808
+ children: (t) => i(e, {
651
1809
  get when() {
652
1810
  return t().length > 0;
653
1811
  },
654
1812
  get fallback() {
655
- return xe();
1813
+ return Dn();
656
1814
  },
657
1815
  get children() {
658
- var e = Q();
659
- return a(e, n(c, {
1816
+ var e = En();
1817
+ return s(e, i(f, {
660
1818
  get each() {
661
1819
  return t();
662
1820
  },
663
1821
  children: (e) => (() => {
664
- var t = Se(), n = t.firstChild, r = n.firstChild, o = r.nextSibling;
665
- o.firstChild;
666
- var s = n.nextSibling;
667
- return a(r, () => e.name ?? "Unnamed passkey"), a(o, () => new Date(e.created_at).toLocaleDateString(), null), s.$$click = () => U(e.id), a(s, () => x() === e.id ? "Deleting..." : "Delete"), i(() => s.disabled = x() === e.id), t;
1822
+ var t = On(), n = t.firstChild, r = n.firstChild, i = r.nextSibling;
1823
+ i.firstChild;
1824
+ var a = n.nextSibling;
1825
+ return s(r, () => e.name ?? "Unnamed passkey"), s(i, () => new Date(e.created_at).toLocaleDateString(), null), a.$$click = () => B(e.id), s(a, () => b() === e.id ? "Deleting..." : "Delete"), o(() => a.disabled = b() === e.id), t;
668
1826
  })()
669
1827
  })), e;
670
1828
  }
@@ -672,47 +1830,47 @@ var ce = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading
672
1830
  }), null), t;
673
1831
  }
674
1832
  }),
675
- n(e, {
676
- when: m,
1833
+ i(e, {
1834
+ when: d,
677
1835
  get children() {
678
- var t = ge();
679
- return t.firstChild, a(t, n(e, {
1836
+ var t = xn();
1837
+ return t.firstChild, s(t, i(e, {
680
1838
  get when() {
681
- return T();
1839
+ return w();
682
1840
  },
683
1841
  get children() {
684
- var e = Z();
685
- return a(e, T), e;
1842
+ var e = _n();
1843
+ return s(e, w), e;
686
1844
  }
687
- }), null), a(t, n(e, {
1845
+ }), null), s(t, i(e, {
688
1846
  get when() {
689
- return C.loading;
1847
+ return S.loading;
690
1848
  },
691
1849
  get children() {
692
- return he();
1850
+ return bn();
693
1851
  }
694
- }), null), a(t, n(e, {
1852
+ }), null), s(t, i(e, {
695
1853
  get when() {
696
- return C();
1854
+ return S();
697
1855
  },
698
- children: (t) => n(e, {
1856
+ children: (t) => i(e, {
699
1857
  get when() {
700
1858
  return t().length > 0;
701
1859
  },
702
1860
  get fallback() {
703
- return Ce();
1861
+ return kn();
704
1862
  },
705
1863
  get children() {
706
- var e = Q();
707
- return a(e, n(c, {
1864
+ var e = En();
1865
+ return s(e, i(f, {
708
1866
  get each() {
709
1867
  return t();
710
1868
  },
711
1869
  children: (e) => (() => {
712
- var t = we(), n = t.firstChild, r = n.firstChild, o = r.nextSibling;
713
- o.firstChild;
714
- var s = n.nextSibling;
715
- return a(r, () => e.provider.charAt(0).toUpperCase() + e.provider.slice(1)), a(o, () => new Date(e.created_at).toLocaleDateString(), null), s.$$click = () => W(e.provider), a(s, () => D() === e.provider ? "Unlinking..." : "Unlink"), i(() => s.disabled = D() === e.provider), t;
1870
+ var t = An(), n = t.firstChild, r = n.firstChild, i = r.nextSibling;
1871
+ i.firstChild;
1872
+ var a = n.nextSibling;
1873
+ return s(r, () => e.provider.charAt(0).toUpperCase() + e.provider.slice(1)), s(i, () => new Date(e.created_at).toLocaleDateString(), null), a.$$click = () => V(e.provider), s(a, () => E() === e.provider ? "Unlinking..." : "Unlink"), o(() => a.disabled = E() === e.provider), t;
716
1874
  })()
717
1875
  })), e;
718
1876
  }
@@ -720,59 +1878,59 @@ var ce = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading
720
1878
  }), null), t;
721
1879
  }
722
1880
  }),
723
- n(e, {
724
- when: h,
1881
+ i(e, {
1882
+ when: p,
725
1883
  get children() {
726
- var t = be();
727
- return t.firstChild, a(t, n(e, {
1884
+ var t = Tn();
1885
+ return t.firstChild, s(t, i(e, {
728
1886
  get when() {
729
- return z();
1887
+ return I();
730
1888
  },
731
1889
  get children() {
732
- var e = Z();
733
- return a(e, z), e;
1890
+ var e = _n();
1891
+ return s(e, I), e;
734
1892
  }
735
- }), null), a(t, n(e, {
1893
+ }), null), s(t, i(e, {
736
1894
  get when() {
737
- return L() === "idle";
1895
+ return P() === "idle";
738
1896
  },
739
1897
  get children() {
740
- var e = _e(), t = e.firstChild, n = t.nextSibling;
741
- return t.$$click = G, a(t, () => V() ? "Setting up..." : "Set up 2FA"), n.$$click = q, a(n, () => V() ? "Disabling..." : "Disable 2FA"), i((e) => {
742
- var r = V(), i = V();
1898
+ var e = Sn(), t = e.firstChild, n = t.nextSibling;
1899
+ return t.$$click = H, s(t, () => R() ? "Setting up..." : "Set up 2FA"), n.$$click = W, s(n, () => R() ? "Disabling..." : "Disable 2FA"), o((e) => {
1900
+ var r = R(), i = R();
743
1901
  return r !== e.e && (t.disabled = e.e = r), i !== e.t && (n.disabled = e.t = i), e;
744
1902
  }, {
745
1903
  e: void 0,
746
1904
  t: void 0
747
1905
  }), e;
748
1906
  }
749
- }), null), a(t, n(e, {
1907
+ }), null), s(t, i(e, {
750
1908
  get when() {
751
- return L() === "confirm";
1909
+ return P() === "confirm";
752
1910
  },
753
1911
  get children() {
754
- var e = ve(), t = e.firstChild.nextSibling, n = t.firstChild.nextSibling, r = t.nextSibling, o = r.firstChild.nextSibling, s = r.nextSibling, c = s.firstChild, l = c.firstChild.nextSibling, u = c.nextSibling;
755
- return a(n, k), a(o, j), s.addEventListener("submit", K), l.$$input = (e) => P(e.currentTarget.value), a(u, () => V() ? "Verifying..." : "Verify and enable"), i((e) => {
756
- var t = V(), n = V();
1912
+ var e = Cn(), t = e.firstChild.nextSibling, n = t.firstChild.nextSibling, r = t.nextSibling, i = r.firstChild.nextSibling, a = r.nextSibling, c = a.firstChild, l = c.firstChild.nextSibling, u = c.nextSibling;
1913
+ return s(n, O), s(i, ee), a.addEventListener("submit", U), l.$$input = (e) => te(e.currentTarget.value), s(u, () => R() ? "Verifying..." : "Verify and enable"), o((e) => {
1914
+ var t = R(), n = R();
757
1915
  return t !== e.e && (l.disabled = e.e = t), n !== e.t && (u.disabled = e.t = n), e;
758
1916
  }, {
759
1917
  e: void 0,
760
1918
  t: void 0
761
- }), i(() => l.value = N()), e;
1919
+ }), o(() => l.value = j()), e;
762
1920
  }
763
- }), null), a(t, n(e, {
1921
+ }), null), s(t, i(e, {
764
1922
  get when() {
765
- return L() === "done";
1923
+ return P() === "done";
766
1924
  },
767
1925
  get children() {
768
- var e = ye(), t = e.firstChild.nextSibling;
769
- return a(t, n(c, {
1926
+ var e = wn(), t = e.firstChild.nextSibling;
1927
+ return s(t, i(f, {
770
1928
  get each() {
771
- return F();
1929
+ return M();
772
1930
  },
773
1931
  children: (e) => (() => {
774
- var t = Te();
775
- return a(t, e), t;
1932
+ var t = jn();
1933
+ return s(t, e), t;
776
1934
  })()
777
1935
  })), e;
778
1936
  }
@@ -783,137 +1941,565 @@ var ce = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading
783
1941
  }), null), t;
784
1942
  })();
785
1943
  };
786
- r(["click", "input"]);
1944
+ a(["click", "input"]);
787
1945
  //#endregion
788
1946
  //#region src/components/register-form.tsx
789
- var De = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), $ = /* @__PURE__ */ s("<form class=space-y-6><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-password>Password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-password name=password type=password required autocomplete=new-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-display-name>Display name (optional)</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-display-name name=display_name type=text autocomplete=name></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Oe = (t) => {
790
- let { client: r } = y(), o = r?.emailPassword;
791
- if (!o) return null;
792
- let [s, c] = p(""), [l, u] = p(""), [d, f] = p(""), [m, h] = p(null), [g, _] = p(!1), v = async (e) => {
793
- e.preventDefault(), h(null), _(!0);
1947
+ var Nn = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Pn = /* @__PURE__ */ u("<form class=space-y-6><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-password>Password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-password name=password type=password required autocomplete=new-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-display-name>Display name (optional)</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-display-name name=display_name type=text autocomplete=name></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Fn = (t) => {
1948
+ let { client: n } = K(), r = n?.emailPassword;
1949
+ if (!r) return null;
1950
+ let [a, c] = v(""), [l, u] = v(""), [d, f] = v(""), [p, m] = v(null), [h, g] = v(!1), _ = async (e) => {
1951
+ e.preventDefault(), m(null), g(!0);
794
1952
  try {
795
- let n = e.currentTarget, r = new FormData(n), i = r.get("display_name") || d(), a = await o.register({
796
- email: r.get("email") || s(),
797
- password: r.get("password") || l(),
798
- display_name: i || void 0
1953
+ let n = e.currentTarget, i = new FormData(n), o = i.get("display_name") || d(), s = await r.register({
1954
+ email: i.get("email") || a(),
1955
+ password: i.get("password") || l(),
1956
+ display_name: o || void 0
799
1957
  });
800
- t.onSuccess?.(a.message ?? "");
1958
+ t.onSuccess?.(s.message ?? "");
801
1959
  } catch (e) {
802
1960
  let n = e instanceof Error ? e : Error(String(e));
803
- h(n.message), t.onError?.(n);
1961
+ m(n.message), t.onError?.(n);
804
1962
  } finally {
805
- _(!1);
1963
+ g(!1);
806
1964
  }
807
1965
  };
808
1966
  return (() => {
809
- var t = $(), r = t.firstChild, o = r.firstChild.nextSibling, p = r.nextSibling, h = p.firstChild.nextSibling, _ = p.nextSibling, y = _.firstChild.nextSibling, b = _.nextSibling;
810
- return t.addEventListener("submit", v), a(t, n(e, {
1967
+ var t = Pn(), n = t.firstChild, r = n.firstChild.nextSibling, m = n.nextSibling, g = m.firstChild.nextSibling, v = m.nextSibling, y = v.firstChild.nextSibling, b = v.nextSibling;
1968
+ return t.addEventListener("submit", _), s(t, i(e, {
811
1969
  get when() {
812
- return m();
1970
+ return p();
813
1971
  },
814
1972
  get children() {
815
- var e = De();
816
- return a(e, m), e;
1973
+ var e = Nn();
1974
+ return s(e, p), e;
817
1975
  }
818
- }), r), o.$$input = (e) => c(e.currentTarget.value), h.$$input = (e) => u(e.currentTarget.value), y.$$input = (e) => f(e.currentTarget.value), a(b, () => g() ? "Creating account..." : "Create account"), i((e) => {
819
- var t = g(), n = g(), r = g(), i = g();
820
- return t !== e.e && (o.disabled = e.e = t), n !== e.t && (h.disabled = e.t = n), r !== e.a && (y.disabled = e.a = r), i !== e.o && (b.disabled = e.o = i), e;
1976
+ }), n), r.$$input = (e) => c(e.currentTarget.value), g.$$input = (e) => u(e.currentTarget.value), y.$$input = (e) => f(e.currentTarget.value), s(b, () => h() ? "Creating account..." : "Create account"), o((e) => {
1977
+ var t = h(), n = h(), i = h(), a = h();
1978
+ return t !== e.e && (r.disabled = e.e = t), n !== e.t && (g.disabled = e.t = n), i !== e.a && (y.disabled = e.a = i), a !== e.o && (b.disabled = e.o = a), e;
821
1979
  }, {
822
1980
  e: void 0,
823
1981
  t: void 0,
824
1982
  a: void 0,
825
1983
  o: void 0
826
- }), i(() => o.value = s()), i(() => h.value = l()), i(() => y.value = d()), t;
1984
+ }), o(() => r.value = a()), o(() => g.value = l()), o(() => y.value = d()), t;
827
1985
  })();
828
1986
  };
829
- r(["input"]);
1987
+ a(["input"]);
830
1988
  //#endregion
831
1989
  //#region src/components/reset-password-form.tsx
832
- var ke = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Ae = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), je = /* @__PURE__ */ s("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-reset-password-input>New password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-reset-password-input name=password type=password required autocomplete=new-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Me = (t) => {
833
- let { client: r } = y(), o = r?.emailPassword;
834
- if (!o) return null;
835
- let [s, c] = p(""), [l, u] = p(null), [d, f] = p(null), [m, h] = p(!1), g = async (e) => {
836
- e.preventDefault(), u(null), f(null), h(!0);
1990
+ var In = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Ln = /* @__PURE__ */ u("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), Rn = /* @__PURE__ */ u("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-reset-password-input>New password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-reset-password-input name=password type=password required autocomplete=new-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), zn = (t) => {
1991
+ let { client: n } = K(), r = n?.emailPassword;
1992
+ if (!r) return null;
1993
+ let [a, c] = v(""), [l, u] = v(null), [d, f] = v(null), [p, m] = v(!1), h = async (e) => {
1994
+ e.preventDefault(), u(null), f(null), m(!0);
837
1995
  try {
838
- let n = e.currentTarget, r = new FormData(n), i = await o.resetPassword({
1996
+ let n = e.currentTarget, i = new FormData(n), o = await r.resetPassword({
839
1997
  token: t.token,
840
- password: r.get("password") || s()
1998
+ password: i.get("password") || a()
841
1999
  });
842
- f(i.message), t.onSuccess?.(i.message);
2000
+ f(o.message), t.onSuccess?.(o.message);
843
2001
  } catch (e) {
844
2002
  u((e instanceof Error ? e : Error(String(e))).message);
845
2003
  } finally {
846
- h(!1);
2004
+ m(!1);
847
2005
  }
848
2006
  };
849
2007
  return (() => {
850
- var t = je(), r = t.firstChild, o = r.firstChild.nextSibling, u = r.nextSibling;
851
- return t.addEventListener("submit", g), a(t, n(e, {
2008
+ var t = Rn(), n = t.firstChild, r = n.firstChild.nextSibling, u = n.nextSibling;
2009
+ return t.addEventListener("submit", h), s(t, i(e, {
852
2010
  get when() {
853
2011
  return l();
854
2012
  },
855
2013
  get children() {
856
- var e = ke();
857
- return a(e, l), e;
2014
+ var e = In();
2015
+ return s(e, l), e;
858
2016
  }
859
- }), r), a(t, n(e, {
2017
+ }), n), s(t, i(e, {
860
2018
  get when() {
861
2019
  return d();
862
2020
  },
863
2021
  get children() {
864
- var e = Ae();
865
- return a(e, d), e;
2022
+ var e = Ln();
2023
+ return s(e, d), e;
866
2024
  }
867
- }), r), o.$$input = (e) => c(e.currentTarget.value), a(u, () => m() ? "Resetting..." : "Reset password"), i((e) => {
868
- var t = m(), n = m();
869
- return t !== e.e && (o.disabled = e.e = t), n !== e.t && (u.disabled = e.t = n), e;
2025
+ }), n), r.$$input = (e) => c(e.currentTarget.value), s(u, () => p() ? "Resetting..." : "Reset password"), o((e) => {
2026
+ var t = p(), n = p();
2027
+ return t !== e.e && (r.disabled = e.e = t), n !== e.t && (u.disabled = e.t = n), e;
870
2028
  }, {
871
2029
  e: void 0,
872
2030
  t: void 0
873
- }), i(() => o.value = s()), t;
2031
+ }), o(() => r.value = a()), t;
2032
+ })();
2033
+ };
2034
+ a(["input"]);
2035
+ //#endregion
2036
+ //#region src/hooks/create-sso-connections.ts
2037
+ function Bn(e) {
2038
+ let { client: t } = K(), [n, r] = v([]), [i, a] = v(!1), [o, s] = v(null), c = async () => {
2039
+ let n = e();
2040
+ if (!n || !t?.organizations) {
2041
+ r([]);
2042
+ return;
2043
+ }
2044
+ a(!0), s(null);
2045
+ try {
2046
+ r(await t.organizations.listSsoConnections(n));
2047
+ } catch (e) {
2048
+ s(e instanceof Error ? e.message : "failed to load connections"), r([]);
2049
+ } finally {
2050
+ a(!1);
2051
+ }
2052
+ };
2053
+ h(() => {
2054
+ e(), c();
2055
+ });
2056
+ let l = async (n) => {
2057
+ let i = e();
2058
+ if (!i || !t?.organizations) return null;
2059
+ s(null);
2060
+ try {
2061
+ let e = await t.organizations.createSsoConnection(i, n);
2062
+ return r((t) => [...t, e]), e;
2063
+ } catch (e) {
2064
+ return s(e instanceof Error ? e.message : "create failed"), null;
2065
+ }
2066
+ }, u = async (n, i) => {
2067
+ let a = e();
2068
+ if (!a || !t?.organizations) return null;
2069
+ s(null);
2070
+ try {
2071
+ let e = await t.organizations.updateSsoConnection(a, n, i);
2072
+ return r((t) => t.map((t) => t.id === e.id ? e : t)), e;
2073
+ } catch (e) {
2074
+ return s(e instanceof Error ? e.message : "update failed"), null;
2075
+ }
2076
+ };
2077
+ return {
2078
+ connections: n,
2079
+ loading: i,
2080
+ error: o,
2081
+ refetch: c,
2082
+ create: l,
2083
+ update: u,
2084
+ disable: (e) => u(e, { status: "disabled" }),
2085
+ enable: (e) => u(e, { status: "active" }),
2086
+ remove: async (n) => {
2087
+ let i = e();
2088
+ if (!i || !t?.organizations) return !1;
2089
+ s(null);
2090
+ try {
2091
+ return await t.organizations.deleteSsoConnection(i, n), r((e) => e.filter((e) => e.id !== n)), !0;
2092
+ } catch (e) {
2093
+ return s(e instanceof Error ? e.message : "delete failed"), !1;
2094
+ }
2095
+ },
2096
+ test: async (n) => {
2097
+ let r = e();
2098
+ if (!r || !t?.organizations) return null;
2099
+ s(null);
2100
+ try {
2101
+ return await t.organizations.testSsoConnection(r, n);
2102
+ } catch (e) {
2103
+ return s(e instanceof Error ? e.message : "test failed"), null;
2104
+ }
2105
+ }
2106
+ };
2107
+ }
2108
+ //#endregion
2109
+ //#region src/components/saml-connection-form.tsx
2110
+ var Vn = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert>"), Hn = /* @__PURE__ */ u("<form class=space-y-4><div class=\"grid gap-3 md:grid-cols-2\"><label class=block><span class=\"text-xs font-medium\">Name</span><input required class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"placeholder=\"Acme Okta SAML\"></label><label class=block><span class=\"text-xs font-medium\">IdP Entity ID</span><input required class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"placeholder=\"urn:idp:acme:saml or https://acme.okta.com/...\"></label><label class=\"block md:col-span-2\"><span class=\"text-xs font-medium\">IdP Single Sign-On URL</span><input required class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"placeholder=https://acme.okta.com/app/.../sso/saml></label><label class=\"block md:col-span-2\"><span class=\"text-xs font-medium\">IdP Single Logout URL (optional)</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"placeholder=https://acme.okta.com/app/.../slo/saml></label><label class=\"block md:col-span-2\"><span class=\"text-xs font-medium\">IdP X.509 Signing Certificate (PEM)</span><textarea required rows=6 class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"placeholder=\"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\"></textarea></label><label class=\"block md:col-span-2\"><span class=\"text-xs font-medium\">SP Private Key (PEM) — optional, only for SP signing or encrypted assertions</span><textarea rows=4 class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"placeholder=\"-----BEGIN PRIVATE KEY-----\"></textarea></label></div><fieldset class=\"rounded-md border p-3\"><legend class=\"px-1 text-xs font-medium\">Attribute mappings</legend><div class=\"grid gap-3 md:grid-cols-2\"><label class=block><span class=text-xs>email attribute</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"></label><label class=block><span class=text-xs>display_name attribute</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"></label><label class=block><span class=text-xs>external_id (default: NameID)</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"></label><label class=block><span class=text-xs>groups attribute</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"></label></div><div class=\"mt-3 space-y-2\"><div class=\"text-xs font-medium\">group → role</div><button type=button class=\"rounded-md border px-3 py-1 text-xs\">+ Add mapping</button></div></fieldset><fieldset class=\"rounded-md border p-3\"><legend class=\"px-1 text-xs font-medium\">Signing requirements</legend><div class=space-y-2><label class=\"flex items-center gap-2 text-xs\"><input type=checkbox>Require assertion signature (recommended)</label><label class=\"flex items-center gap-2 text-xs\"><input type=checkbox>Require response signature (recommended)</label><label class=\"flex items-center gap-2 text-xs\"><input type=checkbox>Require encrypted assertions (requires SP private key)</label><label class=\"flex items-center gap-2 text-xs\"><input type=checkbox>Allow IdP-initiated SSO (cross-tenant footgun — leave OFF unless the IdP sets <code>RelayState=cid:&lt;uuid&gt;</code>)</label></div></fieldset><div class=\"flex items-center gap-4\"><label class=\"flex items-center gap-2 text-xs\"><input type=checkbox>JIT provisioning</label><label class=\"flex items-center gap-2 text-xs\">Default role:<select class=\"rounded-md border bg-background px-2 py-1\"><option value=owner>owner</option><option value=admin>admin</option><option value=member>member</option></select></label></div><button type=submit class=\"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50\">"), Un = /* @__PURE__ */ u("<div class=\"flex items-center gap-2\"><input placeholder=\"group name\"class=\"flex-1 rounded-md border bg-background px-3 py-2 text-sm\"><select class=\"rounded-md border bg-background px-3 py-2 text-sm\"><option value=owner>owner</option><option value=admin>admin</option><option value=member>member</option></select><button type=button class=\"rounded-md border px-2 py-1 text-xs\">x");
2111
+ function Wn(e) {
2112
+ let { create: t, error: n } = Bn(() => e.organizationId), [r, a] = v(""), [c, l] = v(""), [u, d] = v(""), [m, h] = v(""), [_, y] = v(""), [b, x] = v(""), [S, C] = v("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"), [w, T] = v("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"), [E, D] = v("NameID"), [O, k] = v("http://schemas.xmlsoap.org/claims/Group"), [ee, A] = v([{
2113
+ group: "",
2114
+ role: "member"
2115
+ }]), [j, te] = v(!0), [M, N] = v(!0), [P, F] = v(!1), [I, L] = v(!1), [R, z] = v(!0), [B, V] = v("member"), [H, U] = v(!1), W = g(() => r().trim() !== "" && c().trim() !== "" && u().trim().startsWith("http") && _().includes("BEGIN CERTIFICATE")), G = (e, t) => {
2116
+ A((n) => n.map((n, r) => r === e ? {
2117
+ ...n,
2118
+ ...t
2119
+ } : n));
2120
+ }, K = async (i) => {
2121
+ if (i.preventDefault(), !W() || H()) return;
2122
+ U(!0);
2123
+ let a = {};
2124
+ for (let { group: e, role: t } of ee()) {
2125
+ let n = e.trim();
2126
+ n && (a[n] = t);
2127
+ }
2128
+ let o = await t({
2129
+ name: r().trim(),
2130
+ kind: "saml_sp",
2131
+ saml: {
2132
+ idp_entity_id: c().trim(),
2133
+ idp_sso_url: u().trim(),
2134
+ idp_slo_url: m().trim() || null,
2135
+ idp_x509_cert: _().trim(),
2136
+ sp_private_key: b().trim() || null,
2137
+ idp_initiated_sso_allowed: I(),
2138
+ assertion_signed_required: j(),
2139
+ response_signed_required: M(),
2140
+ want_encrypted_assertions: P(),
2141
+ attribute_mappings: {
2142
+ email: S().trim(),
2143
+ display_name: w().trim() || null,
2144
+ external_id: E().trim() || "NameID",
2145
+ groups: O().trim() || null,
2146
+ group_to_role: a
2147
+ }
2148
+ },
2149
+ jit_provisioning_enabled: R(),
2150
+ default_role_on_jit: B()
2151
+ });
2152
+ U(!1), o ? e.onSuccess?.(o) : n() && e.onError?.(Error(n() ?? "create failed"));
2153
+ };
2154
+ return (() => {
2155
+ var e = Hn(), t = e.firstChild, g = t.firstChild, v = g.firstChild.nextSibling, U = g.nextSibling, q = U.firstChild.nextSibling, J = U.nextSibling, ne = J.firstChild.nextSibling, Y = J.nextSibling, X = Y.firstChild.nextSibling, re = Y.nextSibling, ie = re.firstChild.nextSibling, ae = re.nextSibling.firstChild.nextSibling, oe = t.nextSibling, Z = oe.firstChild.nextSibling, Q = Z.firstChild, se = Q.firstChild.nextSibling, ce = Q.nextSibling, le = ce.firstChild.nextSibling, $ = ce.nextSibling, ue = $.firstChild.nextSibling, de = $.nextSibling.firstChild.nextSibling, fe = Z.nextSibling, pe = fe.firstChild.nextSibling, me = oe.nextSibling, he = me.firstChild.nextSibling.firstChild, ge = he.firstChild, _e = he.nextSibling, ve = _e.firstChild, ye = _e.nextSibling, be = ye.firstChild, xe = ye.nextSibling.firstChild, Se = me.nextSibling, Ce = Se.firstChild, we = Ce.firstChild, Te = Ce.nextSibling.firstChild.nextSibling, Ee = Se.nextSibling;
2156
+ return e.addEventListener("submit", K), s(e, i(p, {
2157
+ get when() {
2158
+ return n();
2159
+ },
2160
+ get children() {
2161
+ var e = Vn();
2162
+ return s(e, n), e;
2163
+ }
2164
+ }), t), v.$$input = (e) => a(e.currentTarget.value), q.$$input = (e) => l(e.currentTarget.value), ne.$$input = (e) => d(e.currentTarget.value), X.$$input = (e) => h(e.currentTarget.value), ie.$$input = (e) => y(e.currentTarget.value), ae.$$input = (e) => x(e.currentTarget.value), se.$$input = (e) => C(e.currentTarget.value), le.$$input = (e) => T(e.currentTarget.value), ue.$$input = (e) => D(e.currentTarget.value), de.$$input = (e) => k(e.currentTarget.value), s(fe, i(f, {
2165
+ get each() {
2166
+ return ee();
2167
+ },
2168
+ children: (e, t) => (() => {
2169
+ var n = Un(), r = n.firstChild, i = r.nextSibling, a = i.nextSibling;
2170
+ return r.$$input = (e) => G(t(), { group: e.currentTarget.value }), i.addEventListener("change", (e) => G(t(), { role: e.currentTarget.value })), a.$$click = () => A((e) => e.filter((e, n) => n !== t())), o(() => r.value = e.group), o(() => i.value = e.role), n;
2171
+ })()
2172
+ }), pe), pe.$$click = () => A((e) => [...e, {
2173
+ group: "",
2174
+ role: "member"
2175
+ }]), ge.addEventListener("change", (e) => te(e.currentTarget.checked)), ve.addEventListener("change", (e) => N(e.currentTarget.checked)), be.addEventListener("change", (e) => F(e.currentTarget.checked)), xe.addEventListener("change", (e) => L(e.currentTarget.checked)), we.addEventListener("change", (e) => z(e.currentTarget.checked)), Te.addEventListener("change", (e) => V(e.currentTarget.value)), s(Ee, () => H() ? "Saving..." : "Create SAML connection"), o(() => Ee.disabled = !W() || H()), o(() => v.value = r()), o(() => q.value = c()), o(() => ne.value = u()), o(() => X.value = m()), o(() => ie.value = _()), o(() => ae.value = b()), o(() => se.value = S()), o(() => le.value = w()), o(() => ue.value = E()), o(() => de.value = O()), o(() => ge.checked = j()), o(() => ve.checked = M()), o(() => be.checked = P()), o(() => xe.checked = I()), o(() => we.checked = R()), o(() => Te.value = B()), e;
2176
+ })();
2177
+ }
2178
+ a(["input", "click"]);
2179
+ //#endregion
2180
+ //#region src/components/saml-login-button.tsx
2181
+ var Gn = /* @__PURE__ */ u("<a class=\"inline-flex items-center justify-center rounded-md border bg-background px-4 py-2 text-sm font-medium hover:bg-accent\"><svg class=\"mr-2 h-4 w-4\"viewBox=\"0 0 24 24\"fill=none stroke=currentColor stroke-width=2><title>SAML</title><path d=\"M21 2H3a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zM7 17l5-5-5-5M13 17h4\">");
2182
+ function Kn(e) {
2183
+ let t = K(), n = g(() => t.client.sso.samlLoginUrl({
2184
+ org: e.orgSlug,
2185
+ domain: e.domain,
2186
+ redirectTo: e.redirectTo
2187
+ })), r = g(() => !!(e.orgSlug || e.domain));
2188
+ return i(p, {
2189
+ get when() {
2190
+ return r();
2191
+ },
2192
+ get children() {
2193
+ var t = Gn();
2194
+ return t.firstChild, s(t, () => e.label ?? "Sign in via SAML", null), o(() => l(t, "href", n())), t;
2195
+ }
2196
+ });
2197
+ }
2198
+ //#endregion
2199
+ //#region src/components/scim-settings-panel.tsx
2200
+ var qn = /* @__PURE__ */ u("<section class=space-y-6><header><h2 class=\"text-base font-semibold\">SCIM provisioning</h2><p class=\"mt-1 text-sm text-muted-foreground\">Paste the SCIM Base URL and an org-scoped API key into your IdP (Okta, Entra ID, OneLogin) so it can provision users into this organization.</p></header><div class=space-y-2><label class=\"block text-xs font-medium uppercase tracking-wider text-muted-foreground\">SCIM Base URL</label><div class=\"flex gap-2\"><code class=\"flex-1 truncate rounded-md border bg-muted px-3 py-2 text-xs\"></code><button type=button class=\"rounded-md border px-3 py-1 text-xs\"></button></div></div><div class=\"rounded-md border bg-muted/30 p-4 text-sm\"role=region aria-label=\"API key requirement\"><div class=\"mb-2 font-medium\">Authentication</div><p class=text-muted-foreground>SCIM uses an <strong>org-scoped API key</strong> with the <code>scim:read</code> and <code>scim:write</code> scopes. The IdP sends it as <code>Authorization: Bearer &lt;key&gt;</code> on every request.</p><div class=mt-3><a class=\"inline-flex items-center rounded-md bg-primary px-3 py-1 text-xs text-primary-foreground\">Manage API keys →</a></div><p class=\"mt-3 text-xs text-muted-foreground\">The plaintext key is shown <strong>only at the moment of creation</strong>. We never display it here or in the IdP-side view — only the prefix and the <code>scim:*</code> scopes.</p></div><div class=space-y-3><h3 class=\"text-sm font-medium\">Verify with curl</h3><p class=\"text-xs text-muted-foreground\">Replace <code>&lt;your-scim-key&gt;</code> with the plaintext API key you copied during key creation.</p><div class=space-y-2><label class=\"block text-xs font-medium uppercase tracking-wider text-muted-foreground\">List users</label><div class=\"flex gap-2\"><pre class=\"flex-1 overflow-x-auto rounded-md border bg-muted px-3 py-2 text-xs whitespace-pre\"></pre><button type=button class=\"rounded-md border px-3 py-1 text-xs self-start\"></button></div></div><div class=space-y-2><label class=\"block text-xs font-medium uppercase tracking-wider text-muted-foreground\">Discover capabilities</label><div class=\"flex gap-2\"><pre class=\"flex-1 overflow-x-auto rounded-md border bg-muted px-3 py-2 text-xs whitespace-pre\"></pre><button type=button class=\"rounded-md border px-3 py-1 text-xs self-start\"></button></div></div></div><div class=\"rounded-md border bg-muted/30 p-4 text-xs text-muted-foreground\"><div class=\"mb-1 font-medium text-foreground\">Per-IdP setup guides</div><ul class=\"ml-4 list-disc space-y-1\"><li><a class=underline href=/docs/scim/okta.md target=_blank>Okta</a></li><li><a class=underline href=/docs/scim/entra.md target=_blank>Microsoft Entra ID</a></li><li><a class=underline href=/docs/scim/onelogin.md target=_blank>OneLogin");
2201
+ function Jn(e) {
2202
+ let t = e.length;
2203
+ for (; t > 0 && e[t - 1] === "/";) t--;
2204
+ return e.slice(0, t);
2205
+ }
2206
+ function Yn(e) {
2207
+ let t = g(() => e.apiKeysRoute ?? `/organizations/${e.organizationId}/settings/api-keys`), n = g(() => `${Jn(e.baseUrl)}/api/scim/v2/organizations/${e.organizationId}`), r = g(() => `curl -H "Authorization: Bearer <your-scim-key>" \\
2208
+ -H "Accept: application/scim+json" \\
2209
+ "${n()}/Users?count=10"`), i = g(() => `curl -H "Authorization: Bearer <your-scim-key>" \\
2210
+ -H "Accept: application/scim+json" \\
2211
+ "${n()}/ServiceProviderConfig"`), [a, c] = v(null), u = async (e, t) => {
2212
+ try {
2213
+ await navigator.clipboard.writeText(e), c(t), setTimeout(() => {
2214
+ a() === t && c(null);
2215
+ }, 1500);
2216
+ } catch {}
2217
+ };
2218
+ return (() => {
2219
+ var e = qn(), c = e.firstChild.nextSibling, d = c.firstChild.nextSibling.firstChild, f = d.nextSibling, p = c.nextSibling, m = p.firstChild.nextSibling.nextSibling.firstChild, h = p.nextSibling.firstChild.nextSibling.nextSibling, g = h.firstChild.nextSibling.firstChild, _ = g.nextSibling, v = h.nextSibling.firstChild.nextSibling.firstChild, y = v.nextSibling;
2220
+ return s(d, n), f.$$click = () => u(n(), "url"), s(f, () => a() === "url" ? "Copied" : "Copy"), s(g, r), _.$$click = () => u(r(), "curl-list"), s(_, () => a() === "curl-list" ? "Copied" : "Copy"), s(v, i), y.$$click = () => u(i(), "curl-config"), s(y, () => a() === "curl-config" ? "Copied" : "Copy"), o(() => l(m, "href", t())), e;
2221
+ })();
2222
+ }
2223
+ a(["click"]);
2224
+ //#endregion
2225
+ //#region src/components/sso-connection-form.tsx
2226
+ var Xn = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert>"), Zn = /* @__PURE__ */ u("<form class=space-y-4><div class=\"grid gap-3 md:grid-cols-2\"><label class=block><span class=\"text-xs font-medium\">Name</span><input required class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"placeholder=\"Acme Okta\"></label><label class=block><span class=\"text-xs font-medium\">Discovery URL</span><input required class=\"mt-1 w-full rounded-md border bg-background px-3 py-2 font-mono text-xs\"placeholder=https://idp.example/.well-known/openid-configuration></label><label class=block><span class=\"text-xs font-medium\">Client ID</span><input required class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"></label><label class=block><span class=\"text-xs font-medium\">Client Secret</span><input type=password required class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"></label><label class=\"block md:col-span-2\"><span class=\"text-xs font-medium\">Scopes (comma-separated)</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"></label></div><fieldset class=\"rounded-md border p-3\"><legend class=\"px-1 text-xs font-medium\">Claim mappings</legend><div class=\"grid gap-3 md:grid-cols-2\"><label class=block><span class=text-xs>external_id</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"></label><label class=block><span class=text-xs>email</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"></label><label class=block><span class=text-xs>display_name</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"></label><label class=block><span class=text-xs>groups</span><input class=\"mt-1 w-full rounded-md border bg-background px-3 py-2\"></label></div><div class=\"mt-3 space-y-2\"><div class=\"text-xs font-medium\">group → role</div><button type=button class=\"rounded-md border px-3 py-1 text-xs\">+ Add mapping</button></div></fieldset><div class=\"flex items-center gap-4\"><label class=\"flex items-center gap-2 text-xs\"><input type=checkbox>JIT provisioning</label><label class=\"flex items-center gap-2 text-xs\">Default role:<select class=\"rounded-md border bg-background px-2 py-1\"><option value=owner>owner</option><option value=admin>admin</option><option value=member>member</option></select></label></div><button type=submit class=\"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50\">"), Qn = /* @__PURE__ */ u("<div class=\"flex items-center gap-2\"><input placeholder=\"group name\"class=\"flex-1 rounded-md border bg-background px-3 py-2 text-sm\"><select class=\"rounded-md border bg-background px-3 py-2 text-sm\"><option value=owner>owner</option><option value=admin>admin</option><option value=member>member</option></select><button type=button class=\"rounded-md border px-2 py-1 text-xs\">✕");
2227
+ function $n(e) {
2228
+ let { create: t, error: n } = Bn(() => e.organizationId), [r, a] = v(""), [c, l] = v(""), [u, d] = v(""), [m, h] = v(""), [_, y] = v("openid, email, profile"), [b, x] = v("sub"), [S, C] = v("email"), [w, T] = v("name"), [E, D] = v("groups"), [O, k] = v([{
2229
+ group: "",
2230
+ role: "member"
2231
+ }]), [ee, A] = v(!0), [j, te] = v("member"), [M, N] = v(!1), P = g(() => r().trim() !== "" && c().includes(".well-known/openid-configuration") && u().trim() !== "" && m().trim() !== ""), F = (e, t) => {
2232
+ k((n) => n.map((n, r) => r === e ? {
2233
+ ...n,
2234
+ ...t
2235
+ } : n));
2236
+ }, I = async (i) => {
2237
+ if (i.preventDefault(), !P() || M()) return;
2238
+ N(!0);
2239
+ let a = {};
2240
+ for (let { group: e, role: t } of O()) {
2241
+ let n = e.trim();
2242
+ n && (a[n] = t);
2243
+ }
2244
+ let o = await t({
2245
+ name: r().trim(),
2246
+ kind: "oidc_client",
2247
+ oidc: {
2248
+ discovery_url: c().trim(),
2249
+ client_id: u().trim(),
2250
+ client_secret: m(),
2251
+ scopes: _().split(",").map((e) => e.trim()).filter(Boolean),
2252
+ claim_mappings: {
2253
+ external_id: b().trim() || "sub",
2254
+ email: S().trim() || "email",
2255
+ display_name: w().trim() || null,
2256
+ groups: E().trim() || null,
2257
+ group_to_role: a
2258
+ }
2259
+ },
2260
+ jit_provisioning_enabled: ee(),
2261
+ default_role_on_jit: j()
2262
+ });
2263
+ N(!1), o ? e.onSuccess?.(o) : n() && e.onError?.(Error(n() ?? "create failed"));
2264
+ };
2265
+ return (() => {
2266
+ var e = Zn(), t = e.firstChild, g = t.firstChild, v = g.firstChild.nextSibling, N = g.nextSibling, L = N.firstChild.nextSibling, R = N.nextSibling, z = R.firstChild.nextSibling, B = R.nextSibling, V = B.firstChild.nextSibling, H = B.nextSibling.firstChild.nextSibling, U = t.nextSibling, W = U.firstChild.nextSibling, G = W.firstChild, K = G.firstChild.nextSibling, q = G.nextSibling, J = q.firstChild.nextSibling, ne = q.nextSibling, Y = ne.firstChild.nextSibling, X = ne.nextSibling.firstChild.nextSibling, re = W.nextSibling, ie = re.firstChild.nextSibling, ae = U.nextSibling, oe = ae.firstChild, Z = oe.firstChild, Q = oe.nextSibling.firstChild.nextSibling, se = ae.nextSibling;
2267
+ return e.addEventListener("submit", I), s(e, i(p, {
2268
+ get when() {
2269
+ return n();
2270
+ },
2271
+ get children() {
2272
+ var e = Xn();
2273
+ return s(e, n), e;
2274
+ }
2275
+ }), t), v.$$input = (e) => a(e.currentTarget.value), L.$$input = (e) => l(e.currentTarget.value), z.$$input = (e) => d(e.currentTarget.value), V.$$input = (e) => h(e.currentTarget.value), H.$$input = (e) => y(e.currentTarget.value), K.$$input = (e) => x(e.currentTarget.value), J.$$input = (e) => C(e.currentTarget.value), Y.$$input = (e) => T(e.currentTarget.value), X.$$input = (e) => D(e.currentTarget.value), s(re, i(f, {
2276
+ get each() {
2277
+ return O();
2278
+ },
2279
+ children: (e, t) => (() => {
2280
+ var n = Qn(), r = n.firstChild, i = r.nextSibling, a = i.nextSibling;
2281
+ return r.$$input = (e) => F(t(), { group: e.currentTarget.value }), i.addEventListener("change", (e) => F(t(), { role: e.currentTarget.value })), a.$$click = () => k((e) => e.filter((e, n) => n !== t())), o(() => r.value = e.group), o(() => i.value = e.role), n;
2282
+ })()
2283
+ }), ie), ie.$$click = () => k((e) => [...e, {
2284
+ group: "",
2285
+ role: "member"
2286
+ }]), Z.addEventListener("change", (e) => A(e.currentTarget.checked)), Q.addEventListener("change", (e) => te(e.currentTarget.value)), s(se, () => M() ? "Saving…" : "Create connection"), o(() => se.disabled = !P() || M()), o(() => v.value = r()), o(() => L.value = c()), o(() => z.value = u()), o(() => V.value = m()), o(() => H.value = _()), o(() => K.value = b()), o(() => J.value = S()), o(() => Y.value = w()), o(() => X.value = E()), o(() => Z.checked = ee()), o(() => Q.value = j()), e;
2287
+ })();
2288
+ }
2289
+ a(["input", "click"]);
2290
+ //#endregion
2291
+ //#region src/components/sso-connection-list.tsx
2292
+ var er = /* @__PURE__ */ u("<div class=\"text-sm text-muted-foreground\">Loading…"), tr = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert>"), nr = /* @__PURE__ */ u("<ul class=space-y-3>"), rr = /* @__PURE__ */ u("<div class=space-y-4>"), ir = /* @__PURE__ */ u("<div class=\"rounded-md border border-dashed px-4 py-6 text-center text-sm text-muted-foreground\">No SSO connections yet. Add one to enable federated sign-in for this organization."), ar = /* @__PURE__ */ u("<div class=\"mt-1 text-xs text-muted-foreground\">client_id: <code>"), or = /* @__PURE__ */ u("<a class=\"rounded-md border px-3 py-1 text-xs hover:bg-accent\"data-testid=saml-metadata-download>SP metadata"), sr = /* @__PURE__ */ u("<button type=button class=\"rounded-md border px-3 py-1 text-xs\">Disable"), cr = /* @__PURE__ */ u("<li class=\"rounded-md border bg-card p-4\"><div class=\"flex items-start justify-between gap-4\"><div><div class=font-medium></div><div class=\"text-xs text-muted-foreground\"> · <span></span></div></div><div class=\"flex flex-wrap gap-2\"><button type=button class=\"rounded-md border px-3 py-1 text-xs\">Test</button><button type=button class=\"rounded-md border border-destructive px-3 py-1 text-xs text-destructive\">Delete"), lr = /* @__PURE__ */ u("<div class=\"mt-1 space-y-1\"><div class=\"text-xs text-muted-foreground\">IdP entity: <code></code></div><div class=\"text-xs text-muted-foreground\">SP entity: <code></code></div><div class=\"text-xs text-muted-foreground\">"), ur = /* @__PURE__ */ u("<button type=button class=\"rounded-md border px-3 py-1 text-xs\">Enable"), dr = (e) => {
2293
+ let t = [];
2294
+ return e.assertion_signed_required && t.push("assertion signed"), e.response_signed_required && t.push("response signed"), e.want_encrypted_assertions && t.push("encrypted"), e.idp_initiated_sso_allowed && t.push("IdP-init allowed"), t.length > 0 ? t.join(" · ") : "no signing required";
2295
+ };
2296
+ function fr(e) {
2297
+ let { connections: t, loading: n, error: r, disable: a, enable: u, remove: d, test: m } = Bn(() => e.organizationId), h = K(), g = async (t) => {
2298
+ let n = await m(t);
2299
+ n && e.onTest?.(t, n.ok, n.detail);
2300
+ }, _ = (e) => h.client.sso.samlMetadataUrl(e);
2301
+ return (() => {
2302
+ var e = rr();
2303
+ return s(e, i(p, {
2304
+ get when() {
2305
+ return n();
2306
+ },
2307
+ get children() {
2308
+ return er();
2309
+ }
2310
+ }), null), s(e, i(p, {
2311
+ get when() {
2312
+ return r();
2313
+ },
2314
+ get children() {
2315
+ var e = tr();
2316
+ return s(e, r), e;
2317
+ }
2318
+ }), null), s(e, i(p, {
2319
+ get when() {
2320
+ return c(() => !n())() && t().length > 0;
2321
+ },
2322
+ get fallback() {
2323
+ return i(p, {
2324
+ get when() {
2325
+ return !n();
2326
+ },
2327
+ get children() {
2328
+ return ir();
2329
+ }
2330
+ });
2331
+ },
2332
+ get children() {
2333
+ var e = nr();
2334
+ return s(e, i(f, {
2335
+ get each() {
2336
+ return t();
2337
+ },
2338
+ children: (e) => (() => {
2339
+ var t = cr(), n = t.firstChild.firstChild, r = n.firstChild, c = r.nextSibling, f = c.firstChild, m = f.nextSibling, h = n.nextSibling, v = h.firstChild, y = v.nextSibling;
2340
+ return s(r, () => e.name), s(c, () => e.kind, f), s(m, () => e.status), s(n, i(p, {
2341
+ get when() {
2342
+ return e.oidc;
2343
+ },
2344
+ get children() {
2345
+ var t = ar(), n = t.firstChild.nextSibling;
2346
+ return s(n, () => e.oidc?.client_id), t;
2347
+ }
2348
+ }), null), s(n, i(p, {
2349
+ get when() {
2350
+ return e.saml;
2351
+ },
2352
+ children: (e) => (() => {
2353
+ var t = lr(), n = t.firstChild, r = n.firstChild.nextSibling, i = n.nextSibling, a = i.firstChild.nextSibling, o = i.nextSibling;
2354
+ return s(r, () => e().idp_entity_id), s(a, () => e().sp_entity_id), s(o, () => dr(e())), t;
2355
+ })()
2356
+ }), null), s(h, i(p, {
2357
+ get when() {
2358
+ return e.saml;
2359
+ },
2360
+ get children() {
2361
+ var t = or();
2362
+ return o((n) => {
2363
+ var r = _(e.id), i = `sp-metadata-${e.id}.xml`;
2364
+ return r !== n.e && l(t, "href", n.e = r), i !== n.t && l(t, "download", n.t = i), n;
2365
+ }, {
2366
+ e: void 0,
2367
+ t: void 0
2368
+ }), t;
2369
+ }
2370
+ }), v), v.$$click = () => g(e.id), s(h, i(p, {
2371
+ get when() {
2372
+ return e.status === "active";
2373
+ },
2374
+ get fallback() {
2375
+ return (() => {
2376
+ var t = ur();
2377
+ return t.$$click = () => u(e.id), t;
2378
+ })();
2379
+ },
2380
+ get children() {
2381
+ var t = sr();
2382
+ return t.$$click = () => a(e.id), t;
2383
+ }
2384
+ }), y), y.$$click = () => d(e.id), o((t) => {
2385
+ var n = e.status === "active", r = e.status === "draft", i = e.status === "disabled";
2386
+ return n !== t.e && m.classList.toggle("text-emerald-600", t.e = n), r !== t.t && m.classList.toggle("text-amber-600", t.t = r), i !== t.a && m.classList.toggle("text-muted-foreground", t.a = i), t;
2387
+ }, {
2388
+ e: void 0,
2389
+ t: void 0,
2390
+ a: void 0
2391
+ }), t;
2392
+ })()
2393
+ })), e;
2394
+ }
2395
+ }), null), e;
874
2396
  })();
2397
+ }
2398
+ a(["click"]);
2399
+ //#endregion
2400
+ //#region src/components/sso-login-button.tsx
2401
+ var pr = /* @__PURE__ */ u("<a class=\"inline-flex items-center justify-center rounded-md border bg-background px-4 py-2 text-sm font-medium hover:bg-accent\"><svg class=\"mr-2 h-4 w-4\"viewBox=\"0 0 24 24\"fill=none stroke=currentColor stroke-width=2><title>SSO</title><path d=\"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4M10 17l5-5-5-5M15 12H3\">");
2402
+ function mr(e) {
2403
+ let t = K(), n = g(() => t.client.sso.loginUrl({
2404
+ org: e.orgSlug,
2405
+ domain: e.domain,
2406
+ redirectTo: e.redirectTo
2407
+ })), r = g(() => !!(e.orgSlug || e.domain));
2408
+ return i(p, {
2409
+ get when() {
2410
+ return r();
2411
+ },
2412
+ get children() {
2413
+ var t = pr();
2414
+ return t.firstChild, s(t, () => e.label ?? "Sign in with SSO", null), o(() => l(t, "href", n())), t;
2415
+ }
2416
+ });
2417
+ }
2418
+ //#endregion
2419
+ //#region src/components/transfer-ownership.tsx
2420
+ var hr = /* @__PURE__ */ u("<div class=\"mb-3 rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\"role=alert>"), gr = /* @__PURE__ */ u("<div class=\"fixed inset-0 z-50 flex items-center justify-center bg-black/50\"role=dialog aria-modal=true aria-labelledby=transfer-ownership-title><div class=\"w-full max-w-md rounded-lg border border-input bg-background p-6 shadow-lg\"><h2 id=transfer-ownership-title class=\"mb-2 text-lg font-semibold\">Transfer ownership</h2><p class=\"mb-4 text-sm text-muted-foreground\">Choose a member to promote to owner. You will be demoted to admin. This cannot be undone without another transfer.</p><label class=\"mb-2 block text-sm font-medium\"for=successor-select>New owner</label><select id=successor-select class=\"mb-4 w-full rounded-md border border-input bg-background px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-ring\"><option value disabled>Select a member…</option></select><label class=\"mb-4 flex items-start gap-2 text-sm\"><input type=checkbox class=mt-0.5><span>I understand I will lose owner privileges in this organization.</span></label><div class=\"flex justify-end gap-2\"><button type=button class=\"rounded-md border border-input px-3 py-1.5 text-sm hover:bg-secondary\">Cancel</button><button type=button class=\"rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50\">"), _r = /* @__PURE__ */ u("<option> (<!>)"), vr = (e) => {
2421
+ let { members: t, refetch: n } = ce(() => e.organizationId), { submitting: r, error: a, transferOwnership: c } = de(() => e.organizationId), [l, u] = v(""), [d, m] = v(!1), h = g(() => t().filter((e) => e.role !== $.OWNER)), _ = () => {
2422
+ u(""), m(!1), e.onClose();
2423
+ }, y = async () => {
2424
+ !l() || !d() || await c({ new_owner_user_id: l() }) && (e.onSuccess?.(), await n(), _());
2425
+ };
2426
+ return i(p, {
2427
+ get when() {
2428
+ return e.open;
2429
+ },
2430
+ get children() {
2431
+ var e = gr(), t = e.firstChild, n = t.firstChild.nextSibling.nextSibling, c = n.nextSibling;
2432
+ c.firstChild;
2433
+ var g = c.nextSibling, v = g.firstChild, b = g.nextSibling.firstChild, x = b.nextSibling;
2434
+ return s(t, i(p, {
2435
+ get when() {
2436
+ return a();
2437
+ },
2438
+ get children() {
2439
+ var e = hr();
2440
+ return s(e, a), e;
2441
+ }
2442
+ }), n), c.addEventListener("change", (e) => u(e.currentTarget.value)), s(c, i(f, {
2443
+ get each() {
2444
+ return h();
2445
+ },
2446
+ children: (e) => (() => {
2447
+ var t = _r(), n = t.firstChild, r = n.nextSibling;
2448
+ return r.nextSibling, s(t, () => e.user_id, n), s(t, () => e.role, r), o(() => t.value = e.user_id), t;
2449
+ })()
2450
+ }), null), v.addEventListener("change", (e) => m(e.currentTarget.checked)), b.$$click = _, x.$$click = y, s(x, () => r() ? "Transferring…" : "Transfer ownership"), o((e) => {
2451
+ var t = r(), n = r(), i = r(), a = !l() || !d() || r();
2452
+ return t !== e.e && (c.disabled = e.e = t), n !== e.t && (v.disabled = e.t = n), i !== e.a && (b.disabled = e.a = i), a !== e.o && (x.disabled = e.o = a), e;
2453
+ }, {
2454
+ e: void 0,
2455
+ t: void 0,
2456
+ a: void 0,
2457
+ o: void 0
2458
+ }), o(() => c.value = l()), o(() => v.checked = d()), e;
2459
+ }
2460
+ });
875
2461
  };
876
- r(["input"]);
2462
+ a(["click"]);
877
2463
  //#endregion
878
2464
  //#region src/components/verify-email.tsx
879
- var Ne = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Verifying your email address..."), Pe = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), Fe = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Ie = /* @__PURE__ */ s("<div class=space-y-4>"), Le = (t) => {
880
- let { client: r } = y(), i = r?.emailPassword;
881
- if (!i) return null;
882
- let [o, s] = p("loading"), [c, l] = p(""), [u, f] = p("");
883
- return d(async () => {
2465
+ var yr = /* @__PURE__ */ u("<div class=\"text-sm text-muted-foreground\">Verifying your email address..."), br = /* @__PURE__ */ u("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), xr = /* @__PURE__ */ u("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Sr = /* @__PURE__ */ u("<div class=space-y-4>"), Cr = (t) => {
2466
+ let { client: n } = K(), r = n?.emailPassword;
2467
+ if (!r) return null;
2468
+ let [a, o] = v("loading"), [c, l] = v(""), [u, d] = v("");
2469
+ return h(async () => {
884
2470
  try {
885
- l((await i.verify({ token: t.token })).message), s("success"), t.onSuccess?.();
2471
+ l((await r.verify({ token: t.token })).message), o("success"), t.onSuccess?.();
886
2472
  } catch (e) {
887
2473
  let n = e instanceof Error ? e : Error(String(e));
888
- f(n.message), s("error"), t.onError?.(n);
2474
+ d(n.message), o("error"), t.onError?.(n);
889
2475
  }
890
2476
  }), (() => {
891
- var t = Ie();
892
- return a(t, n(e, {
2477
+ var t = Sr();
2478
+ return s(t, i(e, {
893
2479
  get when() {
894
- return o() === "loading";
2480
+ return a() === "loading";
895
2481
  },
896
2482
  get children() {
897
- return Ne();
2483
+ return yr();
898
2484
  }
899
- }), null), a(t, n(e, {
2485
+ }), null), s(t, i(e, {
900
2486
  get when() {
901
- return o() === "success";
2487
+ return a() === "success";
902
2488
  },
903
2489
  get children() {
904
- var e = Pe();
905
- return a(e, c), e;
2490
+ var e = br();
2491
+ return s(e, c), e;
906
2492
  }
907
- }), null), a(t, n(e, {
2493
+ }), null), s(t, i(e, {
908
2494
  get when() {
909
- return o() === "error";
2495
+ return a() === "error";
910
2496
  },
911
2497
  get children() {
912
- var e = Fe();
913
- return a(e, u), e;
2498
+ var e = xr();
2499
+ return s(e, u), e;
914
2500
  }
915
2501
  }), null), t;
916
2502
  })();
917
2503
  };
918
2504
  //#endregion
919
- export { C as ChangePasswordForm, O as ConsentScreen, M as ForgotPasswordForm, z as LoginForm, G as MagicLinkForm, ee as MfaChallenge, ie as MfaSetup, se as OAuthButtons, F as PasskeyButton, Ee as ProfileSettings, Oe as RegisterForm, Me as ResetPasswordForm, Le as VerifyEmail, v as YAuthProvider, y as useYAuth };
2505
+ export { P as AuditDestinationCreate, U as AuditDestinationList, Y as ChangePasswordForm, oe as ConsentScreen, _e as DomainClaim, Te as DomainList, Ae as DomainVerifyStep, Pe as ForgotPasswordForm, Be as InvitationAccept, Ge as InviteForm, Qe as LoginForm, it as MagicLinkForm, St as MemberList, Tt as MfaChallenge, Mt as MfaSetup, Ft as OAuthButtons, zt as OrganizationCard, Ht as OrganizationCreate, Yt as OrganizationDetail, nn as OrganizationList, dn as OrganizationSwitcher, Je as PasskeyButton, Mn as ProfileSettings, $ as ROLES, Fn as RegisterForm, zn as ResetPasswordForm, ot as RoleSelector, Wn as SamlConnectionForm, Kn as SamlLoginButton, Yn as ScimSettingsPanel, $n as SsoConnectionForm, fr as SsoConnectionList, mr as SsoLoginButton, vr as TransferOwnership, Cr as VerifyEmail, G as YAuthProvider, rn as createActiveOrg, O as createAuditDestinations, fe as createDomains, le as createInvitation, ce as createMembers, ue as createOrgPermissions, de as createOrgRoles, se as createOrganization, Q as createOrganizations, Bn as createSsoConnections, Z as slugify, K as useYAuth };