@incodetech/web 0.0.0-dev-20260402-682edb5 → 0.0.0-dev-20260402-7cf9db4

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,13 +1,13 @@
1
- import { b, u as e, I as O, a as C, S as w, B as y } from "../button-DXIWeie9.js";
1
+ import { b as v, u as e, I as O, a as w, S as C, B as y } from "../button-DXIWeie9.js";
2
2
  import { createEmailManager as P } from "@incodetech/core/email";
3
- import { d as h, y as V } from "../vendor-preact-BoMmvSgn.js";
3
+ import { d as b, y as V } from "../vendor-preact-BoMmvSgn.js";
4
4
  import "@incodetech/core";
5
- import { O as S } from "../otpInput-B85heGC5.js";
5
+ import { O as R } from "../otpInput-B85heGC5.js";
6
6
  import { P as I } from "../page-D4OThpFS.js";
7
- import { r as k } from "../incodeModule-C4XIllao.js";
7
+ import { r as S } from "../incodeModule-C4XIllao.js";
8
8
  import "../uiConfig-DmIn-g8M.js";
9
9
  import "../typography-CBPoLoAP.js";
10
- import { a as L } from "../inputComposed-QzDneavl.js";
10
+ import { a as k } from "../inputComposed-QzDneavl.js";
11
11
  import "../checkbox-wo8qk7tM.js";
12
12
  import "../phoneInputComposed-BAFZQ4Y8.js";
13
13
  import "../dateInputComposed-D5kgh_aC.js";
@@ -15,43 +15,43 @@ import "../captureOverlay-Crv6ZBp_.js";
15
15
  import "../manualCaptureButton-CPZ2xxEI.js";
16
16
  import "../captureFooter-CKqO4KY2.js";
17
17
  import "../countries-DfLkrF0x.js";
18
- const v = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, R = ({
18
+ const h = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, L = ({
19
19
  prefilledEmail: i,
20
20
  emailError: s,
21
- label: m,
22
- disabled: u = !1,
23
- required: n = !1,
21
+ label: d,
22
+ disabled: c = !1,
23
+ required: a = !1,
24
24
  onEmailChange: t
25
25
  }) => {
26
- const { t: r } = b(), [E, p] = h("");
26
+ const { t: l } = v(), [E, p] = b("");
27
27
  V(() => {
28
28
  if (i) {
29
29
  p(i);
30
- const a = v.test(i.trim());
31
- t(i.trim(), a);
30
+ const r = h.test(i.trim());
31
+ t(i.trim(), r);
32
32
  }
33
33
  }, [i, t]);
34
- const f = (a) => {
35
- const d = a.target.value;
36
- p(d);
37
- const l = d.trim(), g = l.length > 0 && v.test(l);
38
- t(l, g);
39
- }, o = s ? "email-error" : void 0;
34
+ const f = (r) => {
35
+ const m = r.target.value;
36
+ p(m);
37
+ const o = m.trim(), u = o.length > 0 && h.test(o);
38
+ t(o, u);
39
+ }, n = s ? "email-error" : void 0;
40
40
  return /* @__PURE__ */ e("div", { class: "IncodeEmailInput", children: /* @__PURE__ */ e("div", { class: "IncodeEmailInputContainer", children: /* @__PURE__ */ e(
41
- L,
41
+ k,
42
42
  {
43
43
  id: "email-input",
44
44
  type: "email",
45
45
  value: E,
46
46
  onInput: f,
47
- placeholder: r("email.placeholder"),
48
- disabled: u,
49
- required: n,
50
- label: m,
47
+ placeholder: l("email.placeholder"),
48
+ disabled: c,
49
+ required: a,
50
+ label: d,
51
51
  "data-testid": "email-input",
52
- "aria-label": m ? void 0 : "Email address",
52
+ "aria-label": d ? void 0 : "Email address",
53
53
  "aria-invalid": s ? "true" : void 0,
54
- "aria-describedby": o || void 0,
54
+ "aria-describedby": n || void 0,
55
55
  autocomplete: "email",
56
56
  error: s,
57
57
  showErrorIcon: !0
@@ -60,10 +60,10 @@ const v = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, R = ({
60
60
  }, T = ({
61
61
  config: i,
62
62
  manager: s,
63
- onFinish: m,
64
- onError: u
63
+ onFinish: d,
64
+ onError: c
65
65
  }) => {
66
- const { t: n } = b(), [t, r] = C(
66
+ const { t: a } = v(), [t, l] = w(
67
67
  () => {
68
68
  if (s) return s;
69
69
  if (!i)
@@ -71,36 +71,36 @@ const v = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, R = ({
71
71
  return P({ config: i });
72
72
  },
73
73
  { manageLifecycle: !s }
74
- ), [E, p] = h(!1);
74
+ ), [E, p] = b(!1);
75
75
  if (t.status === "idle" || t.status === "loadingPrefill" || t.status === "inputting" || t.status === "submitting" || t.status === "sendingInitialOtp") {
76
- const o = t.status === "idle" || t.status === "loadingPrefill" || t.status === "submitting" || t.status === "sendingInitialOtp", a = t.status === "inputting" ? t.prefilledEmail : void 0, c = t.status === "inputting" && t.emailError ? n(t.emailError) : void 0, d = t.status === "inputting" ? t.otpVerification ?? !1 : !1;
76
+ const n = t.status === "idle" || t.status === "loadingPrefill" || t.status === "submitting" || t.status === "sendingInitialOtp", r = t.status === "inputting" ? t.prefilledEmail : void 0, g = t.status === "inputting" && t.emailError ? a(t.emailError) : void 0, m = t.status === "inputting" ? t.otpVerification ?? !1 : !1;
77
77
  return /* @__PURE__ */ e(
78
78
  I,
79
79
  {
80
80
  className: "IncodeEmailPage",
81
- title: n("otp.enterCodeEmail"),
82
- subtitle: d ? n("email.willSendCode") : void 0,
81
+ title: a("otp.enterCodeEmail"),
82
+ subtitle: m ? a("email.willSendCode") : void 0,
83
83
  children: [
84
84
  /* @__PURE__ */ e(
85
- R,
85
+ L,
86
86
  {
87
- prefilledEmail: a,
88
- emailError: c,
89
- disabled: o,
90
- onEmailChange: (l, g) => {
91
- r.setEmail(l, g), p(g);
87
+ prefilledEmail: r,
88
+ emailError: g,
89
+ disabled: n,
90
+ onEmailChange: (o, u) => {
91
+ l.setEmail(o, u), p(u);
92
92
  }
93
93
  }
94
94
  ),
95
- /* @__PURE__ */ e(w, {}),
95
+ /* @__PURE__ */ e(C, {}),
96
96
  /* @__PURE__ */ e(
97
97
  y,
98
98
  {
99
- onClick: () => r.submit(),
99
+ onClick: () => l.submit(),
100
100
  disabled: !E,
101
- isLoading: o,
101
+ isLoading: n,
102
102
  "data-testid": "email-submit",
103
- children: n("common.continue")
103
+ children: a("common.continue")
104
104
  }
105
105
  )
106
106
  ]
@@ -108,45 +108,45 @@ const v = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, R = ({
108
108
  );
109
109
  }
110
110
  if (t.status === "awaitingOtp" || t.status === "verifyingOtp" || t.status === "otpError" || t.status === "resendingOtp") {
111
- const o = t.status === "verifyingOtp", a = t.status === "otpError", c = t.status === "awaitingOtp", d = t.status === "resendingOtp";
111
+ const n = t.status === "verifyingOtp", r = t.status === "otpError", g = t.status === "awaitingOtp", m = t.status === "resendingOtp", o = g || r || n;
112
112
  return /* @__PURE__ */ e(
113
113
  I,
114
114
  {
115
115
  className: "IncodeEmailPage IncodeEmailOtpPage",
116
- title: n("otp.enterCodeEmail"),
116
+ title: a("otp.enterCodeEmail"),
117
117
  children: /* @__PURE__ */ e(
118
- S,
118
+ R,
119
119
  {
120
- resendTimer: c || a ? t.resendTimer : 0,
121
- canResend: c || a ? t.canResend : !1,
122
- error: a ? n(t.otpError) : void 0,
123
- isLoading: o,
124
- disabled: d || o,
125
- onSubmit: (l) => r.submitOtp(l),
126
- onResend: () => r.resendOtp(),
127
- onBack: () => r.back(),
120
+ resendTimer: o ? t.resendTimer : 0,
121
+ canResend: o ? t.canResend : !1,
122
+ error: r ? a(t.otpError) : void 0,
123
+ isLoading: n,
124
+ disabled: m || n,
125
+ onSubmit: (u) => l.submitOtp(u),
126
+ onResend: () => l.resendOtp(),
127
+ onBack: () => l.back(),
128
128
  backLinkText: "otp.changeEmail"
129
129
  }
130
130
  )
131
131
  }
132
132
  );
133
133
  }
134
- return t.status === "finished" ? (m?.(), null) : (t.status === "error" && u?.(t.error), null);
134
+ return t.status === "finished" ? (d?.(), null) : (t.status === "error" && c?.(t.error), null);
135
135
  }, B = ({
136
136
  config: i,
137
137
  manager: s,
138
- onFinish: m,
139
- onError: u
138
+ onFinish: d,
139
+ onError: c
140
140
  }) => /* @__PURE__ */ e(O, { children: i || s ? /* @__PURE__ */ e(
141
141
  T,
142
142
  {
143
143
  config: i,
144
144
  manager: s,
145
- onFinish: m,
146
- onError: u
145
+ onFinish: d,
146
+ onError: c
147
147
  }
148
148
  ) : null });
149
- k(B, "incode-email");
149
+ S(B, "incode-email");
150
150
  export {
151
151
  B as Email
152
152
  };
@@ -1,15 +1,15 @@
1
- import { u as e, I as O, b as C, a as E, S as f, B as v } from "../button-DXIWeie9.js";
2
- import { createPhoneManager as S } from "@incodetech/core/phone";
3
- import { d as w } from "../vendor-preact-BoMmvSgn.js";
1
+ import { u as e, I as O, b as C, a as E, S as g, B as v } from "../button-DXIWeie9.js";
2
+ import { createPhoneManager as w } from "@incodetech/core/phone";
3
+ import { d as S } from "../vendor-preact-BoMmvSgn.js";
4
4
  import "../uiConfig-DmIn-g8M.js";
5
5
  import "@incodetech/core";
6
6
  import { C as y } from "../checkbox-wo8qk7tM.js";
7
7
  import { O as k } from "../otpInput-B85heGC5.js";
8
- import { P as g } from "../page-D4OThpFS.js";
8
+ import { P } from "../page-D4OThpFS.js";
9
9
  import { P as R } from "../phoneInputComposed-BAFZQ4Y8.js";
10
10
  import { r as V } from "../incodeModule-C4XIllao.js";
11
11
  const B = ({
12
- config: i,
12
+ config: r,
13
13
  manager: s,
14
14
  onFinish: d,
15
15
  onError: p
@@ -17,20 +17,20 @@ const B = ({
17
17
  const { t: n } = C(), [t, o] = E(
18
18
  () => {
19
19
  if (s) return s;
20
- if (!i)
20
+ if (!r)
21
21
  throw new Error("Phone config is required");
22
- return S({ config: i });
22
+ return w({ config: r });
23
23
  },
24
24
  { manageLifecycle: !s }
25
- ), [P, b] = w(!1);
25
+ ), [b, I] = S(!1);
26
26
  if (t.status === "idle" || t.status === "loadingPrefill" || t.status === "inputting" || t.status === "submitting" || t.status === "sendingInitialOtp") {
27
- const r = t.status === "idle" || t.status === "loadingPrefill" || t.status === "submitting" || t.status === "sendingInitialOtp", a = t.status === "inputting" ? t.countryCode : "US", u = t.status === "inputting" ? t.prefilledPhone : void 0, l = t.status === "inputting" && t.phoneError ? n(t.phoneError) : void 0, c = t.status === "inputting" ? t.otpVerification ?? !1 : !1, I = t.status === "inputting" ? t.optinEnabled ?? !1 : !1;
27
+ const i = t.status === "idle" || t.status === "loadingPrefill" || t.status === "submitting" || t.status === "sendingInitialOtp", a = t.status === "inputting" ? t.countryCode : "US", l = t.status === "inputting" ? t.prefilledPhone : void 0, c = t.status === "inputting" && t.phoneError ? n(t.phoneError) : void 0, u = t.status === "inputting" ? t.otpVerification ?? !1 : !1, h = t.status === "inputting" ? t.optinEnabled ?? !1 : !1;
28
28
  return /* @__PURE__ */ e(
29
- g,
29
+ P,
30
30
  {
31
31
  className: "IncodePhonePage",
32
32
  title: n("phone.verify"),
33
- subtitle: c ? n("email.willSendCode") : void 0,
33
+ subtitle: u ? n("email.willSendCode") : void 0,
34
34
  children: [
35
35
  /* @__PURE__ */ e("div", { class: "IncodePhoneInputContainer", children: [
36
36
  /* @__PURE__ */ e(
@@ -38,18 +38,18 @@ const B = ({
38
38
  {
39
39
  id: "phone",
40
40
  countryCode: a,
41
- value: u,
42
- error: l,
43
- disabled: r,
44
- onChange: (m, h) => {
45
- o.setPhoneNumber(m, h), b(h);
41
+ value: l,
42
+ error: c,
43
+ disabled: i,
44
+ onChange: (m, f) => {
45
+ o.setPhoneNumber(m, f), I(f);
46
46
  },
47
47
  "data-testid": "phone-input",
48
48
  showErrorIcon: !0
49
49
  }
50
50
  ),
51
- /* @__PURE__ */ e(f, { size: 16 }),
52
- I && /* @__PURE__ */ e(
51
+ /* @__PURE__ */ e(g, { size: 16 }),
52
+ h && /* @__PURE__ */ e(
53
53
  y,
54
54
  {
55
55
  id: "phone-optin",
@@ -59,13 +59,13 @@ const B = ({
59
59
  }
60
60
  )
61
61
  ] }),
62
- /* @__PURE__ */ e(f, {}),
62
+ /* @__PURE__ */ e(g, {}),
63
63
  /* @__PURE__ */ e(
64
64
  v,
65
65
  {
66
66
  onClick: () => o.submit(),
67
- disabled: !P,
68
- isLoading: r,
67
+ disabled: !b,
68
+ isLoading: i,
69
69
  "data-testid": "phone-submit",
70
70
  children: n("common.continue")
71
71
  }
@@ -75,16 +75,16 @@ const B = ({
75
75
  );
76
76
  }
77
77
  if (t.status === "awaitingOtp" || t.status === "verifyingOtp" || t.status === "otpError" || t.status === "resendingOtp") {
78
- const r = t.status === "verifyingOtp", a = t.status === "otpError", u = t.status === "awaitingOtp", l = t.status === "resendingOtp";
79
- return /* @__PURE__ */ e(g, { className: "IncodePhonePage", title: n("otp.enterCodeSMS"), children: /* @__PURE__ */ e(
78
+ const i = t.status === "verifyingOtp", a = t.status === "otpError", l = t.status === "awaitingOtp", c = t.status === "resendingOtp", u = l || a || i;
79
+ return /* @__PURE__ */ e(P, { className: "IncodePhonePage", title: n("otp.enterCodeSMS"), children: /* @__PURE__ */ e(
80
80
  k,
81
81
  {
82
- resendTimer: u || a ? t.resendTimer : 0,
83
- canResend: u || a ? t.canResend : !1,
84
- isLoading: r,
85
- disabled: l || r,
82
+ resendTimer: u ? t.resendTimer : 0,
83
+ canResend: u ? t.canResend : !1,
84
+ isLoading: i,
85
+ disabled: c || i,
86
86
  error: a ? n(t.otpError) : void 0,
87
- onSubmit: (c) => o.submitOtp(c),
87
+ onSubmit: (h) => o.submitOtp(h),
88
88
  onResend: () => o.resendOtp(),
89
89
  onBack: () => o.back()
90
90
  }
@@ -92,14 +92,14 @@ const B = ({
92
92
  }
93
93
  return t.status === "finished" ? (d?.(), null) : (t.status === "error" && p?.(t.error), null);
94
94
  }, L = ({
95
- config: i,
95
+ config: r,
96
96
  manager: s,
97
97
  onFinish: d,
98
98
  onError: p
99
- }) => /* @__PURE__ */ e(O, { children: i || s ? /* @__PURE__ */ e(
99
+ }) => /* @__PURE__ */ e(O, { children: r || s ? /* @__PURE__ */ e(
100
100
  B,
101
101
  {
102
- config: i,
102
+ config: r,
103
103
  manager: s,
104
104
  onFinish: d,
105
105
  onError: p
@@ -1,238 +1,708 @@
1
- import { u, I as k, b as T, a as D, S as R, B as w } from "../button-DXIWeie9.js";
2
- import { D as N, A as I, q as E, F as L, y, d as O, T as W } from "../vendor-preact-BoMmvSgn.js";
1
+ var O = Object.defineProperty;
2
+ var L = (o, n, t) => n in o ? O(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
3
+ var g = (o, n, t) => L(o, typeof n != "symbol" ? n + "" : n, t);
4
+ import { u as w, I, b as B, a as A, S as k, B as T } from "../button-DXIWeie9.js";
5
+ import { D as R, A as P, q as W, F, y as E, d as N, T as z } from "../vendor-preact-BoMmvSgn.js";
3
6
  import "@incodetech/core";
4
7
  import "../uiConfig-DmIn-g8M.js";
5
- import { P } from "../page-D4OThpFS.js";
6
- import { r as z } from "../incodeModule-C4XIllao.js";
7
- import { SignaturePad as M, createSignatureManager as H } from "@incodetech/core/signature";
8
- import { S as A } from "../successIcon-BZphSsQr.js";
9
- import { f as U } from "../typography-CBPoLoAP.js";
10
- const F = (r) => {
8
+ import { P as M } from "../page-D4OThpFS.js";
9
+ import { r as $ } from "../incodeModule-C4XIllao.js";
10
+ import { createSignatureManager as G } from "@incodetech/core/signature";
11
+ import { S as V } from "../successIcon-BZphSsQr.js";
12
+ import { f as q } from "../typography-CBPoLoAP.js";
13
+ var b = class {
14
+ constructor(o, n, t, e) {
15
+ g(this, "x");
16
+ g(this, "y");
17
+ g(this, "pressure");
18
+ g(this, "time");
19
+ if (isNaN(o) || isNaN(n))
20
+ throw new Error(`Point is invalid: (${o}, ${n})`);
21
+ this.x = +o, this.y = +n, this.pressure = t || 0, this.time = e || Date.now();
22
+ }
23
+ distanceTo(o) {
24
+ return Math.sqrt(
25
+ Math.pow(this.x - o.x, 2) + Math.pow(this.y - o.y, 2)
26
+ );
27
+ }
28
+ equals(o) {
29
+ return this.x === o.x && this.y === o.y && this.pressure === o.pressure && this.time === o.time;
30
+ }
31
+ velocityFrom(o) {
32
+ return this.time !== o.time ? this.distanceTo(o) / (this.time - o.time) : 0;
33
+ }
34
+ }, H = class D {
35
+ constructor(n, t, e, i, s, a) {
36
+ this.startPoint = n, this.control2 = t, this.control1 = e, this.endPoint = i, this.startWidth = s, this.endWidth = a;
37
+ }
38
+ static fromPoints(n, t) {
39
+ const e = this.calculateControlPoints(n[0], n[1], n[2]).c2, i = this.calculateControlPoints(n[1], n[2], n[3]).c1;
40
+ return new D(n[1], e, i, n[2], t.start, t.end);
41
+ }
42
+ static calculateControlPoints(n, t, e) {
43
+ const i = n.x - t.x, s = n.y - t.y, a = t.x - e.x, l = t.y - e.y, h = { x: (n.x + t.x) / 2, y: (n.y + t.y) / 2 }, c = { x: (t.x + e.x) / 2, y: (t.y + e.y) / 2 }, d = Math.sqrt(i * i + s * s), r = Math.sqrt(a * a + l * l), u = h.x - c.x, f = h.y - c.y, _ = d + r == 0 ? 0 : r / (d + r), v = { x: c.x + u * _, y: c.y + f * _ }, m = t.x - v.x, y = t.y - v.y;
44
+ return {
45
+ c1: new b(h.x + m, h.y + y),
46
+ c2: new b(c.x + m, c.y + y)
47
+ };
48
+ }
49
+ // Returns approximated length. Code taken from https://www.lemoda.net/maths/bezier-length/index.html.
50
+ length() {
51
+ let t = 0, e, i;
52
+ for (let s = 0; s <= 10; s += 1) {
53
+ const a = s / 10, l = this.point(
54
+ a,
55
+ this.startPoint.x,
56
+ this.control1.x,
57
+ this.control2.x,
58
+ this.endPoint.x
59
+ ), h = this.point(
60
+ a,
61
+ this.startPoint.y,
62
+ this.control1.y,
63
+ this.control2.y,
64
+ this.endPoint.y
65
+ );
66
+ if (s > 0) {
67
+ const c = l - e, d = h - i;
68
+ t += Math.sqrt(c * c + d * d);
69
+ }
70
+ e = l, i = h;
71
+ }
72
+ return t;
73
+ }
74
+ // Calculate parametric value of x or y given t and the four point coordinates of a cubic bezier curve.
75
+ point(n, t, e, i, s) {
76
+ return t * (1 - n) * (1 - n) * (1 - n) + 3 * e * (1 - n) * (1 - n) * n + 3 * i * (1 - n) * n * n + s * n * n * n;
77
+ }
78
+ }, j = class {
79
+ /* tslint:enable: variable-name */
80
+ constructor() {
81
+ /* tslint:disable: variable-name */
82
+ g(this, "_et");
83
+ try {
84
+ this._et = new EventTarget();
85
+ } catch {
86
+ this._et = document;
87
+ }
88
+ }
89
+ addEventListener(o, n, t) {
90
+ this._et.addEventListener(o, n, t);
91
+ }
92
+ dispatchEvent(o) {
93
+ return this._et.dispatchEvent(o);
94
+ }
95
+ removeEventListener(o, n, t) {
96
+ this._et.removeEventListener(o, n, t);
97
+ }
98
+ };
99
+ function X(o, n = 250) {
100
+ let t = 0, e = null, i, s, a;
101
+ const l = () => {
102
+ t = Date.now(), e = null, i = o.apply(s, a), e || (s = null, a = []);
103
+ };
104
+ return function(...c) {
105
+ const d = Date.now(), r = n - (d - t);
106
+ return s = this, a = c, r <= 0 || r > n ? (e && (clearTimeout(e), e = null), t = d, i = o.apply(s, a), e || (s = null, a = [])) : e || (e = window.setTimeout(l, r)), i;
107
+ };
108
+ }
109
+ var Y = class C extends j {
110
+ /* tslint:enable: variable-name */
111
+ constructor(t, e = {}) {
112
+ super();
113
+ // Public stuff
114
+ g(this, "dotSize");
115
+ g(this, "minWidth");
116
+ g(this, "maxWidth");
117
+ g(this, "penColor");
118
+ g(this, "minDistance");
119
+ g(this, "velocityFilterWeight");
120
+ g(this, "compositeOperation");
121
+ g(this, "backgroundColor");
122
+ g(this, "throttle");
123
+ g(this, "canvasContextOptions");
124
+ // Private stuff
125
+ /* tslint:disable: variable-name */
126
+ g(this, "_ctx");
127
+ g(this, "_drawingStroke", !1);
128
+ g(this, "_isEmpty", !0);
129
+ g(this, "_dataUrl");
130
+ g(this, "_dataUrlOptions");
131
+ g(this, "_lastPoints", []);
132
+ // Stores up to 4 most recent points; used to generate a new curve
133
+ g(this, "_data", []);
134
+ // Stores all points in groups (one group per line or dot)
135
+ g(this, "_lastVelocity", 0);
136
+ g(this, "_lastWidth", 0);
137
+ g(this, "_strokeMoveUpdate");
138
+ g(this, "_strokePointerId");
139
+ this.canvas = t, this.velocityFilterWeight = e.velocityFilterWeight || 0.7, this.minWidth = e.minWidth || 0.5, this.maxWidth = e.maxWidth || 2.5, this.throttle = e.throttle ?? 16, this.minDistance = e.minDistance ?? 5, this.dotSize = e.dotSize || 0, this.penColor = e.penColor || "black", this.backgroundColor = e.backgroundColor || "rgba(0,0,0,0)", this.compositeOperation = e.compositeOperation || "source-over", this.canvasContextOptions = e.canvasContextOptions ?? {}, this._strokeMoveUpdate = this.throttle ? X(C.prototype._strokeUpdate, this.throttle) : C.prototype._strokeUpdate, this._handleMouseDown = this._handleMouseDown.bind(this), this._handleMouseMove = this._handleMouseMove.bind(this), this._handleMouseUp = this._handleMouseUp.bind(this), this._handleTouchStart = this._handleTouchStart.bind(this), this._handleTouchMove = this._handleTouchMove.bind(this), this._handleTouchEnd = this._handleTouchEnd.bind(this), this._handlePointerDown = this._handlePointerDown.bind(this), this._handlePointerMove = this._handlePointerMove.bind(this), this._handlePointerUp = this._handlePointerUp.bind(this), this._handlePointerCancel = this._handlePointerCancel.bind(this), this._handleTouchCancel = this._handleTouchCancel.bind(this), this._ctx = t.getContext(
140
+ "2d",
141
+ this.canvasContextOptions
142
+ ), this.clear(), this.on();
143
+ }
144
+ clear() {
145
+ const { _ctx: t, canvas: e } = this;
146
+ t.fillStyle = this.backgroundColor, t.clearRect(0, 0, e.width, e.height), t.fillRect(0, 0, e.width, e.height), this._data = [], this._reset(this._getPointGroupOptions()), this._isEmpty = !0, this._dataUrl = void 0, this._dataUrlOptions = void 0, this._strokePointerId = void 0;
147
+ }
148
+ redraw() {
149
+ const t = this._data, e = this._dataUrl, i = this._dataUrlOptions;
150
+ this.clear(), e && this.fromDataURL(e, i), this.fromData(t, { clear: !1 });
151
+ }
152
+ fromDataURL(t, e = {}) {
153
+ return new Promise((i, s) => {
154
+ const a = new Image(), l = e.ratio || window.devicePixelRatio || 1, h = e.width || this.canvas.width / l, c = e.height || this.canvas.height / l, d = e.xOffset || 0, r = e.yOffset || 0;
155
+ this._reset(this._getPointGroupOptions()), a.onload = () => {
156
+ this._ctx.drawImage(a, d, r, h, c), i();
157
+ }, a.onerror = (u) => {
158
+ s(u);
159
+ }, a.crossOrigin = "anonymous", a.src = t, this._isEmpty = !1, this._dataUrl = t, this._dataUrlOptions = { ...e };
160
+ });
161
+ }
162
+ toDataURL(t = "image/png", e) {
163
+ switch (t) {
164
+ case "image/svg+xml":
165
+ return typeof e != "object" && (e = void 0), `data:image/svg+xml;base64,${btoa(
166
+ this.toSVG(e)
167
+ )}`;
168
+ default:
169
+ return typeof e != "number" && (e = void 0), this.canvas.toDataURL(t, e);
170
+ }
171
+ }
172
+ on() {
173
+ this.canvas.style.touchAction = "none", this.canvas.style.msTouchAction = "none", this.canvas.style.userSelect = "none", this.canvas.style.webkitUserSelect = "none";
174
+ const t = /Macintosh/.test(navigator.userAgent) && "ontouchstart" in document;
175
+ window.PointerEvent && !t ? this._handlePointerEvents() : (this._handleMouseEvents(), "ontouchstart" in window && this._handleTouchEvents());
176
+ }
177
+ off() {
178
+ this.canvas.style.touchAction = "auto", this.canvas.style.msTouchAction = "auto", this.canvas.style.userSelect = "auto", this.canvas.style.webkitUserSelect = "auto", this.canvas.removeEventListener("pointerdown", this._handlePointerDown), this.canvas.removeEventListener("mousedown", this._handleMouseDown), this.canvas.removeEventListener("touchstart", this._handleTouchStart), this._removeMoveUpEventListeners();
179
+ }
180
+ _getListenerFunctions() {
181
+ const t = window.document === this.canvas.ownerDocument ? window : this.canvas.ownerDocument.defaultView ?? this.canvas.ownerDocument;
182
+ return {
183
+ addEventListener: t.addEventListener.bind(
184
+ t
185
+ ),
186
+ removeEventListener: t.removeEventListener.bind(
187
+ t
188
+ )
189
+ };
190
+ }
191
+ _removeMoveUpEventListeners() {
192
+ const { removeEventListener: t } = this._getListenerFunctions();
193
+ t("pointermove", this._handlePointerMove), t("pointerup", this._handlePointerUp), t("pointercancel", this._handlePointerCancel), t("mousemove", this._handleMouseMove), t("mouseup", this._handleMouseUp), t("touchmove", this._handleTouchMove), t("touchend", this._handleTouchEnd), t("touchcancel", this._handleTouchCancel);
194
+ }
195
+ isEmpty() {
196
+ return this._isEmpty;
197
+ }
198
+ fromData(t, { clear: e = !0 } = {}) {
199
+ e && this.clear(), this._fromData(
200
+ t,
201
+ this._drawCurve.bind(this),
202
+ this._drawDot.bind(this)
203
+ ), this._data = this._data.concat(t);
204
+ }
205
+ toData() {
206
+ return this._data;
207
+ }
208
+ _isLeftButtonPressed(t, e) {
209
+ return e ? t.buttons === 1 : (t.buttons & 1) === 1;
210
+ }
211
+ _pointerEventToSignatureEvent(t) {
212
+ return {
213
+ event: t,
214
+ type: t.type,
215
+ x: t.clientX,
216
+ y: t.clientY,
217
+ pressure: "pressure" in t ? t.pressure : 0
218
+ };
219
+ }
220
+ _touchEventToSignatureEvent(t) {
221
+ const e = t.changedTouches[0];
222
+ return {
223
+ event: t,
224
+ type: t.type,
225
+ x: e.clientX,
226
+ y: e.clientY,
227
+ pressure: e.force
228
+ };
229
+ }
230
+ // Event handlers
231
+ _handleMouseDown(t) {
232
+ !this._isLeftButtonPressed(t, !0) || this._drawingStroke || this._strokeBegin(this._pointerEventToSignatureEvent(t));
233
+ }
234
+ _handleMouseMove(t) {
235
+ if (!this._isLeftButtonPressed(t, !0) || !this._drawingStroke) {
236
+ this._strokeEnd(this._pointerEventToSignatureEvent(t), !1);
237
+ return;
238
+ }
239
+ this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t));
240
+ }
241
+ _handleMouseUp(t) {
242
+ this._isLeftButtonPressed(t) || this._strokeEnd(this._pointerEventToSignatureEvent(t));
243
+ }
244
+ _handleTouchStart(t) {
245
+ t.targetTouches.length !== 1 || this._drawingStroke || (t.cancelable && t.preventDefault(), this._strokeBegin(this._touchEventToSignatureEvent(t)));
246
+ }
247
+ _handleTouchMove(t) {
248
+ if (t.targetTouches.length === 1) {
249
+ if (t.cancelable && t.preventDefault(), !this._drawingStroke) {
250
+ this._strokeEnd(this._touchEventToSignatureEvent(t), !1);
251
+ return;
252
+ }
253
+ this._strokeMoveUpdate(this._touchEventToSignatureEvent(t));
254
+ }
255
+ }
256
+ _handleTouchEnd(t) {
257
+ t.targetTouches.length === 0 && (t.cancelable && t.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(t)));
258
+ }
259
+ _handlePointerCancel(t) {
260
+ this._allowPointerId(t) && (t.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(t), !1));
261
+ }
262
+ _handleTouchCancel(t) {
263
+ t.cancelable && t.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(t), !1);
264
+ }
265
+ _getPointerId(t) {
266
+ return t.persistentDeviceId || t.pointerId;
267
+ }
268
+ _allowPointerId(t, e = !1) {
269
+ return typeof this._strokePointerId > "u" ? e : this._getPointerId(t) === this._strokePointerId;
270
+ }
271
+ _handlePointerDown(t) {
272
+ this._drawingStroke || !this._isLeftButtonPressed(t) || !this._allowPointerId(t, !0) || (this._strokePointerId = this._getPointerId(t), t.preventDefault(), this._strokeBegin(this._pointerEventToSignatureEvent(t)));
273
+ }
274
+ _handlePointerMove(t) {
275
+ if (this._allowPointerId(t)) {
276
+ if (!this._isLeftButtonPressed(t, !0) || !this._drawingStroke) {
277
+ this._strokeEnd(this._pointerEventToSignatureEvent(t), !1);
278
+ return;
279
+ }
280
+ t.preventDefault(), this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t));
281
+ }
282
+ }
283
+ _handlePointerUp(t) {
284
+ this._isLeftButtonPressed(t) || !this._allowPointerId(t) || (t.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(t)));
285
+ }
286
+ _getPointGroupOptions(t) {
287
+ return {
288
+ penColor: t && "penColor" in t ? t.penColor : this.penColor,
289
+ dotSize: t && "dotSize" in t ? t.dotSize : this.dotSize,
290
+ minWidth: t && "minWidth" in t ? t.minWidth : this.minWidth,
291
+ maxWidth: t && "maxWidth" in t ? t.maxWidth : this.maxWidth,
292
+ velocityFilterWeight: t && "velocityFilterWeight" in t ? t.velocityFilterWeight : this.velocityFilterWeight,
293
+ compositeOperation: t && "compositeOperation" in t ? t.compositeOperation : this.compositeOperation
294
+ };
295
+ }
296
+ // Private methods
297
+ _strokeBegin(t) {
298
+ if (!this.dispatchEvent(
299
+ new CustomEvent("beginStroke", { detail: t, cancelable: !0 })
300
+ ))
301
+ return;
302
+ const { addEventListener: i } = this._getListenerFunctions();
303
+ switch (t.event.type) {
304
+ case "mousedown":
305
+ i("mousemove", this._handleMouseMove, {
306
+ passive: !1
307
+ }), i("mouseup", this._handleMouseUp, { passive: !1 });
308
+ break;
309
+ case "touchstart":
310
+ i("touchmove", this._handleTouchMove, {
311
+ passive: !1
312
+ }), i("touchend", this._handleTouchEnd, { passive: !1 }), i("touchcancel", this._handleTouchCancel, { passive: !1 });
313
+ break;
314
+ case "pointerdown":
315
+ i("pointermove", this._handlePointerMove, {
316
+ passive: !1
317
+ }), i("pointerup", this._handlePointerUp, {
318
+ passive: !1
319
+ }), i("pointercancel", this._handlePointerCancel, {
320
+ passive: !1
321
+ });
322
+ break;
323
+ }
324
+ this._drawingStroke = !0;
325
+ const s = this._getPointGroupOptions(), a = {
326
+ ...s,
327
+ points: []
328
+ };
329
+ this._data.push(a), this._reset(s), this._strokeUpdate(t);
330
+ }
331
+ _strokeUpdate(t) {
332
+ if (!this._drawingStroke)
333
+ return;
334
+ if (this._data.length === 0) {
335
+ this._strokeBegin(t);
336
+ return;
337
+ }
338
+ this.dispatchEvent(
339
+ new CustomEvent("beforeUpdateStroke", { detail: t })
340
+ );
341
+ const e = this._createPoint(t.x, t.y, t.pressure), i = this._data[this._data.length - 1], s = i.points, a = s.length > 0 && s[s.length - 1], l = a ? e.distanceTo(a) <= this.minDistance : !1, h = this._getPointGroupOptions(i);
342
+ if (!a || !(a && l)) {
343
+ const c = this._addPoint(e, h);
344
+ a ? c && this._drawCurve(c, h) : this._drawDot(e, h), s.push({
345
+ time: e.time,
346
+ x: e.x,
347
+ y: e.y,
348
+ pressure: e.pressure
349
+ });
350
+ }
351
+ this.dispatchEvent(new CustomEvent("afterUpdateStroke", { detail: t }));
352
+ }
353
+ _strokeEnd(t, e = !0) {
354
+ this._removeMoveUpEventListeners(), this._drawingStroke && (e && this._strokeUpdate(t), this._drawingStroke = !1, this._strokePointerId = void 0, this.dispatchEvent(new CustomEvent("endStroke", { detail: t })));
355
+ }
356
+ _handlePointerEvents() {
357
+ this._drawingStroke = !1, this.canvas.addEventListener("pointerdown", this._handlePointerDown, {
358
+ passive: !1
359
+ });
360
+ }
361
+ _handleMouseEvents() {
362
+ this._drawingStroke = !1, this.canvas.addEventListener("mousedown", this._handleMouseDown, {
363
+ passive: !1
364
+ });
365
+ }
366
+ _handleTouchEvents() {
367
+ this.canvas.addEventListener("touchstart", this._handleTouchStart, {
368
+ passive: !1
369
+ });
370
+ }
371
+ // Called when a new line is started
372
+ _reset(t) {
373
+ this._lastPoints = [], this._lastVelocity = 0, this._lastWidth = (t.minWidth + t.maxWidth) / 2, this._ctx.fillStyle = t.penColor, this._ctx.globalCompositeOperation = t.compositeOperation;
374
+ }
375
+ _createPoint(t, e, i) {
376
+ const s = this.canvas.getBoundingClientRect();
377
+ return new b(
378
+ t - s.left,
379
+ e - s.top,
380
+ i,
381
+ (/* @__PURE__ */ new Date()).getTime()
382
+ );
383
+ }
384
+ // Add point to _lastPoints array and generate a new curve if there are enough points (i.e. 3)
385
+ _addPoint(t, e) {
386
+ const { _lastPoints: i } = this;
387
+ if (i.push(t), i.length > 2) {
388
+ i.length === 3 && i.unshift(i[0]);
389
+ const s = this._calculateCurveWidths(
390
+ i[1],
391
+ i[2],
392
+ e
393
+ ), a = H.fromPoints(i, s);
394
+ return i.shift(), a;
395
+ }
396
+ return null;
397
+ }
398
+ _calculateCurveWidths(t, e, i) {
399
+ const s = i.velocityFilterWeight * e.velocityFrom(t) + (1 - i.velocityFilterWeight) * this._lastVelocity, a = this._strokeWidth(s, i), l = {
400
+ end: a,
401
+ start: this._lastWidth
402
+ };
403
+ return this._lastVelocity = s, this._lastWidth = a, l;
404
+ }
405
+ _strokeWidth(t, e) {
406
+ return Math.max(e.maxWidth / (t + 1), e.minWidth);
407
+ }
408
+ _drawCurveSegment(t, e, i) {
409
+ const s = this._ctx;
410
+ s.moveTo(t, e), s.arc(t, e, i, 0, 2 * Math.PI, !1), this._isEmpty = !1;
411
+ }
412
+ _drawCurve(t, e) {
413
+ const i = this._ctx, s = t.endWidth - t.startWidth, a = Math.ceil(t.length()) * 2;
414
+ i.beginPath(), i.fillStyle = e.penColor;
415
+ for (let l = 0; l < a; l += 1) {
416
+ const h = l / a, c = h * h, d = c * h, r = 1 - h, u = r * r, f = u * r;
417
+ let _ = f * t.startPoint.x;
418
+ _ += 3 * u * h * t.control1.x, _ += 3 * r * c * t.control2.x, _ += d * t.endPoint.x;
419
+ let v = f * t.startPoint.y;
420
+ v += 3 * u * h * t.control1.y, v += 3 * r * c * t.control2.y, v += d * t.endPoint.y;
421
+ const m = Math.min(
422
+ t.startWidth + d * s,
423
+ e.maxWidth
424
+ );
425
+ this._drawCurveSegment(_, v, m);
426
+ }
427
+ i.closePath(), i.fill();
428
+ }
429
+ _drawDot(t, e) {
430
+ const i = this._ctx, s = e.dotSize > 0 ? e.dotSize : (e.minWidth + e.maxWidth) / 2;
431
+ i.beginPath(), this._drawCurveSegment(t.x, t.y, s), i.closePath(), i.fillStyle = e.penColor, i.fill();
432
+ }
433
+ _fromData(t, e, i) {
434
+ for (const s of t) {
435
+ const { points: a } = s, l = this._getPointGroupOptions(s);
436
+ if (a.length > 1)
437
+ for (let h = 0; h < a.length; h += 1) {
438
+ const c = a[h], d = new b(
439
+ c.x,
440
+ c.y,
441
+ c.pressure,
442
+ c.time
443
+ );
444
+ h === 0 && this._reset(l);
445
+ const r = this._addPoint(d, l);
446
+ r && e(r, l);
447
+ }
448
+ else
449
+ this._reset(l), i(a[0], l);
450
+ }
451
+ }
452
+ toSVG({ includeBackgroundColor: t = !1, includeDataUrl: e = !1 } = {}) {
453
+ const i = this._data, s = Math.max(window.devicePixelRatio || 1, 1), a = 0, l = 0, h = this.canvas.width / s, c = this.canvas.height / s, d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
454
+ if (d.setAttribute("xmlns", "http://www.w3.org/2000/svg"), d.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), d.setAttribute("viewBox", `${a} ${l} ${h} ${c}`), d.setAttribute("width", h.toString()), d.setAttribute("height", c.toString()), t && this.backgroundColor) {
455
+ const r = document.createElement("rect");
456
+ r.setAttribute("width", "100%"), r.setAttribute("height", "100%"), r.setAttribute("fill", this.backgroundColor), d.appendChild(r);
457
+ }
458
+ if (e && this._dataUrl) {
459
+ const r = this._dataUrlOptions?.ratio || window.devicePixelRatio || 1, u = this._dataUrlOptions?.width || this.canvas.width / r, f = this._dataUrlOptions?.height || this.canvas.height / r, _ = this._dataUrlOptions?.xOffset || 0, v = this._dataUrlOptions?.yOffset || 0, m = document.createElement("image");
460
+ m.setAttribute("x", _.toString()), m.setAttribute("y", v.toString()), m.setAttribute("width", u.toString()), m.setAttribute("height", f.toString()), m.setAttribute("preserveAspectRatio", "none"), m.setAttribute("href", this._dataUrl), d.appendChild(m);
461
+ }
462
+ return this._fromData(
463
+ i,
464
+ (r, { penColor: u }) => {
465
+ const f = document.createElement("path");
466
+ if (!isNaN(r.control1.x) && !isNaN(r.control1.y) && !isNaN(r.control2.x) && !isNaN(r.control2.y)) {
467
+ const _ = `M ${r.startPoint.x.toFixed(3)},${r.startPoint.y.toFixed(
468
+ 3
469
+ )} C ${r.control1.x.toFixed(3)},${r.control1.y.toFixed(3)} ${r.control2.x.toFixed(3)},${r.control2.y.toFixed(3)} ${r.endPoint.x.toFixed(3)},${r.endPoint.y.toFixed(3)}`;
470
+ f.setAttribute("d", _), f.setAttribute("stroke-width", (r.endWidth * 2.25).toFixed(3)), f.setAttribute("stroke", u), f.setAttribute("fill", "none"), f.setAttribute("stroke-linecap", "round"), d.appendChild(f);
471
+ }
472
+ },
473
+ (r, { penColor: u, dotSize: f, minWidth: _, maxWidth: v }) => {
474
+ const m = document.createElement("circle"), y = f > 0 ? f : (_ + v) / 2;
475
+ m.setAttribute("r", y.toString()), m.setAttribute("cx", r.x.toString()), m.setAttribute("cy", r.y.toString()), m.setAttribute("fill", u), d.appendChild(m);
476
+ }
477
+ ), d.outerHTML;
478
+ }
479
+ };
480
+ const K = (o) => {
11
481
  if (typeof document > "u") return null;
12
- const e = document.createElement("div");
13
- e.style.color = r, e.style.position = "absolute", e.style.visibility = "hidden", document.body.appendChild(e);
14
- const a = getComputedStyle(e).color;
15
- if (document.body.removeChild(e), !a || a === "transparent") return null;
16
- const s = a.match(/\d+/g);
17
- if (s && s.length >= 3) {
18
- const t = Number.parseInt(s[0], 10), d = Number.parseInt(s[1], 10), C = Number.parseInt(s[2], 10), m = (c) => {
19
- const l = c.toString(16);
20
- return l.length === 1 ? `0${l}` : l;
482
+ const n = document.createElement("div");
483
+ n.style.color = o, n.style.position = "absolute", n.style.visibility = "hidden", document.body.appendChild(n);
484
+ const t = getComputedStyle(n).color;
485
+ if (document.body.removeChild(n), !t || t === "transparent") return null;
486
+ const e = t.match(/\d+/g);
487
+ if (e && e.length >= 3) {
488
+ const i = Number.parseInt(e[0], 10), s = Number.parseInt(e[1], 10), a = Number.parseInt(e[2], 10), l = (h) => {
489
+ const c = h.toString(16);
490
+ return c.length === 1 ? `0${c}` : c;
21
491
  };
22
- return `#${m(t)}${m(d)}${m(C)}`;
492
+ return `#${l(i)}${l(s)}${l(a)}`;
23
493
  }
24
494
  return null;
25
- }, V = "var(--icon-neutral-800)", _ = "#ffffff", $ = (r) => {
26
- const e = document.createElement("canvas");
27
- e.width = r.width, e.height = r.height;
28
- const a = e.getContext("2d");
29
- if (!a)
495
+ }, J = "var(--icon-neutral-800)", Q = "#ffffff", Z = (o) => {
496
+ const n = document.createElement("canvas");
497
+ n.width = o.width, n.height = o.height;
498
+ const t = n.getContext("2d");
499
+ if (!t)
30
500
  throw new Error("Canvas 2D context is not available");
31
- return a.fillStyle = _, a.fillRect(0, 0, e.width, e.height), a.drawImage(r, 0, 0), e;
32
- }, j = (r, e, a) => new Promise((s, t) => {
33
- r.toBlob(
34
- (d) => {
35
- d ? s(d) : t(new Error("Canvas toBlob() returned null"));
501
+ return t.fillStyle = Q, t.fillRect(0, 0, n.width, n.height), t.drawImage(o, 0, 0), n;
502
+ }, tt = (o, n, t) => new Promise((e, i) => {
503
+ o.toBlob(
504
+ (s) => {
505
+ s ? e(s) : i(new Error("Canvas toBlob() returned null"));
36
506
  },
37
- e,
38
- e === "image/jpeg" || e === "image/webp" ? a : void 0
507
+ n,
508
+ n === "image/jpeg" || n === "image/webp" ? t : void 0
39
509
  );
40
- }), x = N(
510
+ }), U = R(
41
511
  ({
42
- onBeginStroke: r,
43
- hasDrawing: e,
44
- placeholder: a,
45
- customPenColor: s,
46
- customPenStrokeWidth: t,
47
- customBackgroundColor: d
48
- }, C) => {
49
- const m = I(null), c = I(null), l = I(null), h = I(r);
50
- h.current = r;
51
- const S = E(() => {
52
- const i = m.current, g = c.current, o = l.current;
53
- if (!i || !g || !o) return;
54
- const p = Math.max(window.devicePixelRatio || 1, 1), b = g.getContext("2d"), { width: B, height: v } = i.getBoundingClientRect();
55
- if (B === 0 || v === 0 || !b) return;
56
- const n = o.isEmpty() ? null : o.toData();
57
- g.width = Math.floor(B * p), g.height = Math.floor(v * p), b.setTransform(p, 0, 0, p, 0, 0), n ? o.fromData(n, { clear: !0 }) : o.clear();
512
+ onBeginStroke: o,
513
+ hasDrawing: n,
514
+ placeholder: t,
515
+ customPenColor: e,
516
+ customPenStrokeWidth: i,
517
+ customBackgroundColor: s
518
+ }, a) => {
519
+ const l = P(null), h = P(null), c = P(null), d = P(o);
520
+ d.current = o;
521
+ const r = W(() => {
522
+ const u = l.current, f = h.current, _ = c.current;
523
+ if (!u || !f || !_) return;
524
+ const v = Math.max(window.devicePixelRatio || 1, 1), m = f.getContext("2d"), { width: y, height: S } = u.getBoundingClientRect();
525
+ if (y === 0 || S === 0 || !m) return;
526
+ const p = _.isEmpty() ? null : _.toData();
527
+ f.width = Math.floor(y * v), f.height = Math.floor(S * v), m.setTransform(v, 0, 0, v, 0, 0), p ? _.fromData(p, { clear: !0 }) : _.clear();
58
528
  }, []);
59
- return L(
60
- C,
529
+ return F(
530
+ a,
61
531
  () => ({
62
532
  clear: () => {
63
- l.current?.clear();
533
+ c.current?.clear();
64
534
  },
65
- isEmpty: () => l.current?.isEmpty() ?? !0,
66
- toDataURL: (i = "image/png", g) => l.current?.toDataURL(i, g) ?? "",
67
- getCanvas: () => c.current,
68
- getSignaturePad: () => l.current,
69
- on: () => l.current?.on(),
70
- off: () => l.current?.off(),
535
+ isEmpty: () => c.current?.isEmpty() ?? !0,
536
+ toDataURL: (u = "image/png", f) => c.current?.toDataURL(u, f) ?? "",
537
+ getCanvas: () => h.current,
538
+ getSignaturePad: () => c.current,
539
+ on: () => c.current?.on(),
540
+ off: () => c.current?.off(),
71
541
  getSignatureWithWhiteBackground: () => {
72
- const i = c.current;
73
- return i ? $(i) : null;
542
+ const u = h.current;
543
+ return u ? Z(u) : null;
74
544
  },
75
- getBlob: (i = c.current ?? void 0, g = "image/jpeg", o = 0.92) => i ? j(i, g, o) : Promise.reject(new Error("No canvas available for getBlob"))
545
+ getBlob: (u = h.current ?? void 0, f = "image/jpeg", _ = 0.92) => u ? tt(u, f, _) : Promise.reject(new Error("No canvas available for getBlob"))
76
546
  }),
77
547
  []
78
- ), y(() => {
79
- const i = m.current, g = c.current;
80
- if (!i || !g) return;
81
- let o = null;
82
- const p = () => {
83
- o === null && (o = requestAnimationFrame(() => {
84
- o = null, S();
548
+ ), E(() => {
549
+ const u = l.current, f = h.current;
550
+ if (!u || !f) return;
551
+ let _ = null;
552
+ const v = () => {
553
+ _ === null && (_ = requestAnimationFrame(() => {
554
+ _ = null, r();
85
555
  }));
86
- }, b = s ?? F(V), B = {
87
- ...b ? { penColor: b } : {},
88
- ...t ? { maxWidth: t } : {}
89
- }, v = new M(g, B);
90
- l.current = v;
91
- const n = () => h.current?.();
92
- v.addEventListener("beginStroke", n), S();
93
- const f = new ResizeObserver(() => {
94
- p();
556
+ }, m = e ?? K(J), y = {
557
+ ...m ? { penColor: m } : {},
558
+ ...i ? { maxWidth: i } : {}
559
+ }, S = new Y(f, y);
560
+ c.current = S;
561
+ const p = () => d.current?.();
562
+ S.addEventListener("beginStroke", p), r();
563
+ const x = new ResizeObserver(() => {
564
+ v();
95
565
  });
96
- return f.observe(i), () => {
97
- o !== null && cancelAnimationFrame(o), f.disconnect(), v.removeEventListener("beginStroke", n), v.off(), l.current = null;
566
+ return x.observe(u), () => {
567
+ _ !== null && cancelAnimationFrame(_), x.disconnect(), S.removeEventListener("beginStroke", p), S.off(), c.current = null;
98
568
  };
99
- }, [S, s, t]), /* @__PURE__ */ u(
569
+ }, [r, e, i]), /* @__PURE__ */ w(
100
570
  "div",
101
571
  {
102
572
  class: "SignatureCanvasContainer",
103
- style: d ? { backgroundColor: d } : void 0,
104
- ref: m,
573
+ style: s ? { backgroundColor: s } : void 0,
574
+ ref: l,
105
575
  children: [
106
- /* @__PURE__ */ u(
576
+ /* @__PURE__ */ w(
107
577
  "canvas",
108
578
  {
109
579
  class: "SignatureCanvas",
110
- ref: c,
111
- "aria-label": a
580
+ ref: h,
581
+ "aria-label": t
112
582
  }
113
583
  ),
114
- !e && /* @__PURE__ */ u("p", { class: "SignatureCanvasPlaceholder", children: a })
584
+ !n && /* @__PURE__ */ w("p", { class: "SignatureCanvasPlaceholder", children: t })
115
585
  ]
116
586
  }
117
587
  );
118
588
  }
119
589
  );
120
- x.displayName = "SignatureCanvas";
121
- const q = ({
122
- config: r,
123
- onFinish: e,
124
- onError: a
590
+ U.displayName = "SignatureCanvas";
591
+ const et = ({
592
+ config: o,
593
+ onFinish: n,
594
+ onError: t
125
595
  }) => {
126
- const { t: s } = T(), [t, d] = D(
127
- () => H({ config: r }),
596
+ const { t: e } = B(), [i, s] = A(
597
+ () => G({ config: o }),
128
598
  { autoLoad: !0 }
129
- ), [C, m] = O(!1), c = I(null), l = I(void 0), h = W(() => {
130
- if (t.status === "capture" || t.status === "submitting")
131
- return t.phase;
132
- }, [t]), S = t.status === "error" ? t.error : void 0, i = t.status === "submitting", g = t.status === "capture" && t.canContinue && !i, o = E(() => {
133
- c.current && (c.current.on(), c.current.clear(), m(!1), d.setSignatureValid(!1));
134
- }, [d]);
135
- y(() => {
136
- t.status === "finished" && e?.();
137
- }, [t.status, e]), y(() => {
138
- S && (a?.(S), c.current?.on());
139
- }, [S, a]), y(() => {
140
- const n = l.current;
141
- h && n && n !== h && (m(!1), d.setSignatureValid(!1), o()), l.current = h;
142
- }, [h, d, o]);
143
- const p = (n) => {
144
- const f = r.title?.trim();
145
- return f || s(n === "initials" ? "signature.initialsTitle" : "signature.fullSignatureTitle");
146
- }, b = () => {
147
- const n = r.subtitle?.trim();
148
- return n || s("signature.subtitle");
149
- }, B = async () => {
150
- const n = c.current;
151
- if (!n) return;
152
- const f = n.getSignatureWithWhiteBackground();
153
- return f ? r.sendBase64 ?? !1 ? f.toDataURL("image/png").replace(/^data:image\/png;base64,/, "") : n.getBlob(f) : void 0;
154
- }, v = async () => {
155
- const n = c.current;
156
- if (!(!n || t.status !== "capture" || n.isEmpty())) {
157
- n.off();
599
+ ), [a, l] = N(!1), h = P(null), c = P(void 0), d = z(() => {
600
+ if (i.status === "capture" || i.status === "submitting")
601
+ return i.phase;
602
+ }, [i]), r = i.status === "error" ? i.error : void 0, u = i.status === "submitting", f = i.status === "capture" && i.canContinue && !u, _ = W(() => {
603
+ h.current && (h.current.on(), h.current.clear(), l(!1), s.setSignatureValid(!1));
604
+ }, [s]);
605
+ E(() => {
606
+ i.status === "finished" && n?.();
607
+ }, [i.status, n]), E(() => {
608
+ r && (t?.(r), h.current?.on());
609
+ }, [r, t]), E(() => {
610
+ const p = c.current;
611
+ d && p && p !== d && (l(!1), s.setSignatureValid(!1), _()), c.current = d;
612
+ }, [d, s, _]);
613
+ const v = (p) => {
614
+ const x = o.title?.trim();
615
+ return x || e(p === "initials" ? "signature.initialsTitle" : "signature.fullSignatureTitle");
616
+ }, m = () => {
617
+ const p = o.subtitle?.trim();
618
+ return p || e("signature.subtitle");
619
+ }, y = async () => {
620
+ const p = h.current;
621
+ if (!p) return;
622
+ const x = p.getSignatureWithWhiteBackground();
623
+ return x ? o.sendBase64 ?? !1 ? x.toDataURL("image/png").replace(/^data:image\/png;base64,/, "") : p.getBlob(x) : void 0;
624
+ }, S = async () => {
625
+ const p = h.current;
626
+ if (!(!p || i.status !== "capture" || p.isEmpty())) {
627
+ p.off();
158
628
  try {
159
- const f = await B();
160
- if (!f) {
161
- n.on();
629
+ const x = await y();
630
+ if (!x) {
631
+ p.on();
162
632
  return;
163
633
  }
164
- d.submit(f);
634
+ s.submit(x);
165
635
  } catch {
166
- n.on();
636
+ p.on();
167
637
  }
168
638
  }
169
639
  };
170
- return t.status === "idle" || t.status === "finished" || t.status === "error" ? null : t.status === "success" ? /* @__PURE__ */ u(P, { className: "IncodeSignature IncodeSignatureFadeIn", children: /* @__PURE__ */ u(
640
+ return i.status === "idle" || i.status === "finished" || i.status === "error" ? null : i.status === "success" ? /* @__PURE__ */ w(M, { className: "IncodeSignature IncodeSignatureFadeIn", children: /* @__PURE__ */ w(
171
641
  "div",
172
642
  {
173
643
  class: "IncodeSignatureContent IncodeSignatureSuccess",
174
644
  role: "status",
175
645
  children: [
176
- /* @__PURE__ */ u(A, { size: 48 }),
177
- /* @__PURE__ */ u(R, { size: 16 }),
178
- /* @__PURE__ */ u(U, { children: s("signature.successTitle") })
646
+ /* @__PURE__ */ w(V, { size: 48 }),
647
+ /* @__PURE__ */ w(k, { size: 16 }),
648
+ /* @__PURE__ */ w(q, { children: e("signature.successTitle") })
179
649
  ]
180
650
  }
181
- ) }) : /* @__PURE__ */ u(
182
- P,
651
+ ) }) : /* @__PURE__ */ w(
652
+ M,
183
653
  {
184
654
  className: "IncodeSignature IncodeSignatureFadeIn",
185
- title: p(h),
186
- subtitle: b(),
655
+ title: v(d),
656
+ subtitle: m(),
187
657
  children: [
188
- /* @__PURE__ */ u("div", { class: "IncodeSignatureContent", children: [
189
- /* @__PURE__ */ u(
190
- x,
658
+ /* @__PURE__ */ w("div", { class: "IncodeSignatureContent", children: [
659
+ /* @__PURE__ */ w(
660
+ U,
191
661
  {
192
- ref: c,
193
- hasDrawing: C,
662
+ ref: h,
663
+ hasDrawing: a,
194
664
  onBeginStroke: () => {
195
- m(!0), d.setSignatureValid(!0);
665
+ l(!0), s.setSignatureValid(!0);
196
666
  },
197
- placeholder: s(
198
- h === "initials" ? "signature.initialsPlaceholder" : "signature.fullSignaturePlaceholder"
667
+ placeholder: e(
668
+ d === "initials" ? "signature.initialsPlaceholder" : "signature.fullSignaturePlaceholder"
199
669
  ),
200
- customBackgroundColor: r.canvasBackgroundColor,
201
- customPenColor: r.penColor,
202
- customPenStrokeWidth: r.penStrokeWidth
670
+ customBackgroundColor: o.canvasBackgroundColor,
671
+ customPenColor: o.penColor,
672
+ customPenStrokeWidth: o.penStrokeWidth
203
673
  }
204
674
  ),
205
- /* @__PURE__ */ u(R, { size: 8 }),
206
- /* @__PURE__ */ u(
207
- w,
675
+ /* @__PURE__ */ w(k, { size: 8 }),
676
+ /* @__PURE__ */ w(
677
+ T,
208
678
  {
209
679
  variant: "link",
210
- disabled: !C || i,
211
- onClick: o,
212
- children: s("signature.clear")
680
+ disabled: !a || u,
681
+ onClick: _,
682
+ children: e("signature.clear")
213
683
  }
214
684
  )
215
685
  ] }),
216
- /* @__PURE__ */ u("div", { class: "IncodeSignatureButtonContainer", children: /* @__PURE__ */ u(
217
- w,
686
+ /* @__PURE__ */ w("div", { class: "IncodeSignatureButtonContainer", children: /* @__PURE__ */ w(
687
+ T,
218
688
  {
219
- disabled: !g,
220
- isLoading: i,
221
- onClick: v,
222
- children: s(
223
- h === "initials" ? "common.continue" : "signature.done"
689
+ disabled: !f,
690
+ isLoading: u,
691
+ onClick: S,
692
+ children: e(
693
+ d === "initials" ? "common.continue" : "signature.done"
224
694
  )
225
695
  }
226
696
  ) })
227
697
  ]
228
698
  }
229
699
  );
230
- }, G = ({
231
- config: r,
232
- onFinish: e,
233
- onError: a
234
- }) => /* @__PURE__ */ u(k, { children: r ? /* @__PURE__ */ u(q, { config: r, onFinish: e, onError: a }) : null });
235
- z(G, "incode-signature");
700
+ }, it = ({
701
+ config: o,
702
+ onFinish: n,
703
+ onError: t
704
+ }) => /* @__PURE__ */ w(I, { children: o ? /* @__PURE__ */ w(et, { config: o, onFinish: n, onError: t }) : null });
705
+ $(it, "incode-signature");
236
706
  export {
237
- G as Signature
707
+ it as Signature
238
708
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incodetech/web",
3
- "version": "0.0.0-dev-20260402-682edb5",
3
+ "version": "0.0.0-dev-20260402-7cf9db4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.es.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -135,8 +135,9 @@
135
135
  "preact-custom-element": "^4.6.0",
136
136
  "preact-markup": "^2.1.1",
137
137
  "qrcode": "^1.5.4",
138
+ "signature_pad": "^5.1.3",
138
139
  "tailwindcss": "^4.1.17",
139
- "@incodetech/core": "0.0.0-dev-20260402-682edb5"
140
+ "@incodetech/core": "0.0.0-dev-20260402-7cf9db4"
140
141
  },
141
142
  "devDependencies": {
142
143
  "@microsoft/api-extractor": "^7.53.3",
@@ -167,7 +168,7 @@
167
168
  "@incodetech/config": "1.0.0"
168
169
  },
169
170
  "scripts": {
170
- "dev": "vite --host",
171
+ "dev": "vite",
171
172
  "dev:http": "VITE_DEV_HTTPS=false vite --host",
172
173
  "dev:debug": "vite --host --no-open",
173
174
  "build:dev": "vite build --watch",