@incodetech/web 0.0.0-dev-20260407-4580f1c → 0.0.0-dev-20260407-2c382da

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.
Files changed (162) hide show
  1. package/dist/AsYouType-D1H_js4X.js +2607 -0
  2. package/dist/Trans-aTzdT_SA.js +55 -0
  3. package/dist/addressAutocomplete-C8-wL1j_.js +153 -0
  4. package/dist/aligndevicelottie-DlQCRPfM.js +29 -0
  5. package/dist/antifraud/antifraud.es.js +18 -17
  6. package/dist/antifraud/styles.css +1 -1
  7. package/dist/authentication/authentication.es.js +50 -28
  8. package/dist/back-horizontal-hint-CSlf9KI1.js +5 -0
  9. package/dist/back-tutorial-An9AcMSe.js +29 -0
  10. package/dist/back-vertical-hint-CNieqiCr.js +5 -0
  11. package/dist/backdevicelottie-B4NgyWmX.js +29 -0
  12. package/dist/base.css +67 -327
  13. package/dist/blurdevicelottie-_BZRug1c.js +29 -0
  14. package/dist/browser-ponyfill-B6W6hHVY.js +344 -0
  15. package/dist/button-CE9kRlem.js +184 -0
  16. package/dist/cameraView-C2X7klNb.js +55 -0
  17. package/dist/captureOverlay-tCb4R4WE.js +592 -0
  18. package/dist/checkbox-B5X-mfqq.js +137 -0
  19. package/dist/chevronDown-DSHaPKbi.js +23 -0
  20. package/dist/closeIcon-9Hc97omv.js +28 -0
  21. package/dist/consent/consent.es.js +89 -82
  22. package/dist/consent/styles.css +1 -1
  23. package/dist/countries-DfLkrF0x.js +616 -0
  24. package/dist/curp-validation/curp-validation.es.js +313 -271
  25. package/dist/curp-validation/styles.css +1 -1
  26. package/dist/dateInputComposed-C7PCzh-U.js +173 -0
  27. package/dist/document-capture/styles.css +1 -1
  28. package/dist/documentCapture-C0mO-RGE.js +692 -0
  29. package/dist/dropdownComposed-BpinYlrx.js +367 -0
  30. package/dist/ekyb/styles.css +1 -1
  31. package/dist/ekybModule-Dr6LJUg-.js +357 -0
  32. package/dist/ekyc/styles.css +1 -1
  33. package/dist/ekycModule-C3mswduI.js +291 -0
  34. package/dist/email/email.es.js +154 -110
  35. package/dist/email/styles.css +1 -1
  36. package/dist/errorContent-Cb8nmQAE.js +44 -0
  37. package/dist/errorIcon-DEARBrGx.js +26 -0
  38. package/dist/extensibility.es.js +150 -22
  39. package/dist/face-match/styles.css +73 -147
  40. package/dist/faceMatch-DbDp7D3d.js +237 -0
  41. package/dist/fileIcon-CCSvS10T.js +52 -0
  42. package/dist/flip-animation-COR596wy.js +29 -0
  43. package/dist/flipAnimation-BqV462TA.js +2059 -0
  44. package/dist/flow/flow.es.js +2613 -2273
  45. package/dist/flow/styles.css +73 -432
  46. package/dist/formField-CP6wDdfA.js +106 -0
  47. package/dist/front-horizontal-hint-lRLKd7vY.js +7 -0
  48. package/dist/front-vertical-hint-qQoJXRE3.js +7 -0
  49. package/dist/frontdevicelottie-KhKxT5n9.js +29 -0
  50. package/dist/geolocation/geolocation.es.js +832 -852
  51. package/dist/geolocation/styles.css +1 -1
  52. package/dist/glaredevicelottie-DLuIStvb.js +29 -0
  53. package/dist/governmentValidation/governmentValidation.es.js +106 -100
  54. package/dist/governmentValidation/styles.css +1 -1
  55. package/dist/id/id.es.js +59 -53
  56. package/dist/id/styles.css +1 -1
  57. package/dist/id-laser-h-BBV3r3rz.js +29 -0
  58. package/dist/id-laser-v-BTHJaSfx.js +29 -0
  59. package/dist/id-tutorial-B-F5Q28m.js +29 -0
  60. package/dist/incodeModule-C4XIllao.js +96 -0
  61. package/dist/index.es.js +25 -4
  62. package/dist/inputComposed-fUbAGrDy.js +103 -0
  63. package/dist/instance-BWYzq8dk.js +2163 -0
  64. package/dist/loadingIcon-DmuPXh70.js +195 -0
  65. package/dist/mandatoryConsent-5xPI0cor.js +94 -0
  66. package/dist/manualCaptureButton-BvFmTyJe.js +372 -0
  67. package/dist/numberedStep-DwUB__mh.js +5 -0
  68. package/dist/otpInput-BFXhqFRT.js +156 -0
  69. package/dist/page-SrUl0qtN.js +69 -0
  70. package/dist/passport-horizontal-hint-BCtpMp1Y.js +5 -0
  71. package/dist/passport-tutorial-CaYBFTqt.js +29 -0
  72. package/dist/passport-vertical-hint-GaLnzqHP.js +5 -0
  73. package/dist/permissions-DT4Fz9MR.js +709 -0
  74. package/dist/phone/phone.es.js +121 -87
  75. package/dist/phone/styles.css +1 -1
  76. package/dist/phoneInput-CGr8TxOO.js +158 -0
  77. package/dist/phoneInputComposed-Cm9O2Jba.js +206 -0
  78. package/dist/processing-szVOCQwZ.js +19 -0
  79. package/dist/redirect-to-mobile/styles.css +1 -1
  80. package/dist/richText-cspvNz2a.js +1807 -0
  81. package/dist/selfie/selfie.es.js +50 -29
  82. package/dist/selfie/styles.css +66 -170
  83. package/dist/selfieTutorial-Dm_p0ke9.js +29 -0
  84. package/dist/signature/signature.es.js +707 -557
  85. package/dist/signature/styles.css +1 -1
  86. package/dist/spinner-DygONskw.js +60 -0
  87. package/dist/successIcon-Bjsdc4lF.js +26 -0
  88. package/dist/tutorial-Cdz1025D.js +473 -0
  89. package/dist/types/ekyb/styles.d.ts +1 -0
  90. package/dist/types/ekyc/styles.d.ts +1 -0
  91. package/dist/types/index.d.ts +8 -0
  92. package/dist/typography-BDACYR5i.js +14 -0
  93. package/dist/uiConfig-Dnt-2YWB.js +23 -0
  94. package/dist/useMediaQuery-lJdQBmC2.js +18 -0
  95. package/dist/vendor-preact-BoMmvSgn.js +694 -0
  96. package/dist/warningIcon-DQq_MrOB.js +26 -0
  97. package/package.json +11 -8
  98. package/dist/AsYouType-DPWqJvFu.js +0 -2482
  99. package/dist/addressAutocomplete-B3f6PGTT.js +0 -108
  100. package/dist/aligndevicelottie-C9xl1spu.js +0 -12757
  101. package/dist/back-horizontal-hint-Be3dUGk6.js +0 -137
  102. package/dist/back-tutorial-BNTyW-1N.js +0 -14584
  103. package/dist/back-vertical-hint-Bz_rnhd-.js +0 -128
  104. package/dist/backdevicelottie-DBB1YCtW.js +0 -16678
  105. package/dist/blurdevicelottie-9WvZCZ6C.js +0 -15939
  106. package/dist/browser-ponyfill-B4Qc6yfW.js +0 -299
  107. package/dist/button-DhL5eRT3.js +0 -123
  108. package/dist/checkbox-l8NxPf4o.js +0 -85
  109. package/dist/countries-y2ydYDhN.js +0 -8323
  110. package/dist/dateInputComposed-B9WqdYx9.js +0 -2
  111. package/dist/dateInputComposed-ndsGHX1M.js +0 -94
  112. package/dist/defineProperty-brqHEHA_.js +0 -39
  113. package/dist/documentCapture-wDgRLdon.js +0 -784
  114. package/dist/dropdownComposed-_Ey7wJNG.js +0 -258
  115. package/dist/ekyb/ekyb.es.js +0 -2
  116. package/dist/ekybModule-BBOm1y49.js +0 -2
  117. package/dist/ekybModule-fz6i9ZRt.js +0 -286
  118. package/dist/ekyc/ekyc.es.js +0 -2
  119. package/dist/ekycModule-SeTFG3AJ.js +0 -233
  120. package/dist/ekycModule-hxIcNX8n.js +0 -2
  121. package/dist/extensibility-DJihqIzM.js +0 -2248
  122. package/dist/faceMatch-DH8sLx34.js +0 -191
  123. package/dist/flip-animation-DOJzdXB-.js +0 -6983
  124. package/dist/formField-BRTbY8w9.js +0 -100
  125. package/dist/front-horizontal-hint-aGAhadA2.js +0 -380
  126. package/dist/front-vertical-hint-DZz1VeNp.js +0 -420
  127. package/dist/frontdevicelottie-DadDp6be.js +0 -17302
  128. package/dist/glaredevicelottie-BfI84cPw.js +0 -14466
  129. package/dist/i18n-DZOHbK9q.js +0 -1916
  130. package/dist/icons-BHbofCgJ.js +0 -245
  131. package/dist/id-laser-h-BWyU3VgL.js +0 -467
  132. package/dist/id-laser-v-JiWXUlv0.js +0 -467
  133. package/dist/id-tutorial-Cc9xg5_J.js +0 -13152
  134. package/dist/incodeModule-Bf6yJ8RB.js +0 -18
  135. package/dist/inputComposed-BhbfD8Ru.js +0 -77
  136. package/dist/loadingIcon-CeQt7Zgb.js +0 -146
  137. package/dist/mandatoryConsent-LBS8E0rj.js +0 -101
  138. package/dist/numberedStep-CQVRixRP.js +0 -11
  139. package/dist/otpInput-CDIG9el7.js +0 -143
  140. package/dist/page-SvlJWUfz.js +0 -61
  141. package/dist/passport-horizontal-hint-CFsGs7Dp.js +0 -293
  142. package/dist/passport-tutorial-z0LN7Hsp.js +0 -11688
  143. package/dist/passport-vertical-hint-BnCpKWeN.js +0 -267
  144. package/dist/phoneInput-C9T_8FJt.js +0 -138
  145. package/dist/phoneInputComposed-B-0zieIW.js +0 -407
  146. package/dist/processing-B5zhNH6I.js +0 -15
  147. package/dist/richText-Db0PfpkE.js +0 -1973
  148. package/dist/rolldown-runtime-CjdbFOpI.js +0 -13
  149. package/dist/selfieTutorial-B0MIyPrk.js +0 -2676
  150. package/dist/setup-Dq2bzNKH.js +0 -15
  151. package/dist/spacer-DCljE53A.js +0 -59
  152. package/dist/spinner-Bk0YuoLu.js +0 -1
  153. package/dist/spinner-snIGzmm8.js +0 -41
  154. package/dist/successIcon-AHrfmJvv.js +0 -17
  155. package/dist/tutorial-DNOd11tg.js +0 -2780
  156. package/dist/types/ekyb.d.ts +0 -29
  157. package/dist/types/ekyc.d.ts +0 -29
  158. package/dist/typography-BNbFNFek.js +0 -1
  159. package/dist/typography-DvHeVWfY.js +0 -29
  160. package/dist/uiConfig-CwpQ-IM6.js +0 -20
  161. package/dist/vendor-preact-D6SntenC.js +0 -958
  162. package/dist/warningIcon-Cvj-ayg1.js +0 -17
@@ -1,559 +1,709 @@
1
- import { n as e } from "../i18n-DZOHbK9q.js";
2
- import { _ as t, a as n, d as r, h as i, l as a, p as o, u as s, v as c } from "../vendor-preact-D6SntenC.js";
3
- import { c as l, r as u } from "../loadingIcon-CeQt7Zgb.js";
4
- import { t as d } from "../spacer-DCljE53A.js";
5
- import { t as f } from "../button-DhL5eRT3.js";
6
- import { t as p } from "../page-SvlJWUfz.js";
7
- import { r as m } from "../typography-DvHeVWfY.js";
8
- import "../typography-BNbFNFek.js";
9
- import { t as h } from "../successIcon-AHrfmJvv.js";
10
- import { t as g } from "../incodeModule-Bf6yJ8RB.js";
11
- import { t as _ } from "../defineProperty-brqHEHA_.js";
12
- import { createSignatureManager as v } from "@incodetech/core/signature";
13
- //#region ../../node_modules/.pnpm/signature_pad@5.1.3/node_modules/signature_pad/dist/signature_pad.js
14
- var y = class {
15
- constructor(e, t, n, r) {
16
- if (_(this, "x", void 0), _(this, "y", void 0), _(this, "pressure", void 0), _(this, "time", void 0), isNaN(e) || isNaN(t)) throw Error(`Point is invalid: (${e}, ${t})`);
17
- this.x = +e, this.y = +t, this.pressure = n || 0, this.time = r || Date.now();
18
- }
19
- distanceTo(e) {
20
- return Math.sqrt((this.x - e.x) ** 2 + (this.y - e.y) ** 2);
21
- }
22
- equals(e) {
23
- return this.x === e.x && this.y === e.y && this.pressure === e.pressure && this.time === e.time;
24
- }
25
- velocityFrom(e) {
26
- return this.time === e.time ? 0 : this.distanceTo(e) / (this.time - e.time);
27
- }
28
- }, b = class e {
29
- constructor(e, t, n, r, i, a) {
30
- this.startPoint = e, this.control2 = t, this.control1 = n, this.endPoint = r, this.startWidth = i, this.endWidth = a;
31
- }
32
- static fromPoints(t, n) {
33
- let r = this.calculateControlPoints(t[0], t[1], t[2]).c2, i = this.calculateControlPoints(t[1], t[2], t[3]).c1;
34
- return new e(t[1], r, i, t[2], n.start, n.end);
35
- }
36
- static calculateControlPoints(e, t, n) {
37
- let r = e.x - t.x, i = e.y - t.y, a = t.x - n.x, o = t.y - n.y, s = {
38
- x: (e.x + t.x) / 2,
39
- y: (e.y + t.y) / 2
40
- }, c = {
41
- x: (t.x + n.x) / 2,
42
- y: (t.y + n.y) / 2
43
- }, l = Math.sqrt(r * r + i * i), u = Math.sqrt(a * a + o * o), d = s.x - c.x, f = s.y - c.y, p = l + u == 0 ? 0 : u / (l + u), m = {
44
- x: c.x + d * p,
45
- y: c.y + f * p
46
- }, h = t.x - m.x, g = t.y - m.y;
47
- return {
48
- c1: new y(s.x + h, s.y + g),
49
- c2: new y(c.x + h, c.y + g)
50
- };
51
- }
52
- length() {
53
- let e = 0, t, n;
54
- for (let r = 0; r <= 10; r += 1) {
55
- let i = r / 10, a = this.point(i, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x), o = this.point(i, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
56
- if (r > 0) {
57
- let r = a - t, i = o - n;
58
- e += Math.sqrt(r * r + i * i);
59
- }
60
- t = a, n = o;
61
- }
62
- return e;
63
- }
64
- point(e, t, n, r, i) {
65
- return t * (1 - e) * (1 - e) * (1 - e) + 3 * n * (1 - e) * (1 - e) * e + 3 * r * (1 - e) * e * e + i * e * e * e;
66
- }
67
- }, x = class {
68
- constructor() {
69
- _(this, "_et", void 0);
70
- try {
71
- this._et = new EventTarget();
72
- } catch {
73
- this._et = document;
74
- }
75
- }
76
- addEventListener(e, t, n) {
77
- this._et.addEventListener(e, t, n);
78
- }
79
- dispatchEvent(e) {
80
- return this._et.dispatchEvent(e);
81
- }
82
- removeEventListener(e, t, n) {
83
- this._et.removeEventListener(e, t, n);
84
- }
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 } from "../loadingIcon-DmuPXh70.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";
6
+ import "@incodetech/core";
7
+ import "../instance-BWYzq8dk.js";
8
+ import { P as T } from "../page-SrUl0qtN.js";
9
+ import { r as $ } from "../incodeModule-C4XIllao.js";
10
+ import { createSignatureManager as G } from "@incodetech/core/signature";
11
+ import { B as M } from "../button-CE9kRlem.js";
12
+ import { S as V } from "../successIcon-Bjsdc4lF.js";
13
+ import { f as q } from "../typography-BDACYR5i.js";
14
+ var b = class {
15
+ constructor(o, n, t, e) {
16
+ g(this, "x");
17
+ g(this, "y");
18
+ g(this, "pressure");
19
+ g(this, "time");
20
+ if (isNaN(o) || isNaN(n))
21
+ throw new Error(`Point is invalid: (${o}, ${n})`);
22
+ this.x = +o, this.y = +n, this.pressure = t || 0, this.time = e || Date.now();
23
+ }
24
+ distanceTo(o) {
25
+ return Math.sqrt(
26
+ Math.pow(this.x - o.x, 2) + Math.pow(this.y - o.y, 2)
27
+ );
28
+ }
29
+ equals(o) {
30
+ return this.x === o.x && this.y === o.y && this.pressure === o.pressure && this.time === o.time;
31
+ }
32
+ velocityFrom(o) {
33
+ return this.time !== o.time ? this.distanceTo(o) / (this.time - o.time) : 0;
34
+ }
35
+ }, H = class D {
36
+ constructor(n, t, e, i, s, a) {
37
+ this.startPoint = n, this.control2 = t, this.control1 = e, this.endPoint = i, this.startWidth = s, this.endWidth = a;
38
+ }
39
+ static fromPoints(n, t) {
40
+ const e = this.calculateControlPoints(n[0], n[1], n[2]).c2, i = this.calculateControlPoints(n[1], n[2], n[3]).c1;
41
+ return new D(n[1], e, i, n[2], t.start, t.end);
42
+ }
43
+ static calculateControlPoints(n, t, e) {
44
+ 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;
45
+ return {
46
+ c1: new b(h.x + m, h.y + y),
47
+ c2: new b(c.x + m, c.y + y)
48
+ };
49
+ }
50
+ // Returns approximated length. Code taken from https://www.lemoda.net/maths/bezier-length/index.html.
51
+ length() {
52
+ let t = 0, e, i;
53
+ for (let s = 0; s <= 10; s += 1) {
54
+ const a = s / 10, l = this.point(
55
+ a,
56
+ this.startPoint.x,
57
+ this.control1.x,
58
+ this.control2.x,
59
+ this.endPoint.x
60
+ ), h = this.point(
61
+ a,
62
+ this.startPoint.y,
63
+ this.control1.y,
64
+ this.control2.y,
65
+ this.endPoint.y
66
+ );
67
+ if (s > 0) {
68
+ const c = l - e, d = h - i;
69
+ t += Math.sqrt(c * c + d * d);
70
+ }
71
+ e = l, i = h;
72
+ }
73
+ return t;
74
+ }
75
+ // Calculate parametric value of x or y given t and the four point coordinates of a cubic bezier curve.
76
+ point(n, t, e, i, s) {
77
+ 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;
78
+ }
79
+ }, j = class {
80
+ /* tslint:enable: variable-name */
81
+ constructor() {
82
+ /* tslint:disable: variable-name */
83
+ g(this, "_et");
84
+ try {
85
+ this._et = new EventTarget();
86
+ } catch {
87
+ this._et = document;
88
+ }
89
+ }
90
+ addEventListener(o, n, t) {
91
+ this._et.addEventListener(o, n, t);
92
+ }
93
+ dispatchEvent(o) {
94
+ return this._et.dispatchEvent(o);
95
+ }
96
+ removeEventListener(o, n, t) {
97
+ this._et.removeEventListener(o, n, t);
98
+ }
85
99
  };
86
- function S(e, t = 250) {
87
- let n = 0, r = null, i, a, o, s = () => {
88
- n = Date.now(), r = null, i = e.apply(a, o), r || (a = null, o = []);
89
- };
90
- return function(...c) {
91
- let l = Date.now(), u = t - (l - n);
92
- return a = this, o = c, u <= 0 || u > t ? (r &&= (clearTimeout(r), null), n = l, i = e.apply(a, o), r || (a = null, o = [])) : r ||= window.setTimeout(s, u), i;
93
- };
100
+ function X(o, n = 250) {
101
+ let t = 0, e = null, i, s, a;
102
+ const l = () => {
103
+ t = Date.now(), e = null, i = o.apply(s, a), e || (s = null, a = []);
104
+ };
105
+ return function(...c) {
106
+ const d = Date.now(), r = n - (d - t);
107
+ 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;
108
+ };
94
109
  }
95
- var C = class e extends x {
96
- constructor(t, n = {}) {
97
- super(), _(this, "dotSize", void 0), _(this, "minWidth", void 0), _(this, "maxWidth", void 0), _(this, "penColor", void 0), _(this, "minDistance", void 0), _(this, "velocityFilterWeight", void 0), _(this, "compositeOperation", void 0), _(this, "backgroundColor", void 0), _(this, "throttle", void 0), _(this, "canvasContextOptions", void 0), _(this, "_ctx", void 0), _(this, "_drawingStroke", !1), _(this, "_isEmpty", !0), _(this, "_dataUrl", void 0), _(this, "_dataUrlOptions", void 0), _(this, "_lastPoints", []), _(this, "_data", []), _(this, "_lastVelocity", 0), _(this, "_lastWidth", 0), _(this, "_strokeMoveUpdate", void 0), _(this, "_strokePointerId", void 0), this.canvas = t, this.velocityFilterWeight = n.velocityFilterWeight || .7, this.minWidth = n.minWidth || .5, this.maxWidth = n.maxWidth || 2.5, this.throttle = n.throttle ?? 16, this.minDistance = n.minDistance ?? 5, this.dotSize = n.dotSize || 0, this.penColor = n.penColor || "black", this.backgroundColor = n.backgroundColor || "rgba(0,0,0,0)", this.compositeOperation = n.compositeOperation || "source-over", this.canvasContextOptions = n.canvasContextOptions ?? {}, this._strokeMoveUpdate = this.throttle ? S(e.prototype._strokeUpdate, this.throttle) : e.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("2d", this.canvasContextOptions), this.clear(), this.on();
98
- }
99
- clear() {
100
- let { _ctx: e, canvas: t } = this;
101
- e.fillStyle = this.backgroundColor, e.clearRect(0, 0, t.width, t.height), e.fillRect(0, 0, t.width, t.height), this._data = [], this._reset(this._getPointGroupOptions()), this._isEmpty = !0, this._dataUrl = void 0, this._dataUrlOptions = void 0, this._strokePointerId = void 0;
102
- }
103
- redraw() {
104
- let e = this._data, t = this._dataUrl, n = this._dataUrlOptions;
105
- this.clear(), t && this.fromDataURL(t, n), this.fromData(e, { clear: !1 });
106
- }
107
- fromDataURL(e, t = {}) {
108
- return new Promise((n, r) => {
109
- let i = new Image(), a = t.ratio || window.devicePixelRatio || 1, o = t.width || this.canvas.width / a, s = t.height || this.canvas.height / a, c = t.xOffset || 0, l = t.yOffset || 0;
110
- this._reset(this._getPointGroupOptions()), i.onload = () => {
111
- this._ctx.drawImage(i, c, l, o, s), n();
112
- }, i.onerror = (e) => {
113
- r(e);
114
- }, i.crossOrigin = "anonymous", i.src = e, this._isEmpty = !1, this._dataUrl = e, this._dataUrlOptions = { ...t };
115
- });
116
- }
117
- toDataURL(e = "image/png", t) {
118
- switch (e) {
119
- case "image/svg+xml": return typeof t != "object" && (t = void 0), `data:image/svg+xml;base64,${btoa(this.toSVG(t))}`;
120
- default: return typeof t != "number" && (t = void 0), this.canvas.toDataURL(e, t);
121
- }
122
- }
123
- on() {
124
- this.canvas.style.touchAction = "none", this.canvas.style.msTouchAction = "none", this.canvas.style.userSelect = "none", this.canvas.style.webkitUserSelect = "none";
125
- let e = /Macintosh/.test(navigator.userAgent) && "ontouchstart" in document;
126
- window.PointerEvent && !e ? this._handlePointerEvents() : (this._handleMouseEvents(), "ontouchstart" in window && this._handleTouchEvents());
127
- }
128
- off() {
129
- 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();
130
- }
131
- _getListenerFunctions() {
132
- let e = window.document === this.canvas.ownerDocument ? window : this.canvas.ownerDocument.defaultView ?? this.canvas.ownerDocument;
133
- return {
134
- addEventListener: e.addEventListener.bind(e),
135
- removeEventListener: e.removeEventListener.bind(e)
136
- };
137
- }
138
- _removeMoveUpEventListeners() {
139
- let { removeEventListener: e } = this._getListenerFunctions();
140
- e("pointermove", this._handlePointerMove), e("pointerup", this._handlePointerUp), e("pointercancel", this._handlePointerCancel), e("mousemove", this._handleMouseMove), e("mouseup", this._handleMouseUp), e("touchmove", this._handleTouchMove), e("touchend", this._handleTouchEnd), e("touchcancel", this._handleTouchCancel);
141
- }
142
- isEmpty() {
143
- return this._isEmpty;
144
- }
145
- fromData(e, { clear: t = !0 } = {}) {
146
- t && this.clear(), this._fromData(e, this._drawCurve.bind(this), this._drawDot.bind(this)), this._data = this._data.concat(e);
147
- }
148
- toData() {
149
- return this._data;
150
- }
151
- _isLeftButtonPressed(e, t) {
152
- return t ? e.buttons === 1 : (e.buttons & 1) == 1;
153
- }
154
- _pointerEventToSignatureEvent(e) {
155
- return {
156
- event: e,
157
- type: e.type,
158
- x: e.clientX,
159
- y: e.clientY,
160
- pressure: "pressure" in e ? e.pressure : 0
161
- };
162
- }
163
- _touchEventToSignatureEvent(e) {
164
- let t = e.changedTouches[0];
165
- return {
166
- event: e,
167
- type: e.type,
168
- x: t.clientX,
169
- y: t.clientY,
170
- pressure: t.force
171
- };
172
- }
173
- _handleMouseDown(e) {
174
- !this._isLeftButtonPressed(e, !0) || this._drawingStroke || this._strokeBegin(this._pointerEventToSignatureEvent(e));
175
- }
176
- _handleMouseMove(e) {
177
- if (!this._isLeftButtonPressed(e, !0) || !this._drawingStroke) {
178
- this._strokeEnd(this._pointerEventToSignatureEvent(e), !1);
179
- return;
180
- }
181
- this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e));
182
- }
183
- _handleMouseUp(e) {
184
- this._isLeftButtonPressed(e) || this._strokeEnd(this._pointerEventToSignatureEvent(e));
185
- }
186
- _handleTouchStart(e) {
187
- e.targetTouches.length !== 1 || this._drawingStroke || (e.cancelable && e.preventDefault(), this._strokeBegin(this._touchEventToSignatureEvent(e)));
188
- }
189
- _handleTouchMove(e) {
190
- if (e.targetTouches.length === 1) {
191
- if (e.cancelable && e.preventDefault(), !this._drawingStroke) {
192
- this._strokeEnd(this._touchEventToSignatureEvent(e), !1);
193
- return;
194
- }
195
- this._strokeMoveUpdate(this._touchEventToSignatureEvent(e));
196
- }
197
- }
198
- _handleTouchEnd(e) {
199
- e.targetTouches.length === 0 && (e.cancelable && e.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(e)));
200
- }
201
- _handlePointerCancel(e) {
202
- this._allowPointerId(e) && (e.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(e), !1));
203
- }
204
- _handleTouchCancel(e) {
205
- e.cancelable && e.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(e), !1);
206
- }
207
- _getPointerId(e) {
208
- return e.persistentDeviceId || e.pointerId;
209
- }
210
- _allowPointerId(e, t = !1) {
211
- return this._strokePointerId === void 0 ? t : this._getPointerId(e) === this._strokePointerId;
212
- }
213
- _handlePointerDown(e) {
214
- this._drawingStroke || !this._isLeftButtonPressed(e) || !this._allowPointerId(e, !0) || (this._strokePointerId = this._getPointerId(e), e.preventDefault(), this._strokeBegin(this._pointerEventToSignatureEvent(e)));
215
- }
216
- _handlePointerMove(e) {
217
- if (this._allowPointerId(e)) {
218
- if (!this._isLeftButtonPressed(e, !0) || !this._drawingStroke) {
219
- this._strokeEnd(this._pointerEventToSignatureEvent(e), !1);
220
- return;
221
- }
222
- e.preventDefault(), this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e));
223
- }
224
- }
225
- _handlePointerUp(e) {
226
- this._isLeftButtonPressed(e) || !this._allowPointerId(e) || (e.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(e)));
227
- }
228
- _getPointGroupOptions(e) {
229
- return {
230
- penColor: e && "penColor" in e ? e.penColor : this.penColor,
231
- dotSize: e && "dotSize" in e ? e.dotSize : this.dotSize,
232
- minWidth: e && "minWidth" in e ? e.minWidth : this.minWidth,
233
- maxWidth: e && "maxWidth" in e ? e.maxWidth : this.maxWidth,
234
- velocityFilterWeight: e && "velocityFilterWeight" in e ? e.velocityFilterWeight : this.velocityFilterWeight,
235
- compositeOperation: e && "compositeOperation" in e ? e.compositeOperation : this.compositeOperation
236
- };
237
- }
238
- _strokeBegin(e) {
239
- if (!this.dispatchEvent(new CustomEvent("beginStroke", {
240
- detail: e,
241
- cancelable: !0
242
- }))) return;
243
- let { addEventListener: t } = this._getListenerFunctions();
244
- switch (e.event.type) {
245
- case "mousedown":
246
- t("mousemove", this._handleMouseMove, { passive: !1 }), t("mouseup", this._handleMouseUp, { passive: !1 });
247
- break;
248
- case "touchstart":
249
- t("touchmove", this._handleTouchMove, { passive: !1 }), t("touchend", this._handleTouchEnd, { passive: !1 }), t("touchcancel", this._handleTouchCancel, { passive: !1 });
250
- break;
251
- case "pointerdown":
252
- t("pointermove", this._handlePointerMove, { passive: !1 }), t("pointerup", this._handlePointerUp, { passive: !1 }), t("pointercancel", this._handlePointerCancel, { passive: !1 });
253
- break;
254
- default:
255
- }
256
- this._drawingStroke = !0;
257
- let n = this._getPointGroupOptions(), r = {
258
- ...n,
259
- points: []
260
- };
261
- this._data.push(r), this._reset(n), this._strokeUpdate(e);
262
- }
263
- _strokeUpdate(e) {
264
- if (!this._drawingStroke) return;
265
- if (this._data.length === 0) {
266
- this._strokeBegin(e);
267
- return;
268
- }
269
- this.dispatchEvent(new CustomEvent("beforeUpdateStroke", { detail: e }));
270
- let t = this._createPoint(e.x, e.y, e.pressure), n = this._data[this._data.length - 1], r = n.points, i = r.length > 0 && r[r.length - 1], a = i ? t.distanceTo(i) <= this.minDistance : !1, o = this._getPointGroupOptions(n);
271
- if (!i || !(i && a)) {
272
- let e = this._addPoint(t, o);
273
- i ? e && this._drawCurve(e, o) : this._drawDot(t, o), r.push({
274
- time: t.time,
275
- x: t.x,
276
- y: t.y,
277
- pressure: t.pressure
278
- });
279
- }
280
- this.dispatchEvent(new CustomEvent("afterUpdateStroke", { detail: e }));
281
- }
282
- _strokeEnd(e, t = !0) {
283
- this._removeMoveUpEventListeners(), this._drawingStroke && (t && this._strokeUpdate(e), this._drawingStroke = !1, this._strokePointerId = void 0, this.dispatchEvent(new CustomEvent("endStroke", { detail: e })));
284
- }
285
- _handlePointerEvents() {
286
- this._drawingStroke = !1, this.canvas.addEventListener("pointerdown", this._handlePointerDown, { passive: !1 });
287
- }
288
- _handleMouseEvents() {
289
- this._drawingStroke = !1, this.canvas.addEventListener("mousedown", this._handleMouseDown, { passive: !1 });
290
- }
291
- _handleTouchEvents() {
292
- this.canvas.addEventListener("touchstart", this._handleTouchStart, { passive: !1 });
293
- }
294
- _reset(e) {
295
- this._lastPoints = [], this._lastVelocity = 0, this._lastWidth = (e.minWidth + e.maxWidth) / 2, this._ctx.fillStyle = e.penColor, this._ctx.globalCompositeOperation = e.compositeOperation;
296
- }
297
- _createPoint(e, t, n) {
298
- let r = this.canvas.getBoundingClientRect();
299
- return new y(e - r.left, t - r.top, n, (/* @__PURE__ */ new Date()).getTime());
300
- }
301
- _addPoint(e, t) {
302
- let { _lastPoints: n } = this;
303
- if (n.push(e), n.length > 2) {
304
- n.length === 3 && n.unshift(n[0]);
305
- let e = this._calculateCurveWidths(n[1], n[2], t), r = b.fromPoints(n, e);
306
- return n.shift(), r;
307
- }
308
- return null;
309
- }
310
- _calculateCurveWidths(e, t, n) {
311
- let r = n.velocityFilterWeight * t.velocityFrom(e) + (1 - n.velocityFilterWeight) * this._lastVelocity, i = this._strokeWidth(r, n), a = {
312
- end: i,
313
- start: this._lastWidth
314
- };
315
- return this._lastVelocity = r, this._lastWidth = i, a;
316
- }
317
- _strokeWidth(e, t) {
318
- return Math.max(t.maxWidth / (e + 1), t.minWidth);
319
- }
320
- _drawCurveSegment(e, t, n) {
321
- let r = this._ctx;
322
- r.moveTo(e, t), r.arc(e, t, n, 0, 2 * Math.PI, !1), this._isEmpty = !1;
323
- }
324
- _drawCurve(e, t) {
325
- let n = this._ctx, r = e.endWidth - e.startWidth, i = Math.ceil(e.length()) * 2;
326
- n.beginPath(), n.fillStyle = t.penColor;
327
- for (let n = 0; n < i; n += 1) {
328
- let a = n / i, o = a * a, s = o * a, c = 1 - a, l = c * c, u = l * c, d = u * e.startPoint.x;
329
- d += 3 * l * a * e.control1.x, d += 3 * c * o * e.control2.x, d += s * e.endPoint.x;
330
- let f = u * e.startPoint.y;
331
- f += 3 * l * a * e.control1.y, f += 3 * c * o * e.control2.y, f += s * e.endPoint.y;
332
- let p = Math.min(e.startWidth + s * r, t.maxWidth);
333
- this._drawCurveSegment(d, f, p);
334
- }
335
- n.closePath(), n.fill();
336
- }
337
- _drawDot(e, t) {
338
- let n = this._ctx, r = t.dotSize > 0 ? t.dotSize : (t.minWidth + t.maxWidth) / 2;
339
- n.beginPath(), this._drawCurveSegment(e.x, e.y, r), n.closePath(), n.fillStyle = t.penColor, n.fill();
340
- }
341
- _fromData(e, t, n) {
342
- for (let r of e) {
343
- let { points: e } = r, i = this._getPointGroupOptions(r);
344
- if (e.length > 1) for (let n = 0; n < e.length; n += 1) {
345
- let r = e[n], a = new y(r.x, r.y, r.pressure, r.time);
346
- n === 0 && this._reset(i);
347
- let o = this._addPoint(a, i);
348
- o && t(o, i);
349
- }
350
- else this._reset(i), n(e[0], i);
351
- }
352
- }
353
- toSVG({ includeBackgroundColor: e = !1, includeDataUrl: t = !1 } = {}) {
354
- let n = this._data, r = Math.max(window.devicePixelRatio || 1, 1), i = this.canvas.width / r, a = this.canvas.height / r, o = document.createElementNS("http://www.w3.org/2000/svg", "svg");
355
- if (o.setAttribute("xmlns", "http://www.w3.org/2000/svg"), o.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), o.setAttribute("viewBox", `0 0 ${i} ${a}`), o.setAttribute("width", i.toString()), o.setAttribute("height", a.toString()), e && this.backgroundColor) {
356
- let e = document.createElement("rect");
357
- e.setAttribute("width", "100%"), e.setAttribute("height", "100%"), e.setAttribute("fill", this.backgroundColor), o.appendChild(e);
358
- }
359
- if (t && this._dataUrl) {
360
- let e = this._dataUrlOptions?.ratio || window.devicePixelRatio || 1, t = this._dataUrlOptions?.width || this.canvas.width / e, n = this._dataUrlOptions?.height || this.canvas.height / e, r = this._dataUrlOptions?.xOffset || 0, i = this._dataUrlOptions?.yOffset || 0, a = document.createElement("image");
361
- a.setAttribute("x", r.toString()), a.setAttribute("y", i.toString()), a.setAttribute("width", t.toString()), a.setAttribute("height", n.toString()), a.setAttribute("preserveAspectRatio", "none"), a.setAttribute("href", this._dataUrl), o.appendChild(a);
362
- }
363
- return this._fromData(n, (e, { penColor: t }) => {
364
- let n = document.createElement("path");
365
- if (!isNaN(e.control1.x) && !isNaN(e.control1.y) && !isNaN(e.control2.x) && !isNaN(e.control2.y)) {
366
- let r = `M ${e.startPoint.x.toFixed(3)},${e.startPoint.y.toFixed(3)} C ${e.control1.x.toFixed(3)},${e.control1.y.toFixed(3)} ${e.control2.x.toFixed(3)},${e.control2.y.toFixed(3)} ${e.endPoint.x.toFixed(3)},${e.endPoint.y.toFixed(3)}`;
367
- n.setAttribute("d", r), n.setAttribute("stroke-width", (e.endWidth * 2.25).toFixed(3)), n.setAttribute("stroke", t), n.setAttribute("fill", "none"), n.setAttribute("stroke-linecap", "round"), o.appendChild(n);
368
- }
369
- }, (e, { penColor: t, dotSize: n, minWidth: r, maxWidth: i }) => {
370
- let a = document.createElement("circle"), s = n > 0 ? n : (r + i) / 2;
371
- a.setAttribute("r", s.toString()), a.setAttribute("cx", e.x.toString()), a.setAttribute("cy", e.y.toString()), a.setAttribute("fill", t), o.appendChild(a);
372
- }), o.outerHTML;
373
- }
374
- }, w = (e) => {
375
- if (typeof document > "u") return null;
376
- let t = document.createElement("div");
377
- t.style.color = e, t.style.position = "absolute", t.style.visibility = "hidden", document.body.appendChild(t);
378
- let n = getComputedStyle(t).color;
379
- if (document.body.removeChild(t), !n || n === "transparent") return null;
380
- let r = n.match(/\d+/g);
381
- if (r && r.length >= 3) {
382
- let e = Number.parseInt(r[0], 10), t = Number.parseInt(r[1], 10), n = Number.parseInt(r[2], 10), i = (e) => {
383
- let t = e.toString(16);
384
- return t.length === 1 ? `0${t}` : t;
385
- };
386
- return `#${i(e)}${i(t)}${i(n)}`;
387
- }
388
- return null;
389
- }, T = "var(--icon-neutral-800)", E = "#ffffff", D = (e) => {
390
- let t = document.createElement("canvas");
391
- t.width = e.width, t.height = e.height;
392
- let n = t.getContext("2d");
393
- if (!n) throw Error("Canvas 2D context is not available");
394
- return n.fillStyle = E, n.fillRect(0, 0, t.width, t.height), n.drawImage(e, 0, 0), t;
395
- }, O = (e, t, n) => new Promise((r, i) => {
396
- e.toBlob((e) => {
397
- e ? r(e) : i(/* @__PURE__ */ Error("Canvas toBlob() returned null"));
398
- }, t, t === "image/jpeg" || t === "image/webp" ? n : void 0);
399
- }), k = n(({ onBeginStroke: e, hasDrawing: n, placeholder: r, customPenColor: o, customPenStrokeWidth: l, customBackgroundColor: u }, d) => {
400
- let f = a(null), p = a(null), m = a(null), h = a(e);
401
- h.current = e;
402
- let g = i(() => {
403
- let e = f.current, t = p.current, n = m.current;
404
- if (!e || !t || !n) return;
405
- let r = Math.max(window.devicePixelRatio || 1, 1), i = t.getContext("2d"), { width: a, height: o } = e.getBoundingClientRect();
406
- if (a === 0 || o === 0 || !i) return;
407
- let s = n.isEmpty() ? null : n.toData();
408
- t.width = Math.floor(a * r), t.height = Math.floor(o * r), i.setTransform(r, 0, 0, r, 0, 0), s ? n.fromData(s, { clear: !0 }) : n.clear();
409
- }, []);
410
- return s(d, () => ({
411
- clear: () => {
412
- m.current?.clear();
413
- },
414
- isEmpty: () => m.current?.isEmpty() ?? !0,
415
- toDataURL: (e = "image/png", t) => m.current?.toDataURL(e, t) ?? "",
416
- getCanvas: () => p.current,
417
- getSignaturePad: () => m.current,
418
- on: () => m.current?.on(),
419
- off: () => m.current?.off(),
420
- getSignatureWithWhiteBackground: () => {
421
- let e = p.current;
422
- return e ? D(e) : null;
423
- },
424
- getBlob: (e = p.current ?? void 0, t = "image/jpeg", n = .92) => e ? O(e, t, n) : Promise.reject(/* @__PURE__ */ Error("No canvas available for getBlob"))
425
- }), []), t(() => {
426
- let e = f.current, t = p.current;
427
- if (!e || !t) return;
428
- let n = null, r = () => {
429
- n === null && (n = requestAnimationFrame(() => {
430
- n = null, g();
431
- }));
432
- }, i = o ?? w(T), a = new C(t, {
433
- ...i ? { penColor: i } : {},
434
- ...l ? { maxWidth: l } : {}
435
- });
436
- m.current = a;
437
- let s = () => h.current?.();
438
- a.addEventListener("beginStroke", s), g();
439
- let c = new ResizeObserver(() => {
440
- r();
441
- });
442
- return c.observe(e), () => {
443
- n !== null && cancelAnimationFrame(n), c.disconnect(), a.removeEventListener("beginStroke", s), a.off(), m.current = null;
444
- };
445
- }, [
446
- g,
447
- o,
448
- l
449
- ]), /* @__PURE__ */ c("div", {
450
- class: "SignatureCanvasContainer",
451
- style: u ? { backgroundColor: u } : void 0,
452
- ref: f,
453
- children: [/* @__PURE__ */ c("canvas", {
454
- class: "SignatureCanvas",
455
- ref: p,
456
- "aria-label": r
457
- }), !n && /* @__PURE__ */ c("p", {
458
- class: "SignatureCanvasPlaceholder",
459
- children: r
460
- })]
461
- });
462
- });
463
- k.displayName = "SignatureCanvas";
464
- //#endregion
465
- //#region src/modules/signature/signature.tsx
466
- var A = ({ config: n, onFinish: s, onError: u }) => {
467
- let { t: g } = e(), [_, y] = l(() => v({ config: n }), { autoLoad: !0 }), [b, x] = o(!1), S = a(null), C = a(void 0), w = r(() => {
468
- if (_.status === "capture" || _.status === "submitting") return _.phase;
469
- }, [_]), T = _.status === "error" ? _.error : void 0, E = _.status === "submitting", D = _.status === "capture" && _.canContinue && !E, O = i(() => {
470
- S.current && (S.current.on(), S.current.clear(), x(!1), y.setSignatureValid(!1));
471
- }, [y]);
472
- t(() => {
473
- _.status === "finished" && s?.();
474
- }, [_.status, s]), t(() => {
475
- T && (u?.(T), S.current?.on());
476
- }, [T, u]), t(() => {
477
- let e = C.current;
478
- w && e && e !== w && (x(!1), y.setSignatureValid(!1), O()), C.current = w;
479
- }, [
480
- w,
481
- y,
482
- O
483
- ]);
484
- let A = (e) => n.title?.trim() || g(e === "initials" ? "signature.initialsTitle" : "signature.fullSignatureTitle"), j = () => n.subtitle?.trim() || g("signature.subtitle"), M = async () => {
485
- let e = S.current;
486
- if (!e) return;
487
- let t = e.getSignatureWithWhiteBackground();
488
- if (t) return n.sendBase64 ?? !1 ? t.toDataURL("image/png").replace(/^data:image\/png;base64,/, "") : e.getBlob(t);
489
- };
490
- return _.status === "idle" || _.status === "finished" || _.status === "error" ? null : _.status === "success" ? /* @__PURE__ */ c(p, {
491
- className: "IncodeSignature IncodeSignatureFadeIn",
492
- children: /* @__PURE__ */ c("div", {
493
- class: "IncodeSignatureContent IncodeSignatureSuccess",
494
- role: "status",
495
- children: [
496
- /* @__PURE__ */ c(h, { size: 48 }),
497
- /* @__PURE__ */ c(d, { size: 16 }),
498
- /* @__PURE__ */ c(m, { children: g("signature.successTitle") })
499
- ]
500
- })
501
- }) : /* @__PURE__ */ c(p, {
502
- className: "IncodeSignature IncodeSignatureFadeIn",
503
- title: A(w),
504
- subtitle: j(),
505
- children: [/* @__PURE__ */ c("div", {
506
- class: "IncodeSignatureContent",
507
- children: [
508
- /* @__PURE__ */ c(k, {
509
- ref: S,
510
- hasDrawing: b,
511
- onBeginStroke: () => {
512
- x(!0), y.setSignatureValid(!0);
513
- },
514
- placeholder: g(w === "initials" ? "signature.initialsPlaceholder" : "signature.fullSignaturePlaceholder"),
515
- customBackgroundColor: n.canvasBackgroundColor,
516
- customPenColor: n.penColor,
517
- customPenStrokeWidth: n.penStrokeWidth
518
- }),
519
- /* @__PURE__ */ c(d, { size: 8 }),
520
- /* @__PURE__ */ c(f, {
521
- variant: "link",
522
- disabled: !b || E,
523
- onClick: O,
524
- children: g("signature.clear")
525
- })
526
- ]
527
- }), /* @__PURE__ */ c("div", {
528
- class: "IncodeSignatureButtonContainer",
529
- children: /* @__PURE__ */ c(f, {
530
- disabled: !D,
531
- isLoading: E,
532
- onClick: async () => {
533
- let e = S.current;
534
- if (!(!e || _.status !== "capture" || e.isEmpty())) {
535
- e.off();
536
- try {
537
- let t = await M();
538
- if (!t) {
539
- e.on();
540
- return;
541
- }
542
- y.submit(t);
543
- } catch {
544
- e.on();
545
- }
546
- }
547
- },
548
- children: g(w === "initials" ? "common.continue" : "signature.done")
549
- })
550
- })]
551
- });
552
- }, j = ({ config: e, onFinish: t, onError: n }) => /* @__PURE__ */ c(u, { children: e ? /* @__PURE__ */ c(A, {
553
- config: e,
554
- onFinish: t,
555
- onError: n
556
- }) : null });
557
- g(j, "incode-signature");
558
- //#endregion
559
- export { j as Signature };
110
+ var Y = class C extends j {
111
+ /* tslint:enable: variable-name */
112
+ constructor(t, e = {}) {
113
+ super();
114
+ // Public stuff
115
+ g(this, "dotSize");
116
+ g(this, "minWidth");
117
+ g(this, "maxWidth");
118
+ g(this, "penColor");
119
+ g(this, "minDistance");
120
+ g(this, "velocityFilterWeight");
121
+ g(this, "compositeOperation");
122
+ g(this, "backgroundColor");
123
+ g(this, "throttle");
124
+ g(this, "canvasContextOptions");
125
+ // Private stuff
126
+ /* tslint:disable: variable-name */
127
+ g(this, "_ctx");
128
+ g(this, "_drawingStroke", !1);
129
+ g(this, "_isEmpty", !0);
130
+ g(this, "_dataUrl");
131
+ g(this, "_dataUrlOptions");
132
+ g(this, "_lastPoints", []);
133
+ // Stores up to 4 most recent points; used to generate a new curve
134
+ g(this, "_data", []);
135
+ // Stores all points in groups (one group per line or dot)
136
+ g(this, "_lastVelocity", 0);
137
+ g(this, "_lastWidth", 0);
138
+ g(this, "_strokeMoveUpdate");
139
+ g(this, "_strokePointerId");
140
+ 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(
141
+ "2d",
142
+ this.canvasContextOptions
143
+ ), this.clear(), this.on();
144
+ }
145
+ clear() {
146
+ const { _ctx: t, canvas: e } = this;
147
+ 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;
148
+ }
149
+ redraw() {
150
+ const t = this._data, e = this._dataUrl, i = this._dataUrlOptions;
151
+ this.clear(), e && this.fromDataURL(e, i), this.fromData(t, { clear: !1 });
152
+ }
153
+ fromDataURL(t, e = {}) {
154
+ return new Promise((i, s) => {
155
+ 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;
156
+ this._reset(this._getPointGroupOptions()), a.onload = () => {
157
+ this._ctx.drawImage(a, d, r, h, c), i();
158
+ }, a.onerror = (u) => {
159
+ s(u);
160
+ }, a.crossOrigin = "anonymous", a.src = t, this._isEmpty = !1, this._dataUrl = t, this._dataUrlOptions = { ...e };
161
+ });
162
+ }
163
+ toDataURL(t = "image/png", e) {
164
+ switch (t) {
165
+ case "image/svg+xml":
166
+ return typeof e != "object" && (e = void 0), `data:image/svg+xml;base64,${btoa(
167
+ this.toSVG(e)
168
+ )}`;
169
+ default:
170
+ return typeof e != "number" && (e = void 0), this.canvas.toDataURL(t, e);
171
+ }
172
+ }
173
+ on() {
174
+ this.canvas.style.touchAction = "none", this.canvas.style.msTouchAction = "none", this.canvas.style.userSelect = "none", this.canvas.style.webkitUserSelect = "none";
175
+ const t = /Macintosh/.test(navigator.userAgent) && "ontouchstart" in document;
176
+ window.PointerEvent && !t ? this._handlePointerEvents() : (this._handleMouseEvents(), "ontouchstart" in window && this._handleTouchEvents());
177
+ }
178
+ off() {
179
+ 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();
180
+ }
181
+ _getListenerFunctions() {
182
+ const t = window.document === this.canvas.ownerDocument ? window : this.canvas.ownerDocument.defaultView ?? this.canvas.ownerDocument;
183
+ return {
184
+ addEventListener: t.addEventListener.bind(
185
+ t
186
+ ),
187
+ removeEventListener: t.removeEventListener.bind(
188
+ t
189
+ )
190
+ };
191
+ }
192
+ _removeMoveUpEventListeners() {
193
+ const { removeEventListener: t } = this._getListenerFunctions();
194
+ 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);
195
+ }
196
+ isEmpty() {
197
+ return this._isEmpty;
198
+ }
199
+ fromData(t, { clear: e = !0 } = {}) {
200
+ e && this.clear(), this._fromData(
201
+ t,
202
+ this._drawCurve.bind(this),
203
+ this._drawDot.bind(this)
204
+ ), this._data = this._data.concat(t);
205
+ }
206
+ toData() {
207
+ return this._data;
208
+ }
209
+ _isLeftButtonPressed(t, e) {
210
+ return e ? t.buttons === 1 : (t.buttons & 1) === 1;
211
+ }
212
+ _pointerEventToSignatureEvent(t) {
213
+ return {
214
+ event: t,
215
+ type: t.type,
216
+ x: t.clientX,
217
+ y: t.clientY,
218
+ pressure: "pressure" in t ? t.pressure : 0
219
+ };
220
+ }
221
+ _touchEventToSignatureEvent(t) {
222
+ const e = t.changedTouches[0];
223
+ return {
224
+ event: t,
225
+ type: t.type,
226
+ x: e.clientX,
227
+ y: e.clientY,
228
+ pressure: e.force
229
+ };
230
+ }
231
+ // Event handlers
232
+ _handleMouseDown(t) {
233
+ !this._isLeftButtonPressed(t, !0) || this._drawingStroke || this._strokeBegin(this._pointerEventToSignatureEvent(t));
234
+ }
235
+ _handleMouseMove(t) {
236
+ if (!this._isLeftButtonPressed(t, !0) || !this._drawingStroke) {
237
+ this._strokeEnd(this._pointerEventToSignatureEvent(t), !1);
238
+ return;
239
+ }
240
+ this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t));
241
+ }
242
+ _handleMouseUp(t) {
243
+ this._isLeftButtonPressed(t) || this._strokeEnd(this._pointerEventToSignatureEvent(t));
244
+ }
245
+ _handleTouchStart(t) {
246
+ t.targetTouches.length !== 1 || this._drawingStroke || (t.cancelable && t.preventDefault(), this._strokeBegin(this._touchEventToSignatureEvent(t)));
247
+ }
248
+ _handleTouchMove(t) {
249
+ if (t.targetTouches.length === 1) {
250
+ if (t.cancelable && t.preventDefault(), !this._drawingStroke) {
251
+ this._strokeEnd(this._touchEventToSignatureEvent(t), !1);
252
+ return;
253
+ }
254
+ this._strokeMoveUpdate(this._touchEventToSignatureEvent(t));
255
+ }
256
+ }
257
+ _handleTouchEnd(t) {
258
+ t.targetTouches.length === 0 && (t.cancelable && t.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(t)));
259
+ }
260
+ _handlePointerCancel(t) {
261
+ this._allowPointerId(t) && (t.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(t), !1));
262
+ }
263
+ _handleTouchCancel(t) {
264
+ t.cancelable && t.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(t), !1);
265
+ }
266
+ _getPointerId(t) {
267
+ return t.persistentDeviceId || t.pointerId;
268
+ }
269
+ _allowPointerId(t, e = !1) {
270
+ return typeof this._strokePointerId > "u" ? e : this._getPointerId(t) === this._strokePointerId;
271
+ }
272
+ _handlePointerDown(t) {
273
+ this._drawingStroke || !this._isLeftButtonPressed(t) || !this._allowPointerId(t, !0) || (this._strokePointerId = this._getPointerId(t), t.preventDefault(), this._strokeBegin(this._pointerEventToSignatureEvent(t)));
274
+ }
275
+ _handlePointerMove(t) {
276
+ if (this._allowPointerId(t)) {
277
+ if (!this._isLeftButtonPressed(t, !0) || !this._drawingStroke) {
278
+ this._strokeEnd(this._pointerEventToSignatureEvent(t), !1);
279
+ return;
280
+ }
281
+ t.preventDefault(), this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t));
282
+ }
283
+ }
284
+ _handlePointerUp(t) {
285
+ this._isLeftButtonPressed(t) || !this._allowPointerId(t) || (t.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(t)));
286
+ }
287
+ _getPointGroupOptions(t) {
288
+ return {
289
+ penColor: t && "penColor" in t ? t.penColor : this.penColor,
290
+ dotSize: t && "dotSize" in t ? t.dotSize : this.dotSize,
291
+ minWidth: t && "minWidth" in t ? t.minWidth : this.minWidth,
292
+ maxWidth: t && "maxWidth" in t ? t.maxWidth : this.maxWidth,
293
+ velocityFilterWeight: t && "velocityFilterWeight" in t ? t.velocityFilterWeight : this.velocityFilterWeight,
294
+ compositeOperation: t && "compositeOperation" in t ? t.compositeOperation : this.compositeOperation
295
+ };
296
+ }
297
+ // Private methods
298
+ _strokeBegin(t) {
299
+ if (!this.dispatchEvent(
300
+ new CustomEvent("beginStroke", { detail: t, cancelable: !0 })
301
+ ))
302
+ return;
303
+ const { addEventListener: i } = this._getListenerFunctions();
304
+ switch (t.event.type) {
305
+ case "mousedown":
306
+ i("mousemove", this._handleMouseMove, {
307
+ passive: !1
308
+ }), i("mouseup", this._handleMouseUp, { passive: !1 });
309
+ break;
310
+ case "touchstart":
311
+ i("touchmove", this._handleTouchMove, {
312
+ passive: !1
313
+ }), i("touchend", this._handleTouchEnd, { passive: !1 }), i("touchcancel", this._handleTouchCancel, { passive: !1 });
314
+ break;
315
+ case "pointerdown":
316
+ i("pointermove", this._handlePointerMove, {
317
+ passive: !1
318
+ }), i("pointerup", this._handlePointerUp, {
319
+ passive: !1
320
+ }), i("pointercancel", this._handlePointerCancel, {
321
+ passive: !1
322
+ });
323
+ break;
324
+ }
325
+ this._drawingStroke = !0;
326
+ const s = this._getPointGroupOptions(), a = {
327
+ ...s,
328
+ points: []
329
+ };
330
+ this._data.push(a), this._reset(s), this._strokeUpdate(t);
331
+ }
332
+ _strokeUpdate(t) {
333
+ if (!this._drawingStroke)
334
+ return;
335
+ if (this._data.length === 0) {
336
+ this._strokeBegin(t);
337
+ return;
338
+ }
339
+ this.dispatchEvent(
340
+ new CustomEvent("beforeUpdateStroke", { detail: t })
341
+ );
342
+ 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);
343
+ if (!a || !(a && l)) {
344
+ const c = this._addPoint(e, h);
345
+ a ? c && this._drawCurve(c, h) : this._drawDot(e, h), s.push({
346
+ time: e.time,
347
+ x: e.x,
348
+ y: e.y,
349
+ pressure: e.pressure
350
+ });
351
+ }
352
+ this.dispatchEvent(new CustomEvent("afterUpdateStroke", { detail: t }));
353
+ }
354
+ _strokeEnd(t, e = !0) {
355
+ this._removeMoveUpEventListeners(), this._drawingStroke && (e && this._strokeUpdate(t), this._drawingStroke = !1, this._strokePointerId = void 0, this.dispatchEvent(new CustomEvent("endStroke", { detail: t })));
356
+ }
357
+ _handlePointerEvents() {
358
+ this._drawingStroke = !1, this.canvas.addEventListener("pointerdown", this._handlePointerDown, {
359
+ passive: !1
360
+ });
361
+ }
362
+ _handleMouseEvents() {
363
+ this._drawingStroke = !1, this.canvas.addEventListener("mousedown", this._handleMouseDown, {
364
+ passive: !1
365
+ });
366
+ }
367
+ _handleTouchEvents() {
368
+ this.canvas.addEventListener("touchstart", this._handleTouchStart, {
369
+ passive: !1
370
+ });
371
+ }
372
+ // Called when a new line is started
373
+ _reset(t) {
374
+ this._lastPoints = [], this._lastVelocity = 0, this._lastWidth = (t.minWidth + t.maxWidth) / 2, this._ctx.fillStyle = t.penColor, this._ctx.globalCompositeOperation = t.compositeOperation;
375
+ }
376
+ _createPoint(t, e, i) {
377
+ const s = this.canvas.getBoundingClientRect();
378
+ return new b(
379
+ t - s.left,
380
+ e - s.top,
381
+ i,
382
+ (/* @__PURE__ */ new Date()).getTime()
383
+ );
384
+ }
385
+ // Add point to _lastPoints array and generate a new curve if there are enough points (i.e. 3)
386
+ _addPoint(t, e) {
387
+ const { _lastPoints: i } = this;
388
+ if (i.push(t), i.length > 2) {
389
+ i.length === 3 && i.unshift(i[0]);
390
+ const s = this._calculateCurveWidths(
391
+ i[1],
392
+ i[2],
393
+ e
394
+ ), a = H.fromPoints(i, s);
395
+ return i.shift(), a;
396
+ }
397
+ return null;
398
+ }
399
+ _calculateCurveWidths(t, e, i) {
400
+ const s = i.velocityFilterWeight * e.velocityFrom(t) + (1 - i.velocityFilterWeight) * this._lastVelocity, a = this._strokeWidth(s, i), l = {
401
+ end: a,
402
+ start: this._lastWidth
403
+ };
404
+ return this._lastVelocity = s, this._lastWidth = a, l;
405
+ }
406
+ _strokeWidth(t, e) {
407
+ return Math.max(e.maxWidth / (t + 1), e.minWidth);
408
+ }
409
+ _drawCurveSegment(t, e, i) {
410
+ const s = this._ctx;
411
+ s.moveTo(t, e), s.arc(t, e, i, 0, 2 * Math.PI, !1), this._isEmpty = !1;
412
+ }
413
+ _drawCurve(t, e) {
414
+ const i = this._ctx, s = t.endWidth - t.startWidth, a = Math.ceil(t.length()) * 2;
415
+ i.beginPath(), i.fillStyle = e.penColor;
416
+ for (let l = 0; l < a; l += 1) {
417
+ const h = l / a, c = h * h, d = c * h, r = 1 - h, u = r * r, f = u * r;
418
+ let _ = f * t.startPoint.x;
419
+ _ += 3 * u * h * t.control1.x, _ += 3 * r * c * t.control2.x, _ += d * t.endPoint.x;
420
+ let v = f * t.startPoint.y;
421
+ v += 3 * u * h * t.control1.y, v += 3 * r * c * t.control2.y, v += d * t.endPoint.y;
422
+ const m = Math.min(
423
+ t.startWidth + d * s,
424
+ e.maxWidth
425
+ );
426
+ this._drawCurveSegment(_, v, m);
427
+ }
428
+ i.closePath(), i.fill();
429
+ }
430
+ _drawDot(t, e) {
431
+ const i = this._ctx, s = e.dotSize > 0 ? e.dotSize : (e.minWidth + e.maxWidth) / 2;
432
+ i.beginPath(), this._drawCurveSegment(t.x, t.y, s), i.closePath(), i.fillStyle = e.penColor, i.fill();
433
+ }
434
+ _fromData(t, e, i) {
435
+ for (const s of t) {
436
+ const { points: a } = s, l = this._getPointGroupOptions(s);
437
+ if (a.length > 1)
438
+ for (let h = 0; h < a.length; h += 1) {
439
+ const c = a[h], d = new b(
440
+ c.x,
441
+ c.y,
442
+ c.pressure,
443
+ c.time
444
+ );
445
+ h === 0 && this._reset(l);
446
+ const r = this._addPoint(d, l);
447
+ r && e(r, l);
448
+ }
449
+ else
450
+ this._reset(l), i(a[0], l);
451
+ }
452
+ }
453
+ toSVG({ includeBackgroundColor: t = !1, includeDataUrl: e = !1 } = {}) {
454
+ 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");
455
+ 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) {
456
+ const r = document.createElement("rect");
457
+ r.setAttribute("width", "100%"), r.setAttribute("height", "100%"), r.setAttribute("fill", this.backgroundColor), d.appendChild(r);
458
+ }
459
+ if (e && this._dataUrl) {
460
+ 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");
461
+ 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);
462
+ }
463
+ return this._fromData(
464
+ i,
465
+ (r, { penColor: u }) => {
466
+ const f = document.createElement("path");
467
+ if (!isNaN(r.control1.x) && !isNaN(r.control1.y) && !isNaN(r.control2.x) && !isNaN(r.control2.y)) {
468
+ const _ = `M ${r.startPoint.x.toFixed(3)},${r.startPoint.y.toFixed(
469
+ 3
470
+ )} 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)}`;
471
+ 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);
472
+ }
473
+ },
474
+ (r, { penColor: u, dotSize: f, minWidth: _, maxWidth: v }) => {
475
+ const m = document.createElement("circle"), y = f > 0 ? f : (_ + v) / 2;
476
+ m.setAttribute("r", y.toString()), m.setAttribute("cx", r.x.toString()), m.setAttribute("cy", r.y.toString()), m.setAttribute("fill", u), d.appendChild(m);
477
+ }
478
+ ), d.outerHTML;
479
+ }
480
+ };
481
+ const K = (o) => {
482
+ if (typeof document > "u") return null;
483
+ const n = document.createElement("div");
484
+ n.style.color = o, n.style.position = "absolute", n.style.visibility = "hidden", document.body.appendChild(n);
485
+ const t = getComputedStyle(n).color;
486
+ if (document.body.removeChild(n), !t || t === "transparent") return null;
487
+ const e = t.match(/\d+/g);
488
+ if (e && e.length >= 3) {
489
+ const i = Number.parseInt(e[0], 10), s = Number.parseInt(e[1], 10), a = Number.parseInt(e[2], 10), l = (h) => {
490
+ const c = h.toString(16);
491
+ return c.length === 1 ? `0${c}` : c;
492
+ };
493
+ return `#${l(i)}${l(s)}${l(a)}`;
494
+ }
495
+ return null;
496
+ }, J = "var(--icon-neutral-800)", Q = "#ffffff", Z = (o) => {
497
+ const n = document.createElement("canvas");
498
+ n.width = o.width, n.height = o.height;
499
+ const t = n.getContext("2d");
500
+ if (!t)
501
+ throw new Error("Canvas 2D context is not available");
502
+ return t.fillStyle = Q, t.fillRect(0, 0, n.width, n.height), t.drawImage(o, 0, 0), n;
503
+ }, tt = (o, n, t) => new Promise((e, i) => {
504
+ o.toBlob(
505
+ (s) => {
506
+ s ? e(s) : i(new Error("Canvas toBlob() returned null"));
507
+ },
508
+ n,
509
+ n === "image/jpeg" || n === "image/webp" ? t : void 0
510
+ );
511
+ }), U = R(
512
+ ({
513
+ onBeginStroke: o,
514
+ hasDrawing: n,
515
+ placeholder: t,
516
+ customPenColor: e,
517
+ customPenStrokeWidth: i,
518
+ customBackgroundColor: s
519
+ }, a) => {
520
+ const l = P(null), h = P(null), c = P(null), d = P(o);
521
+ d.current = o;
522
+ const r = W(() => {
523
+ const u = l.current, f = h.current, _ = c.current;
524
+ if (!u || !f || !_) return;
525
+ const v = Math.max(window.devicePixelRatio || 1, 1), m = f.getContext("2d"), { width: y, height: S } = u.getBoundingClientRect();
526
+ if (y === 0 || S === 0 || !m) return;
527
+ const p = _.isEmpty() ? null : _.toData();
528
+ 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();
529
+ }, []);
530
+ return F(
531
+ a,
532
+ () => ({
533
+ clear: () => {
534
+ c.current?.clear();
535
+ },
536
+ isEmpty: () => c.current?.isEmpty() ?? !0,
537
+ toDataURL: (u = "image/png", f) => c.current?.toDataURL(u, f) ?? "",
538
+ getCanvas: () => h.current,
539
+ getSignaturePad: () => c.current,
540
+ on: () => c.current?.on(),
541
+ off: () => c.current?.off(),
542
+ getSignatureWithWhiteBackground: () => {
543
+ const u = h.current;
544
+ return u ? Z(u) : null;
545
+ },
546
+ getBlob: (u = h.current ?? void 0, f = "image/jpeg", _ = 0.92) => u ? tt(u, f, _) : Promise.reject(new Error("No canvas available for getBlob"))
547
+ }),
548
+ []
549
+ ), E(() => {
550
+ const u = l.current, f = h.current;
551
+ if (!u || !f) return;
552
+ let _ = null;
553
+ const v = () => {
554
+ _ === null && (_ = requestAnimationFrame(() => {
555
+ _ = null, r();
556
+ }));
557
+ }, m = e ?? K(J), y = {
558
+ ...m ? { penColor: m } : {},
559
+ ...i ? { maxWidth: i } : {}
560
+ }, S = new Y(f, y);
561
+ c.current = S;
562
+ const p = () => d.current?.();
563
+ S.addEventListener("beginStroke", p), r();
564
+ const x = new ResizeObserver(() => {
565
+ v();
566
+ });
567
+ return x.observe(u), () => {
568
+ _ !== null && cancelAnimationFrame(_), x.disconnect(), S.removeEventListener("beginStroke", p), S.off(), c.current = null;
569
+ };
570
+ }, [r, e, i]), /* @__PURE__ */ w(
571
+ "div",
572
+ {
573
+ class: "SignatureCanvasContainer",
574
+ style: s ? { backgroundColor: s } : void 0,
575
+ ref: l,
576
+ children: [
577
+ /* @__PURE__ */ w(
578
+ "canvas",
579
+ {
580
+ class: "SignatureCanvas",
581
+ ref: h,
582
+ "aria-label": t
583
+ }
584
+ ),
585
+ !n && /* @__PURE__ */ w("p", { class: "SignatureCanvasPlaceholder", children: t })
586
+ ]
587
+ }
588
+ );
589
+ }
590
+ );
591
+ U.displayName = "SignatureCanvas";
592
+ const et = ({
593
+ config: o,
594
+ onFinish: n,
595
+ onError: t
596
+ }) => {
597
+ const { t: e } = B(), [i, s] = A(
598
+ () => G({ config: o }),
599
+ { autoLoad: !0 }
600
+ ), [a, l] = N(!1), h = P(null), c = P(void 0), d = z(() => {
601
+ if (i.status === "capture" || i.status === "submitting")
602
+ return i.phase;
603
+ }, [i]), r = i.status === "error" ? i.error : void 0, u = i.status === "submitting", f = i.status === "capture" && i.canContinue && !u, _ = W(() => {
604
+ h.current && (h.current.on(), h.current.clear(), l(!1), s.setSignatureValid(!1));
605
+ }, [s]);
606
+ E(() => {
607
+ i.status === "finished" && n?.();
608
+ }, [i.status, n]), E(() => {
609
+ r && (t?.(r), h.current?.on());
610
+ }, [r, t]), E(() => {
611
+ const p = c.current;
612
+ d && p && p !== d && (l(!1), s.setSignatureValid(!1), _()), c.current = d;
613
+ }, [d, s, _]);
614
+ const v = (p) => {
615
+ const x = o.title?.trim();
616
+ return x || e(p === "initials" ? "signature.initialsTitle" : "signature.fullSignatureTitle");
617
+ }, m = () => {
618
+ const p = o.subtitle?.trim();
619
+ return p || e("signature.subtitle");
620
+ }, y = async () => {
621
+ const p = h.current;
622
+ if (!p) return;
623
+ const x = p.getSignatureWithWhiteBackground();
624
+ return x ? o.sendBase64 ?? !1 ? x.toDataURL("image/png").replace(/^data:image\/png;base64,/, "") : p.getBlob(x) : void 0;
625
+ }, S = async () => {
626
+ const p = h.current;
627
+ if (!(!p || i.status !== "capture" || p.isEmpty())) {
628
+ p.off();
629
+ try {
630
+ const x = await y();
631
+ if (!x) {
632
+ p.on();
633
+ return;
634
+ }
635
+ s.submit(x);
636
+ } catch {
637
+ p.on();
638
+ }
639
+ }
640
+ };
641
+ return i.status === "idle" || i.status === "finished" || i.status === "error" ? null : i.status === "success" ? /* @__PURE__ */ w(T, { className: "IncodeSignature IncodeSignatureFadeIn", children: /* @__PURE__ */ w(
642
+ "div",
643
+ {
644
+ class: "IncodeSignatureContent IncodeSignatureSuccess",
645
+ role: "status",
646
+ children: [
647
+ /* @__PURE__ */ w(V, { size: 48 }),
648
+ /* @__PURE__ */ w(k, { size: 16 }),
649
+ /* @__PURE__ */ w(q, { children: e("signature.successTitle") })
650
+ ]
651
+ }
652
+ ) }) : /* @__PURE__ */ w(
653
+ T,
654
+ {
655
+ className: "IncodeSignature IncodeSignatureFadeIn",
656
+ title: v(d),
657
+ subtitle: m(),
658
+ children: [
659
+ /* @__PURE__ */ w("div", { class: "IncodeSignatureContent", children: [
660
+ /* @__PURE__ */ w(
661
+ U,
662
+ {
663
+ ref: h,
664
+ hasDrawing: a,
665
+ onBeginStroke: () => {
666
+ l(!0), s.setSignatureValid(!0);
667
+ },
668
+ placeholder: e(
669
+ d === "initials" ? "signature.initialsPlaceholder" : "signature.fullSignaturePlaceholder"
670
+ ),
671
+ customBackgroundColor: o.canvasBackgroundColor,
672
+ customPenColor: o.penColor,
673
+ customPenStrokeWidth: o.penStrokeWidth
674
+ }
675
+ ),
676
+ /* @__PURE__ */ w(k, { size: 8 }),
677
+ /* @__PURE__ */ w(
678
+ M,
679
+ {
680
+ variant: "link",
681
+ disabled: !a || u,
682
+ onClick: _,
683
+ children: e("signature.clear")
684
+ }
685
+ )
686
+ ] }),
687
+ /* @__PURE__ */ w("div", { class: "IncodeSignatureButtonContainer", children: /* @__PURE__ */ w(
688
+ M,
689
+ {
690
+ disabled: !f,
691
+ isLoading: u,
692
+ onClick: S,
693
+ children: e(
694
+ d === "initials" ? "common.continue" : "signature.done"
695
+ )
696
+ }
697
+ ) })
698
+ ]
699
+ }
700
+ );
701
+ }, it = ({
702
+ config: o,
703
+ onFinish: n,
704
+ onError: t
705
+ }) => /* @__PURE__ */ w(I, { children: o ? /* @__PURE__ */ w(et, { config: o, onFinish: n, onError: t }) : null });
706
+ $(it, "incode-signature");
707
+ export {
708
+ it as Signature
709
+ };