@getcredify/credify-insurance-widget 1.5.2 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import { useState as M, useRef as O, useEffect as D, useMemo as ie, useCallback as tt, createElement as nt } from "react";
2
- import { createRoot as rt } from "react-dom/client";
3
- import { jsxs as b, jsx as o, Fragment as ze } from "react/jsx-runtime";
1
+ import { useState as M, useRef as O, useEffect as D, useMemo as ie, useCallback as nt, createElement as rt } from "react";
2
+ import { createRoot as st } from "react-dom/client";
3
+ import { jsxs as b, jsx as o, Fragment as Oe } from "react/jsx-runtime";
4
4
  (function() {
5
5
  if (typeof e > "u")
6
6
  var e = { env: {} };
@@ -17,7 +17,7 @@ function U({ id: e, label: t, hint: r, error: s, required: n, className: i, chil
17
17
  s && /* @__PURE__ */ o("p", { id: `${e}-error`, className: "mt-1 text-sm text-red-600", children: s })
18
18
  ] });
19
19
  }
20
- function st({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
20
+ function it({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
21
21
  return /* @__PURE__ */ o(U, { id: e, label: t, hint: r, error: s, required: n, className: i, children: /* @__PURE__ */ o(
22
22
  "input",
23
23
  {
@@ -31,7 +31,7 @@ function st({ id: e, label: t, hint: r, error: s, required: n, className: i, ...
31
31
  }
32
32
  ) });
33
33
  }
34
- function it({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
34
+ function at({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
35
35
  return /* @__PURE__ */ o(U, { id: e, label: t, hint: r, error: s, required: n, className: i, children: /* @__PURE__ */ o(
36
36
  "input",
37
37
  {
@@ -45,7 +45,7 @@ function it({ id: e, label: t, hint: r, error: s, required: n, className: i, ...
45
45
  }
46
46
  ) });
47
47
  }
48
- function at({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
48
+ function ot({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
49
49
  return /* @__PURE__ */ o(U, { id: e, label: t, hint: r, error: s, required: n, className: i, children: /* @__PURE__ */ o(
50
50
  "input",
51
51
  {
@@ -74,7 +74,7 @@ function be(e) {
74
74
  function ve(e) {
75
75
  return e.replace(/\D/g, "");
76
76
  }
77
- function ot({ id: e, label: t, hint: r, error: s, required: n, className: i, value: l = "", onChange: a, ...u }) {
77
+ function lt({ id: e, label: t, hint: r, error: s, required: n, className: i, value: l = "", onChange: a, ...u }) {
78
78
  const [v, k] = M(""), m = O(null), A = O(0);
79
79
  D(() => {
80
80
  if (!l) {
@@ -87,9 +87,9 @@ function ot({ id: e, label: t, hint: r, error: s, required: n, className: i, val
87
87
  k(be(Q));
88
88
  }, [l]);
89
89
  const I = (R) => {
90
- const Q = R.target, C = Q.value;
90
+ const Q = R.target, E = Q.value;
91
91
  A.current = Q.selectionStart || 0;
92
- const d = ve(C).slice(0, 10), p = be(d);
92
+ const d = ve(E).slice(0, 10), p = be(d);
93
93
  k(p);
94
94
  const c = d.length === 10 ? `+1${d}` : d, y = {
95
95
  ...R,
@@ -104,7 +104,7 @@ function ot({ id: e, label: t, hint: r, error: s, required: n, className: i, val
104
104
  };
105
105
  a?.(y), setTimeout(() => {
106
106
  if (m.current) {
107
- const w = C.slice(0, A.current), $ = ve(w), S = be($), _ = Math.min(S.length, p.length);
107
+ const w = E.slice(0, A.current), $ = ve(w), S = be($), _ = Math.min(S.length, p.length);
108
108
  m.current.setSelectionRange(_, _);
109
109
  }
110
110
  }, 0);
@@ -143,7 +143,7 @@ function ot({ id: e, label: t, hint: r, error: s, required: n, className: i, val
143
143
  }
144
144
  ) });
145
145
  }
146
- function lt({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
146
+ function ct({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
147
147
  return /* @__PURE__ */ o(U, { id: e, label: t, hint: r, error: s, required: n, className: i, children: /* @__PURE__ */ o(
148
148
  "input",
149
149
  {
@@ -159,7 +159,7 @@ function lt({ id: e, label: t, hint: r, error: s, required: n, className: i, ...
159
159
  }
160
160
  ) });
161
161
  }
162
- function ct({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
162
+ function dt({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
163
163
  return /* @__PURE__ */ o(U, { id: e, label: t, hint: r, error: s, required: n, className: i, children: /* @__PURE__ */ o(
164
164
  "input",
165
165
  {
@@ -174,7 +174,7 @@ function ct({ id: e, label: t, hint: r, error: s, required: n, className: i, ...
174
174
  }
175
175
  ) });
176
176
  }
177
- function dt({ id: e, label: t, hint: r, error: s, required: n, className: i, rows: l = 4, ...a }) {
177
+ function ut({ id: e, label: t, hint: r, error: s, required: n, className: i, rows: l = 4, ...a }) {
178
178
  return /* @__PURE__ */ o(U, { id: e, label: t, hint: r, error: s, required: n, className: i, children: /* @__PURE__ */ o(
179
179
  "textarea",
180
180
  {
@@ -188,7 +188,7 @@ function dt({ id: e, label: t, hint: r, error: s, required: n, className: i, row
188
188
  }
189
189
  ) });
190
190
  }
191
- function ut({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
191
+ function _t({ id: e, label: t, hint: r, error: s, required: n, className: i, ...l }) {
192
192
  return /* @__PURE__ */ o(U, { id: e, label: t, hint: r, error: s, required: n, className: i, children: /* @__PURE__ */ o(
193
193
  "input",
194
194
  {
@@ -208,7 +208,7 @@ function Re({ id: e, label: t, className: r, ...s }) {
208
208
  /* @__PURE__ */ o("span", { className: "checkbox-label", children: t })
209
209
  ] });
210
210
  }
211
- function _t({
211
+ function ft({
212
212
  name: e,
213
213
  value: t,
214
214
  checked: r,
@@ -220,7 +220,7 @@ function _t({
220
220
  /* @__PURE__ */ o("span", { className: "radio-label", children: n })
221
221
  ] });
222
222
  }
223
- function ft({
223
+ function mt({
224
224
  legend: e,
225
225
  children: t,
226
226
  className: r,
@@ -232,7 +232,7 @@ function ft({
232
232
  /* @__PURE__ */ o("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: t })
233
233
  ] });
234
234
  }
235
- function mt({ id: e, label: t, hint: r, error: s, required: n, className: i, placeholder: l, options: a, children: u, ...v }) {
235
+ function pt({ id: e, label: t, hint: r, error: s, required: n, className: i, placeholder: l, options: a, children: u, ...v }) {
236
236
  const k = [r ? `${e}-hint` : null, s ? `${e}-error` : null].filter(Boolean).join(" ") || void 0, m = !!u;
237
237
  return /* @__PURE__ */ o(U, { id: e, label: t, hint: r, error: s, required: n, className: i, children: /* @__PURE__ */ b(
238
238
  "select",
@@ -250,8 +250,8 @@ function mt({ id: e, label: t, hint: r, error: s, required: n, className: i, pla
250
250
  }
251
251
  ) });
252
252
  }
253
- const pt = "AIzaSyDjLdKLxoa-maLNGAyq_I_2r_Fe_TzFikw";
254
- function gt() {
253
+ const gt = "AIzaSyDjLdKLxoa-maLNGAyq_I_2r_Fe_TzFikw";
254
+ function ht() {
255
255
  return new Promise((e, t) => {
256
256
  if (window.google?.maps?.places) {
257
257
  e();
@@ -263,10 +263,10 @@ function gt() {
263
263
  return;
264
264
  }
265
265
  const s = document.createElement("script");
266
- s.src = `https://maps.googleapis.com/maps/api/js?key=${pt}&libraries=places`, s.async = !0, s.defer = !0, s.onload = () => e(), s.onerror = () => t(new Error("Failed to load Google Maps script")), document.head.appendChild(s);
266
+ s.src = `https://maps.googleapis.com/maps/api/js?key=${gt}&libraries=places`, s.async = !0, s.defer = !0, s.onload = () => e(), s.onerror = () => t(new Error("Failed to load Google Maps script")), document.head.appendChild(s);
267
267
  });
268
268
  }
269
- function ht(e) {
269
+ function yt(e) {
270
270
  const t = {
271
271
  fullAddress: e.formatted_address
272
272
  };
@@ -275,8 +275,8 @@ function ht(e) {
275
275
  s.includes("street_number") && (t.streetNumber = r.long_name), s.includes("route") && (t.streetName = r.long_name), s.includes("locality") && (t.city = r.long_name), s.includes("administrative_area_level_1") && (t.state = r.short_name), s.includes("postal_code") && (t.zipCode = r.long_name), s.includes("country") && (t.country = r.short_name);
276
276
  }), t;
277
277
  }
278
- function yt({ id: e, label: t, hint: r, error: s, required: n, className: i, onChange: l, onPlaceSelect: a, value: u, ...v }) {
279
- const k = O(null), m = O(null), A = O(null), I = O(null), [R, Q] = M(!0), [C, T] = M(u || ""), [d, p] = M([]), [c, y] = M(!1), [w, $] = M(-1), S = O([]), _ = O(!1), f = O(-1);
278
+ function bt({ id: e, label: t, hint: r, error: s, required: n, className: i, onChange: l, onPlaceSelect: a, value: u, ...v }) {
279
+ const k = O(null), m = O(null), A = O(null), I = O(null), [R, Q] = M(!0), [E, T] = M(u || ""), [d, p] = M([]), [c, y] = M(!1), [w, $] = M(-1), S = O([]), _ = O(!1), f = O(-1);
280
280
  D(() => {
281
281
  S.current = d;
282
282
  }, [d]), D(() => {
@@ -290,7 +290,7 @@ function yt({ id: e, label: t, hint: r, error: s, required: n, className: i, onC
290
290
  D(() => {
291
291
  if (!k.current) return;
292
292
  let N = !0;
293
- return gt().then(() => {
293
+ return ht().then(() => {
294
294
  !N || !k.current || (m.current = new google.maps.places.AutocompleteService(), A.current = new google.maps.places.PlacesService(document.createElement("div")), Q(!1));
295
295
  }).catch((x) => {
296
296
  console.error("Error loading Google Maps:", x), Q(!1);
@@ -334,7 +334,7 @@ function yt({ id: e, label: t, hint: r, error: s, required: n, className: i, onC
334
334
  });
335
335
  break;
336
336
  case "Enter":
337
- N.preventDefault(), f.current >= 0 && f.current < S.current.length && E(S.current[f.current]);
337
+ N.preventDefault(), f.current >= 0 && f.current < S.current.length && C(S.current[f.current]);
338
338
  break;
339
339
  case "Escape":
340
340
  N.preventDefault(), y(!1), _.current = !1;
@@ -350,7 +350,7 @@ function yt({ id: e, label: t, hint: r, error: s, required: n, className: i, onC
350
350
  document.removeEventListener("mousedown", N);
351
351
  };
352
352
  }, [c]);
353
- const E = (N) => {
353
+ const C = (N) => {
354
354
  A.current && A.current.getDetails(
355
355
  {
356
356
  placeId: N.place_id,
@@ -360,7 +360,7 @@ function yt({ id: e, label: t, hint: r, error: s, required: n, className: i, onC
360
360
  if (F === google.maps.places.PlacesServiceStatus.OK && x) {
361
361
  const K = x.formatted_address || "";
362
362
  T(K), y(!1), p([]), _.current = !1;
363
- const Z = ht(x);
363
+ const Z = yt(x);
364
364
  l?.(K, Z), a?.(x);
365
365
  }
366
366
  }
@@ -374,7 +374,7 @@ function yt({ id: e, label: t, hint: r, error: s, required: n, className: i, onC
374
374
  id: e,
375
375
  type: "text",
376
376
  className: `form-input ${s ? "input-error" : ""}`,
377
- value: C,
377
+ value: E,
378
378
  onChange: h,
379
379
  onKeyDown: B,
380
380
  "aria-invalid": !!s,
@@ -399,7 +399,7 @@ function yt({ id: e, label: t, hint: r, error: s, required: n, className: i, onC
399
399
  className: `px-4 py-3 cursor-pointer transition-colors ${x === w ? "bg-blue-50 text-slate-900" : "bg-white text-slate-900 hover:bg-slate-50"} ${x < d.length - 1 ? "border-b border-slate-100" : ""}`,
400
400
  role: "option",
401
401
  "aria-selected": x === w,
402
- onClick: () => E(N),
402
+ onClick: () => C(N),
403
403
  onMouseEnter: () => $(x),
404
404
  children: [
405
405
  /* @__PURE__ */ o("div", { className: "font-medium text-slate-900", children: N.structured_formatting.main_text }),
@@ -415,13 +415,13 @@ function yt({ id: e, label: t, hint: r, error: s, required: n, className: i, onC
415
415
  function Ne(e) {
416
416
  return e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
417
417
  }
418
- function Oe(e, t) {
418
+ function Pe(e, t) {
419
419
  return e.key ?? `${Ne(e.question)}-${t}`;
420
420
  }
421
421
  function ge(e, t) {
422
422
  const r = {}, s = (n) => n == null || typeof n == "string" && n.trim() === "";
423
423
  return e.forEach((n, i) => {
424
- const l = Oe(n, i), a = t[l];
424
+ const l = Pe(n, i), a = t[l];
425
425
  if (n.required)
426
426
  switch (n.inputType) {
427
427
  case "checkbox":
@@ -448,7 +448,7 @@ function ge(e, t) {
448
448
  }
449
449
  }), r;
450
450
  }
451
- function bt(e) {
451
+ function vt(e) {
452
452
  if (e === "" || e === null || e === void 0) return;
453
453
  const t = Number(e);
454
454
  return Number.isNaN(t) ? void 0 : t;
@@ -470,7 +470,7 @@ function Me(e, t) {
470
470
  const n = je(e), i = je(t);
471
471
  return n != null && i != null ? n - i : e == null || t == null ? null : String(e).localeCompare(String(t));
472
472
  }
473
- function vt(e, t) {
473
+ function wt(e, t) {
474
474
  return Array.isArray(e) ? e.some((r) => r === t) : typeof e == "string" ? t != null && e.includes(String(t)) : !1;
475
475
  }
476
476
  function oe(e, t, r) {
@@ -486,7 +486,7 @@ function oe(e, t, r) {
486
486
  return s != null && s > 0;
487
487
  }
488
488
  case "contains":
489
- return vt(e, r);
489
+ return wt(e, r);
490
490
  case "startsWith":
491
491
  return e != null && r != null && String(e).startsWith(String(r));
492
492
  case "endsWith":
@@ -518,11 +518,11 @@ function X(e, t, r) {
518
518
  function le(e, t, r) {
519
519
  return ke(e, [...t ?? [], r]);
520
520
  }
521
- function wt(e, t, r, s) {
521
+ function xt(e, t, r, s) {
522
522
  return X(e, [...t ?? [], r], s);
523
523
  }
524
- const xt = "__items", fe = (e) => `${e}${xt}`;
525
- function Nt(e) {
524
+ const Nt = "__items", fe = (e) => `${e}${Nt}`;
525
+ function kt(e) {
526
526
  const t = (r, s) => r.map((n, i) => {
527
527
  const l = s.length ? s.join("__") : "root", a = n.key ?? `${l}__q${i}_${String(n.question).slice(0, 24).replace(/\W+/g, "-") || "field"}`, v = (n.conditionals ?? []).map((k, m) => {
528
528
  const A = k.conditionalQuestions ? t(k.conditionalQuestions, [...s, `${a}__c${m}`]) : void 0;
@@ -535,20 +535,20 @@ function Nt(e) {
535
535
  function J(e) {
536
536
  return e == null ? "" : typeof e == "string" ? e : String(e);
537
537
  }
538
- function kt(e) {
538
+ function St(e) {
539
539
  return e == null ? "" : typeof e == "number" && Number.isFinite(e) || typeof e == "string" ? e : "";
540
540
  }
541
- function St(e) {
541
+ function $t(e) {
542
542
  return e == null ? "" : typeof e == "string" || typeof e == "number" ? e : String(e);
543
543
  }
544
- function $t({
544
+ function At({
545
545
  questions: e,
546
546
  initialValues: t,
547
547
  controlledValues: r,
548
548
  onChangeValues: s,
549
549
  onSubmit: n
550
550
  }) {
551
- const i = ie(() => Nt(e), [e]), l = ie(() => {
551
+ const i = ie(() => kt(e), [e]), l = ie(() => {
552
552
  const d = {};
553
553
  return t && Object.assign(d, t), d;
554
554
  }, [t]), [a, u] = M(l);
@@ -565,24 +565,24 @@ function $t({
565
565
  const [A, I] = M({});
566
566
  function R(d, p) {
567
567
  const c = d.key, y = d.question, w = le(m, p, c), $ = A[c], S = (_) => {
568
- let f = wt(m, p, c, _);
568
+ let f = xt(m, p, c, _);
569
569
  if (d.inputType === "radio" && d.conditionals) {
570
570
  const g = d.conditionals ?? [];
571
571
  for (const h of g) {
572
- const B = le(m, p, c), E = oe(B, h.conditionalType, h.conditionalValue), N = oe(_, h.conditionalType, h.conditionalValue);
573
- if (E && !N && h.conditionalQuestionsAllowMultiple) {
572
+ const B = le(m, p, c), C = oe(B, h.conditionalType, h.conditionalValue), N = oe(_, h.conditionalType, h.conditionalValue);
573
+ if (C && !N && h.conditionalQuestionsAllowMultiple) {
574
574
  const x = h.conditionalQuestions ?? [];
575
575
  if (x.length > 0) {
576
576
  const F = fe(c);
577
577
  f = X(f, [...p ?? [], F], []);
578
578
  const K = (Z, q) => {
579
- Z.forEach((W) => {
580
- (W.conditionals ?? []).forEach((L) => {
581
- if (L.conditionalQuestionsAllowMultiple) {
582
- const ee = fe(W.key);
579
+ Z.forEach((L) => {
580
+ (L.conditionals ?? []).forEach((W) => {
581
+ if (W.conditionalQuestionsAllowMultiple) {
582
+ const ee = fe(L.key);
583
583
  f = X(f, [...q, ee], []);
584
584
  }
585
- const z = L.conditionalQuestions ?? [];
585
+ const z = W.conditionalQuestions ?? [];
586
586
  z.length > 0 && K(z, q);
587
587
  });
588
588
  });
@@ -597,7 +597,7 @@ function $t({
597
597
  switch (d.inputType) {
598
598
  case "text":
599
599
  return /* @__PURE__ */ o(
600
- st,
600
+ it,
601
601
  {
602
602
  id: c,
603
603
  label: y,
@@ -610,7 +610,7 @@ function $t({
610
610
  );
611
611
  case "email":
612
612
  return /* @__PURE__ */ o(
613
- at,
613
+ ot,
614
614
  {
615
615
  id: c,
616
616
  label: y,
@@ -623,7 +623,7 @@ function $t({
623
623
  );
624
624
  case "password":
625
625
  return /* @__PURE__ */ o(
626
- ct,
626
+ dt,
627
627
  {
628
628
  id: c,
629
629
  label: y,
@@ -635,9 +635,9 @@ function $t({
635
635
  c
636
636
  );
637
637
  case "tel":
638
- return /* @__PURE__ */ b(ze, { children: [
638
+ return /* @__PURE__ */ b(Oe, { children: [
639
639
  /* @__PURE__ */ o(
640
- ot,
640
+ lt,
641
641
  {
642
642
  id: c,
643
643
  label: y,
@@ -665,7 +665,7 @@ function $t({
665
665
  ] });
666
666
  case "url":
667
667
  return /* @__PURE__ */ o(
668
- lt,
668
+ ct,
669
669
  {
670
670
  id: c,
671
671
  label: y,
@@ -678,12 +678,12 @@ function $t({
678
678
  );
679
679
  case "number":
680
680
  return /* @__PURE__ */ o(
681
- it,
681
+ at,
682
682
  {
683
683
  id: c,
684
684
  label: y,
685
- value: kt(w),
686
- onChange: (_) => S(bt(_.currentTarget.value)),
685
+ value: St(w),
686
+ onChange: (_) => S(vt(_.currentTarget.value)),
687
687
  "aria-required": d.required || void 0,
688
688
  error: $
689
689
  },
@@ -691,7 +691,7 @@ function $t({
691
691
  );
692
692
  case "textarea":
693
693
  return /* @__PURE__ */ o(
694
- dt,
694
+ ut,
695
695
  {
696
696
  id: c,
697
697
  label: y,
@@ -705,7 +705,7 @@ function $t({
705
705
  );
706
706
  case "date":
707
707
  return /* @__PURE__ */ o(
708
- ut,
708
+ _t,
709
709
  {
710
710
  id: c,
711
711
  label: y,
@@ -733,8 +733,8 @@ function $t({
733
733
  label: f,
734
734
  checked: h,
735
735
  onChange: (B) => {
736
- const E = new Set(_);
737
- B.currentTarget.checked ? E.add(f) : E.delete(f), S(Array.from(E));
736
+ const C = new Set(_);
737
+ B.currentTarget.checked ? C.add(f) : C.delete(f), S(Array.from(C));
738
738
  },
739
739
  "aria-required": d.required || void 0
740
740
  },
@@ -758,18 +758,18 @@ function $t({
758
758
  }
759
759
  case "radio": {
760
760
  const _ = d.options ?? [], f = p && p.length > 0 ? `${c}__${p.join("__")}` : c;
761
- return /* @__PURE__ */ o(ft, { legend: y, legendClassName: d.required ? "legend-required" : void 0, children: _.map((g) => /* @__PURE__ */ o(_t, { name: f, value: g, checked: w === g, onChange: () => S(g), children: g }, `${c}-${Ne(g)}`)) }, c);
761
+ return /* @__PURE__ */ o(mt, { legend: y, legendClassName: d.required ? "legend-required" : void 0, children: _.map((g) => /* @__PURE__ */ o(ft, { name: f, value: g, checked: w === g, onChange: () => S(g), children: g }, `${c}-${Ne(g)}`)) }, c);
762
762
  }
763
763
  case "select": {
764
764
  let _ = d.options ?? [];
765
765
  return c === "quote_vehicle_id" && (_ = r?.vehicles__items?.map((f) => f.vin) ?? []), /* @__PURE__ */ o(
766
- mt,
766
+ pt,
767
767
  {
768
768
  id: c,
769
769
  label: y,
770
770
  "aria-required": d.required || void 0,
771
771
  error: $,
772
- value: St(w),
772
+ value: $t(w),
773
773
  onChange: (f) => S(f.currentTarget.value),
774
774
  placeholder: "Select an option",
775
775
  options: _.map((f) => ({ value: f, label: f }))
@@ -779,7 +779,7 @@ function $t({
779
779
  }
780
780
  case "address":
781
781
  return /* @__PURE__ */ o(
782
- yt,
782
+ bt,
783
783
  {
784
784
  id: c,
785
785
  label: y,
@@ -802,15 +802,15 @@ function $t({
802
802
  return /* @__PURE__ */ b("div", { children: [
803
803
  $,
804
804
  g.map((h, B) => {
805
- const E = h.conditionalQuestions ?? [];
806
- if (!E.length) return null;
805
+ const C = h.conditionalQuestions ?? [];
806
+ if (!C.length) return null;
807
807
  if (!h.conditionalQuestionsAllowMultiple)
808
- return /* @__PURE__ */ o("div", { className: "mt-3", children: Q(E, p) }, `branch-${w}-${B}`);
808
+ return /* @__PURE__ */ o("div", { className: "mt-3", children: Q(C, p) }, `branch-${w}-${B}`);
809
809
  const N = fe(w), x = ke(m, [...p ?? [], N]) ?? [], F = Math.max(1, x.length || 1), K = () => {
810
- const W = X(m, [...p ?? [], N, x.length], {});
811
- r && s ? s(W) : u(W), k(W);
810
+ const L = X(m, [...p ?? [], N, x.length], {});
811
+ r && s ? s(L) : u(L), k(L);
812
812
  }, Z = () => {
813
- const W = x.slice(0, Math.max(0, x.length - 1)), V = X(m, [...p ?? [], N], W);
813
+ const L = x.slice(0, Math.max(0, x.length - 1)), V = X(m, [...p ?? [], N], L);
814
814
  r && s ? s(V) : u(V), k(V);
815
815
  }, q = `${w}__c${B}`;
816
816
  return /* @__PURE__ */ b("div", { className: "mt-3", children: [
@@ -821,47 +821,47 @@ function $t({
821
821
  F > 1 && /* @__PURE__ */ o("button", { type: "button", className: "btn-outline px-3 py-1", onClick: Z, children: "Remove last" })
822
822
  ] })
823
823
  ] }),
824
- Array.from({ length: F }).map((W, V) => {
825
- const L = [...p ?? [], N, V], z = `${q}__i${V}`;
824
+ Array.from({ length: F }).map((L, V) => {
825
+ const W = [...p ?? [], N, V], z = `${q}__i${V}`;
826
826
  return /* @__PURE__ */ b("div", { className: "rounded-lg border p-3 mb-3", children: [
827
827
  /* @__PURE__ */ b("div", { className: "text-sm font-semibold mb-2", children: [
828
828
  "Entry #",
829
829
  V + 1
830
830
  ] }),
831
- E.map((ee) => /* @__PURE__ */ b("div", { className: "mt-3", children: [
832
- R(ee, L),
831
+ C.map((ee) => /* @__PURE__ */ b("div", { className: "mt-3", children: [
832
+ R(ee, W),
833
833
  (() => {
834
834
  const Te = ee.conditionals ?? [];
835
835
  if (!Te.length) return null;
836
- const Xe = le(m, L, ee.key), de = Te.filter((te) => oe(Xe, te.conditionalType, te.conditionalValue));
836
+ const Ze = le(m, W, ee.key), de = Te.filter((te) => oe(Ze, te.conditionalType, te.conditionalValue));
837
837
  return (de.length > 1 && !de.some((te) => te.conditionalQuestionsAllowMultiple) ? de.slice(0, 1) : de).map((te, he) => {
838
838
  const ye = te.conditionalQuestions ?? [];
839
839
  if (!ye.length) return null;
840
840
  if (!te.conditionalQuestionsAllowMultiple)
841
- return /* @__PURE__ */ o("div", { className: "mt-3", children: Q(ye, L) }, `nested-${z}-${he}`);
842
- const ue = fe(ee.key), _e = ke(m, [...L, ue]) ?? [], Ie = Math.max(1, _e.length || 1), Ze = () => {
843
- const se = X(m, [...L, ue, _e.length], {});
841
+ return /* @__PURE__ */ o("div", { className: "mt-3", children: Q(ye, W) }, `nested-${z}-${he}`);
842
+ const ue = fe(ee.key), _e = ke(m, [...W, ue]) ?? [], Ie = Math.max(1, _e.length || 1), qe = () => {
843
+ const se = X(m, [...W, ue, _e.length], {});
844
844
  r && s ? s(se) : u(se), k(se);
845
- }, qe = () => {
846
- const se = _e.slice(0, Math.max(0, _e.length - 1)), ne = X(m, [...L, ue], se);
845
+ }, et = () => {
846
+ const se = _e.slice(0, Math.max(0, _e.length - 1)), ne = X(m, [...W, ue], se);
847
847
  r && s ? s(ne) : u(ne), k(ne);
848
848
  };
849
849
  return /* @__PURE__ */ b("div", { className: "mt-3", children: [
850
850
  /* @__PURE__ */ b("div", { className: "flex items-center justify-between mb-2", children: [
851
851
  /* @__PURE__ */ o("div", { className: "text-sm font-medium opacity-75", children: "Add one or more entries" }),
852
852
  /* @__PURE__ */ b("div", { className: "space-x-2", children: [
853
- /* @__PURE__ */ o("button", { type: "button", className: "btn-outline px-3 py-1", onClick: Ze, children: "Add another" }),
854
- Ie > 1 && /* @__PURE__ */ o("button", { type: "button", className: "btn-outline px-3 py-1", onClick: qe, children: "Remove last" })
853
+ /* @__PURE__ */ o("button", { type: "button", className: "btn-outline px-3 py-1", onClick: qe, children: "Add another" }),
854
+ Ie > 1 && /* @__PURE__ */ o("button", { type: "button", className: "btn-outline px-3 py-1", onClick: et, children: "Remove last" })
855
855
  ] })
856
856
  ] }),
857
857
  Array.from({ length: Ie }).map((se, ne) => {
858
- const et = [...L, ue, ne];
858
+ const tt = [...W, ue, ne];
859
859
  return /* @__PURE__ */ b("div", { className: "rounded-lg border p-3 mb-3", children: [
860
860
  /* @__PURE__ */ b("div", { className: "text-sm font-semibold mb-2", children: [
861
861
  "Entry #",
862
862
  ne + 1
863
863
  ] }),
864
- Q(ye, et)
864
+ Q(ye, tt)
865
865
  ] }, `nested-item-${z}-${he}-${ne}`);
866
866
  })
867
867
  ] }, `nested-repeat-${z}-${he}`);
@@ -875,7 +875,7 @@ function $t({
875
875
  ] }, `wrap-${w}-${y}`);
876
876
  });
877
877
  }
878
- const C = ie(() => {
878
+ const E = ie(() => {
879
879
  const d = [], p = (c, y) => {
880
880
  c.forEach((w) => {
881
881
  d.push(w);
@@ -892,10 +892,10 @@ function $t({
892
892
  }, [i, m]);
893
893
  function T(d) {
894
894
  d.preventDefault();
895
- const p = ge(C, m);
895
+ const p = ge(E, m);
896
896
  if (I(p), Object.keys(p).length > 0) {
897
- const c = C.findIndex((y) => p[y.key]);
898
- c >= 0 && document.getElementById(C[c].key)?.focus();
897
+ const c = E.findIndex((y) => p[y.key]);
898
+ c >= 0 && document.getElementById(E[c].key)?.focus();
899
899
  return;
900
900
  }
901
901
  n(m);
@@ -919,10 +919,10 @@ function De(e, t) {
919
919
  const n = Fe(e), i = Fe(t);
920
920
  return n != null && i != null ? n - i : e == null || t == null ? null : String(e).localeCompare(String(t));
921
921
  }
922
- function At(e, t) {
922
+ function Et(e, t) {
923
923
  return Array.isArray(e) ? e.some((r) => r === t) : typeof e == "string" ? t != null && e.includes(String(t)) : !1;
924
924
  }
925
- function Pe(e, t, r) {
925
+ function Ue(e, t, r) {
926
926
  switch (t) {
927
927
  case "equals":
928
928
  return e === r;
@@ -935,7 +935,7 @@ function Pe(e, t, r) {
935
935
  return s != null && s > 0;
936
936
  }
937
937
  case "contains":
938
- return At(e, r);
938
+ return Et(e, r);
939
939
  case "startsWith":
940
940
  return e != null && r != null && String(e).startsWith(String(r));
941
941
  case "endsWith":
@@ -951,7 +951,7 @@ function Ke(e, t) {
951
951
  r.push(i);
952
952
  const l = String(i.key), a = t[l], u = i.conditionals ?? [];
953
953
  if (!u.length) return;
954
- const v = u.filter((m) => Pe(a, m.conditionalType, m.conditionalValue));
954
+ const v = u.filter((m) => Ue(a, m.conditionalType, m.conditionalValue));
955
955
  (v.length > 1 && !v.some((m) => m.conditionalQuestionsAllowMultiple) ? v.slice(0, 1) : v).forEach((m) => {
956
956
  const A = m.conditionalQuestions ?? [];
957
957
  A.length && (m.conditionalQuestionsAllowMultiple || A.forEach((I) => r.push(I)));
@@ -959,12 +959,12 @@ function Ke(e, t) {
959
959
  });
960
960
  })(e), r;
961
961
  }
962
- const Ue = "__items", Ve = (e) => `${e}${Ue}`;
962
+ const Ve = "__items", Ye = (e) => `${e}${Ve}`;
963
963
  function Se(e, t) {
964
964
  for (const r of e) {
965
965
  const s = String(r.key), n = t[s], i = r.conditionals ?? [];
966
966
  if (!i.length) continue;
967
- const l = i.filter((u) => Pe(n, u.conditionalType, u.conditionalValue)), a = l.length > 1 && !l.some((u) => u.conditionalQuestionsAllowMultiple) ? l.slice(0, 1) : l;
967
+ const l = i.filter((u) => Ue(n, u.conditionalType, u.conditionalValue)), a = l.length > 1 && !l.some((u) => u.conditionalQuestionsAllowMultiple) ? l.slice(0, 1) : l;
968
968
  for (const u of a) {
969
969
  const v = u.conditionalQuestions ?? [];
970
970
  if (!v.length) continue;
@@ -972,7 +972,7 @@ function Se(e, t) {
972
972
  if (Se(v, t)) return !0;
973
973
  continue;
974
974
  }
975
- const k = t[Ve(s)] ?? [];
975
+ const k = t[Ye(s)] ?? [];
976
976
  if (k.length === 0) return !0;
977
977
  for (const m of k) {
978
978
  const A = ge(v, m);
@@ -982,7 +982,7 @@ function Se(e, t) {
982
982
  }
983
983
  return !1;
984
984
  }
985
- function Le(e, t) {
985
+ function We(e, t) {
986
986
  return Se(e, t);
987
987
  }
988
988
  function Ct({
@@ -992,7 +992,7 @@ function Ct({
992
992
  initialValues: s,
993
993
  initialActive: n
994
994
  }) {
995
- const [i, l] = M(n ?? 0), [a, u] = M(s ?? {}), [v, k] = M({}), [m, A] = M(!1), [I, R] = M(!1), [Q, C] = M(null), T = O([]), d = Array.isArray(e) && e.length > 0, p = d ? e[Math.min(i, e.length - 1)] : null, c = p?.key ?? null;
995
+ const [i, l] = M(n ?? 0), [a, u] = M(s ?? {}), [v, k] = M({}), [m, A] = M(!1), [I, R] = M(!1), [Q, E] = M(null), T = O([]), d = Array.isArray(e) && e.length > 0, p = d ? e[Math.min(i, e.length - 1)] : null, c = p?.key ?? null;
996
996
  D(() => {
997
997
  n !== void 0 && l(n);
998
998
  }, [n]), D(() => {
@@ -1002,21 +1002,21 @@ function Ct({
1002
1002
  s !== void 0 && u(s);
1003
1003
  }, [s]), D(() => {
1004
1004
  if (!p || !c) {
1005
- A(!1), C(null);
1005
+ A(!1), E(null);
1006
1006
  return;
1007
1007
  }
1008
1008
  if (v[c]) {
1009
- A(!1), C(null);
1009
+ A(!1), E(null);
1010
1010
  return;
1011
1011
  }
1012
1012
  let g = !1;
1013
- return A(!0), C(null), Promise.resolve(p.loadQuestions()).then((h) => {
1013
+ return A(!0), E(null), Promise.resolve(p.loadQuestions()).then((h) => {
1014
1014
  if (!g) {
1015
1015
  if (!Array.isArray(h)) throw new Error(`loadQuestions("${c}") did not return an array`);
1016
1016
  k((B) => ({ ...B, [c]: h }));
1017
1017
  }
1018
1018
  }).catch((h) => {
1019
- g || C(`Failed to load stage "${p?.title ?? ""}": ${h?.message ?? "Unknown error"}`);
1019
+ g || E(`Failed to load stage "${p?.title ?? ""}": ${h?.message ?? "Unknown error"}`);
1020
1020
  }).finally(() => {
1021
1021
  g || A(!1);
1022
1022
  }), () => {
@@ -1026,24 +1026,24 @@ function Ct({
1026
1026
  const y = c ? v[c] : void 0, w = ie(() => {
1027
1027
  if (!y) return {};
1028
1028
  const g = {};
1029
- ((E) => {
1029
+ ((C) => {
1030
1030
  const N = [], x = (F) => {
1031
1031
  F.forEach((K, Z) => {
1032
- const q = Oe(K, Z);
1032
+ const q = Pe(K, Z);
1033
1033
  N.push(q);
1034
- const W = Ve(q);
1035
- N.push(W), (K.conditionals ?? []).forEach((L) => {
1036
- const z = L.conditionalQuestions ?? [];
1034
+ const L = Ye(q);
1035
+ N.push(L), (K.conditionals ?? []).forEach((W) => {
1036
+ const z = W.conditionalQuestions ?? [];
1037
1037
  z.length > 0 && x(z);
1038
1038
  });
1039
1039
  });
1040
1040
  };
1041
- return x(E), N;
1042
- })(y).forEach((E) => {
1043
- E in a && (g[E] = a[E]);
1041
+ return x(C), N;
1042
+ })(y).forEach((C) => {
1043
+ C in a && (g[C] = a[C]);
1044
1044
  });
1045
- for (const [E, N] of Object.entries(a))
1046
- E.endsWith(Ue) && !(E in g) && (g[E] = N);
1045
+ for (const [C, N] of Object.entries(a))
1046
+ C.endsWith(Ve) && !(C in g) && (g[C] = N);
1047
1047
  return g;
1048
1048
  }, [y, a]), $ = (g) => {
1049
1049
  u((h) => ({ ...h, ...g }));
@@ -1051,13 +1051,13 @@ function Ct({
1051
1051
  l((g) => g > 0 ? g - 1 : 0), document.querySelector(".panel-body")?.scrollTo({ top: 0, behavior: "instant" });
1052
1052
  }, _ = async () => {
1053
1053
  if (!y || !p || m || Q || I) return;
1054
- const g = Ke(y, a), h = ge(g, a), B = Object.values(h).some(Boolean), E = Le(y, a);
1055
- if (!(B || E)) {
1054
+ const g = Ke(y, a), h = ge(g, a), B = Object.values(h).some(Boolean), C = We(y, a);
1055
+ if (!(B || C)) {
1056
1056
  R(!0);
1057
1057
  try {
1058
1058
  const N = Math.min(i + 1, e.length - 1), x = i >= e.length - 1, { success: F, error: K } = x ? await r(a, c ?? "") : await t(w, c ?? "");
1059
1059
  if (!F) {
1060
- C(K ?? "An error occurred");
1060
+ E(K ?? "An error occurred");
1061
1061
  return;
1062
1062
  }
1063
1063
  x || l(N);
@@ -1067,8 +1067,8 @@ function Ct({
1067
1067
  }
1068
1068
  }, f = ie(() => {
1069
1069
  if (!y || m || Q || I) return !0;
1070
- const g = Ke(y, a), h = ge(g, a), B = Object.values(h).some(Boolean), E = Le(y, a);
1071
- return B || E;
1070
+ const g = Ke(y, a), h = ge(g, a), B = Object.values(h).some(Boolean), C = We(y, a);
1071
+ return B || C;
1072
1072
  }, [y, a, m, Q, I]);
1073
1073
  return d ? /* @__PURE__ */ b("div", { className: "space-y-6", children: [
1074
1074
  /* @__PURE__ */ b("div", { className: "flex items-center justify-between gap-4", children: [
@@ -1104,7 +1104,7 @@ function Ct({
1104
1104
  /* @__PURE__ */ b("div", { children: [
1105
1105
  m && /* @__PURE__ */ o("div", { className: "text-slate-500", children: "Loading…" }),
1106
1106
  p && /* @__PURE__ */ o(
1107
- $t,
1107
+ At,
1108
1108
  {
1109
1109
  questions: y ?? [],
1110
1110
  controlledValues: w,
@@ -1175,66 +1175,66 @@ function Ct({
1175
1175
  ] })
1176
1176
  ] }) : /* @__PURE__ */ o("div", { className: "text-slate-600", children: "Loading..." });
1177
1177
  }
1178
- const Ce = "credify_quote_id", Ee = "credify_auth_token";
1179
- function Et(e) {
1178
+ const Ee = "credify_quote_id", Ce = "credify_auth_token";
1179
+ function Tt(e) {
1180
1180
  try {
1181
- localStorage.setItem(Ce, e);
1181
+ localStorage.setItem(Ee, e);
1182
1182
  } catch (t) {
1183
1183
  console.error("Failed to save quoteId to localStorage:", t);
1184
1184
  }
1185
1185
  }
1186
- function Tt() {
1186
+ function It() {
1187
1187
  try {
1188
- return localStorage.getItem(Ce);
1188
+ return localStorage.getItem(Ee);
1189
1189
  } catch (e) {
1190
1190
  return console.error("Failed to load quoteId from localStorage:", e), null;
1191
1191
  }
1192
1192
  }
1193
- function Ye() {
1193
+ function Ge() {
1194
1194
  try {
1195
- localStorage.removeItem(Ce);
1195
+ localStorage.removeItem(Ee);
1196
1196
  } catch (e) {
1197
1197
  console.error("Failed to clear quoteId from localStorage:", e);
1198
1198
  }
1199
1199
  }
1200
- function It(e) {
1200
+ function Rt(e) {
1201
1201
  try {
1202
- localStorage.setItem(Ee, e);
1202
+ localStorage.setItem(Ce, e);
1203
1203
  } catch (t) {
1204
1204
  console.error("Failed to save authToken to localStorage:", t);
1205
1205
  }
1206
1206
  }
1207
- function Rt() {
1207
+ function Qt() {
1208
1208
  try {
1209
- return localStorage.getItem(Ee);
1209
+ return localStorage.getItem(Ce);
1210
1210
  } catch (e) {
1211
1211
  return console.error("Failed to load authToken from localStorage:", e), null;
1212
1212
  }
1213
1213
  }
1214
- function Ge() {
1214
+ function He() {
1215
1215
  try {
1216
- localStorage.removeItem(Ee);
1216
+ localStorage.removeItem(Ce);
1217
1217
  } catch (e) {
1218
1218
  console.error("Failed to clear authToken from localStorage:", e);
1219
1219
  }
1220
1220
  }
1221
- function Qt() {
1222
- Ye(), Ge();
1221
+ function jt() {
1222
+ Ge(), He();
1223
1223
  }
1224
1224
  const G = "https://api.getcredify.com";
1225
1225
  let ae = null;
1226
- function jt(e) {
1227
- ae = e, It(e);
1226
+ function Mt(e) {
1227
+ ae = e, Rt(e);
1228
1228
  }
1229
1229
  function me() {
1230
1230
  return ae;
1231
1231
  }
1232
1232
  function $e() {
1233
- const e = Rt();
1233
+ const e = Qt();
1234
1234
  e && (ae = e);
1235
1235
  }
1236
- function He() {
1237
- ae = null, Ge();
1236
+ function Je() {
1237
+ ae = null, He();
1238
1238
  }
1239
1239
  async function H(e, t) {
1240
1240
  const r = {
@@ -1258,13 +1258,13 @@ async function H(e, t) {
1258
1258
  }
1259
1259
  return s;
1260
1260
  }
1261
- async function Mt(e) {
1261
+ async function Bt(e) {
1262
1262
  return await (await H(`${G}/get-questions-by-stage`, { stage: e })).json();
1263
1263
  }
1264
1264
  async function we() {
1265
1265
  return await (await H(`${G}/get-stages-for-quote`, {})).json();
1266
1266
  }
1267
- async function Bt(e) {
1267
+ async function Ft(e) {
1268
1268
  const r = await (await H(`${G}/create-quote`, { phone: e })).json();
1269
1269
  if (!r || typeof r != "object" || !r.quoteId)
1270
1270
  throw new Error(`Invalid createQuote response: ${JSON.stringify(r)}`);
@@ -1274,28 +1274,28 @@ async function ce(e, t, r) {
1274
1274
  const s = { payload: e, getRates: t };
1275
1275
  return r && typeof r == "string" && r.trim() !== "" && (s.quoteId = r), await (await H(`${G}/update-quote`, s)).json();
1276
1276
  }
1277
- async function Ft(e, t) {
1277
+ async function Dt(e, t) {
1278
1278
  return await (await H(`${G}/verify-quote`, { quoteId: e, smsCode: t })).json();
1279
1279
  }
1280
- async function Dt(e) {
1280
+ async function Kt(e) {
1281
1281
  return await (await H(`${G}/is-supported-state`, { state: e })).json();
1282
1282
  }
1283
- async function Kt() {
1283
+ async function Wt() {
1284
1284
  return await (await H(`${G}/get-rates`, {})).json();
1285
1285
  }
1286
1286
  async function Lt(e) {
1287
1287
  const t = e ? { quoteId: e } : {};
1288
1288
  return await (await H(`${G}/get-quote`, t)).json();
1289
1289
  }
1290
- async function Wt(e) {
1290
+ async function zt(e) {
1291
1291
  const r = await (await H(`${G}/request-bind`, { quoteRateId: e })).json();
1292
1292
  return r && typeof r == "object" && "success" in r ? r : { success: !0 };
1293
1293
  }
1294
- const zt = new Intl.NumberFormat("en-US", {
1294
+ const Ot = new Intl.NumberFormat("en-US", {
1295
1295
  style: "currency",
1296
1296
  currency: "USD"
1297
1297
  });
1298
- function We({ onBack: e }) {
1298
+ function Le({ onBack: e }) {
1299
1299
  return /* @__PURE__ */ o(
1300
1300
  "button",
1301
1301
  {
@@ -1306,20 +1306,20 @@ function We({ onBack: e }) {
1306
1306
  }
1307
1307
  );
1308
1308
  }
1309
- function Ot({ rates: e, onBack: t }) {
1309
+ function Pt({ rates: e, onBack: t }) {
1310
1310
  const r = Array.isArray(e) && e.length > 0, [s, n] = M({});
1311
1311
  return D(() => {
1312
1312
  $e();
1313
1313
  }, []), r ? /* @__PURE__ */ b("section", { className: "mt-8", children: [
1314
1314
  /* @__PURE__ */ o("h3", { className: "text-lg font-semibold text-slate-900", children: "Rates" }),
1315
1315
  /* @__PURE__ */ o("div", { className: "mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3", children: e.map((i) => {
1316
- const l = i.premium_cents / 100, a = zt.format(l), u = i.quote_rate_id, v = s[u] ?? "idle", k = v === "loading", m = v === "success", A = async () => {
1316
+ const l = i.premium_cents / 100, a = Ot.format(l), u = i.quote_rate_id, v = s[u] ?? "idle", k = v === "loading", m = v === "success", A = async () => {
1317
1317
  n((I) => ({ ...I, [u]: "loading" }));
1318
1318
  try {
1319
1319
  if ($e(), !me())
1320
1320
  throw new Error("Authentication required. Please verify your phone number first.");
1321
- if (!((await Wt(i.quote_rate_id))?.success !== !1)) throw new Error("Request failed");
1322
- Qt(), He(), n((C) => ({ ...C, [u]: "success" }));
1321
+ if (!((await zt(i.quote_rate_id))?.success !== !1)) throw new Error("Request failed");
1322
+ jt(), Je(), n((E) => ({ ...E, [u]: "success" }));
1323
1323
  } catch {
1324
1324
  n((I) => ({ ...I, [u]: "error" }));
1325
1325
  }
@@ -1360,11 +1360,11 @@ function Ot({ rates: e, onBack: t }) {
1360
1360
  ] })
1361
1361
  ] }, u);
1362
1362
  }) }),
1363
- t && /* @__PURE__ */ o(We, { onBack: t })
1363
+ t && /* @__PURE__ */ o(Le, { onBack: t })
1364
1364
  ] }) : /* @__PURE__ */ b("section", { className: "mt-8", children: [
1365
1365
  /* @__PURE__ */ o("h3", { className: "text-lg font-semibold text-slate-900", children: "Rates" }),
1366
1366
  /* @__PURE__ */ o("p", { className: "mt-2 text-sm text-slate-500", children: "No rates are available at this time." }),
1367
- t && /* @__PURE__ */ o(We, { onBack: t })
1367
+ t && /* @__PURE__ */ o(Le, { onBack: t })
1368
1368
  ] });
1369
1369
  }
1370
1370
  function j(e) {
@@ -1380,7 +1380,7 @@ function P(e) {
1380
1380
  return;
1381
1381
  }
1382
1382
  }
1383
- function Pt(e) {
1383
+ function Ut(e) {
1384
1384
  const t = {};
1385
1385
  e.phone && (t.phone = e.phone), e.first_name && (t.first_name = e.first_name), e.last_name && (t.last_name = e.last_name), e.email && (t.email = e.email), e.date_of_birth && (t.date_of_birth = P(e.date_of_birth)), e.product && (t.product = e.product), e.state && (t.state = e.state);
1386
1386
  const r = [];
@@ -1438,24 +1438,24 @@ function Ae(e) {
1438
1438
  } else i.includes("__items") || n.has(i) || (t[i] = r(l));
1439
1439
  return t;
1440
1440
  }
1441
- function Ut({ isOpen: e, onClose: t }) {
1441
+ function Vt({ isOpen: e, onClose: t }) {
1442
1442
  const [r, s] = M([]), [n, i] = M(null), [l, a] = M(null), [u, v] = M(null), [k, m] = M(void 0), [A, I] = M(!1);
1443
- function R(C) {
1443
+ function R(E) {
1444
1444
  const T = {
1445
1445
  SMSVerification: "Verify",
1446
1446
  AutoCurrentCarrier: "Current Auto Policy",
1447
1447
  HomeCurrentCarrier: "Current Home Policy"
1448
1448
  };
1449
- return C.map((d) => ({
1449
+ return E.map((d) => ({
1450
1450
  key: d,
1451
1451
  title: T[d] || d,
1452
- loadQuestions: async () => (await Mt(d)).questions
1452
+ loadQuestions: async () => (await Bt(d)).questions
1453
1453
  }));
1454
1454
  }
1455
1455
  D(() => {
1456
1456
  e && (async () => {
1457
1457
  try {
1458
- const T = Tt();
1458
+ const T = It();
1459
1459
  if ($e(), T) {
1460
1460
  I(!0), i(T);
1461
1461
  try {
@@ -1465,7 +1465,7 @@ function Ut({ isOpen: e, onClose: t }) {
1465
1465
  const { quote: c } = p, { stages: y } = await we(), w = R(y);
1466
1466
  s(w);
1467
1467
  try {
1468
- const $ = Pt(c);
1468
+ const $ = Ut(c);
1469
1469
  v($);
1470
1470
  } catch ($) {
1471
1471
  throw new Error(`Failed to transform quote data: ${$ instanceof Error ? $.message : "Unknown error"}`);
@@ -1476,7 +1476,7 @@ function Ut({ isOpen: e, onClose: t }) {
1476
1476
  } else
1477
1477
  m(w.length - 1);
1478
1478
  } catch (d) {
1479
- d.statusCode === 404 ? (Ye(), i(null)) : He();
1479
+ d.statusCode === 404 ? (Ge(), i(null)) : Je();
1480
1480
  } finally {
1481
1481
  I(!1);
1482
1482
  }
@@ -1490,14 +1490,14 @@ function Ut({ isOpen: e, onClose: t }) {
1490
1490
  })();
1491
1491
  }, [e]), D(() => {
1492
1492
  if (!e) return;
1493
- const { overflow: C } = document.body.style;
1493
+ const { overflow: E } = document.body.style;
1494
1494
  return document.body.style.overflow = "hidden", () => {
1495
- document.body.style.overflow = C;
1495
+ document.body.style.overflow = E;
1496
1496
  };
1497
1497
  }, [e]);
1498
- const Q = tt(
1499
- (C) => {
1500
- C.key === "Escape" && t();
1498
+ const Q = nt(
1499
+ (E) => {
1500
+ E.key === "Escape" && t();
1501
1501
  },
1502
1502
  [t]
1503
1503
  );
@@ -1507,103 +1507,107 @@ function Ut({ isOpen: e, onClose: t }) {
1507
1507
  }, [e, Q]), D(() => {
1508
1508
  e || (v(null), m(void 0), I(!1));
1509
1509
  }, [e]), e ? /* @__PURE__ */ b("div", { className: "fixed inset-0 z-[9999] flex items-center justify-center", role: "dialog", "aria-modal": "true", "aria-labelledby": "insurance-modal-title", children: [
1510
- /* @__PURE__ */ o("div", { className: "backdrop", style: { background: "rgba(0, 0, 0, 0.5)" }, onClick: t, "aria-hidden": "true" }),
1511
- /* @__PURE__ */ b(
1512
- "div",
1513
- {
1514
- className: "modal-panel bg-white relative w-full max-w-2xl flex flex-col max-h-[90vh] overflow-hidden",
1515
- style: { background: "#ffffff" },
1516
- role: "document",
1517
- children: [
1518
- /* @__PURE__ */ o("button", { onClick: t, className: "absolute top-4 right-4 text-slate-400 hover:text-slate-600 text-xl", "aria-label": "Close", type: "button", children: "×" }),
1519
- /* @__PURE__ */ b("div", { className: "text-center mb-6", children: [
1520
- /* @__PURE__ */ o("h2", { id: "insurance-modal-title", className: "h1-title", children: "Let's get you the best insurance rates." }),
1521
- /* @__PURE__ */ o("p", { className: "p-subtitle", children: "This should only take a few minutes." })
1522
- ] }),
1523
- /* @__PURE__ */ b("div", { className: "panel-body flex-1 min-h-0 overflow-y-auto", children: [
1524
- !l && /* @__PURE__ */ o(ze, { children: A || r.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ o("div", { className: "text-slate-600", children: "Loading..." }) }) : /* @__PURE__ */ o(
1525
- Ct,
1526
- {
1527
- stages: r,
1528
- initialValues: u ?? void 0,
1529
- initialActive: k,
1530
- onStageComplete: async (C, T) => {
1531
- try {
1532
- const d = Ae(C), { stages: p } = await we(), c = R(p);
1533
- s(c);
1534
- const w = c.findIndex((_) => _.key === T) + 1, S = (w < c.length ? c[w] : null)?.key || T;
1535
- if (n)
1536
- if (T === "SMSVerification") {
1537
- const { isVerified: _, token: f } = await Ft(n, d.sms_code);
1538
- if (!_)
1539
- throw new Error("Invalid SMS code");
1540
- f && jt(f), await ce({ current_stage: S }, !1);
1541
- } else if (T === "State") {
1542
- const { isSupported: _ } = await Dt(d.state);
1543
- if (!_)
1544
- throw new Error("State is not supported");
1545
- const f = me();
1546
- await ce({ ...d, current_stage: S }, !1, f ? void 0 : n);
1547
- } else {
1548
- const _ = me();
1549
- await ce({ ...d, current_stage: S }, !1, _ ? void 0 : n || void 0);
1550
- }
1551
- else {
1552
- const f = (await Bt(d.phone))?.quoteId;
1553
- if (!f || typeof f != "string" || f.trim() === "")
1554
- throw new Error(`Failed to create quote - invalid quoteId returned: ${f}`);
1555
- i(f), Et(f), await ce({ current_stage: S }, !1, f);
1556
- }
1557
- return { success: !0 };
1558
- } catch (d) {
1559
- return { success: !1, error: d instanceof Error ? d.message : "An error occurred" };
1560
- }
1561
- },
1562
- onComplete: async (C) => {
1563
- try {
1564
- const T = Ae(C);
1565
- if (!n)
1566
- throw new Error("Quote ID is required");
1567
- await ce(T, !0), v(C);
1568
- const { rates: d } = await Kt();
1569
- return a(d), { success: !0 };
1570
- } catch (T) {
1571
- return { success: !1, error: T instanceof Error ? T.message : "An error occurred" };
1510
+ /* @__PURE__ */ o("div", { className: "backdrop", onClick: t, "aria-hidden": "true" }),
1511
+ /* @__PURE__ */ b("div", { className: "modal-panel bg-white relative w-full max-w-2xl flex flex-col max-h-[90vh] overflow-hidden", role: "document", children: [
1512
+ /* @__PURE__ */ o("button", { onClick: t, className: "absolute top-4 right-4 text-slate-400 hover:text-slate-600 text-xl", "aria-label": "Close", type: "button", children: "×" }),
1513
+ /* @__PURE__ */ b("div", { className: "text-center mb-6", children: [
1514
+ /* @__PURE__ */ o("h2", { id: "insurance-modal-title", className: "h1-title", children: "Let's get you the best insurance rates." }),
1515
+ /* @__PURE__ */ o("p", { className: "p-subtitle", children: "This should only take a few minutes." })
1516
+ ] }),
1517
+ /* @__PURE__ */ b("div", { className: "panel-body flex-1 min-h-0 overflow-y-auto", children: [
1518
+ !l && /* @__PURE__ */ o(Oe, { children: A || r.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ o("div", { className: "text-slate-600", children: "Loading..." }) }) : /* @__PURE__ */ o(
1519
+ Ct,
1520
+ {
1521
+ stages: r,
1522
+ initialValues: u ?? void 0,
1523
+ initialActive: k,
1524
+ onStageComplete: async (E, T) => {
1525
+ try {
1526
+ const d = Ae(E), { stages: p } = await we(), c = R(p);
1527
+ s(c);
1528
+ const w = c.findIndex((_) => _.key === T) + 1, S = (w < c.length ? c[w] : null)?.key || T;
1529
+ if (n)
1530
+ if (T === "SMSVerification") {
1531
+ const { isVerified: _, token: f } = await Dt(n, d.sms_code);
1532
+ if (!_)
1533
+ throw new Error("Invalid SMS code");
1534
+ f && Mt(f), await ce({ current_stage: S }, !1);
1535
+ } else if (T === "State") {
1536
+ const { isSupported: _ } = await Kt(d.state);
1537
+ if (!_)
1538
+ throw new Error("State is not supported");
1539
+ const f = me();
1540
+ await ce({ ...d, current_stage: S }, !1, f ? void 0 : n);
1541
+ } else {
1542
+ const _ = me();
1543
+ await ce({ ...d, current_stage: S }, !1, _ ? void 0 : n || void 0);
1572
1544
  }
1545
+ else {
1546
+ const f = (await Ft(d.phone))?.quoteId;
1547
+ if (!f || typeof f != "string" || f.trim() === "")
1548
+ throw new Error(`Failed to create quote - invalid quoteId returned: ${f}`);
1549
+ i(f), Tt(f), await ce({ current_stage: S }, !1, f);
1573
1550
  }
1551
+ return { success: !0 };
1552
+ } catch (d) {
1553
+ return { success: !1, error: d instanceof Error ? d.message : "An error occurred" };
1574
1554
  }
1575
- ) }),
1576
- " ",
1577
- l && n && /* @__PURE__ */ o(Ot, { rates: l, onBack: () => a(null) })
1578
- ] }),
1579
- /* @__PURE__ */ o("div", { className: "mt-4 pt-4 border-t border-slate-200", children: /* @__PURE__ */ o("p", { className: "text-center text-sm text-slate-500", children: "Insurance products offered through Credify Corporation, a licensed insurance agency." }) })
1580
- ]
1581
- }
1582
- )
1555
+ },
1556
+ onComplete: async (E) => {
1557
+ try {
1558
+ const T = Ae(E);
1559
+ if (!n)
1560
+ throw new Error("Quote ID is required");
1561
+ await ce(T, !0), v(E);
1562
+ const { rates: d } = await Wt();
1563
+ return a(d), { success: !0 };
1564
+ } catch (T) {
1565
+ return { success: !1, error: T instanceof Error ? T.message : "An error occurred" };
1566
+ }
1567
+ }
1568
+ }
1569
+ ) }),
1570
+ " ",
1571
+ l && n && /* @__PURE__ */ o(Pt, { rates: l, onBack: () => a(null) })
1572
+ ] }),
1573
+ /* @__PURE__ */ o("div", { className: "mt-4 pt-4 border-t border-slate-200", children: /* @__PURE__ */ o("p", { className: "text-center text-sm text-slate-500", children: "Insurance products offered through Credify Corporation, a licensed insurance agency." }) })
1574
+ ] })
1583
1575
  ] }) : null;
1584
1576
  }
1585
- function Vt({ isOpen: e }) {
1577
+ function Yt({ isOpen: e }) {
1586
1578
  return /* @__PURE__ */ o(
1587
- Ut,
1579
+ Vt,
1588
1580
  {
1589
1581
  isOpen: e,
1590
1582
  onClose: () => {
1591
- Je.close();
1583
+ Xe.close();
1592
1584
  }
1593
1585
  }
1594
1586
  );
1595
1587
  }
1588
+ const ze = "credify-insurance-widget-styles";
1589
+ function Gt() {
1590
+ if (typeof document > "u" || document.getElementById(ze)) return;
1591
+ const e = document.currentScript, t = e?.getAttribute?.("src") || e?.src;
1592
+ if (!(!t || !/credify-insurance-widget|index\.umd\.js/.test(t)))
1593
+ try {
1594
+ const n = `${t.replace(/\/[^/?#]+(\?.*)?$/, "")}/credify-insurance-widget.css`, i = document.createElement("link");
1595
+ i.id = ze, i.rel = "stylesheet", i.href = n, document.head.appendChild(i);
1596
+ } catch {
1597
+ }
1598
+ }
1599
+ Gt();
1596
1600
  let Y = null, re = null, pe = !1;
1597
- function Yt() {
1598
- Y || (Y = document.createElement("div"), Y.id = "insurance-widget-root", document.body.appendChild(Y)), !re && Y && (re = rt(Y));
1601
+ function Ht() {
1602
+ Y || (Y = document.createElement("div"), Y.id = "insurance-widget-root", document.documentElement.appendChild(Y)), !re && Y && (re = st(Y));
1599
1603
  }
1600
1604
  function xe() {
1601
- Yt(), re && re.render(nt(Vt, { isOpen: pe }));
1605
+ Ht(), re && re.render(rt(Yt, { isOpen: pe }));
1602
1606
  }
1603
- function Gt() {
1607
+ function Jt() {
1604
1608
  re && Y && (re.unmount(), Y.remove()), re = null, Y = null;
1605
1609
  }
1606
- const Je = {
1610
+ const Xe = {
1607
1611
  init: (e) => {
1608
1612
  pe = !!e?.autoOpen, xe();
1609
1613
  },
@@ -1613,11 +1617,11 @@ const Je = {
1613
1617
  close: () => {
1614
1618
  pe = !1, xe();
1615
1619
  },
1616
- destroy: Gt
1620
+ destroy: Jt
1617
1621
  };
1618
- typeof window < "u" && (window.CredifyInsuranceWidget = Je);
1622
+ typeof window < "u" && (window.CredifyInsuranceWidget = Xe);
1619
1623
  export {
1620
- Je as CredifyInsuranceWidget,
1621
- Je as default
1624
+ Xe as CredifyInsuranceWidget,
1625
+ Xe as default
1622
1626
  };
1623
1627
  //# sourceMappingURL=index.es.js.map