@incodetech/web 2.0.0-alpha.6 → 2.0.0-alpha.7

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,557 +1,539 @@
1
- import { b as K, u as i, L as W, S as R, B as q, c as _, a as V } from "../preact-custom-element.esm-BGQkPkOv.js";
2
- import { getRequiredWasmPipelines as N, createOrchestratedFlowManager as Y } from "@incodetech/core/flow";
3
- import { k as $, A as U, d as k, y as v } from "../vendor-preact-CK0WeTOR.js";
1
+ import { c as D, u as i, L as W, S as E, B as j, r as H, a as B } from "../incodeModule-Dv8Qllrv.js";
2
+ import { createOrchestratedFlowManager as O, getRequiredWasmPipelines as R } from "@incodetech/core/flow";
3
+ import { k as F, A as I, d as x, y as M } from "../vendor-preact-CK0WeTOR.js";
4
4
  import "../instance-B-q0ZREN.js";
5
- import { T as Z, u as A } from "../title-XSxhaBDx.js";
6
- import { api as D, warmupWasm as G } from "@incodetech/core";
7
- import { emailMachine as J } from "@incodetech/core/email";
8
- import { phoneMachine as Q } from "@incodetech/core/phone";
9
- import { selfieMachine as X } from "@incodetech/core/selfie";
10
- import { s as ee } from "../setup-wNL83jmW.js";
11
- import { s as F } from "../uiConfig-CQ1W9cUD.js";
12
- const te = {
5
+ import { T as K, u as $ } from "../title-BfO5Dlzk.js";
6
+ import { api as z, warmupWasm as q } from "@incodetech/core";
7
+ import { emailMachine as _ } from "@incodetech/core/email";
8
+ import { phoneMachine as V } from "@incodetech/core/phone";
9
+ import { selfieMachine as Y } from "@incodetech/core/selfie";
10
+ import { s as Z } from "../setup-wNL83jmW.js";
11
+ import { s as y } from "../uiConfig-CQ1W9cUD.js";
12
+ const G = {
13
13
  small: 24,
14
14
  medium: 48,
15
15
  large: 64
16
- }, E = ({
17
- title: t,
18
- subtitle: e,
19
- size: o = "medium",
16
+ }, b = ({
17
+ title: e,
18
+ subtitle: t,
19
+ size: n = "medium",
20
20
  fullScreen: s = !0,
21
- className: l
21
+ className: r
22
22
  }) => {
23
- const c = te[o], r = K(
23
+ const a = G[n], o = D(
24
24
  "IncodeSpinner",
25
25
  s && "IncodeSpinnerFullScreen",
26
- l
26
+ r
27
27
  );
28
- return /* @__PURE__ */ i("div", { class: r, children: /* @__PURE__ */ i("div", { class: "IncodeSpinnerContent", children: [
29
- /* @__PURE__ */ i(W, { size: c }),
30
- (t || e) && /* @__PURE__ */ i($, { children: [
31
- /* @__PURE__ */ i(R, { size: 16 }),
32
- /* @__PURE__ */ i("div", { class: "IncodeSpinnerText", children: [
33
- t && /* @__PURE__ */ i(Z, { className: "IncodeSpinnerTitle", children: t }),
34
- e && /* @__PURE__ */ i($, { children: [
35
- t && /* @__PURE__ */ i(R, { size: 12 }),
36
- /* @__PURE__ */ i("p", { class: "IncodeSpinnerSubtitle", children: e })
28
+ return /* @__PURE__ */ i(
29
+ "div",
30
+ {
31
+ class: o,
32
+ "data-testid": "spinner",
33
+ "data-title": e,
34
+ "data-subtitle": t,
35
+ "data-size": n,
36
+ children: /* @__PURE__ */ i("div", { class: "IncodeSpinnerContent", children: [
37
+ /* @__PURE__ */ i(W, { size: a }),
38
+ (e || t) && /* @__PURE__ */ i(F, { children: [
39
+ /* @__PURE__ */ i(E, { size: 16 }),
40
+ /* @__PURE__ */ i("div", { class: "IncodeSpinnerText", children: [
41
+ e && /* @__PURE__ */ i(K, { className: "IncodeSpinnerTitle", children: e }),
42
+ t && /* @__PURE__ */ i(F, { children: [
43
+ e && /* @__PURE__ */ i(E, { size: 12 }),
44
+ /* @__PURE__ */ i("p", { class: "IncodeSpinnerSubtitle", children: t })
45
+ ] })
46
+ ] })
37
47
  ] })
38
48
  ] })
39
- ] })
40
- ] }) });
49
+ }
50
+ );
41
51
  };
42
- function re(t) {
43
- let e = t.replace("#", "");
44
- e.length === 3 && (e = e.split("").map((d) => d + d).join(""));
45
- const o = /^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
46
- if (!o) return null;
47
- const s = Number.parseInt(o[1], 16) / 255, l = Number.parseInt(o[2], 16) / 255, c = Number.parseInt(o[3], 16) / 255, r = Math.max(s, l, c), u = Math.min(s, l, c);
48
- let f = 0, m = 0;
49
- const a = (r + u) / 2;
50
- if (r !== u) {
51
- const d = r - u;
52
- switch (m = a > 0.5 ? d / (2 - r - u) : d / (r + u), r) {
52
+ function J(e) {
53
+ let t = e.replace("#", "");
54
+ t.length === 3 && (t = t.split("").map((u) => u + u).join(""));
55
+ const n = /^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
56
+ if (!n) return null;
57
+ const s = Number.parseInt(n[1], 16) / 255, r = Number.parseInt(n[2], 16) / 255, a = Number.parseInt(n[3], 16) / 255, o = Math.max(s, r, a), l = Math.min(s, r, a);
58
+ let c = 0, p = 0;
59
+ const d = (o + l) / 2;
60
+ if (o !== l) {
61
+ const u = o - l;
62
+ switch (p = d > 0.5 ? u / (2 - o - l) : u / (o + l), o) {
53
63
  case s:
54
- f = ((l - c) / d + (l < c ? 6 : 0)) / 6;
64
+ c = ((r - a) / u + (r < a ? 6 : 0)) / 6;
55
65
  break;
56
- case l:
57
- f = ((c - s) / d + 2) / 6;
66
+ case r:
67
+ c = ((a - s) / u + 2) / 6;
58
68
  break;
59
- case c:
60
- f = ((s - l) / d + 4) / 6;
69
+ case a:
70
+ c = ((s - r) / u + 4) / 6;
61
71
  break;
62
72
  }
63
73
  }
64
- return { h: f * 360, s: m * 100, l: a * 100 };
74
+ return { h: c * 360, s: p * 100, l: d * 100 };
65
75
  }
66
- function I(t, e, o) {
67
- const s = t / 360, l = e / 100, c = o / 100;
68
- let r, u, f;
69
- if (l === 0)
70
- r = u = f = c;
76
+ function w(e, t, n) {
77
+ const s = e / 360, r = t / 100, a = n / 100;
78
+ let o, l, c;
79
+ if (r === 0)
80
+ o = l = c = a;
71
81
  else {
72
- const a = (n, g, p) => (p < 0 && (p += 1), p > 1 && (p -= 1), p < 0.16666666666666666 ? n + (g - n) * 6 * p : p < 0.5 ? g : p < 0.6666666666666666 ? n + (g - n) * (0.6666666666666666 - p) * 6 : n), d = c < 0.5 ? c * (1 + l) : c + l - c * l, h = 2 * c - d;
73
- r = a(h, d, s + 1 / 3), u = a(h, d, s), f = a(h, d, s - 1 / 3);
82
+ const d = (h, C, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 0.16666666666666666 ? h + (C - h) * 6 * m : m < 0.5 ? C : m < 0.6666666666666666 ? h + (C - h) * (0.6666666666666666 - m) * 6 : h), u = a < 0.5 ? a * (1 + r) : a + r - a * r, f = 2 * a - u;
83
+ o = d(f, u, s + 1 / 3), l = d(f, u, s), c = d(f, u, s - 1 / 3);
74
84
  }
75
- const m = (a) => {
76
- const d = Math.round(a * 255).toString(16);
77
- return d.length === 1 ? `0${d}` : d;
85
+ const p = (d) => {
86
+ const u = Math.round(d * 255).toString(16);
87
+ return u.length === 1 ? `0${u}` : u;
78
88
  };
79
- return `#${m(r)}${m(u)}${m(f)}`;
89
+ return `#${p(o)}${p(l)}${p(c)}`;
80
90
  }
81
- function oe(t) {
82
- const e = re(t);
83
- if (!e)
84
- throw new Error(`Invalid color format: ${t}`);
91
+ function Q(e) {
92
+ const t = J(e);
93
+ if (!t)
94
+ throw new Error(`Invalid color format: ${e}`);
85
95
  return {
86
- 50: I(e.h, e.s, 95),
87
- 200: I(e.h, e.s, 80),
88
- 300: I(e.h, e.s, 65),
89
- 400: I(e.h, e.s, Math.min(100, e.l + 10)),
90
- 500: t,
91
- 600: I(e.h, e.s, Math.max(0, e.l - 10)),
92
- 900: I(e.h, e.s, 20)
96
+ 50: w(t.h, t.s, 95),
97
+ 200: w(t.h, t.s, 80),
98
+ 300: w(t.h, t.s, 65),
99
+ 400: w(t.h, t.s, Math.min(100, t.l + 10)),
100
+ 500: e,
101
+ 600: w(t.h, t.s, Math.max(0, t.l - 10)),
102
+ 900: w(t.h, t.s, 20)
93
103
  };
94
104
  }
95
- function ne(t, e) {
105
+ function X(e, t) {
96
106
  if (typeof document > "u")
97
107
  return;
98
- const o = oe(t);
108
+ const n = Q(e);
99
109
  let s = document.getElementById(
100
110
  "incode-theme"
101
111
  );
102
112
  s || (s = document.createElement("style"), s.id = "incode-theme", document.head.appendChild(s));
103
- const l = e || "#ffffff", c = `
113
+ const r = t || "#ffffff", a = `
104
114
  :root,
105
115
  :host {
106
- --primitive-color-brand-50: ${o[50]};
107
- --primitive-color-brand-200: ${o[200]};
108
- --primitive-color-brand-300: ${o[300]};
109
- --primitive-color-brand-400: ${o[400]};
110
- --primitive-color-brand-500: ${o[500]};
111
- --primitive-color-brand-600: ${o[600]};
112
- --primitive-color-brand-900: ${o[900]};
113
- --button-primary-text-default: ${l};
116
+ --primitive-color-brand-50: ${n[50]};
117
+ --primitive-color-brand-200: ${n[200]};
118
+ --primitive-color-brand-300: ${n[300]};
119
+ --primitive-color-brand-400: ${n[400]};
120
+ --primitive-color-brand-500: ${n[500]};
121
+ --primitive-color-brand-600: ${n[600]};
122
+ --primitive-color-brand-900: ${n[900]};
123
+ --button-primary-text-default: ${r};
114
124
  }
115
125
  `;
116
- s.textContent = c;
126
+ s.textContent = a;
117
127
  }
118
- async function se() {
119
- return (await D.get("/omni/asset/fetch-all")).data;
128
+ async function ee() {
129
+ return (await z.get("/omni/asset/fetch-all")).data;
120
130
  }
121
- const z = /* @__PURE__ */ new Map();
122
- async function ae(t) {
123
- if (t.startsWith("data:"))
124
- return t;
125
- const e = z.get(t);
126
- if (e)
131
+ const L = /* @__PURE__ */ new Map();
132
+ async function te(e) {
133
+ if (e.startsWith("data:"))
127
134
  return e;
128
- const s = await (await fetch(t)).blob(), l = await new Promise((c, r) => {
129
- const u = new FileReader();
130
- u.onloadend = () => c(u.result), u.onerror = r, u.readAsDataURL(s);
135
+ const t = L.get(e);
136
+ if (t)
137
+ return t;
138
+ const s = await (await fetch(e)).blob(), r = await new Promise((a, o) => {
139
+ const l = new FileReader();
140
+ l.onloadend = () => a(l.result), l.onerror = o, l.readAsDataURL(s);
131
141
  });
132
- return z.set(t, l), l;
142
+ return L.set(e, r), r;
133
143
  }
134
- async function ie() {
135
- const t = await se();
136
- if (!t.theme)
144
+ async function re() {
145
+ const e = await ee();
146
+ if (!e.theme)
137
147
  throw new Error("Theme URL not found in assets response");
138
- const e = t.theme, o = e.startsWith("http://") || e.startsWith("https://");
148
+ const t = e.theme, n = t.startsWith("http://") || t.startsWith("https://");
139
149
  let s;
140
- if (o) {
141
- const r = await fetch(e);
142
- if (!r.ok)
143
- throw new Error(`Failed to fetch theme: ${r.statusText}`);
144
- s = await r.json();
150
+ if (n) {
151
+ const o = await fetch(t);
152
+ if (!o.ok)
153
+ throw new Error(`Failed to fetch theme: ${o.statusText}`);
154
+ s = await o.json();
145
155
  } else
146
- s = (await D.get(e)).data;
147
- const l = t["logo.png"] || t["logo.svg"] || t["logo.jpg"] || t["logo.jpeg"] || t["logo.webp"] || s.logo;
148
- let c = l;
149
- return l && (c = await ae(l)), {
156
+ s = (await z.get(t)).data;
157
+ const r = e["logo.png"] || e["logo.svg"] || e["logo.jpg"] || e["logo.jpeg"] || e["logo.webp"] || s.logo;
158
+ let a = r;
159
+ return r && (a = await te(r)), {
150
160
  ...s,
151
- logo: c
161
+ logo: a
152
162
  };
153
163
  }
154
- async function le() {
155
- const t = await ie();
156
- return t.main && ne(t.main, t.buttonColor), t;
164
+ async function ne() {
165
+ const e = await re();
166
+ return e.main && X(e.main, e.buttonColor), e;
157
167
  }
158
- const L = {
159
- PHONE: () => import("../phone/phone.es.js").then((t) => t.Phone),
160
- EMAIL: () => import("../email/email.es.js").then((t) => t.Email),
161
- SELFIE: () => import("../selfie/selfie.es.js").then((t) => t.Selfie)
168
+ const S = {
169
+ PHONE: () => import("../phone/phone.es.js").then((e) => e.Phone),
170
+ EMAIL: () => import("../email/email.es.js").then((e) => e.Email),
171
+ SELFIE: () => import("../selfie/selfie.es.js").then((e) => e.Selfie)
162
172
  };
163
- function j() {
164
- return Y({
173
+ function T() {
174
+ return O({
165
175
  modules: {
166
- PHONE: Q,
167
- EMAIL: J,
168
- SELFIE: X
176
+ PHONE: V,
177
+ EMAIL: _,
178
+ SELFIE: Y
169
179
  }
170
180
  });
171
181
  }
172
- async function H(t) {
173
- await ee({
174
- apiURL: t.apiURL,
175
- token: t.token,
176
- i18n: { lang: t.lang ?? "en" }
182
+ async function N(e) {
183
+ await Z({
184
+ apiURL: e.apiURL,
185
+ token: e.token,
186
+ i18n: { lang: e.lang ?? "en" }
177
187
  });
178
188
  }
179
- async function B() {
189
+ async function k() {
180
190
  try {
181
- const t = await le(), e = {
182
- logoSrc: t.logo,
183
- hideFooterBranding: t.hideFooterBranding
191
+ const e = await ne(), t = {
192
+ logoSrc: e.logo,
193
+ hideFooterBranding: e.hideFooterBranding
184
194
  };
185
- return F(e), { theme: t, uiConfig: e };
186
- } catch (t) {
187
- return console.warn("Failed to fetch dashboard theme:", t), {};
195
+ return y(t), { theme: e, uiConfig: t };
196
+ } catch (e) {
197
+ return console.warn("Failed to fetch dashboard theme:", e), {};
188
198
  }
189
199
  }
190
- function O(t, e) {
191
- const o = N(t.flow);
192
- o.length > 0 && G({
193
- ...e,
194
- pipelines: o
200
+ function A(e, t) {
201
+ const n = R(e.flow);
202
+ n.length > 0 && q({
203
+ ...t,
204
+ pipelines: n
195
205
  }).catch((s) => {
196
206
  console.error("WASM warmup failed:", s);
197
207
  });
198
208
  }
199
- function ce(t) {
200
- const e = t.currentStep;
201
- if (e) {
202
- const o = L[e];
203
- o && o().catch(() => {
209
+ function oe(e) {
210
+ const t = e.currentStep;
211
+ if (t) {
212
+ const n = S[t];
213
+ n && n().catch(() => {
204
214
  });
205
215
  }
206
216
  }
207
- const de = ({
208
- moduleKey: t,
209
- onNext: e
217
+ const se = ({
218
+ moduleKey: e,
219
+ onNext: t
210
220
  }) => {
211
- const { t: o } = A();
221
+ const { t: n } = $();
212
222
  return /* @__PURE__ */ i("section", { class: "IncodeUnsupportedModule", "aria-live": "polite", children: /* @__PURE__ */ i("div", { class: "IncodeUnsupportedModuleContent", children: [
213
- /* @__PURE__ */ i("h2", { class: "IncodeUnsupportedModuleTitle", children: o("unsupportedModule.title", "Module not available") }),
214
- /* @__PURE__ */ i("p", { class: "IncodeUnsupportedModuleMessage", children: o(
223
+ /* @__PURE__ */ i("h2", { class: "IncodeUnsupportedModuleTitle", children: n("unsupportedModule.title", "Module not available") }),
224
+ /* @__PURE__ */ i("p", { class: "IncodeUnsupportedModuleMessage", children: n(
215
225
  "unsupportedModule.message",
216
- `The "${t}" module is not yet supported in this version.`
226
+ `The "${e}" module is not yet supported in this version.`
217
227
  ) }),
218
228
  /* @__PURE__ */ i(
219
- q,
229
+ j,
220
230
  {
221
- onClick: e,
231
+ onClick: t,
222
232
  class: "IncodeUnsupportedModuleButton",
223
233
  "data-testid": "unsupported-module-next-button",
224
- children: o("unsupportedModule.next", "Next")
234
+ children: n("unsupportedModule.next", "Next")
225
235
  }
226
236
  )
227
237
  ] }) });
228
- }, y = /* @__PURE__ */ new Map();
229
- function C(t) {
230
- const e = y.get(t);
231
- if (!e)
238
+ }, g = /* @__PURE__ */ new Map();
239
+ function U(e) {
240
+ const t = g.get(e);
241
+ if (!t)
232
242
  throw new Error("Preload state not found");
233
243
  return {
234
244
  get isReady() {
235
- return e.status === "ready";
245
+ return t.status === "ready";
236
246
  },
237
247
  get error() {
238
- return e.status === "error" ? e.error ?? null : null;
248
+ return t.status === "error" ? t.error ?? null : null;
239
249
  },
240
250
  async waitUntilReady() {
241
- if (e.status !== "ready") {
242
- if (e.status === "error")
243
- throw new Error(e.error ?? "Preload failed");
244
- return e.readyPromise;
251
+ if (t.status !== "ready") {
252
+ if (t.status === "error")
253
+ throw new Error(t.error ?? "Preload failed");
254
+ return t.readyPromise;
245
255
  }
246
256
  },
247
257
  cancel() {
248
- e.status === "loading" && (e.unsubscribe && e.unsubscribe(), e.flowManager.stop(), e.readyReject(new Error("Preload cancelled")), y.delete(t));
258
+ t.status === "loading" && (t.unsubscribe && t.unsubscribe(), t.flowManager.stop(), t.readyReject(new Error("Preload cancelled")), g.delete(e));
249
259
  }
250
260
  };
251
261
  }
252
- function Ue(t) {
253
- const { token: e } = t;
254
- if (y.has(e))
255
- return C(e);
256
- let o, s;
257
- const l = new Promise((f, m) => {
258
- o = f, s = m;
259
- }), c = j(), r = {
262
+ function Ie(e) {
263
+ const { token: t } = e;
264
+ if (g.has(t))
265
+ return U(t);
266
+ let n, s;
267
+ const r = new Promise((c, p) => {
268
+ n = c, s = p;
269
+ }), a = T(), o = {
260
270
  status: "loading",
261
- flowManager: c,
262
- config: t,
263
- readyPromise: l,
264
- readyResolve: o,
271
+ flowManager: a,
272
+ config: e,
273
+ readyPromise: r,
274
+ readyResolve: n,
265
275
  readyReject: s
266
276
  };
267
- return y.set(e, r), (async () => {
277
+ return g.set(t, o), (async () => {
268
278
  try {
269
- await H({
270
- apiURL: t.apiURL,
271
- token: t.token,
272
- lang: t.lang
279
+ await N({
280
+ apiURL: e.apiURL,
281
+ token: e.token,
282
+ lang: e.lang
273
283
  });
274
- const f = t.disableDashboardTheme ? Promise.resolve({}) : B().then((a) => {
275
- r.theme = a.theme, r.uiConfig = a.uiConfig;
276
- }), m = c.subscribe((a) => {
277
- if (a.status === "ready") {
278
- const d = a;
279
- t.wasmConfig && O(d, t.wasmConfig), ce(d), r.unsubscribe?.(), r.unsubscribe = void 0, r.status = "ready", r.readyResolve();
280
- } else a.status === "error" && (r.unsubscribe?.(), r.unsubscribe = void 0, r.status = "error", r.error = a.error, r.readyReject(new Error(a.error)));
284
+ const c = e.disableDashboardTheme ? Promise.resolve({}) : k().then((d) => {
285
+ o.theme = d.theme, o.uiConfig = d.uiConfig;
286
+ }), p = a.subscribe((d) => {
287
+ if (d.status === "ready") {
288
+ const u = d;
289
+ e.wasmConfig && A(u, e.wasmConfig), oe(u), o.unsubscribe?.(), o.unsubscribe = void 0, o.status = "ready", o.readyResolve();
290
+ } else d.status === "error" && (o.unsubscribe?.(), o.unsubscribe = void 0, o.status = "error", o.error = d.error, o.readyReject(new Error(d.error)));
281
291
  });
282
- r.unsubscribe = m, c.load(), await f;
283
- } catch (f) {
284
- r.status = "error", r.error = f instanceof Error ? f.message : "Failed to preload", r.readyReject(
285
- f instanceof Error ? f : new Error("Failed to preload")
286
- ), y.delete(e);
292
+ o.unsubscribe = p, a.load(), await c;
293
+ } catch (c) {
294
+ o.status = "error", o.error = c instanceof Error ? c.message : "Failed to preload", o.readyReject(
295
+ c instanceof Error ? c : new Error("Failed to preload")
296
+ ), g.delete(t);
287
297
  }
288
- })(), C(e);
298
+ })(), U(t);
289
299
  }
290
- function x(t) {
291
- return y.get(t) ?? null;
300
+ function v(e) {
301
+ return g.get(e) ?? null;
292
302
  }
293
- function T(t) {
294
- const e = x(t);
295
- return e && y.delete(t), e;
303
+ function P(e) {
304
+ const t = v(e);
305
+ return t && g.delete(e), t;
296
306
  }
297
- function ue(t) {
298
- const { apiURL: e, token: o, lang: s, disableDashboardTheme: l, onError: c } = t, r = U(null), [u, f] = k(() => {
299
- const a = x(o);
300
- if (a?.status === "ready") {
301
- const h = T(o);
302
- if (h)
303
- return r.current = h.flowManager, h.uiConfig && F(h.uiConfig), { status: "ready", flowManager: h.flowManager };
307
+ function ie(e) {
308
+ const { apiURL: t, token: n, lang: s, disableDashboardTheme: r, onError: a } = e, o = I(null), [l, c] = x(() => {
309
+ const d = v(n);
310
+ if (d?.status === "ready") {
311
+ const f = P(n);
312
+ if (f)
313
+ return o.current = f.flowManager, f.uiConfig && y(f.uiConfig), { status: "ready", flowManager: f.flowManager };
304
314
  }
305
- const d = j();
306
- return r.current = d, a?.status === "error" ? {
315
+ const u = T();
316
+ return o.current = u, d?.status === "error" ? {
307
317
  status: "error",
308
- error: a.error ?? "Preload failed",
309
- flowManager: d
310
- } : { status: "initializing", flowManager: d };
311
- }), m = U(!1);
312
- return v(() => {
313
- if (u.status !== "initializing")
318
+ error: d.error ?? "Preload failed",
319
+ flowManager: u
320
+ } : { status: "initializing", flowManager: u };
321
+ }), p = I(!1);
322
+ return M(() => {
323
+ if (l.status !== "initializing")
314
324
  return;
315
- const a = x(o);
316
- if (a?.status === "loading") {
317
- a.readyPromise.then(() => {
318
- const h = T(o);
319
- h && (r.current = h.flowManager, h.uiConfig && F(h.uiConfig), f({ status: "ready", flowManager: h.flowManager }));
320
- }).catch((h) => {
321
- const n = h instanceof Error ? h.message : "Preload failed";
322
- f({
325
+ const d = v(n);
326
+ if (d?.status === "loading") {
327
+ d.readyPromise.then(() => {
328
+ const f = P(n);
329
+ f && (o.current = f.flowManager, f.uiConfig && y(f.uiConfig), c({ status: "ready", flowManager: f.flowManager }));
330
+ }).catch((f) => {
331
+ const h = f instanceof Error ? f.message : "Preload failed";
332
+ c({
323
333
  status: "error",
324
- error: n,
325
- flowManager: u.flowManager
326
- }), c?.(n);
334
+ error: h,
335
+ flowManager: l.flowManager
336
+ }), a?.(h);
327
337
  });
328
338
  return;
329
339
  }
330
- if (m.current)
340
+ if (p.current)
331
341
  return;
332
- m.current = !0, (async () => {
342
+ p.current = !0, (async () => {
333
343
  try {
334
- await H({ apiURL: e, token: o, lang: s });
335
- const h = l ? Promise.resolve() : B().then((n) => {
336
- n.uiConfig && F(n.uiConfig);
344
+ await N({ apiURL: t, token: n, lang: s });
345
+ const f = r ? Promise.resolve() : k().then((h) => {
346
+ h.uiConfig && y(h.uiConfig);
337
347
  });
338
- u.flowManager.load(), await h, f({ status: "ready", flowManager: u.flowManager });
339
- } catch (h) {
340
- const n = h instanceof Error ? h.message : "Failed to initialize SDK";
341
- f({
348
+ l.flowManager.load(), await f, c({ status: "ready", flowManager: l.flowManager });
349
+ } catch (f) {
350
+ const h = f instanceof Error ? f.message : "Failed to initialize SDK";
351
+ c({
342
352
  status: "error",
343
- error: n,
344
- flowManager: u.flowManager
345
- }), c?.(n);
353
+ error: h,
354
+ flowManager: l.flowManager
355
+ }), a?.(h);
346
356
  }
347
357
  })();
348
- }, [e, o, s, l, c, u]), u;
358
+ }, [t, n, s, r, a, l]), l;
349
359
  }
350
- function fe(t) {
351
- const { moduleKey: e, onModuleLoading: o, onModuleLoaded: s, onError: l } = t, [c, r] = k({ status: "idle" });
352
- return v(() => {
353
- if (!e) {
354
- r({ status: "idle" });
360
+ function ae(e) {
361
+ const { moduleKey: t, onModuleLoading: n, onModuleLoaded: s, onError: r } = e, [a, o] = x({ status: "idle" });
362
+ return M(() => {
363
+ if (!t) {
364
+ o({ status: "idle" });
355
365
  return;
356
366
  }
357
- const u = L[e];
358
- if (!u) {
359
- r({ status: "unsupported", moduleKey: e });
367
+ const l = S[t];
368
+ if (!l) {
369
+ o({ status: "unsupported", moduleKey: t });
360
370
  return;
361
371
  }
362
- r({ status: "loading", moduleKey: e }), o?.(e);
363
- let f = !1;
364
- return u().then((m) => {
365
- f || (r({ status: "loaded", moduleKey: e, Component: m }), s?.(e));
366
- }).catch((m) => {
367
- if (!f) {
368
- const a = m instanceof Error ? m.message : "Failed to load module";
369
- r({ status: "error", moduleKey: e, error: a }), l?.(`Failed to load ${e}: ${a}`);
372
+ o({ status: "loading", moduleKey: t }), n?.(t);
373
+ let c = !1;
374
+ return l().then((p) => {
375
+ c || (o({ status: "loaded", moduleKey: t, Component: p }), s?.(t));
376
+ }).catch((p) => {
377
+ if (!c) {
378
+ const d = p instanceof Error ? p.message : "Failed to load module";
379
+ o({ status: "error", moduleKey: t, error: d }), r?.(`Failed to load ${t}: ${d}`);
370
380
  }
371
381
  }), () => {
372
- f = !0;
382
+ c = !0;
373
383
  };
374
- }, [e, o, s, l]), c;
384
+ }, [t, n, s, r]), a;
375
385
  }
376
- function he(t, e) {
377
- const o = U(/* @__PURE__ */ new Set());
378
- v(() => {
379
- if (e < t.length - 1) {
380
- const s = t[e + 1];
381
- if (s && !o.current.has(s)) {
382
- o.current.add(s);
383
- const l = L[s];
384
- l && l().catch(() => {
385
- o.current.delete(s);
386
+ function le(e, t) {
387
+ const n = I(/* @__PURE__ */ new Set());
388
+ M(() => {
389
+ if (t < e.length - 1) {
390
+ const s = e[t + 1];
391
+ if (s && !n.current.has(s)) {
392
+ n.current.add(s);
393
+ const r = S[s];
394
+ r && r().catch(() => {
395
+ n.current.delete(s);
386
396
  });
387
397
  }
388
398
  }
389
- }, [t, e]);
399
+ }, [e, t]);
390
400
  }
391
- const me = ({
392
- apiURL: t,
393
- token: e,
394
- wasmConfig: o,
395
- lang: s,
396
- disableDashboardTheme: l,
397
- onComplete: c,
398
- onError: r,
399
- onModuleLoading: u,
400
- onModuleLoaded: f,
401
- onWasmWarmup: m,
402
- spinnerConfig: a
403
- }) => {
404
- const { t: d } = A(), h = ue({
405
- apiURL: t,
406
- token: e,
407
- lang: s,
408
- disableDashboardTheme: l,
409
- onError: r
410
- }), [n, g] = V(() => h.flowManager, {
401
+ const de = ({ config: e, onError: t }) => {
402
+ const { t: n } = $(), s = ie({
403
+ apiURL: e.apiURL,
404
+ token: e.token,
405
+ lang: e.lang,
406
+ disableDashboardTheme: e.disableDashboardTheme,
407
+ onError: t
408
+ }), [r, a] = B(() => s.flowManager, {
411
409
  autoLoad: !1
412
- }), p = fe({
413
- moduleKey: n?.status === "ready" ? n.currentStep : void 0,
414
- onModuleLoading: u,
415
- onModuleLoaded: f,
416
- onError: r
410
+ }), o = ae({
411
+ moduleKey: r?.status === "ready" ? r.currentStep : void 0,
412
+ onModuleLoading: e.onModuleLoading,
413
+ onModuleLoaded: e.onModuleLoaded,
414
+ onError: t
417
415
  });
418
- if (he(
419
- n?.status === "ready" ? n.steps : [],
420
- n?.status === "ready" ? n.currentStepIndex : -1
421
- ), v(() => {
422
- if (n?.status === "ready" && o) {
423
- const w = n, b = N(w.flow);
424
- b.length > 0 && (m?.(b), O(w, o));
416
+ if (le(
417
+ r?.status === "ready" ? r.steps : [],
418
+ r?.status === "ready" ? r.currentStepIndex : -1
419
+ ), M(() => {
420
+ if (r?.status === "ready" && e.wasmConfig) {
421
+ const l = r, c = R(l.flow);
422
+ c.length > 0 && (e.onWasmWarmup?.(c), A(l, e.wasmConfig));
425
423
  }
426
- }, [n?.status, o, n, m]), v(() => {
427
- n?.status === "finished" && c(n.finishStatus);
428
- }, [n?.status, c, n]), v(() => {
429
- n?.status === "error" && r && r(n.error);
430
- }, [n?.status, r, n]), h.status === "error")
424
+ }, [r, e]), M(() => {
425
+ r?.status === "finished" && e.onComplete(r.finishStatus);
426
+ }, [r?.status, e, r]), M(() => {
427
+ r?.status === "error" && t && t(r.error);
428
+ }, [r?.status, t, r]), s.status === "error")
431
429
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i("div", { children: [
432
430
  "Error: ",
433
- h.error
431
+ s.error
434
432
  ] }) });
435
- if (h.status === "initializing")
433
+ if (s.status === "initializing")
436
434
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
437
- E,
435
+ b,
438
436
  {
439
- title: a?.title ?? d("home.settingUp"),
440
- subtitle: a?.subtitle,
441
- size: a?.size,
437
+ title: e.spinnerConfig?.title ?? n("home.settingUp"),
438
+ subtitle: e.spinnerConfig?.subtitle,
439
+ size: e.spinnerConfig?.size,
442
440
  fullScreen: !0
443
441
  }
444
442
  ) });
445
- if (!n || n.status === "idle" || n.status === "loading")
443
+ if (!r || r.status === "idle" || r.status === "loading")
446
444
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
447
- E,
445
+ b,
448
446
  {
449
- title: a?.title ?? d("home.settingUp"),
450
- subtitle: a?.subtitle,
451
- size: a?.size,
447
+ title: e.spinnerConfig?.title ?? n("home.settingUp"),
448
+ subtitle: e.spinnerConfig?.subtitle,
449
+ size: e.spinnerConfig?.size,
452
450
  fullScreen: !0
453
451
  }
454
452
  ) });
455
- if (n.status === "error")
453
+ if (r.status === "error")
456
454
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i("div", { children: [
457
455
  "Error: ",
458
- n.error
456
+ r.error
459
457
  ] }) });
460
- if (n.status === "finished")
458
+ if (r.status === "finished")
461
459
  return null;
462
- if (n.status === "ready") {
463
- const { currentStep: w, config: b } = n;
464
- if (!w || !b)
460
+ if (r.status === "ready") {
461
+ const { currentStep: l, config: c } = r;
462
+ if (!l || !c)
465
463
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
466
- E,
464
+ b,
467
465
  {
468
- title: a?.title ?? d("loadingCircle.hangOn"),
469
- subtitle: a?.subtitle ?? d("loadingCircle.validating"),
470
- size: a?.size,
466
+ title: e.spinnerConfig?.title ?? n("loadingCircle.hangOn"),
467
+ subtitle: e.spinnerConfig?.subtitle ?? n("loadingCircle.validating"),
468
+ size: e.spinnerConfig?.size,
471
469
  fullScreen: !0
472
470
  }
473
471
  ) });
474
- if (p.status === "unsupported")
472
+ if (o.status === "unsupported")
475
473
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
476
- de,
474
+ se,
477
475
  {
478
- moduleKey: w,
479
- onNext: () => g.completeModule()
476
+ moduleKey: l,
477
+ onNext: () => a.completeModule()
480
478
  }
481
479
  ) });
482
- if (p.status === "idle" || p.status === "loading" || p.status === "error")
480
+ if (o.status === "idle" || o.status === "loading" || o.status === "error")
483
481
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
484
- E,
482
+ b,
485
483
  {
486
- title: a?.title ?? d("loadingCircle.hangOn"),
487
- subtitle: a?.subtitle ?? d("loadingCircle.validating"),
488
- size: a?.size,
484
+ title: e.spinnerConfig?.title ?? n("loadingCircle.hangOn"),
485
+ subtitle: e.spinnerConfig?.subtitle ?? n("loadingCircle.validating"),
486
+ size: e.spinnerConfig?.size,
489
487
  fullScreen: !0
490
488
  }
491
489
  ) });
492
- const { Component: P } = p;
493
- if (w === "SELFIE")
490
+ const { Component: p } = o;
491
+ if (l === "SELFIE")
494
492
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
495
- P,
493
+ p,
496
494
  {
497
- config: b,
498
- onFinish: () => g.completeModule(),
499
- onError: (S) => {
500
- r?.(S ?? "Selfie verification error");
495
+ config: c,
496
+ onFinish: () => a.completeModule(),
497
+ onError: (u) => {
498
+ t?.(u ?? "Selfie verification error");
501
499
  }
502
500
  },
503
- `selfie-${n.currentStepIndex}`
501
+ `selfie-${r.currentStepIndex}`
504
502
  ) });
505
- if (w === "PHONE")
503
+ if (l === "PHONE")
506
504
  return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
507
- P,
505
+ p,
508
506
  {
509
- config: b,
510
- onFinish: () => g.completeModule(),
511
- onError: (S) => {
512
- r?.(S ?? "Phone verification error");
507
+ config: c,
508
+ onFinish: () => a.completeModule(),
509
+ onError: (u) => {
510
+ t?.(u ?? "Phone verification error");
513
511
  }
514
512
  },
515
- `phone-${n.currentStepIndex}`
513
+ `phone-${r.currentStepIndex}`
516
514
  ) });
517
- if (w === "EMAIL") {
518
- const M = b;
519
- return !M || typeof M.otpVerification != "boolean" || typeof M.otpExpirationInMinutes != "number" ? /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i("div", { children: "Error: Invalid email configuration" }) }) : /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
520
- P,
515
+ if (l === "EMAIL") {
516
+ const d = c;
517
+ return !d || typeof d.otpVerification != "boolean" || typeof d.otpExpirationInMinutes != "number" ? /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i("div", { children: "Error: Invalid email configuration" }) }) : /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
518
+ p,
521
519
  {
522
520
  config: {
523
- ...M,
524
- prefill: M.prefill ?? !1
521
+ ...d,
522
+ prefill: d.prefill ?? !1
525
523
  },
526
- onFinish: () => g.completeModule(),
527
- onError: (S) => {
528
- r?.(S ?? "Email verification error");
524
+ onFinish: () => a.completeModule(),
525
+ onError: (u) => {
526
+ t?.(u ?? "Email verification error");
529
527
  }
530
528
  },
531
- `email-${n.currentStepIndex}`
529
+ `email-${r.currentStepIndex}`
532
530
  ) });
533
531
  }
534
532
  }
535
533
  return null;
536
- }, pe = (t) => /* @__PURE__ */ i("div", { class: "IncodeComponent", children: /* @__PURE__ */ i(me, { ...t }) });
537
- _(
538
- pe,
539
- "incode-flow",
540
- [
541
- "apiURL",
542
- "token",
543
- "wasmConfig",
544
- "lang",
545
- "disableDashboardTheme",
546
- "spinnerConfig",
547
- "onComplete",
548
- "onError"
549
- ],
550
- {
551
- shadow: !1
552
- }
553
- );
534
+ }, ce = ({ config: e, onError: t }) => /* @__PURE__ */ i("div", { class: "IncodeComponent", children: e ? /* @__PURE__ */ i(de, { config: e, onError: t }) : null });
535
+ H(ce, "incode-flow");
554
536
  export {
555
- pe as IncodeFlow,
556
- Ue as preloadIncodeFlow
537
+ ce as IncodeFlow,
538
+ Ie as preloadIncodeFlow
557
539
  };