@wral/report-it 0.2.0 → 0.2.2

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.
@@ -1,68 +1,68 @@
1
- import { css as y, html as c, nothing as f, LitElement as G } from "lit";
2
- import { getAuthContext as Se, createStorage as Ce, verifyCode as Te, extractTokens as Z, saveTokens as X, decodeJwtPayload as ee, refreshTokenSimple as te, sendCode as Re, createUserPool as Me, signUpIfNeeded as De, createCognitoUser as Pe, STORAGE_KEYS as S, isAuthenticatedSimple as ze } from "@wral/sdk-auth-audience";
3
- const K = globalThis, re = (s) => s, B = K.trustedTypes, se = B ? B.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, xe = "$lit$", v = `lit$${Math.random().toFixed(9).slice(2)}$`, ve = "?" + v, Be = `<${ve}>`, A = document, O = () => A.createComment(""), R = (s) => s === null || typeof s != "object" && typeof s != "function", Q = Array.isArray, Oe = (s) => Q(s) || typeof s?.[Symbol.iterator] == "function", H = `[
4
- \f\r]`, C = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ie = /-->/g, ne = />/g, $ = RegExp(`>|${H}(?:([^\\s"'>=/]+)(${H}*=${H}*(?:[^
5
- \f\r"'\`<>=]|("|')|))|$)`, "g"), oe = /'/g, ae = /"/g, _e = /^(?:script|style|textarea|title)$/i, M = /* @__PURE__ */ Symbol.for("lit-noChange"), m = /* @__PURE__ */ Symbol.for("lit-nothing"), le = /* @__PURE__ */ new WeakMap(), k = A.createTreeWalker(A, 129);
6
- function $e(s, e) {
7
- if (!Q(s) || !s.hasOwnProperty("raw")) throw Error("invalid template strings array");
8
- return se !== void 0 ? se.createHTML(e) : e;
9
- }
10
- const Ue = (s, e) => {
11
- const t = s.length - 1, r = [];
12
- let i, n = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", o = C;
1
+ import { css as b, html as c, nothing as f, LitElement as G } from "lit";
2
+ import { getAuthContext as Re, createStorage as Oe, verifyCode as Me, extractTokens as J, saveTokens as X, decodeJwtPayload as ee, refreshTokenSimple as te, sendCode as Ne, createUserPool as De, createCognitoUser as Pe, STORAGE_KEYS as S, isAuthenticatedSimple as Ue, signUpIfNeeded as ze } from "@wral/sdk-auth-audience";
3
+ const K = globalThis, se = (r) => r, P = K.trustedTypes, re = P ? P.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ve = "$lit$", _ = `lit$${Math.random().toFixed(9).slice(2)}$`, _e = "?" + _, Be = `<${_e}>`, F = document, U = () => F.createComment(""), R = (r) => r === null || typeof r != "object" && typeof r != "function", Q = Array.isArray, Le = (r) => Q(r) || typeof r?.[Symbol.iterator] == "function", q = `[
4
+ \f\r]`, C = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ne = /-->/g, ie = />/g, k = RegExp(`>|${q}(?:([^\\s"'>=/]+)(${q}*=${q}*(?:[^
5
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), oe = /'/g, ae = /"/g, $e = /^(?:script|style|textarea|title)$/i, O = /* @__PURE__ */ Symbol.for("lit-noChange"), g = /* @__PURE__ */ Symbol.for("lit-nothing"), le = /* @__PURE__ */ new WeakMap(), A = F.createTreeWalker(F, 129);
6
+ function ke(r, e) {
7
+ if (!Q(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array");
8
+ return re !== void 0 ? re.createHTML(e) : e;
9
+ }
10
+ const He = (r, e) => {
11
+ const t = r.length - 1, s = [];
12
+ let n, i = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", o = C;
13
13
  for (let a = 0; a < t; a++) {
14
- const l = s[a];
15
- let d, p, u = -1, h = 0;
16
- for (; h < l.length && (o.lastIndex = h, p = o.exec(l), p !== null); ) h = o.lastIndex, o === C ? p[1] === "!--" ? o = ie : p[1] !== void 0 ? o = ne : p[2] !== void 0 ? (_e.test(p[2]) && (i = RegExp("</" + p[2], "g")), o = $) : p[3] !== void 0 && (o = $) : o === $ ? p[0] === ">" ? (o = i ?? C, u = -1) : p[1] === void 0 ? u = -2 : (u = o.lastIndex - p[2].length, d = p[1], o = p[3] === void 0 ? $ : p[3] === '"' ? ae : oe) : o === ae || o === oe ? o = $ : o === ie || o === ne ? o = C : (o = $, i = void 0);
17
- const b = o === $ && s[a + 1].startsWith("/>") ? " " : "";
18
- n += o === C ? l + Be : u >= 0 ? (r.push(d), l.slice(0, u) + xe + l.slice(u) + v + b) : l + v + (u === -2 ? a : b);
14
+ const l = r[a];
15
+ let d, h, u = -1, p = 0;
16
+ for (; p < l.length && (o.lastIndex = p, h = o.exec(l), h !== null); ) p = o.lastIndex, o === C ? h[1] === "!--" ? o = ne : h[1] !== void 0 ? o = ie : h[2] !== void 0 ? ($e.test(h[2]) && (n = RegExp("</" + h[2], "g")), o = k) : h[3] !== void 0 && (o = k) : o === k ? h[0] === ">" ? (o = n ?? C, u = -1) : h[1] === void 0 ? u = -2 : (u = o.lastIndex - h[2].length, d = h[1], o = h[3] === void 0 ? k : h[3] === '"' ? ae : oe) : o === ae || o === oe ? o = k : o === ne || o === ie ? o = C : (o = k, n = void 0);
17
+ const y = o === k && r[a + 1].startsWith("/>") ? " " : "";
18
+ i += o === C ? l + Be : u >= 0 ? (s.push(d), l.slice(0, u) + ve + l.slice(u) + _ + y) : l + _ + (u === -2 ? a : y);
19
19
  }
20
- return [$e(s, n + (s[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), r];
20
+ return [ke(r, i + (r[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), s];
21
21
  };
22
- class D {
23
- constructor({ strings: e, _$litType$: t }, r) {
24
- let i;
22
+ class M {
23
+ constructor({ strings: e, _$litType$: t }, s) {
24
+ let n;
25
25
  this.parts = [];
26
- let n = 0, o = 0;
27
- const a = e.length - 1, l = this.parts, [d, p] = Ue(e, t);
28
- if (this.el = D.createElement(d, r), k.currentNode = this.el.content, t === 2 || t === 3) {
26
+ let i = 0, o = 0;
27
+ const a = e.length - 1, l = this.parts, [d, h] = He(e, t);
28
+ if (this.el = M.createElement(d, s), A.currentNode = this.el.content, t === 2 || t === 3) {
29
29
  const u = this.el.content.firstChild;
30
30
  u.replaceWith(...u.childNodes);
31
31
  }
32
- for (; (i = k.nextNode()) !== null && l.length < a; ) {
33
- if (i.nodeType === 1) {
34
- if (i.hasAttributes()) for (const u of i.getAttributeNames()) if (u.endsWith(xe)) {
35
- const h = p[o++], b = i.getAttribute(u).split(v), w = /([.?@])?(.*)/.exec(h);
36
- l.push({ type: 1, index: n, name: w[2], strings: b, ctor: w[1] === "." ? Ne : w[1] === "?" ? qe : w[1] === "@" ? He : L }), i.removeAttribute(u);
37
- } else u.startsWith(v) && (l.push({ type: 6, index: n }), i.removeAttribute(u));
38
- if (_e.test(i.tagName)) {
39
- const u = i.textContent.split(v), h = u.length - 1;
40
- if (h > 0) {
41
- i.textContent = B ? B.emptyScript : "";
42
- for (let b = 0; b < h; b++) i.append(u[b], O()), k.nextNode(), l.push({ type: 2, index: ++n });
43
- i.append(u[h], O());
32
+ for (; (n = A.nextNode()) !== null && l.length < a; ) {
33
+ if (n.nodeType === 1) {
34
+ if (n.hasAttributes()) for (const u of n.getAttributeNames()) if (u.endsWith(ve)) {
35
+ const p = h[o++], y = n.getAttribute(u).split(_), w = /([.?@])?(.*)/.exec(p);
36
+ l.push({ type: 1, index: i, name: w[2], strings: y, ctor: w[1] === "." ? We : w[1] === "?" ? Ve : w[1] === "@" ? je : B }), n.removeAttribute(u);
37
+ } else u.startsWith(_) && (l.push({ type: 6, index: i }), n.removeAttribute(u));
38
+ if ($e.test(n.tagName)) {
39
+ const u = n.textContent.split(_), p = u.length - 1;
40
+ if (p > 0) {
41
+ n.textContent = P ? P.emptyScript : "";
42
+ for (let y = 0; y < p; y++) n.append(u[y], U()), A.nextNode(), l.push({ type: 2, index: ++i });
43
+ n.append(u[p], U());
44
44
  }
45
45
  }
46
- } else if (i.nodeType === 8) if (i.data === ve) l.push({ type: 2, index: n });
46
+ } else if (n.nodeType === 8) if (n.data === _e) l.push({ type: 2, index: i });
47
47
  else {
48
48
  let u = -1;
49
- for (; (u = i.data.indexOf(v, u + 1)) !== -1; ) l.push({ type: 7, index: n }), u += v.length - 1;
49
+ for (; (u = n.data.indexOf(_, u + 1)) !== -1; ) l.push({ type: 7, index: i }), u += _.length - 1;
50
50
  }
51
- n++;
51
+ i++;
52
52
  }
53
53
  }
54
54
  static createElement(e, t) {
55
- const r = A.createElement("template");
56
- return r.innerHTML = e, r;
55
+ const s = F.createElement("template");
56
+ return s.innerHTML = e, s;
57
57
  }
58
58
  }
59
- function E(s, e, t = s, r) {
60
- if (e === M) return e;
61
- let i = r !== void 0 ? t._$Co?.[r] : t._$Cl;
62
- const n = R(e) ? void 0 : e._$litDirective$;
63
- return i?.constructor !== n && (i?._$AO?.(!1), n === void 0 ? i = void 0 : (i = new n(s), i._$AT(s, t, r)), r !== void 0 ? (t._$Co ??= [])[r] = i : t._$Cl = i), i !== void 0 && (e = E(s, i._$AS(s, e.values), i, r)), e;
59
+ function E(r, e, t = r, s) {
60
+ if (e === O) return e;
61
+ let n = s !== void 0 ? t._$Co?.[s] : t._$Cl;
62
+ const i = R(e) ? void 0 : e._$litDirective$;
63
+ return n?.constructor !== i && (n?._$AO?.(!1), i === void 0 ? n = void 0 : (n = new i(r), n._$AT(r, t, s)), s !== void 0 ? (t._$Co ??= [])[s] = n : t._$Cl = n), n !== void 0 && (e = E(r, n._$AS(r, e.values), n, s)), e;
64
64
  }
65
- class Le {
65
+ class qe {
66
66
  constructor(e, t) {
67
67
  this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
68
68
  }
@@ -73,29 +73,29 @@ class Le {
73
73
  return this._$AM._$AU;
74
74
  }
75
75
  u(e) {
76
- const { el: { content: t }, parts: r } = this._$AD, i = (e?.creationScope ?? A).importNode(t, !0);
77
- k.currentNode = i;
78
- let n = k.nextNode(), o = 0, a = 0, l = r[0];
76
+ const { el: { content: t }, parts: s } = this._$AD, n = (e?.creationScope ?? F).importNode(t, !0);
77
+ A.currentNode = n;
78
+ let i = A.nextNode(), o = 0, a = 0, l = s[0];
79
79
  for (; l !== void 0; ) {
80
80
  if (o === l.index) {
81
81
  let d;
82
- l.type === 2 ? d = new U(n, n.nextSibling, this, e) : l.type === 1 ? d = new l.ctor(n, l.name, l.strings, this, e) : l.type === 6 && (d = new je(n, this, e)), this._$AV.push(d), l = r[++a];
82
+ l.type === 2 ? d = new z(i, i.nextSibling, this, e) : l.type === 1 ? d = new l.ctor(i, l.name, l.strings, this, e) : l.type === 6 && (d = new Ye(i, this, e)), this._$AV.push(d), l = s[++a];
83
83
  }
84
- o !== l?.index && (n = k.nextNode(), o++);
84
+ o !== l?.index && (i = A.nextNode(), o++);
85
85
  }
86
- return k.currentNode = A, i;
86
+ return A.currentNode = F, n;
87
87
  }
88
88
  p(e) {
89
89
  let t = 0;
90
- 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++;
90
+ for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(e, s, t), t += s.strings.length - 2) : s._$AI(e[t])), t++;
91
91
  }
92
92
  }
93
- class U {
93
+ class z {
94
94
  get _$AU() {
95
95
  return this._$AM?._$AU ?? this._$Cv;
96
96
  }
97
- constructor(e, t, r, i) {
98
- this.type = 2, this._$AH = m, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = r, this.options = i, this._$Cv = i?.isConnected ?? !0;
97
+ constructor(e, t, s, n) {
98
+ this.type = 2, this._$AH = g, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = s, this.options = n, this._$Cv = n?.isConnected ?? !0;
99
99
  }
100
100
  get parentNode() {
101
101
  let e = this._$AA.parentNode;
@@ -109,7 +109,7 @@ class U {
109
109
  return this._$AB;
110
110
  }
111
111
  _$AI(e, t = this) {
112
- e = E(this, e, t), R(e) ? e === m || e == null || e === "" ? (this._$AH !== m && this._$AR(), this._$AH = m) : e !== this._$AH && e !== M && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : Oe(e) ? this.k(e) : this._(e);
112
+ e = E(this, e, t), R(e) ? e === g || e == null || e === "" ? (this._$AH !== g && this._$AR(), this._$AH = g) : e !== this._$AH && e !== O && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : Le(e) ? this.k(e) : this._(e);
113
113
  }
114
114
  O(e) {
115
115
  return this._$AA.parentNode.insertBefore(e, this._$AB);
@@ -118,94 +118,94 @@ class U {
118
118
  this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
119
119
  }
120
120
  _(e) {
121
- this._$AH !== m && R(this._$AH) ? this._$AA.nextSibling.data = e : this.T(A.createTextNode(e)), this._$AH = e;
121
+ this._$AH !== g && R(this._$AH) ? this._$AA.nextSibling.data = e : this.T(F.createTextNode(e)), this._$AH = e;
122
122
  }
123
123
  $(e) {
124
- const { values: t, _$litType$: r } = e, i = typeof r == "number" ? this._$AC(e) : (r.el === void 0 && (r.el = D.createElement($e(r.h, r.h[0]), this.options)), r);
125
- if (this._$AH?._$AD === i) this._$AH.p(t);
124
+ const { values: t, _$litType$: s } = e, n = typeof s == "number" ? this._$AC(e) : (s.el === void 0 && (s.el = M.createElement(ke(s.h, s.h[0]), this.options)), s);
125
+ if (this._$AH?._$AD === n) this._$AH.p(t);
126
126
  else {
127
- const n = new Le(i, this), o = n.u(this.options);
128
- n.p(t), this.T(o), this._$AH = n;
127
+ const i = new qe(n, this), o = i.u(this.options);
128
+ i.p(t), this.T(o), this._$AH = i;
129
129
  }
130
130
  }
131
131
  _$AC(e) {
132
132
  let t = le.get(e.strings);
133
- return t === void 0 && le.set(e.strings, t = new D(e)), t;
133
+ return t === void 0 && le.set(e.strings, t = new M(e)), t;
134
134
  }
135
135
  k(e) {
136
136
  Q(this._$AH) || (this._$AH = [], this._$AR());
137
137
  const t = this._$AH;
138
- let r, i = 0;
139
- for (const n of e) i === t.length ? t.push(r = new U(this.O(O()), this.O(O()), this, this.options)) : r = t[i], r._$AI(n), i++;
140
- i < t.length && (this._$AR(r && r._$AB.nextSibling, i), t.length = i);
138
+ let s, n = 0;
139
+ for (const i of e) n === t.length ? t.push(s = new z(this.O(U()), this.O(U()), this, this.options)) : s = t[n], s._$AI(i), n++;
140
+ n < t.length && (this._$AR(s && s._$AB.nextSibling, n), t.length = n);
141
141
  }
142
142
  _$AR(e = this._$AA.nextSibling, t) {
143
143
  for (this._$AP?.(!1, !0, t); e !== this._$AB; ) {
144
- const r = re(e).nextSibling;
145
- re(e).remove(), e = r;
144
+ const s = se(e).nextSibling;
145
+ se(e).remove(), e = s;
146
146
  }
147
147
  }
148
148
  setConnected(e) {
149
149
  this._$AM === void 0 && (this._$Cv = e, this._$AP?.(e));
150
150
  }
151
151
  }
152
- class L {
152
+ class B {
153
153
  get tagName() {
154
154
  return this.element.tagName;
155
155
  }
156
156
  get _$AU() {
157
157
  return this._$AM._$AU;
158
158
  }
159
- constructor(e, t, r, i, n) {
160
- this.type = 1, this._$AH = m, this._$AN = void 0, this.element = e, this.name = t, this._$AM = i, this.options = n, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = m;
159
+ constructor(e, t, s, n, i) {
160
+ this.type = 1, this._$AH = g, this._$AN = void 0, this.element = e, this.name = t, this._$AM = n, this.options = i, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = g;
161
161
  }
162
- _$AI(e, t = this, r, i) {
163
- const n = this.strings;
162
+ _$AI(e, t = this, s, n) {
163
+ const i = this.strings;
164
164
  let o = !1;
165
- if (n === void 0) e = E(this, e, t, 0), o = !R(e) || e !== this._$AH && e !== M, o && (this._$AH = e);
165
+ if (i === void 0) e = E(this, e, t, 0), o = !R(e) || e !== this._$AH && e !== O, o && (this._$AH = e);
166
166
  else {
167
167
  const a = e;
168
168
  let l, d;
169
- for (e = n[0], l = 0; l < n.length - 1; l++) d = E(this, a[r + l], t, l), d === M && (d = this._$AH[l]), o ||= !R(d) || d !== this._$AH[l], d === m ? e = m : e !== m && (e += (d ?? "") + n[l + 1]), this._$AH[l] = d;
169
+ for (e = i[0], l = 0; l < i.length - 1; l++) d = E(this, a[s + l], t, l), d === O && (d = this._$AH[l]), o ||= !R(d) || d !== this._$AH[l], d === g ? e = g : e !== g && (e += (d ?? "") + i[l + 1]), this._$AH[l] = d;
170
170
  }
171
- o && !i && this.j(e);
171
+ o && !n && this.j(e);
172
172
  }
173
173
  j(e) {
174
- e === m ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
174
+ e === g ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
175
175
  }
176
176
  }
177
- class Ne extends L {
177
+ class We extends B {
178
178
  constructor() {
179
179
  super(...arguments), this.type = 3;
180
180
  }
181
181
  j(e) {
182
- this.element[this.name] = e === m ? void 0 : e;
182
+ this.element[this.name] = e === g ? void 0 : e;
183
183
  }
184
184
  }
185
- class qe extends L {
185
+ class Ve extends B {
186
186
  constructor() {
187
187
  super(...arguments), this.type = 4;
188
188
  }
189
189
  j(e) {
190
- this.element.toggleAttribute(this.name, !!e && e !== m);
190
+ this.element.toggleAttribute(this.name, !!e && e !== g);
191
191
  }
192
192
  }
193
- class He extends L {
194
- constructor(e, t, r, i, n) {
195
- super(e, t, r, i, n), this.type = 5;
193
+ class je extends B {
194
+ constructor(e, t, s, n, i) {
195
+ super(e, t, s, n, i), this.type = 5;
196
196
  }
197
197
  _$AI(e, t = this) {
198
- if ((e = E(this, e, t, 0) ?? m) === M) return;
199
- const r = this._$AH, i = e === m && r !== m || e.capture !== r.capture || e.once !== r.once || e.passive !== r.passive, n = e !== m && (r === m || i);
200
- i && this.element.removeEventListener(this.name, this, r), n && this.element.addEventListener(this.name, this, e), this._$AH = e;
198
+ if ((e = E(this, e, t, 0) ?? g) === O) return;
199
+ const s = this._$AH, n = e === g && s !== g || e.capture !== s.capture || e.once !== s.once || e.passive !== s.passive, i = e !== g && (s === g || n);
200
+ n && this.element.removeEventListener(this.name, this, s), i && this.element.addEventListener(this.name, this, e), this._$AH = e;
201
201
  }
202
202
  handleEvent(e) {
203
203
  typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
204
204
  }
205
205
  }
206
- class je {
207
- constructor(e, t, r) {
208
- this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = r;
206
+ class Ye {
207
+ constructor(e, t, s) {
208
+ this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = s;
209
209
  }
210
210
  get _$AU() {
211
211
  return this._$AM._$AU;
@@ -214,9 +214,9 @@ class je {
214
214
  E(this, e);
215
215
  }
216
216
  }
217
- const We = K.litHtmlPolyfillSupport;
218
- We?.(D, U), (K.litHtmlVersions ??= []).push("3.3.3");
219
- const ce = (s) => s ?? m, Ve = y`
217
+ const Ge = K.litHtmlPolyfillSupport;
218
+ Ge?.(M, z), (K.litHtmlVersions ??= []).push("3.3.3");
219
+ const ce = (r) => r ?? g, Ke = b`
220
220
  :host {
221
221
  display: block;
222
222
  box-sizing: border-box;
@@ -240,7 +240,7 @@ const ce = (s) => s ?? m, Ve = y`
240
240
  position: absolute; width: 1px; height: 1px; overflow: hidden;
241
241
  clip: rect(0 0 0 0); white-space: nowrap;
242
242
  }
243
- `, Ye = y`
243
+ `, Qe = b`
244
244
  @keyframes pop-in {
245
245
  0% { opacity: 0; transform: translateY(16px) scale(0.95); }
246
246
  100% { opacity: 1; transform: translateY(0) scale(1); }
@@ -253,7 +253,7 @@ const ce = (s) => s ?? m, Ve = y`
253
253
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
254
254
  30% { transform: translateY(-5px); opacity: 1; }
255
255
  }
256
- .msg, .options, .form-card, .confirm-card, .journey {
256
+ .msg, .options, .form-card, .confirm-card {
257
257
  animation: pop-in 340ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
258
258
  }
259
259
  .chip { animation: chip-in 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@@ -267,11 +267,11 @@ const ce = (s) => s ?? m, Ve = y`
267
267
  .typing span:nth-child(2) { animation-delay: 0.15s; }
268
268
  .typing span:nth-child(3) { animation-delay: 0.3s; }
269
269
  @media (prefers-reduced-motion: reduce) {
270
- .msg, .options, .form-card, .confirm-card, .journey, .chip, .typing span {
270
+ .msg, .options, .form-card, .confirm-card, .chip, .typing span {
271
271
  animation: none !important;
272
272
  }
273
273
  }
274
- `, Ge = y`
274
+ `, Ze = b`
275
275
  .msg { max-width: 85%; padding: 12px 16px; border-radius: 14px; font-size: 15px; }
276
276
  .msg.bot {
277
277
  background: var(--wral-semantic-surface-default, #FFFFFF);
@@ -293,7 +293,7 @@ const ce = (s) => s ?? m, Ve = y`
293
293
  .msg .sub { display: block; font-size: 13px; color: var(--wral-semantic-fg-muted, #64748B); margin-top: 4px; }
294
294
  .msg.user .sub { color: rgba(255, 255, 255, 0.75); }
295
295
  .msg.error { border-left: 3px solid var(--wral-base-red-on-light, #D1232A); }
296
- `, Ke = y`
296
+ `, Je = b`
297
297
  .options { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 92%; padding: 2px 0 6px; }
298
298
  .chip {
299
299
  font-family: var(--wral-base-font-ui, 'IBM Plex Sans Condensed', sans-serif);
@@ -307,7 +307,7 @@ const ce = (s) => s ?? m, Ve = y`
307
307
  .chip:hover { background: var(--wral-base-secondary-1, #2594E3); color: #FFFFFF; }
308
308
  .chip:focus-visible { outline: 2px solid var(--wral-base-secondary-1, #2594E3); outline-offset: 2px; }
309
309
  .chip:active { transform: scale(0.97); }
310
- `, Qe = y`
310
+ `, Xe = b`
311
311
  .form-card {
312
312
  align-self: stretch;
313
313
  background: var(--wral-semantic-surface-default, #FFFFFF);
@@ -372,7 +372,7 @@ const ce = (s) => s ?? m, Ve = y`
372
372
  .btn-ghost:hover { border-color: var(--wral-base-secondary-1, #2594E3); }
373
373
  .btn-ghost:active { transform: scale(0.97); }
374
374
  .btn-ghost:focus-visible { outline: 2px solid var(--wral-base-secondary-1, #2594E3); outline-offset: 2px; }
375
- `, Je = y`
375
+ `, et = b`
376
376
  .login-card { padding: 28px 26px; }
377
377
  .login-card h2 {
378
378
  font-family: var(--wral-base-font-display, 'IBM Plex Sans Condensed', sans-serif);
@@ -459,7 +459,7 @@ const ce = (s) => s ?? m, Ve = y`
459
459
  .anon-costs .x { flex-shrink: 0; font-weight: 700; color: var(--wral-base-red-on-light, #D1232A); }
460
460
  .anon-actions { display: flex; flex-direction: column; gap: 10px; }
461
461
  .anon-actions .btn-ghost { width: 100%; }
462
- `, Ze = y`
462
+ `, tt = b`
463
463
  .review-list { margin: 0; padding: 0; list-style: none; font-size: 14px; }
464
464
  .review-list li {
465
465
  display: grid; grid-template-columns: 130px 1fr; gap: 10px;
@@ -491,7 +491,7 @@ const ce = (s) => s ?? m, Ve = y`
491
491
  color: var(--wral-base-primary-1, #001D68);
492
492
  }
493
493
  @media (max-width: 540px) { .review-list li { grid-template-columns: 1fr; gap: 2px; } }
494
- `, Xe = y`
494
+ `, st = b`
495
495
  .upload-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13.5px; }
496
496
  .upload-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
497
497
  .upload-row .state { font-size: 12px; color: var(--wral-semantic-fg-subtle, #64748B); }
@@ -507,7 +507,7 @@ const ce = (s) => s ?? m, Ve = y`
507
507
  border-radius: 999px; padding: 3px 12px; cursor: pointer;
508
508
  }
509
509
  .retry-chip:focus-visible { outline: 2px solid var(--wral-base-secondary-1, #2594E3); outline-offset: 2px; }
510
- `, et = y`
510
+ `, rt = b`
511
511
  .confirm-card {
512
512
  align-self: stretch;
513
513
  background: var(--wral-base-primary-1, #001D68);
@@ -557,48 +557,23 @@ const ce = (s) => s ?? m, Ve = y`
557
557
  .c-again:hover { background: rgba(255, 255, 255, 0.12); }
558
558
  .c-again:focus-visible { outline: 2px solid var(--wral-base-secondary-2, #50A9E8); outline-offset: 2px; }
559
559
  .c-again:active { transform: scale(0.97); }
560
- `, tt = y`
561
- .journey {
562
- align-self: stretch;
563
- background: var(--wral-semantic-surface-default, #FFFFFF);
564
- border: 1px solid var(--wral-semantic-border-muted, #E2E8F0);
565
- border-radius: 12px; padding: 20px 22px;
566
- box-shadow: 0 1px 2px rgba(3, 7, 17, 0.07), 0 6px 16px rgba(3, 7, 17, 0.05);
567
- }
568
- .j-eyebrow {
569
- font-family: var(--wral-base-font-ui, 'IBM Plex Sans Condensed', sans-serif);
570
- font-size: 12px; font-weight: 700; text-transform: uppercase;
571
- letter-spacing: 0.08em;
572
- color: var(--wral-base-red-on-light, #D1232A);
573
- margin-bottom: 2px;
574
- }
575
- .j-title {
576
- font-family: var(--wral-base-font-display, 'IBM Plex Sans Condensed', sans-serif);
577
- font-size: 18px; font-weight: 700;
578
- color: var(--wral-base-primary-1, #001D68); margin: 0 0 10px;
560
+ .facts-offer dl {
561
+ display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
562
+ margin: 0 0 14px; font-size: 14.5px;
579
563
  }
580
- .j-step { position: relative; display: flex; gap: 12px; padding: 9px 0; }
581
- .j-step:not(:last-child)::before {
582
- content: ''; position: absolute; left: 12px; top: 38px; bottom: -6px;
583
- width: 1.5px; background: var(--wral-semantic-border-default, #CBD5E1);
564
+ .facts-offer dt { font-weight: 700; color: var(--wral-semantic-fg-subtle, #64748B); }
565
+ .facts-offer dd { margin: 0; overflow-wrap: anywhere; }
566
+ .facts-offer .facts-note {
567
+ display: flex; gap: 8px; align-items: center;
568
+ margin: 0 0 14px; font-size: 13.5px;
569
+ color: var(--wral-semantic-fg-muted, #475569);
584
570
  }
585
- .j-dot {
586
- flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
587
- background: var(--wral-semantic-surface-sunken, #F1F5F9);
588
- border: 1.5px solid var(--wral-base-secondary-1, #2594E3);
571
+ .facts-offer .my-wral-icon {
572
+ flex-shrink: 0; width: 28px; height: 28px;
589
573
  color: var(--wral-base-primary-1, #001D68);
590
- font-family: var(--wral-base-font-mono, 'IBM Plex Mono', monospace);
591
- font-size: 11px;
592
- display: flex; align-items: center; justify-content: center;
593
- position: relative; z-index: 1;
594
- }
595
- .j-body .j-t {
596
- font-family: var(--wral-base-font-ui, 'IBM Plex Sans Condensed', sans-serif);
597
- font-size: 14.5px; font-weight: 700;
598
- color: var(--wral-base-primary-1, #001D68); margin-bottom: 2px;
599
574
  }
600
- .j-body .j-d { font-size: 13.5px; color: var(--wral-semantic-fg-muted, #475569); line-height: 1.55; }
601
- `, rt = y`
575
+ .facts-offer .actions { display: flex; flex-wrap: wrap; gap: 8px; }
576
+ `, nt = b`
602
577
  .bottom-bar {
603
578
  position: sticky; bottom: 0; z-index: 20;
604
579
  background: var(--wral-semantic-surface-default, #FFFFFF);
@@ -611,89 +586,100 @@ const ce = (s) => s ?? m, Ve = y`
611
586
  }
612
587
  .bottom-bar .note { margin-left: auto; font-size: 12px; color: var(--wral-semantic-fg-subtle, #64748B); }
613
588
  @media (max-width: 540px) { .bottom-bar .note { display: none; } }
614
- `, st = [Ve, Ye, Ge, Ke, Qe, Je, Ze, Xe, et, tt, rt];
615
- function g(s, e, { noAnim: t = !1, error: r = !1 } = {}) {
589
+ `, it = [Ke, Qe, Ze, Je, Xe, et, tt, st, rt, nt];
590
+ function m(r, e, { noAnim: t = !1, error: s = !1 } = {}) {
616
591
  return c`
617
- <div class="msg bot ${t ? "no-anim" : ""} ${r ? "error" : ""}">
618
- <span class="lead">${s}</span>
592
+ <div class="msg bot ${t ? "no-anim" : ""} ${s ? "error" : ""}">
593
+ <span class="lead">${r}</span>
619
594
  ${e ? c`<span class="sub">${e}</span>` : f}
620
595
  </div>
621
596
  `;
622
597
  }
623
- function F(s, { noAnim: e = !1 } = {}) {
624
- return c`<div class="msg user ${e ? "no-anim" : ""}">${s}</div>`;
598
+ function v(r, { noAnim: e = !1 } = {}) {
599
+ return c`<div class="msg user ${e ? "no-anim" : ""}">${r}</div>`;
625
600
  }
626
- function j() {
601
+ function W() {
627
602
  return c`<div class="msg bot typing"><span></span><span></span><span></span></div>`;
628
603
  }
629
- function it(s) {
630
- return s ? c`<span class="flag-pill ${s}">${s === "urgent" ? "Urgent" : "Moderate"}</span>` : f;
604
+ function ot(r) {
605
+ return r ? c`<span class="flag-pill ${r}">${r === "urgent" ? "Urgent" : "Moderate"}</span>` : f;
631
606
  }
632
- function nt() {
607
+ function at() {
633
608
  return c`
634
609
  <svg viewBox="0 0 24 24" fill="none" stroke="#FFFFFF" stroke-width="3"
635
610
  stroke-linecap="round" stroke-linejoin="round" width="20" height="20"
636
611
  aria-hidden="true"><path d="M20 6L9 17l-5-5"/></svg>
637
612
  `;
638
613
  }
639
- const ot = 15e3;
614
+ function lt() {
615
+ return c`
616
+ <svg class="my-wral-icon" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 423 423">
617
+ <rect x="7.4" y="7.4" width="408.21" height="408.21" rx="204.1" ry="204.1" transform="translate(-46.49 60.15) rotate(-14.6)" fill="#fff"/>
618
+ <path d="M275.54,335.39c-6.35-4.36-6.31-10.09-2.64-8.95,2.38.89,7.28,2.02,12.45.67,28.16-7.34,33.71-60.25,33.4-90.88-8.42,12.43-14.4,23.62-24.46,26.24-6.04,1.57-15.9.23-23.04-3.63-9.31-5.1-13.58-10.91-16.81-23.31-4.04-15.5,1.11-47.55,3.78-60.89.07-.92.86-1.43,1.72-1.65,9.48-2.47,28.53,7.02,28.44,17.28.01,15.35-6.27,38.36-3.41,49.35.81,3.1,2.97,4.34,4.98,3.82,7.76-2.02,21.85-31.58,26.87-46.44,6.59-19.48,6.85-37.3,10.88-38.35,6.89-1.8,22.4,5.9,24.17,13.87,10.85,52.26.88,151.79-51.71,165.48-7.47,1.95-16.82,2.57-24.62-2.62Z" fill="currentColor"/>
619
+ <path d="M77.88,314.03c-4.19-16.07-3.14-35.61-2.89-44.1,1.84-47.14,4.3-84.81,13.75-133.32,1.05-5.39,4.7-9.05,16.15-7.52,10.8,1.4,14.78,6.08,16.1,11.16.66,2.54.97,6.07,2,11.22,12.38,1.59,15.13,5.09,19.64,14.15,4.58,9.34,6.28,17.03,8.04,23.79,2.72,10.43,4.49,18.4,7.34,26.99,11.89-22.67,15.82-55.9,34.99-75.34,6.66-6.25,10.81-9.14,15.41-10.34,3.74-.97,4.31-1.12,7.98-1.17,11.21-2.92,20.44,1.9,21.91,7.54.44,1.69,1.77,7.97,2,10.01,2.08,12.7-1.86,42.33-.69,73.93.66,15.48.93,25.95,2.42,36.4.75,5.22-.23,10.9-9.71,13.37-3.16.82-7.4,2.23-10.42,2.41-6.33.45-8.81-6.73-9.78-12.8-6.74-36.47,1.6-91.63-1.83-101.27-9.11,19.23-13.35,32.38-18.54,45.47-3.41,9.32-6.93,21.67-10.7,30.78-3.69,10.59-4.88,15.42-13.22,17.59-3.45.9-6.39,1.36-9.27,2.11-7.19,1.87-17.92-1.65-20.41-8.83-6.22-19.15-9-27.46-20.28-66.06-5.84,78.88-6.35,118.15.88,140.04,1.83,5.85-9.96,7.71-12.04,7.96-23,3.58-26.87-6.55-28.85-14.16Z" fill="currentColor"/>
620
+ <rect x="7.4" y="7.4" width="408.21" height="408.21" rx="204.1" ry="204.1" transform="translate(-46.49 60.15) rotate(-14.6)" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="2"/>
621
+ <rect x="7.4" y="7.4" width="408.21" height="408.21" rx="204.1" ry="204.1" transform="translate(-46.49 60.15) rotate(-14.6)" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="10"/>
622
+ </svg>
623
+ `;
624
+ }
625
+ const ct = 15e3;
640
626
  class I extends Error {
641
627
  constructor(e, t) {
642
628
  super(`api-forms request failed with status ${e}`), this.status = e, this.body = t;
643
629
  }
644
630
  }
645
631
  const de = Object.freeze({ enabled: !1, humanCheck: null });
646
- function at({
647
- baseUrl: s,
648
- fetchFn: e = (...i) => fetch(...i),
632
+ function dt({
633
+ baseUrl: r,
634
+ fetchFn: e = (...n) => fetch(...n),
649
635
  xhrFactory: t = () => new XMLHttpRequest(),
650
- getAuthHeaders: r
636
+ getAuthHeaders: s
651
637
  }) {
652
- const i = String(s || "").replace(/\/+$/, "");
653
- let n = de, o = null;
654
- async function a(l, { method: d = "GET", body: p, auth: u = !1, timeoutMs: h } = {}) {
655
- const b = { Accept: "application/json" };
656
- u && Object.assign(b, o ? { Authorization: `Bearer ${o}` } : await r()), p !== void 0 && (b["Content-Type"] = "application/json");
638
+ const n = String(r || "").replace(/\/+$/, "");
639
+ let i = de, o = null;
640
+ async function a(l, { method: d = "GET", body: h, auth: u = !1, timeoutMs: p } = {}) {
641
+ const y = { Accept: "application/json" };
642
+ u && Object.assign(y, o ? { Authorization: `Bearer ${o}` } : await s()), h !== void 0 && (y["Content-Type"] = "application/json");
657
643
  let w;
658
644
  try {
659
- w = await e(`${i}${l}`, {
645
+ w = await e(`${n}${l}`, {
660
646
  method: d,
661
- headers: b,
662
- ...h ? { signal: AbortSignal.timeout(h) } : {},
663
- ...p !== void 0 ? { body: JSON.stringify(p) } : {}
647
+ headers: y,
648
+ ...p ? { signal: AbortSignal.timeout(p) } : {},
649
+ ...h !== void 0 ? { body: JSON.stringify(h) } : {}
664
650
  });
665
- } catch (P) {
666
- throw Object.assign(new I(0, null), { cause: P });
651
+ } catch (N) {
652
+ throw Object.assign(new I(0, null), { cause: N });
667
653
  }
668
- let _ = null;
654
+ let $ = null;
669
655
  try {
670
- _ = await w.json();
656
+ $ = await w.json();
671
657
  } catch {
672
658
  }
673
659
  if (!w.ok)
674
- throw new I(w.status, _);
675
- return _;
660
+ throw new I(w.status, $);
661
+ return $;
676
662
  }
677
663
  return {
678
664
  /** @returns {Promise<Array>} published form documents */
679
665
  listForms: async () => {
680
- const l = await a("/v1/forms", { timeoutMs: ot });
681
- return n = l?.anonymous?.enabled === !0 ? { enabled: !0, humanCheck: l.anonymous.humanCheck || null } : de, (l?.forms || []).filter((d) => d?.formId && d?.start && Array.isArray(d?.nodes));
666
+ const l = await a("/v1/forms", { timeoutMs: ct });
667
+ return i = l?.anonymous?.enabled === !0 ? { enabled: !0, humanCheck: l.anonymous.humanCheck || null } : de, (l?.forms || []).filter((d) => d?.formId && d?.start && Array.isArray(d?.nodes));
682
668
  },
683
669
  /**
684
670
  * What the server advertised on the last listForms.
685
671
  * @returns {{enabled: boolean, humanCheck: {provider, siteKey}|null}}
686
672
  */
687
- anonymousCapability: () => n,
673
+ anonymousCapability: () => i,
688
674
  /**
689
675
  * Mint a submission-scoped anonymous session; subsequent auth-bearing
690
676
  * calls present it until endAnonSession(). Unauthenticated by design.
691
677
  * @returns {Promise<{expiresIn: number}>}
692
678
  */
693
- createAnonSession: async ({ formId: l, requestId: d, humanToken: p }) => {
679
+ createAnonSession: async ({ formId: l, requestId: d, humanToken: h }) => {
694
680
  const u = await a("/v1/anon/sessions", {
695
681
  method: "POST",
696
- body: { formId: l, requestId: d, ...p ? { humanToken: p } : {} }
682
+ body: { formId: l, requestId: d, ...h ? { humanToken: h } : {} }
697
683
  });
698
684
  if (o = u?.token || null, !o)
699
685
  throw new I(502, { message: "The anonymous session had no token" });
@@ -713,87 +699,179 @@ function at({
713
699
  * progress is observable. Resolves on 2xx; rejects with
714
700
  * ApiError(status) otherwise. Returns { promise, abort }.
715
701
  */
716
- uploadFile: ({ url: l, file: d, contentType: p, onProgress: u = () => {
702
+ uploadFile: ({ url: l, file: d, contentType: h, onProgress: u = () => {
717
703
  } }) => {
718
- const h = t();
719
- return { promise: new Promise((w, _) => {
720
- h.open("PUT", l), h.setRequestHeader("Content-Type", p || d.type), h.upload && (h.upload.onprogress = (P) => {
721
- u({ loaded: P.loaded, total: P.total || d.size });
722
- }), h.onload = () => {
723
- h.status >= 200 && h.status < 300 ? w({ status: h.status }) : _(new I(h.status, null));
724
- }, h.onerror = () => _(new I(0, null)), h.onabort = () => _(new I(0, { aborted: !0 })), h.send(d);
725
- }), abort: () => h.abort() };
704
+ const p = t();
705
+ return { promise: new Promise((w, $) => {
706
+ p.open("PUT", l), p.setRequestHeader("Content-Type", h || d.type), p.upload && (p.upload.onprogress = (N) => {
707
+ u({ loaded: N.loaded, total: N.total || d.size });
708
+ }), p.onload = () => {
709
+ p.status >= 200 && p.status < 300 ? w({ status: p.status }) : $(new I(p.status, null));
710
+ }, p.onerror = () => $(new I(0, null)), p.onabort = () => $(new I(0, { aborted: !0 })), p.send(d);
711
+ }), abort: () => p.abort() };
726
712
  },
727
713
  /** @returns {Promise<{requestId,reference,confirmation,routing}>} */
728
714
  putRequest: async (l, d) => await a(`/v1/requests/${l}`, { method: "PUT", body: d, auth: !0 })
729
715
  };
730
716
  }
731
717
  const ue = 60 * 1e3;
732
- async function lt({ read: s, refresh: e, now: t = Date.now }) {
733
- const r = (n) => {
734
- const { token: o, expiry: a } = s() || {};
735
- return o && Number(a) - n > t() ? o : null;
718
+ async function ut({ read: r, refresh: e, now: t = Date.now }) {
719
+ const s = (i) => {
720
+ const { token: o, expiry: a } = r() || {};
721
+ return o && Number(a) - i > t() ? o : null;
736
722
  };
737
- let i = r(ue);
738
- if (!i) {
723
+ let n = s(ue);
724
+ if (!n) {
739
725
  try {
740
726
  await e();
741
727
  } catch {
742
728
  }
743
- i = r(ue) || r(0);
729
+ n = s(ue) || s(0);
744
730
  }
745
- if (!i)
731
+ if (!n)
746
732
  throw Object.assign(new Error("Please sign in again to continue."), { status: 401, body: null });
747
- return { Authorization: `Bearer ${i}` };
733
+ return { Authorization: `Bearer ${n}` };
748
734
  }
749
- function ct() {
750
- const { config: s, storage: e } = Se();
751
- let t = null;
735
+ const he = (r) => String(r || "").toLowerCase().trim();
736
+ function ht(r) {
737
+ const e = /* @__PURE__ */ new Set();
752
738
  return {
753
- isAuthenticated: () => ze(),
754
- signedInEmail: () => e.get(S.userEmail) || null,
755
- /* The ID token, so api-forms can record the verified email (../lib/id-token.mjs). */
756
- getAuthHeaders: () => lt({
757
- read: () => ({
758
- token: e.get(S.idToken),
759
- expiry: e.get(S.idTokenExpiry)
760
- }),
761
- refresh: () => te()
739
+ signUpIfNeeded: async (t, ...s) => {
740
+ const n = await r(t, ...s);
741
+ return n?.exists === !1 && !n.error && e.add(he(t)), n;
742
+ },
743
+ isNewAccount: (t) => e.has(he(t))
744
+ };
745
+ }
746
+ const pt = "wral_user_facts", ft = "1", gt = 100;
747
+ function mt(r, e) {
748
+ let t = "";
749
+ for (const s of r) {
750
+ if (t.length + s.length > e) break;
751
+ t += s;
752
+ }
753
+ return t;
754
+ }
755
+ const yt = [
756
+ {
757
+ autocomplete: "name",
758
+ factName: "preferred_name",
759
+ label: "Name",
760
+ shape: (r) => {
761
+ const e = String(r ?? "").replace(/\s+/g, " ").trim();
762
+ return e ? mt(e, gt).trim() : null;
763
+ }
764
+ },
765
+ {
766
+ autocomplete: "postal-code",
767
+ factName: "zipcode",
768
+ label: "Zip code",
769
+ shape: (r) => String(r ?? "").trim().match(/^(\d{5})(-\d{4})?$/)?.[1] ?? null
770
+ }
771
+ ];
772
+ function bt(r = [], e = {}) {
773
+ const t = [];
774
+ for (const s of yt) {
775
+ const n = r.find((i) => i?.kind === "text" && i.autocomplete === s.autocomplete && s.shape(e[i.key]) !== null);
776
+ n && t.push({ factName: s.factName, label: s.label, value: s.shape(e[n.key]) });
777
+ }
778
+ return t;
779
+ }
780
+ async function wt(r, {
781
+ baseUrl: e,
782
+ getAuthHeaders: t,
783
+ fetchFn: s = (...i) => fetch(...i),
784
+ onSaved: n = () => {
785
+ }
786
+ }) {
787
+ const i = String(e).replace(/\/+$/, "");
788
+ let o = !1;
789
+ try {
790
+ for (const { factName: a, value: l } of r) {
791
+ const d = { "Content-Type": "application/json", ...await t() };
792
+ let h;
793
+ try {
794
+ h = await s(
795
+ `${i}/user/${encodeURIComponent(a)}/${ft}`,
796
+ { method: "PUT", headers: d, body: JSON.stringify({ value: l }) }
797
+ );
798
+ } catch (u) {
799
+ throw Object.assign(new Error("user-facts request failed"), { status: 0, cause: u });
800
+ }
801
+ if (!h.ok)
802
+ throw Object.assign(
803
+ new Error(`user-facts request failed with status ${h.status}`),
804
+ { status: h.status }
805
+ );
806
+ o = !0;
807
+ }
808
+ } finally {
809
+ o && n();
810
+ }
811
+ }
812
+ function xt({ factsBaseUrl: r } = {}) {
813
+ const { config: e, storage: t } = Re(), s = ht(ze);
814
+ let n = null;
815
+ const i = () => ut({
816
+ read: () => ({
817
+ token: t.get(S.idToken),
818
+ expiry: t.get(S.idTokenExpiry)
762
819
  }),
820
+ refresh: () => te()
821
+ });
822
+ return {
823
+ isAuthenticated: () => Ue(),
824
+ signedInEmail: () => t.get(S.userEmail) || null,
825
+ getAuthHeaders: i,
826
+ /* Save mapped answers (../lib/user-facts.mjs) to the viewer's My WRAL user facts. */
827
+ ...r ? {
828
+ saveUserFacts: (o) => wt(o, {
829
+ baseUrl: r,
830
+ getAuthHeaders: i,
831
+ onSaved: () => {
832
+ try {
833
+ localStorage.removeItem(pt);
834
+ } catch {
835
+ }
836
+ }
837
+ })
838
+ } : {},
763
839
  /**
764
840
  * Email step. Keeps the challenge user in memory for verifyCode.
765
- * @returns {{challengeRequired?: boolean, authenticated?: boolean}}
841
+ * `newAccount` is true when this page load created the account.
842
+ * @returns {{challengeRequired?: boolean, authenticated?: boolean, newAccount: boolean}}
766
843
  */
767
- sendCode: async (r) => {
768
- const i = await Re(
769
- s,
770
- r,
844
+ sendCode: async (o) => {
845
+ const a = await Ne(
771
846
  e,
772
- Me,
847
+ o,
848
+ t,
773
849
  De,
850
+ s.signUpIfNeeded,
774
851
  Pe,
775
- Z,
852
+ J,
776
853
  X,
777
854
  ee
778
855
  );
779
- return t = i.cognitoUser || null, {
780
- challengeRequired: !!i.challengeRequired,
781
- authenticated: !!i.authenticated
856
+ return n = a.cognitoUser || null, {
857
+ challengeRequired: !!a.challengeRequired,
858
+ authenticated: !!a.authenticated,
859
+ newAccount: s.isNewAccount(o)
782
860
  };
783
861
  },
784
862
  /**
785
863
  * Code step; refreshes immediately after verify so the session
786
864
  * starts with a full lifetime (house pattern).
787
865
  */
788
- verifyCode: async (r) => {
789
- if (!t)
866
+ verifyCode: async (o) => {
867
+ if (!n)
790
868
  throw new Error("Please enter your email again to get a new code.");
791
869
  try {
792
- await Te(
870
+ await Me(
871
+ n,
872
+ o,
793
873
  t,
794
- r,
795
- e,
796
- Z,
874
+ J,
797
875
  X,
798
876
  ee
799
877
  );
@@ -804,133 +882,133 @@ function ct() {
804
882
  },
805
883
  /** Local sign-out only ("use a different email"). */
806
884
  signOut: () => {
807
- t = null, Ce().clear();
885
+ n = null, Oe().clear();
808
886
  },
809
887
  /**
810
888
  * Detect a login completed in ANOTHER tab (the storage event
811
889
  * never fires in the tab that wrote). Returns an unsubscribe.
812
890
  */
813
- onCrossTabLogin: (r) => {
814
- const i = (n) => {
815
- (n.key === S.accessToken || n.key === S.idToken) && r();
891
+ onCrossTabLogin: (o) => {
892
+ const a = (l) => {
893
+ (l.key === S.accessToken || l.key === S.idToken) && o();
816
894
  };
817
- return window.addEventListener("storage", i), () => window.removeEventListener("storage", i);
895
+ return window.addEventListener("storage", a), () => window.removeEventListener("storage", a);
818
896
  }
819
897
  };
820
898
  }
821
- function dt({ baseUrl: s }) {
822
- const e = ct();
823
- return { ...at({ baseUrl: s, getAuthHeaders: e.getAuthHeaders }), ...e };
899
+ function vt({ baseUrl: r, factsBaseUrl: e }) {
900
+ const t = xt({ factsBaseUrl: e });
901
+ return { ...dt({ baseUrl: r, getAuthHeaders: t.getAuthHeaders }), ...t };
824
902
  }
825
- function x(s, e) {
826
- return (s?.nodes || []).find((t) => t.id === e);
903
+ function x(r, e) {
904
+ return (r?.nodes || []).find((t) => t.id === e);
827
905
  }
828
- function N(s) {
829
- return s?.form ? { formId: s.form, path: [...s.path || []] } : null;
906
+ function L(r) {
907
+ return r?.form ? { formId: r.form, path: [...r.path || []] } : null;
830
908
  }
831
- function q(s, e = []) {
909
+ function H(r, e = []) {
832
910
  const t = [];
833
- let r = s?.start;
834
- for (const n of e) {
835
- const o = x(s, r);
911
+ let s = r?.start;
912
+ for (const i of e) {
913
+ const o = x(r, s);
836
914
  if (!o)
837
- return { nodeId: null, node: null, flags: t, error: { step: n, reason: `unknown node: ${r}` } };
915
+ return { nodeId: null, node: null, flags: t, error: { step: i, reason: `unknown node: ${s}` } };
838
916
  if (o.type === "terminal" || o.type === "redirect")
839
- return { nodeId: null, node: null, flags: t, error: { step: n, reason: `steps continue past ${o.type}` } };
840
- if (n.nodeId !== r || n.kind !== o.type)
841
- return { nodeId: null, node: null, flags: t, error: { step: n, reason: `step does not match node ${r}` } };
917
+ return { nodeId: null, node: null, flags: t, error: { step: i, reason: `steps continue past ${o.type}` } };
918
+ if (i.nodeId !== s || i.kind !== o.type)
919
+ return { nodeId: null, node: null, flags: t, error: { step: i, reason: `step does not match node ${s}` } };
842
920
  if (o.type === "choice") {
843
- const a = (o.options || []).find((l) => l.id === n.optionId);
921
+ const a = (o.options || []).find((l) => l.id === i.optionId);
844
922
  if (!a)
845
- return { nodeId: null, node: null, flags: t, error: { step: n, reason: `unknown option: ${n.optionId}` } };
846
- if (N(a))
847
- return { nodeId: null, node: null, flags: t, error: { step: n, reason: `steps continue past a hand-off: ${n.optionId}` } };
848
- t.push(...a.flags || []), r = a.next;
923
+ return { nodeId: null, node: null, flags: t, error: { step: i, reason: `unknown option: ${i.optionId}` } };
924
+ if (L(a))
925
+ return { nodeId: null, node: null, flags: t, error: { step: i, reason: `steps continue past a hand-off: ${i.optionId}` } };
926
+ t.push(...a.flags || []), s = a.next;
849
927
  continue;
850
928
  }
851
- r = o.next;
929
+ s = o.next;
852
930
  }
853
- const i = x(s, r);
854
- return i ? { nodeId: r, node: i, flags: Ae(t), error: null } : { nodeId: null, node: null, flags: t, error: { step: null, reason: `unknown node: ${r}` } };
931
+ const n = x(r, s);
932
+ return n ? { nodeId: s, node: n, flags: Ee(t), error: null } : { nodeId: null, node: null, flags: t, error: { step: null, reason: `unknown node: ${s}` } };
855
933
  }
856
- function ut(s, e = []) {
934
+ function Ae(r, e = []) {
857
935
  const t = [];
858
- for (const r of e) {
859
- if (r.kind !== "collect") continue;
860
- const i = x(s, r.nodeId);
861
- t.push(...i?.fields || []);
936
+ for (const s of e) {
937
+ if (s.kind !== "collect") continue;
938
+ const n = x(r, s.nodeId);
939
+ t.push(...n?.fields || []);
862
940
  }
863
941
  return t;
864
942
  }
865
- function pt(s = []) {
943
+ function Fe(r = []) {
866
944
  const e = {};
867
- for (const t of s)
945
+ for (const t of r)
868
946
  t.kind === "collect" && Object.assign(e, t.values || {});
869
947
  return e;
870
948
  }
871
- function ht(s = []) {
872
- return s.filter((e) => e.kind === "choice").map((e) => `${e.nodeId}:${e.optionId}`);
949
+ function _t(r = []) {
950
+ return r.filter((e) => e.kind === "choice").map((e) => `${e.nodeId}:${e.optionId}`);
873
951
  }
874
- function ke(s, e = []) {
952
+ function Ie(r, e = []) {
875
953
  const t = [];
876
- for (const r of e) {
877
- if (r.kind !== "choice") continue;
878
- const n = (x(s, r.nodeId)?.options || []).find((o) => o.id === r.optionId);
879
- t.push(...n?.flags || []);
954
+ for (const s of e) {
955
+ if (s.kind !== "choice") continue;
956
+ const i = (x(r, s.nodeId)?.options || []).find((o) => o.id === s.optionId);
957
+ t.push(...i?.flags || []);
880
958
  }
881
- return Ae(t);
959
+ return Ee(t);
882
960
  }
883
- function ft(s = []) {
884
- return s.includes("urgent") ? "urgent" : s.includes("moderate") ? "moderate" : null;
961
+ function $t(r = []) {
962
+ return r.includes("urgent") ? "urgent" : r.includes("moderate") ? "moderate" : null;
885
963
  }
886
- function Ae(s) {
887
- return [...new Set(s)];
964
+ function Ee(r) {
965
+ return [...new Set(r)];
888
966
  }
889
- function mt(s, e = []) {
967
+ function kt(r, e = []) {
890
968
  const t = [];
891
- for (const i of e) {
892
- const [n, o] = String(i).split(":"), a = x(s, n), l = a?.type === "choice" ? (a.options || []).find((d) => d.id === o) : null;
969
+ for (const n of e) {
970
+ const [i, o] = String(n).split(":"), a = x(r, i), l = a?.type === "choice" ? (a.options || []).find((d) => d.id === o) : null;
893
971
  if (!l)
894
- return { steps: [], error: `unknown preset step: ${i}` };
895
- t.push({ nodeId: n, kind: "choice", optionId: o, label: l.label, preset: !0 });
972
+ return { steps: [], error: `unknown preset step: ${n}` };
973
+ t.push({ nodeId: i, kind: "choice", optionId: o, label: l.label, preset: !0 });
896
974
  }
897
- const { error: r } = q(s, t);
898
- return r ? { steps: [], error: r.reason } : { steps: t, error: null };
975
+ const { error: s } = H(r, t);
976
+ return s ? { steps: [], error: s.reason } : { steps: t, error: null };
899
977
  }
900
- function gt(s, e) {
901
- const t = N(e);
978
+ function At(r, e) {
979
+ const t = L(e);
902
980
  if (!t) return { form: null, steps: [], error: "not a hand-off" };
903
- const r = (s || []).find((o) => o.formId === t.formId);
904
- if (!r) return { form: null, steps: [], error: `unknown form: ${t.formId}` };
905
- const { steps: i, error: n } = mt(r, t.path);
906
- return n ? { form: null, steps: [], error: n } : { form: r, steps: i, error: null };
981
+ const s = (r || []).find((o) => o.formId === t.formId);
982
+ if (!s) return { form: null, steps: [], error: `unknown form: ${t.formId}` };
983
+ const { steps: n, error: i } = kt(s, t.path);
984
+ return i ? { form: null, steps: [], error: i } : { form: s, steps: n, error: null };
907
985
  }
908
- function bt(s, e, t, r) {
986
+ function Ft(r, e, t, s) {
909
987
  return {
910
- form: s,
988
+ form: r,
911
989
  steps: e,
912
- option: { nodeId: t.id, optionId: r.id, label: r.label }
990
+ option: { nodeId: t.id, optionId: s.id, label: s.label }
913
991
  };
914
992
  }
915
- function yt(s = []) {
916
- return s.every((e) => e.preset === !0);
993
+ function It(r = []) {
994
+ return r.every((e) => e.preset === !0);
917
995
  }
918
- function wt(s, e, t) {
919
- if (!Array.isArray(s) || !s.length) return [];
920
- const r = [];
921
- for (let i = 0; i < s.length; i++) {
922
- const n = s[i], o = (e || []).find((u) => u.formId === n?.formId);
996
+ function Et(r, e, t) {
997
+ if (!Array.isArray(r) || !r.length) return [];
998
+ const s = [];
999
+ for (let n = 0; n < r.length; n++) {
1000
+ const i = r[n], o = (e || []).find((u) => u.formId === i?.formId);
923
1001
  if (!o) return [];
924
- const { node: a, error: l } = q(o, n.steps || []);
925
- if (l || a?.id !== n.option?.nodeId) return [];
926
- const d = (a.options || []).find((u) => u.id === n.option.optionId), p = i + 1 < s.length ? s[i + 1].formId : t;
927
- if (N(d)?.formId !== p) return [];
928
- r.push({ form: o, steps: n.steps || [], option: n.option });
1002
+ const { node: a, error: l } = H(o, i.steps || []);
1003
+ if (l || a?.id !== i.option?.nodeId) return [];
1004
+ const d = (a.options || []).find((u) => u.id === i.option.optionId), h = n + 1 < r.length ? r[n + 1].formId : t;
1005
+ if (L(d)?.formId !== h) return [];
1006
+ s.push({ form: o, steps: i.steps || [], option: i.option });
929
1007
  }
930
- return r;
1008
+ return s;
931
1009
  }
932
- function xt({ attr: s = null, search: e = "" } = {}) {
933
- const t = String(s ?? "").trim();
1010
+ function St({ attr: r = null, search: e = "" } = {}) {
1011
+ const t = String(r ?? "").trim();
934
1012
  if (t) return t;
935
1013
  try {
936
1014
  return new URLSearchParams(e || "").get("flow")?.trim() || null;
@@ -938,41 +1016,41 @@ function xt({ attr: s = null, search: e = "" } = {}) {
938
1016
  return null;
939
1017
  }
940
1018
  }
941
- function vt(s, e) {
942
- return e && (s || []).find((t) => t.formId === e) || null;
1019
+ function Ct(r, e) {
1020
+ return e && (r || []).find((t) => t.formId === e) || null;
943
1021
  }
944
- function _t(s, e) {
945
- return !e || s?.form?.formId === e ? !0 : (s?.origins || []).some((t) => t.form?.formId === e);
1022
+ function Tt(r, e) {
1023
+ return !e || r?.form?.formId === e ? !0 : (r?.origins || []).some((t) => t.form?.formId === e);
946
1024
  }
947
- const $t = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/, pe = {
1025
+ const Rt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/, pe = {
948
1026
  text: 500,
949
1027
  textarea: 5e3,
950
1028
  url: 2048
951
- }, kt = "Please confirm the rights statement so we can use what you send.";
952
- function Fe(s, { mediaCount: e = 0 } = {}) {
953
- return s.kind === "consent" && s.requiredIf === "media" ? e > 0 : !!s.required;
1029
+ }, Ot = "Please confirm the rights statement so we can use what you send.";
1030
+ function Se(r, { mediaCount: e = 0 } = {}) {
1031
+ return r.kind === "consent" && r.requiredIf === "media" ? e > 0 : !!r.required;
954
1032
  }
955
- function At(s, e) {
1033
+ function Mt(r, e) {
956
1034
  try {
957
- return new RegExp(s, "u").test(e);
1035
+ return new RegExp(r, "u").test(e);
958
1036
  } catch {
959
1037
  return !0;
960
1038
  }
961
1039
  }
962
- function Ft(s) {
963
- return s.key === "zip" ? "Please enter a five-digit zip code." : `Please check the format of ${s.label.toLowerCase()}.`;
1040
+ function Nt(r) {
1041
+ return r.key === "zip" ? "Please enter a five-digit zip code." : `Please check the format of ${r.label.toLowerCase()}.`;
964
1042
  }
965
- function It(s, e, { mediaCount: t = 0 } = {}) {
966
- const r = Fe(s, { mediaCount: t });
967
- if (s.kind === "consent")
968
- return e === !0 || !r ? null : kt;
969
- if (e == null || e === "" || s.kind === "location" && Et(e))
970
- return r ? `Please fill in: ${s.label.toLowerCase()}.` : null;
971
- switch (s.kind) {
1043
+ function Dt(r, e, { mediaCount: t = 0 } = {}) {
1044
+ const s = Se(r, { mediaCount: t });
1045
+ if (r.kind === "consent")
1046
+ return e === !0 || !s ? null : Ot;
1047
+ if (e == null || e === "" || r.kind === "location" && Pt(e))
1048
+ return s ? `Please fill in: ${r.label.toLowerCase()}.` : null;
1049
+ switch (r.kind) {
972
1050
  case "text":
973
1051
  case "textarea": {
974
- const n = s.maxLength || pe[s.kind];
975
- return typeof e != "string" ? `Please enter text for ${s.label.toLowerCase()}.` : e.length > n ? `Please keep ${s.label.toLowerCase()} under ${n} characters.` : s.kind === "text" && s.pattern && !At(s.pattern, e) ? Ft(s) : null;
1052
+ const i = r.maxLength || pe[r.kind];
1053
+ return typeof e != "string" ? `Please enter text for ${r.label.toLowerCase()}.` : e.length > i ? `Please keep ${r.label.toLowerCase()} under ${i} characters.` : r.kind === "text" && r.pattern && !Mt(r.pattern, e) ? Nt(r) : null;
976
1054
  }
977
1055
  case "url": {
978
1056
  if (typeof e != "string" || e.length > pe.url)
@@ -984,108 +1062,108 @@ function It(s, e, { mediaCount: t = 0 } = {}) {
984
1062
  }
985
1063
  }
986
1064
  case "datetime":
987
- return $t.test(String(e)) ? null : "Please pick a date and time.";
1065
+ return Rt.test(String(e)) ? null : "Please pick a date and time.";
988
1066
  case "select":
989
- return (s.options || []).map((o) => o.id).includes(e) ? null : `Please choose one of the options for ${s.label.toLowerCase()}.`;
1067
+ return (r.options || []).map((o) => o.id).includes(e) ? null : `Please choose one of the options for ${r.label.toLowerCase()}.`;
990
1068
  case "location":
991
- return St(s, e);
1069
+ return Ut(r, e);
992
1070
  case "media":
993
1071
  return null;
994
1072
  default:
995
- return `Unsupported field: ${s.kind}`;
1073
+ return `Unsupported field: ${r.kind}`;
996
1074
  }
997
1075
  }
998
- function Et(s) {
999
- return s == null ? !0 : typeof s != "object" ? !1 : !s.county && !s.where && !(Array.isArray(s.gps) && s.gps.length);
1076
+ function Pt(r) {
1077
+ return r == null ? !0 : typeof r != "object" ? !1 : !r.county && !r.where && !(Array.isArray(r.gps) && r.gps.length);
1000
1078
  }
1001
- function St(s, e) {
1002
- return typeof e != "object" || Array.isArray(e) ? "Please tell us where this was." : e.county !== void 0 && (typeof e.county != "string" || e.county.length > 100) ? "Please choose a county." : e.where !== void 0 && (typeof e.where != "string" || e.where.length > 500) ? "Please shorten the location description." : e.gps !== void 0 && !(Array.isArray(e.gps) && e.gps.length === 2 && e.gps.every((r) => typeof r == "number" && Number.isFinite(r))) ? "Location coordinates look wrong; try re-sharing your location." : s.required && !e.county && !e.where ? `Please fill in: ${s.label.toLowerCase()}.` : null;
1079
+ function Ut(r, e) {
1080
+ return typeof e != "object" || Array.isArray(e) ? "Please tell us where this was." : e.county !== void 0 && (typeof e.county != "string" || e.county.length > 100) ? "Please choose a county." : e.where !== void 0 && (typeof e.where != "string" || e.where.length > 500) ? "Please shorten the location description." : e.gps !== void 0 && !(Array.isArray(e.gps) && e.gps.length === 2 && e.gps.every((s) => typeof s == "number" && Number.isFinite(s))) ? "Location coordinates look wrong; try re-sharing your location." : r.required && !e.county && !e.where ? `Please fill in: ${r.label.toLowerCase()}.` : null;
1003
1081
  }
1004
- function he(s, e = {}, { mediaCount: t = 0 } = {}) {
1005
- const r = {};
1006
- for (const i of s) {
1007
- if (i.kind === "media") continue;
1008
- const n = It(i, e[i.key], { mediaCount: t });
1009
- n && (r[i.key] = n);
1082
+ function fe(r, e = {}, { mediaCount: t = 0 } = {}) {
1083
+ const s = {};
1084
+ for (const n of r) {
1085
+ if (n.kind === "media") continue;
1086
+ const i = Dt(n, e[n.key], { mediaCount: t });
1087
+ i && (s[n.key] = i);
1010
1088
  }
1011
- return { ok: Object.keys(r).length === 0, errors: r };
1089
+ return { ok: Object.keys(s).length === 0, errors: s };
1012
1090
  }
1013
- function Y(s = [], e = {}, { required: t = !1 } = {}) {
1091
+ function Y(r = [], e = {}, { required: t = !1 } = {}) {
1014
1092
  const {
1015
- maxFiles: r = 5,
1016
- maxFileBytes: i = 512 * 1024 * 1024,
1017
- allowedTypes: n = []
1093
+ maxFiles: s = 5,
1094
+ maxFileBytes: n = 512 * 1024 * 1024,
1095
+ allowedTypes: i = []
1018
1096
  } = e, o = [];
1019
- return t && s.length === 0 && o.push({ reason: "required", message: "Please attach at least one photo or video." }), s.length > r && o.push({
1097
+ return t && r.length === 0 && o.push({ reason: "required", message: "Please attach at least one photo or video." }), r.length > s && o.push({
1020
1098
  reason: "count",
1021
- message: `This form accepts at most ${r} ${r === 1 ? "file" : "files"}.`
1022
- }), s.forEach((a, l) => {
1023
- n.length && !n.includes(a.type) && o.push({
1099
+ message: `This form accepts at most ${s} ${s === 1 ? "file" : "files"}.`
1100
+ }), r.forEach((a, l) => {
1101
+ i.length && !i.includes(a.type) && o.push({
1024
1102
  index: l,
1025
1103
  reason: "type",
1026
1104
  message: `${a.name || "A file"} is a type this form does not accept.`
1027
- }), a.size > i && o.push({
1105
+ }), a.size > n && o.push({
1028
1106
  index: l,
1029
1107
  reason: "size",
1030
1108
  message: `${a.name || "A file"} is larger than this form allows.`
1031
1109
  });
1032
1110
  }), { ok: o.length === 0, errors: o };
1033
1111
  }
1034
- function fe({ formId: s, requestId: e, files: t }) {
1112
+ function ge({ formId: r, requestId: e, files: t }) {
1035
1113
  return {
1036
- formId: s,
1114
+ formId: r,
1037
1115
  requestId: e,
1038
- files: t.map((r) => ({ contentType: r.type, size: r.size }))
1116
+ files: t.map((s) => ({ contentType: s.type, size: s.size }))
1039
1117
  };
1040
1118
  }
1041
- function Ct({ form: s, steps: e, media: t = [] }) {
1042
- const r = ut(s, e), i = pt(e), n = {};
1043
- for (const o of r) {
1119
+ function zt({ form: r, steps: e, media: t = [] }) {
1120
+ const s = Ae(r, e), n = Fe(e), i = {};
1121
+ for (const o of s) {
1044
1122
  if (o.kind === "media") continue;
1045
- const a = i[o.key];
1123
+ const a = n[o.key];
1046
1124
  if (!(a == null || a === "") && !(o.kind === "consent" && (a !== !0 || o.requiredIf === "media" && !t.length))) {
1047
1125
  if (o.kind === "location") {
1048
1126
  const l = {};
1049
- a.county && (l.county = a.county), a.where && (l.where = a.where), Array.isArray(a.gps) && a.gps.length === 2 && (l.gps = a.gps), Object.keys(l).length && (n[o.key] = l);
1127
+ a.county && (l.county = a.county), a.where && (l.where = a.where), Array.isArray(a.gps) && a.gps.length === 2 && (l.gps = a.gps), Object.keys(l).length && (i[o.key] = l);
1050
1128
  continue;
1051
1129
  }
1052
- n[o.key] = a;
1130
+ i[o.key] = a;
1053
1131
  }
1054
1132
  }
1055
1133
  return {
1056
- formId: s.formId,
1057
- flowVersion: s.flowVersion,
1058
- path: ht(e),
1059
- answers: n,
1134
+ formId: r.formId,
1135
+ flowVersion: r.flowVersion,
1136
+ path: _t(e),
1137
+ answers: i,
1060
1138
  media: t.map(({ assetId: o, type: a }) => ({ assetId: o, type: a }))
1061
1139
  };
1062
1140
  }
1063
- function me(s, e) {
1064
- if (s === 429)
1141
+ function me(r, e) {
1142
+ if (r === 429)
1065
1143
  return {
1066
1144
  kind: "throttled",
1067
1145
  message: e?.message || "You have reached the submission limit; please try again later.",
1068
1146
  limit: e?.limit,
1069
1147
  retryAfter: e?.retryAfter
1070
1148
  };
1071
- if (s === 401)
1149
+ if (r === 401)
1072
1150
  return { kind: "auth", message: "Please sign in again to continue." };
1073
- if (s === 403)
1151
+ if (r === 403)
1074
1152
  return { kind: "forbidden", message: e?.message || "This submission belongs to another account." };
1075
- if (s === 404)
1153
+ if (r === 404)
1076
1154
  return { kind: "unknown-form", message: "This form is no longer available." };
1077
- if (s === 409)
1155
+ if (r === 409)
1078
1156
  return {
1079
1157
  kind: "stale",
1080
1158
  message: e?.message || "The form changed while you were filling it out; please review and resubmit."
1081
1159
  };
1082
- if (s === 400 && e?.code === "media-not-verified")
1160
+ if (r === 400 && e?.code === "media-not-verified")
1083
1161
  return {
1084
1162
  kind: "media",
1085
1163
  message: e.message || "An attached file is missing or does not match this submission.",
1086
1164
  assetId: e.assetId
1087
1165
  };
1088
- if (s === 400 && Array.isArray(e)) {
1166
+ if (r === 400 && Array.isArray(e)) {
1089
1167
  const t = e[0] || {};
1090
1168
  return {
1091
1169
  kind: "validation",
@@ -1093,153 +1171,123 @@ function me(s, e) {
1093
1171
  fieldKey: String(t.instancePath || "").split("/").filter(Boolean)[0] || null
1094
1172
  };
1095
1173
  }
1096
- return s === 0 ? { kind: "network", message: "We could not reach WRAL; check your connection and try again." } : {
1174
+ return r === 0 ? { kind: "network", message: "We could not reach WRAL; check your connection and try again." } : {
1097
1175
  kind: "server",
1098
1176
  message: "Something went wrong on our end; please try again."
1099
1177
  };
1100
1178
  }
1101
- const Tt = 34, Rt = 44;
1102
- function ge(s, e) {
1103
- const t = String(s);
1179
+ const Bt = 34, Lt = 44;
1180
+ function ye(r, e) {
1181
+ const t = String(r);
1104
1182
  return t.length > e ? `${t.slice(0, e)}…` : t;
1105
1183
  }
1106
- function Mt(s, e) {
1107
- const t = (s.options || []).find((r) => r.id === e);
1184
+ function Ht(r, e) {
1185
+ const t = (r.options || []).find((s) => s.id === e);
1108
1186
  return t ? t.label : e;
1109
1187
  }
1110
- function Dt(s) {
1111
- return !s || typeof s != "object" ? "" : [s.county, s.where].filter(Boolean).join(", ");
1188
+ function qt(r) {
1189
+ return !r || typeof r != "object" ? "" : [r.county, r.where].filter(Boolean).join(", ");
1112
1190
  }
1113
- function Pt(s, e = {}, t = []) {
1114
- const r = [];
1115
- for (const i of s) {
1116
- if (i.kind === "consent") continue;
1117
- if (i.kind === "media") {
1118
- t.length && r.push(`${t.length} ${t.length === 1 ? "file" : "files"}`);
1191
+ function Wt(r, e = {}, t = []) {
1192
+ const s = [];
1193
+ for (const n of r) {
1194
+ if (n.kind === "consent") continue;
1195
+ if (n.kind === "media") {
1196
+ t.length && s.push(`${t.length} ${t.length === 1 ? "file" : "files"}`);
1119
1197
  continue;
1120
1198
  }
1121
- const n = i.kind === "location" ? Dt(e[i.key]) : i.kind === "select" ? Mt(i, e[i.key]) : e[i.key];
1122
- n == null || n === "" || (i.kind === "textarea" ? r.push(`"${ge(n, Rt)}"`) : r.push(ge(n, Tt)));
1199
+ const i = n.kind === "location" ? qt(e[n.key]) : n.kind === "select" ? Ht(n, e[n.key]) : e[n.key];
1200
+ i == null || i === "" || (n.kind === "textarea" ? s.push(`"${ye(i, Lt)}"`) : s.push(ye(i, Bt)));
1123
1201
  }
1124
- return r.join(" · ") || "Details provided";
1202
+ return s.join(" · ") || "Details provided";
1125
1203
  }
1126
- function zt(s, e = [], t = null) {
1127
- const r = [];
1128
- for (const n of e) {
1129
- const o = x(s, n.nodeId);
1130
- n.kind === "choice" && o && r.push({ k: (o.prompt || "").replace(/\?$/, ""), v: n.label || n.optionId }), n.kind === "collect" && r.push({ k: "Details", v: n.summary || "Details provided" }), n.kind === "gate" && (n.anonymous ? r.push({ k: "Contact", v: "Anonymous — we will have no way to reach you" }) : (n.email || t) && r.push({ k: "Verified email", v: n.email || t }));
1204
+ function Vt(r, e = [], t = null) {
1205
+ const s = [];
1206
+ for (const i of e) {
1207
+ const o = x(r, i.nodeId);
1208
+ i.kind === "choice" && o && s.push({ k: (o.prompt || "").replace(/\?$/, ""), v: i.label || i.optionId }), i.kind === "collect" && s.push({ k: "Details", v: i.summary || "Details provided" }), i.kind === "gate" && (i.anonymous ? s.push({ k: "Contact", v: "Anonymous — we will have no way to reach you" }) : (i.email || t) && s.push({ k: "Verified email", v: i.email || t }));
1131
1209
  }
1132
- const i = ft(ke(s, e));
1133
- return i && r.push({ k: "Priority", v: i === "urgent" ? "Urgent" : "Moderate", pill: i }), r;
1210
+ const n = $t(Ie(r, e));
1211
+ return n && s.push({ k: "Priority", v: n === "urgent" ? "Urgent" : "Moderate", pill: n }), s;
1134
1212
  }
1135
- function Bt(s, e = []) {
1136
- const t = s?.confirmation || {};
1213
+ function jt(r, e = []) {
1214
+ const t = r?.confirmation || {};
1137
1215
  return {
1138
1216
  title: t.title || "Report received.",
1139
1217
  body: t.body || "Your report is in the review queue.",
1140
1218
  urgentNote: e.includes("urgent") ? t.urgentNote : void 0
1141
1219
  };
1142
1220
  }
1143
- function Ot(s, e) {
1144
- const t = e === "failed" ? " The notification is queued for a delivery retry." : "";
1145
- return s?.startsWith("studio+email:") ? `Sent to the Studio review queue; the desk is emailed.${t}` : s?.startsWith("studio:") ? "Sent to the Studio review queue." : s?.startsWith("jsm:") ? `A ticket is opened for tech support with your details as fields, not prose.${t}` : s?.startsWith("email:") ? `Emailed to the owning desk with a link to your report.${t}` : "Routed to the right team.";
1146
- }
1147
- function Ut({ routing: s = {}, flags: e = [], reference: t = "", anonymous: r = !1 }) {
1148
- const i = e.includes("urgent");
1149
- return [
1150
- {
1151
- title: "Received",
1152
- body: `Report ${t} and its media are written to the dedicated Report It intake store before anything downstream touches them.`
1153
- },
1154
- {
1155
- title: "Routed",
1156
- body: Ot(s.destination, s.state),
1157
- pill: i ? "Urgent · pinned first" : void 0
1158
- },
1159
- {
1160
- title: "Reviewed",
1161
- body: r ? "An editor reviews it in the Report It queue: accept and promote it uncredited, reject, or re-route." : "An editor reviews it in the Report It queue: accept and promote with your credit, reject, or re-route."
1162
- },
1163
- {
1164
- title: "Monitored",
1165
- body: "The record joins the monitoring stream, which watches for related reports by category, place and symptom."
1166
- },
1167
- {
1168
- title: "Escalation check",
1169
- body: "Related reports crossing a threshold alert the owning team automatically; below it, we keep monitoring."
1170
- }
1171
- ];
1172
- }
1173
- const J = "wral-report-it:draft:v1", Ie = 1;
1174
- function Lt(s, e) {
1221
+ const Z = "wral-report-it:draft:v1", Ce = 1;
1222
+ function Yt(r, e) {
1175
1223
  try {
1176
- s.setItem(J, JSON.stringify({ ...e, v: Ie, savedAt: Date.now() }));
1224
+ r.setItem(Z, JSON.stringify({ ...e, v: Ce, savedAt: Date.now() }));
1177
1225
  } catch {
1178
1226
  }
1179
1227
  }
1180
- function Nt(s) {
1228
+ function Gt(r) {
1181
1229
  try {
1182
- const e = s.getItem(J);
1230
+ const e = r.getItem(Z);
1183
1231
  if (!e) return null;
1184
1232
  const t = JSON.parse(e);
1185
- return t?.v !== Ie ? null : t;
1233
+ return t?.v !== Ce ? null : t;
1186
1234
  } catch {
1187
1235
  return null;
1188
1236
  }
1189
1237
  }
1190
- function be(s) {
1238
+ function be(r) {
1191
1239
  try {
1192
- s.removeItem(J);
1240
+ r.removeItem(Z);
1193
1241
  } catch {
1194
1242
  }
1195
1243
  }
1196
- function qt({
1197
- apiOrigin: s,
1244
+ function Kt({
1245
+ apiOrigin: r,
1198
1246
  form: e,
1199
1247
  steps: t,
1200
- requestId: r = null,
1201
- mediaMeta: i = {},
1202
- origins: n = []
1248
+ requestId: s = null,
1249
+ mediaMeta: n = {},
1250
+ origins: i = []
1203
1251
  }) {
1204
1252
  return {
1205
- apiOrigin: s,
1253
+ apiOrigin: r,
1206
1254
  formId: e.formId,
1207
1255
  flowVersion: e.flowVersion,
1208
- requestId: r,
1256
+ requestId: s,
1209
1257
  steps: t,
1210
- media: i,
1211
- origins: n.map(({ form: o, steps: a, option: l }) => ({
1258
+ media: n,
1259
+ origins: i.map(({ form: o, steps: a, option: l }) => ({
1212
1260
  formId: o.formId,
1213
1261
  steps: a,
1214
1262
  option: l
1215
1263
  }))
1216
1264
  };
1217
1265
  }
1218
- function Ht(s, e, { apiOrigin: t } = {}) {
1219
- if (!s) return { status: "discarded" };
1220
- if (t && s.apiOrigin && s.apiOrigin !== t)
1221
- return { status: "discarded" };
1222
- const r = (e || []).find((o) => o.formId === s.formId);
1266
+ function Qt(r, e, { apiOrigin: t } = {}) {
1223
1267
  if (!r) return { status: "discarded" };
1224
- const { error: i } = q(r, s.steps || []);
1225
- if (i) return { status: "discarded" };
1226
- const n = {};
1227
- for (const [o, a] of Object.entries(s.media || {}))
1228
- a?.length && (n[o] = a.map((l) => ({ ...l, lost: !0 })));
1268
+ if (t && r.apiOrigin && r.apiOrigin !== t)
1269
+ return { status: "discarded" };
1270
+ const s = (e || []).find((o) => o.formId === r.formId);
1271
+ if (!s) return { status: "discarded" };
1272
+ const { error: n } = H(s, r.steps || []);
1273
+ if (n) return { status: "discarded" };
1274
+ const i = {};
1275
+ for (const [o, a] of Object.entries(r.media || {}))
1276
+ a?.length && (i[o] = a.map((l) => ({ ...l, lost: !0 })));
1229
1277
  return {
1230
- status: s.flowVersion === r.flowVersion ? "ok" : "review-required",
1231
- form: r,
1232
- steps: s.steps || [],
1233
- requestId: s.requestId || null,
1234
- lostMedia: n,
1235
- origins: wt(s.origins, e, r.formId)
1278
+ status: r.flowVersion === s.flowVersion ? "ok" : "review-required",
1279
+ form: s,
1280
+ steps: r.steps || [],
1281
+ requestId: r.requestId || null,
1282
+ lostMedia: i,
1283
+ origins: Et(r.origins, e, s.formId)
1236
1284
  };
1237
1285
  }
1238
- function z(s = []) {
1286
+ function D(r = []) {
1239
1287
  return {
1240
1288
  stage: "idle",
1241
1289
  resumeStage: null,
1242
- files: s.map((e) => ({
1290
+ files: r.map((e) => ({
1243
1291
  name: e.name,
1244
1292
  type: e.type,
1245
1293
  size: e.size,
@@ -1255,82 +1303,82 @@ function z(s = []) {
1255
1303
  error: null
1256
1304
  };
1257
1305
  }
1258
- function jt(s, e) {
1306
+ function Zt(r, e) {
1259
1307
  switch (e.type) {
1260
1308
  case "START":
1261
- return { ...s, stage: s.files.length ? "minting" : "requesting", error: null };
1309
+ return { ...r, stage: r.files.length ? "minting" : "requesting", error: null };
1262
1310
  case "AUTH_REQUIRED":
1263
- return { ...s, resumeStage: s.stage === "auth" ? s.resumeStage : s.stage, stage: "auth" };
1311
+ return { ...r, resumeStage: r.stage === "auth" ? r.resumeStage : r.stage, stage: "auth" };
1264
1312
  case "AUTH_OK":
1265
- return { ...s, stage: s.resumeStage || "idle", resumeStage: null };
1313
+ return { ...r, stage: r.resumeStage || "idle", resumeStage: null };
1266
1314
  case "MINTED": {
1267
- const t = s.files.map((r, i) => ({
1268
- ...r,
1269
- assetId: e.uploads[i]?.assetId ?? r.assetId,
1270
- url: e.uploads[i]?.url ?? r.url,
1271
- assetUrl: e.uploads[i]?.assetUrl ?? r.assetUrl,
1315
+ const t = r.files.map((s, n) => ({
1316
+ ...s,
1317
+ assetId: e.uploads[n]?.assetId ?? s.assetId,
1318
+ url: e.uploads[n]?.url ?? s.url,
1319
+ assetUrl: e.uploads[n]?.assetUrl ?? s.assetUrl,
1272
1320
  status: "uploading",
1273
1321
  progress: 0,
1274
1322
  error: null
1275
1323
  }));
1276
- return { ...s, stage: "uploading", files: t };
1324
+ return { ...r, stage: "uploading", files: t };
1277
1325
  }
1278
1326
  case "FILE_PROGRESS":
1279
- return T(s, e.i, (t) => ({
1327
+ return T(r, e.i, (t) => ({
1280
1328
  ...t,
1281
1329
  progress: e.total ? e.loaded / e.total : 0
1282
1330
  }));
1283
1331
  case "FILE_DONE": {
1284
- const t = T(s, e.i, (r) => ({ ...r, status: "done", progress: 1 }));
1285
- return Wt(t);
1332
+ const t = T(r, e.i, (s) => ({ ...s, status: "done", progress: 1 }));
1333
+ return Jt(t);
1286
1334
  }
1287
1335
  case "FILE_FAIL":
1288
- return { ...T(s, e.i, (r) => ({
1289
- ...r,
1336
+ return { ...T(r, e.i, (s) => ({
1337
+ ...s,
1290
1338
  status: "failed",
1291
1339
  error: e.error || "upload failed"
1292
1340
  })), stage: "uploading-error" };
1293
1341
  case "RETRY_FILE":
1294
- return { ...T(s, e.i, (r) => ({
1295
- ...r,
1342
+ return { ...T(r, e.i, (s) => ({
1343
+ ...s,
1296
1344
  status: "uploading",
1297
1345
  progress: 0,
1298
1346
  error: null
1299
1347
  })), stage: "uploading" };
1300
1348
  case "REMINT_FILE":
1301
- return { ...T(s, e.i, (r) => ({
1302
- ...r,
1349
+ return { ...T(r, e.i, (s) => ({
1350
+ ...s,
1303
1351
  assetId: e.upload.assetId,
1304
1352
  url: e.upload.url,
1305
- assetUrl: e.upload.assetUrl ?? r.assetUrl,
1353
+ assetUrl: e.upload.assetUrl ?? s.assetUrl,
1306
1354
  status: "uploading",
1307
1355
  progress: 0,
1308
1356
  error: null
1309
1357
  })), stage: "uploading" };
1310
1358
  case "REQUEST_START":
1311
- return { ...s, stage: "requesting", error: null };
1359
+ return { ...r, stage: "requesting", error: null };
1312
1360
  case "REQUEST_OK":
1313
- return { ...s, stage: "done", result: e.result, error: null };
1361
+ return { ...r, stage: "done", result: e.result, error: null };
1314
1362
  case "REQUEST_FAIL":
1315
- return { ...s, stage: "requesting-error", error: e.error };
1363
+ return { ...r, stage: "requesting-error", error: e.error };
1316
1364
  case "RESET":
1317
- return z([]);
1365
+ return D([]);
1318
1366
  default:
1319
- return s;
1367
+ return r;
1320
1368
  }
1321
1369
  }
1322
- function T(s, e, t) {
1323
- const r = s.files.map((i, n) => n === e ? t(i) : i);
1324
- return { ...s, files: r };
1370
+ function T(r, e, t) {
1371
+ const s = r.files.map((n, i) => i === e ? t(n) : n);
1372
+ return { ...r, files: s };
1325
1373
  }
1326
- function Wt(s) {
1327
- const e = s.files.every((r) => r.status === "done"), t = s.files.some((r) => r.status === "failed");
1328
- return e ? { ...s, stage: "requesting" } : t ? { ...s, stage: "uploading-error" } : s;
1374
+ function Jt(r) {
1375
+ const e = r.files.every((s) => s.status === "done"), t = r.files.some((s) => s.status === "failed");
1376
+ return e ? { ...r, stage: "requesting" } : t ? { ...r, stage: "uploading-error" } : r;
1329
1377
  }
1330
- function ye(s) {
1331
- return s.files.map((e, t) => ({ ...e, i: t })).filter((e) => e.status === "failed");
1378
+ function we(r) {
1379
+ return r.files.map((e, t) => ({ ...e, i: t })).filter((e) => e.status === "failed");
1332
1380
  }
1333
- const Vt = [
1381
+ const Xt = [
1334
1382
  "Wake",
1335
1383
  "Durham",
1336
1384
  "Orange",
@@ -1347,20 +1395,21 @@ const Vt = [
1347
1395
  "Moore",
1348
1396
  "Sampson",
1349
1397
  "Other / outside the area"
1350
- ], we = "(919) 821-8600", Yt = "https://www.wral.com/my-wral/", Gt = Object.freeze([
1398
+ ], xe = "(919) 821-8600", es = "https://www.wral.com/my-wral/", ts = Object.freeze([
1351
1399
  "We cannot come back to you for the detail that often turns a tip into a story.",
1352
1400
  "We cannot credit you if we use your photos or video.",
1353
1401
  "If you lose your reference number, we cannot look it up for you."
1354
1402
  ]);
1355
- function Kt(s) {
1356
- const e = String(s).replace(/\D/g, "");
1403
+ function ss(r) {
1404
+ const e = String(r).replace(/\D/g, "");
1357
1405
  return `tel:+1${e.length === 11 && e.startsWith("1") ? e.slice(1) : e}`;
1358
1406
  }
1359
- const Qt = "https://api.wral.com/forms", Jt = 480, Zt = 2, Ee = "What would you like to send to WRAL?", W = `Welcome to Report It. ${Ee}`, V = "A few quick questions route your report to the right team.", Xt = 2500, er = "I took or own this material and give WRAL permission to use it on air and online with credit to me.";
1360
- class ar extends G {
1361
- static styles = st;
1407
+ const rs = "https://api.wral.com/forms", ns = 480, is = 2, Te = "What would you like to send to WRAL?", V = `Welcome to Report It. ${Te}`, j = "A few quick questions route your report to the right team.", os = 2500, as = "I took or own this material and give WRAL permission to use it on air and online with credit to me.";
1408
+ class fs extends G {
1409
+ static styles = it;
1362
1410
  static properties = {
1363
1411
  api: { type: String },
1412
+ factsApi: { type: String, attribute: "facts-api" },
1364
1413
  flow: { type: String },
1365
1414
  _phase: { state: !0 },
1366
1415
  _forms: { state: !0 },
@@ -1376,45 +1425,51 @@ class ar extends G {
1376
1425
  _submit: { state: !0 },
1377
1426
  _banner: { state: !0 },
1378
1427
  _notice: { state: !0 },
1379
- _result: { state: !0 }
1428
+ _result: { state: !0 },
1429
+ _factsOffer: { state: !0 }
1380
1430
  };
1381
1431
  #c = null;
1382
1432
  #l = null;
1383
1433
  #u = null;
1384
1434
  #t = null;
1385
- #r = {};
1386
1435
  #s = {};
1387
- #n = /* @__PURE__ */ new Map();
1388
- #y = null;
1389
- #p = null;
1390
- #w = !1;
1436
+ #r = {};
1437
+ #i = /* @__PURE__ */ new Map();
1438
+ #w = null;
1439
+ #h = null;
1440
+ #x = !1;
1391
1441
  #d = null;
1392
- #F = 0;
1442
+ #I = 0;
1443
+ /* The gate was passed with an account created on this page load; offered once. */
1444
+ #p = !1;
1393
1445
  constructor() {
1394
- super(), this.api = Qt, this.flow = null, this._phase = "loading", this._forms = [], this._form = null, this._steps = [], this._origins = [], this._handoffError = !1, this._typing = !1, this._loadingSlow = !1, this._cardValues = {}, this._fieldErrors = {}, this._gate = { stage: null, email: "", error: "", loading: !1 }, this._submit = z([]), this._banner = null, this._notice = null, this._result = null;
1446
+ super(), this.api = rs, this.factsApi = null, this.flow = null, this._phase = "loading", this._forms = [], this._form = null, this._steps = [], this._origins = [], this._handoffError = !1, this._typing = !1, this._loadingSlow = !1, this._cardValues = {}, this._fieldErrors = {}, this._gate = { stage: null, email: "", error: "", loading: !1 }, this._submit = D([]), this._banner = null, this._notice = null, this._result = null, this._factsOffer = null;
1395
1447
  }
1396
1448
  get client() {
1397
- return this.#c ? this.#c : ((!this.#l || this.#u !== this.api) && (this.#l = dt({ baseUrl: this.api }), this.#u = this.api), this.#l);
1449
+ if (this.#c) return this.#c;
1450
+ const e = `${this.api}
1451
+ ${this.factsApi || ""}`;
1452
+ return (!this.#l || this.#u !== e) && (this.#l = vt({ baseUrl: this.api, factsBaseUrl: this.factsApi || null }), this.#u = e), this.#l;
1398
1453
  }
1399
1454
  set client(e) {
1400
- this.#c = e || null, this.isConnected && this.#x();
1455
+ this.#c = e || null, this.isConnected && this.#v();
1401
1456
  }
1402
1457
  connectedCallback() {
1403
- super.connectedCallback(), this.#x();
1458
+ super.connectedCallback(), this.#v();
1404
1459
  }
1405
1460
  disconnectedCallback() {
1406
- super.disconnectedCallback(), clearTimeout(this.#y), clearTimeout(this.#p), this.#d?.();
1407
- for (const { abort: e } of this.#n.values()) e?.();
1408
- this.#n.clear();
1461
+ super.disconnectedCallback(), clearTimeout(this.#w), clearTimeout(this.#h), this.#d?.();
1462
+ for (const { abort: e } of this.#i.values()) e?.();
1463
+ this.#i.clear();
1409
1464
  }
1410
- get #O() {
1465
+ get #B() {
1411
1466
  try {
1412
1467
  return matchMedia("(prefers-reduced-motion: reduce)").matches;
1413
1468
  } catch {
1414
1469
  return !0;
1415
1470
  }
1416
1471
  }
1417
- get #h() {
1472
+ get #f() {
1418
1473
  try {
1419
1474
  return sessionStorage;
1420
1475
  } catch {
@@ -1429,38 +1484,38 @@ class ar extends G {
1429
1484
  * submission is enabled on this deployment, and a form whose desk needs
1430
1485
  * a way to reach the viewer opts out with allowAnonymous: false.
1431
1486
  */
1432
- get #U() {
1487
+ get #L() {
1433
1488
  return this.client.anonymousCapability?.().enabled === !0 && this._form?.allowAnonymous !== !1;
1434
1489
  }
1435
1490
  /* Derived from the gate step, so a reload restores the choice. */
1436
- get #f() {
1491
+ get #g() {
1437
1492
  return this._steps.some((e) => e.kind === "gate" && e.anonymous === !0);
1438
1493
  }
1439
1494
  // ── Loading + draft restore ─────────────────────────────────────
1440
- async #x() {
1441
- const e = ++this.#F, t = () => e === this.#F;
1442
- this._phase = "loading", this._banner = null, this._loadingSlow = !1, clearTimeout(this.#p), this.#p = setTimeout(() => {
1495
+ async #v() {
1496
+ const e = ++this.#I, t = () => e === this.#I;
1497
+ this._phase = "loading", this._banner = null, this._loadingSlow = !1, clearTimeout(this.#h), this.#h = setTimeout(() => {
1443
1498
  this._loadingSlow = !0;
1444
- }, Xt);
1445
- let r;
1499
+ }, os);
1500
+ let s;
1446
1501
  try {
1447
- r = await this.client.listForms();
1502
+ s = await this.client.listForms();
1448
1503
  } catch {
1449
1504
  t() && (this._phase = "load-error");
1450
1505
  return;
1451
1506
  } finally {
1452
- t() && (clearTimeout(this.#p), this._loadingSlow = !1);
1507
+ t() && (clearTimeout(this.#h), this._loadingSlow = !1);
1453
1508
  }
1454
1509
  if (!t()) return;
1455
- this._forms = r;
1456
- const i = xt({ attr: this.flow, search: globalThis.location?.search }), n = Ht(Nt(this.#h), this._forms, { apiOrigin: this.api });
1457
- if ((n.status === "ok" || n.status === "review-required") && _t(n, i)) {
1458
- this._form = n.form, this._steps = n.steps, this._origins = n.origins || [], this.#t = n.requestId, this.#s = n.lostMedia || {}, n.status === "review-required" ? this._notice = "This form changed since your last visit — please review your answers." : Object.keys(this.#s).length && (this._notice = "Welcome back — your answers were saved, but attachments need to be re-attached."), this.#i({ animate: !1 });
1510
+ this._forms = s;
1511
+ const n = St({ attr: this.flow, search: globalThis.location?.search }), i = Qt(Gt(this.#f), this._forms, { apiOrigin: this.api });
1512
+ if ((i.status === "ok" || i.status === "review-required") && Tt(i, n)) {
1513
+ this._form = i.form, this._steps = i.steps, this._origins = i.origins || [], this.#t = i.requestId, this.#r = i.lostMedia || {}, i.status === "review-required" ? this._notice = "This form changed since your last visit — please review your answers." : Object.keys(this.#r).length && (this._notice = "Welcome back — your answers were saved, but attachments need to be re-attached."), this.#n({ animate: !1 });
1459
1514
  return;
1460
1515
  }
1461
- const o = vt(this._forms, i);
1516
+ const o = Ct(this._forms, n);
1462
1517
  if (o) {
1463
- this.#I(o);
1518
+ this.#E(o);
1464
1519
  return;
1465
1520
  }
1466
1521
  this._phase = "pick";
@@ -1468,9 +1523,9 @@ class ar extends G {
1468
1523
  #o() {
1469
1524
  if (!this._form) return;
1470
1525
  const e = {};
1471
- for (const [t, r] of Object.entries(this.#r))
1472
- r.length && (e[t] = r.map(({ name: i, type: n, size: o }) => ({ name: i, type: n, size: o })));
1473
- Lt(this.#h, qt({
1526
+ for (const [t, s] of Object.entries(this.#s))
1527
+ s.length && (e[t] = s.map(({ name: n, type: i, size: o }) => ({ name: n, type: i, size: o })));
1528
+ Yt(this.#f, Kt({
1474
1529
  apiOrigin: this.api,
1475
1530
  form: this._form,
1476
1531
  steps: this._steps,
@@ -1480,23 +1535,23 @@ class ar extends G {
1480
1535
  }));
1481
1536
  }
1482
1537
  // ── Walk mechanics ──────────────────────────────────────────────
1483
- #i({ animate: e = !0 } = {}) {
1484
- this._phase = "walk", this._cardValues = {}, this._fieldErrors = {}, this._gate = { stage: null, email: "", error: "", loading: !1 }, e && !this.#O ? (this._typing = !0, clearTimeout(this.#y), this.#y = setTimeout(() => {
1538
+ #n({ animate: e = !0 } = {}) {
1539
+ this._phase = "walk", this._cardValues = {}, this._fieldErrors = {}, this._gate = { stage: null, email: "", error: "", loading: !1 }, e && !this.#B ? (this._typing = !0, clearTimeout(this.#w), this.#w = setTimeout(() => {
1485
1540
  this._typing = !1;
1486
- }, Jt)) : this._typing = !1;
1541
+ }, ns)) : this._typing = !1;
1487
1542
  }
1488
- get #v() {
1489
- return this._form ? q(this._form, this._steps) : { node: null };
1543
+ get #_() {
1544
+ return this._form ? H(this._form, this._steps) : { node: null };
1490
1545
  }
1491
- #I(e) {
1492
- this._form = e, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#r = {}, this.#s = {}, this._notice = null, this.#o(), this.#i();
1546
+ #E(e) {
1547
+ this._form = e, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#s = {}, this.#r = {}, this._notice = null, this.#o(), this.#n();
1493
1548
  }
1494
1549
  #m(e) {
1495
- this._steps = [...this._steps, e], this.#o(), this.#i();
1550
+ this._steps = [...this._steps, e], this.#o(), this.#n();
1496
1551
  }
1497
- #L(e, t) {
1498
- if (N(t)) {
1499
- this.#N(e, t);
1552
+ #H(e, t) {
1553
+ if (L(t)) {
1554
+ this.#q(e, t);
1500
1555
  return;
1501
1556
  }
1502
1557
  this._handoffError = !1, this.#m({
@@ -1513,97 +1568,97 @@ class ar extends G {
1513
1568
  * Back can return them. A target that is missing or no longer matches
1514
1569
  * its preset path is a config mistake: say so and stay put.
1515
1570
  */
1516
- #N(e, t) {
1517
- const { form: r, steps: i, error: n } = gt(this._forms, t);
1518
- if (n) {
1571
+ #q(e, t) {
1572
+ const { form: s, steps: n, error: i } = At(this._forms, t);
1573
+ if (i) {
1519
1574
  this._handoffError = !0;
1520
1575
  return;
1521
1576
  }
1522
1577
  this._handoffError = !1, this._origins = [...this._origins, {
1523
- ...bt(this._form, this._steps, e, t),
1524
- media: this.#r,
1525
- lostMedia: this.#s
1526
- }], this._form = r, this._steps = i, this.#t = null, this.#r = {}, this.#s = {}, this._notice = null, this.#o(), this.#i();
1578
+ ...Ft(this._form, this._steps, e, t),
1579
+ media: this.#s,
1580
+ lostMedia: this.#r
1581
+ }], this._form = s, this._steps = n, this.#t = null, this.#s = {}, this.#r = {}, this._notice = null, this.#o(), this.#n();
1527
1582
  }
1528
1583
  /* Back past a hand-off: the originating form, on the choice card. */
1529
- #q() {
1584
+ #W() {
1530
1585
  const e = this._origins.at(-1);
1531
- this._origins = this._origins.slice(0, -1), this._form = e.form, this._steps = e.steps, this.#t = null, this.#r = e.media || {}, this.#s = e.lostMedia || {}, this._handoffError = !1, this.#o(), this.#i({ animate: !1 });
1586
+ this._origins = this._origins.slice(0, -1), this._form = e.form, this._steps = e.steps, this.#t = null, this.#s = e.media || {}, this.#r = e.lostMedia || {}, this._handoffError = !1, this.#o(), this.#n({ animate: !1 });
1532
1587
  }
1533
- #H() {
1588
+ #V() {
1534
1589
  if (this._phase === "done" || this._phase === "submitting") return;
1535
1590
  if (this._phase === "review") {
1536
- this.#i({ animate: !1 });
1591
+ this.#n({ animate: !1 });
1537
1592
  return;
1538
1593
  }
1539
- if (this._origins.length && yt(this._steps)) {
1540
- this.#q();
1594
+ if (this._origins.length && It(this._steps)) {
1595
+ this.#W();
1541
1596
  return;
1542
1597
  }
1543
1598
  if (!this._steps.length) {
1544
- this.#_();
1599
+ this.#$();
1545
1600
  return;
1546
1601
  }
1547
1602
  const e = this._steps.at(-1);
1548
- this._steps = this._steps.slice(0, -1), e.kind === "collect" && (this._cardValues = { ...e.values }), this.#o(), this.#i({ animate: !1 });
1603
+ this._steps = this._steps.slice(0, -1), e.kind === "collect" && (this._cardValues = { ...e.values }), this.#o(), this.#n({ animate: !1 });
1549
1604
  }
1550
- #_() {
1551
- this.client.endAnonSession?.(), this._form = null, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#r = {}, this.#s = {}, this._result = null, this._banner = null, this._notice = null, this._submit = z([]), be(this.#h), this._phase = "pick";
1605
+ #$() {
1606
+ this.client.endAnonSession?.(), this._form = null, this._steps = [], this._origins = [], this._handoffError = !1, this.#t = null, this.#s = {}, this.#r = {}, this._result = null, this._banner = null, this._notice = null, this._submit = D([]), this._factsOffer = null, be(this.#f), this._phase = "pick";
1552
1607
  }
1553
1608
  // ── Collect card ────────────────────────────────────────────────
1554
- #$(e, t) {
1609
+ #k(e, t) {
1555
1610
  this._cardValues = { ...this._cardValues, [e]: t };
1556
1611
  }
1557
1612
  /* Files attached on the given collect cards (a files-only consent counts them). */
1558
- #E(e) {
1613
+ #S(e) {
1559
1614
  let t = 0;
1560
- for (const r of new Set(e)) t += (this.#r[r] || []).length;
1615
+ for (const s of new Set(e)) t += (this.#s[s] || []).length;
1561
1616
  return t;
1562
1617
  }
1563
1618
  /* Files attached so far on this walk, the card being filled in included. */
1564
- #S(e) {
1565
- const t = this._steps.filter((r) => r.kind === "collect").map((r) => r.nodeId);
1566
- return this.#E([...t, e]);
1619
+ #C(e) {
1620
+ const t = this._steps.filter((s) => s.kind === "collect").map((s) => s.nodeId);
1621
+ return this.#S([...t, e]);
1567
1622
  }
1568
1623
  #j(e) {
1569
- const t = e.fields || [], { ok: r, errors: i } = he(t, this._cardValues, {
1570
- mediaCount: this.#S(e.id)
1571
- }), n = t.find((l) => l.kind === "media");
1624
+ const t = e.fields || [], { ok: s, errors: n } = fe(t, this._cardValues, {
1625
+ mediaCount: this.#C(e.id)
1626
+ }), i = t.find((l) => l.kind === "media");
1572
1627
  let o = !0;
1573
- if (n) {
1574
- const l = this.#r[e.id] || [], d = Y(l, this._form.budget, {
1575
- required: !!n.required
1628
+ if (i) {
1629
+ const l = this.#s[e.id] || [], d = Y(l, this._form.budget, {
1630
+ required: !!i.required
1576
1631
  });
1577
- d.ok ? l.length && (this.#s = { ...this.#s, [e.id]: [] }) : (o = !1, i[n.key] = d.errors[0].message);
1632
+ d.ok ? l.length && (this.#r = { ...this.#r, [e.id]: [] }) : (o = !1, n[i.key] = d.errors[0].message);
1578
1633
  }
1579
- if (!r || !o) {
1580
- this._fieldErrors = i;
1634
+ if (!s || !o) {
1635
+ this._fieldErrors = n;
1581
1636
  return;
1582
1637
  }
1583
- const a = this.#r[e.id] || [];
1638
+ const a = this.#s[e.id] || [];
1584
1639
  this.#m({
1585
1640
  nodeId: e.id,
1586
1641
  kind: "collect",
1587
1642
  values: { ...this._cardValues },
1588
- summary: Pt(t, this._cardValues, a)
1643
+ summary: Wt(t, this._cardValues, a)
1589
1644
  });
1590
1645
  }
1591
1646
  // ── Gate ────────────────────────────────────────────────────────
1592
- async #C() {
1593
- if (!(this._gate.stage || this.#w)) {
1594
- this.#w = !0;
1647
+ async #T() {
1648
+ if (!(this._gate.stage || this.#x)) {
1649
+ this.#x = !0;
1595
1650
  try {
1596
1651
  const e = await this.client.isAuthenticated();
1597
1652
  this._gate = e ? { stage: "signedin", email: this.client.signedInEmail?.() || "", error: "", loading: !1 } : { stage: "email", email: "", error: "", loading: !1 };
1598
1653
  } finally {
1599
- this.#w = !1;
1654
+ this.#x = !1;
1600
1655
  }
1601
1656
  this._gate.stage === "email" && this.client.onCrossTabLogin && !this.#d && (this.#d = this.client.onCrossTabLogin(() => {
1602
- this.#d?.(), this.#d = null, this._gate = { stage: null, email: "", error: "", loading: !1 }, this.#C();
1657
+ this.#d?.(), this.#d = null, this._gate = { stage: null, email: "", error: "", loading: !1 }, this.#T();
1603
1658
  }));
1604
1659
  }
1605
1660
  }
1606
- async #k() {
1661
+ async #A() {
1607
1662
  const e = this._gate.email.trim();
1608
1663
  if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
1609
1664
  this._gate = { ...this._gate, error: "Please enter a valid email address." };
@@ -1611,8 +1666,8 @@ class ar extends G {
1611
1666
  }
1612
1667
  this._gate = { ...this._gate, error: "", loading: !0 };
1613
1668
  try {
1614
- const t = await this.client.sendCode(e);
1615
- this._gate = t.authenticated ? { stage: "signedin", email: e, error: "", loading: !1 } : { ...this._gate, stage: "code", loading: !1 };
1669
+ const t = await this.client.sendCode(e), s = !!t.newAccount;
1670
+ this._gate = t.authenticated ? { stage: "signedin", email: e, error: "", loading: !1, newAccount: s } : { ...this._gate, stage: "code", loading: !1, newAccount: s };
1616
1671
  } catch (t) {
1617
1672
  this._gate = {
1618
1673
  ...this._gate,
@@ -1621,10 +1676,10 @@ class ar extends G {
1621
1676
  };
1622
1677
  }
1623
1678
  }
1624
- async #T(e) {
1679
+ async #R(e) {
1625
1680
  this._gate = { ...this._gate, error: "", loading: !0 };
1626
1681
  try {
1627
- await this.client.verifyCode(e), this.#R(this._gate.email);
1682
+ await this.client.verifyCode(e), this.#O(this._gate.email);
1628
1683
  } catch (t) {
1629
1684
  this._gate = {
1630
1685
  ...this._gate,
@@ -1633,30 +1688,30 @@ class ar extends G {
1633
1688
  };
1634
1689
  }
1635
1690
  }
1636
- #R(e) {
1637
- if (this._gate = { stage: null, email: "", error: "", loading: !1 }, this._submit.stage === "auth") {
1691
+ #O(e) {
1692
+ if (this.#p = !!this._gate.newAccount, this._gate = { stage: null, email: "", error: "", loading: !1 }, this._submit.stage === "auth") {
1638
1693
  this.#e({ type: "AUTH_OK" }), this._phase = "submitting", this.#a();
1639
1694
  return;
1640
1695
  }
1641
- const { node: t } = this.#v;
1696
+ const { node: t } = this.#_;
1642
1697
  t?.type === "gate" && this.#m({ nodeId: t.id, kind: "gate", email: e });
1643
1698
  }
1644
- #W() {
1645
- this.client.signOut?.(), this._gate = { stage: "email", email: "", error: "", loading: !1 };
1699
+ #Y() {
1700
+ this.client.signOut?.(), this.#p = !1, this._gate = { stage: "email", email: "", error: "", loading: !1 };
1646
1701
  }
1647
1702
  // ── Anonymous route ─────────────────────────────────────────────
1648
- #V() {
1703
+ #G() {
1649
1704
  this._gate = { ...this._gate, stage: "anon-confirm", error: "" };
1650
1705
  }
1651
- #Y() {
1706
+ #K() {
1652
1707
  this._gate = { ...this._gate, stage: "email", error: "" };
1653
1708
  }
1654
1709
  /*
1655
1710
  * Records the choice only. The session is minted at submit, against
1656
1711
  * the requestId, so an abandoned form leaves nothing behind.
1657
1712
  */
1658
- #G() {
1659
- const { node: e } = this.#v;
1713
+ #Q() {
1714
+ const { node: e } = this.#_;
1660
1715
  e?.type === "gate" && (this._gate = { stage: null, email: "", error: "", loading: !1 }, this.#m({ nodeId: e.id, kind: "gate", anonymous: !0 }));
1661
1716
  }
1662
1717
  async #M() {
@@ -1671,7 +1726,7 @@ class ar extends G {
1671
1726
  }
1672
1727
  /* An anonymous session outliving the upload run re-mints in place; there
1673
1728
  * is no identity to send back to the sign-in card. */
1674
- async #K() {
1729
+ async #Z() {
1675
1730
  if (await this.#M()) {
1676
1731
  this.#e({ type: "AUTH_OK" }), this._phase = "submitting", this.#a();
1677
1732
  return;
@@ -1679,42 +1734,42 @@ class ar extends G {
1679
1734
  this.#e({ type: "REQUEST_FAIL", error: this._banner });
1680
1735
  }
1681
1736
  // ── Submit pipeline ─────────────────────────────────────────────
1682
- get #g() {
1737
+ get #y() {
1683
1738
  const e = [];
1684
1739
  for (const t of this._steps)
1685
1740
  if (t.kind === "collect")
1686
- for (const r of this.#r[t.nodeId] || [])
1687
- e.push(r);
1741
+ for (const s of this.#s[t.nodeId] || [])
1742
+ e.push(s);
1688
1743
  return e;
1689
1744
  }
1690
1745
  #e(e) {
1691
- this._submit = jt(this._submit, e);
1746
+ this._submit = Zt(this._submit, e);
1692
1747
  }
1693
- async #Q() {
1748
+ async #J() {
1694
1749
  this._banner = null;
1695
1750
  for (let e = 0; e < this._steps.length; e++) {
1696
1751
  const t = this._steps[e];
1697
1752
  if (t.kind !== "collect") continue;
1698
- const r = x(this._form, t.nodeId), i = this._steps.slice(0, e + 1).filter((d) => d.kind === "collect").map((d) => d.nodeId), { ok: n, errors: o } = he(r?.fields || [], t.values, {
1699
- mediaCount: this.#E(i)
1700
- }), a = (r?.fields || []).find((d) => d.kind === "media");
1753
+ const s = x(this._form, t.nodeId), n = this._steps.slice(0, e + 1).filter((d) => d.kind === "collect").map((d) => d.nodeId), { ok: i, errors: o } = fe(s?.fields || [], t.values, {
1754
+ mediaCount: this.#S(n)
1755
+ }), a = (s?.fields || []).find((d) => d.kind === "media");
1701
1756
  let l = !0;
1702
1757
  if (a) {
1703
- const d = this.#r[t.nodeId] || [], p = Y(d, this._form.budget, {
1758
+ const d = this.#s[t.nodeId] || [], h = Y(d, this._form.budget, {
1704
1759
  required: !!a.required
1705
1760
  });
1706
- p.ok || (l = !1, o[a.key] = p.errors[0].message);
1761
+ h.ok || (l = !1, o[a.key] = h.errors[0].message);
1707
1762
  }
1708
- if (!n || !l) {
1709
- this._steps = this._steps.slice(0, e), this._cardValues = { ...t.values }, this._fieldErrors = o, this.#o(), this.#i({ animate: !1 });
1763
+ if (!i || !l) {
1764
+ this._steps = this._steps.slice(0, e), this._cardValues = { ...t.values }, this._fieldErrors = o, this.#o(), this.#n({ animate: !1 });
1710
1765
  return;
1711
1766
  }
1712
1767
  }
1713
- if (this.#t = this.#t || crypto.randomUUID(), this.#o(), this.#f) {
1768
+ if (this.#t = this.#t || crypto.randomUUID(), this.#o(), this.#g) {
1714
1769
  if (!await this.#M()) return;
1715
1770
  } else
1716
1771
  this.client.endAnonSession?.();
1717
- if (this._submit = z(this.#g), this._phase = "submitting", this.#f) {
1772
+ if (this._submit = D(this.#y), this._phase = "submitting", this.#g) {
1718
1773
  this.#e({ type: "START" }), this.#a();
1719
1774
  return;
1720
1775
  }
@@ -1726,93 +1781,111 @@ class ar extends G {
1726
1781
  }
1727
1782
  async #a() {
1728
1783
  const e = this._submit.stage;
1729
- if (e === "minting") return this.#J();
1730
- if (e === "uploading") return this.#D();
1731
- if (e === "requesting") return this.#ee();
1784
+ if (e === "minting") return this.#X();
1785
+ if (e === "uploading") return this.#N();
1786
+ if (e === "requesting") return this.#se();
1732
1787
  }
1733
- async #J() {
1788
+ async #X() {
1734
1789
  try {
1735
- const e = await this.client.createUploads(fe({
1790
+ const e = await this.client.createUploads(ge({
1736
1791
  formId: this._form.formId,
1737
1792
  requestId: this.#t,
1738
- files: this.#g
1793
+ files: this.#y
1739
1794
  }));
1740
1795
  this.#e({ type: "MINTED", uploads: e }), this.#a();
1741
1796
  } catch (e) {
1742
- this.#A(e);
1797
+ this.#F(e);
1743
1798
  }
1744
1799
  }
1745
- #D() {
1746
- const e = this._submit.files, t = this.#n.size;
1747
- let r = 0;
1748
- for (let i = 0; i < e.length && t + r < Zt; i++)
1749
- e[i].status !== "uploading" || this.#n.has(i) || (r += 1, this.#Z(i));
1800
+ #N() {
1801
+ const e = this._submit.files, t = this.#i.size;
1802
+ let s = 0;
1803
+ for (let n = 0; n < e.length && t + s < is; n++)
1804
+ e[n].status !== "uploading" || this.#i.has(n) || (s += 1, this.#ee(n));
1750
1805
  }
1751
- #Z(e) {
1752
- const t = this._submit.files[e], r = this.#g[e], { promise: i, abort: n } = this.client.uploadFile({
1806
+ #ee(e) {
1807
+ const t = this._submit.files[e], s = this.#y[e], { promise: n, abort: i } = this.client.uploadFile({
1753
1808
  url: t.url,
1754
- file: r,
1809
+ file: s,
1755
1810
  contentType: t.type,
1756
1811
  onProgress: ({ loaded: o, total: a }) => {
1757
1812
  this.#e({ type: "FILE_PROGRESS", i: e, loaded: o, total: a });
1758
1813
  }
1759
1814
  });
1760
- this.#n.set(e, { abort: n }), i.then(() => {
1761
- this.#n.delete(e), this.#e({ type: "FILE_DONE", i: e }), this.#a();
1815
+ this.#i.set(e, { abort: i }), n.then(() => {
1816
+ this.#i.delete(e), this.#e({ type: "FILE_DONE", i: e }), this.#a();
1762
1817
  }).catch((o) => {
1763
- this.#n.delete(e), this.#e({
1818
+ this.#i.delete(e), this.#e({
1764
1819
  type: "FILE_FAIL",
1765
1820
  i: e,
1766
1821
  error: o?.status === 403 ? "expired" : "failed"
1767
1822
  });
1768
1823
  });
1769
1824
  }
1770
- async #X(e) {
1825
+ async #te(e) {
1771
1826
  if (this._submit.files[e].error === "expired")
1772
1827
  try {
1773
- const [r] = await this.client.createUploads(fe({
1828
+ const [s] = await this.client.createUploads(ge({
1774
1829
  formId: this._form.formId,
1775
1830
  requestId: this.#t,
1776
- files: [this.#g[e]]
1831
+ files: [this.#y[e]]
1777
1832
  }));
1778
- this.#e({ type: "REMINT_FILE", i: e, upload: r });
1779
- } catch (r) {
1780
- this.#A(r);
1833
+ this.#e({ type: "REMINT_FILE", i: e, upload: s });
1834
+ } catch (s) {
1835
+ this.#F(s);
1781
1836
  return;
1782
1837
  }
1783
1838
  else
1784
1839
  this.#e({ type: "RETRY_FILE", i: e });
1785
- this.#D();
1840
+ this.#N();
1786
1841
  }
1787
- async #ee() {
1842
+ async #se() {
1788
1843
  try {
1789
- const e = this._submit.files.map(({ assetId: r, type: i }) => ({ assetId: r, type: i })), t = await this.client.putRequest(this.#t, Ct({
1844
+ const e = this._submit.files.map(({ assetId: s, type: n }) => ({ assetId: s, type: n })), t = await this.client.putRequest(this.#t, zt({
1790
1845
  form: this._form,
1791
1846
  steps: this._steps,
1792
1847
  media: e
1793
1848
  }));
1794
- this.#e({ type: "REQUEST_OK", result: t }), this._result = t, be(this.#h), this.client.endAnonSession?.(), this._phase = "done";
1849
+ this.#e({ type: "REQUEST_OK", result: t }), this._result = t, be(this.#f), this.client.endAnonSession?.(), this.#re(), this._phase = "done";
1795
1850
  } catch (e) {
1796
- this.#A(e);
1851
+ this.#F(e);
1852
+ }
1853
+ }
1854
+ // ── Save to My WRAL (new accounts only) ─────────────────────────
1855
+ #re() {
1856
+ if (!this.#p || this.#g || !this.client.saveUserFacts) return;
1857
+ this.#p = !1;
1858
+ const e = bt(Ae(this._form, this._steps), Fe(this._steps));
1859
+ e.length && (this._factsOffer = { stage: "offer", facts: e });
1860
+ }
1861
+ async #ne() {
1862
+ const e = this._factsOffer;
1863
+ if (!(!e || e.stage === "saving")) {
1864
+ this._factsOffer = { ...e, stage: "saving" };
1865
+ try {
1866
+ await this.client.saveUserFacts(e.facts), this._factsOffer = { ...e, stage: "saved" };
1867
+ } catch {
1868
+ this._factsOffer = { ...e, stage: "error" };
1869
+ }
1797
1870
  }
1798
1871
  }
1799
- #A(e) {
1872
+ #F(e) {
1800
1873
  const t = me(e?.status ?? 0, e?.body ?? null);
1801
1874
  if (t.kind === "auth") {
1802
- if (this.#e({ type: "AUTH_REQUIRED" }), this.#f) {
1803
- this.#K();
1875
+ if (this.#e({ type: "AUTH_REQUIRED" }), this.#g) {
1876
+ this.#Z();
1804
1877
  return;
1805
1878
  }
1806
1879
  this._gate = { stage: "email", email: "", error: "", loading: !1 };
1807
1880
  return;
1808
1881
  }
1809
1882
  if (t.kind === "stale") {
1810
- this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t }), this.#te();
1883
+ this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t }), this.#ie();
1811
1884
  return;
1812
1885
  }
1813
1886
  this._banner = t, this.#e({ type: "REQUEST_FAIL", error: t });
1814
1887
  }
1815
- async #te() {
1888
+ async #ie() {
1816
1889
  try {
1817
1890
  this._forms = await this.client.listForms();
1818
1891
  const e = this._forms.find((t) => t.formId === this._form.formId);
@@ -1820,52 +1893,52 @@ class ar extends G {
1820
1893
  } catch {
1821
1894
  }
1822
1895
  }
1823
- #re() {
1896
+ #oe() {
1824
1897
  this._banner = null, this.#e({ type: "REQUEST_START" }), this.#a();
1825
1898
  }
1826
1899
  // ── Render ──────────────────────────────────────────────────────
1827
1900
  render() {
1828
1901
  return c`
1829
1902
  <div class="chat" aria-live="polite">
1830
- ${this.#se()}
1903
+ ${this.#ae()}
1831
1904
  </div>
1832
- ${this.#ge()}
1905
+ ${this.#$e()}
1833
1906
  `;
1834
1907
  }
1835
- #se() {
1908
+ #ae() {
1836
1909
  switch (this._phase) {
1837
1910
  case "loading":
1838
- return c`${g(W, this._loadingSlow ? "Loading the form list…" : V)}
1839
- ${j()}`;
1911
+ return c`${m(V, this._loadingSlow ? "Loading the form list…" : j)}
1912
+ ${W()}`;
1840
1913
  case "load-error":
1841
1914
  return c`
1842
- ${g("We could not load the forms.", "Check your connection and try again.", { error: !0 })}
1915
+ ${m("We could not load the forms.", "Check your connection and try again.", { error: !0 })}
1843
1916
  <div class="options">
1844
- <button type="button" class="chip" @click=${() => this.#x()}>Try again</button>
1917
+ <button type="button" class="chip" @click=${() => this.#v()}>Try again</button>
1845
1918
  </div>
1846
1919
  `;
1847
1920
  case "pick":
1848
- return this.#ie();
1921
+ return this.#le();
1849
1922
  case "walk":
1850
- return c`${this.#b()}${this._typing ? j() : this.#ne()}`;
1923
+ return c`${this.#b()}${this._typing ? W() : this.#ce()}`;
1851
1924
  case "review":
1852
- return c`${this.#b()}${this.#B()}`;
1925
+ return c`${this.#b()}${this.#U()}`;
1853
1926
  case "submitting":
1854
- return c`${this.#b()}${this.#fe()}`;
1927
+ return c`${this.#b()}${this.#be()}`;
1855
1928
  case "done":
1856
- return c`${this.#b()}${this.#me()}`;
1929
+ return c`${this.#b()}${this.#xe ? this.#_e() : c`${this.#ve()}${this.#we()}`}`;
1857
1930
  default:
1858
1931
  return f;
1859
1932
  }
1860
1933
  }
1861
- #ie() {
1934
+ #le() {
1862
1935
  const e = this._forms.filter((t) => t.listed !== !1);
1863
1936
  return c`
1864
- ${g(W, V, { noAnim: !0 })}
1865
- <div class="options" role="group" aria-label=${Ee}>
1866
- ${e.map((t, r) => c`
1867
- <button type="button" class="chip" style="animation-delay: ${60 + r * 50}ms"
1868
- @click=${() => this.#I(t)}>${t.title}</button>
1937
+ ${m(V, j, { noAnim: !0 })}
1938
+ <div class="options" role="group" aria-label=${Te}>
1939
+ ${e.map((t, s) => c`
1940
+ <button type="button" class="chip" style="animation-delay: ${60 + s * 50}ms"
1941
+ @click=${() => this.#E(t)}>${t.title}</button>
1869
1942
  `)}
1870
1943
  </div>
1871
1944
  `;
@@ -1880,48 +1953,48 @@ class ar extends G {
1880
1953
  const e = [];
1881
1954
  if (!this._form) return e;
1882
1955
  const t = this._origins[0]?.form || this._form;
1883
- e.push(g(W, V, { noAnim: !0 })), e.push(F(t.title, { noAnim: !0 })), this._notice && e.push(g(this._notice, "", { noAnim: !0 }));
1884
- let r = null;
1885
- for (const i of this._origins) {
1886
- e.push(...this.#P(i.form, i.steps, r));
1887
- const n = x(i.form, i.option.nodeId);
1888
- n?.prompt && e.push(g(n.prompt, n.help, { noAnim: !0 })), r = i.option.label || i.option.optionId, e.push(F(r, { noAnim: !0 }));
1956
+ e.push(m(V, j, { noAnim: !0 })), e.push(v(t.title, { noAnim: !0 })), this._notice && e.push(m(this._notice, "", { noAnim: !0 }));
1957
+ let s = null;
1958
+ for (const n of this._origins) {
1959
+ e.push(...this.#D(n.form, n.steps, s));
1960
+ const i = x(n.form, n.option.nodeId);
1961
+ i?.prompt && e.push(m(i.prompt, i.help, { noAnim: !0 })), s = n.option.label || n.option.optionId, e.push(v(s, { noAnim: !0 }));
1889
1962
  }
1890
- return e.push(...this.#P(this._form, this._steps, r)), e;
1891
- }
1892
- #P(e, t, r = null) {
1893
- const i = [];
1894
- for (const n of t) {
1895
- if (n.preset) {
1896
- const a = n.label || n.optionId;
1897
- a !== r && i.push(F(a, { noAnim: !0 }));
1963
+ return e.push(...this.#D(this._form, this._steps, s)), e;
1964
+ }
1965
+ #D(e, t, s = null) {
1966
+ const n = [];
1967
+ for (const i of t) {
1968
+ if (i.preset) {
1969
+ const a = i.label || i.optionId;
1970
+ a !== s && n.push(v(a, { noAnim: !0 }));
1898
1971
  continue;
1899
1972
  }
1900
- const o = x(e, n.nodeId);
1901
- o?.prompt && i.push(g(o.prompt, o.help, { noAnim: !0 })), o?.type === "gate" && i.push(n.anonymous ? g(
1973
+ const o = x(e, i.nodeId);
1974
+ o?.prompt && n.push(m(o.prompt, o.help, { noAnim: !0 })), o?.type === "gate" && n.push(i.anonymous ? m(
1902
1975
  "Last step: how can we reach you?",
1903
1976
  "You chose to send this anonymously.",
1904
1977
  { noAnim: !0 }
1905
- ) : g(
1906
- "Last step: verify your email so we can follow up.",
1978
+ ) : m(
1979
+ "Almost done: verify your email so we can follow up.",
1907
1980
  "One address, one code. No password needed.",
1908
1981
  { noAnim: !0 }
1909
- )), n.kind === "choice" && i.push(F(n.label || n.optionId, { noAnim: !0 })), n.kind === "collect" && i.push(F(n.summary || "Details provided", { noAnim: !0 })), n.kind === "gate" && i.push(F(n.anonymous ? "Send anonymously" : n.email, { noAnim: !0 }));
1982
+ )), i.kind === "choice" && n.push(v(i.label || i.optionId, { noAnim: !0 })), i.kind === "collect" && n.push(v(i.summary || "Details provided", { noAnim: !0 })), i.kind === "gate" && n.push(v(i.anonymous ? "Send anonymously" : i.email, { noAnim: !0 }));
1910
1983
  }
1911
- return i;
1984
+ return n;
1912
1985
  }
1913
- #ne() {
1914
- const { node: e, error: t } = this.#v;
1915
- return t || !e ? g("Something went sideways with this form.", "Please start over.", { error: !0 }) : e.type === "choice" ? this.#oe(e) : e.type === "collect" ? this.#ae(e) : e.type === "gate" ? this.#z(e) : e.type === "redirect" ? this.#he(e) : e.type === "terminal" ? this.#B() : f;
1986
+ #ce() {
1987
+ const { node: e, error: t } = this.#_;
1988
+ return t || !e ? m("Something went sideways with this form.", "Please start over.", { error: !0 }) : e.type === "choice" ? this.#de(e) : e.type === "collect" ? this.#ue(e) : e.type === "gate" ? this.#P(e) : e.type === "redirect" ? this.#ye(e) : e.type === "terminal" ? this.#U() : f;
1916
1989
  }
1917
- #oe(e) {
1990
+ #de(e) {
1918
1991
  return c`
1919
- ${g(e.prompt, e.help)}
1920
- ${this._handoffError ? g("We could not load the forms.", "Check your connection and try again.", { error: !0 }) : f}
1992
+ ${m(e.prompt, e.help)}
1993
+ ${this._handoffError ? m("We could not load the forms.", "Check your connection and try again.", { error: !0 }) : f}
1921
1994
  <div class="options" role="group" aria-label=${e.prompt || "Choose one"}>
1922
- ${(e.options || []).map((t, r) => c`
1923
- <button type="button" class="chip" style="animation-delay: ${60 + r * 50}ms"
1924
- @click=${() => this.#L(e, t)}>${t.label}</button>
1995
+ ${(e.options || []).map((t, s) => c`
1996
+ <button type="button" class="chip" style="animation-delay: ${60 + s * 50}ms"
1997
+ @click=${() => this.#H(e, t)}>${t.label}</button>
1925
1998
  `)}
1926
1999
  </div>
1927
2000
  `;
@@ -1932,123 +2005,123 @@ class ar extends G {
1932
2005
  * novalidate: the card validates itself (native url checks would
1933
2006
  * otherwise block the submit silently).
1934
2007
  */
1935
- #ae(e) {
2008
+ #ue(e) {
1936
2009
  const t = e.fields || [];
1937
2010
  return c`
1938
- ${g(e.prompt, e.help)}
2011
+ ${m(e.prompt, e.help)}
1939
2012
  <form class="form-card" autocomplete="on" novalidate
1940
- @submit=${(r) => {
1941
- r.preventDefault(), this.#j(e);
2013
+ @submit=${(s) => {
2014
+ s.preventDefault(), this.#j(e);
1942
2015
  }}>
1943
- ${t.map((r) => this.#le(e, r))}
2016
+ ${t.map((s) => this.#he(e, s))}
1944
2017
  <button type="submit" class="btn-primary">Continue</button>
1945
2018
  </form>
1946
2019
  `;
1947
2020
  }
1948
- #le(e, t) {
1949
- const r = this.#S(e.id);
1950
- if (t.kind === "consent" && t.requiredIf === "media" && r === 0)
2021
+ #he(e, t) {
2022
+ const s = this.#C(e.id);
2023
+ if (t.kind === "consent" && t.requiredIf === "media" && s === 0)
1951
2024
  return f;
1952
- const i = this._cardValues[t.key], n = this._fieldErrors[t.key], o = !Fe(t, { mediaCount: r }) && t.kind !== "consent" ? c` <span class="opt">optional</span>` : f, a = t.kind === "consent" ? f : c`
2025
+ const n = this._cardValues[t.key], i = this._fieldErrors[t.key], o = !Se(t, { mediaCount: s }) && t.kind !== "consent" ? c` <span class="opt">optional</span>` : f, a = t.kind === "consent" ? f : c`
1953
2026
  <label for="f-${t.key}">${t.label}${o}</label>
1954
2027
  `;
1955
2028
  return c`
1956
2029
  <div class="field">
1957
2030
  ${a}
1958
- ${this.#ce(e, t, i)}
1959
- ${n ? c`<div class="err" role="alert">${n}</div>` : f}
2031
+ ${this.#pe(e, t, n)}
2032
+ ${i ? c`<div class="err" role="alert">${i}</div>` : f}
1960
2033
  </div>
1961
2034
  `;
1962
2035
  }
1963
- #ce(e, t, r) {
1964
- const i = (n) => (o) => this.#$(n, o.target.value);
2036
+ #pe(e, t, s) {
2037
+ const n = (i) => (o) => this.#k(i, o.target.value);
1965
2038
  switch (t.kind) {
1966
2039
  case "text":
1967
- return c`<input type="text" id="f-${t.key}" name=${t.key} .value=${r || ""}
2040
+ return c`<input type="text" id="f-${t.key}" name=${t.key} .value=${s || ""}
1968
2041
  inputmode=${ce(t.inputMode)} autocomplete=${ce(t.autocomplete)}
1969
- placeholder=${t.placeholder || ""} @input=${i(t.key)}>`;
2042
+ placeholder=${t.placeholder || ""} @input=${n(t.key)}>`;
1970
2043
  case "url":
1971
- return c`<input type="url" id="f-${t.key}" .value=${r || ""}
1972
- placeholder=${t.placeholder || ""} @input=${i(t.key)}>`;
2044
+ return c`<input type="url" id="f-${t.key}" .value=${s || ""}
2045
+ placeholder=${t.placeholder || ""} @input=${n(t.key)}>`;
1973
2046
  case "textarea":
1974
- return c`<textarea id="f-${t.key}" .value=${r || ""}
1975
- placeholder=${t.placeholder || ""} @input=${i(t.key)}></textarea>`;
2047
+ return c`<textarea id="f-${t.key}" .value=${s || ""}
2048
+ placeholder=${t.placeholder || ""} @input=${n(t.key)}></textarea>`;
1976
2049
  case "datetime":
1977
- return c`<input type="datetime-local" id="f-${t.key}" .value=${r || ""}
1978
- @input=${i(t.key)}>`;
2050
+ return c`<input type="datetime-local" id="f-${t.key}" .value=${s || ""}
2051
+ @input=${n(t.key)}>`;
1979
2052
  case "select":
1980
2053
  return c`
1981
- <select id="f-${t.key}" @change=${i(t.key)}>
2054
+ <select id="f-${t.key}" @change=${n(t.key)}>
1982
2055
  <option value="">Choose one</option>
1983
- ${(t.options || []).map((n) => c`
1984
- <option value=${n.id} ?selected=${r === n.id}>${n.label}</option>
2056
+ ${(t.options || []).map((i) => c`
2057
+ <option value=${i.id} ?selected=${s === i.id}>${i.label}</option>
1985
2058
  `)}
1986
2059
  </select>
1987
2060
  `;
1988
2061
  case "location":
1989
- return this.#de(t, r || {});
2062
+ return this.#fe(t, s || {});
1990
2063
  case "consent":
1991
2064
  return c`
1992
2065
  <div class="consent-row">
1993
- <input type="checkbox" id="f-${t.key}" .checked=${r === !0}
1994
- @change=${(n) => this.#$(t.key, n.target.checked)}>
2066
+ <input type="checkbox" id="f-${t.key}" .checked=${s === !0}
2067
+ @change=${(i) => this.#k(t.key, i.target.checked)}>
1995
2068
  <label for="f-${t.key}" style="all: unset; cursor: pointer;">
1996
- ${t.text || er}
2069
+ ${t.text || as}
1997
2070
  </label>
1998
2071
  </div>
1999
2072
  `;
2000
2073
  case "media":
2001
2074
  return c`
2002
2075
  <wral-report-media
2003
- .files=${this.#r[e.id] || []}
2004
- .lostMeta=${this.#s[e.id] || []}
2076
+ .files=${this.#s[e.id] || []}
2077
+ .lostMeta=${this.#r[e.id] || []}
2005
2078
  .budget=${this._form.budget || {}}
2006
2079
  ?required=${!!t.required}
2007
2080
  label=${t.label}
2008
- @files-changed=${(n) => {
2009
- this.#r = { ...this.#r, [e.id]: n.detail.files }, this.requestUpdate();
2081
+ @files-changed=${(i) => {
2082
+ this.#s = { ...this.#s, [e.id]: i.detail.files }, this.requestUpdate();
2010
2083
  }}></wral-report-media>
2011
2084
  `;
2012
2085
  default:
2013
2086
  return f;
2014
2087
  }
2015
2088
  }
2016
- #de(e, t) {
2017
- const r = e.counties || Vt, i = (n) => this.#$(e.key, { ...t, ...n });
2089
+ #fe(e, t) {
2090
+ const s = e.counties || Xt, n = (i) => this.#k(e.key, { ...t, ...i });
2018
2091
  return c`
2019
2092
  <select id="f-${e.key}" aria-label="County"
2020
- @change=${(n) => i({ county: n.target.value || void 0 })}>
2093
+ @change=${(i) => n({ county: i.target.value || void 0 })}>
2021
2094
  <option value="">Choose a county</option>
2022
- ${r.map((n) => c`
2023
- <option value=${n} ?selected=${t.county === n}>${n}</option>
2095
+ ${s.map((i) => c`
2096
+ <option value=${i} ?selected=${t.county === i}>${i}</option>
2024
2097
  `)}
2025
2098
  </select>
2026
2099
  <input type="text" style="margin-top: 8px;"
2027
2100
  aria-label="Nearest town or crossroads"
2028
2101
  placeholder="Nearest town or crossroads"
2029
2102
  .value=${t.where || ""}
2030
- @input=${(n) => i({ where: n.target.value || void 0 })}>
2103
+ @input=${(i) => n({ where: i.target.value || void 0 })}>
2031
2104
  `;
2032
2105
  }
2033
- #z(e) {
2034
- this.#C();
2035
- const t = this._gate, r = g(
2036
- "Last step: verify your email so we can follow up.",
2106
+ #P(e) {
2107
+ this.#T();
2108
+ const t = this._gate, s = m(
2109
+ "Almost done: verify your email so we can follow up.",
2037
2110
  "One address, one code. No password needed."
2038
2111
  );
2039
2112
  return t.stage ? t.stage === "signedin" ? c`
2040
- ${r}
2113
+ ${s}
2041
2114
  <div class="form-card">
2042
2115
  <p style="margin: 0 0 12px; font-size: 14.5px;">
2043
2116
  You are signed in as <strong>${t.email || "your My WRAL account"}</strong> on this device.
2044
2117
  </p>
2045
2118
  <button type="button" class="btn-primary"
2046
- @click=${() => this.#R(t.email)}>Continue</button>
2119
+ @click=${() => this.#O(t.email)}>Continue</button>
2047
2120
  <button type="button" class="btn-ghost"
2048
- @click=${() => this.#W()}>Use a different email</button>
2121
+ @click=${() => this.#Y()}>Use a different email</button>
2049
2122
  </div>
2050
2123
  ` : t.stage === "email" ? c`
2051
- ${r}
2124
+ ${s}
2052
2125
  <div class="form-card login-card">
2053
2126
  <h2>Sign in or create account</h2>
2054
2127
  <p class="login-sub">
@@ -2058,16 +2131,16 @@ class ar extends G {
2058
2131
  <label for="gate-email">Email address</label>
2059
2132
  <input type="email" id="gate-email" autocomplete="email"
2060
2133
  placeholder="you@example.com" .value=${t.email}
2061
- @input=${(i) => {
2062
- this._gate = { ...t, email: i.target.value };
2134
+ @input=${(n) => {
2135
+ this._gate = { ...t, email: n.target.value };
2063
2136
  }}
2064
- @keydown=${(i) => {
2065
- i.key === "Enter" && this.#k();
2137
+ @keydown=${(n) => {
2138
+ n.key === "Enter" && this.#A();
2066
2139
  }}>
2067
2140
  </div>
2068
2141
  ${t.error ? c`<div class="err" role="alert">${t.error}</div>` : f}
2069
2142
  <button type="button" class="login-btn" ?disabled=${t.loading}
2070
- @click=${() => this.#k()}>
2143
+ @click=${() => this.#A()}>
2071
2144
  ${t.loading ? "Sending…" : "Continue with email"}
2072
2145
  </button>
2073
2146
  <div class="login-why">
@@ -2076,13 +2149,13 @@ class ar extends G {
2076
2149
  <li>We can follow up on your report</li>
2077
2150
  <li>Your contact information fills in automatically next time</li>
2078
2151
  <li>You are credited by name when we use your photos or video</li>
2079
- <li><a href=${Yt} target="_blank" rel="noopener">All other My WRAL account benefits</a></li>
2152
+ <li><a href=${es} target="_blank" rel="noopener">All other My WRAL account benefits</a></li>
2080
2153
  </ul>
2081
2154
  </div>
2082
- ${this._submit.stage === "auth" ? f : this.#ue()}
2155
+ ${this._submit.stage === "auth" ? f : this.#ge()}
2083
2156
  </div>
2084
- ` : t.stage === "anon-confirm" ? this.#pe(r) : c`
2085
- ${r}
2157
+ ` : t.stage === "anon-confirm" ? this.#me(s) : c`
2158
+ ${s}
2086
2159
  <div class="form-card login-card">
2087
2160
  <h2>Enter verification code</h2>
2088
2161
  <p class="login-sub">We sent a 6-digit code to <strong>${t.email}</strong></p>
@@ -2095,39 +2168,39 @@ class ar extends G {
2095
2168
  <div class="field">
2096
2169
  <label>Verification code</label>
2097
2170
  <wral-code-input
2098
- @code-complete=${(i) => this.#T(i.detail?.code ?? i.detail?.value ?? i.target.value)}>
2171
+ @code-complete=${(n) => this.#R(n.detail?.code ?? n.detail?.value ?? n.target.value)}>
2099
2172
  </wral-code-input>
2100
2173
  </div>
2101
2174
  ${t.error ? c`<div class="err" role="alert">${t.error}</div>` : f}
2102
2175
  <button type="button" class="login-btn" ?disabled=${t.loading}
2103
2176
  @click=${() => {
2104
- const i = this.renderRoot.querySelector("wral-code-input");
2105
- this.#T(i?.value || "");
2177
+ const n = this.renderRoot.querySelector("wral-code-input");
2178
+ this.#R(n?.value || "");
2106
2179
  }}>
2107
2180
  ${t.loading ? "Checking…" : "Sign in"}
2108
2181
  </button>
2109
2182
  <p class="login-help">
2110
2183
  Didn’t receive a code? Check your spam folder or
2111
- <button type="button" @click=${() => this.#k()}>resend a new code</button>.
2184
+ <button type="button" @click=${() => this.#A()}>resend a new code</button>.
2112
2185
  </p>
2113
2186
  </div>
2114
- ` : c`${r}${j()}`;
2187
+ ` : c`${s}${W()}`;
2115
2188
  }
2116
2189
  /* Collapsed by default: findable for whoever needs it, never the
2117
2190
  * first thing a viewer reaches for. */
2118
- #ue() {
2191
+ #ge() {
2119
2192
  return c`
2120
2193
  <details class="login-alt">
2121
2194
  <summary>Other ways to send this</summary>
2122
2195
  <div class="alt-body">
2123
2196
  <p class="alt-row">
2124
2197
  Call the newsroom desk at
2125
- <a href=${Kt(we)}>${we}</a>.
2198
+ <a href=${ss(xe)}>${xe}</a>.
2126
2199
  </p>
2127
- ${this.#U ? c`
2200
+ ${this.#L ? c`
2128
2201
  <p class="alt-row">
2129
2202
  <button type="button" class="alt-link"
2130
- @click=${() => this.#V()}>Send this anonymously</button>
2203
+ @click=${() => this.#G()}>Send this anonymously</button>
2131
2204
  — no follow-up, and no credit if we use your photos or video.
2132
2205
  </p>
2133
2206
  ` : f}
@@ -2135,7 +2208,7 @@ class ar extends G {
2135
2208
  </details>
2136
2209
  `;
2137
2210
  }
2138
- #pe(e) {
2211
+ #me(e) {
2139
2212
  return c`
2140
2213
  ${e}
2141
2214
  <div class="form-card login-card">
@@ -2144,20 +2217,20 @@ class ar extends G {
2144
2217
  You can send this report without an account. Here is what it costs you.
2145
2218
  </p>
2146
2219
  <ul class="anon-costs">
2147
- ${Gt.map((t) => c`
2220
+ ${ts.map((t) => c`
2148
2221
  <li><span class="x" aria-hidden="true">✕</span><span>${t}</span></li>
2149
2222
  `)}
2150
2223
  </ul>
2151
2224
  <div class="anon-actions">
2152
2225
  <button type="button" class="login-btn"
2153
- @click=${() => this.#Y()}>Sign in instead</button>
2226
+ @click=${() => this.#K()}>Sign in instead</button>
2154
2227
  <button type="button" class="btn-ghost"
2155
- @click=${() => this.#G()}>Continue anonymously</button>
2228
+ @click=${() => this.#Q()}>Continue anonymously</button>
2156
2229
  </div>
2157
2230
  </div>
2158
2231
  `;
2159
2232
  }
2160
- #he(e) {
2233
+ #ye(e) {
2161
2234
  const t = e.redirect || {};
2162
2235
  return c`
2163
2236
  <div class="form-card">
@@ -2176,16 +2249,16 @@ class ar extends G {
2176
2249
  </div>
2177
2250
  `;
2178
2251
  }
2179
- #B() {
2180
- const e = zt(this._form, this._steps);
2252
+ #U() {
2253
+ const e = Vt(this._form, this._steps);
2181
2254
  return c`
2182
- ${g("Here is what you are sending.", "Check it over, then submit.")}
2255
+ ${m("Here is what you are sending.", "Check it over, then submit.")}
2183
2256
  <div class="form-card">
2184
2257
  <ul class="review-list">
2185
2258
  ${e.map((t) => c`
2186
2259
  <li>
2187
2260
  <span class="k">${t.k}</span>
2188
- <span>${t.pill ? it(t.pill) : t.v}</span>
2261
+ <span>${t.pill ? ot(t.pill) : t.v}</span>
2189
2262
  </li>
2190
2263
  `)}
2191
2264
  </ul>
@@ -2193,16 +2266,16 @@ class ar extends G {
2193
2266
  <div class="err" role="alert" style="margin-top: 12px;">${this._banner.message}</div>
2194
2267
  ` : f}
2195
2268
  <div style="margin-top: 16px;">
2196
- <button type="button" class="btn-primary" @click=${() => this.#Q()}>
2269
+ <button type="button" class="btn-primary" @click=${() => this.#J()}>
2197
2270
  Submit report
2198
2271
  </button>
2199
2272
  </div>
2200
2273
  </div>
2201
2274
  `;
2202
2275
  }
2203
- #fe() {
2276
+ #be() {
2204
2277
  const e = this._submit;
2205
- if (e.stage === "auth") return this.#z({ id: null, type: "gate" });
2278
+ if (e.stage === "auth") return this.#P({ id: null, type: "gate" });
2206
2279
  const t = {
2207
2280
  minting: "Preparing your uploads…",
2208
2281
  uploading: "Uploading your files…",
@@ -2211,21 +2284,21 @@ class ar extends G {
2211
2284
  "requesting-error": this._banner?.message || "We could not send your report."
2212
2285
  }[e.stage] || "Working…";
2213
2286
  return c`
2214
- ${g("Submitting your report.", t)}
2287
+ ${m("Submitting your report.", t)}
2215
2288
  <div class="form-card">
2216
- ${e.files.map((r, i) => c`
2289
+ ${e.files.map((s, n) => c`
2217
2290
  <div class="upload-row">
2218
- <span class="name">${r.name}</span>
2291
+ <span class="name">${s.name}</span>
2219
2292
  <div class="upload-bar" role="progressbar"
2220
2293
  aria-valuemin="0" aria-valuemax="100"
2221
- aria-valuenow=${Math.round((r.status === "done" ? 1 : r.progress) * 100)}>
2222
- <div class="fill" style="width: ${(r.status === "done" ? 1 : r.progress) * 100}%"></div>
2294
+ aria-valuenow=${Math.round((s.status === "done" ? 1 : s.progress) * 100)}>
2295
+ <div class="fill" style="width: ${(s.status === "done" ? 1 : s.progress) * 100}%"></div>
2223
2296
  </div>
2224
- <span class="state ${r.status === "failed" ? "failed" : ""}">
2225
- ${r.status === "done" ? "Done" : r.status === "failed" ? "Failed" : "Uploading"}
2297
+ <span class="state ${s.status === "failed" ? "failed" : ""}">
2298
+ ${s.status === "done" ? "Done" : s.status === "failed" ? "Failed" : "Uploading"}
2226
2299
  </span>
2227
- ${r.status === "failed" ? c`
2228
- <button type="button" class="retry-chip" @click=${() => this.#X(i)}>
2300
+ ${s.status === "failed" ? c`
2301
+ <button type="button" class="retry-chip" @click=${() => this.#te(n)}>
2229
2302
  Retry
2230
2303
  </button>
2231
2304
  ` : f}
@@ -2238,26 +2311,21 @@ class ar extends G {
2238
2311
  ${Math.ceil(this._banner.retryAfter / 60)} minutes.</div>
2239
2312
  ` : f}
2240
2313
  <button type="button" class="btn-primary" style="margin-top: 8px;"
2241
- @click=${() => this.#re()}>Try again</button>
2314
+ @click=${() => this.#oe()}>Try again</button>
2242
2315
  ` : f}
2243
- ${ye(e).length && e.stage === "uploading-error" ? c`
2316
+ ${we(e).length && e.stage === "uploading-error" ? c`
2244
2317
  <div class="err" role="alert">Retry the failed
2245
- ${ye(e).length === 1 ? "file" : "files"} to continue.</div>
2318
+ ${we(e).length === 1 ? "file" : "files"} to continue.</div>
2246
2319
  ` : f}
2247
2320
  </div>
2248
2321
  `;
2249
2322
  }
2250
- #me() {
2251
- const e = ke(this._form, this._steps), t = Bt(this._result, e), r = Ut({
2252
- routing: this._result?.routing || {},
2253
- flags: e,
2254
- reference: this._result?.reference || "",
2255
- anonymous: this.#f
2256
- });
2323
+ #we() {
2324
+ const e = Ie(this._form, this._steps), t = jt(this._result, e);
2257
2325
  return c`
2258
2326
  <div class="confirm-card">
2259
2327
  <div class="c-head">
2260
- <div class="c-check">${nt()}</div>
2328
+ <div class="c-check">${at()}</div>
2261
2329
  <div>
2262
2330
  <div class="eyebrow">Report received</div>
2263
2331
  <h2>${t.title}</h2>
@@ -2265,39 +2333,72 @@ class ar extends G {
2265
2333
  </div>
2266
2334
  <p>${t.body}</p>
2267
2335
  ${t.urgentNote ? c`<p>${t.urgentNote}</p>` : f}
2336
+ ${this._factsOffer?.stage === "saved" ? c`
2337
+ <p role="status">Your ${this.#z} ${this._factsOffer.facts.length === 1 ? "is" : "are"}
2338
+ saved to your My WRAL account.</p>
2339
+ ` : f}
2268
2340
  <div class="refs">
2269
2341
  <span class="ref"><span class="rk">Reference</span>${this._result?.reference || ""}</span>
2270
2342
  </div>
2271
- <button type="button" class="c-again" @click=${() => this.#_()}>
2343
+ <button type="button" class="c-again" @click=${() => this.#$()}>
2272
2344
  Start a new report
2273
2345
  </button>
2274
2346
  </div>
2275
- <div class="journey">
2276
- <div class="j-eyebrow">Behind the scenes</div>
2277
- <div class="j-title">What happens to your report now</div>
2278
- ${r.map((i, n) => c`
2279
- <div class="j-step">
2280
- <div class="j-dot">${n + 1}</div>
2281
- <div class="j-body">
2282
- <div class="j-t">${i.title}
2283
- ${i.pill ? c` <span class="flag-pill urgent">${i.pill}</span>` : f}
2284
- </div>
2285
- <div class="j-d">${i.body}</div>
2286
- </div>
2287
- </div>
2288
- `)}
2347
+ `;
2348
+ }
2349
+ /* The offer is a step of its own: the confirmation waits for Save or No thanks. */
2350
+ get #xe() {
2351
+ return ["offer", "saving", "error"].includes(this._factsOffer?.stage);
2352
+ }
2353
+ get #z() {
2354
+ return (this._factsOffer?.facts || []).map((e) => e.label.toLowerCase()).join(" and ");
2355
+ }
2356
+ #ve() {
2357
+ const e = this._factsOffer?.stage;
2358
+ return e === "saved" ? v("Save to my account", { noAnim: !0 }) : e === "dismissed" ? v("No thanks", { noAnim: !0 }) : f;
2359
+ }
2360
+ #_e() {
2361
+ const e = this._factsOffer, t = e.stage === "saving";
2362
+ return c`
2363
+ ${m(
2364
+ `One more step: save your ${this.#z} to your new My WRAL account?`,
2365
+ "Only what is listed here is saved."
2366
+ )}
2367
+ <div class="form-card facts-offer">
2368
+ <dl>
2369
+ ${e.facts.map((s) => c`<dt>${s.label}</dt><dd>${s.value}</dd>`)}
2370
+ </dl>
2371
+ <p class="facts-note">
2372
+ ${lt()}
2373
+ <span>${e.facts.length === 1 ? "This is saved to your My WRAL dashboard, where you can change it anytime." : "These are saved to your My WRAL dashboard, where you can change them anytime."}</span>
2374
+ </p>
2375
+ ${e.stage === "error" ? c`
2376
+ <div class="err" role="alert">We couldn't save these. Please try again.</div>
2377
+ ` : f}
2378
+ <div class="actions">
2379
+ <button type="button" class="btn-primary" ?disabled=${t}
2380
+ @click=${() => this.#ne()}>
2381
+ ${t ? "Saving…" : e.stage === "error" ? "Try again" : "Save to my account"}
2382
+ </button>
2383
+ <button type="button" class="btn-ghost" ?disabled=${t}
2384
+ @click=${() => {
2385
+ this._factsOffer = { ...e, stage: "dismissed" };
2386
+ }}>
2387
+ No thanks
2388
+ </button>
2389
+ </div>
2289
2390
  </div>
2290
2391
  `;
2291
2392
  }
2292
- #ge() {
2393
+ #$e() {
2293
2394
  const e = this._phase === "submitting" || this._phase === "done" || this._phase === "loading" || this._phase === "load-error";
2294
2395
  return c`
2295
2396
  <div class="bottom-bar">
2296
2397
  <div class="inner">
2297
2398
  <button type="button" class="btn-ghost" ?disabled=${e || this._phase === "pick"}
2298
- @click=${() => this.#H()}>← Back</button>
2399
+ @click=${() => this.#V()}>← Back</button>
2299
2400
  <button type="button" class="btn-ghost" ?disabled=${this._phase === "submitting"}
2300
- @click=${() => this.#_()}>Start over</button>
2401
+ @click=${() => this.#$()}>Start over</button>
2301
2402
  <span class="note">Your report goes to a person on the right desk.</span>
2302
2403
  </div>
2303
2404
  </div>
@@ -2307,7 +2408,7 @@ class ar extends G {
2307
2408
  this.renderRoot?.querySelector(".chat")?.lastElementChild?.scrollIntoView?.({ block: "nearest" });
2308
2409
  }
2309
2410
  }
2310
- class lr extends G {
2411
+ class gs extends G {
2311
2412
  static properties = {
2312
2413
  files: { attribute: !1 },
2313
2414
  lostMeta: { attribute: !1 },
@@ -2315,7 +2416,7 @@ class lr extends G {
2315
2416
  required: { type: Boolean },
2316
2417
  label: { type: String }
2317
2418
  };
2318
- static styles = y`
2419
+ static styles = b`
2319
2420
  :host { display: block; }
2320
2421
  input[type=file] { font-family: inherit; font-size: 14px; }
2321
2422
  .file-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
@@ -2364,13 +2465,13 @@ class lr extends G {
2364
2465
  @change=${this.#u}>
2365
2466
  ${e.length ? c`
2366
2467
  <ul class="file-list">
2367
- ${e.map((r, i) => c`
2468
+ ${e.map((s, n) => c`
2368
2469
  <li>
2369
- <span>${r.name}</span>
2370
- <span class="size">${tr(r.size)}</span>
2470
+ <span>${s.name}</span>
2471
+ <span class="size">${ls(s.size)}</span>
2371
2472
  <button type="button" class="remove"
2372
- aria-label="Remove ${r.name}"
2373
- @click=${() => this.#t(i)}>✕</button>
2473
+ aria-label="Remove ${s.name}"
2474
+ @click=${() => this.#t(n)}>✕</button>
2374
2475
  </li>
2375
2476
  `)}
2376
2477
  </ul>
@@ -2378,47 +2479,47 @@ class lr extends G {
2378
2479
  ${(this.lostMeta || []).length ? c`
2379
2480
  <div class="lost">
2380
2481
  Please re-attach your ${this.lostMeta.length === 1 ? "file" : "files"}
2381
- (${this.lostMeta.map((r) => r.name).join(", ")}) —
2482
+ (${this.lostMeta.map((s) => s.name).join(", ")}) —
2382
2483
  attachments can't be saved between visits.
2383
2484
  </div>
2384
2485
  ` : f}
2385
- ${t.map((r) => c`<div class="err">${r.message}</div>`)}
2486
+ ${t.map((s) => c`<div class="err">${s.message}</div>`)}
2386
2487
  `;
2387
2488
  }
2388
2489
  }
2389
- function tr(s) {
2390
- return Number.isFinite(s) ? s >= 1024 * 1024 ? `${(s / (1024 * 1024)).toFixed(1)} MB` : s >= 1024 ? `${Math.round(s / 1024)} KB` : `${s} B` : "";
2490
+ function ls(r) {
2491
+ return Number.isFinite(r) ? r >= 1024 * 1024 ? `${(r / (1024 * 1024)).toFixed(1)} MB` : r >= 1024 ? `${Math.round(r / 1024)} KB` : `${r} B` : "";
2391
2492
  }
2392
- const rr = (s, e, t, r) => {
2393
- const i = e.target.value.replace(/\D/g, "").slice(-1), n = [...t];
2394
- n[s] = i;
2395
- const o = n.join(""), a = n.every((l) => l !== "");
2396
- return r("code-change", { value: o, complete: a }), i && a && r("code-complete", { value: o }), n;
2397
- }, sr = (s, e, t, r) => {
2493
+ const cs = (r, e, t, s) => {
2494
+ const n = e.target.value.replace(/\D/g, "").slice(-1), i = [...t];
2495
+ i[r] = n;
2496
+ const o = i.join(""), a = i.every((l) => l !== "");
2497
+ return s("code-change", { value: o, complete: a }), n && a && s("code-complete", { value: o }), i;
2498
+ }, ds = (r, e, t, s) => {
2398
2499
  if (e.key === "Backspace") {
2399
- const i = [...t];
2400
- !i[s] && s > 0 ? i[s - 1] = "" : i[s] && (i[s] = "");
2401
- const n = i.join("");
2402
- return r("code-change", { value: n, complete: !1 }), i;
2500
+ const n = [...t];
2501
+ !n[r] && r > 0 ? n[r - 1] = "" : n[r] && (n[r] = "");
2502
+ const i = n.join("");
2503
+ return s("code-change", { value: i, complete: !1 }), n;
2403
2504
  }
2404
2505
  return t;
2405
- }, ir = (s, e, t) => {
2406
- s.preventDefault();
2407
- const r = s.clipboardData.getData("text").replace(/\D/g, "").slice(0, 6);
2408
- if (r.length === 0) return e;
2409
- const i = [...e];
2410
- for (let a = 0; a < r.length && a < 6; a++)
2411
- i[a] = r[a];
2412
- const n = i.join(""), o = i.every((a) => a !== "");
2413
- return t("code-change", { value: n, complete: o }), r.length === 6 && t("code-complete", { value: n }), i;
2506
+ }, us = (r, e, t) => {
2507
+ r.preventDefault();
2508
+ const s = r.clipboardData.getData("text").replace(/\D/g, "").slice(0, 6);
2509
+ if (s.length === 0) return e;
2510
+ const n = [...e];
2511
+ for (let a = 0; a < s.length && a < 6; a++)
2512
+ n[a] = s[a];
2513
+ const i = n.join(""), o = n.every((a) => a !== "");
2514
+ return t("code-change", { value: i, complete: o }), s.length === 6 && t("code-complete", { value: i }), n;
2414
2515
  };
2415
- class cr extends G {
2516
+ class ms extends G {
2416
2517
  static formAssociated = !0;
2417
2518
  static properties = {
2418
2519
  _values: { type: Array, state: !0 },
2419
2520
  disabled: { type: Boolean, reflect: !0 }
2420
2521
  };
2421
- static styles = y`
2522
+ static styles = b`
2422
2523
  :host {
2423
2524
  display: block;
2424
2525
  width: 100%;
@@ -2517,7 +2618,7 @@ class cr extends G {
2517
2618
  this.getInputs()[e]?.focus();
2518
2619
  }
2519
2620
  inputHandler(e, t) {
2520
- this._values = rr(
2621
+ this._values = cs(
2521
2622
  e,
2522
2623
  t,
2523
2624
  this._values,
@@ -2526,17 +2627,17 @@ class cr extends G {
2526
2627
  }
2527
2628
  keydownHandler(e, t) {
2528
2629
  if (t.key === "Backspace") {
2529
- const r = !this._values[e];
2530
- this._values = sr(
2630
+ const s = !this._values[e];
2631
+ this._values = ds(
2531
2632
  e,
2532
2633
  t,
2533
2634
  this._values,
2534
2635
  this.dispatchCustomEvent.bind(this)
2535
- ), r && e > 0 && this.focusInput(e - 1);
2636
+ ), s && e > 0 && this.focusInput(e - 1);
2536
2637
  }
2537
2638
  }
2538
2639
  pasteHandler(e) {
2539
- this._values = ir(e, this._values, this.dispatchCustomEvent.bind(this));
2640
+ this._values = us(e, this._values, this.dispatchCustomEvent.bind(this));
2540
2641
  }
2541
2642
  render() {
2542
2643
  return c`
@@ -2561,10 +2662,10 @@ class cr extends G {
2561
2662
  }
2562
2663
  }
2563
2664
  export {
2564
- cr as W,
2565
- lr as a,
2566
- ar as b,
2567
- ct as c,
2568
- at as d,
2569
- dt as e
2665
+ ms as W,
2666
+ gs as a,
2667
+ fs as b,
2668
+ xt as c,
2669
+ dt as d,
2670
+ vt as e
2570
2671
  };