@aerogel/plugin-solid 0.0.1-next.04142b2821eaa6e510478867fc4e63149b6ae8c9

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.
@@ -0,0 +1,620 @@
1
+ var X = Object.defineProperty;
2
+ var Z = (n, e, t) => e in n ? X(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var a = (n, e, t) => Z(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { persistent as ee, defineServiceState as te, Events as d, UI as I, translateWithDefault as l, App as g, Storage as ie, Errors as D, defineFormValidationRule as ne, computedAsync as re, Cache as P, useForm as se, requiredStringInput as oe, Form as ae, Input as le, Button as O, registerErrorHandler as ce, bootServices as ue } from "@aerogel/core";
5
+ import { SolidEngine as he, SolidTypeIndex as m, SolidContainer as A, SolidACLAuthorization as de, SolidDocument as ge, bootSolidModels as fe } from "soukai-solid";
6
+ import { JSError as R, arr as me, fail as S, PromisedValue as pe, Storage as L, after as F, required as M, facade as we, tap as x, arrayUnique as z, objectWithout as W, isDevelopment as ye, asyncMemo as B, hasLocationQueryParameter as w, getLocationQueryParameter as E, arrayFilter as Se, setAsyncMemo as j, urlRoot as ve, requireUrlParse as be, objectWithoutEmpty as Ie, parseBoolean as V, arrayWithout as Pe } from "@noeldemartin/utils";
7
+ import { fetchLoginUserProfile as Ae } from "@noeldemartin/solid-utils";
8
+ import { setEngine as Le } from "soukai";
9
+ import y from "virtual:aerogel-solid";
10
+ import { markRaw as xe, createElementBlock as v, openBlock as h, createElementVNode as _, defineComponent as $, unref as u, computed as H, createBlock as p, toDisplayString as T, withCtx as U, createVNode as Ee, createTextVNode as N } from "vue";
11
+ class _e extends R {
12
+ }
13
+ function Ue(n, e) {
14
+ return n;
15
+ }
16
+ class b extends R {
17
+ constructor(t, i, r) {
18
+ super(Ue(t), r);
19
+ a(this, "description");
20
+ this.description = i;
21
+ }
22
+ }
23
+ class Ce extends R {
24
+ constructor(e, t) {
25
+ super(`Container at ${e.url} is already in use`, t);
26
+ }
27
+ }
28
+ class Q {
29
+ constructor() {
30
+ a(this, "name");
31
+ a(this, "authenticatedFetch");
32
+ a(this, "booted");
33
+ a(this, "listeners", me([]));
34
+ a(this, "_engine");
35
+ }
36
+ get engine() {
37
+ return this._engine = this._engine ?? new he(this.requireAuthenticatedFetch()), this._engine;
38
+ }
39
+ getAuthenticatedFetch() {
40
+ return this.authenticatedFetch ?? null;
41
+ }
42
+ requireAuthenticatedFetch() {
43
+ return this.authenticatedFetch ?? S("Authenticated fetch is not ready");
44
+ }
45
+ addListener(e) {
46
+ return this.listeners.includes(e) || this.listeners.push(e), () => {
47
+ this.removeListener(e);
48
+ };
49
+ }
50
+ removeListener(e) {
51
+ this.listeners.includes(e) && this.listeners.remove(e);
52
+ }
53
+ async boot() {
54
+ if (this.booted)
55
+ return this.booted;
56
+ this.booted = new pe(), await this.restoreSession(), this.booted.resolve();
57
+ }
58
+ async initAuthenticatedFetch(e) {
59
+ this.authenticatedFetch = e, await this.notifyListeners("onAuthenticatedFetchReady", e);
60
+ }
61
+ async startSession(e) {
62
+ const t = {
63
+ authenticator: this,
64
+ ...e
65
+ };
66
+ return await this.notifyListeners("onSessionStarted", t), t;
67
+ }
68
+ async failSession(e, t) {
69
+ await this.notifyListeners("onSessionFailed", e, t);
70
+ }
71
+ async endSession() {
72
+ await this.notifyListeners("onSessionEnded");
73
+ }
74
+ async notifyListeners(e, ...t) {
75
+ await Promise.all(
76
+ this.listeners.toArray().map(async (i) => {
77
+ const r = i[e];
78
+ await (r == null ? void 0 : r(...t));
79
+ })
80
+ );
81
+ }
82
+ }
83
+ const C = "inrupt-authenticator";
84
+ class Te extends Q {
85
+ constructor() {
86
+ super(...arguments);
87
+ a(this, "_events");
88
+ a(this, "_fetch");
89
+ a(this, "_login");
90
+ a(this, "_logout");
91
+ a(this, "_handleIncomingRedirect");
92
+ }
93
+ async login(t) {
94
+ L.set(C, t);
95
+ const i = {
96
+ oidcIssuer: t
97
+ };
98
+ return y.clientID && (i.clientId = y.clientID.client_id, i.clientName = y.clientID.client_name, i.redirectUrl = y.clientID.redirect_uris[0]), await this._login(i), await F({ seconds: 60 }), S("Browser should have redirected, but it didn't");
99
+ }
100
+ async logout() {
101
+ await this._logout(), await this.endSession();
102
+ }
103
+ async restoreSession() {
104
+ const { events: t, fetch: i, handleIncomingRedirect: r, login: s, logout: c } = await import("./InruptAuthenticator.lazy-BvpQLGoj.js");
105
+ this._fetch = i, this._login = s, this._logout = c, this._events = t, this._handleIncomingRedirect = r, await this.loginFromRedirect();
106
+ }
107
+ async loginFromRedirect() {
108
+ const t = L.get(C);
109
+ if (!t)
110
+ return;
111
+ this._events().on("error", (r, s) => {
112
+ r ?? (r = "Error using Inrupt Authenticator method"), typeof s == "object" ? this.failSession(t, new b(r, null, { cause: s })) : this.failSession(t, new b(r, s));
113
+ });
114
+ const i = await this._handleIncomingRedirect(globalThis.location.href);
115
+ L.remove(C), i != null && i.isLoggedIn && i.webId && await this.initSession(i.webId);
116
+ }
117
+ async initSession(t) {
118
+ await this.initAuthenticatedFetch(this._fetch);
119
+ try {
120
+ const i = await f.requireUserProfile(t);
121
+ await this.startSession({ user: i, loginUrl: t });
122
+ } catch (i) {
123
+ await this.failSession(t, i);
124
+ }
125
+ }
126
+ }
127
+ class Re extends Q {
128
+ constructor() {
129
+ super();
130
+ a(this, "store");
131
+ this.store = ee("legacy-authenticator", {});
132
+ }
133
+ async login(t, i) {
134
+ const { SolidAuthClient: r } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js");
135
+ throw this.store.webId = i == null ? void 0 : i.webId, this.store.loginUrl = (i == null ? void 0 : i.oidcIssuerUrl) ?? t, await r.login(this.store.loginUrl) === null ? (delete this.store.webId, delete this.store.loginUrl, new b("Could not log in with Solid using the legacy authenticator")) : (await F({ seconds: 60 }), new Error("Browser should have redirected, but it didn't"));
136
+ }
137
+ async logout() {
138
+ const { SolidAuthClient: t } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js");
139
+ delete this.store.webId, delete this.store.loginUrl, await t.logout(), await this.endSession();
140
+ }
141
+ async restoreSession() {
142
+ if (!this.store.loginUrl)
143
+ return;
144
+ const { SolidAuthClient: t } = await import("./LegacyAuthenticator.lazy-ChFFqP14.js"), i = await t.currentSession(), r = M(this.store.loginUrl);
145
+ await this.initAuthenticatedFetch((s, c) => t.fetch(s, c));
146
+ try {
147
+ const s = await f.requireUserProfile(M((i == null ? void 0 : i.webId) ?? this.store.webId));
148
+ await this.startSession({ user: s, loginUrl: r });
149
+ } catch (s) {
150
+ await this.failSession(r, s);
151
+ }
152
+ }
153
+ }
154
+ const q = {}, Fe = {
155
+ inrupt: new Te(),
156
+ legacy: new Re()
157
+ };
158
+ function $e(n) {
159
+ q.default = n;
160
+ }
161
+ function Y(n) {
162
+ return q[n];
163
+ }
164
+ function qe(n) {
165
+ Object.entries(n).forEach(([e, t]) => ke(e, t));
166
+ }
167
+ function ke(n, e) {
168
+ q[n] = e, e.name = e.name ?? n;
169
+ }
170
+ const k = { autoReconnect: !0 }, De = te({
171
+ name: "solid",
172
+ persist: ["autoReconnect", "dismissed", "previousSession", "profiles", "staleProfiles"],
173
+ initialState: {
174
+ autoReconnect: k.autoReconnect,
175
+ dismissed: !1,
176
+ ignorePreviousSessionError: !1,
177
+ loginStartupError: null,
178
+ loginOngoing: !1,
179
+ preferredAuthenticator: null,
180
+ previousSession: null,
181
+ profiles: {},
182
+ session: null,
183
+ loginStale: !1,
184
+ staleProfiles: []
185
+ },
186
+ serialize(n) {
187
+ var e;
188
+ return ((e = n.previousSession) == null ? void 0 : e.error) instanceof Error && (n.previousSession.error = n.previousSession.error.message), n;
189
+ },
190
+ computed: {
191
+ user: (n) => {
192
+ var e, t;
193
+ return ((e = n.session) == null ? void 0 : e.user) ?? ((t = n.previousSession) == null ? void 0 : t.profile) ?? null;
194
+ },
195
+ authenticator: (n) => {
196
+ var e;
197
+ return ((e = n.session) == null ? void 0 : e.authenticator) ?? null;
198
+ },
199
+ fetch() {
200
+ var n;
201
+ return ((n = this.authenticator) == null ? void 0 : n.getAuthenticatedFetch()) ?? globalThis.fetch.bind(globalThis);
202
+ },
203
+ error(n) {
204
+ var e;
205
+ return n.loginStartupError ? n.loginStartupError ?? null : n.ignorePreviousSessionError ? null : ((e = n.previousSession) == null ? void 0 : e.error) ?? null;
206
+ }
207
+ }
208
+ });
209
+ class Oe extends De {
210
+ isLoggedIn() {
211
+ return !!this.session;
212
+ }
213
+ wasLoggedIn() {
214
+ return !!this.previousSession;
215
+ }
216
+ hasLoggedIn() {
217
+ return !!(this.session || this.previousSession);
218
+ }
219
+ requireAuthenticator() {
220
+ return this.authenticator ?? S("Could not get authenticator");
221
+ }
222
+ requireUser() {
223
+ return this.user ?? S("Could not get user profile (are you logged in?)");
224
+ }
225
+ requireUserProfile(e) {
226
+ return this.getUserProfile(e, { required: !0 });
227
+ }
228
+ /* eslint-enable max-len */
229
+ async getUserProfile(e, t = {}) {
230
+ var c;
231
+ let i = null;
232
+ const r = t.markStale ?? !((c = this.authenticator) != null && c.getAuthenticatedFetch()), s = this.profiles[e] ?? await x(
233
+ await Ae(e, {
234
+ fetch: this.fetch,
235
+ required: t.required ?? !1,
236
+ onLoaded(o) {
237
+ i = o;
238
+ }
239
+ }),
240
+ async (o) => {
241
+ o && (i && await d.emit("solid:user-profile-loaded", [o, i]), this.rememberProfile(o));
242
+ }
243
+ );
244
+ return s && r && this.setState({ staleProfiles: z(this.staleProfiles.concat([s.webId])) }), s;
245
+ }
246
+ async refreshUserProfile() {
247
+ if (!this.isLoggedIn())
248
+ return;
249
+ this.setState({ profiles: W(this.profiles, [this.user.webId]) });
250
+ const e = await this.requireUserProfile(this.user.webId);
251
+ this.setState({
252
+ session: {
253
+ ...this.session,
254
+ user: e
255
+ }
256
+ });
257
+ }
258
+ async login(e, t = {}) {
259
+ if (ye() && e === "dev" && (e = "http://localhost:3000"), /^https?:\/\//.test(e) || (t.fallbackUrl ?? (t.fallbackUrl = `http://${e}`), e = `https://${e}`), this.isLoggedIn())
260
+ return !0;
261
+ if (this.loginOngoing)
262
+ throw new Error("Authentication already in progress");
263
+ return t.loading ? I.loading(l("solid.loggingIn", "Logging in..."), () => this.attemptLogin(e, t)) : this.attemptLogin(e, t);
264
+ }
265
+ async reconnect(e = {}) {
266
+ const { force: t, ...i } = e;
267
+ this.isLoggedIn() || !this.previousSession || this.previousSession.error !== null && !t || await this.login(this.previousSession.loginUrl, {
268
+ authenticator: this.previousSession.authenticator,
269
+ ...i,
270
+ loading: i.loading ?? !1
271
+ });
272
+ }
273
+ async logout(e = !1) {
274
+ var c, o;
275
+ const t = !g.plugin("@aerogel/local-first") || !!((c = g.service("$cloud")) != null && c.ready), i = !g.plugin("@aerogel/local-first") || !!((o = g.service("$cloud")) != null && o.dirty), [r, s] = e ? [!0, { wipeLocalData: t }] : await I.confirm(
276
+ t ? l("solid.logoutConfirmTitle", "Log out from this device?") : l("solid.disconnectConfirmTitle", "Disconnect account?"),
277
+ t ? i ? l(
278
+ "solid.logoutConfirmMessageWithLocalChanges",
279
+ "There are some changes that haven't been synchronized and will be lost, but the rest of the data will remain in your Solid POD."
280
+ ) : l(
281
+ "solid.logoutConfirmMessage",
282
+ "Logging out will remove all the data from this device, but you'll still have it in your Solid POD."
283
+ ) : l(
284
+ "solid.disconnectConfirmMessage",
285
+ "You'll need to introduce your credentials again to connect to your Solid POD."
286
+ ),
287
+ {
288
+ acceptText: l("solid.logoutConfirmAccept", "Log out"),
289
+ acceptVariant: "danger",
290
+ cancelText: l(
291
+ "solid.logoutConfirmCancel",
292
+ l("ui.cancel", "Cancel")
293
+ ),
294
+ checkboxes: t ? i ? {
295
+ wipeLocalData: {
296
+ label: l(
297
+ "solid.logoutConfirmWipeNotice",
298
+ "I understand that changes that haven't been synchronized will be lost."
299
+ ),
300
+ default: !1,
301
+ required: !0
302
+ }
303
+ } : void 0 : {
304
+ wipeLocalData: {
305
+ label: l(
306
+ "solid.logoutConfirmWipe",
307
+ "Also remove all existing data"
308
+ ),
309
+ default: !1
310
+ }
311
+ }
312
+ }
313
+ );
314
+ r && this.previousSession && await I.loading(l("solid.logoutOngoing", "Logging out..."), async () => {
315
+ this.setState({
316
+ dismissed: !1,
317
+ ignorePreviousSessionError: !1,
318
+ loginStartupError: null,
319
+ previousSession: null,
320
+ ...k
321
+ }), this.isLoggedIn() && await this.authenticator.logout(), (s.wipeLocalData ?? !0) && await ie.purge(), await d.emit("auth:logout"), await d.emit("auth:after-logout");
322
+ });
323
+ }
324
+ async whenLoggedIn(e) {
325
+ return this.isLoggedIn() ? e(this.session) : new Promise((t) => {
326
+ const i = (r) => t(e(r));
327
+ d.once("auth:login", i);
328
+ });
329
+ }
330
+ dismiss() {
331
+ this.setState({ dismissed: !0 });
332
+ }
333
+ async findOrCreatePrivateTypeIndex() {
334
+ return await this.findPrivateTypeIndex() ?? await this.createPrivateTypeIndex();
335
+ }
336
+ async findPrivateTypeIndex() {
337
+ const { webId: e, privateTypeIndexUrl: t } = this.requireUser(), i = this.requireAuthenticator().engine;
338
+ return t ? B(`${e}-privateTypeIndex`, () => m.withEngine(i).find(t)) : null;
339
+ }
340
+ async findOrCreatePublicTypeIndex() {
341
+ return await this.findPublicTypeIndex() ?? await this.createPublicTypeIndex();
342
+ }
343
+ async findPublicTypeIndex() {
344
+ const { webId: e, publicTypeIndexUrl: t } = this.requireUser(), i = this.requireAuthenticator().engine;
345
+ return t ? B(`${e}-publicTypeIndex`, () => m.withEngine(i).find(t)) : null;
346
+ }
347
+ async createPrivateContainer(e) {
348
+ const t = this.requireAuthenticator().engine;
349
+ return A.withEngine(t, async () => {
350
+ const i = await A.find(e.url);
351
+ if (i && !e.reuseExisting)
352
+ throw new Ce(i);
353
+ const r = i ?? new A({ url: e.url, name: e.name });
354
+ if (await r.save(), e.registerFor) {
355
+ const s = await this.findOrCreatePrivateTypeIndex();
356
+ await r.register(s, e.registerFor);
357
+ }
358
+ return r;
359
+ });
360
+ }
361
+ async boot() {
362
+ var e, t;
363
+ await D.booted, w("authenticator") && this.setState({
364
+ preferredAuthenticator: E("authenticator")
365
+ }), w("refreshProfile") && this.setState({
366
+ staleProfiles: z(
367
+ this.staleProfiles.concat(Se([(e = this.session) == null ? void 0 : e.user.webId, (t = this.previousSession) == null ? void 0 : t.loginUrl]))
368
+ )
369
+ }), await this.restorePreviousSession(), await this.startupReconnect();
370
+ }
371
+ async createPrivateTypeIndex() {
372
+ const e = this.requireUser(), t = this.requireAuthenticator(), i = await m.withEngine(t.engine).createPrivate(e);
373
+ return x(i, () => {
374
+ e.privateTypeIndexUrl = i.url, j(`${e.webId}-privateTypeIndex`, i), this.rememberProfile(e);
375
+ });
376
+ }
377
+ async createPublicTypeIndex() {
378
+ const e = this.requireUser(), t = this.requireAuthenticator(), i = await m.withEngine(t.engine).createPublic(e);
379
+ return x(i, () => {
380
+ e.privateTypeIndexUrl = i.url, j(`${e.webId}-publicTypeIndex`, i), this.rememberProfile(e);
381
+ });
382
+ }
383
+ async attemptLogin(e, t) {
384
+ const i = t.authenticator ?? this.preferredAuthenticator ?? "default", r = t.onError ?? ((o) => g.isMounted() ? D.report(o) : this.setState({ loginStartupError: o })), s = setTimeout(() => this.loginStale = !0, 1e4), c = {
385
+ dismissed: this.dismissed,
386
+ ignorePreviousSessionError: this.ignorePreviousSessionError,
387
+ previousSession: this.previousSession
388
+ };
389
+ this.loginOngoing = !0;
390
+ try {
391
+ const o = await this.getUserProfile(e, { markStale: !0 }), G = (o == null ? void 0 : o.oidcIssuerUrl) ?? ve((o == null ? void 0 : o.webId) ?? e), J = await this.bootAuthenticator(i), { domain: K } = be(e);
392
+ return this.setState({
393
+ dismissed: !1,
394
+ ignorePreviousSessionError: !0,
395
+ previousSession: Ie({
396
+ profile: o,
397
+ loginUrl: e,
398
+ authenticator: i,
399
+ error: l(
400
+ "auth.stuckConnecting",
401
+ `We didn't hear back from the identity provider at \`${K}\`, maybe try reconnecting?`
402
+ )
403
+ })
404
+ }), await d.emit("auth:before-login"), await J.login(G, o), !0;
405
+ } catch (o) {
406
+ return this.setState(c), o instanceof _e ? !1 : t.fallbackUrl ? F().then(() => this.login(t.fallbackUrl ?? "", W(t, "fallbackUrl"))) : (r(o), !1);
407
+ } finally {
408
+ clearTimeout(s), this.setState({
409
+ loginOngoing: !1,
410
+ loginStale: !1
411
+ });
412
+ }
413
+ }
414
+ async restorePreviousSession() {
415
+ this.previousSession && await this.bootAuthenticator(this.previousSession.authenticator);
416
+ }
417
+ async startupReconnect() {
418
+ this.reconnectOnStartup() && await this.reconnect({ force: this.forcingReconnect() });
419
+ }
420
+ reconnectOnStartup() {
421
+ return w("autoReconnect") ? V(E("autoReconnect")) : this.autoReconnect;
422
+ }
423
+ forcingReconnect() {
424
+ return w("autoReconnect") && V(E("autoReconnect"));
425
+ }
426
+ async bootAuthenticator(e) {
427
+ const t = Y(e);
428
+ return t.addListener({
429
+ onSessionStarted: async (i) => {
430
+ this.setState({
431
+ session: i,
432
+ previousSession: {
433
+ authenticator: t.name,
434
+ loginUrl: i.loginUrl,
435
+ profile: i.user,
436
+ error: null
437
+ }
438
+ }), this.staleProfiles.includes(i.user.webId) && await this.refreshUserProfile(), g.plugin("@aerogel/local-first") || Le(i.authenticator.engine), de.setEngine(i.authenticator.engine), m.setEngine(i.authenticator.engine), ge.setEngine(i.authenticator.engine), await d.emit("auth:login", i);
439
+ },
440
+ onSessionFailed: async (i, r) => {
441
+ var s;
442
+ this.setState({
443
+ session: null,
444
+ previousSession: {
445
+ profile: (s = this.previousSession) == null ? void 0 : s.profile,
446
+ authenticator: t.name,
447
+ loginUrl: i,
448
+ error: r
449
+ }
450
+ });
451
+ },
452
+ onSessionEnded: () => this.setState({ session: null }),
453
+ onAuthenticatedFetchReady: (i) => d.emit("auth:fetch-ready", i)
454
+ }), await t.boot(), t;
455
+ }
456
+ rememberProfile(e) {
457
+ this.setState({
458
+ profiles: {
459
+ ...this.profiles,
460
+ [e.webId]: e
461
+ },
462
+ staleProfiles: Pe(this.staleProfiles, e.webId)
463
+ });
464
+ }
465
+ }
466
+ const f = we(Oe);
467
+ function Me() {
468
+ ne("container_url", (n) => {
469
+ if (!n.endsWith("/"))
470
+ return "containerEndingSlashMissing";
471
+ });
472
+ }
473
+ const ze = {
474
+ viewBox: "0 0 20 20",
475
+ width: "1.2em",
476
+ height: "1.2em"
477
+ };
478
+ function We(n, e) {
479
+ return h(), v("svg", ze, e[0] || (e[0] = [
480
+ _("path", {
481
+ fill: "currentColor",
482
+ d: "M15 2H5L4 8h12zM0 10s2 1 10 1s10-1 10-1l-4-2H4zm8 4h4v1H8z"
483
+ }, null, -1),
484
+ _("circle", {
485
+ cx: "6",
486
+ cy: "15",
487
+ r: "3",
488
+ fill: "currentColor"
489
+ }, null, -1),
490
+ _("circle", {
491
+ cx: "14",
492
+ cy: "15",
493
+ r: "3",
494
+ fill: "currentColor"
495
+ }, null, -1)
496
+ ]));
497
+ }
498
+ const Be = xe({ name: "ooui-user-anonymous", render: We }), je = ["src"], Ve = /* @__PURE__ */ $({
499
+ __name: "SolidImage",
500
+ props: {
501
+ src: {}
502
+ },
503
+ setup(n) {
504
+ const e = re(async () => {
505
+ const i = await P.get(n.src) ?? await t(n.src), r = await (i == null ? void 0 : i.blob());
506
+ return r && URL.createObjectURL(r);
507
+ });
508
+ async function t(i) {
509
+ try {
510
+ const r = await f.fetch(i);
511
+ return r.status !== 200 ? null : (await P.store(i, r), P.get(i));
512
+ } catch {
513
+ return null;
514
+ }
515
+ }
516
+ return (i, r) => (h(), v("img", { src: u(e) }, null, 8, je));
517
+ }
518
+ }), Ne = { class: "relative flex items-center justify-center rounded-full bg-gray-200" }, He = {
519
+ key: 1,
520
+ class: "text-sm font-semibold tracking-wider text-gray-500",
521
+ "aria-hidden": "true"
522
+ }, it = /* @__PURE__ */ $({
523
+ __name: "SolidAvatar",
524
+ setup(n) {
525
+ const e = H(() => {
526
+ var i;
527
+ return (((i = f.user) == null ? void 0 : i.name) ?? "").trim().split(" ").map((r) => {
528
+ var s;
529
+ return (s = r[0]) == null ? void 0 : s.toUpperCase();
530
+ }).join("").slice(0, 3);
531
+ });
532
+ return (t, i) => {
533
+ var r, s;
534
+ return h(), v("div", Ne, [
535
+ (r = t.$solid.user) != null && r.avatarUrl ? (h(), p(Ve, {
536
+ key: 0,
537
+ src: (s = t.$solid.user) == null ? void 0 : s.avatarUrl,
538
+ alt: "",
539
+ class: "absolute inset-0 size-full rounded-full"
540
+ }, null, 8, ["src"])) : e.value ? (h(), v("span", He, T(e.value), 1)) : (h(), p(u(Be), {
541
+ key: 2,
542
+ class: "size-6 text-gray-500"
543
+ }))
544
+ ]);
545
+ };
546
+ }
547
+ }), nt = /* @__PURE__ */ $({
548
+ __name: "SolidLogin",
549
+ setup(n) {
550
+ const e = se({ url: oe() }), t = H(
551
+ () => g.development && (!e.url || e.url === "dev" || e.url.trim().length === 0)
552
+ );
553
+ return (i, r) => (h(), p(u(ae), {
554
+ form: u(e),
555
+ class: "flex flex-col items-center gap-2 md:flex-row",
556
+ onSubmit: r[1] || (r[1] = (s) => i.$solid.login(u(e).url))
557
+ }, {
558
+ default: U(() => [
559
+ Ee(u(le), {
560
+ name: "url",
561
+ "aria-label": i.$td("solid.logIn.label", "Login url"),
562
+ placeholder: i.$td("solid.logIn.placeholder", "https://me.solidcommunity.net"),
563
+ class: "w-96 max-w-full"
564
+ }, null, 8, ["aria-label", "placeholder"]),
565
+ t.value ? (h(), p(u(O), {
566
+ key: 0,
567
+ submit: "",
568
+ class: "w-full whitespace-nowrap md:w-auto",
569
+ onClick: r[0] || (r[0] = (s) => u(e).url = "dev")
570
+ }, {
571
+ default: U(() => [
572
+ N(T(i.$td("solid.logIn.dev", "Log in to dev server")), 1)
573
+ ]),
574
+ _: 1
575
+ })) : (h(), p(u(O), {
576
+ key: 1,
577
+ submit: "",
578
+ class: "w-full md:w-auto"
579
+ }, {
580
+ default: U(() => [
581
+ N(T(i.$td("solid.logIn.submit", "Log in")), 1)
582
+ ]),
583
+ _: 1
584
+ }))
585
+ ]),
586
+ _: 1
587
+ }, 8, ["form"]));
588
+ }
589
+ }), Qe = { $solid: f };
590
+ function rt(n = {}) {
591
+ return {
592
+ async install(e) {
593
+ fe(), qe({ ...Fe, ...n.authenticators ?? {} }), Me(), $e(Y(n.defaultAuthenticator ?? "inrupt")), ce((t) => {
594
+ if (t instanceof b)
595
+ return t.description ? `${t.message} (${t.description})` : t.message;
596
+ }), typeof n.autoReconnect == "boolean" && (k.autoReconnect = n.autoReconnect, f.hasPersistedState() || (f.autoReconnect = n.autoReconnect)), n.onUserProfileLoaded && d.on("solid:user-profile-loaded", ([t, i]) => {
597
+ var r;
598
+ (r = n.onUserProfileLoaded) == null || r.call(n, t, i);
599
+ }), await ue(e, Qe);
600
+ }
601
+ };
602
+ }
603
+ export {
604
+ _e as AuthenticationCancelledError,
605
+ b as AuthenticationFailedError,
606
+ Q as Authenticator,
607
+ Ce as ContainerAlreadyInUse,
608
+ f as Solid,
609
+ it as SolidAvatar,
610
+ Ve as SolidImage,
611
+ nt as SolidLogin,
612
+ Oe as SolidService,
613
+ Fe as authenticators,
614
+ rt as default,
615
+ Y as getAuthenticator,
616
+ ke as registerAuthenticator,
617
+ qe as registerAuthenticators,
618
+ $e as setDefaultAuthenticator
619
+ };
620
+ //# sourceMappingURL=aerogel-plugin-solid.js.map