1import { a as k } from "./runtime-dom.esm-bundler-E8HrAoYr.js"; 2import { _ as L } from "./BuAppRegistrationFormBase.vue_vue_type_style_index_0_lang-hgNQBOGJ.js"; 3import { _ as O } from "./BuAppRegistrationFormStep.vue_vue_type_style_index_0_lang-DUAlNYK6.js"; 4import { _ as U } from "./BuAppRegistrationConfirmed.vue_vue_type_style_index_0_lang-DLfn3o8N.js"; 5import { u as X } from "./useCommonUtils-eps3nKgp.js"; 6import { u as Y } from "./registration-D7UqEwye.js"; 7import { u as K } from "./api-vmXNQwuv.js"; 8import { q as H, r as D, d, b8 as J, k as Q, s as A, u as B, y as W, l as w, v as ee } from "./runtime-core.esm-bundler-p6FoNF-k.js"; 9const ce = /* @__PURE__ */ H({ 10 name: "BuAppRegistration", 11 __name: "BuAppRegistration", 12 setup(te) { 13 const y = D({}), S = D(!1), s = Y(), r = d(() => s.formStep), $ = d(() => s.formData), c = d(() => s.formType), N = K(), E = d(() => N.siteaccess), i = d(() => s.getStepData || {}), V = d(() => s.getNextStepData), x = d(() => s.getAllStepData), C = d(() => x.value.reduce((e, t) => (t.progressText && e.push({ progressText: t.progressText }), e), [])); 14 J(() => { 15 (E.value === "website_br_pt" || E.value === "website_tr_tr") && (s.formType = "new", s.formStep = r.value + 1); 16 }); 17 const F = (e) => { 18 const t = typeof e.value == "object" && !Array.isArray(e.value) ? e.value[e.data.name] : e.value; 19 if (e.data?.name === "acceptedTaxExemption" && (i.value.lines.flatMap((o) => o.columns || []).find((o) => o?.data?.name === "taxType")?.value !== "EXEMPT" || e.required === !1)) 20 return e.valid = !0, e; 21 if (e.required && (t === "" || /^\s+$/.test(t) || !t)) 22 return e.valid = !1, e; 23 if (!e.required && (t === "" || /^\s+$/.test(t) || !t)) 24 return e.valid = !0, e; 25 switch (e.type) { 26 case "checkbox": 27 e.valid = t !== !1; 28 break; 29 case "fileUpload": 30 e.valid = t.length > 0; 31 break; 32 case "input": 33 if (e.data.type === "email") { 34 const n = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 35 e.valid = n.test(t); 36 } else if (e.data.type === "phone") { 37 const n = /^\d+$/; 38 e.valid = n.test(t); 39 } else if (e.data.gst) { 40 const n = /^[0-9]{2}[a-zA-Z0-9]{10}[1-9a-zA-Z]Z[a-zA-Z0-9]$/; 41 e.valid = n.test(t); 42 } else 43 e.valid = t !== ""; 44 break; 45 default: 46 e.valid = t !== ""; 47 } 48 return e; 49 }, f = (e, t, n) => { 50 s.setFormField(r.value, e, t, n); 51 }, { track: v } = X(), q = async () => { 52 try { 53 const { dynamic: e } = V.value; 54 if (!e) 55 return !0; 56 const t = await s.getCountryByType(c.value); 57 if (!t) 58 throw r.value === 1 && c.value === "existing" && v("Registration", "Existing - Step 1", "Authentication Error"), Error("Couldn't getCountryByType"); 59 if (t === e.country) 60 return !0; 61 c.value === "new" && r.value === 1 && v("Registration", "New - Step 1", "Next-Step", t); 62 const n = await s.getContactFieldsResponseByCountry( 63 t, 64 c.value 65 ); 66 return n ? (s.setFormStepKey(r.value, "dynamic", { 67 ...e, 68 country: t 69 }), n?.RegistrationGetContactFieldsResponse?.lines && s.setFormLines( 70 r.value, 71 n?.RegistrationGetContactFieldsResponse?.lines 72 ), !0) : !1; 73 } catch { 74 c.value !== "existing" && r.value !== 1 && i.value.lines.forEach((t, n) => { 75 t.type === "row" && t.columns.forEach((o, l) => { 76 f(n, l, { 77 ...o, 78 valid: !1, 79 apiError: "" 80 }); 81 }); 82 }); 83 } 84 return !1; 85 }, R = () => { 86 let e = null; 87 if (typeof i.value.lines > "u") 88 return s.formType = "existing", s.formStep = 0, !1; 89 const t = i.value.lines.filter((n) => n.type === "row" ? n.columns.filter((o) => [void 0, null].includes(o.required) || [void 0, null].includes(o.val
89id) && !o.required ? !1 : (o.valid === !1 && !e && (e = o), o.valid === !1)).length > 0 : !1).length; 90 return e && (y.value = e), t === 0; 91 }, z = async () => { 92 const e = s.getStepDataByType(c.value); 93 let t = {}; 94 e.forEach((a, g) => { 95 t = { 96 ...t, 97 ...a.lines.reduce((p, h) => (h.type === "row" && h.columns.forEach((m) => { 98 m.data.name === "phone" ? m.value.phone && (p[m.data.name] = m.value.phone, m.value["select-phone"]?.value ? p.prefixPhone = m.value["select-phone"].value : p.prefixPhone = m.value.value) : p[m.data.name] = m.value; 99 }), p), {}) 100 }; 101 }); 102 const n = i.value.dynamic ? i.value.dynamic : {}, o = await s.validateFormData({ 103 ...t, 104 ...n 105 }); 106 if (console.log("validationResponse", o), console.log("getStepData", i.value), !o) return !1; 107 const l = o?.ValidationResponse, u = Object.values(l).filter( 108 (a) => typeof a.valid > "u" ? !1 : !a.valid 109 ).length > 0; 110 return l && u && i.value.lines.forEach((a, g) => { 111 a.type === "row" && a.columns.forEach((p, h) => { 112 l[p.data.name]?.valid === !1 && f(g, h, { 113 ...p, 114 valid: !1, 115 apiError: l[p.data.name]?.message 116 }); 117 }); 118 }), !u; 119 }, P = () => !R(), G = () => { 120 i.value.lines.forEach((e, t) => { 121 e.type === "row" && e.columns.forEach((n, o) => { 122 f(t, o, F({ ...n })); 123 }); 124 }); 125 }, I = (e) => { 126 s.formType = e, s.formValidatedSteps = [0]; 127 }, b = (e, t) => { 128 const n = t !== void 0 ? x.value[t] : i.value; 129 if (!n?.lines?.length) 130 return null; 131 for (let o = 0; o < n.lines.length; o++) { 132 const l = n.lines[o]; 133 if (l.type === "row" && l.columns) { 134 const u = l.columns.findIndex((a) => a?.data?.name === e); 135 if (u !== -1) 136 return { 137 lineIndex: o, 138 colIndex: u, 139 field: l.columns[u] 140 }; 141 } 142 } 143 return null; 144 }, T = ({ 145 valueName: e, 146 newValue: t, 147 stepIndex: n, 148 lineIndex: o, 149 colIndex: l 150 }) => { 151 if ([null, void 0].includes(o) || [null, void 0].includes(l)) 152 return !1; 153 const u = { 154 ...i.value.lines[o].columns[l], 155 valid: void 0, 156 value: t 157 }; 158 if (s.setFormField(n, o, l, u), u.data.name === "city" || u.data.name === "state") { 159 const a = b("zip", n); 160 a && f(a.lineIndex, a.colIndex, { 161 ...a.field, 162 valid: void 0, 163 apiError: null 164 }); 165 } 166 if (e === "taxType") { 167 const a = b("acceptedTaxExemption", n); 168 if (a) 169 if (t !== "EXEMPT") { 170 const g = F({ ...a.field }); 171 f(a.lineIndex, a.colIndex, g); 172 } else 173 f(a.lineIndex, a.colIndex, { 174 ...a.field, 175 valid: void 0 176 }); 177 } 178 return !0; 179 }, Z = () => { 180 s.resetFormStep(); 181 }, _ = async () => { 182 if (r.value === 0 && v("Registration", "Selection", "Next - step", c.value), c.value === "existing" && r.value !== 0 && r.value < 3 && v("Registration", `Existing - Step ${r.value}`, "Next-Step"), c.value === "new" && r.value === 2 && v("Registration", "New - Step 2", "Next-Step"), Z(), G(), R()) { 183 const e = i.value.dynamic ? await z() : !0; 184 if (r.value === 2) return e; 185 e && await q() && (s.formStep = r.value + 1), window.scrollTo({ top: 0, behavior: "smooth" }); 186 } else if (document.querySelector(`[name=${y.value?.data?.name}]`)) { 187 const t = document.querySelector(`[name=${y.value?.data?.name}]`).getBoundingClientRect().top + window.scrollY; 188 window.scrollTo({ top: t, behavior: "smooth" }); 189 } else { 190 const t = document.querySelector( 191 `[name=${y.value?.data?.name}_files]` 192 ); 193 if (t) { 194 const n = t.getBoundingClientRect().top + window.scrollY; 195 window.scrollTo({ top: n, behavior: "smooth" }); 196 } 197 } 198 return !1; 199 }, M = () => { 200 c.value === "existing" && (r.value === 1 && v("Registration", "Existing - Step 1", "Go back to selection"), r.value === 2 && v("Registration", "Existing - Step 2", "Go back to Customer Identity Check")), c.value === "new" && r.value < 3 && v("Registration", `New - Step ${r.value}`, "Go back to selection"), s.formStep = r.value - 1; 201 }, j = async () => { 202 if (await _()) { 203 const t = x.value.reduce((o, l) =>
203 (l.lines.forEach((u) => { 204 u.columns && u.columns.every((a) => a.type === "chooseFormType" ? !1 : (a.data.name === "phone" && a.value.phone && (o[a.data.name] = a.value.phone, a.value["select-phone"]?.value ? o.prefixPhone = a.value["select-phone"].value : o.prefixPhone = a.value.value), a.data.name && a.value && a.data.name !== "phone" && (o[a.data.name] = a.value), !0)); 205 }), o), {}); 206 await s.submitForm(t) && (S.value = !0, window.scrollTo({ top: 0, behavior: "smooth" })); 207 } 208 }; 209 return (e, t) => (w(), Q("div", null, [ 210 S.value ? B("", !0) : (w(), A(L, { 211 key: 0, 212 "form-type": c.value, 213 headline: i.value?.headline, 214 "step-data-progress-radio": C.value, 215 "total-step-data-copy": i.value?.copy, 216 "form-step": r.value, 217 onChange: T, 218 onSubmit: k(j, ["prevent"]) 219 }, { 220 default: W(() => [ 221 ee(O, { 222 ref_key: "formStep", 223 ref: r, 224 "form-step": r.value, 225 "form-step-amount": C.value?.length || 0, 226 "form-lines": i.value?.lines, 227 info: i.value?.info, 228 submit: i.value?.submit, 229 error: i.value?.error, 230 "continue-disabled": P(), 231 onChange: T, 232 onOnTypeChange: I, 233 onReturn: M, 234 onContinue: k(_, ["prevent"]) 235 }, null, 8, ["form-step", "form-step-amount", "form-lines", "info", "submit", "error", "continue-disabled"]) 236 ]), 237 _: 1 238 }, 8, ["form-type", "headline", "step-data-progress-radio", "total-step-data-copy", "form-step"])), 239 S.value ? (w(), A(U, { 240 key: 1, 241 data: $.value.submit 242 }, null, 8, ["data"])) : B("", !0) 243 ])); 244 } 245}); 246export { 247 ce as _ 248};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.