@wral/studio.mods.auth 0.3.7 → 1.0.1

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.
Files changed (45) hide show
  1. package/README.md +39 -47
  2. package/bitbucket-pipelines.yml +28 -4
  3. package/dist/auth.cjs.js +326 -1467
  4. package/dist/auth.es.js +1077 -3078
  5. package/dist/lib.cjs.js +1 -1
  6. package/dist/lib.es.js +13 -7
  7. package/eslint.config.mjs +41 -34
  8. package/index.html +83 -18
  9. package/jest.config.mjs +24 -0
  10. package/jest.setup.mjs +5 -0
  11. package/package.json +15 -28
  12. package/src/auth.mjs +204 -69
  13. package/src/auth.test.mjs +97 -0
  14. package/src/components/auth-app.mjs +26 -0
  15. package/src/components/forgot-password-form.mjs +217 -0
  16. package/src/components/login-form.mjs +288 -0
  17. package/src/config.mjs +27 -0
  18. package/src/helper.mjs +31 -0
  19. package/src/helper.test.mjs +44 -0
  20. package/src/index.mjs +17 -0
  21. package/src/login-layout.mjs +32 -0
  22. package/src/login.mjs +20 -0
  23. package/src/routes/change-password.mjs +158 -0
  24. package/src/routes/dashboard.mjs +17 -0
  25. package/src/routes/index.mjs +15 -0
  26. package/src/state.mjs +61 -0
  27. package/src/state.test.mjs +58 -0
  28. package/src/styles.mjs +9 -0
  29. package/src/token.mjs +40 -0
  30. package/src/utils.mjs +3 -0
  31. package/vellum-fixture.mjs +86 -0
  32. package/vite.config.mjs +12 -0
  33. package/components.html +0 -43
  34. package/development.md +0 -41
  35. package/src/components/mod-auth-login-form.mjs +0 -133
  36. package/src/components/studio-change-password.mjs +0 -84
  37. package/src/components/studio-login.mjs +0 -94
  38. package/src/components/studio-profile-view.mjs +0 -56
  39. package/src/components/studio-reset-password.mjs +0 -110
  40. package/src/lib.mjs +0 -16
  41. package/src/tool-dummy.mjs +0 -84
  42. package/src/util.mjs +0 -194
  43. package/src/util.test.mjs +0 -171
  44. package/vite.config.js +0 -12
  45. package/web-test-runner.config.mjs +0 -28
package/dist/auth.es.js CHANGED
@@ -1,310 +1,241 @@
1
- var fe = Object.defineProperty;
2
- var me = (o, t, e) => t in o ? fe(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var E = (o, t, e) => me(o, typeof t != "symbol" ? t + "" : t, e);
4
- function mt(o) {
5
- return {
6
- // Underlying mechanism to use the REST URLs directly.
7
- api: (t, e) => O(o, t, e),
8
- mintToken: ({ username: t, password: e }) => ge({ config: o, username: t, password: e }),
9
- refreshToken: ({ token: t }) => ve({ config: o, token: t }),
10
- pubkey: () => ye({ config: o }),
11
- updatePassword: ({ token: t, currentPassword: e, newPassword: r }) => we({ config: o, token: t, currentPassword: e, newPassword: r }),
12
- triggerResetPassword: ({ username: t }) => _e({ config: o, username: t }),
13
- confirmResetPassword: ({ username: t, newPassword: e, confirmationCode: r }) => $e({ config: o, username: t, newPassword: e, confirmationCode: r })
1
+ import { getToken as G } from "./lib.es.js";
2
+ function be(s, e) {
3
+ var o, i;
4
+ const r = e.element.attributes;
5
+ return console.log(r), {
6
+ api: r.api.value || ve("auth:api is required"),
7
+ forceLogin: r["force-login"] !== void 0,
8
+ // TODO: handle false
9
+ storageKey: (o = r["storage-key"]) == null ? void 0 : o.value,
10
+ mount: ((i = r.path) == null ? void 0 : i.value) || "/auth",
11
+ toolkit: s
14
12
  };
15
13
  }
16
- function ge({ config: o, username: t, password: e }) {
17
- return O(o, "/v1/user/login", {
18
- method: "POST",
19
- body: {
20
- username: t,
21
- password: e
22
- }
23
- });
24
- }
25
- function ve({ config: o, token: t }) {
26
- return O(o, "/v1/refresh", {
27
- method: "POST",
28
- body: {
29
- token: t
30
- }
31
- });
32
- }
33
- function ye({ config: o }) {
34
- return O(o, "/v1/pubkey", {
35
- method: "GET"
36
- });
37
- }
38
- function we({ config: o, token: t, currentPassword: e, newPassword: r }) {
39
- return O(o, "/v1/user/password", {
40
- method: "PUT",
41
- body: {
42
- currentPassword: e,
43
- newPassword: r
44
- },
45
- headers: {
46
- Authorization: `Bearer ${t}`
47
- }
48
- });
49
- }
50
- function _e({ config: o, username: t }) {
51
- return O(o, "/v1/user/password/reset", {
52
- method: "POST",
53
- body: {
54
- username: t
55
- }
56
- });
57
- }
58
- function $e({ config: o, username: t, newPassword: e, confirmationCode: r }) {
59
- return O(o, "/v1/user/password/reset/confirm", {
60
- method: "POST",
61
- body: {
62
- username: t,
63
- newPassword: e,
64
- confirmationCode: r
65
- }
66
- });
14
+ function ve(s) {
15
+ throw new Error(s);
67
16
  }
68
- async function O(o, t, e) {
69
- var c;
70
- const r = o.baseUrl.endsWith("/") ? o.baseUrl : `${o.baseUrl}/`, s = t.startsWith("/") ? t.substring(1) : t, i = new URL(s, r), d = Object.assign({}, e, {
71
- headers: Object.assign({}, {
72
- "Content-Type": "application/json"
73
- }, e == null ? void 0 : e.headers),
74
- body: e != null && e.body ? JSON.stringify(e.body) : void 0
75
- }), l = await fetch(i.toString(), d);
76
- if (!l.ok) {
77
- const b = new Error("API request failed.");
78
- if (b.status = l.status, b.statusText = l.statusText, b.url = i.toString(), b.headers = l.headers, b.bodyUsed = l.bodyUsed, (c = l.headers.get("Content-Type")) != null && c.includes("application/json"))
79
- try {
80
- b.body = await l.json();
81
- } catch {
82
- b.body = "Failed to parse response body.";
83
- }
84
- throw b;
85
- }
86
- if (l.status !== 204)
87
- return await l.json();
17
+ function k(s, ...e) {
18
+ return (...t) => s(...e, ...t);
88
19
  }
89
20
  /**
90
21
  * @license
91
22
  * Copyright 2019 Google LLC
92
23
  * SPDX-License-Identifier: BSD-3-Clause
93
24
  */
94
- const rt = globalThis, xt = rt.ShadowRoot && (rt.ShadyCSS === void 0 || rt.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, kt = Symbol(), Ut = /* @__PURE__ */ new WeakMap();
95
- let Jt = class {
96
- constructor(t, e, r) {
97
- if (this._$cssResult$ = !0, r !== kt) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
98
- this.cssText = t, this.t = e;
25
+ const F = globalThis, K = F.ShadowRoot && (F.ShadyCSS === void 0 || F.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Q = Symbol(), Z = /* @__PURE__ */ new WeakMap();
26
+ let ce = class {
27
+ constructor(e, t, r) {
28
+ if (this._$cssResult$ = !0, r !== Q) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
29
+ this.cssText = e, this.t = t;
99
30
  }
100
31
  get styleSheet() {
101
- let t = this.o;
102
- const e = this.t;
103
- if (xt && t === void 0) {
104
- const r = e !== void 0 && e.length === 1;
105
- r && (t = Ut.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), r && Ut.set(e, t));
32
+ let e = this.o;
33
+ const t = this.t;
34
+ if (K && e === void 0) {
35
+ const r = t !== void 0 && t.length === 1;
36
+ r && (e = Z.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), r && Z.set(t, e));
106
37
  }
107
- return t;
38
+ return e;
108
39
  }
109
40
  toString() {
110
41
  return this.cssText;
111
42
  }
112
43
  };
113
- const xe = (o) => new Jt(typeof o == "string" ? o : o + "", void 0, kt), $ = (o, ...t) => {
114
- const e = o.length === 1 ? o[0] : t.reduce((r, s, i) => r + ((n) => {
44
+ const _e = (s) => new ce(typeof s == "string" ? s : s + "", void 0, Q), q = (s, ...e) => {
45
+ const t = s.length === 1 ? s[0] : e.reduce((r, o, i) => r + ((n) => {
115
46
  if (n._$cssResult$ === !0) return n.cssText;
116
47
  if (typeof n == "number") return n;
117
48
  throw Error("Value passed to 'css' function must be a 'css' function result: " + n + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
118
- })(s) + o[i + 1], o[0]);
119
- return new Jt(e, o, kt);
120
- }, ke = (o, t) => {
121
- if (xt) o.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
122
- else for (const e of t) {
123
- const r = document.createElement("style"), s = rt.litNonce;
124
- s !== void 0 && r.setAttribute("nonce", s), r.textContent = e.cssText, o.appendChild(r);
125
- }
126
- }, Lt = xt ? (o) => o : (o) => o instanceof CSSStyleSheet ? ((t) => {
127
- let e = "";
128
- for (const r of t.cssRules) e += r.cssText;
129
- return xe(e);
130
- })(o) : o;
49
+ })(o) + s[i + 1], s[0]);
50
+ return new ce(t, s, Q);
51
+ }, Ae = (s, e) => {
52
+ if (K) s.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet);
53
+ else for (const t of e) {
54
+ const r = document.createElement("style"), o = F.litNonce;
55
+ o !== void 0 && r.setAttribute("nonce", o), r.textContent = t.cssText, s.appendChild(r);
56
+ }
57
+ }, X = K ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((e) => {
58
+ let t = "";
59
+ for (const r of e.cssRules) t += r.cssText;
60
+ return _e(t);
61
+ })(s) : s;
131
62
  /**
132
63
  * @license
133
64
  * Copyright 2017 Google LLC
134
65
  * SPDX-License-Identifier: BSD-3-Clause
135
66
  */
136
- const { is: Ce, defineProperty: Ae, getOwnPropertyDescriptor: Se, getOwnPropertyNames: Ee, getOwnPropertySymbols: Pe, getPrototypeOf: Te } = Object, A = globalThis, Ot = A.trustedTypes, ze = Ot ? Ot.emptyScript : "", lt = A.reactiveElementPolyfillSupport, q = (o, t) => o, R = { toAttribute(o, t) {
137
- switch (t) {
67
+ const { is: Ee, defineProperty: Pe, getOwnPropertyDescriptor: Se, getOwnPropertyNames: Ce, getOwnPropertySymbols: xe, getPrototypeOf: ke } = Object, $ = globalThis, ee = $.trustedTypes, Te = ee ? ee.emptyScript : "", z = $.reactiveElementPolyfillSupport, U = (s, e) => s, V = { toAttribute(s, e) {
68
+ switch (e) {
138
69
  case Boolean:
139
- o = o ? ze : null;
70
+ s = s ? Te : null;
140
71
  break;
141
72
  case Object:
142
73
  case Array:
143
- o = o == null ? o : JSON.stringify(o);
74
+ s = s == null ? s : JSON.stringify(s);
144
75
  }
145
- return o;
146
- }, fromAttribute(o, t) {
147
- let e = o;
148
- switch (t) {
76
+ return s;
77
+ }, fromAttribute(s, e) {
78
+ let t = s;
79
+ switch (e) {
149
80
  case Boolean:
150
- e = o !== null;
81
+ t = s !== null;
151
82
  break;
152
83
  case Number:
153
- e = o === null ? null : Number(o);
84
+ t = s === null ? null : Number(s);
154
85
  break;
155
86
  case Object:
156
87
  case Array:
157
88
  try {
158
- e = JSON.parse(o);
89
+ t = JSON.parse(s);
159
90
  } catch {
160
- e = null;
91
+ t = null;
161
92
  }
162
93
  }
163
- return e;
164
- } }, Ct = (o, t) => !Ce(o, t), It = { attribute: !0, type: String, converter: R, reflect: !1, hasChanged: Ct };
165
- Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), A.litPropertyMetadata ?? (A.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
166
- class I extends HTMLElement {
167
- static addInitializer(t) {
168
- this._$Ei(), (this.l ?? (this.l = [])).push(t);
94
+ return t;
95
+ } }, de = (s, e) => !Ee(s, e), te = { attribute: !0, type: String, converter: V, reflect: !1, hasChanged: de };
96
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), $.litPropertyMetadata ?? ($.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
97
+ class P extends HTMLElement {
98
+ static addInitializer(e) {
99
+ this._$Ei(), (this.l ?? (this.l = [])).push(e);
169
100
  }
170
101
  static get observedAttributes() {
171
102
  return this.finalize(), this._$Eh && [...this._$Eh.keys()];
172
103
  }
173
- static createProperty(t, e = It) {
174
- if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
175
- const r = Symbol(), s = this.getPropertyDescriptor(t, r, e);
176
- s !== void 0 && Ae(this.prototype, t, s);
104
+ static createProperty(e, t = te) {
105
+ if (t.state && (t.attribute = !1), this._$Ei(), this.elementProperties.set(e, t), !t.noAccessor) {
106
+ const r = Symbol(), o = this.getPropertyDescriptor(e, r, t);
107
+ o !== void 0 && Pe(this.prototype, e, o);
177
108
  }
178
109
  }
179
- static getPropertyDescriptor(t, e, r) {
180
- const { get: s, set: i } = Se(this.prototype, t) ?? { get() {
181
- return this[e];
110
+ static getPropertyDescriptor(e, t, r) {
111
+ const { get: o, set: i } = Se(this.prototype, e) ?? { get() {
112
+ return this[t];
182
113
  }, set(n) {
183
- this[e] = n;
114
+ this[t] = n;
184
115
  } };
185
116
  return { get() {
186
- return s == null ? void 0 : s.call(this);
117
+ return o == null ? void 0 : o.call(this);
187
118
  }, set(n) {
188
- const d = s == null ? void 0 : s.call(this);
189
- i.call(this, n), this.requestUpdate(t, d, r);
119
+ const l = o == null ? void 0 : o.call(this);
120
+ i.call(this, n), this.requestUpdate(e, l, r);
190
121
  }, configurable: !0, enumerable: !0 };
191
122
  }
192
- static getPropertyOptions(t) {
193
- return this.elementProperties.get(t) ?? It;
123
+ static getPropertyOptions(e) {
124
+ return this.elementProperties.get(e) ?? te;
194
125
  }
195
126
  static _$Ei() {
196
- if (this.hasOwnProperty(q("elementProperties"))) return;
197
- const t = Te(this);
198
- t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
127
+ if (this.hasOwnProperty(U("elementProperties"))) return;
128
+ const e = ke(this);
129
+ e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
199
130
  }
200
131
  static finalize() {
201
- if (this.hasOwnProperty(q("finalized"))) return;
202
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(q("properties"))) {
203
- const e = this.properties, r = [...Ee(e), ...Pe(e)];
204
- for (const s of r) this.createProperty(s, e[s]);
132
+ if (this.hasOwnProperty(U("finalized"))) return;
133
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(U("properties"))) {
134
+ const t = this.properties, r = [...Ce(t), ...xe(t)];
135
+ for (const o of r) this.createProperty(o, t[o]);
205
136
  }
206
- const t = this[Symbol.metadata];
207
- if (t !== null) {
208
- const e = litPropertyMetadata.get(t);
209
- if (e !== void 0) for (const [r, s] of e) this.elementProperties.set(r, s);
137
+ const e = this[Symbol.metadata];
138
+ if (e !== null) {
139
+ const t = litPropertyMetadata.get(e);
140
+ if (t !== void 0) for (const [r, o] of t) this.elementProperties.set(r, o);
210
141
  }
211
142
  this._$Eh = /* @__PURE__ */ new Map();
212
- for (const [e, r] of this.elementProperties) {
213
- const s = this._$Eu(e, r);
214
- s !== void 0 && this._$Eh.set(s, e);
143
+ for (const [t, r] of this.elementProperties) {
144
+ const o = this._$Eu(t, r);
145
+ o !== void 0 && this._$Eh.set(o, t);
215
146
  }
216
147
  this.elementStyles = this.finalizeStyles(this.styles);
217
148
  }
218
- static finalizeStyles(t) {
219
- const e = [];
220
- if (Array.isArray(t)) {
221
- const r = new Set(t.flat(1 / 0).reverse());
222
- for (const s of r) e.unshift(Lt(s));
223
- } else t !== void 0 && e.push(Lt(t));
224
- return e;
149
+ static finalizeStyles(e) {
150
+ const t = [];
151
+ if (Array.isArray(e)) {
152
+ const r = new Set(e.flat(1 / 0).reverse());
153
+ for (const o of r) t.unshift(X(o));
154
+ } else e !== void 0 && t.push(X(e));
155
+ return t;
225
156
  }
226
- static _$Eu(t, e) {
227
- const r = e.attribute;
228
- return r === !1 ? void 0 : typeof r == "string" ? r : typeof t == "string" ? t.toLowerCase() : void 0;
157
+ static _$Eu(e, t) {
158
+ const r = t.attribute;
159
+ return r === !1 ? void 0 : typeof r == "string" ? r : typeof e == "string" ? e.toLowerCase() : void 0;
229
160
  }
230
161
  constructor() {
231
162
  super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
232
163
  }
233
164
  _$Ev() {
234
- var t;
235
- this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
236
- }
237
- addController(t) {
238
165
  var e;
239
- (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
166
+ this._$ES = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (e = this.constructor.l) == null || e.forEach((t) => t(this));
240
167
  }
241
- removeController(t) {
242
- var e;
243
- (e = this._$EO) == null || e.delete(t);
168
+ addController(e) {
169
+ var t;
170
+ (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(e), this.renderRoot !== void 0 && this.isConnected && ((t = e.hostConnected) == null || t.call(e));
171
+ }
172
+ removeController(e) {
173
+ var t;
174
+ (t = this._$EO) == null || t.delete(e);
244
175
  }
245
176
  _$E_() {
246
- const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
247
- for (const r of e.keys()) this.hasOwnProperty(r) && (t.set(r, this[r]), delete this[r]);
248
- t.size > 0 && (this._$Ep = t);
177
+ const e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
178
+ for (const r of t.keys()) this.hasOwnProperty(r) && (e.set(r, this[r]), delete this[r]);
179
+ e.size > 0 && (this._$Ep = e);
249
180
  }
250
181
  createRenderRoot() {
251
- const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
252
- return ke(t, this.constructor.elementStyles), t;
182
+ const e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
183
+ return Ae(e, this.constructor.elementStyles), e;
253
184
  }
254
185
  connectedCallback() {
255
- var t;
256
- this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
186
+ var e;
187
+ this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (e = this._$EO) == null || e.forEach((t) => {
257
188
  var r;
258
- return (r = e.hostConnected) == null ? void 0 : r.call(e);
189
+ return (r = t.hostConnected) == null ? void 0 : r.call(t);
259
190
  });
260
191
  }
261
- enableUpdating(t) {
192
+ enableUpdating(e) {
262
193
  }
263
194
  disconnectedCallback() {
264
- var t;
265
- (t = this._$EO) == null || t.forEach((e) => {
195
+ var e;
196
+ (e = this._$EO) == null || e.forEach((t) => {
266
197
  var r;
267
- return (r = e.hostDisconnected) == null ? void 0 : r.call(e);
198
+ return (r = t.hostDisconnected) == null ? void 0 : r.call(t);
268
199
  });
269
200
  }
270
- attributeChangedCallback(t, e, r) {
271
- this._$AK(t, r);
201
+ attributeChangedCallback(e, t, r) {
202
+ this._$AK(e, r);
272
203
  }
273
- _$EC(t, e) {
204
+ _$EC(e, t) {
274
205
  var i;
275
- const r = this.constructor.elementProperties.get(t), s = this.constructor._$Eu(t, r);
276
- if (s !== void 0 && r.reflect === !0) {
277
- const n = (((i = r.converter) == null ? void 0 : i.toAttribute) !== void 0 ? r.converter : R).toAttribute(e, r.type);
278
- this._$Em = t, n == null ? this.removeAttribute(s) : this.setAttribute(s, n), this._$Em = null;
206
+ const r = this.constructor.elementProperties.get(e), o = this.constructor._$Eu(e, r);
207
+ if (o !== void 0 && r.reflect === !0) {
208
+ const n = (((i = r.converter) == null ? void 0 : i.toAttribute) !== void 0 ? r.converter : V).toAttribute(t, r.type);
209
+ this._$Em = e, n == null ? this.removeAttribute(o) : this.setAttribute(o, n), this._$Em = null;
279
210
  }
280
211
  }
281
- _$AK(t, e) {
212
+ _$AK(e, t) {
282
213
  var i;
283
- const r = this.constructor, s = r._$Eh.get(t);
284
- if (s !== void 0 && this._$Em !== s) {
285
- const n = r.getPropertyOptions(s), d = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((i = n.converter) == null ? void 0 : i.fromAttribute) !== void 0 ? n.converter : R;
286
- this._$Em = s, this[s] = d.fromAttribute(e, n.type), this._$Em = null;
214
+ const r = this.constructor, o = r._$Eh.get(e);
215
+ if (o !== void 0 && this._$Em !== o) {
216
+ const n = r.getPropertyOptions(o), l = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((i = n.converter) == null ? void 0 : i.fromAttribute) !== void 0 ? n.converter : V;
217
+ this._$Em = o, this[o] = l.fromAttribute(t, n.type), this._$Em = null;
287
218
  }
288
219
  }
289
- requestUpdate(t, e, r) {
290
- if (t !== void 0) {
291
- if (r ?? (r = this.constructor.getPropertyOptions(t)), !(r.hasChanged ?? Ct)(this[t], e)) return;
292
- this.P(t, e, r);
220
+ requestUpdate(e, t, r) {
221
+ if (e !== void 0) {
222
+ if (r ?? (r = this.constructor.getPropertyOptions(e)), !(r.hasChanged ?? de)(this[e], t)) return;
223
+ this.P(e, t, r);
293
224
  }
294
225
  this.isUpdatePending === !1 && (this._$ES = this._$ET());
295
226
  }
296
- P(t, e, r) {
297
- this._$AL.has(t) || this._$AL.set(t, e), r.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
227
+ P(e, t, r) {
228
+ this._$AL.has(e) || this._$AL.set(e, t), r.reflect === !0 && this._$Em !== e && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(e);
298
229
  }
299
230
  async _$ET() {
300
231
  this.isUpdatePending = !0;
301
232
  try {
302
233
  await this._$ES;
303
- } catch (e) {
304
- Promise.reject(e);
234
+ } catch (t) {
235
+ Promise.reject(t);
305
236
  }
306
- const t = this.scheduleUpdate();
307
- return t != null && await t, !this.isUpdatePending;
237
+ const e = this.scheduleUpdate();
238
+ return e != null && await e, !this.isUpdatePending;
308
239
  }
309
240
  scheduleUpdate() {
310
241
  return this.performUpdate();
@@ -317,29 +248,29 @@ class I extends HTMLElement {
317
248
  for (const [i, n] of this._$Ep) this[i] = n;
318
249
  this._$Ep = void 0;
319
250
  }
320
- const s = this.constructor.elementProperties;
321
- if (s.size > 0) for (const [i, n] of s) n.wrapped !== !0 || this._$AL.has(i) || this[i] === void 0 || this.P(i, this[i], n);
251
+ const o = this.constructor.elementProperties;
252
+ if (o.size > 0) for (const [i, n] of o) n.wrapped !== !0 || this._$AL.has(i) || this[i] === void 0 || this.P(i, this[i], n);
322
253
  }
323
- let t = !1;
324
- const e = this._$AL;
254
+ let e = !1;
255
+ const t = this._$AL;
325
256
  try {
326
- t = this.shouldUpdate(e), t ? (this.willUpdate(e), (r = this._$EO) == null || r.forEach((s) => {
257
+ e = this.shouldUpdate(t), e ? (this.willUpdate(t), (r = this._$EO) == null || r.forEach((o) => {
327
258
  var i;
328
- return (i = s.hostUpdate) == null ? void 0 : i.call(s);
329
- }), this.update(e)) : this._$EU();
330
- } catch (s) {
331
- throw t = !1, this._$EU(), s;
259
+ return (i = o.hostUpdate) == null ? void 0 : i.call(o);
260
+ }), this.update(t)) : this._$EU();
261
+ } catch (o) {
262
+ throw e = !1, this._$EU(), o;
332
263
  }
333
- t && this._$AE(e);
264
+ e && this._$AE(t);
334
265
  }
335
- willUpdate(t) {
266
+ willUpdate(e) {
336
267
  }
337
- _$AE(t) {
338
- var e;
339
- (e = this._$EO) == null || e.forEach((r) => {
340
- var s;
341
- return (s = r.hostUpdated) == null ? void 0 : s.call(r);
342
- }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
268
+ _$AE(e) {
269
+ var t;
270
+ (t = this._$EO) == null || t.forEach((r) => {
271
+ var o;
272
+ return (o = r.hostUpdated) == null ? void 0 : o.call(r);
273
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
343
274
  }
344
275
  _$EU() {
345
276
  this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
@@ -350,89 +281,89 @@ class I extends HTMLElement {
350
281
  getUpdateComplete() {
351
282
  return this._$ES;
352
283
  }
353
- shouldUpdate(t) {
284
+ shouldUpdate(e) {
354
285
  return !0;
355
286
  }
356
- update(t) {
357
- this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
287
+ update(e) {
288
+ this._$Ej && (this._$Ej = this._$Ej.forEach((t) => this._$EC(t, this[t]))), this._$EU();
358
289
  }
359
- updated(t) {
290
+ updated(e) {
360
291
  }
361
- firstUpdated(t) {
292
+ firstUpdated(e) {
362
293
  }
363
294
  }
364
- I.elementStyles = [], I.shadowRootOptions = { mode: "open" }, I[q("elementProperties")] = /* @__PURE__ */ new Map(), I[q("finalized")] = /* @__PURE__ */ new Map(), lt == null || lt({ ReactiveElement: I }), (A.reactiveElementVersions ?? (A.reactiveElementVersions = [])).push("2.0.4");
295
+ P.elementStyles = [], P.shadowRootOptions = { mode: "open" }, P[U("elementProperties")] = /* @__PURE__ */ new Map(), P[U("finalized")] = /* @__PURE__ */ new Map(), z == null || z({ ReactiveElement: P }), ($.reactiveElementVersions ?? ($.reactiveElementVersions = [])).push("2.0.4");
365
296
  /**
366
297
  * @license
367
298
  * Copyright 2017 Google LLC
368
299
  * SPDX-License-Identifier: BSD-3-Clause
369
300
  */
370
- const W = globalThis, st = W.trustedTypes, Vt = st ? st.createPolicy("lit-html", { createHTML: (o) => o }) : void 0, Gt = "$lit$", C = `lit$${Math.random().toFixed(9).slice(2)}$`, Qt = "?" + C, Ue = `<${Qt}>`, L = document, Z = () => L.createComment(""), Y = (o) => o === null || typeof o != "object" && typeof o != "function", At = Array.isArray, Le = (o) => At(o) || typeof (o == null ? void 0 : o[Symbol.iterator]) == "function", ut = `[
371
- \f\r]`, N = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Rt = /-->/g, Bt = />/g, P = RegExp(`>|${ut}(?:([^\\s"'>=/]+)(${ut}*=${ut}*(?:[^
372
- \f\r"'\`<>=]|("|')|))|$)`, "g"), Mt = /'/g, Nt = /"/g, Xt = /^(?:script|style|textarea|title)$/i, Oe = (o) => (t, ...e) => ({ _$litType$: o, strings: t, values: e }), v = Oe(1), w = Symbol.for("lit-noChange"), g = Symbol.for("lit-nothing"), Dt = /* @__PURE__ */ new WeakMap(), U = L.createTreeWalker(L, 129);
373
- function te(o, t) {
374
- if (!At(o) || !o.hasOwnProperty("raw")) throw Error("invalid template strings array");
375
- return Vt !== void 0 ? Vt.createHTML(t) : t;
301
+ const R = globalThis, M = R.trustedTypes, re = M ? M.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, he = "$lit$", w = `lit$${Math.random().toFixed(9).slice(2)}$`, ue = "?" + w, Ue = `<${ue}>`, A = document, O = () => A.createComment(""), N = (s) => s === null || typeof s != "object" && typeof s != "function", J = Array.isArray, Re = (s) => J(s) || typeof (s == null ? void 0 : s[Symbol.iterator]) == "function", j = `[
302
+ \f\r]`, T = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, se = /-->/g, oe = />/g, v = RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^
303
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), ie = /'/g, ne = /"/g, pe = /^(?:script|style|textarea|title)$/i, Oe = (s) => (e, ...t) => ({ _$litType$: s, strings: e, values: t }), c = Oe(1), S = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), ae = /* @__PURE__ */ new WeakMap(), _ = A.createTreeWalker(A, 129);
304
+ function me(s, e) {
305
+ if (!J(s) || !s.hasOwnProperty("raw")) throw Error("invalid template strings array");
306
+ return re !== void 0 ? re.createHTML(e) : e;
376
307
  }
377
- const Ie = (o, t) => {
378
- const e = o.length - 1, r = [];
379
- let s, i = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", n = N;
380
- for (let d = 0; d < e; d++) {
381
- const l = o[d];
382
- let c, b, p = -1, _ = 0;
383
- for (; _ < l.length && (n.lastIndex = _, b = n.exec(l), b !== null); ) _ = n.lastIndex, n === N ? b[1] === "!--" ? n = Rt : b[1] !== void 0 ? n = Bt : b[2] !== void 0 ? (Xt.test(b[2]) && (s = RegExp("</" + b[2], "g")), n = P) : b[3] !== void 0 && (n = P) : n === P ? b[0] === ">" ? (n = s ?? N, p = -1) : b[1] === void 0 ? p = -2 : (p = n.lastIndex - b[2].length, c = b[1], n = b[3] === void 0 ? P : b[3] === '"' ? Nt : Mt) : n === Nt || n === Mt ? n = P : n === Rt || n === Bt ? n = N : (n = P, s = void 0);
384
- const y = n === P && o[d + 1].startsWith("/>") ? " " : "";
385
- i += n === N ? l + Ue : p >= 0 ? (r.push(c), l.slice(0, p) + Gt + l.slice(p) + C + y) : l + C + (p === -2 ? d : y);
386
- }
387
- return [te(o, i + (o[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
308
+ const Ne = (s, e) => {
309
+ const t = s.length - 1, r = [];
310
+ let o, i = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", n = T;
311
+ for (let l = 0; l < t; l++) {
312
+ const a = s[l];
313
+ let u, d, h = -1, m = 0;
314
+ for (; m < a.length && (n.lastIndex = m, d = n.exec(a), d !== null); ) m = n.lastIndex, n === T ? d[1] === "!--" ? n = se : d[1] !== void 0 ? n = oe : d[2] !== void 0 ? (pe.test(d[2]) && (o = RegExp("</" + d[2], "g")), n = v) : d[3] !== void 0 && (n = v) : n === v ? d[0] === ">" ? (n = o ?? T, h = -1) : d[1] === void 0 ? h = -2 : (h = n.lastIndex - d[2].length, u = d[1], n = d[3] === void 0 ? v : d[3] === '"' ? ne : ie) : n === ne || n === ie ? n = v : n === se || n === oe ? n = T : (n = v, o = void 0);
315
+ const f = n === v && s[l + 1].startsWith("/>") ? " " : "";
316
+ i += n === T ? a + Ue : h >= 0 ? (r.push(u), a.slice(0, h) + he + a.slice(h) + w + f) : a + w + (h === -2 ? l : f);
317
+ }
318
+ return [me(s, i + (s[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), r];
388
319
  };
389
- class J {
390
- constructor({ strings: t, _$litType$: e }, r) {
391
- let s;
320
+ class H {
321
+ constructor({ strings: e, _$litType$: t }, r) {
322
+ let o;
392
323
  this.parts = [];
393
324
  let i = 0, n = 0;
394
- const d = t.length - 1, l = this.parts, [c, b] = Ie(t, e);
395
- if (this.el = J.createElement(c, r), U.currentNode = this.el.content, e === 2 || e === 3) {
396
- const p = this.el.content.firstChild;
397
- p.replaceWith(...p.childNodes);
325
+ const l = e.length - 1, a = this.parts, [u, d] = Ne(e, t);
326
+ if (this.el = H.createElement(u, r), _.currentNode = this.el.content, t === 2 || t === 3) {
327
+ const h = this.el.content.firstChild;
328
+ h.replaceWith(...h.childNodes);
398
329
  }
399
- for (; (s = U.nextNode()) !== null && l.length < d; ) {
400
- if (s.nodeType === 1) {
401
- if (s.hasAttributes()) for (const p of s.getAttributeNames()) if (p.endsWith(Gt)) {
402
- const _ = b[n++], y = s.getAttribute(p).split(C), tt = /([.?@])?(.*)/.exec(_);
403
- l.push({ type: 1, index: i, name: tt[2], strings: y, ctor: tt[1] === "." ? Re : tt[1] === "?" ? Be : tt[1] === "@" ? Me : nt }), s.removeAttribute(p);
404
- } else p.startsWith(C) && (l.push({ type: 6, index: i }), s.removeAttribute(p));
405
- if (Xt.test(s.tagName)) {
406
- const p = s.textContent.split(C), _ = p.length - 1;
407
- if (_ > 0) {
408
- s.textContent = st ? st.emptyScript : "";
409
- for (let y = 0; y < _; y++) s.append(p[y], Z()), U.nextNode(), l.push({ type: 2, index: ++i });
410
- s.append(p[_], Z());
330
+ for (; (o = _.nextNode()) !== null && a.length < l; ) {
331
+ if (o.nodeType === 1) {
332
+ if (o.hasAttributes()) for (const h of o.getAttributeNames()) if (h.endsWith(he)) {
333
+ const m = d[n++], f = o.getAttribute(h).split(w), L = /([.?@])?(.*)/.exec(m);
334
+ a.push({ type: 1, index: i, name: L[2], strings: f, ctor: L[1] === "." ? qe : L[1] === "?" ? De : L[1] === "@" ? Le : I }), o.removeAttribute(h);
335
+ } else h.startsWith(w) && (a.push({ type: 6, index: i }), o.removeAttribute(h));
336
+ if (pe.test(o.tagName)) {
337
+ const h = o.textContent.split(w), m = h.length - 1;
338
+ if (m > 0) {
339
+ o.textContent = M ? M.emptyScript : "";
340
+ for (let f = 0; f < m; f++) o.append(h[f], O()), _.nextNode(), a.push({ type: 2, index: ++i });
341
+ o.append(h[m], O());
411
342
  }
412
343
  }
413
- } else if (s.nodeType === 8) if (s.data === Qt) l.push({ type: 2, index: i });
344
+ } else if (o.nodeType === 8) if (o.data === ue) a.push({ type: 2, index: i });
414
345
  else {
415
- let p = -1;
416
- for (; (p = s.data.indexOf(C, p + 1)) !== -1; ) l.push({ type: 7, index: i }), p += C.length - 1;
346
+ let h = -1;
347
+ for (; (h = o.data.indexOf(w, h + 1)) !== -1; ) a.push({ type: 7, index: i }), h += w.length - 1;
417
348
  }
418
349
  i++;
419
350
  }
420
351
  }
421
- static createElement(t, e) {
422
- const r = L.createElement("template");
423
- return r.innerHTML = t, r;
352
+ static createElement(e, t) {
353
+ const r = A.createElement("template");
354
+ return r.innerHTML = e, r;
424
355
  }
425
356
  }
426
- function B(o, t, e = o, r) {
427
- var n, d;
428
- if (t === w) return t;
429
- let s = r !== void 0 ? (n = e.o) == null ? void 0 : n[r] : e.l;
430
- const i = Y(t) ? void 0 : t._$litDirective$;
431
- return (s == null ? void 0 : s.constructor) !== i && ((d = s == null ? void 0 : s._$AO) == null || d.call(s, !1), i === void 0 ? s = void 0 : (s = new i(o), s._$AT(o, e, r)), r !== void 0 ? (e.o ?? (e.o = []))[r] = s : e.l = s), s !== void 0 && (t = B(o, s._$AS(o, t.values), s, r)), t;
357
+ function C(s, e, t = s, r) {
358
+ var n, l;
359
+ if (e === S) return e;
360
+ let o = r !== void 0 ? (n = t._$Co) == null ? void 0 : n[r] : t._$Cl;
361
+ const i = N(e) ? void 0 : e._$litDirective$;
362
+ return (o == null ? void 0 : o.constructor) !== i && ((l = o == null ? void 0 : o._$AO) == null || l.call(o, !1), i === void 0 ? o = void 0 : (o = new i(s), o._$AT(s, t, r)), r !== void 0 ? (t._$Co ?? (t._$Co = []))[r] = o : t._$Cl = o), o !== void 0 && (e = C(s, o._$AS(s, e.values), o, r)), e;
432
363
  }
433
- class Ve {
434
- constructor(t, e) {
435
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
364
+ class He {
365
+ constructor(e, t) {
366
+ this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
436
367
  }
437
368
  get parentNode() {
438
369
  return this._$AM.parentNode;
@@ -440,36 +371,36 @@ class Ve {
440
371
  get _$AU() {
441
372
  return this._$AM._$AU;
442
373
  }
443
- u(t) {
444
- const { el: { content: e }, parts: r } = this._$AD, s = ((t == null ? void 0 : t.creationScope) ?? L).importNode(e, !0);
445
- U.currentNode = s;
446
- let i = U.nextNode(), n = 0, d = 0, l = r[0];
447
- for (; l !== void 0; ) {
448
- if (n === l.index) {
449
- let c;
450
- l.type === 2 ? c = new G(i, i.nextSibling, this, t) : l.type === 1 ? c = new l.ctor(i, l.name, l.strings, this, t) : l.type === 6 && (c = new Ne(i, this, t)), this._$AV.push(c), l = r[++d];
374
+ u(e) {
375
+ const { el: { content: t }, parts: r } = this._$AD, o = ((e == null ? void 0 : e.creationScope) ?? A).importNode(t, !0);
376
+ _.currentNode = o;
377
+ let i = _.nextNode(), n = 0, l = 0, a = r[0];
378
+ for (; a !== void 0; ) {
379
+ if (n === a.index) {
380
+ let u;
381
+ a.type === 2 ? u = new D(i, i.nextSibling, this, e) : a.type === 1 ? u = new a.ctor(i, a.name, a.strings, this, e) : a.type === 6 && (u = new Fe(i, this, e)), this._$AV.push(u), a = r[++l];
451
382
  }
452
- n !== (l == null ? void 0 : l.index) && (i = U.nextNode(), n++);
383
+ n !== (a == null ? void 0 : a.index) && (i = _.nextNode(), n++);
453
384
  }
454
- return U.currentNode = L, s;
385
+ return _.currentNode = A, o;
455
386
  }
456
- p(t) {
457
- let e = 0;
458
- for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(t, r, e), e += r.strings.length - 2) : r._$AI(t[e])), e++;
387
+ p(e) {
388
+ let t = 0;
389
+ for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(e, r, t), t += r.strings.length - 2) : r._$AI(e[t])), t++;
459
390
  }
460
391
  }
461
- class G {
392
+ class D {
462
393
  get _$AU() {
463
- var t;
464
- return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this.v;
394
+ var e;
395
+ return ((e = this._$AM) == null ? void 0 : e._$AU) ?? this._$Cv;
465
396
  }
466
- constructor(t, e, r, s) {
467
- this.type = 2, this._$AH = g, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = r, this.options = s, this.v = (s == null ? void 0 : s.isConnected) ?? !0;
397
+ constructor(e, t, r, o) {
398
+ this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = r, this.options = o, this._$Cv = (o == null ? void 0 : o.isConnected) ?? !0;
468
399
  }
469
400
  get parentNode() {
470
- let t = this._$AA.parentNode;
471
- const e = this._$AM;
472
- return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
401
+ let e = this._$AA.parentNode;
402
+ const t = this._$AM;
403
+ return t !== void 0 && (e == null ? void 0 : e.nodeType) === 11 && (e = t.parentNode), e;
473
404
  }
474
405
  get startNode() {
475
406
  return this._$AA;
@@ -477,2903 +408,971 @@ class G {
477
408
  get endNode() {
478
409
  return this._$AB;
479
410
  }
480
- _$AI(t, e = this) {
481
- t = B(this, t, e), Y(t) ? t === g || t == null || t === "" ? (this._$AH !== g && this._$AR(), this._$AH = g) : t !== this._$AH && t !== w && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Le(t) ? this.k(t) : this._(t);
411
+ _$AI(e, t = this) {
412
+ e = C(this, e, t), N(e) ? e === p || e == null || e === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : e !== this._$AH && e !== S && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : Re(e) ? this.k(e) : this._(e);
482
413
  }
483
- O(t) {
484
- return this._$AA.parentNode.insertBefore(t, this._$AB);
414
+ O(e) {
415
+ return this._$AA.parentNode.insertBefore(e, this._$AB);
485
416
  }
486
- T(t) {
487
- this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
417
+ T(e) {
418
+ this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
488
419
  }
489
- _(t) {
490
- this._$AH !== g && Y(this._$AH) ? this._$AA.nextSibling.data = t : this.T(L.createTextNode(t)), this._$AH = t;
420
+ _(e) {
421
+ this._$AH !== p && N(this._$AH) ? this._$AA.nextSibling.data = e : this.T(A.createTextNode(e)), this._$AH = e;
491
422
  }
492
- $(t) {
423
+ $(e) {
493
424
  var i;
494
- const { values: e, _$litType$: r } = t, s = typeof r == "number" ? this._$AC(t) : (r.el === void 0 && (r.el = J.createElement(te(r.h, r.h[0]), this.options)), r);
495
- if (((i = this._$AH) == null ? void 0 : i._$AD) === s) this._$AH.p(e);
425
+ const { values: t, _$litType$: r } = e, o = typeof r == "number" ? this._$AC(e) : (r.el === void 0 && (r.el = H.createElement(me(r.h, r.h[0]), this.options)), r);
426
+ if (((i = this._$AH) == null ? void 0 : i._$AD) === o) this._$AH.p(t);
496
427
  else {
497
- const n = new Ve(s, this), d = n.u(this.options);
498
- n.p(e), this.T(d), this._$AH = n;
428
+ const n = new He(o, this), l = n.u(this.options);
429
+ n.p(t), this.T(l), this._$AH = n;
499
430
  }
500
431
  }
501
- _$AC(t) {
502
- let e = Dt.get(t.strings);
503
- return e === void 0 && Dt.set(t.strings, e = new J(t)), e;
432
+ _$AC(e) {
433
+ let t = ae.get(e.strings);
434
+ return t === void 0 && ae.set(e.strings, t = new H(e)), t;
504
435
  }
505
- k(t) {
506
- At(this._$AH) || (this._$AH = [], this._$AR());
507
- const e = this._$AH;
508
- let r, s = 0;
509
- for (const i of t) s === e.length ? e.push(r = new G(this.O(Z()), this.O(Z()), this, this.options)) : r = e[s], r._$AI(i), s++;
510
- s < e.length && (this._$AR(r && r._$AB.nextSibling, s), e.length = s);
436
+ k(e) {
437
+ J(this._$AH) || (this._$AH = [], this._$AR());
438
+ const t = this._$AH;
439
+ let r, o = 0;
440
+ for (const i of e) o === t.length ? t.push(r = new D(this.O(O()), this.O(O()), this, this.options)) : r = t[o], r._$AI(i), o++;
441
+ o < t.length && (this._$AR(r && r._$AB.nextSibling, o), t.length = o);
511
442
  }
512
- _$AR(t = this._$AA.nextSibling, e) {
443
+ _$AR(e = this._$AA.nextSibling, t) {
513
444
  var r;
514
- for ((r = this._$AP) == null ? void 0 : r.call(this, !1, !0, e); t && t !== this._$AB; ) {
515
- const s = t.nextSibling;
516
- t.remove(), t = s;
445
+ for ((r = this._$AP) == null ? void 0 : r.call(this, !1, !0, t); e && e !== this._$AB; ) {
446
+ const o = e.nextSibling;
447
+ e.remove(), e = o;
517
448
  }
518
449
  }
519
- setConnected(t) {
520
- var e;
521
- this._$AM === void 0 && (this.v = t, (e = this._$AP) == null || e.call(this, t));
450
+ setConnected(e) {
451
+ var t;
452
+ this._$AM === void 0 && (this._$Cv = e, (t = this._$AP) == null || t.call(this, e));
522
453
  }
523
454
  }
524
- class nt {
455
+ class I {
525
456
  get tagName() {
526
457
  return this.element.tagName;
527
458
  }
528
459
  get _$AU() {
529
460
  return this._$AM._$AU;
530
461
  }
531
- constructor(t, e, r, s, i) {
532
- this.type = 1, this._$AH = g, this._$AN = void 0, this.element = t, this.name = e, this._$AM = s, this.options = i, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = g;
462
+ constructor(e, t, r, o, i) {
463
+ this.type = 1, this._$AH = p, this._$AN = void 0, this.element = e, this.name = t, this._$AM = o, this.options = i, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = p;
533
464
  }
534
- _$AI(t, e = this, r, s) {
465
+ _$AI(e, t = this, r, o) {
535
466
  const i = this.strings;
536
467
  let n = !1;
537
- if (i === void 0) t = B(this, t, e, 0), n = !Y(t) || t !== this._$AH && t !== w, n && (this._$AH = t);
468
+ if (i === void 0) e = C(this, e, t, 0), n = !N(e) || e !== this._$AH && e !== S, n && (this._$AH = e);
538
469
  else {
539
- const d = t;
540
- let l, c;
541
- for (t = i[0], l = 0; l < i.length - 1; l++) c = B(this, d[r + l], e, l), c === w && (c = this._$AH[l]), n || (n = !Y(c) || c !== this._$AH[l]), c === g ? t = g : t !== g && (t += (c ?? "") + i[l + 1]), this._$AH[l] = c;
470
+ const l = e;
471
+ let a, u;
472
+ for (e = i[0], a = 0; a < i.length - 1; a++) u = C(this, l[r + a], t, a), u === S && (u = this._$AH[a]), n || (n = !N(u) || u !== this._$AH[a]), u === p ? e = p : e !== p && (e += (u ?? "") + i[a + 1]), this._$AH[a] = u;
542
473
  }
543
- n && !s && this.j(t);
474
+ n && !o && this.j(e);
544
475
  }
545
- j(t) {
546
- t === g ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
476
+ j(e) {
477
+ e === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
547
478
  }
548
479
  }
549
- class Re extends nt {
480
+ class qe extends I {
550
481
  constructor() {
551
482
  super(...arguments), this.type = 3;
552
483
  }
553
- j(t) {
554
- this.element[this.name] = t === g ? void 0 : t;
484
+ j(e) {
485
+ this.element[this.name] = e === p ? void 0 : e;
555
486
  }
556
487
  }
557
- class Be extends nt {
488
+ class De extends I {
558
489
  constructor() {
559
490
  super(...arguments), this.type = 4;
560
491
  }
561
- j(t) {
562
- this.element.toggleAttribute(this.name, !!t && t !== g);
492
+ j(e) {
493
+ this.element.toggleAttribute(this.name, !!e && e !== p);
563
494
  }
564
495
  }
565
- class Me extends nt {
566
- constructor(t, e, r, s, i) {
567
- super(t, e, r, s, i), this.type = 5;
496
+ class Le extends I {
497
+ constructor(e, t, r, o, i) {
498
+ super(e, t, r, o, i), this.type = 5;
568
499
  }
569
- _$AI(t, e = this) {
570
- if ((t = B(this, t, e, 0) ?? g) === w) return;
571
- const r = this._$AH, s = t === g && r !== g || t.capture !== r.capture || t.once !== r.once || t.passive !== r.passive, i = t !== g && (r === g || s);
572
- s && this.element.removeEventListener(this.name, this, r), i && this.element.addEventListener(this.name, this, t), this._$AH = t;
500
+ _$AI(e, t = this) {
501
+ if ((e = C(this, e, t, 0) ?? p) === S) return;
502
+ const r = this._$AH, o = e === p && r !== p || e.capture !== r.capture || e.once !== r.once || e.passive !== r.passive, i = e !== p && (r === p || o);
503
+ o && this.element.removeEventListener(this.name, this, r), i && this.element.addEventListener(this.name, this, e), this._$AH = e;
573
504
  }
574
- handleEvent(t) {
575
- var e;
576
- typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
505
+ handleEvent(e) {
506
+ var t;
507
+ typeof this._$AH == "function" ? this._$AH.call(((t = this.options) == null ? void 0 : t.host) ?? this.element, e) : this._$AH.handleEvent(e);
577
508
  }
578
509
  }
579
- class Ne {
580
- constructor(t, e, r) {
581
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = r;
510
+ class Fe {
511
+ constructor(e, t, r) {
512
+ this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = r;
582
513
  }
583
514
  get _$AU() {
584
515
  return this._$AM._$AU;
585
516
  }
586
- _$AI(t) {
587
- B(this, t);
517
+ _$AI(e) {
518
+ C(this, e);
588
519
  }
589
520
  }
590
- const dt = W.litHtmlPolyfillSupport;
591
- dt == null || dt(J, G), (W.litHtmlVersions ?? (W.litHtmlVersions = [])).push("3.2.0");
592
- const De = (o, t, e) => {
593
- const r = (e == null ? void 0 : e.renderBefore) ?? t;
594
- let s = r._$litPart$;
595
- if (s === void 0) {
596
- const i = (e == null ? void 0 : e.renderBefore) ?? null;
597
- r._$litPart$ = s = new G(t.insertBefore(Z(), i), i, void 0, e ?? {});
598
- }
599
- return s._$AI(o), s;
521
+ const W = R.litHtmlPolyfillSupport;
522
+ W == null || W(H, D), (R.litHtmlVersions ?? (R.litHtmlVersions = [])).push("3.2.1");
523
+ const Me = (s, e, t) => {
524
+ const r = (t == null ? void 0 : t.renderBefore) ?? e;
525
+ let o = r._$litPart$;
526
+ if (o === void 0) {
527
+ const i = (t == null ? void 0 : t.renderBefore) ?? null;
528
+ r._$litPart$ = o = new D(e.insertBefore(O(), i), i, void 0, t ?? {});
529
+ }
530
+ return o._$AI(s), o;
600
531
  };
601
532
  /**
602
533
  * @license
603
534
  * Copyright 2017 Google LLC
604
535
  * SPDX-License-Identifier: BSD-3-Clause
605
536
  */
606
- class S extends I {
537
+ class b extends P {
607
538
  constructor() {
608
- super(...arguments), this.renderOptions = { host: this }, this.o = void 0;
539
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
609
540
  }
610
541
  createRenderRoot() {
611
- var e;
612
- const t = super.createRenderRoot();
613
- return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t;
542
+ var t;
543
+ const e = super.createRenderRoot();
544
+ return (t = this.renderOptions).renderBefore ?? (t.renderBefore = e.firstChild), e;
614
545
  }
615
- update(t) {
616
- const e = this.render();
617
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this.o = De(e, this.renderRoot, this.renderOptions);
546
+ update(e) {
547
+ const t = this.render();
548
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do = Me(t, this.renderRoot, this.renderOptions);
618
549
  }
619
550
  connectedCallback() {
620
- var t;
621
- super.connectedCallback(), (t = this.o) == null || t.setConnected(!0);
551
+ var e;
552
+ super.connectedCallback(), (e = this._$Do) == null || e.setConnected(!0);
622
553
  }
623
554
  disconnectedCallback() {
624
- var t;
625
- super.disconnectedCallback(), (t = this.o) == null || t.setConnected(!1);
555
+ var e;
556
+ super.disconnectedCallback(), (e = this._$Do) == null || e.setConnected(!1);
626
557
  }
627
558
  render() {
628
- return w;
559
+ return S;
629
560
  }
630
561
  }
631
- var Yt;
632
- S._$litElement$ = !0, S.finalized = !0, (Yt = globalThis.litElementHydrateSupport) == null || Yt.call(globalThis, { LitElement: S });
633
- const ct = globalThis.litElementPolyfillSupport;
634
- ct == null || ct({ LitElement: S });
635
- (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.0");
636
- var Fe = $`
637
- :host {
638
- --border-color: var(--sl-color-neutral-200);
639
- --border-radius: var(--sl-border-radius-medium);
640
- --border-width: 1px;
641
- --padding: var(--sl-spacing-large);
642
-
643
- display: inline-block;
644
- }
645
-
646
- .card {
647
- display: flex;
648
- flex-direction: column;
649
- background-color: var(--sl-panel-background-color);
650
- box-shadow: var(--sl-shadow-x-small);
651
- border: solid var(--border-width) var(--border-color);
652
- border-radius: var(--border-radius);
653
- }
654
-
655
- .card__image {
656
- display: flex;
657
- border-top-left-radius: var(--border-radius);
658
- border-top-right-radius: var(--border-radius);
659
- margin: calc(-1 * var(--border-width));
660
- overflow: hidden;
661
- }
662
-
663
- .card__image::slotted(img) {
664
- display: block;
665
- width: 100%;
666
- }
667
-
668
- .card:not(.card--has-image) .card__image {
669
- display: none;
670
- }
671
-
672
- .card__header {
673
- display: block;
674
- border-bottom: solid var(--border-width) var(--border-color);
675
- padding: calc(var(--padding) / 2) var(--padding);
676
- }
677
-
678
- .card:not(.card--has-header) .card__header {
679
- display: none;
680
- }
681
-
682
- .card:not(.card--has-image) .card__header {
683
- border-top-left-radius: var(--border-radius);
684
- border-top-right-radius: var(--border-radius);
685
- }
686
-
687
- .card__body {
688
- display: block;
689
- padding: var(--padding);
690
- }
691
-
692
- .card--has-footer .card__footer {
693
- display: block;
694
- border-top: solid var(--border-width) var(--border-color);
695
- padding: var(--padding);
696
- }
697
-
698
- .card:not(.card--has-footer) .card__footer {
699
- display: none;
700
- }
701
- `, St = class {
702
- constructor(o, ...t) {
703
- this.slotNames = [], this.handleSlotChange = (e) => {
704
- const r = e.target;
705
- (this.slotNames.includes("[default]") && !r.name || r.name && this.slotNames.includes(r.name)) && this.host.requestUpdate();
706
- }, (this.host = o).addController(this), this.slotNames = t;
707
- }
708
- hasDefaultSlot() {
709
- return [...this.host.childNodes].some((o) => {
710
- if (o.nodeType === o.TEXT_NODE && o.textContent.trim() !== "")
711
- return !0;
712
- if (o.nodeType === o.ELEMENT_NODE) {
713
- const t = o;
714
- if (t.tagName.toLowerCase() === "sl-visually-hidden")
715
- return !1;
716
- if (!t.hasAttribute("slot"))
717
- return !0;
718
- }
719
- return !1;
720
- });
721
- }
722
- hasNamedSlot(o) {
723
- return this.host.querySelector(`:scope > [slot="${o}"]`) !== null;
724
- }
725
- test(o) {
726
- return o === "[default]" ? this.hasDefaultSlot() : this.hasNamedSlot(o);
727
- }
728
- hostConnected() {
729
- this.host.shadowRoot.addEventListener("slotchange", this.handleSlotChange);
730
- }
731
- hostDisconnected() {
732
- this.host.shadowRoot.removeEventListener("slotchange", this.handleSlotChange);
733
- }
734
- }, Q = $`
735
- :host {
736
- box-sizing: border-box;
737
- }
738
-
739
- :host *,
740
- :host *::before,
741
- :host *::after {
742
- box-sizing: inherit;
743
- }
744
-
745
- [hidden] {
746
- display: none !important;
747
- }
748
- `, ee = Object.defineProperty, He = Object.defineProperties, je = Object.getOwnPropertyDescriptor, qe = Object.getOwnPropertyDescriptors, Ft = Object.getOwnPropertySymbols, We = Object.prototype.hasOwnProperty, Ke = Object.prototype.propertyIsEnumerable, Ht = (o, t, e) => t in o ? ee(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, X = (o, t) => {
749
- for (var e in t || (t = {}))
750
- We.call(t, e) && Ht(o, e, t[e]);
751
- if (Ft)
752
- for (var e of Ft(t))
753
- Ke.call(t, e) && Ht(o, e, t[e]);
754
- return o;
755
- }, oe = (o, t) => He(o, qe(t)), a = (o, t, e, r) => {
756
- for (var s = r > 1 ? void 0 : r ? je(t, e) : t, i = o.length - 1, n; i >= 0; i--)
757
- (n = o[i]) && (s = (r ? n(t, e, s) : n(s)) || s);
758
- return r && s && ee(t, e, s), s;
759
- };
760
- /**
761
- * @license
762
- * Copyright 2017 Google LLC
763
- * SPDX-License-Identifier: BSD-3-Clause
764
- */
765
- const Ze = { attribute: !0, type: String, converter: R, reflect: !1, hasChanged: Ct }, Ye = (o = Ze, t, e) => {
766
- const { kind: r, metadata: s } = e;
767
- let i = globalThis.litPropertyMetadata.get(s);
768
- if (i === void 0 && globalThis.litPropertyMetadata.set(s, i = /* @__PURE__ */ new Map()), i.set(e.name, o), r === "accessor") {
769
- const { name: n } = e;
770
- return { set(d) {
771
- const l = t.get.call(this);
772
- t.set.call(this, d), this.requestUpdate(n, l, o);
773
- }, init(d) {
774
- return d !== void 0 && this.P(n, void 0, o), d;
775
- } };
776
- }
777
- if (r === "setter") {
778
- const { name: n } = e;
779
- return function(d) {
780
- const l = this[n];
781
- t.call(this, d), this.requestUpdate(n, l, o);
782
- };
783
- }
784
- throw Error("Unsupported decorator location: " + r);
785
- };
786
- function u(o) {
787
- return (t, e) => typeof e == "object" ? Ye(o, t, e) : ((r, s, i) => {
788
- const n = s.hasOwnProperty(i);
789
- return s.constructor.createProperty(i, n ? { ...r, wrapped: !0 } : r), n ? Object.getOwnPropertyDescriptor(s, i) : void 0;
790
- })(o, t, e);
562
+ var le;
563
+ b._$litElement$ = !0, b.finalized = !0, (le = globalThis.litElementHydrateSupport) == null || le.call(globalThis, { LitElement: b });
564
+ const B = globalThis.litElementPolyfillSupport;
565
+ B == null || B({ LitElement: b });
566
+ (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1");
567
+ function x(s) {
568
+ return {
569
+ // Underlying mechanism to use the REST URLs directly.
570
+ api: (e, t) => E(s, e, t),
571
+ mintToken: ({ username: e, password: t }) => Ie({ config: s, username: e, password: t }),
572
+ refreshToken: ({ token: e }) => ze({ config: s, token: e }),
573
+ pubkey: () => je({ config: s }),
574
+ updatePassword: ({ token: e, currentPassword: t, newPassword: r }) => We({ config: s, token: e, currentPassword: t, newPassword: r }),
575
+ triggerResetPassword: ({ username: e }) => Be({ config: s, username: e }),
576
+ confirmResetPassword: ({ username: e, newPassword: t, confirmationCode: r }) => Ge({ config: s, username: e, newPassword: t, confirmationCode: r })
577
+ };
791
578
  }
792
- /**
793
- * @license
794
- * Copyright 2017 Google LLC
795
- * SPDX-License-Identifier: BSD-3-Clause
796
- */
797
- function at(o) {
798
- return u({ ...o, state: !0, attribute: !1 });
579
+ function Ie({ config: s, username: e, password: t }) {
580
+ return E(s, "/v1/user/login", {
581
+ method: "POST",
582
+ body: {
583
+ username: e,
584
+ password: t
585
+ }
586
+ });
799
587
  }
800
- /**
801
- * @license
802
- * Copyright 2017 Google LLC
803
- * SPDX-License-Identifier: BSD-3-Clause
804
- */
805
- const Je = (o, t, e) => (e.configurable = !0, e.enumerable = !0, Reflect.decorate && typeof t != "object" && Object.defineProperty(o, t, e), e);
806
- /**
807
- * @license
808
- * Copyright 2017 Google LLC
809
- * SPDX-License-Identifier: BSD-3-Clause
810
- */
811
- function re(o, t) {
812
- return (e, r, s) => {
813
- const i = (n) => {
814
- var d;
815
- return ((d = n.renderRoot) == null ? void 0 : d.querySelector(o)) ?? null;
816
- };
817
- return Je(e, r, { get() {
818
- return i(this);
819
- } });
820
- };
588
+ function ze({ config: s, token: e }) {
589
+ return E(s, "/v1/refresh", {
590
+ method: "POST",
591
+ body: {
592
+ token: e
593
+ }
594
+ });
821
595
  }
822
- var k = class extends S {
823
- constructor() {
824
- super(), Object.entries(this.constructor.dependencies).forEach(([o, t]) => {
825
- this.constructor.define(o, t);
826
- });
827
- }
828
- emit(o, t) {
829
- const e = new CustomEvent(o, X({
830
- bubbles: !0,
831
- cancelable: !1,
832
- composed: !0,
833
- detail: {}
834
- }, t));
835
- return this.dispatchEvent(e), e;
836
- }
837
- /* eslint-enable */
838
- static define(o, t = this, e = {}) {
839
- const r = customElements.get(o);
840
- if (!r) {
596
+ function je({ config: s }) {
597
+ return E(s, "/v1/pubkey", {
598
+ method: "GET"
599
+ });
600
+ }
601
+ function We({ config: s, token: e, currentPassword: t, newPassword: r }) {
602
+ return E(s, "/v1/user/password", {
603
+ method: "PUT",
604
+ body: {
605
+ currentPassword: t,
606
+ newPassword: r
607
+ },
608
+ headers: {
609
+ Authorization: `Bearer ${e}`
610
+ }
611
+ });
612
+ }
613
+ function Be({ config: s, username: e }) {
614
+ return E(s, "/v1/user/password/reset", {
615
+ method: "POST",
616
+ body: {
617
+ username: e
618
+ }
619
+ });
620
+ }
621
+ function Ge({ config: s, username: e, newPassword: t, confirmationCode: r }) {
622
+ return E(s, "/v1/user/password/reset/confirm", {
623
+ method: "POST",
624
+ body: {
625
+ username: e,
626
+ newPassword: t,
627
+ confirmationCode: r
628
+ }
629
+ });
630
+ }
631
+ async function E(s, e, t) {
632
+ var u;
633
+ const r = s.baseUrl.endsWith("/") ? s.baseUrl : `${s.baseUrl}/`, o = e.startsWith("/") ? e.substring(1) : e, i = new URL(o, r), l = Object.assign({}, t, {
634
+ headers: Object.assign({}, {
635
+ "Content-Type": "application/json"
636
+ }, t == null ? void 0 : t.headers),
637
+ body: t != null && t.body ? JSON.stringify(t.body) : void 0
638
+ }), a = await fetch(i.toString(), l);
639
+ if (!a.ok) {
640
+ const d = new Error("API request failed.");
641
+ if (d.status = a.status, d.statusText = a.statusText, d.url = i.toString(), d.headers = a.headers, d.bodyUsed = a.bodyUsed, (u = a.headers.get("Content-Type")) != null && u.includes("application/json"))
841
642
  try {
842
- customElements.define(o, t, e);
643
+ d.body = await a.json();
843
644
  } catch {
844
- customElements.define(o, class extends t {
845
- }, e);
645
+ d.body = "Failed to parse response body.";
846
646
  }
847
- return;
848
- }
849
- let s = " (unknown version)", i = s;
850
- "version" in t && t.version && (s = " v" + t.version), "version" in r && r.version && (i = " v" + r.version), !(s && i && s === i) && console.warn(
851
- `Attempted to register <${o}>${s}, but <${o}>${i} has already been registered.`
852
- );
853
- }
854
- };
855
- k.version = "2.16.0";
856
- k.dependencies = {};
857
- a([
858
- u()
859
- ], k.prototype, "dir", 2);
860
- a([
861
- u()
862
- ], k.prototype, "lang", 2);
863
- /**
864
- * @license
865
- * Copyright 2017 Google LLC
866
- * SPDX-License-Identifier: BSD-3-Clause
867
- */
868
- const T = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }, se = (o) => (...t) => ({ _$litDirective$: o, values: t });
869
- class ie {
870
- constructor(t) {
871
- }
872
- get _$AU() {
873
- return this._$AM._$AU;
874
- }
875
- _$AT(t, e, r) {
876
- this.t = t, this._$AM = e, this.i = r;
647
+ throw d;
877
648
  }
878
- _$AS(t, e) {
879
- return this.update(t, e);
649
+ if (a.status !== 204)
650
+ return await a.json();
651
+ }
652
+ function fe({ api: s }, e) {
653
+ const t = x({
654
+ baseUrl: s
655
+ });
656
+ return console.log("sending credentials to API", s), t.mintToken(e);
657
+ }
658
+ const g = Object.freeze({
659
+ REQUEST: "request",
660
+ CONFIRM: "confirm",
661
+ FINISHED: "finished"
662
+ });
663
+ class Ve extends b {
664
+ static get properties() {
665
+ return {
666
+ api: { type: String, attribute: "api" },
667
+ confirmation: { type: "String", attribute: "confirmation" }
668
+ };
880
669
  }
881
- update(t, e) {
882
- return this.render(...e);
670
+ static get styles() {
671
+ return q`
672
+ :host {
673
+ display: block;
674
+ font-family: Arial, sans-serif;
675
+ }
676
+ form input[type="text"],
677
+ form input[type="password"] {
678
+ width: 100%;
679
+ margin: 5px 0 15px 0;
680
+ padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
681
+ box-sizing: border-box;
682
+ border: 1px solid var(--color-gray-300, #ccc);
683
+ border-radius: var(--radius-sm, 5px);
684
+ color: var(--color-gray-9, #333);
685
+ background-color: var(--color-gray-0, transparent);
686
+ }
687
+ form input[type="submit"] {
688
+ background-color:var(--color-primary, inherit);
689
+ color: var(--color-gray-0, #fff);
690
+ border: none;
691
+ padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
692
+ border-radius: var(--radius-dynamic, 5px);
693
+ width: 200px;
694
+ display: block;
695
+ margin: var(--spacing-md, 1rem) auto;
696
+ cursor: pointer;
697
+ }
698
+ form label {
699
+ font-size: 14px;
700
+ color: var(--color-gray-9, #333);
701
+ font-weight: bold;
702
+ margin-bottom: var(--spacing-sm, 0.5rem);
703
+ }
704
+ .error {
705
+ color: var(--color-danger, red);
706
+ font-size: 12px;
707
+ }
708
+ `;
883
709
  }
884
- }
885
- /**
886
- * @license
887
- * Copyright 2018 Google LLC
888
- * SPDX-License-Identifier: BSD-3-Clause
889
- */
890
- const it = se(class extends ie {
891
- constructor(o) {
892
- var t;
893
- if (super(o), o.type !== T.ATTRIBUTE || o.name !== "class" || ((t = o.strings) == null ? void 0 : t.length) > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
710
+ constructor() {
711
+ super(), this.errors = {}, this.stage = g.REQUEST;
894
712
  }
895
- render(o) {
896
- return " " + Object.keys(o).filter((t) => o[t]).join(" ") + " ";
713
+ connectedCallback() {
714
+ console.log("[auth]", "[forgot-password]", { confirmation: this.confirmation }), super.connectedCallback(), this.confirmation && this.stage !== g.FINISHED && (this.stage = g.CONFIRM), this.requestUpdate();
715
+ }
716
+ handleSubmitRequest(e) {
717
+ e.preventDefault();
718
+ const t = e.target.username.value;
719
+ this.username = t, x({
720
+ baseUrl: this.api
721
+ }).triggerResetPassword({ username: t }).then(() => {
722
+ console.log("[auth]", "triggered reset password for ", t), this.stage = g.CONFIRM;
723
+ }).catch((o) => {
724
+ console.error("[auth] error triggering reset password", o), this.errors.general = o.message || "Unable to send password reset request. Please try again later.";
725
+ }).finally(() => {
726
+ this.requestUpdate();
727
+ });
897
728
  }
898
- update(o, [t]) {
899
- var r, s;
900
- if (this.st === void 0) {
901
- this.st = /* @__PURE__ */ new Set(), o.strings !== void 0 && (this.nt = new Set(o.strings.join(" ").split(/\s/).filter((i) => i !== "")));
902
- for (const i in t) t[i] && !((r = this.nt) != null && r.has(i)) && this.st.add(i);
903
- return this.render(t);
729
+ handleSubmitConfirm(e) {
730
+ e.preventDefault();
731
+ const t = e.target.password.value, r = e.target["confirm-password"].value;
732
+ if (t !== r) {
733
+ this.errors["confirm-password"] = "Passwords do not match.", this.requestUpdate();
734
+ return;
904
735
  }
905
- const e = o.element.classList;
906
- for (const i of this.st) i in t || (e.remove(i), this.st.delete(i));
907
- for (const i in t) {
908
- const n = !!t[i];
909
- n === this.st.has(i) || (s = this.nt) != null && s.has(i) || (n ? (e.add(i), this.st.add(i)) : (e.remove(i), this.st.delete(i)));
736
+ const o = this.confirmation || e.target.confirmation.value;
737
+ if (!o) {
738
+ this.errors.general = "Confirmation code is required.", this.requestUpdate();
739
+ return;
910
740
  }
911
- return w;
912
- }
913
- });
914
- var ne = class extends k {
915
- constructor() {
916
- super(...arguments), this.hasSlotController = new St(this, "footer", "header", "image");
741
+ x({
742
+ baseUrl: this.api
743
+ }).confirmResetPassword({
744
+ username: this.username,
745
+ newPassword: t,
746
+ confirmationCode: o
747
+ }).then(() => fe(this, { username: this.username, password: t }).then(({ token: n }) => {
748
+ this.dispatchEvent(new CustomEvent("login-success", {
749
+ detail: { token: n },
750
+ composed: !0,
751
+ bubbles: !0
752
+ }));
753
+ })).catch((n) => {
754
+ console.error("[auth][forgot-password-form]", n), this.errors.general = "Unable to reset password. Please try again later.";
755
+ }).finally(() => {
756
+ this.requestUpdate();
757
+ });
917
758
  }
918
759
  render() {
919
- return v`
920
- <div
921
- part="base"
922
- class=${it({
923
- card: !0,
924
- "card--has-footer": this.hasSlotController.test("footer"),
925
- "card--has-image": this.hasSlotController.test("image"),
926
- "card--has-header": this.hasSlotController.test("header")
927
- })}
928
- >
929
- <slot name="image" part="image" class="card__image"></slot>
930
- <slot name="header" part="header" class="card__header"></slot>
931
- <slot part="body" class="card__body"></slot>
932
- <slot name="footer" part="footer" class="card__footer"></slot>
933
- </div>
934
- `;
935
- }
936
- };
937
- ne.styles = [Q, Fe];
938
- ne.define("sl-card");
939
- var Ge = $`
940
- :host {
941
- display: block;
760
+ switch (this.stage) {
761
+ case g.CONFIRM:
762
+ return this.renderConfirmForm();
763
+ case g.FINISHED:
764
+ return c`<p>Your password has been reset.</p>`;
765
+ case g.REQUEST_SENT:
766
+ return c`<p>A email has been sent with instructions to finish
767
+ resetting your password.</p>`;
768
+ case g.REQUEST:
769
+ default:
770
+ return this.renderRequestForm();
771
+ }
942
772
  }
943
-
944
- .input {
945
- flex: 1 1 auto;
946
- display: inline-flex;
947
- align-items: stretch;
948
- justify-content: start;
949
- position: relative;
950
- width: 100%;
951
- font-family: var(--sl-input-font-family);
952
- font-weight: var(--sl-input-font-weight);
953
- letter-spacing: var(--sl-input-letter-spacing);
954
- vertical-align: middle;
955
- overflow: hidden;
956
- cursor: text;
957
- transition:
958
- var(--sl-transition-fast) color,
959
- var(--sl-transition-fast) border,
960
- var(--sl-transition-fast) box-shadow,
961
- var(--sl-transition-fast) background-color;
773
+ renderRequestForm() {
774
+ return c`<form @submit=${this.handleSubmitRequest}>
775
+ <label for="username">Username/Email</label>
776
+ <input
777
+ type="text"
778
+ name="username"
779
+ placeholder="Email or Username"
780
+ required
781
+ />
782
+ <p class="error">${this.errors.general}</p>
783
+ <input type="submit" value="Request password reset" />
784
+ </form>`;
785
+ }
786
+ renderConfirmForm() {
787
+ return c`<form @submit=${this.handleSubmitConfirm}>
788
+ <p>You should have received a confirmation code to reset your password</p>
789
+
790
+ ${this.confirmation ? "" : c`<label for="confirmation">Confirmation Code</label>
791
+ <input
792
+ type="text"
793
+ name="confirmation"
794
+ placeholder="Confirmation Code"
795
+ required
796
+ />`}
797
+
798
+ <label for="password">New Password</label>
799
+ <input
800
+ type="password"
801
+ name="password"
802
+ placeholder="Password"
803
+ required
804
+ />
805
+ ${this.errors.password ? c`<p class="error">${this.errors.password}</p>` : ""}
806
+
807
+ <label for="confirm-password">Confirm Password</label>
808
+ <input
809
+ type="password"
810
+ name="confirm-password"
811
+ placeholder="Confirm Password"
812
+ required
813
+ />
814
+ ${this.errors["confirm-password"] ? c`<p class="error">${this.errors["confirm-password"]}</p>` : ""}
815
+
816
+ ${this.errors.general ? c`<p class="error">${this.errors.general}</p>` : ""}
817
+ <input type="submit" value="Reset Password" />
818
+ </form>`;
962
819
  }
963
-
964
- /* Standard inputs */
965
- .input--standard {
966
- background-color: var(--sl-input-background-color);
967
- border: solid var(--sl-input-border-width) var(--sl-input-border-color);
820
+ }
821
+ class y extends b {
822
+ static get properties() {
823
+ return {
824
+ api: { type: String, attribute: "api" }
825
+ };
968
826
  }
969
-
970
- .input--standard:hover:not(.input--disabled) {
971
- background-color: var(--sl-input-background-color-hover);
972
- border-color: var(--sl-input-border-color-hover);
827
+ static get styles() {
828
+ return q`
829
+ :host {
830
+ display: block;
831
+ font-family: Arial, sans-serif;
832
+ }
833
+ .login-form {
834
+ background-color: var(--color-gray-0, #fff);
835
+ padding: var(--spacing-xl, 3rem);
836
+ border-radius: var(--radius-md, 5px);
837
+ box-shadow: var(--drop-shadow-md, none);
838
+ }
839
+ form input[type="text"],
840
+ form input[type="password"] {
841
+ width: 100%;
842
+ margin: 5px 0 15px 0;
843
+ padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
844
+ box-sizing: border-box;
845
+ border: 1px solid var(--color-gray-300, #ccc);
846
+ border-radius: var(--radius-sm, 5px);
847
+ color: var(--color-gray-9, #333);
848
+ background-color: var(--color-gray-0, transparent);
849
+ }
850
+ form input[type="submit"] {
851
+ background-color: var(--color-primary, inherit);
852
+ color: var(--color-gray-0, #fff);
853
+ border: none;
854
+ padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
855
+ border-radius: var(--radius-dynamic, 5px);
856
+ width: 200px;
857
+ display: block;
858
+ margin: var(--spacing-md, 1rem) auto;
859
+ cursor: pointer;
860
+ }
861
+ form label {
862
+ font-size: 14px;
863
+ color: var(--color-gray-9, #333);
864
+ font-weight: bold;
865
+ margin-bottom: var(--spacing-sm, 0.5rem);
866
+ }
867
+ a.forgot {
868
+ color: var(--color-primary, inherit);
869
+ text-decoration: none;
870
+ font-size: 12px;
871
+ font-weight: bold;
872
+ }
873
+ .error {
874
+ color: var(--color-error, red);
875
+ font-size: 12px;
876
+ margin-top: var(--spacing-sm, 0.5rem);
877
+ }
878
+ .header {
879
+ display: flex;
880
+ flex-direction: column;
881
+ align-items: center;
882
+ }
883
+ .header .intro {
884
+ width: 200px;
885
+ margin-bottom: 0;
886
+ color: var(--color-gray-3);
887
+ }
888
+ .header .brand {
889
+ font-size: 32px;
890
+ min-width: 200px;
891
+ margin-bottom: var(--spacing-lg, 2rem);
892
+ }
893
+ .header .brand em {
894
+ text-transform: uppercase;
895
+ font-weight: bold;
896
+ font-style: normal;
897
+ }
898
+ `;
899
+ }
900
+ static get states() {
901
+ return {
902
+ DEFAULT: "DEFAULT",
903
+ FORGOT: "FORGOT",
904
+ CHALLENGE_CHANGE_PW: "CHALLENGE_CHANGE_PW"
905
+ };
973
906
  }
974
-
975
- .input--standard.input--focused:not(.input--disabled) {
976
- background-color: var(--sl-input-background-color-focus);
977
- border-color: var(--sl-input-border-color-focus);
978
- box-shadow: 0 0 0 var(--sl-focus-ring-width) var(--sl-input-focus-ring-color);
907
+ constructor() {
908
+ super(), this.formState = y.states.DEFAULT, this.username = "", this.password = "", this.token = void 0, this.errors = [];
909
+ }
910
+ onSubmit(e) {
911
+ e.preventDefault();
912
+ const t = e.explicitOriginalTarget.parentElement;
913
+ console.log(t);
914
+ const r = new FormData(t).entries().reduce((o, [i, n]) => (o[i] = n, o), {});
915
+ fe(this, r).then(({ token: o, challenge: i }) => {
916
+ if (i && i.name === "NEW_PASSWORD_REQUIRED") {
917
+ this.token = o, this.username = r.username, this.password = r.password, this.setState(y.states.CHALLENGE_CHANGE_PW);
918
+ return;
919
+ }
920
+ this.dispatchEvent(new CustomEvent("login-success", {
921
+ detail: { token: o }
922
+ }));
923
+ }).catch((o) => {
924
+ console.log(o), this.errors = [o.message], this.requestUpdate();
925
+ });
979
926
  }
980
-
981
- .input--standard.input--focused:not(.input--disabled) .input__control {
982
- color: var(--sl-input-color-focus);
927
+ onSubmitChangePasswordChallenge(e) {
928
+ e.preventDefault();
929
+ const t = e.explicitOriginalTarget, r = new FormData(t).entries().reduce((l, [a, u]) => (l[a] = u, l), {}), o = r.password, i = r["confirm-password"];
930
+ if (o !== i) {
931
+ this.errors = ["Passwords do not match."], this.requestUpdate();
932
+ return;
933
+ }
934
+ x({
935
+ baseUrl: this.api
936
+ }).updatePassword({
937
+ token: this.token,
938
+ currentPassword: this.password,
939
+ newPassword: o
940
+ }).then(() => {
941
+ this.dispatchEvent(new CustomEvent("login-success", {
942
+ detail: { token: this.token }
943
+ }));
944
+ }).catch((l) => {
945
+ console.log(l), this.errors = [l.message], this.requestUpdate();
946
+ });
983
947
  }
984
-
985
- .input--standard.input--disabled {
986
- background-color: var(--sl-input-background-color-disabled);
987
- border-color: var(--sl-input-border-color-disabled);
988
- opacity: 0.5;
989
- cursor: not-allowed;
948
+ setState(e) {
949
+ e !== this.formState && (this.formState = e, this.errors = [], this.requestUpdate());
990
950
  }
991
-
992
- .input--standard.input--disabled .input__control {
993
- color: var(--sl-input-color-disabled);
951
+ render() {
952
+ return c`<div class="login-form">
953
+ ${this.renderHeader()}
954
+ ${this.formState === y.states.FORGOT ? this.renderForgotPasswordForm() : ""}
955
+ ${this.formState === y.states.CHALLENGE_CHANGE_PW ? this.renderChangePasswordForm() : ""}
956
+ ${this.formState === y.states.DEFAULT ? this.renderLoginForm() : ""}
957
+ </div>`;
994
958
  }
995
-
996
- .input--standard.input--disabled .input__control::placeholder {
997
- color: var(--sl-input-placeholder-color-disabled);
959
+ /**
960
+ * TODO: accept the header as a slot
961
+ */
962
+ renderHeader() {
963
+ return c`<div class="header">
964
+ <div class="intro">
965
+ Welcome to
966
+ </div>
967
+ <div class="brand">
968
+ <em>WRAL</em>.studio
969
+ </div>
970
+ </div>`;
998
971
  }
999
-
1000
- /* Filled inputs */
1001
- .input--filled {
1002
- border: none;
1003
- background-color: var(--sl-input-filled-background-color);
1004
- color: var(--sl-input-color);
972
+ renderLoginForm() {
973
+ return c`
974
+ <form>
975
+ <label for="username">User</label>
976
+ <input
977
+ type="text"
978
+ name="username"
979
+ placeholder="Email or Username"
980
+ required
981
+ />
982
+
983
+ <label for="password">Password</label>
984
+ <input
985
+ type="password"
986
+ name="password"
987
+ placeholder="Password"
988
+ required
989
+ />
990
+ <div>
991
+ <a href="#" class="forgot"
992
+ @click=${() => {
993
+ this.setState(y.states.FORGOT);
994
+ }}
995
+ >Forgot password</a>
996
+ </div>
997
+
998
+ ${this.errors ? this.errors.map((e) => c`<p class="error">${e}</p>`) : ""}
999
+ <input type="submit" value="Log in" @click=${this.onSubmit} />
1000
+
1001
+ </form>`;
1002
+ }
1003
+ renderForgotPasswordForm() {
1004
+ return c`
1005
+ <auth-forgot-password-form
1006
+ api=${this.api}>
1007
+ </auth-forgot-password-form>
1008
+ `;
1009
+ }
1010
+ renderChangePasswordForm() {
1011
+ return c`
1012
+ <p>You have logged in successfully, but you must change your password.</p>
1013
+ <form @submit=${this.onSubmitChangePasswordChallenge}>
1014
+ <input type="hidden" name="username" value="${this.username}" />
1015
+ <label for="password">New Password</label>
1016
+ <input
1017
+ type="password"
1018
+ name="password"
1019
+ placeholder="Password"
1020
+ required
1021
+ />
1022
+ <label for="confirm-password">Confirm Password</label>
1023
+ <input
1024
+ type="password"
1025
+ name="confirm-password"
1026
+ placeholder="Confirm Password"
1027
+ required
1028
+ />
1029
+ ${this.errors ? this.errors.map((e) => c`<p class="error">${e}</p>`) : ""}
1030
+ <input type="submit" value="Change Password" />
1031
+ </form>
1032
+ `;
1005
1033
  }
1006
-
1007
- .input--filled:hover:not(.input--disabled) {
1008
- background-color: var(--sl-input-filled-background-color-hover);
1034
+ }
1035
+ customElements.define("auth-login-form", y);
1036
+ customElements.define("auth-forgot-password-form", Ve);
1037
+ function Ke() {
1038
+ return function(s) {
1039
+ const e = q`
1040
+ .login-layout {
1041
+ display: flex;
1042
+ flex-direction: column;
1043
+ gap: 1rem;
1044
+ justify-content: center;
1045
+ align-items: center;
1046
+ min-height: 100vh;
1047
+ background-color: var(--color-gray-100, #f5f5f5);
1048
+ }
1049
+ .login-layout > * {
1050
+ max-width: 400px;
1051
+ }
1052
+ `;
1053
+ return c`
1054
+ <style>${e}</style>
1055
+ <div class="login-layout">
1056
+ ${s.main}
1057
+ </div>
1058
+ `;
1059
+ };
1060
+ }
1061
+ function Qe(s) {
1062
+ return JSON.parse(window.atob(s.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")));
1063
+ }
1064
+ function Je(s, e = 300, t = Date.now()) {
1065
+ return Qe(s).exp * 1e3 - e < t;
1066
+ }
1067
+ function ge(s) {
1068
+ return (s.startsWith("/") ? s : `/${s}`).replace(/\/{2,}/g, "/").replace(new RegExp("(?<=.)\\/$"), "");
1069
+ }
1070
+ function ye(s, e, t) {
1071
+ const r = Ze(s, t);
1072
+ e.pushState(t, t.title, r), s.requestRender(t);
1073
+ }
1074
+ function Ye(s, e) {
1075
+ const { mount: t } = s.config, { history: r } = s.config.toolkit.element.ownerDocument.defaultView;
1076
+ return e.startsWith(t) ? {
1077
+ path: ge(e.slice(t.length)),
1078
+ push: (o) => ye(s, r, o)
1079
+ } : null;
1080
+ }
1081
+ function Ze(s, e) {
1082
+ const { mount: t } = s.config;
1083
+ return ge(`${t}/${e.path}`);
1084
+ }
1085
+ function Xe(s, e) {
1086
+ const { history: t } = e.config.toolkit.element.ownerDocument.defaultView;
1087
+ return c`
1088
+ <h1>Auth Dashboard</h1>
1089
+ <ul>
1090
+ <li><a href="#" @click=${((o, i) => () => {
1091
+ ye(e, t, { path: o, title: i });
1092
+ })("/change-password")}>Change Password</a></li>
1093
+ <li><a href="#" @click=${e.handleDestroyAuth}>Logout</a></li>
1094
+ </ul>
1095
+ `;
1096
+ }
1097
+ function et(s, e) {
1098
+ return c`
1099
+ <auth-change-password-form .auth=${e}></auth-change-password-form>
1100
+ `;
1101
+ }
1102
+ class tt extends b {
1103
+ static get styles() {
1104
+ return q`
1105
+ :host {
1106
+ color: var(--color-text);
1107
+ display: block;
1108
+ font-family: var(--font-body);
1109
+ }
1110
+ h1,h2,h3,h4,h5,h6,label { font-family: var(--font-heading) }
1111
+ label {
1112
+ display: block;
1113
+ font-size: var(--font-size-base);
1114
+ margin-top: var(--spacing-md, 0.5rem);
1115
+ }
1116
+ input[type="text"],
1117
+ input[type="password"] {
1118
+ width: 100%;
1119
+ margin: 5px 0 15px 0;
1120
+ padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
1121
+ box-sizing: border-box;
1122
+ border: 1px solid var(--color-gray-300, #ccc);
1123
+ border-radius: var(--radius-sm, 5px);
1124
+ color: var(--color-gray-9, #333);
1125
+ background-color: var(--color-gray-0, transparent);
1126
+ }
1127
+ input[type="submit"] {
1128
+ background-color: var(--color-primary, inherit);
1129
+ color: var(--color-gray-0, #fff);
1130
+ border: none;
1131
+ padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 1rem);
1132
+ border-radius: var(--radius-dynamic, 5px);
1133
+ width: 200px;
1134
+ cursor: pointer;
1135
+ }
1136
+ .error {
1137
+ color: var(--color-error);
1138
+ }
1139
+ `;
1140
+ }
1141
+ static get properties() {
1142
+ return {
1143
+ auth: { type: Object }
1144
+ };
1009
1145
  }
1010
-
1011
- .input--filled.input--focused:not(.input--disabled) {
1012
- background-color: var(--sl-input-filled-background-color-focus);
1013
- outline: var(--sl-focus-ring);
1014
- outline-offset: var(--sl-focus-ring-offset);
1146
+ constructor() {
1147
+ super(), this.errors = {}, this.success = null;
1015
1148
  }
1016
-
1017
- .input--filled.input--disabled {
1018
- background-color: var(--sl-input-filled-background-color-disabled);
1019
- opacity: 0.5;
1020
- cursor: not-allowed;
1149
+ connectedCallback() {
1150
+ super.connectedCallback(), G(this);
1021
1151
  }
1022
-
1023
- .input__control {
1024
- flex: 1 1 auto;
1025
- font-family: inherit;
1026
- font-size: inherit;
1027
- font-weight: inherit;
1028
- min-width: 0;
1029
- height: 100%;
1030
- color: var(--sl-input-color);
1031
- border: none;
1032
- background: inherit;
1033
- box-shadow: none;
1034
- padding: 0;
1035
- margin: 0;
1036
- cursor: inherit;
1037
- -webkit-appearance: none;
1152
+ async onSubmit(e) {
1153
+ if (e.preventDefault(), e.target.newPassword.value !== e.target.confirmPassword.value) {
1154
+ this.errors.confirmPassword = "Passwords do not match", this.requestUpdate();
1155
+ return;
1156
+ }
1157
+ if (e.target.newPassword.value === e.target.currentPassword.value) {
1158
+ this.errors.newPassword = "The new password is the same as your current password.", this.requestUpdate();
1159
+ return;
1160
+ }
1161
+ await G(this), await x({
1162
+ baseUrl: this.auth.config.api
1163
+ }).updatePassword({
1164
+ currentPassword: e.target.currentPassword.value,
1165
+ newPassword: e.target.newPassword.value
1166
+ }).then(() => {
1167
+ this.errors = {}, this.success = "Password changed.", this.requestUpdate();
1168
+ }).catch((r) => {
1169
+ this.errors.submit = r.message, this.requestUpdate();
1170
+ });
1038
1171
  }
1039
-
1040
- .input__control::-webkit-search-decoration,
1041
- .input__control::-webkit-search-cancel-button,
1042
- .input__control::-webkit-search-results-button,
1043
- .input__control::-webkit-search-results-decoration {
1044
- -webkit-appearance: none;
1172
+ render() {
1173
+ return c`
1174
+ <h1>Change your password</h1>
1175
+ <p>Enter your current password and choose a new password.</p>
1176
+ <form @submit=${this.onSubmit}>
1177
+ <div class="field">
1178
+ <label for="currentPassword">Current Password</label>
1179
+ <input
1180
+ type="password"
1181
+ name="currentPassword"
1182
+ placeholder="Current Password"
1183
+ required
1184
+ />
1185
+ ${this.errors.currentPassword ? c`<p class="error">${this.errors.currentPassword}</p>` : ""}
1186
+ </div>
1187
+ <div class="field">
1188
+ <label for="newPassword">New Password</label>
1189
+ <input
1190
+ type="password"
1191
+ name="newPassword"
1192
+ placeholder="New Password"
1193
+ required
1194
+ />
1195
+ ${this.errors.newPassword ? c`<p class="error">${this.errors.newPassword}</p>` : ""}
1196
+ </div>
1197
+ <div class="field">
1198
+ <label for="confirmPassword">Confirm Password</label>
1199
+ <input
1200
+ type="password"
1201
+ name="confirmPassword"
1202
+ placeholder="Confirm Password"
1203
+ required
1204
+ />
1205
+ ${this.errors.confirmPassword ? c`<p class="error">${this.errors.confirmPassword}</p>` : ""}
1206
+ </div>
1207
+ <input type="submit" value="Change Password" />
1208
+ ${this.errors.submit ? c`<p class="error">${this.errors.submit}</p>` : ""}
1209
+ ${this.success ? c`<p class="success">${this.success}</p>` : ""}
1210
+ </form>
1211
+ `;
1045
1212
  }
1213
+ }
1214
+ customElements.get("auth-change-password-form") || customElements.define("auth-change-password-form", tt);
1215
+ const rt = [
1216
+ { path: "/", render: Xe },
1217
+ { path: "/change-password", render: et }
1218
+ ];
1219
+ function st(s, e) {
1220
+ const { path: t } = s, r = rt.find((o) => o.path === t);
1221
+ if (r)
1222
+ return r.render(s, e);
1223
+ }
1224
+ const ot = q`
1225
+ :host {
1046
1226
 
1047
- .input__control:-webkit-autofill,
1048
- .input__control:-webkit-autofill:hover,
1049
- .input__control:-webkit-autofill:focus,
1050
- .input__control:-webkit-autofill:active {
1051
- box-shadow: 0 0 0 var(--sl-input-height-large) var(--sl-input-background-color-hover) inset !important;
1052
- -webkit-text-fill-color: var(--sl-color-primary-500);
1053
- caret-color: var(--sl-input-color);
1227
+ }
1228
+ `;
1229
+ class it extends b {
1230
+ static get styles() {
1231
+ return [ot];
1232
+ }
1233
+ static get properties() {
1234
+ return {
1235
+ state: { type: Object },
1236
+ auth: { type: Object }
1237
+ };
1054
1238
  }
1055
-
1056
- .input--filled .input__control:-webkit-autofill,
1057
- .input--filled .input__control:-webkit-autofill:hover,
1058
- .input--filled .input__control:-webkit-autofill:focus,
1059
- .input--filled .input__control:-webkit-autofill:active {
1060
- box-shadow: 0 0 0 var(--sl-input-height-large) var(--sl-input-filled-background-color) inset !important;
1239
+ render() {
1240
+ const { state: e, auth: t } = this;
1241
+ return st(e, t);
1061
1242
  }
1062
-
1063
- .input__control::placeholder {
1064
- color: var(--sl-input-placeholder-color);
1065
- user-select: none;
1066
- -webkit-user-select: none;
1067
- }
1068
-
1069
- .input:hover:not(.input--disabled) .input__control {
1070
- color: var(--sl-input-color-hover);
1071
- }
1072
-
1073
- .input__control:focus {
1074
- outline: none;
1075
- }
1076
-
1077
- .input__prefix,
1078
- .input__suffix {
1079
- display: inline-flex;
1080
- flex: 0 0 auto;
1081
- align-items: center;
1082
- cursor: default;
1083
- }
1084
-
1085
- .input__prefix ::slotted(sl-icon),
1086
- .input__suffix ::slotted(sl-icon) {
1087
- color: var(--sl-input-icon-color);
1088
- }
1089
-
1090
- /*
1091
- * Size modifiers
1092
- */
1093
-
1094
- .input--small {
1095
- border-radius: var(--sl-input-border-radius-small);
1096
- font-size: var(--sl-input-font-size-small);
1097
- height: var(--sl-input-height-small);
1098
- }
1099
-
1100
- .input--small .input__control {
1101
- height: calc(var(--sl-input-height-small) - var(--sl-input-border-width) * 2);
1102
- padding: 0 var(--sl-input-spacing-small);
1103
- }
1104
-
1105
- .input--small .input__clear,
1106
- .input--small .input__password-toggle {
1107
- width: calc(1em + var(--sl-input-spacing-small) * 2);
1108
- }
1109
-
1110
- .input--small .input__prefix ::slotted(*) {
1111
- margin-inline-start: var(--sl-input-spacing-small);
1112
- }
1113
-
1114
- .input--small .input__suffix ::slotted(*) {
1115
- margin-inline-end: var(--sl-input-spacing-small);
1116
- }
1117
-
1118
- .input--medium {
1119
- border-radius: var(--sl-input-border-radius-medium);
1120
- font-size: var(--sl-input-font-size-medium);
1121
- height: var(--sl-input-height-medium);
1122
- }
1123
-
1124
- .input--medium .input__control {
1125
- height: calc(var(--sl-input-height-medium) - var(--sl-input-border-width) * 2);
1126
- padding: 0 var(--sl-input-spacing-medium);
1127
- }
1128
-
1129
- .input--medium .input__clear,
1130
- .input--medium .input__password-toggle {
1131
- width: calc(1em + var(--sl-input-spacing-medium) * 2);
1132
- }
1133
-
1134
- .input--medium .input__prefix ::slotted(*) {
1135
- margin-inline-start: var(--sl-input-spacing-medium);
1136
- }
1137
-
1138
- .input--medium .input__suffix ::slotted(*) {
1139
- margin-inline-end: var(--sl-input-spacing-medium);
1140
- }
1141
-
1142
- .input--large {
1143
- border-radius: var(--sl-input-border-radius-large);
1144
- font-size: var(--sl-input-font-size-large);
1145
- height: var(--sl-input-height-large);
1146
- }
1147
-
1148
- .input--large .input__control {
1149
- height: calc(var(--sl-input-height-large) - var(--sl-input-border-width) * 2);
1150
- padding: 0 var(--sl-input-spacing-large);
1151
- }
1152
-
1153
- .input--large .input__clear,
1154
- .input--large .input__password-toggle {
1155
- width: calc(1em + var(--sl-input-spacing-large) * 2);
1156
- }
1157
-
1158
- .input--large .input__prefix ::slotted(*) {
1159
- margin-inline-start: var(--sl-input-spacing-large);
1160
- }
1161
-
1162
- .input--large .input__suffix ::slotted(*) {
1163
- margin-inline-end: var(--sl-input-spacing-large);
1164
- }
1165
-
1166
- /*
1167
- * Pill modifier
1168
- */
1169
-
1170
- .input--pill.input--small {
1171
- border-radius: var(--sl-input-height-small);
1172
- }
1173
-
1174
- .input--pill.input--medium {
1175
- border-radius: var(--sl-input-height-medium);
1176
- }
1177
-
1178
- .input--pill.input--large {
1179
- border-radius: var(--sl-input-height-large);
1180
- }
1181
-
1182
- /*
1183
- * Clearable + Password Toggle
1184
- */
1185
-
1186
- .input__clear,
1187
- .input__password-toggle {
1188
- display: inline-flex;
1189
- align-items: center;
1190
- justify-content: center;
1191
- font-size: inherit;
1192
- color: var(--sl-input-icon-color);
1193
- border: none;
1194
- background: none;
1195
- padding: 0;
1196
- transition: var(--sl-transition-fast) color;
1197
- cursor: pointer;
1198
- }
1199
-
1200
- .input__clear:hover,
1201
- .input__password-toggle:hover {
1202
- color: var(--sl-input-icon-color-hover);
1203
- }
1204
-
1205
- .input__clear:focus,
1206
- .input__password-toggle:focus {
1207
- outline: none;
1208
- }
1209
-
1210
- /* Don't show the browser's password toggle in Edge */
1211
- ::-ms-reveal {
1212
- display: none;
1213
- }
1214
-
1215
- /* Hide the built-in number spinner */
1216
- .input--no-spin-buttons input[type='number']::-webkit-outer-spin-button,
1217
- .input--no-spin-buttons input[type='number']::-webkit-inner-spin-button {
1218
- -webkit-appearance: none;
1219
- display: none;
1220
- }
1221
-
1222
- .input--no-spin-buttons input[type='number'] {
1223
- -moz-appearance: textfield;
1224
- }
1225
- `, Qe = (o = "value") => (t, e) => {
1226
- const r = t.constructor, s = r.prototype.attributeChangedCallback;
1227
- r.prototype.attributeChangedCallback = function(i, n, d) {
1228
- var l;
1229
- const c = r.getPropertyOptions(o), b = typeof c.attribute == "string" ? c.attribute : o;
1230
- if (i === b) {
1231
- const p = c.converter || R, y = (typeof p == "function" ? p : (l = p == null ? void 0 : p.fromAttribute) != null ? l : R.fromAttribute)(d, c.type);
1232
- this[o] !== y && (this[e] = y);
1233
- }
1234
- s.call(this, i, n, d);
1243
+ }
1244
+ customElements.get("auth-app") || customElements.define("auth-app", it);
1245
+ function nt(s) {
1246
+ const e = {
1247
+ config: s,
1248
+ log: (...t) => console.log("[auth]", ...t)
1235
1249
  };
1236
- }, Xe = $`
1237
- .form-control .form-control__label {
1238
- display: none;
1239
- }
1240
-
1241
- .form-control .form-control__help-text {
1242
- display: none;
1243
- }
1244
-
1245
- /* Label */
1246
- .form-control--has-label .form-control__label {
1247
- display: inline-block;
1248
- color: var(--sl-input-label-color);
1249
- margin-bottom: var(--sl-spacing-3x-small);
1250
- }
1251
-
1252
- .form-control--has-label.form-control--small .form-control__label {
1253
- font-size: var(--sl-input-label-font-size-small);
1254
- }
1255
-
1256
- .form-control--has-label.form-control--medium .form-control__label {
1257
- font-size: var(--sl-input-label-font-size-medium);
1258
- }
1259
-
1260
- .form-control--has-label.form-control--large .form-control__label {
1261
- font-size: var(--sl-input-label-font-size-large);
1262
- }
1263
-
1264
- :host([required]) .form-control--has-label .form-control__label::after {
1265
- content: var(--sl-input-required-content);
1266
- margin-inline-start: var(--sl-input-required-content-offset);
1267
- color: var(--sl-input-required-content-color);
1268
- }
1269
-
1270
- /* Help text */
1271
- .form-control--has-help-text .form-control__help-text {
1272
- display: block;
1273
- color: var(--sl-input-help-text-color);
1274
- margin-top: var(--sl-spacing-3x-small);
1275
- }
1276
-
1277
- .form-control--has-help-text.form-control--small .form-control__help-text {
1278
- font-size: var(--sl-input-help-text-font-size-small);
1279
- }
1280
-
1281
- .form-control--has-help-text.form-control--medium .form-control__help-text {
1282
- font-size: var(--sl-input-help-text-font-size-medium);
1283
- }
1284
-
1285
- .form-control--has-help-text.form-control--large .form-control__help-text {
1286
- font-size: var(--sl-input-help-text-font-size-large);
1287
- }
1288
-
1289
- .form-control--has-help-text.form-control--radio-group .form-control__help-text {
1290
- margin-top: var(--sl-spacing-2x-small);
1291
- }
1292
- `, D = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakSet(), et = /* @__PURE__ */ new WeakMap(), ae = class {
1293
- constructor(o, t) {
1294
- this.handleFormData = (e) => {
1295
- const r = this.options.disabled(this.host), s = this.options.name(this.host), i = this.options.value(this.host), n = this.host.tagName.toLowerCase() === "sl-button";
1296
- this.host.isConnected && !r && !n && typeof s == "string" && s.length > 0 && typeof i < "u" && (Array.isArray(i) ? i.forEach((d) => {
1297
- e.formData.append(s, d.toString());
1298
- }) : e.formData.append(s, i.toString()));
1299
- }, this.handleFormSubmit = (e) => {
1300
- var r;
1301
- const s = this.options.disabled(this.host), i = this.options.reportValidity;
1302
- this.form && !this.form.noValidate && ((r = D.get(this.form)) == null || r.forEach((n) => {
1303
- this.setUserInteracted(n, !0);
1304
- })), this.form && !this.form.noValidate && !s && !i(this.host) && (e.preventDefault(), e.stopImmediatePropagation());
1305
- }, this.handleFormReset = () => {
1306
- this.options.setValue(this.host, this.options.defaultValue(this.host)), this.setUserInteracted(this.host, !1), et.set(this.host, []);
1307
- }, this.handleInteraction = (e) => {
1308
- const r = et.get(this.host);
1309
- r.includes(e.type) || r.push(e.type), r.length === this.options.assumeInteractionOn.length && this.setUserInteracted(this.host, !0);
1310
- }, this.checkFormValidity = () => {
1311
- if (this.form && !this.form.noValidate) {
1312
- const e = this.form.querySelectorAll("*");
1313
- for (const r of e)
1314
- if (typeof r.checkValidity == "function" && !r.checkValidity())
1315
- return !1;
1250
+ return e.mount = k(at, e), e.handleTokenRequest = ct(e), e.handleDestroyAuth = dt(e), e.presentLoginForm = k(ht, e), e.getToken = k($e, e), e.saveToken = k(ut, e), e.getFreshToken = k(pt, e), e.requestRender = (t) => we(e, t), e;
1251
+ }
1252
+ function at(s) {
1253
+ const e = s.config.toolkit.element.ownerDocument.defaultView;
1254
+ [
1255
+ {
1256
+ type: "action:register",
1257
+ detail: {
1258
+ actionType: "auth:requestToken",
1259
+ handler: s.handleTokenRequest,
1260
+ modName: "auth"
1316
1261
  }
1317
- return !0;
1318
- }, this.reportFormValidity = () => {
1319
- if (this.form && !this.form.noValidate) {
1320
- const e = this.form.querySelectorAll("*");
1321
- for (const r of e)
1322
- if (typeof r.reportValidity == "function" && !r.reportValidity())
1323
- return !1;
1262
+ },
1263
+ {
1264
+ type: "action:register",
1265
+ detail: {
1266
+ actionType: "auth:destroy",
1267
+ handler: s.handleDestroyAuth,
1268
+ modName: "auth"
1269
+ }
1270
+ },
1271
+ {
1272
+ type: "layout:register",
1273
+ detail: {
1274
+ name: "auth:login",
1275
+ slots: ["main"],
1276
+ templateFn: Ke()
1324
1277
  }
1325
- return !0;
1326
- }, (this.host = o).addController(this), this.options = X({
1327
- form: (e) => {
1328
- const r = e.form;
1329
- if (r) {
1330
- const i = e.getRootNode().querySelector(`#${r}`);
1331
- if (i)
1332
- return i;
1333
- }
1334
- return e.closest("form");
1335
- },
1336
- name: (e) => e.name,
1337
- value: (e) => e.value,
1338
- defaultValue: (e) => e.defaultValue,
1339
- disabled: (e) => {
1340
- var r;
1341
- return (r = e.disabled) != null ? r : !1;
1342
- },
1343
- reportValidity: (e) => typeof e.reportValidity == "function" ? e.reportValidity() : !0,
1344
- checkValidity: (e) => typeof e.checkValidity == "function" ? e.checkValidity() : !0,
1345
- setValue: (e, r) => e.value = r,
1346
- assumeInteractionOn: ["sl-input"]
1347
- }, t);
1348
- }
1349
- hostConnected() {
1350
- const o = this.options.form(this.host);
1351
- o && this.attachForm(o), et.set(this.host, []), this.options.assumeInteractionOn.forEach((t) => {
1352
- this.host.addEventListener(t, this.handleInteraction);
1353
- });
1354
- }
1355
- hostDisconnected() {
1356
- this.detachForm(), et.delete(this.host), this.options.assumeInteractionOn.forEach((o) => {
1357
- this.host.removeEventListener(o, this.handleInteraction);
1358
- });
1359
- }
1360
- hostUpdated() {
1361
- const o = this.options.form(this.host);
1362
- o || this.detachForm(), o && this.form !== o && (this.detachForm(), this.attachForm(o)), this.host.hasUpdated && this.setValidity(this.host.validity.valid);
1363
- }
1364
- attachForm(o) {
1365
- o ? (this.form = o, D.has(this.form) ? D.get(this.form).add(this.host) : D.set(this.form, /* @__PURE__ */ new Set([this.host])), this.form.addEventListener("formdata", this.handleFormData), this.form.addEventListener("submit", this.handleFormSubmit), this.form.addEventListener("reset", this.handleFormReset), F.has(this.form) || (F.set(this.form, this.form.reportValidity), this.form.reportValidity = () => this.reportFormValidity()), H.has(this.form) || (H.set(this.form, this.form.checkValidity), this.form.checkValidity = () => this.checkFormValidity())) : this.form = void 0;
1366
- }
1367
- detachForm() {
1368
- if (!this.form)
1369
- return;
1370
- const o = D.get(this.form);
1371
- o && (o.delete(this.host), o.size <= 0 && (this.form.removeEventListener("formdata", this.handleFormData), this.form.removeEventListener("submit", this.handleFormSubmit), this.form.removeEventListener("reset", this.handleFormReset), F.has(this.form) && (this.form.reportValidity = F.get(this.form), F.delete(this.form)), H.has(this.form) && (this.form.checkValidity = H.get(this.form), H.delete(this.form)), this.form = void 0));
1372
- }
1373
- setUserInteracted(o, t) {
1374
- t ? ht.add(o) : ht.delete(o), o.requestUpdate();
1375
- }
1376
- doAction(o, t) {
1377
- if (this.form) {
1378
- const e = document.createElement("button");
1379
- e.type = o, e.style.position = "absolute", e.style.width = "0", e.style.height = "0", e.style.clipPath = "inset(50%)", e.style.overflow = "hidden", e.style.whiteSpace = "nowrap", t && (e.name = t.name, e.value = t.value, ["formaction", "formenctype", "formmethod", "formnovalidate", "formtarget"].forEach((r) => {
1380
- t.hasAttribute(r) && e.setAttribute(r, t.getAttribute(r));
1381
- })), this.form.append(e), e.click(), e.remove();
1382
1278
  }
1383
- }
1384
- /** Returns the associated `<form>` element, if one exists. */
1385
- getForm() {
1386
- var o;
1387
- return (o = this.form) != null ? o : null;
1388
- }
1389
- /** Resets the form, restoring all the control to their default value */
1390
- reset(o) {
1391
- this.doAction("reset", o);
1392
- }
1393
- /** Submits the form, triggering validation and form data injection. */
1394
- submit(o) {
1395
- this.doAction("submit", o);
1396
- }
1397
- /**
1398
- * Synchronously sets the form control's validity. Call this when you know the future validity but need to update
1399
- * the host element immediately, i.e. before Lit updates the component in the next update.
1400
- */
1401
- setValidity(o) {
1402
- const t = this.host, e = !!ht.has(t), r = !!t.required;
1403
- t.toggleAttribute("data-required", r), t.toggleAttribute("data-optional", !r), t.toggleAttribute("data-invalid", !o), t.toggleAttribute("data-valid", o), t.toggleAttribute("data-user-invalid", !o && e), t.toggleAttribute("data-user-valid", o && e);
1404
- }
1405
- /**
1406
- * Updates the form control's validity based on the current value of `host.validity.valid`. Call this when anything
1407
- * that affects constraint validation changes so the component receives the correct validity states.
1408
- */
1409
- updateValidity() {
1410
- const o = this.host;
1411
- this.setValidity(o.validity.valid);
1412
- }
1413
- /**
1414
- * Dispatches a non-bubbling, cancelable custom event of type `sl-invalid`.
1415
- * If the `sl-invalid` event will be cancelled then the original `invalid`
1416
- * event (which may have been passed as argument) will also be cancelled.
1417
- * If no original `invalid` event has been passed then the `sl-invalid`
1418
- * event will be cancelled before being dispatched.
1419
- */
1420
- emitInvalidEvent(o) {
1421
- const t = new CustomEvent("sl-invalid", {
1422
- bubbles: !1,
1423
- composed: !1,
1424
- cancelable: !0,
1425
- detail: {}
1426
- });
1427
- o || t.preventDefault(), this.host.dispatchEvent(t) || o == null || o.preventDefault();
1428
- }
1429
- }, Et = Object.freeze({
1430
- badInput: !1,
1431
- customError: !1,
1432
- patternMismatch: !1,
1433
- rangeOverflow: !1,
1434
- rangeUnderflow: !1,
1435
- stepMismatch: !1,
1436
- tooLong: !1,
1437
- tooShort: !1,
1438
- typeMismatch: !1,
1439
- valid: !0,
1440
- valueMissing: !1
1441
- });
1442
- Object.freeze(oe(X({}, Et), {
1443
- valid: !1,
1444
- valueMissing: !0
1445
- }));
1446
- Object.freeze(oe(X({}, Et), {
1447
- valid: !1,
1448
- customError: !0
1449
- }));
1450
- const gt = /* @__PURE__ */ new Set(), V = /* @__PURE__ */ new Map();
1451
- let z, Pt = "ltr", Tt = "en";
1452
- const le = typeof MutationObserver < "u" && typeof document < "u" && typeof document.documentElement < "u";
1453
- if (le) {
1454
- const o = new MutationObserver(de);
1455
- Pt = document.documentElement.dir || "ltr", Tt = document.documentElement.lang || navigator.language, o.observe(document.documentElement, {
1456
- attributes: !0,
1457
- attributeFilter: ["dir", "lang"]
1458
- });
1459
- }
1460
- function ue(...o) {
1461
- o.map((t) => {
1462
- const e = t.$code.toLowerCase();
1463
- V.has(e) ? V.set(e, Object.assign(Object.assign({}, V.get(e)), t)) : V.set(e, t), z || (z = t);
1464
- }), de();
1465
- }
1466
- function de() {
1467
- le && (Pt = document.documentElement.dir || "ltr", Tt = document.documentElement.lang || navigator.language), [...gt.keys()].map((o) => {
1468
- typeof o.requestUpdate == "function" && o.requestUpdate();
1469
- });
1470
- }
1471
- let to = class {
1472
- constructor(t) {
1473
- this.host = t, this.host.addController(this);
1474
- }
1475
- hostConnected() {
1476
- gt.add(this.host);
1477
- }
1478
- hostDisconnected() {
1479
- gt.delete(this.host);
1480
- }
1481
- dir() {
1482
- return `${this.host.dir || Pt}`.toLowerCase();
1483
- }
1484
- lang() {
1485
- return `${this.host.lang || Tt}`.toLowerCase();
1486
- }
1487
- getTranslationData(t) {
1488
- var e, r;
1489
- const s = new Intl.Locale(t.replace(/_/g, "-")), i = s == null ? void 0 : s.language.toLowerCase(), n = (r = (e = s == null ? void 0 : s.region) === null || e === void 0 ? void 0 : e.toLowerCase()) !== null && r !== void 0 ? r : "", d = V.get(`${i}-${n}`), l = V.get(i);
1490
- return { locale: s, language: i, region: n, primary: d, secondary: l };
1491
- }
1492
- exists(t, e) {
1493
- var r;
1494
- const { primary: s, secondary: i } = this.getTranslationData((r = e.lang) !== null && r !== void 0 ? r : this.lang());
1495
- return e = Object.assign({ includeFallback: !1 }, e), !!(s && s[t] || i && i[t] || e.includeFallback && z && z[t]);
1496
- }
1497
- term(t, ...e) {
1498
- const { primary: r, secondary: s } = this.getTranslationData(this.lang());
1499
- let i;
1500
- if (r && r[t])
1501
- i = r[t];
1502
- else if (s && s[t])
1503
- i = s[t];
1504
- else if (z && z[t])
1505
- i = z[t];
1506
- else
1507
- return console.error(`No translation found for: ${String(t)}`), String(t);
1508
- return typeof i == "function" ? i(...e) : i;
1509
- }
1510
- date(t, e) {
1511
- return t = new Date(t), new Intl.DateTimeFormat(this.lang(), e).format(t);
1512
- }
1513
- number(t, e) {
1514
- return t = Number(t), isNaN(t) ? "" : new Intl.NumberFormat(this.lang(), e).format(t);
1515
- }
1516
- relativeTime(t, e, r) {
1517
- return new Intl.RelativeTimeFormat(this.lang(), r).format(t, e);
1518
- }
1519
- };
1520
- var ce = {
1521
- $code: "en",
1522
- $name: "English",
1523
- $dir: "ltr",
1524
- carousel: "Carousel",
1525
- clearEntry: "Clear entry",
1526
- close: "Close",
1527
- copied: "Copied",
1528
- copy: "Copy",
1529
- currentValue: "Current value",
1530
- error: "Error",
1531
- goToSlide: (o, t) => `Go to slide ${o} of ${t}`,
1532
- hidePassword: "Hide password",
1533
- loading: "Loading",
1534
- nextSlide: "Next slide",
1535
- numOptionsSelected: (o) => o === 0 ? "No options selected" : o === 1 ? "1 option selected" : `${o} options selected`,
1536
- previousSlide: "Previous slide",
1537
- progress: "Progress",
1538
- remove: "Remove",
1539
- resize: "Resize",
1540
- scrollToEnd: "Scroll to end",
1541
- scrollToStart: "Scroll to start",
1542
- selectAColorFromTheScreen: "Select a color from the screen",
1543
- showPassword: "Show password",
1544
- slideNum: (o) => `Slide ${o}`,
1545
- toggleColorFormat: "Toggle color format"
1546
- };
1547
- ue(ce);
1548
- var eo = ce, zt = class extends to {
1549
- };
1550
- ue(eo);
1551
- var vt = "";
1552
- function jt(o) {
1553
- vt = o;
1279
+ ].forEach((t) => s.config.toolkit.dispatchAction(t)), e.addEventListener("popstate", lt(s));
1554
1280
  }
1555
- function oo(o = "") {
1556
- if (!vt) {
1557
- const t = [...document.getElementsByTagName("script")], e = t.find((r) => r.hasAttribute("data-shoelace"));
1558
- if (e)
1559
- jt(e.getAttribute("data-shoelace"));
1560
- else {
1561
- const r = t.find((i) => /shoelace(\.min)?\.js($|\?)/.test(i.src) || /shoelace-autoloader(\.min)?\.js($|\?)/.test(i.src));
1562
- let s = "";
1563
- r && (s = r.getAttribute("src")), jt(s.split("/").slice(0, -1).join("/"));
1281
+ function we(s, e) {
1282
+ const t = s.config.toolkit.element.ownerDocument.defaultView;
1283
+ let r = e;
1284
+ r || (r = Ye(s, t.location.pathname)), r && s.config.toolkit.dispatchAction({
1285
+ type: "layout:slot:replace",
1286
+ detail: {
1287
+ layout: "menu-main-task-layout",
1288
+ slot: "main",
1289
+ content: c`<auth-app .state=${r} .auth=${s}></auth-app>`
1564
1290
  }
1565
- }
1566
- return vt.replace(/\/$/, "") + (o ? `/${o.replace(/^\//, "")}` : "");
1567
- }
1568
- var ro = {
1569
- name: "default",
1570
- resolver: (o) => oo(`assets/icons/${o}.svg`)
1571
- }, so = ro, qt = {
1572
- caret: `
1573
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
1574
- <polyline points="6 9 12 15 18 9"></polyline>
1575
- </svg>
1576
- `,
1577
- check: `
1578
- <svg part="checked-icon" class="checkbox__icon" viewBox="0 0 16 16">
1579
- <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
1580
- <g stroke="currentColor">
1581
- <g transform="translate(3.428571, 3.428571)">
1582
- <path d="M0,5.71428571 L3.42857143,9.14285714"></path>
1583
- <path d="M9.14285714,0 L3.42857143,9.14285714"></path>
1584
- </g>
1585
- </g>
1586
- </g>
1587
- </svg>
1588
- `,
1589
- "chevron-down": `
1590
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">
1591
- <path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/>
1592
- </svg>
1593
- `,
1594
- "chevron-left": `
1595
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-left" viewBox="0 0 16 16">
1596
- <path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/>
1597
- </svg>
1598
- `,
1599
- "chevron-right": `
1600
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-right" viewBox="0 0 16 16">
1601
- <path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
1602
- </svg>
1603
- `,
1604
- copy: `
1605
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-copy" viewBox="0 0 16 16">
1606
- <path fill-rule="evenodd" d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V2Zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H6ZM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1H2Z"/>
1607
- </svg>
1608
- `,
1609
- eye: `
1610
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye" viewBox="0 0 16 16">
1611
- <path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8zM1.173 8a13.133 13.133 0 0 1 1.66-2.043C4.12 4.668 5.88 3.5 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.133 13.133 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755C11.879 11.332 10.119 12.5 8 12.5c-2.12 0-3.879-1.168-5.168-2.457A13.134 13.134 0 0 1 1.172 8z"/>
1612
- <path d="M8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5zM4.5 8a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0z"/>
1613
- </svg>
1614
- `,
1615
- "eye-slash": `
1616
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye-slash" viewBox="0 0 16 16">
1617
- <path d="M13.359 11.238C15.06 9.72 16 8 16 8s-3-5.5-8-5.5a7.028 7.028 0 0 0-2.79.588l.77.771A5.944 5.944 0 0 1 8 3.5c2.12 0 3.879 1.168 5.168 2.457A13.134 13.134 0 0 1 14.828 8c-.058.087-.122.183-.195.288-.335.48-.83 1.12-1.465 1.755-.165.165-.337.328-.517.486l.708.709z"/>
1618
- <path d="M11.297 9.176a3.5 3.5 0 0 0-4.474-4.474l.823.823a2.5 2.5 0 0 1 2.829 2.829l.822.822zm-2.943 1.299.822.822a3.5 3.5 0 0 1-4.474-4.474l.823.823a2.5 2.5 0 0 0 2.829 2.829z"/>
1619
- <path d="M3.35 5.47c-.18.16-.353.322-.518.487A13.134 13.134 0 0 0 1.172 8l.195.288c.335.48.83 1.12 1.465 1.755C4.121 11.332 5.881 12.5 8 12.5c.716 0 1.39-.133 2.02-.36l.77.772A7.029 7.029 0 0 1 8 13.5C3 13.5 0 8 0 8s.939-1.721 2.641-3.238l.708.709zm10.296 8.884-12-12 .708-.708 12 12-.708.708z"/>
1620
- </svg>
1621
- `,
1622
- eyedropper: `
1623
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eyedropper" viewBox="0 0 16 16">
1624
- <path d="M13.354.646a1.207 1.207 0 0 0-1.708 0L8.5 3.793l-.646-.647a.5.5 0 1 0-.708.708L8.293 5l-7.147 7.146A.5.5 0 0 0 1 12.5v1.793l-.854.853a.5.5 0 1 0 .708.707L1.707 15H3.5a.5.5 0 0 0 .354-.146L11 7.707l1.146 1.147a.5.5 0 0 0 .708-.708l-.647-.646 3.147-3.146a1.207 1.207 0 0 0 0-1.708l-2-2zM2 12.707l7-7L10.293 7l-7 7H2v-1.293z"></path>
1625
- </svg>
1626
- `,
1627
- "grip-vertical": `
1628
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-grip-vertical" viewBox="0 0 16 16">
1629
- <path d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zM7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"></path>
1630
- </svg>
1631
- `,
1632
- indeterminate: `
1633
- <svg part="indeterminate-icon" class="checkbox__icon" viewBox="0 0 16 16">
1634
- <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round">
1635
- <g stroke="currentColor" stroke-width="2">
1636
- <g transform="translate(2.285714, 6.857143)">
1637
- <path d="M10.2857143,1.14285714 L1.14285714,1.14285714"></path>
1638
- </g>
1639
- </g>
1640
- </g>
1641
- </svg>
1642
- `,
1643
- "person-fill": `
1644
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-fill" viewBox="0 0 16 16">
1645
- <path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/>
1646
- </svg>
1647
- `,
1648
- "play-fill": `
1649
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play-fill" viewBox="0 0 16 16">
1650
- <path d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393z"></path>
1651
- </svg>
1652
- `,
1653
- "pause-fill": `
1654
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pause-fill" viewBox="0 0 16 16">
1655
- <path d="M5.5 3.5A1.5 1.5 0 0 1 7 5v6a1.5 1.5 0 0 1-3 0V5a1.5 1.5 0 0 1 1.5-1.5zm5 0A1.5 1.5 0 0 1 12 5v6a1.5 1.5 0 0 1-3 0V5a1.5 1.5 0 0 1 1.5-1.5z"></path>
1656
- </svg>
1657
- `,
1658
- radio: `
1659
- <svg part="checked-icon" class="radio__icon" viewBox="0 0 16 16">
1660
- <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1661
- <g fill="currentColor">
1662
- <circle cx="8" cy="8" r="3.42857143"></circle>
1663
- </g>
1664
- </g>
1665
- </svg>
1666
- `,
1667
- "star-fill": `
1668
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
1669
- <path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
1670
- </svg>
1671
- `,
1672
- "x-lg": `
1673
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">
1674
- <path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>
1675
- </svg>
1676
- `,
1677
- "x-circle-fill": `
1678
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle-fill" viewBox="0 0 16 16">
1679
- <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z"></path>
1680
- </svg>
1681
- `
1682
- }, io = {
1683
- name: "system",
1684
- resolver: (o) => o in qt ? `data:image/svg+xml,${encodeURIComponent(qt[o])}` : ""
1685
- }, no = io, ao = [so, no], yt = [];
1686
- function lo(o) {
1687
- yt.push(o);
1688
- }
1689
- function uo(o) {
1690
- yt = yt.filter((t) => t !== o);
1691
- }
1692
- function Wt(o) {
1693
- return ao.find((t) => t.name === o);
1291
+ });
1694
1292
  }
1695
- var co = $`
1696
- :host {
1697
- display: inline-block;
1698
- width: 1em;
1699
- height: 1em;
1700
- box-sizing: content-box !important;
1701
- }
1702
-
1703
- svg {
1704
- display: block;
1705
- height: 100%;
1706
- width: 100%;
1707
- }
1708
- `;
1709
- function M(o, t) {
1710
- const e = X({
1711
- waitUntilFirstUpdate: !1
1712
- }, t);
1713
- return (r, s) => {
1714
- const { update: i } = r, n = Array.isArray(o) ? o : [o];
1715
- r.update = function(d) {
1716
- n.forEach((l) => {
1717
- const c = l;
1718
- if (d.has(c)) {
1719
- const b = d.get(c), p = this[c];
1720
- b !== p && (!e.waitUntilFirstUpdate || this.hasUpdated) && this[s](b, p);
1721
- }
1722
- }), i.call(this, d);
1723
- };
1293
+ function lt(s) {
1294
+ return (e) => {
1295
+ s.log("onpopstate", e), we(s);
1724
1296
  };
1725
1297
  }
1726
- /**
1727
- * @license
1728
- * Copyright 2020 Google LLC
1729
- * SPDX-License-Identifier: BSD-3-Clause
1730
- */
1731
- const ho = (o, t) => (o == null ? void 0 : o._$litType$) !== void 0, po = (o) => o.strings === void 0, bo = {}, fo = (o, t = bo) => o._$AH = t;
1732
- var j = Symbol(), ot = Symbol(), pt, bt = /* @__PURE__ */ new Map(), x = class extends k {
1733
- constructor() {
1734
- super(...arguments), this.initialRender = !1, this.svg = null, this.label = "", this.library = "default";
1735
- }
1736
- /** Given a URL, this function returns the resulting SVG element or an appropriate error symbol. */
1737
- async resolveIcon(o, t) {
1738
- var e;
1739
- let r;
1740
- if (t != null && t.spriteSheet) {
1741
- this.svg = v`<svg part="svg">
1742
- <use part="use" href="${o}"></use>
1743
- </svg>`, await this.updateComplete;
1744
- const s = this.shadowRoot.querySelector("[part='svg']");
1745
- return typeof t.mutator == "function" && t.mutator(s), this.svg;
1746
- }
1747
- try {
1748
- if (r = await fetch(o, { mode: "cors" }), !r.ok)
1749
- return r.status === 410 ? j : ot;
1750
- } catch {
1751
- return ot;
1752
- }
1298
+ function ct(s) {
1299
+ let e = [], t = !1;
1300
+ const r = (o) => {
1301
+ e.forEach((i) => {
1302
+ i(o);
1303
+ }), e = [];
1304
+ };
1305
+ return async ({ callback: o }) => {
1306
+ let i;
1753
1307
  try {
1754
- const s = document.createElement("div");
1755
- s.innerHTML = await r.text();
1756
- const i = s.firstElementChild;
1757
- if (((e = i == null ? void 0 : i.tagName) == null ? void 0 : e.toLowerCase()) !== "svg")
1758
- return j;
1759
- pt || (pt = new DOMParser());
1760
- const d = pt.parseFromString(i.outerHTML, "text/html").body.querySelector("svg");
1761
- return d ? (d.part.add("svg"), document.adoptNode(d)) : j;
1762
- } catch {
1763
- return j;
1764
- }
1765
- }
1766
- connectedCallback() {
1767
- super.connectedCallback(), lo(this);
1768
- }
1769
- firstUpdated() {
1770
- this.initialRender = !0, this.setIcon();
1771
- }
1772
- disconnectedCallback() {
1773
- super.disconnectedCallback(), uo(this);
1774
- }
1775
- getIconSource() {
1776
- const o = Wt(this.library);
1777
- return this.name && o ? {
1778
- url: o.resolver(this.name),
1779
- fromLibrary: !0
1780
- } : {
1781
- url: this.src,
1782
- fromLibrary: !1
1783
- };
1784
- }
1785
- handleLabelChange() {
1786
- typeof this.label == "string" && this.label.length > 0 ? (this.setAttribute("role", "img"), this.setAttribute("aria-label", this.label), this.removeAttribute("aria-hidden")) : (this.removeAttribute("role"), this.removeAttribute("aria-label"), this.setAttribute("aria-hidden", "true"));
1787
- }
1788
- async setIcon() {
1789
- var o;
1790
- const { url: t, fromLibrary: e } = this.getIconSource(), r = e ? Wt(this.library) : void 0;
1791
- if (!t) {
1792
- this.svg = null;
1793
- return;
1794
- }
1795
- let s = bt.get(t);
1796
- if (s || (s = this.resolveIcon(t, r), bt.set(t, s)), !this.initialRender)
1797
- return;
1798
- const i = await s;
1799
- if (i === ot && bt.delete(t), t === this.getIconSource().url) {
1800
- if (ho(i)) {
1801
- this.svg = i;
1802
- return;
1803
- }
1804
- switch (i) {
1805
- case ot:
1806
- case j:
1807
- this.svg = null, this.emit("sl-error");
1808
- break;
1809
- default:
1810
- this.svg = i.cloneNode(!0), (o = r == null ? void 0 : r.mutator) == null || o.call(r, this.svg), this.emit("sl-load");
1811
- }
1308
+ i = await s.getFreshToken(), o(i);
1309
+ } catch (n) {
1310
+ e.push(o), t || (s.presentLoginForm({ onLogin: r }), t = !0), s.log(n);
1812
1311
  }
1813
- }
1814
- render() {
1815
- return this.svg;
1816
- }
1817
- };
1818
- x.styles = [Q, co];
1819
- a([
1820
- at()
1821
- ], x.prototype, "svg", 2);
1822
- a([
1823
- u({ reflect: !0 })
1824
- ], x.prototype, "name", 2);
1825
- a([
1826
- u()
1827
- ], x.prototype, "src", 2);
1828
- a([
1829
- u()
1830
- ], x.prototype, "label", 2);
1831
- a([
1832
- u({ reflect: !0 })
1833
- ], x.prototype, "library", 2);
1834
- a([
1835
- M("label")
1836
- ], x.prototype, "handleLabelChange", 1);
1837
- a([
1838
- M(["name", "src", "library"])
1839
- ], x.prototype, "setIcon", 1);
1840
- /**
1841
- * @license
1842
- * Copyright 2018 Google LLC
1843
- * SPDX-License-Identifier: BSD-3-Clause
1844
- */
1845
- const m = (o) => o ?? g;
1846
- /**
1847
- * @license
1848
- * Copyright 2020 Google LLC
1849
- * SPDX-License-Identifier: BSD-3-Clause
1850
- */
1851
- const mo = se(class extends ie {
1852
- constructor(o) {
1853
- if (super(o), o.type !== T.PROPERTY && o.type !== T.ATTRIBUTE && o.type !== T.BOOLEAN_ATTRIBUTE) throw Error("The `live` directive is not allowed on child or event bindings");
1854
- if (!po(o)) throw Error("`live` bindings can only contain a single expression");
1855
- }
1856
- render(o) {
1857
- return o;
1858
- }
1859
- update(o, [t]) {
1860
- if (t === w || t === g) return t;
1861
- const e = o.element, r = o.name;
1862
- if (o.type === T.PROPERTY) {
1863
- if (t === e[r]) return w;
1864
- } else if (o.type === T.BOOLEAN_ATTRIBUTE) {
1865
- if (!!t === e.hasAttribute(r)) return w;
1866
- } else if (o.type === T.ATTRIBUTE && e.getAttribute(r) === t + "") return w;
1867
- return fo(o), t;
1868
- }
1869
- });
1870
- var h = class extends k {
1871
- constructor() {
1872
- super(...arguments), this.formControlController = new ae(this, {
1873
- assumeInteractionOn: ["sl-blur", "sl-input"]
1874
- }), this.hasSlotController = new St(this, "help-text", "label"), this.localize = new zt(this), this.hasFocus = !1, this.title = "", this.__numberInput = Object.assign(document.createElement("input"), { type: "number" }), this.__dateInput = Object.assign(document.createElement("input"), { type: "date" }), this.type = "text", this.name = "", this.value = "", this.defaultValue = "", this.size = "medium", this.filled = !1, this.pill = !1, this.label = "", this.helpText = "", this.clearable = !1, this.disabled = !1, this.placeholder = "", this.readonly = !1, this.passwordToggle = !1, this.passwordVisible = !1, this.noSpinButtons = !1, this.form = "", this.required = !1, this.spellcheck = !0;
1875
- }
1876
- //
1877
- // NOTE: We use an in-memory input for these getters/setters instead of the one in the template because the properties
1878
- // can be set before the component is rendered.
1879
- //
1880
- /**
1881
- * Gets or sets the current value as a `Date` object. Returns `null` if the value can't be converted. This will use the native `<input type="{{type}}">` implementation and may result in an error.
1882
- */
1883
- get valueAsDate() {
1884
- var o;
1885
- return this.__dateInput.type = this.type, this.__dateInput.value = this.value, ((o = this.input) == null ? void 0 : o.valueAsDate) || this.__dateInput.valueAsDate;
1886
- }
1887
- set valueAsDate(o) {
1888
- this.__dateInput.type = this.type, this.__dateInput.valueAsDate = o, this.value = this.__dateInput.value;
1889
- }
1890
- /** Gets or sets the current value as a number. Returns `NaN` if the value can't be converted. */
1891
- get valueAsNumber() {
1892
- var o;
1893
- return this.__numberInput.value = this.value, ((o = this.input) == null ? void 0 : o.valueAsNumber) || this.__numberInput.valueAsNumber;
1894
- }
1895
- set valueAsNumber(o) {
1896
- this.__numberInput.valueAsNumber = o, this.value = this.__numberInput.value;
1897
- }
1898
- /** Gets the validity state object */
1899
- get validity() {
1900
- return this.input.validity;
1901
- }
1902
- /** Gets the validation message */
1903
- get validationMessage() {
1904
- return this.input.validationMessage;
1905
- }
1906
- firstUpdated() {
1907
- this.formControlController.updateValidity();
1908
- }
1909
- handleBlur() {
1910
- this.hasFocus = !1, this.emit("sl-blur");
1911
- }
1912
- handleChange() {
1913
- this.value = this.input.value, this.emit("sl-change");
1914
- }
1915
- handleClearClick(o) {
1916
- o.preventDefault(), this.value !== "" && (this.value = "", this.emit("sl-clear"), this.emit("sl-input"), this.emit("sl-change")), this.input.focus();
1917
- }
1918
- handleFocus() {
1919
- this.hasFocus = !0, this.emit("sl-focus");
1920
- }
1921
- handleInput() {
1922
- this.value = this.input.value, this.formControlController.updateValidity(), this.emit("sl-input");
1923
- }
1924
- handleInvalid(o) {
1925
- this.formControlController.setValidity(!1), this.formControlController.emitInvalidEvent(o);
1926
- }
1927
- handleKeyDown(o) {
1928
- const t = o.metaKey || o.ctrlKey || o.shiftKey || o.altKey;
1929
- o.key === "Enter" && !t && setTimeout(() => {
1930
- !o.defaultPrevented && !o.isComposing && this.formControlController.submit();
1312
+ };
1313
+ }
1314
+ function dt(s) {
1315
+ return () => {
1316
+ const e = Y(s);
1317
+ window.localStorage.removeItem(e), s.config.toolkit.dispatchAction({
1318
+ type: "layout:pop"
1931
1319
  });
1932
- }
1933
- handlePasswordToggle() {
1934
- this.passwordVisible = !this.passwordVisible;
1935
- }
1936
- handleDisabledChange() {
1937
- this.formControlController.setValidity(this.disabled);
1938
- }
1939
- handleStepChange() {
1940
- this.input.step = String(this.step), this.formControlController.updateValidity();
1941
- }
1942
- async handleValueChange() {
1943
- await this.updateComplete, this.formControlController.updateValidity();
1944
- }
1945
- /** Sets focus on the input. */
1946
- focus(o) {
1947
- this.input.focus(o);
1948
- }
1949
- /** Removes focus from the input. */
1950
- blur() {
1951
- this.input.blur();
1952
- }
1953
- /** Selects all the text in the input. */
1954
- select() {
1955
- this.input.select();
1956
- }
1957
- /** Sets the start and end positions of the text selection (0-based). */
1958
- setSelectionRange(o, t, e = "none") {
1959
- this.input.setSelectionRange(o, t, e);
1960
- }
1961
- /** Replaces a range of text with a new string. */
1962
- setRangeText(o, t, e, r = "preserve") {
1963
- const s = t ?? this.input.selectionStart, i = e ?? this.input.selectionEnd;
1964
- this.input.setRangeText(o, s, i, r), this.value !== this.input.value && (this.value = this.input.value);
1965
- }
1966
- /** Displays the browser picker for an input element (only works if the browser supports it for the input type). */
1967
- showPicker() {
1968
- "showPicker" in HTMLInputElement.prototype && this.input.showPicker();
1969
- }
1970
- /** Increments the value of a numeric input type by the value of the step attribute. */
1971
- stepUp() {
1972
- this.input.stepUp(), this.value !== this.input.value && (this.value = this.input.value);
1973
- }
1974
- /** Decrements the value of a numeric input type by the value of the step attribute. */
1975
- stepDown() {
1976
- this.input.stepDown(), this.value !== this.input.value && (this.value = this.input.value);
1977
- }
1978
- /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
1979
- checkValidity() {
1980
- return this.input.checkValidity();
1981
- }
1982
- /** Gets the associated form, if one exists. */
1983
- getForm() {
1984
- return this.formControlController.getForm();
1985
- }
1986
- /** Checks for validity and shows the browser's validation message if the control is invalid. */
1987
- reportValidity() {
1988
- return this.input.reportValidity();
1989
- }
1990
- /** Sets a custom validation message. Pass an empty string to restore validity. */
1991
- setCustomValidity(o) {
1992
- this.input.setCustomValidity(o), this.formControlController.updateValidity();
1993
- }
1994
- render() {
1995
- const o = this.hasSlotController.test("label"), t = this.hasSlotController.test("help-text"), e = this.label ? !0 : !!o, r = this.helpText ? !0 : !!t, i = this.clearable && !this.disabled && !this.readonly && (typeof this.value == "number" || this.value.length > 0);
1996
- return v`
1997
- <div
1998
- part="form-control"
1999
- class=${it({
2000
- "form-control": !0,
2001
- "form-control--small": this.size === "small",
2002
- "form-control--medium": this.size === "medium",
2003
- "form-control--large": this.size === "large",
2004
- "form-control--has-label": e,
2005
- "form-control--has-help-text": r
2006
- })}
2007
- >
2008
- <label
2009
- part="form-control-label"
2010
- class="form-control__label"
2011
- for="input"
2012
- aria-hidden=${e ? "false" : "true"}
2013
- >
2014
- <slot name="label">${this.label}</slot>
2015
- </label>
2016
-
2017
- <div part="form-control-input" class="form-control-input">
2018
- <div
2019
- part="base"
2020
- class=${it({
2021
- input: !0,
2022
- // Sizes
2023
- "input--small": this.size === "small",
2024
- "input--medium": this.size === "medium",
2025
- "input--large": this.size === "large",
2026
- // States
2027
- "input--pill": this.pill,
2028
- "input--standard": !this.filled,
2029
- "input--filled": this.filled,
2030
- "input--disabled": this.disabled,
2031
- "input--focused": this.hasFocus,
2032
- "input--empty": !this.value,
2033
- "input--no-spin-buttons": this.noSpinButtons
2034
- })}
2035
- >
2036
- <span part="prefix" class="input__prefix">
2037
- <slot name="prefix"></slot>
2038
- </span>
2039
-
2040
- <input
2041
- part="input"
2042
- id="input"
2043
- class="input__control"
2044
- type=${this.type === "password" && this.passwordVisible ? "text" : this.type}
2045
- title=${this.title}
2046
- name=${m(this.name)}
2047
- ?disabled=${this.disabled}
2048
- ?readonly=${this.readonly}
2049
- ?required=${this.required}
2050
- placeholder=${m(this.placeholder)}
2051
- minlength=${m(this.minlength)}
2052
- maxlength=${m(this.maxlength)}
2053
- min=${m(this.min)}
2054
- max=${m(this.max)}
2055
- step=${m(this.step)}
2056
- .value=${mo(this.value)}
2057
- autocapitalize=${m(this.autocapitalize)}
2058
- autocomplete=${m(this.autocomplete)}
2059
- autocorrect=${m(this.autocorrect)}
2060
- ?autofocus=${this.autofocus}
2061
- spellcheck=${this.spellcheck}
2062
- pattern=${m(this.pattern)}
2063
- enterkeyhint=${m(this.enterkeyhint)}
2064
- inputmode=${m(this.inputmode)}
2065
- aria-describedby="help-text"
2066
- @change=${this.handleChange}
2067
- @input=${this.handleInput}
2068
- @invalid=${this.handleInvalid}
2069
- @keydown=${this.handleKeyDown}
2070
- @focus=${this.handleFocus}
2071
- @blur=${this.handleBlur}
2072
- />
2073
-
2074
- ${i ? v`
2075
- <button
2076
- part="clear-button"
2077
- class="input__clear"
2078
- type="button"
2079
- aria-label=${this.localize.term("clearEntry")}
2080
- @click=${this.handleClearClick}
2081
- tabindex="-1"
2082
- >
2083
- <slot name="clear-icon">
2084
- <sl-icon name="x-circle-fill" library="system"></sl-icon>
2085
- </slot>
2086
- </button>
2087
- ` : ""}
2088
- ${this.passwordToggle && !this.disabled ? v`
2089
- <button
2090
- part="password-toggle-button"
2091
- class="input__password-toggle"
2092
- type="button"
2093
- aria-label=${this.localize.term(this.passwordVisible ? "hidePassword" : "showPassword")}
2094
- @click=${this.handlePasswordToggle}
2095
- tabindex="-1"
2096
- >
2097
- ${this.passwordVisible ? v`
2098
- <slot name="show-password-icon">
2099
- <sl-icon name="eye-slash" library="system"></sl-icon>
2100
- </slot>
2101
- ` : v`
2102
- <slot name="hide-password-icon">
2103
- <sl-icon name="eye" library="system"></sl-icon>
2104
- </slot>
2105
- `}
2106
- </button>
2107
- ` : ""}
2108
-
2109
- <span part="suffix" class="input__suffix">
2110
- <slot name="suffix"></slot>
2111
- </span>
2112
- </div>
2113
- </div>
2114
-
2115
- <div
2116
- part="form-control-help-text"
2117
- id="help-text"
2118
- class="form-control__help-text"
2119
- aria-hidden=${r ? "false" : "true"}
2120
- >
2121
- <slot name="help-text">${this.helpText}</slot>
2122
- </div>
2123
- </div>
2124
- `;
2125
- }
2126
- };
2127
- h.styles = [Q, Xe, Ge];
2128
- h.dependencies = { "sl-icon": x };
2129
- a([
2130
- re(".input__control")
2131
- ], h.prototype, "input", 2);
2132
- a([
2133
- at()
2134
- ], h.prototype, "hasFocus", 2);
2135
- a([
2136
- u()
2137
- ], h.prototype, "title", 2);
2138
- a([
2139
- u({ reflect: !0 })
2140
- ], h.prototype, "type", 2);
2141
- a([
2142
- u()
2143
- ], h.prototype, "name", 2);
2144
- a([
2145
- u()
2146
- ], h.prototype, "value", 2);
2147
- a([
2148
- Qe()
2149
- ], h.prototype, "defaultValue", 2);
2150
- a([
2151
- u({ reflect: !0 })
2152
- ], h.prototype, "size", 2);
2153
- a([
2154
- u({ type: Boolean, reflect: !0 })
2155
- ], h.prototype, "filled", 2);
2156
- a([
2157
- u({ type: Boolean, reflect: !0 })
2158
- ], h.prototype, "pill", 2);
2159
- a([
2160
- u()
2161
- ], h.prototype, "label", 2);
2162
- a([
2163
- u({ attribute: "help-text" })
2164
- ], h.prototype, "helpText", 2);
2165
- a([
2166
- u({ type: Boolean })
2167
- ], h.prototype, "clearable", 2);
2168
- a([
2169
- u({ type: Boolean, reflect: !0 })
2170
- ], h.prototype, "disabled", 2);
2171
- a([
2172
- u()
2173
- ], h.prototype, "placeholder", 2);
2174
- a([
2175
- u({ type: Boolean, reflect: !0 })
2176
- ], h.prototype, "readonly", 2);
2177
- a([
2178
- u({ attribute: "password-toggle", type: Boolean })
2179
- ], h.prototype, "passwordToggle", 2);
2180
- a([
2181
- u({ attribute: "password-visible", type: Boolean })
2182
- ], h.prototype, "passwordVisible", 2);
2183
- a([
2184
- u({ attribute: "no-spin-buttons", type: Boolean })
2185
- ], h.prototype, "noSpinButtons", 2);
2186
- a([
2187
- u({ reflect: !0 })
2188
- ], h.prototype, "form", 2);
2189
- a([
2190
- u({ type: Boolean, reflect: !0 })
2191
- ], h.prototype, "required", 2);
2192
- a([
2193
- u()
2194
- ], h.prototype, "pattern", 2);
2195
- a([
2196
- u({ type: Number })
2197
- ], h.prototype, "minlength", 2);
2198
- a([
2199
- u({ type: Number })
2200
- ], h.prototype, "maxlength", 2);
2201
- a([
2202
- u()
2203
- ], h.prototype, "min", 2);
2204
- a([
2205
- u()
2206
- ], h.prototype, "max", 2);
2207
- a([
2208
- u()
2209
- ], h.prototype, "step", 2);
2210
- a([
2211
- u()
2212
- ], h.prototype, "autocapitalize", 2);
2213
- a([
2214
- u()
2215
- ], h.prototype, "autocorrect", 2);
2216
- a([
2217
- u()
2218
- ], h.prototype, "autocomplete", 2);
2219
- a([
2220
- u({ type: Boolean })
2221
- ], h.prototype, "autofocus", 2);
2222
- a([
2223
- u()
2224
- ], h.prototype, "enterkeyhint", 2);
2225
- a([
2226
- u({
2227
- type: Boolean,
2228
- converter: {
2229
- // Allow "true|false" attribute values but keep the property boolean
2230
- fromAttribute: (o) => !(!o || o === "false"),
2231
- toAttribute: (o) => o ? "true" : "false"
2232
- }
2233
- })
2234
- ], h.prototype, "spellcheck", 2);
2235
- a([
2236
- u()
2237
- ], h.prototype, "inputmode", 2);
2238
- a([
2239
- M("disabled", { waitUntilFirstUpdate: !0 })
2240
- ], h.prototype, "handleDisabledChange", 1);
2241
- a([
2242
- M("step", { waitUntilFirstUpdate: !0 })
2243
- ], h.prototype, "handleStepChange", 1);
2244
- a([
2245
- M("value", { waitUntilFirstUpdate: !0 })
2246
- ], h.prototype, "handleValueChange", 1);
2247
- h.define("sl-input");
2248
- var go = $`
2249
- :host {
2250
- --track-width: 2px;
2251
- --track-color: rgb(128 128 128 / 25%);
2252
- --indicator-color: var(--sl-color-primary-600);
2253
- --speed: 2s;
2254
-
2255
- display: inline-flex;
2256
- width: 1em;
2257
- height: 1em;
2258
- flex: none;
2259
- }
2260
-
2261
- .spinner {
2262
- flex: 1 1 auto;
2263
- height: 100%;
2264
- width: 100%;
2265
- }
2266
-
2267
- .spinner__track,
2268
- .spinner__indicator {
2269
- fill: none;
2270
- stroke-width: var(--track-width);
2271
- r: calc(0.5em - var(--track-width) / 2);
2272
- cx: 0.5em;
2273
- cy: 0.5em;
2274
- transform-origin: 50% 50%;
2275
- }
2276
-
2277
- .spinner__track {
2278
- stroke: var(--track-color);
2279
- transform-origin: 0% 0%;
2280
- }
2281
-
2282
- .spinner__indicator {
2283
- stroke: var(--indicator-color);
2284
- stroke-linecap: round;
2285
- stroke-dasharray: 150% 75%;
2286
- animation: spin var(--speed) linear infinite;
2287
- }
2288
-
2289
- @keyframes spin {
2290
- 0% {
2291
- transform: rotate(0deg);
2292
- stroke-dasharray: 0.05em, 3em;
2293
- }
2294
-
2295
- 50% {
2296
- transform: rotate(450deg);
2297
- stroke-dasharray: 1.375em, 1.375em;
1320
+ };
1321
+ }
1322
+ function ht(s, { onLogin: e }) {
1323
+ const { toolkit: t } = s.config, o = new URLSearchParams(
1324
+ t.element.ownerDocument.defaultView.location.search
1325
+ ).get("password_reset_confirmation"), i = (n) => {
1326
+ s.log("login success", { event: n });
1327
+ const { token: l } = n.detail;
1328
+ s.log("Login form dismissed", { args: [l] }), t.dispatchAction({
1329
+ type: "layout:pop"
1330
+ }), s.saveToken({ token: l }), e({ token: l });
1331
+ };
1332
+ t.dispatchAction({
1333
+ type: "layout:push",
1334
+ detail: {
1335
+ layout: "auth:login"
2298
1336
  }
2299
-
2300
- 100% {
2301
- transform: rotate(1080deg);
2302
- stroke-dasharray: 0.05em, 3em;
1337
+ }), t.dispatchAction({
1338
+ type: "layout:slot:push",
1339
+ detail: {
1340
+ layout: "auth:login",
1341
+ slot: "main",
1342
+ content: c`<auth-login-form
1343
+ api=${s.config.api}
1344
+ confirmation="${o}"
1345
+ @login-success=${i}>
1346
+ </auth-login-form>`
2303
1347
  }
2304
- }
2305
- `, he = class extends k {
2306
- constructor() {
2307
- super(...arguments), this.localize = new zt(this);
2308
- }
2309
- render() {
2310
- return v`
2311
- <svg part="base" class="spinner" role="progressbar" aria-label=${this.localize.term("loading")}>
2312
- <circle class="spinner__track"></circle>
2313
- <circle class="spinner__indicator"></circle>
2314
- </svg>
2315
- `;
2316
- }
2317
- };
2318
- he.styles = [Q, go];
2319
- var vo = $`
2320
- :host {
2321
- display: inline-block;
2322
- position: relative;
2323
- width: auto;
2324
- cursor: pointer;
2325
- }
2326
-
2327
- .button {
2328
- display: inline-flex;
2329
- align-items: stretch;
2330
- justify-content: center;
2331
- width: 100%;
2332
- border-style: solid;
2333
- border-width: var(--sl-input-border-width);
2334
- font-family: var(--sl-input-font-family);
2335
- font-weight: var(--sl-font-weight-semibold);
2336
- text-decoration: none;
2337
- user-select: none;
2338
- -webkit-user-select: none;
2339
- white-space: nowrap;
2340
- vertical-align: middle;
2341
- padding: 0;
2342
- transition:
2343
- var(--sl-transition-x-fast) background-color,
2344
- var(--sl-transition-x-fast) color,
2345
- var(--sl-transition-x-fast) border,
2346
- var(--sl-transition-x-fast) box-shadow;
2347
- cursor: inherit;
2348
- }
2349
-
2350
- .button::-moz-focus-inner {
2351
- border: 0;
2352
- }
2353
-
2354
- .button:focus {
2355
- outline: none;
2356
- }
2357
-
2358
- .button:focus-visible {
2359
- outline: var(--sl-focus-ring);
2360
- outline-offset: var(--sl-focus-ring-offset);
2361
- }
2362
-
2363
- .button--disabled {
2364
- opacity: 0.5;
2365
- cursor: not-allowed;
2366
- }
2367
-
2368
- /* When disabled, prevent mouse events from bubbling up from children */
2369
- .button--disabled * {
2370
- pointer-events: none;
2371
- }
2372
-
2373
- .button__prefix,
2374
- .button__suffix {
2375
- flex: 0 0 auto;
2376
- display: flex;
2377
- align-items: center;
2378
- pointer-events: none;
2379
- }
2380
-
2381
- .button__label {
2382
- display: inline-block;
2383
- }
2384
-
2385
- .button__label::slotted(sl-icon) {
2386
- vertical-align: -2px;
2387
- }
2388
-
2389
- /*
2390
- * Standard buttons
2391
- */
2392
-
2393
- /* Default */
2394
- .button--standard.button--default {
2395
- background-color: var(--sl-color-neutral-0);
2396
- border-color: var(--sl-input-border-color);
2397
- color: var(--sl-color-neutral-700);
2398
- }
2399
-
2400
- .button--standard.button--default:hover:not(.button--disabled) {
2401
- background-color: var(--sl-color-primary-50);
2402
- border-color: var(--sl-color-primary-300);
2403
- color: var(--sl-color-primary-700);
2404
- }
2405
-
2406
- .button--standard.button--default:active:not(.button--disabled) {
2407
- background-color: var(--sl-color-primary-100);
2408
- border-color: var(--sl-color-primary-400);
2409
- color: var(--sl-color-primary-700);
2410
- }
2411
-
2412
- /* Primary */
2413
- .button--standard.button--primary {
2414
- background-color: var(--sl-color-primary-600);
2415
- border-color: var(--sl-color-primary-600);
2416
- color: var(--sl-color-neutral-0);
2417
- }
2418
-
2419
- .button--standard.button--primary:hover:not(.button--disabled) {
2420
- background-color: var(--sl-color-primary-500);
2421
- border-color: var(--sl-color-primary-500);
2422
- color: var(--sl-color-neutral-0);
2423
- }
2424
-
2425
- .button--standard.button--primary:active:not(.button--disabled) {
2426
- background-color: var(--sl-color-primary-600);
2427
- border-color: var(--sl-color-primary-600);
2428
- color: var(--sl-color-neutral-0);
2429
- }
2430
-
2431
- /* Success */
2432
- .button--standard.button--success {
2433
- background-color: var(--sl-color-success-600);
2434
- border-color: var(--sl-color-success-600);
2435
- color: var(--sl-color-neutral-0);
2436
- }
2437
-
2438
- .button--standard.button--success:hover:not(.button--disabled) {
2439
- background-color: var(--sl-color-success-500);
2440
- border-color: var(--sl-color-success-500);
2441
- color: var(--sl-color-neutral-0);
2442
- }
2443
-
2444
- .button--standard.button--success:active:not(.button--disabled) {
2445
- background-color: var(--sl-color-success-600);
2446
- border-color: var(--sl-color-success-600);
2447
- color: var(--sl-color-neutral-0);
2448
- }
2449
-
2450
- /* Neutral */
2451
- .button--standard.button--neutral {
2452
- background-color: var(--sl-color-neutral-600);
2453
- border-color: var(--sl-color-neutral-600);
2454
- color: var(--sl-color-neutral-0);
2455
- }
2456
-
2457
- .button--standard.button--neutral:hover:not(.button--disabled) {
2458
- background-color: var(--sl-color-neutral-500);
2459
- border-color: var(--sl-color-neutral-500);
2460
- color: var(--sl-color-neutral-0);
2461
- }
2462
-
2463
- .button--standard.button--neutral:active:not(.button--disabled) {
2464
- background-color: var(--sl-color-neutral-600);
2465
- border-color: var(--sl-color-neutral-600);
2466
- color: var(--sl-color-neutral-0);
2467
- }
2468
-
2469
- /* Warning */
2470
- .button--standard.button--warning {
2471
- background-color: var(--sl-color-warning-600);
2472
- border-color: var(--sl-color-warning-600);
2473
- color: var(--sl-color-neutral-0);
2474
- }
2475
- .button--standard.button--warning:hover:not(.button--disabled) {
2476
- background-color: var(--sl-color-warning-500);
2477
- border-color: var(--sl-color-warning-500);
2478
- color: var(--sl-color-neutral-0);
2479
- }
2480
-
2481
- .button--standard.button--warning:active:not(.button--disabled) {
2482
- background-color: var(--sl-color-warning-600);
2483
- border-color: var(--sl-color-warning-600);
2484
- color: var(--sl-color-neutral-0);
2485
- }
2486
-
2487
- /* Danger */
2488
- .button--standard.button--danger {
2489
- background-color: var(--sl-color-danger-600);
2490
- border-color: var(--sl-color-danger-600);
2491
- color: var(--sl-color-neutral-0);
2492
- }
2493
-
2494
- .button--standard.button--danger:hover:not(.button--disabled) {
2495
- background-color: var(--sl-color-danger-500);
2496
- border-color: var(--sl-color-danger-500);
2497
- color: var(--sl-color-neutral-0);
2498
- }
2499
-
2500
- .button--standard.button--danger:active:not(.button--disabled) {
2501
- background-color: var(--sl-color-danger-600);
2502
- border-color: var(--sl-color-danger-600);
2503
- color: var(--sl-color-neutral-0);
2504
- }
2505
-
2506
- /*
2507
- * Outline buttons
2508
- */
2509
-
2510
- .button--outline {
2511
- background: none;
2512
- border: solid 1px;
2513
- }
2514
-
2515
- /* Default */
2516
- .button--outline.button--default {
2517
- border-color: var(--sl-input-border-color);
2518
- color: var(--sl-color-neutral-700);
2519
- }
2520
-
2521
- .button--outline.button--default:hover:not(.button--disabled),
2522
- .button--outline.button--default.button--checked:not(.button--disabled) {
2523
- border-color: var(--sl-color-primary-600);
2524
- background-color: var(--sl-color-primary-600);
2525
- color: var(--sl-color-neutral-0);
2526
- }
2527
-
2528
- .button--outline.button--default:active:not(.button--disabled) {
2529
- border-color: var(--sl-color-primary-700);
2530
- background-color: var(--sl-color-primary-700);
2531
- color: var(--sl-color-neutral-0);
2532
- }
2533
-
2534
- /* Primary */
2535
- .button--outline.button--primary {
2536
- border-color: var(--sl-color-primary-600);
2537
- color: var(--sl-color-primary-600);
2538
- }
2539
-
2540
- .button--outline.button--primary:hover:not(.button--disabled),
2541
- .button--outline.button--primary.button--checked:not(.button--disabled) {
2542
- background-color: var(--sl-color-primary-600);
2543
- color: var(--sl-color-neutral-0);
2544
- }
2545
-
2546
- .button--outline.button--primary:active:not(.button--disabled) {
2547
- border-color: var(--sl-color-primary-700);
2548
- background-color: var(--sl-color-primary-700);
2549
- color: var(--sl-color-neutral-0);
2550
- }
2551
-
2552
- /* Success */
2553
- .button--outline.button--success {
2554
- border-color: var(--sl-color-success-600);
2555
- color: var(--sl-color-success-600);
2556
- }
2557
-
2558
- .button--outline.button--success:hover:not(.button--disabled),
2559
- .button--outline.button--success.button--checked:not(.button--disabled) {
2560
- background-color: var(--sl-color-success-600);
2561
- color: var(--sl-color-neutral-0);
2562
- }
2563
-
2564
- .button--outline.button--success:active:not(.button--disabled) {
2565
- border-color: var(--sl-color-success-700);
2566
- background-color: var(--sl-color-success-700);
2567
- color: var(--sl-color-neutral-0);
2568
- }
2569
-
2570
- /* Neutral */
2571
- .button--outline.button--neutral {
2572
- border-color: var(--sl-color-neutral-600);
2573
- color: var(--sl-color-neutral-600);
2574
- }
2575
-
2576
- .button--outline.button--neutral:hover:not(.button--disabled),
2577
- .button--outline.button--neutral.button--checked:not(.button--disabled) {
2578
- background-color: var(--sl-color-neutral-600);
2579
- color: var(--sl-color-neutral-0);
2580
- }
2581
-
2582
- .button--outline.button--neutral:active:not(.button--disabled) {
2583
- border-color: var(--sl-color-neutral-700);
2584
- background-color: var(--sl-color-neutral-700);
2585
- color: var(--sl-color-neutral-0);
2586
- }
2587
-
2588
- /* Warning */
2589
- .button--outline.button--warning {
2590
- border-color: var(--sl-color-warning-600);
2591
- color: var(--sl-color-warning-600);
2592
- }
2593
-
2594
- .button--outline.button--warning:hover:not(.button--disabled),
2595
- .button--outline.button--warning.button--checked:not(.button--disabled) {
2596
- background-color: var(--sl-color-warning-600);
2597
- color: var(--sl-color-neutral-0);
2598
- }
2599
-
2600
- .button--outline.button--warning:active:not(.button--disabled) {
2601
- border-color: var(--sl-color-warning-700);
2602
- background-color: var(--sl-color-warning-700);
2603
- color: var(--sl-color-neutral-0);
2604
- }
2605
-
2606
- /* Danger */
2607
- .button--outline.button--danger {
2608
- border-color: var(--sl-color-danger-600);
2609
- color: var(--sl-color-danger-600);
2610
- }
2611
-
2612
- .button--outline.button--danger:hover:not(.button--disabled),
2613
- .button--outline.button--danger.button--checked:not(.button--disabled) {
2614
- background-color: var(--sl-color-danger-600);
2615
- color: var(--sl-color-neutral-0);
2616
- }
2617
-
2618
- .button--outline.button--danger:active:not(.button--disabled) {
2619
- border-color: var(--sl-color-danger-700);
2620
- background-color: var(--sl-color-danger-700);
2621
- color: var(--sl-color-neutral-0);
2622
- }
2623
-
2624
- @media (forced-colors: active) {
2625
- .button.button--outline.button--checked:not(.button--disabled) {
2626
- outline: solid 2px transparent;
2627
- }
2628
- }
2629
-
2630
- /*
2631
- * Text buttons
2632
- */
2633
-
2634
- .button--text {
2635
- background-color: transparent;
2636
- border-color: transparent;
2637
- color: var(--sl-color-primary-600);
2638
- }
2639
-
2640
- .button--text:hover:not(.button--disabled) {
2641
- background-color: transparent;
2642
- border-color: transparent;
2643
- color: var(--sl-color-primary-500);
2644
- }
2645
-
2646
- .button--text:focus-visible:not(.button--disabled) {
2647
- background-color: transparent;
2648
- border-color: transparent;
2649
- color: var(--sl-color-primary-500);
2650
- }
2651
-
2652
- .button--text:active:not(.button--disabled) {
2653
- background-color: transparent;
2654
- border-color: transparent;
2655
- color: var(--sl-color-primary-700);
2656
- }
2657
-
2658
- /*
2659
- * Size modifiers
2660
- */
2661
-
2662
- .button--small {
2663
- height: auto;
2664
- min-height: var(--sl-input-height-small);
2665
- font-size: var(--sl-button-font-size-small);
2666
- line-height: calc(var(--sl-input-height-small) - var(--sl-input-border-width) * 2);
2667
- border-radius: var(--sl-input-border-radius-small);
2668
- }
2669
-
2670
- .button--medium {
2671
- height: auto;
2672
- min-height: var(--sl-input-height-medium);
2673
- font-size: var(--sl-button-font-size-medium);
2674
- line-height: calc(var(--sl-input-height-medium) - var(--sl-input-border-width) * 2);
2675
- border-radius: var(--sl-input-border-radius-medium);
2676
- }
2677
-
2678
- .button--large {
2679
- height: auto;
2680
- min-height: var(--sl-input-height-large);
2681
- font-size: var(--sl-button-font-size-large);
2682
- line-height: calc(var(--sl-input-height-large) - var(--sl-input-border-width) * 2);
2683
- border-radius: var(--sl-input-border-radius-large);
2684
- }
2685
-
2686
- /*
2687
- * Pill modifier
2688
- */
2689
-
2690
- .button--pill.button--small {
2691
- border-radius: var(--sl-input-height-small);
2692
- }
2693
-
2694
- .button--pill.button--medium {
2695
- border-radius: var(--sl-input-height-medium);
2696
- }
2697
-
2698
- .button--pill.button--large {
2699
- border-radius: var(--sl-input-height-large);
2700
- }
2701
-
2702
- /*
2703
- * Circle modifier
2704
- */
2705
-
2706
- .button--circle {
2707
- padding-left: 0;
2708
- padding-right: 0;
2709
- }
2710
-
2711
- .button--circle.button--small {
2712
- width: var(--sl-input-height-small);
2713
- border-radius: 50%;
2714
- }
2715
-
2716
- .button--circle.button--medium {
2717
- width: var(--sl-input-height-medium);
2718
- border-radius: 50%;
2719
- }
2720
-
2721
- .button--circle.button--large {
2722
- width: var(--sl-input-height-large);
2723
- border-radius: 50%;
2724
- }
2725
-
2726
- .button--circle .button__prefix,
2727
- .button--circle .button__suffix,
2728
- .button--circle .button__caret {
2729
- display: none;
2730
- }
2731
-
2732
- /*
2733
- * Caret modifier
2734
- */
2735
-
2736
- .button--caret .button__suffix {
2737
- display: none;
2738
- }
2739
-
2740
- .button--caret .button__caret {
2741
- height: auto;
2742
- }
2743
-
2744
- /*
2745
- * Loading modifier
2746
- */
2747
-
2748
- .button--loading {
2749
- position: relative;
2750
- cursor: wait;
2751
- }
2752
-
2753
- .button--loading .button__prefix,
2754
- .button--loading .button__label,
2755
- .button--loading .button__suffix,
2756
- .button--loading .button__caret {
2757
- visibility: hidden;
2758
- }
2759
-
2760
- .button--loading sl-spinner {
2761
- --indicator-color: currentColor;
2762
- position: absolute;
2763
- font-size: 1em;
2764
- height: 1em;
2765
- width: 1em;
2766
- top: calc(50% - 0.5em);
2767
- left: calc(50% - 0.5em);
2768
- }
2769
-
2770
- /*
2771
- * Badges
2772
- */
2773
-
2774
- .button ::slotted(sl-badge) {
2775
- position: absolute;
2776
- top: 0;
2777
- right: 0;
2778
- translate: 50% -50%;
2779
- pointer-events: none;
2780
- }
2781
-
2782
- .button--rtl ::slotted(sl-badge) {
2783
- right: auto;
2784
- left: 0;
2785
- translate: -50% -50%;
2786
- }
2787
-
2788
- /*
2789
- * Button spacing
2790
- */
2791
-
2792
- .button--has-label.button--small .button__label {
2793
- padding: 0 var(--sl-spacing-small);
2794
- }
2795
-
2796
- .button--has-label.button--medium .button__label {
2797
- padding: 0 var(--sl-spacing-medium);
2798
- }
2799
-
2800
- .button--has-label.button--large .button__label {
2801
- padding: 0 var(--sl-spacing-large);
2802
- }
2803
-
2804
- .button--has-prefix.button--small {
2805
- padding-inline-start: var(--sl-spacing-x-small);
2806
- }
2807
-
2808
- .button--has-prefix.button--small .button__label {
2809
- padding-inline-start: var(--sl-spacing-x-small);
2810
- }
2811
-
2812
- .button--has-prefix.button--medium {
2813
- padding-inline-start: var(--sl-spacing-small);
2814
- }
2815
-
2816
- .button--has-prefix.button--medium .button__label {
2817
- padding-inline-start: var(--sl-spacing-small);
2818
- }
2819
-
2820
- .button--has-prefix.button--large {
2821
- padding-inline-start: var(--sl-spacing-small);
2822
- }
2823
-
2824
- .button--has-prefix.button--large .button__label {
2825
- padding-inline-start: var(--sl-spacing-small);
2826
- }
2827
-
2828
- .button--has-suffix.button--small,
2829
- .button--caret.button--small {
2830
- padding-inline-end: var(--sl-spacing-x-small);
2831
- }
2832
-
2833
- .button--has-suffix.button--small .button__label,
2834
- .button--caret.button--small .button__label {
2835
- padding-inline-end: var(--sl-spacing-x-small);
2836
- }
2837
-
2838
- .button--has-suffix.button--medium,
2839
- .button--caret.button--medium {
2840
- padding-inline-end: var(--sl-spacing-small);
2841
- }
2842
-
2843
- .button--has-suffix.button--medium .button__label,
2844
- .button--caret.button--medium .button__label {
2845
- padding-inline-end: var(--sl-spacing-small);
2846
- }
2847
-
2848
- .button--has-suffix.button--large,
2849
- .button--caret.button--large {
2850
- padding-inline-end: var(--sl-spacing-small);
2851
- }
2852
-
2853
- .button--has-suffix.button--large .button__label,
2854
- .button--caret.button--large .button__label {
2855
- padding-inline-end: var(--sl-spacing-small);
2856
- }
2857
-
2858
- /*
2859
- * Button groups support a variety of button types (e.g. buttons with tooltips, buttons as dropdown triggers, etc.).
2860
- * This means buttons aren't always direct descendants of the button group, thus we can't target them with the
2861
- * ::slotted selector. To work around this, the button group component does some magic to add these special classes to
2862
- * buttons and we style them here instead.
2863
- */
2864
-
2865
- :host([data-sl-button-group__button--first]:not([data-sl-button-group__button--last])) .button {
2866
- border-start-end-radius: 0;
2867
- border-end-end-radius: 0;
2868
- }
2869
-
2870
- :host([data-sl-button-group__button--inner]) .button {
2871
- border-radius: 0;
2872
- }
2873
-
2874
- :host([data-sl-button-group__button--last]:not([data-sl-button-group__button--first])) .button {
2875
- border-start-start-radius: 0;
2876
- border-end-start-radius: 0;
2877
- }
2878
-
2879
- /* All except the first */
2880
- :host([data-sl-button-group__button]:not([data-sl-button-group__button--first])) {
2881
- margin-inline-start: calc(-1 * var(--sl-input-border-width));
2882
- }
2883
-
2884
- /* Add a visual separator between solid buttons */
2885
- :host(
2886
- [data-sl-button-group__button]:not(
2887
- [data-sl-button-group__button--first],
2888
- [data-sl-button-group__button--radio],
2889
- [variant='default']
2890
- ):not(:hover)
2891
- )
2892
- .button:after {
2893
- content: '';
2894
- position: absolute;
2895
- top: 0;
2896
- inset-inline-start: 0;
2897
- bottom: 0;
2898
- border-left: solid 1px rgb(128 128 128 / 33%);
2899
- mix-blend-mode: multiply;
2900
- }
2901
-
2902
- /* Bump hovered, focused, and checked buttons up so their focus ring isn't clipped */
2903
- :host([data-sl-button-group__button--hover]) {
2904
- z-index: 1;
2905
- }
2906
-
2907
- /* Focus and checked are always on top */
2908
- :host([data-sl-button-group__button--focus]),
2909
- :host([data-sl-button-group__button][checked]) {
2910
- z-index: 2;
2911
- }
2912
- `;
2913
- /**
2914
- * @license
2915
- * Copyright 2020 Google LLC
2916
- * SPDX-License-Identifier: BSD-3-Clause
2917
- */
2918
- const pe = Symbol.for(""), yo = (o) => {
2919
- if ((o == null ? void 0 : o.r) === pe) return o == null ? void 0 : o._$litStatic$;
2920
- }, Kt = (o, ...t) => ({ _$litStatic$: t.reduce((e, r, s) => e + ((i) => {
2921
- if (i._$litStatic$ !== void 0) return i._$litStatic$;
2922
- throw Error(`Value passed to 'literal' function must be a 'literal' result: ${i}. Use 'unsafeStatic' to pass non-literal values, but
2923
- take care to ensure page security.`);
2924
- })(r) + o[s + 1], o[0]), r: pe }), Zt = /* @__PURE__ */ new Map(), wo = (o) => (t, ...e) => {
2925
- const r = e.length;
2926
- let s, i;
2927
- const n = [], d = [];
2928
- let l, c = 0, b = !1;
2929
- for (; c < r; ) {
2930
- for (l = t[c]; c < r && (i = e[c], (s = yo(i)) !== void 0); ) l += s + t[++c], b = !0;
2931
- c !== r && d.push(i), n.push(l), c++;
2932
- }
2933
- if (c === r && n.push(t[r]), b) {
2934
- const p = n.join("$$lit$$");
2935
- (t = Zt.get(p)) === void 0 && (n.raw = n, Zt.set(p, t = n)), e = d;
2936
- }
2937
- return o(t, ...e);
2938
- }, ft = wo(v);
2939
- var f = class extends k {
2940
- constructor() {
2941
- super(...arguments), this.formControlController = new ae(this, {
2942
- assumeInteractionOn: ["click"]
2943
- }), this.hasSlotController = new St(this, "[default]", "prefix", "suffix"), this.localize = new zt(this), this.hasFocus = !1, this.invalid = !1, this.title = "", this.variant = "default", this.size = "medium", this.caret = !1, this.disabled = !1, this.loading = !1, this.outline = !1, this.pill = !1, this.circle = !1, this.type = "button", this.name = "", this.value = "", this.href = "", this.rel = "noreferrer noopener";
2944
- }
2945
- /** Gets the validity state object */
2946
- get validity() {
2947
- return this.isButton() ? this.button.validity : Et;
2948
- }
2949
- /** Gets the validation message */
2950
- get validationMessage() {
2951
- return this.isButton() ? this.button.validationMessage : "";
2952
- }
2953
- firstUpdated() {
2954
- this.isButton() && this.formControlController.updateValidity();
2955
- }
2956
- handleBlur() {
2957
- this.hasFocus = !1, this.emit("sl-blur");
2958
- }
2959
- handleFocus() {
2960
- this.hasFocus = !0, this.emit("sl-focus");
2961
- }
2962
- handleClick() {
2963
- this.type === "submit" && this.formControlController.submit(this), this.type === "reset" && this.formControlController.reset(this);
2964
- }
2965
- handleInvalid(o) {
2966
- this.formControlController.setValidity(!1), this.formControlController.emitInvalidEvent(o);
2967
- }
2968
- isButton() {
2969
- return !this.href;
2970
- }
2971
- isLink() {
2972
- return !!this.href;
2973
- }
2974
- handleDisabledChange() {
2975
- this.isButton() && this.formControlController.setValidity(this.disabled);
2976
- }
2977
- /** Simulates a click on the button. */
2978
- click() {
2979
- this.button.click();
2980
- }
2981
- /** Sets focus on the button. */
2982
- focus(o) {
2983
- this.button.focus(o);
2984
- }
2985
- /** Removes focus from the button. */
2986
- blur() {
2987
- this.button.blur();
2988
- }
2989
- /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
2990
- checkValidity() {
2991
- return this.isButton() ? this.button.checkValidity() : !0;
2992
- }
2993
- /** Gets the associated form, if one exists. */
2994
- getForm() {
2995
- return this.formControlController.getForm();
2996
- }
2997
- /** Checks for validity and shows the browser's validation message if the control is invalid. */
2998
- reportValidity() {
2999
- return this.isButton() ? this.button.reportValidity() : !0;
3000
- }
3001
- /** Sets a custom validation message. Pass an empty string to restore validity. */
3002
- setCustomValidity(o) {
3003
- this.isButton() && (this.button.setCustomValidity(o), this.formControlController.updateValidity());
3004
- }
3005
- render() {
3006
- const o = this.isLink(), t = o ? Kt`a` : Kt`button`;
3007
- return ft`
3008
- <${t}
3009
- part="base"
3010
- class=${it({
3011
- button: !0,
3012
- "button--default": this.variant === "default",
3013
- "button--primary": this.variant === "primary",
3014
- "button--success": this.variant === "success",
3015
- "button--neutral": this.variant === "neutral",
3016
- "button--warning": this.variant === "warning",
3017
- "button--danger": this.variant === "danger",
3018
- "button--text": this.variant === "text",
3019
- "button--small": this.size === "small",
3020
- "button--medium": this.size === "medium",
3021
- "button--large": this.size === "large",
3022
- "button--caret": this.caret,
3023
- "button--circle": this.circle,
3024
- "button--disabled": this.disabled,
3025
- "button--focused": this.hasFocus,
3026
- "button--loading": this.loading,
3027
- "button--standard": !this.outline,
3028
- "button--outline": this.outline,
3029
- "button--pill": this.pill,
3030
- "button--rtl": this.localize.dir() === "rtl",
3031
- "button--has-label": this.hasSlotController.test("[default]"),
3032
- "button--has-prefix": this.hasSlotController.test("prefix"),
3033
- "button--has-suffix": this.hasSlotController.test("suffix")
3034
- })}
3035
- ?disabled=${m(o ? void 0 : this.disabled)}
3036
- type=${m(o ? void 0 : this.type)}
3037
- title=${this.title}
3038
- name=${m(o ? void 0 : this.name)}
3039
- value=${m(o ? void 0 : this.value)}
3040
- href=${m(o ? this.href : void 0)}
3041
- target=${m(o ? this.target : void 0)}
3042
- download=${m(o ? this.download : void 0)}
3043
- rel=${m(o ? this.rel : void 0)}
3044
- role=${m(o ? void 0 : "button")}
3045
- aria-disabled=${this.disabled ? "true" : "false"}
3046
- tabindex=${this.disabled ? "-1" : "0"}
3047
- @blur=${this.handleBlur}
3048
- @focus=${this.handleFocus}
3049
- @invalid=${this.isButton() ? this.handleInvalid : null}
3050
- @click=${this.handleClick}
3051
- >
3052
- <slot name="prefix" part="prefix" class="button__prefix"></slot>
3053
- <slot part="label" class="button__label"></slot>
3054
- <slot name="suffix" part="suffix" class="button__suffix"></slot>
3055
- ${this.caret ? ft` <sl-icon part="caret" class="button__caret" library="system" name="caret"></sl-icon> ` : ""}
3056
- ${this.loading ? ft`<sl-spinner part="spinner"></sl-spinner>` : ""}
3057
- </${t}>
3058
- `;
3059
- }
3060
- };
3061
- f.styles = [Q, vo];
3062
- f.dependencies = {
3063
- "sl-icon": x,
3064
- "sl-spinner": he
3065
- };
3066
- a([
3067
- re(".button")
3068
- ], f.prototype, "button", 2);
3069
- a([
3070
- at()
3071
- ], f.prototype, "hasFocus", 2);
3072
- a([
3073
- at()
3074
- ], f.prototype, "invalid", 2);
3075
- a([
3076
- u()
3077
- ], f.prototype, "title", 2);
3078
- a([
3079
- u({ reflect: !0 })
3080
- ], f.prototype, "variant", 2);
3081
- a([
3082
- u({ reflect: !0 })
3083
- ], f.prototype, "size", 2);
3084
- a([
3085
- u({ type: Boolean, reflect: !0 })
3086
- ], f.prototype, "caret", 2);
3087
- a([
3088
- u({ type: Boolean, reflect: !0 })
3089
- ], f.prototype, "disabled", 2);
3090
- a([
3091
- u({ type: Boolean, reflect: !0 })
3092
- ], f.prototype, "loading", 2);
3093
- a([
3094
- u({ type: Boolean, reflect: !0 })
3095
- ], f.prototype, "outline", 2);
3096
- a([
3097
- u({ type: Boolean, reflect: !0 })
3098
- ], f.prototype, "pill", 2);
3099
- a([
3100
- u({ type: Boolean, reflect: !0 })
3101
- ], f.prototype, "circle", 2);
3102
- a([
3103
- u()
3104
- ], f.prototype, "type", 2);
3105
- a([
3106
- u()
3107
- ], f.prototype, "name", 2);
3108
- a([
3109
- u()
3110
- ], f.prototype, "value", 2);
3111
- a([
3112
- u()
3113
- ], f.prototype, "href", 2);
3114
- a([
3115
- u()
3116
- ], f.prototype, "target", 2);
3117
- a([
3118
- u()
3119
- ], f.prototype, "rel", 2);
3120
- a([
3121
- u()
3122
- ], f.prototype, "download", 2);
3123
- a([
3124
- u()
3125
- ], f.prototype, "form", 2);
3126
- a([
3127
- u({ attribute: "formaction" })
3128
- ], f.prototype, "formAction", 2);
3129
- a([
3130
- u({ attribute: "formenctype" })
3131
- ], f.prototype, "formEnctype", 2);
3132
- a([
3133
- u({ attribute: "formmethod" })
3134
- ], f.prototype, "formMethod", 2);
3135
- a([
3136
- u({ attribute: "formnovalidate", type: Boolean })
3137
- ], f.prototype, "formNoValidate", 2);
3138
- a([
3139
- u({ attribute: "formtarget" })
3140
- ], f.prototype, "formTarget", 2);
3141
- a([
3142
- M("disabled", { waitUntilFirstUpdate: !0 })
3143
- ], f.prototype, "handleDisabledChange", 1);
3144
- f.define("sl-button");
3145
- class wt extends S {
3146
- constructor() {
3147
- super(), this.username = "", this.password = "", this.disabled = !1;
3148
- }
3149
- handleSubmit(t) {
3150
- t.preventDefault(), this.dispatchEvent(
3151
- new CustomEvent("login-attempt", {
3152
- detail: {
3153
- username: this.username,
3154
- password: this.password
3155
- },
3156
- bubbles: !0,
3157
- composed: !0
3158
- })
3159
- );
3160
- }
3161
- handleInputChange(t) {
3162
- const { name: e, value: r } = t.target;
3163
- this[e] = r;
3164
- }
3165
- render() {
3166
- return v`
3167
- <sl-card>
3168
- <form @submit="${this.handleSubmit}">
3169
- <sl-input
3170
- name="username"
3171
- placeholder="Username or Email"
3172
- .value="${this.username}"
3173
- autocomplete="username"
3174
- @sl-change="${this.handleInputChange}">
3175
- </sl-input>
3176
- <sl-input
3177
- type="password"
3178
- name="password"
3179
- placeholder="Password"
3180
- .value="${this.password}"
3181
- autocomplete="current-password"
3182
- @sl-change="${this.handleInputChange}">
3183
- </sl-input>
3184
- <sl-button type="submit" ?disabled="${this.disabled}">Login</sl-button>
3185
- </form>
3186
- </sl-card>
3187
- `;
3188
- }
3189
- }
3190
- E(wt, "styles", $`
3191
- :host {
3192
- display: flex;
3193
- justify-content: center;
3194
- align-items: center;
3195
- height: 100vh;
3196
- box-sizing: border-box;
3197
- }
3198
- sl-card {
3199
- width: 300px;
3200
- --padding: var(--sl-card-padding);
3201
- --background-color: var(--sl-card-background-color);
3202
- --border-radius: var(--sl-card-border-radius);
3203
- --box-shadow: var(--sl-card-shadow);
3204
- }
3205
- sl-input, sl-button {
3206
- width: 100%;
3207
- margin-bottom: 10px;
3208
- }
3209
- `), E(wt, "properties", {
3210
- username: { type: String },
3211
- password: { type: String },
3212
- disabled: { type: Boolean, reflect: !0 }
3213
- });
3214
- customElements.define("studio-login", wt);
3215
- class _t extends S {
3216
- constructor() {
3217
- super(), this.currentPassword = "", this.newPassword = "", this.confirmPassword = "";
3218
- }
3219
- render() {
3220
- return v`
3221
- <form @submit="${this.handleSubmit}">
3222
- <input type="password" name="currentPassword"
3223
- autocomplete="current-password"
3224
- placeholder="Current Password"
3225
- .value="${this.currentPassword}"
3226
- @input="${this.updateProperty("currentPassword")}"
3227
- >
3228
- <input type="password" name="newPassword"
3229
- placeholder="New Password"
3230
- .value="${this.newPassword}"
3231
- @input="${this.updateProperty("newPassword")}"
3232
- >
3233
- <input type="password" name="confirmPassword"
3234
- placeholder="Confirm New Password"
3235
- .value="${this.confirmPassword}"
3236
- @input="${this.updateProperty("confirmPassword")}"
3237
- >
3238
- <button type="submit">Change Password</button>
3239
- </form>
3240
- `;
3241
- }
3242
- updateProperty(t) {
3243
- return (e) => {
3244
- this[t] = e.target.value;
3245
- };
3246
- }
3247
- handleSubmit(t) {
3248
- t.preventDefault(), this.newPassword === this.confirmPassword ? this.dispatchEvent(new CustomEvent("change-password", {
3249
- detail: {
3250
- currentPassword: this.currentPassword,
3251
- newPassword: this.newPassword
3252
- }
3253
- })) : alert("The new passwords do not match.");
3254
- }
3255
- }
3256
- E(_t, "styles", $`
3257
- :host {
3258
- display: block;
3259
- box-sizing: border-box;
3260
- }
3261
- input, button {
3262
- width: 100%;
3263
- margin-bottom: 10px;
3264
- padding: 8px;
3265
- box-sizing: border-box;
3266
- }
3267
- `), E(_t, "properties", {
3268
- currentPassword: { type: String },
3269
- newPassword: { type: String },
3270
- confirmPassword: { type: String }
3271
- });
3272
- customElements.define("studio-change-password", _t);
3273
- class $t extends S {
3274
- constructor() {
3275
- super(), this.apibaseurl = "", this.error = "", this.isAwaiting = !1, this.lastResult = void 0, this.forceChangePassword = !1, this.handleLogin = this.handleLogin.bind(this), this.handleLoginResult = this.handleLoginResult.bind(this), this.handleLoginError = this.handleLoginError.bind(this), this.renderPasswordChangeForm = this.renderPasswordChangeForm.bind(this);
3276
- }
3277
- handleLogin(t) {
3278
- this.isAwaiting = !0;
3279
- const { username: e, password: r } = t.detail, s = mt({ baseUrl: this.apibaseurl });
3280
- this.requestUpdate(), s.mintToken({ username: e, password: r }).then(this.handleLoginResult).catch(this.handleLoginError);
3281
- }
3282
- handleLoginResult(t) {
3283
- var e;
3284
- this.error = "", this.isAwaiting = !1, this.lastResult = t, ((e = t.challenge) == null ? void 0 : e.name) === "NEW_PASSWORD_REQUIRED" ? (this.forceChangePassword = !0, this.error = "You must set a new password to continue.") : this.dispatchEvent(new CustomEvent("login-success", { detail: t })), this.requestUpdate();
3285
- }
3286
- handleLoginError(t) {
3287
- var e, r;
3288
- console.error("Error logging in:", t), this.error = ((r = (e = t == null ? void 0 : t.body) == null ? void 0 : e.error) == null ? void 0 : r.message) || "Invalid username or password", this.isAwaiting = !1, this.requestUpdate();
3289
- }
3290
- handleChangePassword(t) {
3291
- const { currentPassword: e, newPassword: r } = t.detail, { token: s } = this.lastResult, i = mt({ baseUrl: this.apibaseurl });
3292
- this.requestUpdate(), i.updatePassword({ token: s, currentPassword: e, newPassword: r }).then(() => {
3293
- this.forceChangePassword = !1, this.error = "Login with your new password.", this.isAwaiting = !1, this.requestUpdate();
3294
- }).catch((n) => {
3295
- var d, l;
3296
- this.error = ((l = (d = n == null ? void 0 : n.body) == null ? void 0 : d.error) == null ? void 0 : l.message) || n.message, this.isAwaiting = !1, this.requestUpdate();
3297
- });
3298
- }
3299
- renderPasswordChangeForm() {
3300
- return v`
3301
- <div>
3302
- ${this.error ? v`<div class="error">${this.error}</div>` : null}
3303
- <studio-change-password @change-password=${this.handleChangePassword}>
3304
- </studio-change-password>
3305
- </div>
3306
- `;
3307
- }
3308
- renderLoginForm() {
3309
- return v`
3310
- ${this.error ? v`<div class="error">${this.error}</div>` : null}
3311
- <studio-login
3312
- @login-attempt=${this.handleLogin}
3313
- ?disabled=${this.isAwaiting}
3314
- ></studio-login>
3315
- `;
3316
- }
3317
- render() {
3318
- return this.forceChangePassword ? this.renderPasswordChangeForm() : this.renderLoginForm();
3319
- }
3320
- }
3321
- E($t, "properties", {
3322
- apibaseurl: { type: String },
3323
- error: { type: String }
3324
- }), E($t, "styles", $`
3325
- :host {
3326
- display: block;
3327
- max-width: 400px;
3328
- margin: 0 auto;
3329
- }
3330
- `);
3331
- window.customElements.define("mod-auth-login-form", $t);
3332
- function be({ studio: o, config: t }) {
3333
- return new Promise((e, r) => {
3334
- let s = window.sessionStorage.getItem(K());
3335
- if (s) {
3336
- ko(s) ? _o({ studio: o, config: t, token: s }).then(e).catch((l) => {
3337
- console.error("Failed to refresh token:", l), window.sessionStorage.removeItem(K()), be({ studio: o, config: t }).then(e).catch(r);
3338
- }) : e(s);
3339
- return;
3340
- }
3341
- const i = (l) => (window.sessionStorage.setItem(K(), l), l);
3342
- let n;
3343
- const d = (l) => {
3344
- const { token: c } = l.detail;
3345
- i(c), e(c), o.pub("system::workspace", "dismiss", n);
3346
- };
3347
- n = v`<mod-auth-login-form
3348
- id="login"
3349
- apibaseurl=${t.apibaseurl}
3350
- @login-success=${d}></mod-auth-login-form>`, o.pub("system::workspace", "present", n);
3351
1348
  });
3352
1349
  }
3353
- async function _o({ studio: o, config: t, token: e }) {
3354
- const r = t.apibaseurl, s = mt({ baseUrl: r }), { token: i } = await s.refreshToken({ token: e });
3355
- return window.sessionStorage.setItem(K(), i), i;
3356
- }
3357
- function $o({ studio: o }) {
3358
- window.sessionStorage.removeItem(K());
1350
+ function ut(s, { token: e }) {
1351
+ s.log("saving token", { args: [e] });
1352
+ const t = Y(s);
1353
+ window.localStorage.setItem(t, e);
3359
1354
  }
3360
- function xo(o) {
3361
- return JSON.parse(window.atob(o.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")));
1355
+ function $e(s) {
1356
+ const e = Y(s);
1357
+ return window.localStorage.getItem(e);
3362
1358
  }
3363
- function ko(o, t = 300, e = Date.now()) {
3364
- return xo(o).exp * 1e3 - t < e;
1359
+ async function pt(s) {
1360
+ const e = $e(s);
1361
+ if (!e || e.length < 1)
1362
+ throw new Error("No token found");
1363
+ return Je(e) ? (s.log("refreshing token", { args: [e] }), await x({
1364
+ baseUrl: s.config.api
1365
+ }).refreshToken({ token: e }).then(({ token: r }) => r)) : e;
3365
1366
  }
3366
- function K() {
3367
- return "studio.wral::auth_token";
1367
+ function Y({ storageKey: s = "token" }) {
1368
+ return s;
3368
1369
  }
3369
- function Eo(o, t) {
3370
- o.sub("studio.wral::mod-auth", "token-request", ({ state: e }) => {
3371
- const { callback: r } = e.value;
3372
- r ? be({ studio: o, config: t }).then((s) => r(s)).catch((s) => r(null, s)) : console.warn("No token callback defined");
3373
- }), o.sub("studio.wral::mod-auth", "logout", () => {
3374
- $o({ studio: o });
1370
+ function gt(s, e) {
1371
+ const t = be(s, e), r = nt(t);
1372
+ r.mount(), r.requestRender(), t.forceLogin && G(s.element).then((o) => {
1373
+ r.log("You have logged in successfully!", o);
3375
1374
  });
3376
1375
  }
3377
1376
  export {
3378
- Eo as init
1377
+ gt as init
3379
1378
  };