@cal.macconnachie/web-components 0.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.
package/dist/index ADDED
@@ -0,0 +1,2437 @@
1
+ import { css as kt, LitElement as Ct, nothing as $, html as m } from "lit";
2
+ const xt = (e) => (t, s) => {
3
+ s !== void 0 ? s.addInitializer((() => {
4
+ customElements.define(e, t);
5
+ })) : customElements.define(e, t);
6
+ };
7
+ const z = globalThis, Z = z.ShadowRoot && (z.ShadyCSS === void 0 || z.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, yt = Symbol(), it = /* @__PURE__ */ new WeakMap();
8
+ let Et = class {
9
+ constructor(t, s, i) {
10
+ if (this._$cssResult$ = !0, i !== yt) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
11
+ this.cssText = t, this.t = s;
12
+ }
13
+ get styleSheet() {
14
+ let t = this.o;
15
+ const s = this.t;
16
+ if (Z && t === void 0) {
17
+ const i = s !== void 0 && s.length === 1;
18
+ i && (t = it.get(s)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && it.set(s, t));
19
+ }
20
+ return t;
21
+ }
22
+ toString() {
23
+ return this.cssText;
24
+ }
25
+ };
26
+ const Tt = (e) => new Et(typeof e == "string" ? e : e + "", void 0, yt), Pt = (e, t) => {
27
+ if (Z) e.adoptedStyleSheets = t.map(((s) => s instanceof CSSStyleSheet ? s : s.styleSheet));
28
+ else for (const s of t) {
29
+ const i = document.createElement("style"), r = z.litNonce;
30
+ r !== void 0 && i.setAttribute("nonce", r), i.textContent = s.cssText, e.appendChild(i);
31
+ }
32
+ }, rt = Z ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((t) => {
33
+ let s = "";
34
+ for (const i of t.cssRules) s += i.cssText;
35
+ return Tt(s);
36
+ })(e) : e;
37
+ const { is: Ot, defineProperty: Dt, getOwnPropertyDescriptor: Ut, getOwnPropertyNames: Rt, getOwnPropertySymbols: It, getPrototypeOf: Nt } = Object, F = globalThis, ot = F.trustedTypes, Lt = ot ? ot.emptyScript : "", Mt = F.reactiveElementPolyfillSupport, M = (e, t) => e, B = { toAttribute(e, t) {
38
+ switch (t) {
39
+ case Boolean:
40
+ e = e ? Lt : null;
41
+ break;
42
+ case Object:
43
+ case Array:
44
+ e = e == null ? e : JSON.stringify(e);
45
+ }
46
+ return e;
47
+ }, fromAttribute(e, t) {
48
+ let s = e;
49
+ switch (t) {
50
+ case Boolean:
51
+ s = e !== null;
52
+ break;
53
+ case Number:
54
+ s = e === null ? null : Number(e);
55
+ break;
56
+ case Object:
57
+ case Array:
58
+ try {
59
+ s = JSON.parse(e);
60
+ } catch {
61
+ s = null;
62
+ }
63
+ }
64
+ return s;
65
+ } }, Q = (e, t) => !Ot(e, t), at = { attribute: !0, type: String, converter: B, reflect: !1, useDefault: !1, hasChanged: Q };
66
+ Symbol.metadata ??= Symbol("metadata"), F.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
67
+ class I extends HTMLElement {
68
+ static addInitializer(t) {
69
+ this._$Ei(), (this.l ??= []).push(t);
70
+ }
71
+ static get observedAttributes() {
72
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
73
+ }
74
+ static createProperty(t, s = at) {
75
+ if (s.state && (s.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((s = Object.create(s)).wrapped = !0), this.elementProperties.set(t, s), !s.noAccessor) {
76
+ const i = Symbol(), r = this.getPropertyDescriptor(t, i, s);
77
+ r !== void 0 && Dt(this.prototype, t, r);
78
+ }
79
+ }
80
+ static getPropertyDescriptor(t, s, i) {
81
+ const { get: r, set: o } = Ut(this.prototype, t) ?? { get() {
82
+ return this[s];
83
+ }, set(a) {
84
+ this[s] = a;
85
+ } };
86
+ return { get: r, set(a) {
87
+ const h = r?.call(this);
88
+ o?.call(this, a), this.requestUpdate(t, h, i);
89
+ }, configurable: !0, enumerable: !0 };
90
+ }
91
+ static getPropertyOptions(t) {
92
+ return this.elementProperties.get(t) ?? at;
93
+ }
94
+ static _$Ei() {
95
+ if (this.hasOwnProperty(M("elementProperties"))) return;
96
+ const t = Nt(this);
97
+ t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
98
+ }
99
+ static finalize() {
100
+ if (this.hasOwnProperty(M("finalized"))) return;
101
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(M("properties"))) {
102
+ const s = this.properties, i = [...Rt(s), ...It(s)];
103
+ for (const r of i) this.createProperty(r, s[r]);
104
+ }
105
+ const t = this[Symbol.metadata];
106
+ if (t !== null) {
107
+ const s = litPropertyMetadata.get(t);
108
+ if (s !== void 0) for (const [i, r] of s) this.elementProperties.set(i, r);
109
+ }
110
+ this._$Eh = /* @__PURE__ */ new Map();
111
+ for (const [s, i] of this.elementProperties) {
112
+ const r = this._$Eu(s, i);
113
+ r !== void 0 && this._$Eh.set(r, s);
114
+ }
115
+ this.elementStyles = this.finalizeStyles(this.styles);
116
+ }
117
+ static finalizeStyles(t) {
118
+ const s = [];
119
+ if (Array.isArray(t)) {
120
+ const i = new Set(t.flat(1 / 0).reverse());
121
+ for (const r of i) s.unshift(rt(r));
122
+ } else t !== void 0 && s.push(rt(t));
123
+ return s;
124
+ }
125
+ static _$Eu(t, s) {
126
+ const i = s.attribute;
127
+ return i === !1 ? void 0 : typeof i == "string" ? i : typeof t == "string" ? t.toLowerCase() : void 0;
128
+ }
129
+ constructor() {
130
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
131
+ }
132
+ _$Ev() {
133
+ this._$ES = new Promise(((t) => this.enableUpdating = t)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t) => t(this)));
134
+ }
135
+ addController(t) {
136
+ (this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.();
137
+ }
138
+ removeController(t) {
139
+ this._$EO?.delete(t);
140
+ }
141
+ _$E_() {
142
+ const t = /* @__PURE__ */ new Map(), s = this.constructor.elementProperties;
143
+ for (const i of s.keys()) this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
144
+ t.size > 0 && (this._$Ep = t);
145
+ }
146
+ createRenderRoot() {
147
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
148
+ return Pt(t, this.constructor.elementStyles), t;
149
+ }
150
+ connectedCallback() {
151
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach(((t) => t.hostConnected?.()));
152
+ }
153
+ enableUpdating(t) {
154
+ }
155
+ disconnectedCallback() {
156
+ this._$EO?.forEach(((t) => t.hostDisconnected?.()));
157
+ }
158
+ attributeChangedCallback(t, s, i) {
159
+ this._$AK(t, i);
160
+ }
161
+ _$ET(t, s) {
162
+ const i = this.constructor.elementProperties.get(t), r = this.constructor._$Eu(t, i);
163
+ if (r !== void 0 && i.reflect === !0) {
164
+ const o = (i.converter?.toAttribute !== void 0 ? i.converter : B).toAttribute(s, i.type);
165
+ this._$Em = t, o == null ? this.removeAttribute(r) : this.setAttribute(r, o), this._$Em = null;
166
+ }
167
+ }
168
+ _$AK(t, s) {
169
+ const i = this.constructor, r = i._$Eh.get(t);
170
+ if (r !== void 0 && this._$Em !== r) {
171
+ const o = i.getPropertyOptions(r), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : o.converter?.fromAttribute !== void 0 ? o.converter : B;
172
+ this._$Em = r;
173
+ const h = a.fromAttribute(s, o.type);
174
+ this[r] = h ?? this._$Ej?.get(r) ?? h, this._$Em = null;
175
+ }
176
+ }
177
+ requestUpdate(t, s, i) {
178
+ if (t !== void 0) {
179
+ const r = this.constructor, o = this[t];
180
+ if (i ??= r.getPropertyOptions(t), !((i.hasChanged ?? Q)(o, s) || i.useDefault && i.reflect && o === this._$Ej?.get(t) && !this.hasAttribute(r._$Eu(t, i)))) return;
181
+ this.C(t, s, i);
182
+ }
183
+ this.isUpdatePending === !1 && (this._$ES = this._$EP());
184
+ }
185
+ C(t, s, { useDefault: i, reflect: r, wrapped: o }, a) {
186
+ i && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, a ?? s ?? this[t]), o !== !0 || a !== void 0) || (this._$AL.has(t) || (this.hasUpdated || i || (s = void 0), this._$AL.set(t, s)), r === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t));
187
+ }
188
+ async _$EP() {
189
+ this.isUpdatePending = !0;
190
+ try {
191
+ await this._$ES;
192
+ } catch (s) {
193
+ Promise.reject(s);
194
+ }
195
+ const t = this.scheduleUpdate();
196
+ return t != null && await t, !this.isUpdatePending;
197
+ }
198
+ scheduleUpdate() {
199
+ return this.performUpdate();
200
+ }
201
+ performUpdate() {
202
+ if (!this.isUpdatePending) return;
203
+ if (!this.hasUpdated) {
204
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
205
+ for (const [r, o] of this._$Ep) this[r] = o;
206
+ this._$Ep = void 0;
207
+ }
208
+ const i = this.constructor.elementProperties;
209
+ if (i.size > 0) for (const [r, o] of i) {
210
+ const { wrapped: a } = o, h = this[r];
211
+ a !== !0 || this._$AL.has(r) || h === void 0 || this.C(r, void 0, o, h);
212
+ }
213
+ }
214
+ let t = !1;
215
+ const s = this._$AL;
216
+ try {
217
+ t = this.shouldUpdate(s), t ? (this.willUpdate(s), this._$EO?.forEach(((i) => i.hostUpdate?.())), this.update(s)) : this._$EM();
218
+ } catch (i) {
219
+ throw t = !1, this._$EM(), i;
220
+ }
221
+ t && this._$AE(s);
222
+ }
223
+ willUpdate(t) {
224
+ }
225
+ _$AE(t) {
226
+ this._$EO?.forEach(((s) => s.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
227
+ }
228
+ _$EM() {
229
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
230
+ }
231
+ get updateComplete() {
232
+ return this.getUpdateComplete();
233
+ }
234
+ getUpdateComplete() {
235
+ return this._$ES;
236
+ }
237
+ shouldUpdate(t) {
238
+ return !0;
239
+ }
240
+ update(t) {
241
+ this._$Eq &&= this._$Eq.forEach(((s) => this._$ET(s, this[s]))), this._$EM();
242
+ }
243
+ updated(t) {
244
+ }
245
+ firstUpdated(t) {
246
+ }
247
+ }
248
+ I.elementStyles = [], I.shadowRootOptions = { mode: "open" }, I[M("elementProperties")] = /* @__PURE__ */ new Map(), I[M("finalized")] = /* @__PURE__ */ new Map(), Mt?.({ ReactiveElement: I }), (F.reactiveElementVersions ??= []).push("2.1.1");
249
+ const Ht = { attribute: !0, type: String, converter: B, reflect: !1, hasChanged: Q }, jt = (e = Ht, t, s) => {
250
+ const { kind: i, metadata: r } = s;
251
+ let o = globalThis.litPropertyMetadata.get(r);
252
+ if (o === void 0 && globalThis.litPropertyMetadata.set(r, o = /* @__PURE__ */ new Map()), i === "setter" && ((e = Object.create(e)).wrapped = !0), o.set(s.name, e), i === "accessor") {
253
+ const { name: a } = s;
254
+ return { set(h) {
255
+ const n = t.get.call(this);
256
+ t.set.call(this, h), this.requestUpdate(a, n, e);
257
+ }, init(h) {
258
+ return h !== void 0 && this.C(a, void 0, e, h), h;
259
+ } };
260
+ }
261
+ if (i === "setter") {
262
+ const { name: a } = s;
263
+ return function(h) {
264
+ const n = this[a];
265
+ t.call(this, h), this.requestUpdate(a, n, e);
266
+ };
267
+ }
268
+ throw Error("Unsupported decorator location: " + i);
269
+ };
270
+ function k(e) {
271
+ return (t, s) => typeof s == "object" ? jt(e, t, s) : ((i, r, o) => {
272
+ const a = r.hasOwnProperty(o);
273
+ return r.constructor.createProperty(o, i), a ? Object.getOwnPropertyDescriptor(r, o) : void 0;
274
+ })(e, t, s);
275
+ }
276
+ function b(e) {
277
+ return k({ ...e, state: !0, attribute: !1 });
278
+ }
279
+ const qt = (e, t, s) => (s.configurable = !0, s.enumerable = !0, Reflect.decorate && typeof t != "object" && Object.defineProperty(e, t, s), s);
280
+ function X(e, t) {
281
+ return (s, i, r) => {
282
+ const o = (a) => a.renderRoot?.querySelector(e) ?? null;
283
+ return qt(s, i, { get() {
284
+ return o(this);
285
+ } });
286
+ };
287
+ }
288
+ const tt = globalThis, Y = tt.trustedTypes, nt = Y ? Y.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, wt = "$lit$", x = `lit$${Math.random().toFixed(9).slice(2)}$`, $t = "?" + x, zt = `<${$t}>`, D = document, K = () => D.createComment(""), H = (e) => e === null || typeof e != "object" && typeof e != "function", et = Array.isArray, Bt = (e) => et(e) || typeof e?.[Symbol.iterator] == "function", W = `[
289
+ \f\r]`, N = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, lt = /-->/g, ht = />/g, T = RegExp(`>|${W}(?:([^\\s"'>=/]+)(${W}*=${W}*(?:[^
290
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), ct = /'/g, dt = /"/g, bt = /^(?:script|style|textarea|title)$/i, U = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), pt = /* @__PURE__ */ new WeakMap(), O = D.createTreeWalker(D, 129);
291
+ function vt(e, t) {
292
+ if (!et(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
293
+ return nt !== void 0 ? nt.createHTML(t) : t;
294
+ }
295
+ const Yt = (e, t) => {
296
+ const s = e.length - 1, i = [];
297
+ let r, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = N;
298
+ for (let h = 0; h < s; h++) {
299
+ const n = e[h];
300
+ let c, p, l = -1, d = 0;
301
+ for (; d < n.length && (a.lastIndex = d, p = a.exec(n), p !== null); ) d = a.lastIndex, a === N ? p[1] === "!--" ? a = lt : p[1] !== void 0 ? a = ht : p[2] !== void 0 ? (bt.test(p[2]) && (r = RegExp("</" + p[2], "g")), a = T) : p[3] !== void 0 && (a = T) : a === T ? p[0] === ">" ? (a = r ?? N, l = -1) : p[1] === void 0 ? l = -2 : (l = a.lastIndex - p[2].length, c = p[1], a = p[3] === void 0 ? T : p[3] === '"' ? dt : ct) : a === dt || a === ct ? a = T : a === lt || a === ht ? a = N : (a = T, r = void 0);
302
+ const u = a === T && e[h + 1].startsWith("/>") ? " " : "";
303
+ o += a === N ? n + zt : l >= 0 ? (i.push(c), n.slice(0, l) + wt + n.slice(l) + x + u) : n + x + (l === -2 ? h : u);
304
+ }
305
+ return [vt(e, o + (e[s] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), i];
306
+ };
307
+ class j {
308
+ constructor({ strings: t, _$litType$: s }, i) {
309
+ let r;
310
+ this.parts = [];
311
+ let o = 0, a = 0;
312
+ const h = t.length - 1, n = this.parts, [c, p] = Yt(t, s);
313
+ if (this.el = j.createElement(c, i), O.currentNode = this.el.content, s === 2 || s === 3) {
314
+ const l = this.el.content.firstChild;
315
+ l.replaceWith(...l.childNodes);
316
+ }
317
+ for (; (r = O.nextNode()) !== null && n.length < h; ) {
318
+ if (r.nodeType === 1) {
319
+ if (r.hasAttributes()) for (const l of r.getAttributeNames()) if (l.endsWith(wt)) {
320
+ const d = p[a++], u = r.getAttribute(l).split(x), y = /([.?@])?(.*)/.exec(d);
321
+ n.push({ type: 1, index: o, name: y[2], strings: u, ctor: y[1] === "." ? Ft : y[1] === "?" ? Vt : y[1] === "@" ? Wt : V }), r.removeAttribute(l);
322
+ } else l.startsWith(x) && (n.push({ type: 6, index: o }), r.removeAttribute(l));
323
+ if (bt.test(r.tagName)) {
324
+ const l = r.textContent.split(x), d = l.length - 1;
325
+ if (d > 0) {
326
+ r.textContent = Y ? Y.emptyScript : "";
327
+ for (let u = 0; u < d; u++) r.append(l[u], K()), O.nextNode(), n.push({ type: 2, index: ++o });
328
+ r.append(l[d], K());
329
+ }
330
+ }
331
+ } else if (r.nodeType === 8) if (r.data === $t) n.push({ type: 2, index: o });
332
+ else {
333
+ let l = -1;
334
+ for (; (l = r.data.indexOf(x, l + 1)) !== -1; ) n.push({ type: 7, index: o }), l += x.length - 1;
335
+ }
336
+ o++;
337
+ }
338
+ }
339
+ static createElement(t, s) {
340
+ const i = D.createElement("template");
341
+ return i.innerHTML = t, i;
342
+ }
343
+ }
344
+ function R(e, t, s = e, i) {
345
+ if (t === U) return t;
346
+ let r = i !== void 0 ? s._$Co?.[i] : s._$Cl;
347
+ const o = H(t) ? void 0 : t._$litDirective$;
348
+ return r?.constructor !== o && (r?._$AO?.(!1), o === void 0 ? r = void 0 : (r = new o(e), r._$AT(e, s, i)), i !== void 0 ? (s._$Co ??= [])[i] = r : s._$Cl = r), r !== void 0 && (t = R(e, r._$AS(e, t.values), r, i)), t;
349
+ }
350
+ let Kt = class {
351
+ constructor(t, s) {
352
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = s;
353
+ }
354
+ get parentNode() {
355
+ return this._$AM.parentNode;
356
+ }
357
+ get _$AU() {
358
+ return this._$AM._$AU;
359
+ }
360
+ u(t) {
361
+ const { el: { content: s }, parts: i } = this._$AD, r = (t?.creationScope ?? D).importNode(s, !0);
362
+ O.currentNode = r;
363
+ let o = O.nextNode(), a = 0, h = 0, n = i[0];
364
+ for (; n !== void 0; ) {
365
+ if (a === n.index) {
366
+ let c;
367
+ n.type === 2 ? c = new q(o, o.nextSibling, this, t) : n.type === 1 ? c = new n.ctor(o, n.name, n.strings, this, t) : n.type === 6 && (c = new Gt(o, this, t)), this._$AV.push(c), n = i[++h];
368
+ }
369
+ a !== n?.index && (o = O.nextNode(), a++);
370
+ }
371
+ return O.currentNode = D, r;
372
+ }
373
+ p(t) {
374
+ let s = 0;
375
+ for (const i of this._$AV) i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, s), s += i.strings.length - 2) : i._$AI(t[s])), s++;
376
+ }
377
+ };
378
+ class q {
379
+ get _$AU() {
380
+ return this._$AM?._$AU ?? this._$Cv;
381
+ }
382
+ constructor(t, s, i, r) {
383
+ this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t, this._$AB = s, this._$AM = i, this.options = r, this._$Cv = r?.isConnected ?? !0;
384
+ }
385
+ get parentNode() {
386
+ let t = this._$AA.parentNode;
387
+ const s = this._$AM;
388
+ return s !== void 0 && t?.nodeType === 11 && (t = s.parentNode), t;
389
+ }
390
+ get startNode() {
391
+ return this._$AA;
392
+ }
393
+ get endNode() {
394
+ return this._$AB;
395
+ }
396
+ _$AI(t, s = this) {
397
+ t = R(this, t, s), H(t) ? t === A || t == null || t === "" ? (this._$AH !== A && this._$AR(), this._$AH = A) : t !== this._$AH && t !== U && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Bt(t) ? this.k(t) : this._(t);
398
+ }
399
+ O(t) {
400
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
401
+ }
402
+ T(t) {
403
+ this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
404
+ }
405
+ _(t) {
406
+ this._$AH !== A && H(this._$AH) ? this._$AA.nextSibling.data = t : this.T(D.createTextNode(t)), this._$AH = t;
407
+ }
408
+ $(t) {
409
+ const { values: s, _$litType$: i } = t, r = typeof i == "number" ? this._$AC(t) : (i.el === void 0 && (i.el = j.createElement(vt(i.h, i.h[0]), this.options)), i);
410
+ if (this._$AH?._$AD === r) this._$AH.p(s);
411
+ else {
412
+ const o = new Kt(r, this), a = o.u(this.options);
413
+ o.p(s), this.T(a), this._$AH = o;
414
+ }
415
+ }
416
+ _$AC(t) {
417
+ let s = pt.get(t.strings);
418
+ return s === void 0 && pt.set(t.strings, s = new j(t)), s;
419
+ }
420
+ k(t) {
421
+ et(this._$AH) || (this._$AH = [], this._$AR());
422
+ const s = this._$AH;
423
+ let i, r = 0;
424
+ for (const o of t) r === s.length ? s.push(i = new q(this.O(K()), this.O(K()), this, this.options)) : i = s[r], i._$AI(o), r++;
425
+ r < s.length && (this._$AR(i && i._$AB.nextSibling, r), s.length = r);
426
+ }
427
+ _$AR(t = this._$AA.nextSibling, s) {
428
+ for (this._$AP?.(!1, !0, s); t !== this._$AB; ) {
429
+ const i = t.nextSibling;
430
+ t.remove(), t = i;
431
+ }
432
+ }
433
+ setConnected(t) {
434
+ this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
435
+ }
436
+ }
437
+ class V {
438
+ get tagName() {
439
+ return this.element.tagName;
440
+ }
441
+ get _$AU() {
442
+ return this._$AM._$AU;
443
+ }
444
+ constructor(t, s, i, r, o) {
445
+ this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t, this.name = s, this._$AM = r, this.options = o, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = A;
446
+ }
447
+ _$AI(t, s = this, i, r) {
448
+ const o = this.strings;
449
+ let a = !1;
450
+ if (o === void 0) t = R(this, t, s, 0), a = !H(t) || t !== this._$AH && t !== U, a && (this._$AH = t);
451
+ else {
452
+ const h = t;
453
+ let n, c;
454
+ for (t = o[0], n = 0; n < o.length - 1; n++) c = R(this, h[i + n], s, n), c === U && (c = this._$AH[n]), a ||= !H(c) || c !== this._$AH[n], c === A ? t = A : t !== A && (t += (c ?? "") + o[n + 1]), this._$AH[n] = c;
455
+ }
456
+ a && !r && this.j(t);
457
+ }
458
+ j(t) {
459
+ t === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
460
+ }
461
+ }
462
+ class Ft extends V {
463
+ constructor() {
464
+ super(...arguments), this.type = 3;
465
+ }
466
+ j(t) {
467
+ this.element[this.name] = t === A ? void 0 : t;
468
+ }
469
+ }
470
+ class Vt extends V {
471
+ constructor() {
472
+ super(...arguments), this.type = 4;
473
+ }
474
+ j(t) {
475
+ this.element.toggleAttribute(this.name, !!t && t !== A);
476
+ }
477
+ }
478
+ class Wt extends V {
479
+ constructor(t, s, i, r, o) {
480
+ super(t, s, i, r, o), this.type = 5;
481
+ }
482
+ _$AI(t, s = this) {
483
+ if ((t = R(this, t, s, 0) ?? A) === U) return;
484
+ const i = this._$AH, r = t === A && i !== A || t.capture !== i.capture || t.once !== i.once || t.passive !== i.passive, o = t !== A && (i === A || r);
485
+ r && this.element.removeEventListener(this.name, this, i), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
486
+ }
487
+ handleEvent(t) {
488
+ typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t);
489
+ }
490
+ }
491
+ class Gt {
492
+ constructor(t, s, i) {
493
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = s, this.options = i;
494
+ }
495
+ get _$AU() {
496
+ return this._$AM._$AU;
497
+ }
498
+ _$AI(t) {
499
+ R(this, t);
500
+ }
501
+ }
502
+ const Jt = { I: q }, Zt = tt.litHtmlPolyfillSupport;
503
+ Zt?.(j, q), (tt.litHtmlVersions ??= []).push("3.3.1");
504
+ const At = { ATTRIBUTE: 1, CHILD: 2 }, _t = (e) => (...t) => ({ _$litDirective$: e, values: t });
505
+ class St {
506
+ constructor(t) {
507
+ }
508
+ get _$AU() {
509
+ return this._$AM._$AU;
510
+ }
511
+ _$AT(t, s, i) {
512
+ this._$Ct = t, this._$AM = s, this._$Ci = i;
513
+ }
514
+ _$AS(t, s) {
515
+ return this.update(t, s);
516
+ }
517
+ update(t, s) {
518
+ return this.render(...s);
519
+ }
520
+ }
521
+ const ut = _t(class extends St {
522
+ constructor(e) {
523
+ if (super(e), e.type !== At.ATTRIBUTE || e.name !== "class" || e.strings?.length > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
524
+ }
525
+ render(e) {
526
+ return " " + Object.keys(e).filter(((t) => e[t])).join(" ") + " ";
527
+ }
528
+ update(e, [t]) {
529
+ if (this.st === void 0) {
530
+ this.st = /* @__PURE__ */ new Set(), e.strings !== void 0 && (this.nt = new Set(e.strings.join(" ").split(/\s/).filter(((i) => i !== ""))));
531
+ for (const i in t) t[i] && !this.nt?.has(i) && this.st.add(i);
532
+ return this.render(t);
533
+ }
534
+ const s = e.element.classList;
535
+ for (const i of this.st) i in t || (s.remove(i), this.st.delete(i));
536
+ for (const i in t) {
537
+ const r = !!t[i];
538
+ r === this.st.has(i) || this.nt?.has(i) || (r ? (s.add(i), this.st.add(i)) : (s.remove(i), this.st.delete(i)));
539
+ }
540
+ return U;
541
+ }
542
+ });
543
+ const { I: Qt } = Jt, gt = () => document.createComment(""), L = (e, t, s) => {
544
+ const i = e._$AA.parentNode, r = t === void 0 ? e._$AB : t._$AA;
545
+ if (s === void 0) {
546
+ const o = i.insertBefore(gt(), r), a = i.insertBefore(gt(), r);
547
+ s = new Qt(o, a, e, e.options);
548
+ } else {
549
+ const o = s._$AB.nextSibling, a = s._$AM, h = a !== e;
550
+ if (h) {
551
+ let n;
552
+ s._$AQ?.(e), s._$AM = e, s._$AP !== void 0 && (n = e._$AU) !== a._$AU && s._$AP(n);
553
+ }
554
+ if (o !== r || h) {
555
+ let n = s._$AA;
556
+ for (; n !== o; ) {
557
+ const c = n.nextSibling;
558
+ i.insertBefore(n, r), n = c;
559
+ }
560
+ }
561
+ }
562
+ return s;
563
+ }, P = (e, t, s = e) => (e._$AI(t, s), e), Xt = {}, te = (e, t = Xt) => e._$AH = t, ee = (e) => e._$AH, G = (e) => {
564
+ e._$AR(), e._$AA.remove();
565
+ };
566
+ const mt = (e, t, s) => {
567
+ const i = /* @__PURE__ */ new Map();
568
+ for (let r = t; r <= s; r++) i.set(e[r], r);
569
+ return i;
570
+ }, ft = _t(class extends St {
571
+ constructor(e) {
572
+ if (super(e), e.type !== At.CHILD) throw Error("repeat() can only be used in text expressions");
573
+ }
574
+ dt(e, t, s) {
575
+ let i;
576
+ s === void 0 ? s = t : t !== void 0 && (i = t);
577
+ const r = [], o = [];
578
+ let a = 0;
579
+ for (const h of e) r[a] = i ? i(h, a) : a, o[a] = s(h, a), a++;
580
+ return { values: o, keys: r };
581
+ }
582
+ render(e, t, s) {
583
+ return this.dt(e, t, s).values;
584
+ }
585
+ update(e, [t, s, i]) {
586
+ const r = ee(e), { values: o, keys: a } = this.dt(t, s, i);
587
+ if (!Array.isArray(r)) return this.ut = a, o;
588
+ const h = this.ut ??= [], n = [];
589
+ let c, p, l = 0, d = r.length - 1, u = 0, y = o.length - 1;
590
+ for (; l <= d && u <= y; ) if (r[l] === null) l++;
591
+ else if (r[d] === null) d--;
592
+ else if (h[l] === a[u]) n[u] = P(r[l], o[u]), l++, u++;
593
+ else if (h[d] === a[y]) n[y] = P(r[d], o[y]), d--, y--;
594
+ else if (h[l] === a[y]) n[y] = P(r[l], o[y]), L(e, n[y + 1], r[l]), l++, y--;
595
+ else if (h[d] === a[u]) n[u] = P(r[d], o[u]), L(e, r[l], r[d]), d--, u++;
596
+ else if (c === void 0 && (c = mt(a, u, y), p = mt(h, l, d)), c.has(h[l])) if (c.has(h[d])) {
597
+ const v = p.get(a[u]), _ = v !== void 0 ? r[v] : null;
598
+ if (_ === null) {
599
+ const w = L(e, r[l]);
600
+ P(w, o[u]), n[u] = w;
601
+ } else n[u] = P(_, o[u]), L(e, r[l], _), r[v] = null;
602
+ u++;
603
+ } else G(r[d]), d--;
604
+ else G(r[l]), l++;
605
+ for (; u <= y; ) {
606
+ const v = L(e, n[y + 1]);
607
+ P(v, o[u]), n[u++] = v;
608
+ }
609
+ for (; l <= d; ) {
610
+ const v = r[l++];
611
+ v !== null && G(v);
612
+ }
613
+ return this.ut = a, te(e, n), U;
614
+ }
615
+ }), se = ({
616
+ baseUrl: e
617
+ }) => {
618
+ const t = {
619
+ login: "auth/login",
620
+ logout: "auth/logout",
621
+ refresh: "auth/refresh",
622
+ requestRegisterOtp: "auth/request-register-otp",
623
+ register: "auth/register",
624
+ requestResetPassword: "auth/request-reset-password",
625
+ resetPassword: "auth/reset-password"
626
+ };
627
+ return {
628
+ login: async ({
629
+ email: c,
630
+ password: p,
631
+ accessToken: l,
632
+ refreshToken: d,
633
+ idToken: u
634
+ }) => {
635
+ const y = await fetch(`${e}${t.login}`, {
636
+ method: "POST",
637
+ headers: {
638
+ "Content-Type": "application/json"
639
+ },
640
+ body: JSON.stringify({
641
+ email: c,
642
+ password: p,
643
+ accessToken: l,
644
+ refreshToken: d,
645
+ idToken: u
646
+ })
647
+ });
648
+ if (!y.ok) {
649
+ const v = await y.json();
650
+ throw new Error(v.message || v.error || "Login failed");
651
+ }
652
+ return y.json();
653
+ },
654
+ logout: async ({
655
+ accessToken: c,
656
+ refreshToken: p,
657
+ authToken: l
658
+ }) => {
659
+ const d = await fetch(`${e}${t.logout}`, {
660
+ method: "POST",
661
+ headers: {
662
+ "Content-Type": "application/json",
663
+ Authorization: `Bearer ${l}`
664
+ },
665
+ body: JSON.stringify({
666
+ accessToken: c,
667
+ refreshToken: p
668
+ })
669
+ });
670
+ if (!d.ok) {
671
+ const u = await d.json();
672
+ throw new Error(u.message || u.error || "Logout failed");
673
+ }
674
+ return d.json();
675
+ },
676
+ refresh: async ({ refreshToken: c }) => {
677
+ const p = await fetch(`${e}${t.refresh}`, {
678
+ method: "POST",
679
+ headers: {
680
+ "Content-Type": "application/json"
681
+ },
682
+ body: JSON.stringify({
683
+ refreshToken: c
684
+ })
685
+ });
686
+ if (!p.ok) {
687
+ const l = await p.json();
688
+ throw new Error(l.message || l.error || "Failed to refresh token");
689
+ }
690
+ return p.json();
691
+ },
692
+ requestRegisterOtp: async ({ email: c }) => {
693
+ const p = await fetch(`${e}${t.requestRegisterOtp}`, {
694
+ method: "POST",
695
+ headers: {
696
+ "Content-Type": "application/json"
697
+ },
698
+ body: JSON.stringify({
699
+ email: c
700
+ })
701
+ });
702
+ if (!p.ok) {
703
+ const l = await p.json();
704
+ throw new Error(l.message || l.error || "Failed to request OTP");
705
+ }
706
+ return p.json();
707
+ },
708
+ register: async ({
709
+ email: c,
710
+ password: p,
711
+ phone_number: l,
712
+ family_name: d,
713
+ given_name: u,
714
+ code: y
715
+ }) => {
716
+ const v = await fetch(`${e}${t.register}`, {
717
+ method: "POST",
718
+ headers: {
719
+ "Content-Type": "application/json"
720
+ },
721
+ body: JSON.stringify({
722
+ email: c,
723
+ password: p,
724
+ phone_number: l,
725
+ family_name: d,
726
+ given_name: u,
727
+ code: y
728
+ })
729
+ });
730
+ if (!v.ok) {
731
+ const _ = await v.json();
732
+ throw new Error(_.message || _.error || "Registration failed");
733
+ }
734
+ return v.json();
735
+ },
736
+ requestResetPassword: async ({ email: c }) => {
737
+ const p = await fetch(`${e}${t.requestResetPassword}`, {
738
+ method: "POST",
739
+ headers: {
740
+ "Content-Type": "application/json"
741
+ },
742
+ body: JSON.stringify({
743
+ email: c
744
+ })
745
+ });
746
+ if (!p.ok) {
747
+ const l = await p.json();
748
+ throw new Error(l.message || l.error || "Failed to request password reset");
749
+ }
750
+ return p.json();
751
+ },
752
+ resetPassword: async ({
753
+ email: c,
754
+ otp: p,
755
+ newPassword: l
756
+ }) => {
757
+ const d = await fetch(`${e}${t.resetPassword}`, {
758
+ method: "POST",
759
+ headers: {
760
+ "Content-Type": "application/json"
761
+ },
762
+ body: JSON.stringify({
763
+ email: c,
764
+ otp: p,
765
+ newPassword: l
766
+ })
767
+ });
768
+ if (!d.ok) {
769
+ const u = await d.json();
770
+ throw new Error(u.message || u.error || "Failed to reset password");
771
+ }
772
+ return d.json();
773
+ }
774
+ };
775
+ }, J = {
776
+ AUTH_TOKEN: "authToken",
777
+ ACCESS_TOKEN: "accessToken",
778
+ REFRESH_TOKEN: "refreshToken"
779
+ }, ie = {
780
+ maxAge: 3600 * 24 * 7,
781
+ // 7 days
782
+ secure: !0,
783
+ sameSite: "lax",
784
+ path: "/"
785
+ }, re = () => {
786
+ const e = (n, c, p = {}) => {
787
+ const {
788
+ maxAge: l,
789
+ path: d = "/",
790
+ secure: u = window.location.protocol === "https:",
791
+ sameSite: y = "lax",
792
+ domain: v
793
+ } = p;
794
+ let _ = `${encodeURIComponent(n)}=${encodeURIComponent(c)}`;
795
+ l !== void 0 && (_ += `; Max-Age=${l}`), _ += `; Path=${d}`, u && (_ += "; Secure"), _ += `; SameSite=${y}`, v && (_ += `; Domain=${v}`), document.cookie = _;
796
+ }, t = (n) => {
797
+ const c = encodeURIComponent(n) + "=", p = document.cookie.split(";");
798
+ for (let l = 0; l < p.length; l++) {
799
+ let d = p[l];
800
+ for (; d.charAt(0) === " "; )
801
+ d = d.substring(1);
802
+ if (d.indexOf(c) === 0)
803
+ return decodeURIComponent(d.substring(c.length));
804
+ }
805
+ return null;
806
+ }, s = (n, c = {}) => {
807
+ e(n, "", {
808
+ ...c,
809
+ maxAge: -1
810
+ });
811
+ }, i = (n) => t(n) !== null, r = (n, c) => {
812
+ e(J[n], c, ie);
813
+ }, o = (n) => t(J[n]), a = (n) => {
814
+ s(J[n]);
815
+ };
816
+ return {
817
+ setCookie: e,
818
+ getCookie: t,
819
+ removeCookie: s,
820
+ hasCookie: i,
821
+ setAuthToken: r,
822
+ getAuthToken: o,
823
+ removeAuthToken: a,
824
+ clearAllAuthTokens: () => {
825
+ a("AUTH_TOKEN"), a("ACCESS_TOKEN"), a("REFRESH_TOKEN");
826
+ }
827
+ };
828
+ }, oe = ["code", "state", "error", "error_description"], ae = (e) => {
829
+ if (e) return e;
830
+ const t = new URL(window.location.href);
831
+ return oe.forEach((s) => t.searchParams.delete(s)), t.toString();
832
+ }, ne = ({
833
+ domain: e,
834
+ cognitoRegion: t,
835
+ userPoolId: s,
836
+ clientId: i,
837
+ redirectUri: r
838
+ }) => {
839
+ const o = {
840
+ domain: e,
841
+ clientId: i,
842
+ redirectUri: ae(r)
843
+ }, a = (w) => {
844
+ const S = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~", C = new Uint8Array(w);
845
+ return crypto.getRandomValues(C), Array.from(C).map((E) => S[E % S.length]).join("");
846
+ }, h = async (w) => {
847
+ const C = new TextEncoder().encode(w), E = await crypto.subtle.digest("SHA-256", C);
848
+ return btoa(String.fromCharCode(...new Uint8Array(E))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
849
+ }, n = async () => {
850
+ const w = a(128), S = await h(w);
851
+ return sessionStorage.setItem("pkce_code_verifier", w), { codeVerifier: w, codeChallenge: S };
852
+ }, c = () => {
853
+ const w = a(32);
854
+ return sessionStorage.setItem("oauth_state", w), w;
855
+ }, p = async () => {
856
+ const { codeChallenge: w } = await n(), S = c(), C = new URLSearchParams({
857
+ response_type: "code",
858
+ client_id: o.clientId,
859
+ redirect_uri: o.redirectUri,
860
+ identity_provider: "Google",
861
+ scope: "openid email profile",
862
+ state: S,
863
+ code_challenge_method: "S256",
864
+ code_challenge: w,
865
+ prompt: "select_account"
866
+ });
867
+ return `${o.domain}/oauth2/authorize?${C.toString()}`;
868
+ }, l = async () => {
869
+ const w = await p();
870
+ window.location.href = w;
871
+ }, d = async () => {
872
+ const { codeChallenge: w } = await n(), S = c(), C = new URLSearchParams({
873
+ response_type: "code",
874
+ client_id: o.clientId,
875
+ redirect_uri: o.redirectUri,
876
+ identity_provider: "SignInWithApple",
877
+ scope: "openid email profile",
878
+ state: S,
879
+ code_challenge_method: "S256",
880
+ code_challenge: w
881
+ });
882
+ return `${o.domain}/oauth2/authorize?${C.toString()}`;
883
+ }, u = async () => {
884
+ const w = await d();
885
+ window.location.href = w;
886
+ }, y = (w) => {
887
+ const S = sessionStorage.getItem("oauth_state");
888
+ return sessionStorage.removeItem("oauth_state"), S === w;
889
+ }, v = () => {
890
+ const w = sessionStorage.getItem("pkce_code_verifier");
891
+ return sessionStorage.removeItem("pkce_code_verifier"), w;
892
+ };
893
+ return {
894
+ redirectToGoogleAuth: l,
895
+ redirectToAppleAuth: u,
896
+ validateState: y,
897
+ getCodeVerifier: v,
898
+ exchangeCodeForTokens: async (w) => {
899
+ const S = v();
900
+ if (!S)
901
+ throw new Error("PKCE code verifier not found. Please restart the authentication flow.");
902
+ const C = new URLSearchParams({
903
+ grant_type: "authorization_code",
904
+ client_id: o.clientId,
905
+ code: w,
906
+ redirect_uri: o.redirectUri,
907
+ code_verifier: S
908
+ }), E = await fetch(`${o.domain}/oauth2/token`, {
909
+ method: "POST",
910
+ headers: {
911
+ "Content-Type": "application/x-www-form-urlencoded"
912
+ },
913
+ body: C.toString()
914
+ });
915
+ if (!E.ok) {
916
+ const st = await E.text();
917
+ throw new Error(`Token exchange failed: ${st}`);
918
+ }
919
+ return E.json();
920
+ }
921
+ };
922
+ }, le = () => kt`
923
+ :host {
924
+ display: inline-block;
925
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
926
+ box-sizing: border-box;
927
+ --color-primary: var(--cals-auth-color-primary, #2563eb);
928
+ --color-bg-primary: var(--cals-auth-color-bg-primary, #ffffff);
929
+ --color-bg-secondary: var(--cals-auth-color-bg-secondary, #f8fafc);
930
+ --color-text-primary: var(--cals-auth-color-text-primary, #0f172a);
931
+ --color-text-secondary: var(--cals-auth-color-text-secondary, #64748b);
932
+ --color-text-muted: var(--cals-auth-color-text-muted, #94a3b8);
933
+ --color-border: var(--cals-auth-color-border, #e2e8f0);
934
+ --color-error: var(--cals-auth-color-error, #dc2626);
935
+ --color-success: var(--cals-auth-color-success, #16a34a);
936
+ --transition-slow: var(--cals-auth-transition-slow, 300ms);
937
+ --radius-md: var(--cals-auth-radius-md, 0.5rem);
938
+ --radius-lg: var(--cals-auth-radius-lg, 0.75rem);
939
+ --radius-xl: var(--cals-auth-radius-xl, 1.25rem);
940
+ --space-2: var(--cals-auth-space-2, 0.5rem);
941
+ --space-3: var(--cals-auth-space-3, 0.75rem);
942
+ --space-4: var(--cals-auth-space-4, 1rem);
943
+ --space-5: var(--cals-auth-space-5, 1.25rem);
944
+ --space-6: var(--cals-auth-space-6, 1.5rem);
945
+ }
946
+
947
+ *,
948
+ *::before,
949
+ *::after {
950
+ box-sizing: border-box;
951
+ }
952
+
953
+ /* Body scroll lock */
954
+ :host(.modal-open) {
955
+ overflow: hidden;
956
+ }
957
+
958
+ .modal-overlay {
959
+ position: fixed;
960
+ top: 0;
961
+ left: 0;
962
+ right: 0;
963
+ bottom: 0;
964
+ background: rgba(0, 0, 0, 0.5);
965
+ display: flex;
966
+ align-items: flex-end;
967
+ justify-content: center;
968
+ z-index: 1000;
969
+ backdrop-filter: none;
970
+ animation: fadeIn 0.2s ease-out;
971
+ }
972
+
973
+ .modal-overlay--closing {
974
+ animation: fadeOut var(--transition-slow) ease-out forwards;
975
+ }
976
+
977
+ .modal-container {
978
+ background: var(--color-bg-primary);
979
+ border-top-left-radius: var(--radius-xl);
980
+ border-top-right-radius: var(--radius-xl);
981
+ box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1), 0 -2px 4px -1px rgba(0, 0, 0, 0.06);
982
+ width: 100vw;
983
+ max-width: 100vw;
984
+ height: 85dvh;
985
+ display: flex;
986
+ flex-direction: column;
987
+ overflow: hidden;
988
+ animation: slideUp var(--transition-slow);
989
+ transform-origin: bottom center;
990
+ transition: height var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
991
+ }
992
+
993
+ .modal-container--closing {
994
+ animation: slideDown var(--transition-slow);
995
+ }
996
+
997
+ .modal-container--dragging {
998
+ user-select: none;
999
+ -webkit-user-select: none;
1000
+ cursor: grabbing;
1001
+ }
1002
+
1003
+ .drawer-handle {
1004
+ display: flex;
1005
+ justify-content: center;
1006
+ padding-top: var(--space-3);
1007
+ padding-bottom: var(--space-2);
1008
+ flex-shrink: 0;
1009
+ cursor: pointer;
1010
+ user-select: none;
1011
+ -webkit-tap-highlight-color: transparent;
1012
+ }
1013
+
1014
+ .drawer-handle:hover .drawer-handle-bar {
1015
+ opacity: 0.7;
1016
+ }
1017
+
1018
+ .drawer-handle-bar {
1019
+ width: 36px;
1020
+ height: 5px;
1021
+ background: var(--color-text-muted);
1022
+ border-radius: 100px;
1023
+ opacity: 0.5;
1024
+ transition: opacity var(--transition-slow) ease;
1025
+ }
1026
+
1027
+ .drawer-content {
1028
+ width: 100%;
1029
+ max-width: 100%;
1030
+ margin: 0 auto;
1031
+ display: flex;
1032
+ flex-direction: column;
1033
+ overflow: hidden;
1034
+ height: 100%;
1035
+ }
1036
+
1037
+ .drawer-content--sm {
1038
+ max-width: 400px;
1039
+ }
1040
+
1041
+ .drawer-content--md {
1042
+ max-width: 600px;
1043
+ }
1044
+
1045
+ .drawer-content--lg {
1046
+ max-width: 900px;
1047
+ }
1048
+
1049
+ .modal-header {
1050
+ display: flex;
1051
+ align-items: center;
1052
+ justify-content: center;
1053
+ padding: var(--space-4) var(--space-6);
1054
+ flex-shrink: 0;
1055
+ }
1056
+
1057
+ .auth-logo {
1058
+ display: block;
1059
+ }
1060
+ .auth-logo {
1061
+ position: relative;
1062
+ transition: all 0.3s ease;
1063
+ }
1064
+ .auth-logo[src] {
1065
+ opacity: 1;
1066
+ position: relative;
1067
+ z-index: 1;
1068
+ }
1069
+ :host([data-theme='dark']) .auth-header {
1070
+ filter: brightness(0) saturate(100%) invert(98%) sepia(4%) saturate(346%)
1071
+ hue-rotate(183deg) brightness(106%) contrast(93%);
1072
+ }
1073
+
1074
+ .modal-body {
1075
+ padding: var(--space-4) var(--space-6);
1076
+ overflow-y: auto;
1077
+ flex: 1;
1078
+ min-height: 0;
1079
+ }
1080
+
1081
+ .auth-form {
1082
+ display: flex;
1083
+ flex-direction: column;
1084
+ gap: var(--space-5);
1085
+ }
1086
+
1087
+ .field {
1088
+ display: flex;
1089
+ flex-direction: column;
1090
+ gap: var(--space-1);
1091
+ }
1092
+
1093
+ .field-label {
1094
+ font-weight: 500;
1095
+ font-size: 0.875rem;
1096
+ color: var(--color-text-primary);
1097
+ }
1098
+
1099
+ .field-input {
1100
+ width: 100%;
1101
+ padding: 0.75rem 1rem;
1102
+ border: 1px solid var(--color-border);
1103
+ border-radius: var(--radius-md);
1104
+ background: var(--color-bg-primary);
1105
+ color: var(--color-text-primary);
1106
+ font-size: 1rem;
1107
+ transition: all 0.15s ease;
1108
+ }
1109
+
1110
+ .field-input:focus {
1111
+ outline: none;
1112
+ border-color: var(--color-primary);
1113
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
1114
+ }
1115
+
1116
+ .field-input:-webkit-autofill,
1117
+ .field-input:-webkit-autofill:hover,
1118
+ .field-input:-webkit-autofill:focus,
1119
+ .field-input:-webkit-autofill:active {
1120
+ -webkit-box-shadow: 0 0 0 1000px var(--color-bg-primary) inset !important;
1121
+ -webkit-text-fill-color: var(--color-text-primary) !important;
1122
+ transition: background-color 5000s ease-in-out 0s;
1123
+ }
1124
+
1125
+ .field-input:-moz-autofill {
1126
+ box-shadow: 0 0 0 1000px var(--color-bg-primary) inset !important;
1127
+ color: var(--color-text-primary) !important;
1128
+ }
1129
+
1130
+ .field-input--error {
1131
+ border-color: var(--color-error);
1132
+ }
1133
+
1134
+ .field-error {
1135
+ color: var(--color-error);
1136
+ font-size: 0.875rem;
1137
+ }
1138
+
1139
+ .forgot-row {
1140
+ display: flex;
1141
+ justify-content: flex-end;
1142
+ margin-top: calc(var(--space-2) * -1);
1143
+ }
1144
+
1145
+ .text-btn {
1146
+ background: none;
1147
+ border: none;
1148
+ color: var(--color-primary);
1149
+ cursor: pointer;
1150
+ font-weight: 600;
1151
+ font-size: 0.875rem;
1152
+ padding: 0;
1153
+ text-decoration: none;
1154
+ }
1155
+
1156
+ .text-btn:hover {
1157
+ text-decoration: underline;
1158
+ }
1159
+
1160
+ .form-actions {
1161
+ display: flex;
1162
+ flex-direction: column;
1163
+ gap: var(--space-3);
1164
+ margin-top: var(--space-2);
1165
+ }
1166
+
1167
+ .cta {
1168
+ width: 100%;
1169
+ padding: 0.875rem 1rem;
1170
+ border: none;
1171
+ border-radius: var(--radius-md);
1172
+ background: var(--color-primary);
1173
+ color: white;
1174
+ font-weight: 600;
1175
+ font-size: 1rem;
1176
+ cursor: pointer;
1177
+ transition: all 0.15s ease;
1178
+ }
1179
+
1180
+ .cta:hover:not(:disabled) {
1181
+ background: color-mix(in srgb, var(--color-primary), black 10%);
1182
+ transform: translateY(-1px);
1183
+ }
1184
+
1185
+ .cta:disabled {
1186
+ opacity: 0.5;
1187
+ cursor: not-allowed;
1188
+ }
1189
+
1190
+ .button-row {
1191
+ display: flex;
1192
+ gap: var(--space-3);
1193
+ width: 100%;
1194
+ }
1195
+
1196
+ .oauth-btn {
1197
+ flex: 1;
1198
+ padding: 0.875rem 1rem;
1199
+ border: 1px solid var(--color-border);
1200
+ border-radius: var(--radius-md);
1201
+ background: var(--color-bg-primary);
1202
+ cursor: pointer;
1203
+ transition: all 0.15s ease;
1204
+ display: flex;
1205
+ align-items: center;
1206
+ justify-content: center;
1207
+ }
1208
+
1209
+ .oauth-btn:hover:not(:disabled) {
1210
+ background: var(--color-bg-secondary);
1211
+ border-color: var(--color-text-muted);
1212
+ }
1213
+
1214
+ .oauth-btn:disabled {
1215
+ opacity: 0.5;
1216
+ cursor: not-allowed;
1217
+ }
1218
+
1219
+ .apple-icon path {
1220
+ fill: #0b0b0a;
1221
+ }
1222
+
1223
+ /* Dark theme */
1224
+ :host([data-theme='dark']) {
1225
+ --color-primary: #3b82f6;
1226
+ --color-bg-primary: #1e293b;
1227
+ --color-bg-secondary: #0f172a;
1228
+ --color-text-primary: #f8fafc;
1229
+ --color-text-secondary: #cbd5e1;
1230
+ --color-text-muted: #94a3b8;
1231
+ --color-border: #334155;
1232
+ --color-error: #ef4444;
1233
+ --color-success: #10b981;
1234
+ }
1235
+
1236
+ :host([data-theme='dark']) .apple-icon path {
1237
+ fill: #8e8e93;
1238
+ }
1239
+
1240
+ @media (prefers-color-scheme: dark) {
1241
+ .apple-icon path {
1242
+ fill: #8e8e93;
1243
+ }
1244
+ }
1245
+
1246
+ .otp-section {
1247
+ display: flex;
1248
+ flex-direction: column;
1249
+ gap: var(--space-2);
1250
+ }
1251
+
1252
+ .otp-label {
1253
+ display: block;
1254
+ font-weight: 500;
1255
+ font-size: 0.875rem;
1256
+ color: var(--color-text-primary);
1257
+ }
1258
+
1259
+ .otp-inputs {
1260
+ display: flex;
1261
+ gap: var(--space-2);
1262
+ justify-content: center;
1263
+ }
1264
+
1265
+ .otp-input {
1266
+ width: 44px;
1267
+ height: 52px;
1268
+ text-align: center;
1269
+ font-size: 1.25rem;
1270
+ font-weight: 600;
1271
+ border: 1px solid var(--color-border);
1272
+ border-radius: var(--radius-md);
1273
+ background: var(--color-bg-primary);
1274
+ color: var(--color-text-primary);
1275
+ transition: all 0.15s ease;
1276
+ }
1277
+
1278
+ .otp-input:focus {
1279
+ outline: none;
1280
+ border-color: var(--color-primary);
1281
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
1282
+ }
1283
+
1284
+ .otp-input--error {
1285
+ border-color: var(--color-error);
1286
+ }
1287
+
1288
+ .otp-error {
1289
+ margin: 0;
1290
+ color: var(--color-error);
1291
+ font-size: 0.875rem;
1292
+ text-align: center;
1293
+ }
1294
+
1295
+ .new-password-fields {
1296
+ display: flex;
1297
+ flex-direction: column;
1298
+ gap: var(--space-5);
1299
+ animation: fadeSlide 0.2s ease;
1300
+ }
1301
+
1302
+ .alert {
1303
+ padding: var(--space-3) var(--space-4);
1304
+ border-radius: var(--radius-md);
1305
+ font-size: 0.875rem;
1306
+ display: flex;
1307
+ align-items: center;
1308
+ justify-content: space-between;
1309
+ gap: var(--space-2);
1310
+ }
1311
+
1312
+ .alert--success {
1313
+ background: color-mix(in srgb, var(--color-success) 10%, transparent);
1314
+ border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
1315
+ color: var(--color-success);
1316
+ }
1317
+
1318
+ .alert--error {
1319
+ background: color-mix(in srgb, var(--color-error) 10%, transparent);
1320
+ border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
1321
+ color: var(--color-error);
1322
+ }
1323
+
1324
+ .alert-close {
1325
+ background: none;
1326
+ border: none;
1327
+ color: inherit;
1328
+ cursor: pointer;
1329
+ font-size: 1.5rem;
1330
+ line-height: 1;
1331
+ padding: 0;
1332
+ opacity: 0.7;
1333
+ }
1334
+
1335
+ .alert-close:hover {
1336
+ opacity: 1;
1337
+ }
1338
+
1339
+ .auth-footer {
1340
+ display: flex;
1341
+ align-items: center;
1342
+ justify-content: center;
1343
+ gap: var(--space-2);
1344
+ padding-top: var(--space-4);
1345
+ text-align: center;
1346
+ }
1347
+
1348
+ .toggle-text {
1349
+ margin: 0;
1350
+ font-size: 0.875rem;
1351
+ color: var(--color-text-secondary);
1352
+ }
1353
+
1354
+ .toggle-text a {
1355
+ color: var(--color-primary);
1356
+ text-decoration: none;
1357
+ }
1358
+
1359
+ .toggle-text a:hover {
1360
+ text-decoration: underline;
1361
+ }
1362
+
1363
+ @keyframes fadeIn {
1364
+ from {
1365
+ opacity: 0;
1366
+ }
1367
+ to {
1368
+ opacity: 1;
1369
+ }
1370
+ }
1371
+
1372
+ @keyframes fadeOut {
1373
+ from {
1374
+ opacity: 1;
1375
+ }
1376
+ to {
1377
+ opacity: 0;
1378
+ }
1379
+ }
1380
+
1381
+ @keyframes slideUp {
1382
+ from {
1383
+ transform: translateY(100%);
1384
+ }
1385
+ to {
1386
+ transform: translateY(0);
1387
+ }
1388
+ }
1389
+
1390
+ @keyframes slideDown {
1391
+ from {
1392
+ transform: translateY(0);
1393
+ }
1394
+ to {
1395
+ transform: translateY(100%);
1396
+ }
1397
+ }
1398
+
1399
+ @keyframes fadeSlide {
1400
+ from {
1401
+ opacity: 0;
1402
+ transform: translateY(6px);
1403
+ }
1404
+ to {
1405
+ opacity: 1;
1406
+ transform: translateY(0);
1407
+ }
1408
+ }
1409
+
1410
+ @media (max-width: 640px) {
1411
+ .modal-container {
1412
+ height: 80dvh;
1413
+ }
1414
+ }
1415
+
1416
+ @media (prefers-reduced-motion: reduce) {
1417
+ * {
1418
+ animation: none !important;
1419
+ transition: none !important;
1420
+ }
1421
+ }`;
1422
+ var he = Object.defineProperty, ce = Object.getOwnPropertyDescriptor, f = (e, t, s, i) => {
1423
+ for (var r = i > 1 ? void 0 : i ? ce(t, s) : t, o = e.length - 1, a; o >= 0; o--)
1424
+ (a = e[o]) && (r = (i ? a(t, s, r) : a(r)) || r);
1425
+ return i && r && he(t, s, r), r;
1426
+ };
1427
+ const de = ["code", "state", "error", "error_description"];
1428
+ let g = class extends Ct {
1429
+ constructor() {
1430
+ super(...arguments), this.open = !1, this.initialMode = "signin", this.logoUrl = "", this.baseUrl = "", this.oauthDomain = "", this.oauthRegion = "", this.oauthUserPoolId = "", this.oauthClientId = "", this.oauthRedirectUri = "", this.size = "sm", this.theme = "light", this.mode = "signin", this.resetStep = "none", this.signupStep = "form", this.isLoading = !1, this.isClosing = !1, this.isVisible = !1, this.isLoggedIn = !1, this.email = "", this.password = "", this.givenName = "", this.familyName = "", this.newPassword = "", this.confirmPassword = "", this.notice = "", this.error = "", this.errors = {}, this.otpDigits = ["", "", "", "", "", ""], this.signupOtpDigits = ["", "", "", "", "", ""], this.isDragging = !1, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.lastDragEndTime = 0, this.cookies = re(), this.scrollPosition = 0, this.transitionDuration = 300, this.hasHandledOAuthCallback = !1, this.boundKeyHandler = (e) => {
1431
+ e.key === "Escape" && this.isVisible && this.handleClose();
1432
+ }, this.baseUrlErrorMessage = "Authentication service is not configured correctly. Please add an API domain or contact support.", this.handleClose = () => {
1433
+ this.isClosing || !this.isVisible || (this.cleanupInlineStyles(), this.isDragging = !1, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.isClosing = !0, setTimeout(() => {
1434
+ this.isClosing = !1, this.isVisible = !1, this.open = !1;
1435
+ }, this.transitionDuration));
1436
+ }, this.handleOverlayClick = () => {
1437
+ this.handleClose();
1438
+ }, this.handleDragStart = (e) => {
1439
+ if (!this.modalContainer || this.modalBody && this.modalBody.scrollTop > 0)
1440
+ return;
1441
+ const t = e.target;
1442
+ !(t.classList.contains("drawer-handle") || t.classList.contains("drawer-handle-bar") || t.closest(".drawer-handle")) && this.modalBody && this.modalBody.scrollTop > 0 || (this.modalContainer.style.transition = "", this.modalContainer.style.transform = "", this.isDragging = !0, this.dragStartTime = Date.now(), e instanceof TouchEvent ? (this.dragStartY = e.touches[0].clientY, this.dragCurrentY = e.touches[0].clientY) : (this.dragStartY = e.clientY, this.dragCurrentY = e.clientY));
1443
+ }, this.handleDragMove = (e) => {
1444
+ if (!this.isDragging || !this.modalContainer) return;
1445
+ e instanceof TouchEvent ? this.dragCurrentY = e.touches[0].clientY : this.dragCurrentY = e.clientY;
1446
+ const t = this.dragCurrentY - this.dragStartY;
1447
+ t > 0 && (e.preventDefault(), this.modalContainer.style.transform = `translateY(${t}px)`, this.modalContainer.style.transition = "none");
1448
+ }, this.handleDragEnd = () => {
1449
+ if (!this.isDragging || !this.modalContainer) return;
1450
+ const e = Math.max(0, this.dragCurrentY - this.dragStartY);
1451
+ e > 5 && (this.lastDragEndTime = Date.now());
1452
+ const t = Date.now() - this.dragStartTime, s = e / t, i = this.modalContainer.offsetHeight, r = Math.max(150, i * 0.3), a = e > r || s > 0.5;
1453
+ this.isDragging = !1;
1454
+ const h = this.modalContainer, n = a ? i + i * 0.1 : 0;
1455
+ h.style.transition = "none", h.style.transform = `translateY(${e}px)`, requestAnimationFrame(() => {
1456
+ h.style.transition = `transform ${this.transitionDuration}ms cubic-bezier(0.4, 0, 0.2, 1)`, h.style.transform = `translateY(${n}px)`;
1457
+ }), setTimeout(() => {
1458
+ this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, a ? (this.isVisible = !1, this.open = !1) : this.modalContainer && (this.modalContainer.style.transition = "", this.modalContainer.style.transform = "");
1459
+ }, this.transitionDuration);
1460
+ }, this.handleHandleClick = (e) => {
1461
+ if (Date.now() - this.lastDragEndTime < 200) {
1462
+ e.preventDefault(), e.stopPropagation();
1463
+ return;
1464
+ }
1465
+ this.handleClose();
1466
+ };
1467
+ }
1468
+ hasApiBaseUrl() {
1469
+ return this.baseUrl.trim().length > 0;
1470
+ }
1471
+ getNormalizedBaseUrl() {
1472
+ const e = this.baseUrl.trim();
1473
+ if (!e) return "";
1474
+ const t = e.endsWith("/") ? e : `${e}/`;
1475
+ return t.startsWith("http://") || t.startsWith("https://") ? t : `https://${t}`;
1476
+ }
1477
+ getApiService() {
1478
+ if (!this.hasApiBaseUrl())
1479
+ throw new Error("API domain is not set");
1480
+ return this.apiService || (this.apiService = se({
1481
+ baseUrl: this.getNormalizedBaseUrl()
1482
+ })), this.apiService;
1483
+ }
1484
+ connectedCallback() {
1485
+ super.connectedCallback(), window.addEventListener("keyup", this.boundKeyHandler);
1486
+ const e = this.cookies.getAuthToken("AUTH_TOKEN"), t = this.cookies.getAuthToken("REFRESH_TOKEN");
1487
+ this.isLoggedIn = !!(e && t), this.mode = this.initialMode, this.hasApiBaseUrl() || (this.error = this.baseUrlErrorMessage), this.handleOAuthCallbackIfPresent();
1488
+ }
1489
+ disconnectedCallback() {
1490
+ window.removeEventListener("keyup", this.boundKeyHandler), this.unlockBodyScroll(), super.disconnectedCallback();
1491
+ }
1492
+ firstUpdated() {
1493
+ this.open && (this.isVisible = !0);
1494
+ }
1495
+ updated(e) {
1496
+ e.has("baseUrl") && (this.apiService = void 0, this.hasApiBaseUrl() ? (this.error === this.baseUrlErrorMessage && (this.error = ""), this.hasHandledOAuthCallback || this.handleOAuthCallbackIfPresent()) : this.error = this.baseUrlErrorMessage), (e.has("oauthDomain") || e.has("oauthRegion") || e.has("oauthUserPoolId") || e.has("oauthClientId") || e.has("oauthRedirectUri")) && (this.oauthService = void 0, this.handleOAuthCallbackIfPresent()), e.has("open") && (this.open ? (this.isVisible = !0, this.lockBodyScroll(), setTimeout(() => {
1497
+ this.emailInput?.focus();
1498
+ }, 100)) : this.isVisible && this.handleClose()), e.has("isVisible") && (this.isVisible ? (this.lockBodyScroll(), this.cleanupInlineStyles()) : (this.unlockBodyScroll(), this.resetState()));
1499
+ }
1500
+ lockBodyScroll() {
1501
+ this.scrollPosition = window.scrollY, document.body.classList.add("modal-open"), document.body.style.top = `-${this.scrollPosition}px`;
1502
+ }
1503
+ unlockBodyScroll() {
1504
+ document.body.classList.remove("modal-open"), document.body.style.top = "", window.scrollTo(0, this.scrollPosition);
1505
+ }
1506
+ cleanupInlineStyles() {
1507
+ setTimeout(() => {
1508
+ this.modalContainer && (this.modalContainer.style.transition = "", this.modalContainer.style.transform = "");
1509
+ }, 0);
1510
+ }
1511
+ resetState() {
1512
+ this.isDragging = !1, this.lastDragEndTime = 0, this.dragStartY = 0, this.dragCurrentY = 0, this.dragStartTime = 0, this.error = "", this.notice = "", this.errors = {}, this.email = "", this.password = "", this.givenName = "", this.familyName = "", this.newPassword = "", this.confirmPassword = "", this.otpDigits = ["", "", "", "", "", ""], this.signupOtpDigits = ["", "", "", "", "", ""], this.resetStep = "none", this.signupStep = "form", this.mode = this.initialMode;
1513
+ }
1514
+ toggleMode() {
1515
+ this.resetStep === "none" && (this.mode = this.mode === "signin" ? "signup" : "signin", this.signupStep = "form", this.error = "", this.notice = "", this.errors = {}, this.confirmPassword = "", this.mode === "signin" && (this.givenName = "", this.familyName = "", this.signupOtpDigits = ["", "", "", "", "", ""]));
1516
+ }
1517
+ startReset() {
1518
+ this.mode = "signin", this.resetStep = "request", this.error = "", this.notice = "", this.errors = {}, this.password = "", this.newPassword = "", this.confirmPassword = "";
1519
+ }
1520
+ cancelReset() {
1521
+ this.resetStep = "none", this.error = "", this.notice = "", this.otpDigits = ["", "", "", "", "", ""], this.errors = {}, this.newPassword = "", this.confirmPassword = "";
1522
+ }
1523
+ backToRequest() {
1524
+ this.resetStep = "request", this.error = "", this.notice = "", this.otpDigits = ["", "", "", "", "", ""], this.errors = {}, this.newPassword = "", this.confirmPassword = "";
1525
+ }
1526
+ backToSignupForm() {
1527
+ this.signupStep = "form", this.error = "", this.notice = "", this.signupOtpDigits = ["", "", "", "", "", ""], this.errors = {};
1528
+ }
1529
+ // Validation
1530
+ validate() {
1531
+ const e = {};
1532
+ if (this.email.trim() ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.email) || (e.email = "Enter a valid email") : e.email = "Email is required", this.resetStep === "none" && this.signupStep === "form") {
1533
+ if (!this.password)
1534
+ e.password = "Password is required";
1535
+ else if (this.password.length < 8)
1536
+ e.password = "Password must be at least 8 characters";
1537
+ else if (this.mode === "signup") {
1538
+ const t = /[A-Z]/.test(this.password), s = /[a-z]/.test(this.password), i = /[0-9]/.test(this.password);
1539
+ (!t || !s || !i) && (e.password = "Password must contain uppercase, lowercase, and number");
1540
+ }
1541
+ }
1542
+ if (this.mode === "signup" && this.resetStep === "none" && this.signupStep === "form" && (this.givenName.trim() ? /^[a-zA-Z\s-']+$/.test(this.givenName.trim()) || (e.givenName = "Invalid first name") : e.givenName = "First name is required", this.familyName.trim() ? /^[a-zA-Z\s-']+$/.test(this.familyName.trim()) || (e.familyName = "Invalid last name") : e.familyName = "Last name is required", this.confirmPassword ? this.password !== this.confirmPassword && (e.confirm_password = "Passwords must match") : e.confirm_password = "Please confirm your password"), this.signupStep === "otp") {
1543
+ const t = this.signupOtpDigits.join("");
1544
+ (t.length !== 6 || !/^\d{6}$/.test(t)) && (e.signup_otp = "Enter the 6-digit code");
1545
+ }
1546
+ if (this.resetStep === "confirm") {
1547
+ const t = this.otpDigits.join("");
1548
+ if ((t.length !== 6 || !/^\d{6}$/.test(t)) && (e.otp = "Enter the 6-digit code"), t.length === 6) {
1549
+ if (!this.newPassword)
1550
+ e.new_password = "New password is required";
1551
+ else if (this.newPassword.length < 8)
1552
+ e.new_password = "Password must be at least 8 characters";
1553
+ else {
1554
+ const s = /[A-Z]/.test(this.newPassword), i = /[a-z]/.test(this.newPassword), r = /[0-9]/.test(this.newPassword);
1555
+ (!s || !i || !r) && (e.new_password = "Password must contain uppercase, lowercase, and number");
1556
+ }
1557
+ this.confirmPassword ? this.newPassword !== this.confirmPassword && (e.confirm_password = "Passwords must match") : e.confirm_password = "Please confirm your password";
1558
+ }
1559
+ }
1560
+ return this.errors = e, Object.keys(e).length === 0;
1561
+ }
1562
+ // Form submission
1563
+ async handleSubmit(e) {
1564
+ if (e.preventDefault(), this.notice = "", this.error = "", !this.hasApiBaseUrl()) {
1565
+ this.error = this.baseUrlErrorMessage;
1566
+ return;
1567
+ }
1568
+ if (this.validate()) {
1569
+ this.isLoading = !0;
1570
+ try {
1571
+ switch (`${this.resetStep}-${this.mode}-${this.signupStep}`) {
1572
+ case "request-signin-form":
1573
+ try {
1574
+ await this.handleRequestReset();
1575
+ } catch {
1576
+ this.error = "Reset request failed. Please check your details and try again.";
1577
+ }
1578
+ break;
1579
+ case "confirm-signin-form":
1580
+ try {
1581
+ await this.handleConfirmReset();
1582
+ } catch {
1583
+ this.error = "Reset confirmation failed. Please check your details and try again.";
1584
+ }
1585
+ break;
1586
+ case "none-signup-form":
1587
+ try {
1588
+ await this.handleRequestSignupOtp();
1589
+ } catch {
1590
+ this.error = "Signup failed. Please check your details and try again.";
1591
+ }
1592
+ break;
1593
+ case "none-signup-otp":
1594
+ try {
1595
+ await this.handleSignupWithOtp();
1596
+ } catch {
1597
+ this.error = "Signup failed. Please check your details and try again.";
1598
+ }
1599
+ break;
1600
+ default:
1601
+ try {
1602
+ await this.handleSignIn();
1603
+ } catch {
1604
+ this.error = "Login failed. Please check your credentials and try again.";
1605
+ }
1606
+ break;
1607
+ }
1608
+ } finally {
1609
+ this.isLoading = !1;
1610
+ }
1611
+ }
1612
+ }
1613
+ setAuthTokens(e, t, s) {
1614
+ this.cookies.setAuthToken("ACCESS_TOKEN", e), this.cookies.setAuthToken("AUTH_TOKEN", t), this.cookies.setAuthToken("REFRESH_TOKEN", s), this.isLoggedIn = !0;
1615
+ }
1616
+ async handleSignIn() {
1617
+ const e = {
1618
+ email: this.email.trim(),
1619
+ password: this.password
1620
+ }, { accessToken: t, idToken: s, refreshToken: i } = await this.getApiService().login(e);
1621
+ this.setAuthTokens(t, s, i), this.handleClose();
1622
+ }
1623
+ isOAuthConfigured() {
1624
+ return [this.oauthDomain, this.oauthRegion, this.oauthUserPoolId, this.oauthClientId].every(
1625
+ (e) => !!e?.trim()
1626
+ );
1627
+ }
1628
+ getOAuthService() {
1629
+ if (!this.isOAuthConfigured())
1630
+ return null;
1631
+ if (!this.oauthService) {
1632
+ const e = this.oauthRedirectUri?.trim() ? this.oauthRedirectUri.trim() : void 0;
1633
+ this.oauthService = ne({
1634
+ domain: this.oauthDomain.trim(),
1635
+ cognitoRegion: this.oauthRegion.trim(),
1636
+ userPoolId: this.oauthUserPoolId.trim(),
1637
+ clientId: this.oauthClientId.trim(),
1638
+ redirectUri: e
1639
+ });
1640
+ }
1641
+ return this.oauthService;
1642
+ }
1643
+ stripOAuthParamsFromUrl() {
1644
+ const e = new URL(window.location.href);
1645
+ let t = !1;
1646
+ for (const s of de)
1647
+ e.searchParams.has(s) && (e.searchParams.delete(s), t = !0);
1648
+ if (t) {
1649
+ const s = e.searchParams.toString(), i = `${e.pathname}${s ? `?${s}` : ""}${e.hash}`;
1650
+ window.history.replaceState({}, document.title, i);
1651
+ }
1652
+ }
1653
+ async handleOAuthCallbackIfPresent() {
1654
+ const e = new URLSearchParams(window.location.search), t = e.get("code"), s = e.get("state"), i = e.get("error"), r = e.get("error_description");
1655
+ if (!(!t && !i) && !this.hasHandledOAuthCallback && this.isOAuthConfigured()) {
1656
+ if (!this.hasApiBaseUrl()) {
1657
+ this.error = this.baseUrlErrorMessage;
1658
+ return;
1659
+ }
1660
+ this.hasHandledOAuthCallback = !0, this.isLoading = !0, this.error = "";
1661
+ try {
1662
+ if (i)
1663
+ throw new Error(r || `OAuth error: ${i}`);
1664
+ if (!t || !s)
1665
+ throw new Error("Missing authorization code or state parameter");
1666
+ const o = this.getOAuthService();
1667
+ if (!o)
1668
+ throw new Error("OAuth is not configured correctly. Please try again later.");
1669
+ if (!o.validateState(s))
1670
+ throw new Error("Invalid state parameter. Please try signing in again.");
1671
+ const a = await o.exchangeCodeForTokens(t), { accessToken: h, idToken: n, refreshToken: c } = await this.getApiService().login({
1672
+ accessToken: a.access_token,
1673
+ refreshToken: a.refresh_token,
1674
+ idToken: a.id_token
1675
+ });
1676
+ this.setAuthTokens(h, n, c ?? a.refresh_token);
1677
+ } catch (o) {
1678
+ this.error = o.message || "An unexpected error occurred during authentication";
1679
+ } finally {
1680
+ this.stripOAuthParamsFromUrl(), this.isLoading = !1;
1681
+ }
1682
+ }
1683
+ }
1684
+ async handleRequestSignupOtp() {
1685
+ this.signupStep = "otp", this.notice = "A 6-digit code has been sent to your email", this.signupOtpDigits = ["", "", "", "", "", ""], await this.getApiService().requestRegisterOtp({ email: this.email.trim() }), setTimeout(() => {
1686
+ this.shadowRoot?.querySelector(".signup-otp-input")?.focus();
1687
+ }, 200);
1688
+ }
1689
+ async handleSignupWithOtp() {
1690
+ const e = {
1691
+ email: this.email.trim(),
1692
+ password: this.password,
1693
+ givenName: this.givenName.trim(),
1694
+ familyName: this.familyName.trim(),
1695
+ code: this.signupOtpDigits.join("")
1696
+ };
1697
+ await this.getApiService().register({
1698
+ email: e.email,
1699
+ password: e.password,
1700
+ given_name: e.givenName,
1701
+ family_name: e.familyName,
1702
+ code: e.code
1703
+ }), await this.handleSignIn();
1704
+ }
1705
+ async handleRequestReset() {
1706
+ const e = {
1707
+ email: this.email.trim()
1708
+ };
1709
+ this.resetStep = "confirm", this.notice = "If an account exists, a 6-digit code has been sent", this.otpDigits = ["", "", "", "", "", ""], await this.getApiService().requestResetPassword(e), setTimeout(() => {
1710
+ this.shadowRoot?.querySelector(".reset-otp-input")?.focus();
1711
+ }, 100);
1712
+ }
1713
+ async handleConfirmReset() {
1714
+ const e = {
1715
+ email: this.email.trim(),
1716
+ newPassword: this.newPassword,
1717
+ otp: this.otpDigits.join("")
1718
+ };
1719
+ await this.getApiService().resetPassword({
1720
+ email: e.email,
1721
+ newPassword: e.newPassword,
1722
+ otp: e.otp
1723
+ }), await this.handleSignIn();
1724
+ }
1725
+ async logout() {
1726
+ const e = this.cookies.getAuthToken("ACCESS_TOKEN"), t = this.cookies.getAuthToken("AUTH_TOKEN"), s = this.cookies.getAuthToken("REFRESH_TOKEN");
1727
+ if (e == null || s == null || t == null) {
1728
+ this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1;
1729
+ return;
1730
+ }
1731
+ if (!this.hasApiBaseUrl()) {
1732
+ this.error = this.baseUrlErrorMessage;
1733
+ return;
1734
+ }
1735
+ const i = this.getApiService(), {
1736
+ redirectUrl: r,
1737
+ requiresRedirect: o
1738
+ } = await i.logout({
1739
+ accessToken: e,
1740
+ refreshToken: s,
1741
+ authToken: t
1742
+ });
1743
+ if (this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1, o && r) {
1744
+ const a = window.location.host;
1745
+ new URL(r).host !== a ? window.open(r, "newWindow", "width=400,height=400,resizable=yes,scrollbars=yes,status=yes") : window.location.href = r;
1746
+ }
1747
+ }
1748
+ // OAuth handlers
1749
+ handleGoogleSignIn() {
1750
+ this.getOAuthService()?.redirectToGoogleAuth();
1751
+ }
1752
+ handleAppleSignIn() {
1753
+ this.getOAuthService()?.redirectToAppleAuth();
1754
+ }
1755
+ // OTP input handlers
1756
+ handleOtpInput(e, t, s) {
1757
+ const i = t.target, r = i.value.replace(/\D/g, "");
1758
+ if (!r) {
1759
+ s ? (this.signupOtpDigits[e] = "", this.signupOtpDigits = [...this.signupOtpDigits]) : (this.otpDigits[e] = "", this.otpDigits = [...this.otpDigits]);
1760
+ return;
1761
+ }
1762
+ const o = r[r.length - 1];
1763
+ if (s ? (this.signupOtpDigits[e] = o, this.signupOtpDigits = [...this.signupOtpDigits]) : (this.otpDigits[e] = o, this.otpDigits = [...this.otpDigits]), e < 5) {
1764
+ const a = this.shadowRoot?.querySelector(
1765
+ `${s ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${e + 1}"]`
1766
+ );
1767
+ a?.focus(), a?.select();
1768
+ } else
1769
+ i.blur();
1770
+ }
1771
+ handleOtpKeydown(e, t, s) {
1772
+ const i = s ? this.signupOtpDigits : this.otpDigits;
1773
+ if (t.key === "Backspace") {
1774
+ if (i[e]) {
1775
+ s ? (this.signupOtpDigits[e] = "", this.signupOtpDigits = [...this.signupOtpDigits]) : (this.otpDigits[e] = "", this.otpDigits = [...this.otpDigits]);
1776
+ return;
1777
+ }
1778
+ if (e > 0) {
1779
+ const r = this.shadowRoot?.querySelector(
1780
+ `${s ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${e - 1}"]`
1781
+ );
1782
+ r?.focus(), r?.select(), s ? (this.signupOtpDigits[e - 1] = "", this.signupOtpDigits = [...this.signupOtpDigits]) : (this.otpDigits[e - 1] = "", this.otpDigits = [...this.otpDigits]);
1783
+ }
1784
+ }
1785
+ if (t.key === "ArrowLeft" && e > 0) {
1786
+ const r = this.shadowRoot?.querySelector(
1787
+ `${s ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${e - 1}"]`
1788
+ );
1789
+ r?.focus(), r?.select(), t.preventDefault();
1790
+ }
1791
+ if (t.key === "ArrowRight" && e < 5) {
1792
+ const r = this.shadowRoot?.querySelector(
1793
+ `${s ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${e + 1}"]`
1794
+ );
1795
+ r?.focus(), r?.select(), t.preventDefault();
1796
+ }
1797
+ t.key.length === 1 && /\D/.test(t.key) && t.preventDefault();
1798
+ }
1799
+ handleOtpPaste(e, t) {
1800
+ const i = (e.clipboardData?.getData("text") || "").replace(/\D/g, "").slice(0, 6).split("");
1801
+ if (i.length === 0) return;
1802
+ e.preventDefault();
1803
+ for (let o = 0; o < 6; o++)
1804
+ t ? this.signupOtpDigits[o] = i[o] || "" : this.otpDigits[o] = i[o] || "";
1805
+ t ? this.signupOtpDigits = [...this.signupOtpDigits] : this.otpDigits = [...this.otpDigits];
1806
+ const r = (t ? this.signupOtpDigits : this.otpDigits).findIndex((o) => !o);
1807
+ if (r === -1)
1808
+ this.shadowRoot?.querySelector(
1809
+ `${t ? ".signup-otp-input" : ".reset-otp-input"}[data-index="5"]`
1810
+ )?.blur();
1811
+ else {
1812
+ const o = this.shadowRoot?.querySelector(
1813
+ `${t ? ".signup-otp-input" : ".reset-otp-input"}[data-index="${r}"]`
1814
+ );
1815
+ o?.focus(), o?.select();
1816
+ }
1817
+ }
1818
+ render() {
1819
+ if (!this.isVisible)
1820
+ return $;
1821
+ const e = {
1822
+ "modal-overlay": !0,
1823
+ "modal-overlay--closing": this.isClosing
1824
+ }, t = {
1825
+ "modal-container": !0,
1826
+ "modal-container--drawer": !0,
1827
+ "modal-container--closing": this.isClosing,
1828
+ "modal-container--dragging": this.isDragging,
1829
+ [`modal-container--${this.size}`]: !0
1830
+ };
1831
+ return m`
1832
+ <!-- Modal/Drawer -->
1833
+ <div
1834
+ class=${ut(e)}
1835
+ @click=${this.handleOverlayClick}
1836
+ @touchstart=${this.handleDragStart}
1837
+ @touchmove=${this.handleDragMove}
1838
+ @touchend=${this.handleDragEnd}
1839
+ @mousedown=${this.handleDragStart}
1840
+ >
1841
+ <div
1842
+ class=${ut(t)}
1843
+ @click=${(s) => s.stopPropagation()}
1844
+ role="dialog"
1845
+ aria-modal="true"
1846
+ @mousemove=${this.handleDragMove}
1847
+ @mouseup=${this.handleDragEnd}
1848
+ >
1849
+ <!-- Drawer Handle -->
1850
+ <div
1851
+ class="drawer-handle"
1852
+ @click=${this.handleHandleClick}
1853
+ role="button"
1854
+ tabindex="0"
1855
+ aria-label="Close drawer"
1856
+ >
1857
+ <div class="drawer-handle-bar"></div>
1858
+ </div>
1859
+
1860
+ <!-- Drawer Content Wrapper -->
1861
+ <div class="drawer-content drawer-content--${this.size}">
1862
+ ${this.renderContent()}
1863
+ </div>
1864
+ </div>
1865
+ </div>
1866
+ `;
1867
+ }
1868
+ renderContent() {
1869
+ if (!this.hasApiBaseUrl()) {
1870
+ const e = this.baseUrlErrorMessage;
1871
+ return m`
1872
+ ${this.logoUrl.length > 0 ? m`
1873
+ <header class="modal-header">
1874
+ <div class="auth-header">
1875
+ <img
1876
+ src="${this.logoUrl}"
1877
+ width="48"
1878
+ height="48"
1879
+ alt="Logo"
1880
+ class="auth-logo"
1881
+ />
1882
+ </div>
1883
+ </header>
1884
+ ` : $}
1885
+
1886
+ <div class="modal-body">
1887
+ <div class="auth-form">
1888
+ <div class="alert alert--error">
1889
+ ${e}
1890
+ </div>
1891
+ </div>
1892
+ </div>
1893
+ `;
1894
+ }
1895
+ return this.isLoggedIn ? m`
1896
+ <!-- Header -->
1897
+ ${this.logoUrl.length > 0 ? m`
1898
+ <header class="modal-header">
1899
+ <div class="auth-header">
1900
+ <img
1901
+ src="${this.logoUrl}"
1902
+ width="48"
1903
+ height="48"
1904
+ alt="Logo"
1905
+ class="auth-logo"
1906
+ />
1907
+ </div>
1908
+ </header>
1909
+ ` : $}
1910
+
1911
+ <!-- Body -->
1912
+ <div class="modal-body">
1913
+ <div class="auth-form">
1914
+ <div class="form-actions">
1915
+ <button type="button" class="cta" @click=${this.logout}>Logout</button>
1916
+ </div>
1917
+ ${this.renderAlerts()}
1918
+ </div>
1919
+ </div>
1920
+ ` : m`
1921
+ <!-- Header -->
1922
+ ${(!this.mode || this.resetStep === "none") && this.logoUrl.length > 0 && this.mode === "signin" ? m`
1923
+ <header class="modal-header">
1924
+
1925
+ <div class="auth-header">
1926
+ <img
1927
+ src="${this.logoUrl}"
1928
+ width="48"
1929
+ height="48"
1930
+ alt="Logo"
1931
+ class="auth-logo"
1932
+ />
1933
+ </div>
1934
+ </header>
1935
+ ` : $}
1936
+
1937
+ <!-- Body -->
1938
+ <div class="modal-body">
1939
+ <form @submit=${this.handleSubmit} class="auth-form" novalidate>
1940
+ ${this.renderFormContent()}
1941
+
1942
+ <!-- Actions -->
1943
+ <div class="form-actions">
1944
+ ${this.renderActions()}
1945
+ </div>
1946
+
1947
+ ${this.renderAlerts()}
1948
+ </form>
1949
+
1950
+ ${this.renderFooter()}
1951
+ </div>
1952
+ `;
1953
+ }
1954
+ renderFormContent() {
1955
+ if (this.resetStep === "none" && (!this.mode || this.mode === "signin" || this.signupStep === "form"))
1956
+ return m`
1957
+ <!-- Email -->
1958
+ <label class="field">
1959
+ <span class="field-label">Email Address</span>
1960
+ <input
1961
+ id="email-input"
1962
+ type="email"
1963
+ class="field-input ${this.errors.email ? "field-input--error" : ""}"
1964
+ placeholder="Enter your email"
1965
+ .value=${this.email}
1966
+ @input=${(e) => this.email = e.target.value}
1967
+ required
1968
+ autocomplete="email"
1969
+ />
1970
+ ${this.errors.email ? m`<span class="field-error">${this.errors.email}</span>` : $}
1971
+ </label>
1972
+
1973
+ <!-- Password -->
1974
+ <label class="field">
1975
+ <span class="field-label">Password</span>
1976
+ <input
1977
+ type="password"
1978
+ class="field-input ${this.errors.password ? "field-input--error" : ""}"
1979
+ placeholder="Enter your password"
1980
+ .value=${this.password}
1981
+ @input=${(e) => this.password = e.target.value}
1982
+ required
1983
+ autocomplete=${this.mode === "signup" ? "new-password" : "current-password"}
1984
+ />
1985
+ ${this.errors.password ? m`<span class="field-error">${this.errors.password}</span>` : $}
1986
+ </label>
1987
+
1988
+ ${this.mode === "signin" && this.error ? m`
1989
+ <div class="forgot-row">
1990
+ <button type="button" class="text-btn" @click=${this.startReset}>
1991
+ Forgot your password?
1992
+ </button>
1993
+ </div>
1994
+ ` : $}
1995
+
1996
+ ${this.mode === "signup" ? m`
1997
+ <!-- Confirm Password -->
1998
+ <label class="field">
1999
+ <span class="field-label">Confirm Password</span>
2000
+ <input
2001
+ type="password"
2002
+ class="field-input ${this.errors.confirm_password ? "field-input--error" : ""}"
2003
+ placeholder="Re-enter your password"
2004
+ .value=${this.confirmPassword}
2005
+ @input=${(e) => this.confirmPassword = e.target.value}
2006
+ required
2007
+ autocomplete="new-password"
2008
+ />
2009
+ ${this.errors.confirm_password ? m`<span class="field-error">${this.errors.confirm_password}</span>` : $}
2010
+ </label>
2011
+
2012
+ <!-- First Name -->
2013
+ <label class="field">
2014
+ <span class="field-label">First Name</span>
2015
+ <input
2016
+ type="text"
2017
+ class="field-input ${this.errors.givenName ? "field-input--error" : ""}"
2018
+ placeholder="Enter your first name"
2019
+ .value=${this.givenName}
2020
+ @input=${(e) => this.givenName = e.target.value}
2021
+ required
2022
+ autocomplete="given-name"
2023
+ />
2024
+ ${this.errors.givenName ? m`<span class="field-error">${this.errors.givenName}</span>` : $}
2025
+ </label>
2026
+
2027
+ <!-- Last Name -->
2028
+ <label class="field">
2029
+ <span class="field-label">Last Name</span>
2030
+ <input
2031
+ type="text"
2032
+ class="field-input ${this.errors.familyName ? "field-input--error" : ""}"
2033
+ placeholder="Enter your last name"
2034
+ .value=${this.familyName}
2035
+ @input=${(e) => this.familyName = e.target.value}
2036
+ required
2037
+ autocomplete="family-name"
2038
+ />
2039
+ ${this.errors.familyName ? m`<span class="field-error">${this.errors.familyName}</span>` : $}
2040
+ </label>
2041
+ ` : $}
2042
+ `;
2043
+ if (this.mode === "signup" && this.signupStep === "otp")
2044
+ return m`
2045
+ <div class="otp-section">
2046
+ <label class="otp-label">Enter 6-digit code</label>
2047
+ <div class="otp-inputs" role="group" aria-label="One time code">
2048
+ ${ft(
2049
+ Array.from({ length: 6 }, (e, t) => t),
2050
+ (e) => e,
2051
+ (e) => m`
2052
+ <input
2053
+ class="otp-input signup-otp-input ${this.errors.signup_otp ? "otp-input--error" : ""}"
2054
+ type="text"
2055
+ inputmode="numeric"
2056
+ pattern="[0-9]*"
2057
+ maxlength="1"
2058
+ data-index="${e}"
2059
+ .value=${this.signupOtpDigits[e]}
2060
+ @input=${(t) => this.handleOtpInput(e, t, !0)}
2061
+ @keydown=${(t) => this.handleOtpKeydown(e, t, !0)}
2062
+ @paste=${(t) => this.handleOtpPaste(t, !0)}
2063
+ aria-label="Digit ${e + 1}"
2064
+ />
2065
+ `
2066
+ )}
2067
+ </div>
2068
+ ${this.errors.signup_otp ? m`<p class="otp-error">${this.errors.signup_otp}</p>` : $}
2069
+ </div>
2070
+ <div class="forgot-row">
2071
+ <button type="button" class="text-btn" @click=${this.backToSignupForm}>
2072
+ Didn't get a code? Go back
2073
+ </button>
2074
+ </div>
2075
+ `;
2076
+ if (this.resetStep === "request")
2077
+ return m`
2078
+ <label class="field">
2079
+ <span class="field-label">Email Address</span>
2080
+ <input
2081
+ id="email-input"
2082
+ type="email"
2083
+ class="field-input ${this.errors.email ? "field-input--error" : ""}"
2084
+ placeholder="Enter your email"
2085
+ .value=${this.email}
2086
+ @input=${(e) => this.email = e.target.value}
2087
+ required
2088
+ autocomplete="email"
2089
+ />
2090
+ ${this.errors.email ? m`<span class="field-error">${this.errors.email}</span>` : $}
2091
+ </label>
2092
+ <div class="forgot-row">
2093
+ <button type="button" class="text-btn" @click=${this.cancelReset}>
2094
+ Back to Sign In
2095
+ </button>
2096
+ </div>
2097
+ `;
2098
+ if (this.resetStep === "confirm") {
2099
+ const e = this.otpDigits.every((t) => /^\d$/.test(t));
2100
+ return m`
2101
+ <label class="field">
2102
+ <span class="field-label">Email Address</span>
2103
+ <input
2104
+ type="email"
2105
+ class="field-input ${this.errors.email ? "field-input--error" : ""}"
2106
+ placeholder="Enter your email"
2107
+ .value=${this.email}
2108
+ @input=${(t) => this.email = t.target.value}
2109
+ required
2110
+ autocomplete="email"
2111
+ />
2112
+ ${this.errors.email ? m`<span class="field-error">${this.errors.email}</span>` : $}
2113
+ </label>
2114
+
2115
+ <div class="otp-section">
2116
+ <label class="otp-label">Enter 6-digit code</label>
2117
+ <div class="otp-inputs" role="group" aria-label="One time code">
2118
+ ${ft(
2119
+ Array.from({ length: 6 }, (t, s) => s),
2120
+ (t) => t,
2121
+ (t) => m`
2122
+ <input
2123
+ class="otp-input reset-otp-input ${this.errors.otp ? "otp-input--error" : ""}"
2124
+ type="text"
2125
+ inputmode="numeric"
2126
+ pattern="[0-9]*"
2127
+ maxlength="1"
2128
+ data-index="${t}"
2129
+ .value=${this.otpDigits[t]}
2130
+ @input=${(s) => this.handleOtpInput(t, s, !1)}
2131
+ @keydown=${(s) => this.handleOtpKeydown(t, s, !1)}
2132
+ @paste=${(s) => this.handleOtpPaste(s, !1)}
2133
+ aria-label="Digit ${t + 1}"
2134
+ />
2135
+ `
2136
+ )}
2137
+ </div>
2138
+ ${this.errors.otp ? m`<p class="otp-error">${this.errors.otp}</p>` : $}
2139
+ </div>
2140
+
2141
+ ${e ? m`
2142
+ <div class="new-password-fields">
2143
+ <label class="field">
2144
+ <span class="field-label">New Password</span>
2145
+ <input
2146
+ type="password"
2147
+ class="field-input ${this.errors.new_password ? "field-input--error" : ""}"
2148
+ placeholder="Enter your new password"
2149
+ .value=${this.newPassword}
2150
+ @input=${(t) => this.newPassword = t.target.value}
2151
+ required
2152
+ autocomplete="new-password"
2153
+ />
2154
+ ${this.errors.new_password ? m`<span class="field-error">${this.errors.new_password}</span>` : $}
2155
+ </label>
2156
+
2157
+ <label class="field">
2158
+ <span class="field-label">Confirm New Password</span>
2159
+ <input
2160
+ type="password"
2161
+ class="field-input ${this.errors.confirm_password ? "field-input--error" : ""}"
2162
+ placeholder="Re-enter your new password"
2163
+ .value=${this.confirmPassword}
2164
+ @input=${(t) => this.confirmPassword = t.target.value}
2165
+ required
2166
+ autocomplete="new-password"
2167
+ />
2168
+ ${this.errors.confirm_password ? m`<span class="field-error">${this.errors.confirm_password}</span>` : $}
2169
+ </label>
2170
+ </div>
2171
+ ` : $}
2172
+
2173
+ <div class="forgot-row">
2174
+ <button type="button" class="text-btn" @click=${this.backToRequest}>
2175
+ Didn't get a code? Resend
2176
+ </button>
2177
+ </div>
2178
+ `;
2179
+ }
2180
+ return $;
2181
+ }
2182
+ renderActions() {
2183
+ if (this.resetStep === "request")
2184
+ return m`
2185
+ <button type="submit" class="cta" ?disabled=${this.isLoading}>
2186
+ ${this.isLoading ? "Sending..." : "Send Reset Code"}
2187
+ </button>
2188
+ `;
2189
+ if (this.resetStep === "confirm")
2190
+ return this.otpDigits.every((t) => /^\d$/.test(t)) ? m`
2191
+ <button type="submit" class="cta" ?disabled=${this.isLoading}>
2192
+ ${this.isLoading ? "Resetting..." : "Reset Password"}
2193
+ </button>
2194
+ ` : $;
2195
+ if (this.mode === "signup" && this.signupStep === "otp") {
2196
+ const e = this.signupOtpDigits.every((t) => /^\d$/.test(t));
2197
+ return m`
2198
+ <button type="submit" class="cta" ?disabled=${!e || this.isLoading}>
2199
+ ${this.isLoading ? "Completing..." : "Complete Registration"}
2200
+ </button>
2201
+ `;
2202
+ }
2203
+ return m`
2204
+ <button type="submit" class="cta" ?disabled=${this.isLoading}>
2205
+ ${this.isLoading ? "Loading..." : this.mode === "signup" ? "Continue" : "Sign In"}
2206
+ </button>
2207
+
2208
+ ${this.isOAuthConfigured() && this.mode === "signin" ? m`
2209
+ <div class="button-row">
2210
+ <button
2211
+ type="button"
2212
+ class="oauth-btn"
2213
+ @click=${this.handleGoogleSignIn}
2214
+ ?disabled=${this.isLoading}
2215
+ >
2216
+ ${this.renderGoogleIcon()}
2217
+ </button>
2218
+
2219
+ <button
2220
+ type="button"
2221
+ class="oauth-btn"
2222
+ @click=${this.handleAppleSignIn}
2223
+ ?disabled=${this.isLoading}
2224
+ >
2225
+ ${this.renderAppleIcon()}
2226
+ </button>
2227
+ </div>
2228
+ ` : $}
2229
+ `;
2230
+ }
2231
+ renderAlerts() {
2232
+ return m`
2233
+ ${this.notice ? m`
2234
+ <div class="alert alert--success">
2235
+ ${this.notice}
2236
+ <button class="alert-close" @click=${() => this.notice = ""} aria-label="Dismiss">
2237
+ ×
2238
+ </button>
2239
+ </div>
2240
+ ` : $}
2241
+ ${this.error ? m`
2242
+ <div class="alert alert--error">
2243
+ ${this.error}
2244
+ <button class="alert-close" @click=${() => this.error = ""} aria-label="Dismiss">
2245
+ ×
2246
+ </button>
2247
+ </div>
2248
+ ` : $}
2249
+ `;
2250
+ }
2251
+ renderFooter() {
2252
+ return this.isLoggedIn ? $ : this.resetStep === "none" && (!this.mode || this.mode === "signin" || this.signupStep === "form") ? m`
2253
+ <div class="auth-footer">
2254
+ <p class="toggle-text">
2255
+ ${this.mode === "signup" ? "Already have an account?" : "Don't have an account?"}
2256
+ </p>
2257
+ <button type="button" class="text-btn" @click=${this.toggleMode}>
2258
+ ${this.mode === "signup" ? "Sign In" : "Sign Up"}
2259
+ </button>
2260
+ </div>
2261
+ ` : m`
2262
+ <div class="auth-footer">
2263
+ <p class="toggle-text">
2264
+ Having trouble? Email
2265
+ <a href="mailto:support@example.com">support@example.com</a>
2266
+ </p>
2267
+ </div>
2268
+ `;
2269
+ }
2270
+ renderGoogleIcon() {
2271
+ return m`
2272
+ <svg viewBox="-0.5 0 48 48" width="18" height="18" fill="none">
2273
+ <path d="M9.82727273,24 C9.82727273,22.4757333 10.0804318,21.0144 10.5322727,19.6437333 L2.62345455,13.6042667 C1.08206818,16.7338667 0.213636364,20.2602667 0.213636364,24 C0.213636364,27.7365333 1.081,31.2608 2.62025,34.3882667 L10.5247955,28.3370667 C10.0772273,26.9728 9.82727273,25.5168 9.82727273,24" fill="#FBBC05"></path>
2274
+ <path d="M23.7136364,10.1333333 C27.025,10.1333333 30.0159091,11.3066667 32.3659091,13.2266667 L39.2022727,6.4 C35.0363636,2.77333333 29.6954545,0.533333333 23.7136364,0.533333333 C14.4268636,0.533333333 6.44540909,5.84426667 2.62345455,13.6042667 L10.5322727,19.6437333 C12.3545909,14.112 17.5491591,10.1333333 23.7136364,10.1333333" fill="#EB4335"></path>
2275
+ <path d="M23.7136364,37.8666667 C17.5491591,37.8666667 12.3545909,33.888 10.5322727,28.3562667 L2.62345455,34.3946667 C6.44540909,42.1557333 14.4268636,47.4666667 23.7136364,47.4666667 C29.4455,47.4666667 34.9177955,45.4314667 39.0249545,41.6181333 L31.5177727,35.8144 C29.3995682,37.1488 26.7323182,37.8666667 23.7136364,37.8666667" fill="#34A853"></path>
2276
+ <path d="M46.1454545,24 C46.1454545,22.6133333 45.9318182,21.12 45.6113636,19.7333333 L23.7136364,19.7333333 L23.7136364,28.8 L36.3181818,28.8 C35.6879545,31.8912 33.9724545,34.2677333 31.5177727,35.8144 L39.0249545,41.6181333 C43.3393409,37.6138667 46.1454545,31.6490667 46.1454545,24" fill="#4285F4"></path>
2277
+ </svg>
2278
+ `;
2279
+ }
2280
+ renderAppleIcon() {
2281
+ return m`
2282
+ <svg viewBox="-3.5 0 48 48" width="18" height="18" class="apple-icon">
2283
+ <path d="M231.174735,567.792499 C232.740177,565.771699 233.926883,562.915484 233.497649,560 C230.939077,560.177808 227.948466,561.814769 226.203475,563.948463 C224.612784,565.88177 223.305444,568.757742 223.816036,571.549042 C226.613071,571.636535 229.499881,569.960061 231.174735,567.792499 L231.174735,567.792499 Z M245,595.217241 C243.880625,597.712195 243.341978,598.827022 241.899976,601.03692 C239.888467,604.121745 237.052156,607.962958 233.53412,607.991182 C230.411652,608.02505 229.606488,605.94498 225.367451,605.970382 C221.128414,605.99296 220.244696,608.030695 217.116618,607.999649 C213.601387,607.968603 210.913765,604.502761 208.902256,601.417937 C203.27452,592.79849 202.68257,582.680377 206.152914,577.298162 C208.621711,573.476705 212.515678,571.241407 216.173986,571.241407 C219.89682,571.241407 222.239372,573.296075 225.322563,573.296075 C228.313175,573.296075 230.133913,571.235762 234.440281,571.235762 C237.700215,571.235762 241.153726,573.022307 243.611302,576.10431 C235.554045,580.546683 236.85858,592.121127 245,595.217241 L245,595.217241 Z" transform="translate(-204.000000, -560.000000)" fill="#0b0b0a"></path>
2284
+ </svg>
2285
+ `;
2286
+ }
2287
+ // Public methods for external control
2288
+ setError(e) {
2289
+ this.error = e;
2290
+ }
2291
+ setNotice(e) {
2292
+ this.notice = e;
2293
+ }
2294
+ closeModal() {
2295
+ this.handleClose();
2296
+ }
2297
+ openModal() {
2298
+ this.open = !0, this.isVisible = !0;
2299
+ }
2300
+ async refresh() {
2301
+ try {
2302
+ if (!this.hasApiBaseUrl()) {
2303
+ this.error = this.baseUrlErrorMessage;
2304
+ return;
2305
+ }
2306
+ const e = this.cookies.getAuthToken("REFRESH_TOKEN"), t = this.cookies.getAuthToken("ACCESS_TOKEN"), s = this.cookies.getAuthToken("AUTH_TOKEN");
2307
+ if (!e || !t || !s) {
2308
+ this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1;
2309
+ return;
2310
+ }
2311
+ const { accessToken: i, idToken: r, refreshToken: o } = await this.getApiService().refresh({
2312
+ refreshToken: e
2313
+ });
2314
+ this.cookies.setAuthToken("ACCESS_TOKEN", i), this.cookies.setAuthToken("AUTH_TOKEN", r), this.cookies.setAuthToken("REFRESH_TOKEN", o ?? e);
2315
+ } catch {
2316
+ this.cookies.clearAllAuthTokens(), this.isLoggedIn = !1;
2317
+ }
2318
+ }
2319
+ };
2320
+ g.styles = le();
2321
+ f([
2322
+ k({ type: Boolean, reflect: !0 })
2323
+ ], g.prototype, "open", 2);
2324
+ f([
2325
+ k({ type: String, attribute: "initial-mode" })
2326
+ ], g.prototype, "initialMode", 2);
2327
+ f([
2328
+ k({ type: String, attribute: "logo-url" })
2329
+ ], g.prototype, "logoUrl", 2);
2330
+ f([
2331
+ k({ type: String, attribute: "api-domain" })
2332
+ ], g.prototype, "baseUrl", 2);
2333
+ f([
2334
+ k({ type: String, attribute: "oauth-domain" })
2335
+ ], g.prototype, "oauthDomain", 2);
2336
+ f([
2337
+ k({ type: String, attribute: "oauth-region" })
2338
+ ], g.prototype, "oauthRegion", 2);
2339
+ f([
2340
+ k({ type: String, attribute: "oauth-user-pool-id" })
2341
+ ], g.prototype, "oauthUserPoolId", 2);
2342
+ f([
2343
+ k({ type: String, attribute: "oauth-client-id" })
2344
+ ], g.prototype, "oauthClientId", 2);
2345
+ f([
2346
+ k({ type: String, attribute: "oauth-redirect-uri" })
2347
+ ], g.prototype, "oauthRedirectUri", 2);
2348
+ f([
2349
+ k({ type: String, attribute: "size" })
2350
+ ], g.prototype, "size", 2);
2351
+ f([
2352
+ k({ type: String, attribute: "data-theme", reflect: !0 })
2353
+ ], g.prototype, "theme", 2);
2354
+ f([
2355
+ b()
2356
+ ], g.prototype, "mode", 2);
2357
+ f([
2358
+ b()
2359
+ ], g.prototype, "resetStep", 2);
2360
+ f([
2361
+ b()
2362
+ ], g.prototype, "signupStep", 2);
2363
+ f([
2364
+ b()
2365
+ ], g.prototype, "isLoading", 2);
2366
+ f([
2367
+ b()
2368
+ ], g.prototype, "isClosing", 2);
2369
+ f([
2370
+ b()
2371
+ ], g.prototype, "isVisible", 2);
2372
+ f([
2373
+ b()
2374
+ ], g.prototype, "isLoggedIn", 2);
2375
+ f([
2376
+ b()
2377
+ ], g.prototype, "email", 2);
2378
+ f([
2379
+ b()
2380
+ ], g.prototype, "password", 2);
2381
+ f([
2382
+ b()
2383
+ ], g.prototype, "givenName", 2);
2384
+ f([
2385
+ b()
2386
+ ], g.prototype, "familyName", 2);
2387
+ f([
2388
+ b()
2389
+ ], g.prototype, "newPassword", 2);
2390
+ f([
2391
+ b()
2392
+ ], g.prototype, "confirmPassword", 2);
2393
+ f([
2394
+ b()
2395
+ ], g.prototype, "notice", 2);
2396
+ f([
2397
+ b()
2398
+ ], g.prototype, "error", 2);
2399
+ f([
2400
+ b()
2401
+ ], g.prototype, "errors", 2);
2402
+ f([
2403
+ b()
2404
+ ], g.prototype, "otpDigits", 2);
2405
+ f([
2406
+ b()
2407
+ ], g.prototype, "signupOtpDigits", 2);
2408
+ f([
2409
+ b()
2410
+ ], g.prototype, "isDragging", 2);
2411
+ f([
2412
+ b()
2413
+ ], g.prototype, "dragStartY", 2);
2414
+ f([
2415
+ b()
2416
+ ], g.prototype, "dragCurrentY", 2);
2417
+ f([
2418
+ b()
2419
+ ], g.prototype, "dragStartTime", 2);
2420
+ f([
2421
+ b()
2422
+ ], g.prototype, "lastDragEndTime", 2);
2423
+ f([
2424
+ X(".modal-container")
2425
+ ], g.prototype, "modalContainer", 2);
2426
+ f([
2427
+ X("#email-input")
2428
+ ], g.prototype, "emailInput", 2);
2429
+ f([
2430
+ X(".modal-body")
2431
+ ], g.prototype, "modalBody", 2);
2432
+ g = f([
2433
+ xt("cals-auth")
2434
+ ], g);
2435
+ export {
2436
+ g as CalsAuth
2437
+ };