@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.
- package/dist/AsYouType-D1H_js4X.js +2607 -0
- package/dist/Trans-aTzdT_SA.js +55 -0
- package/dist/addressAutocomplete-C8-wL1j_.js +153 -0
- package/dist/aligndevicelottie-DlQCRPfM.js +29 -0
- package/dist/antifraud/antifraud.es.js +18 -17
- package/dist/antifraud/styles.css +1 -1
- package/dist/authentication/authentication.es.js +50 -28
- package/dist/back-horizontal-hint-CSlf9KI1.js +5 -0
- package/dist/back-tutorial-An9AcMSe.js +29 -0
- package/dist/back-vertical-hint-CNieqiCr.js +5 -0
- package/dist/backdevicelottie-B4NgyWmX.js +29 -0
- package/dist/base.css +67 -327
- package/dist/blurdevicelottie-_BZRug1c.js +29 -0
- package/dist/browser-ponyfill-B6W6hHVY.js +344 -0
- package/dist/button-CE9kRlem.js +184 -0
- package/dist/cameraView-C2X7klNb.js +55 -0
- package/dist/captureOverlay-tCb4R4WE.js +592 -0
- package/dist/checkbox-B5X-mfqq.js +137 -0
- package/dist/chevronDown-DSHaPKbi.js +23 -0
- package/dist/closeIcon-9Hc97omv.js +28 -0
- package/dist/consent/consent.es.js +89 -82
- package/dist/consent/styles.css +1 -1
- package/dist/countries-DfLkrF0x.js +616 -0
- package/dist/curp-validation/curp-validation.es.js +313 -271
- package/dist/curp-validation/styles.css +1 -1
- package/dist/dateInputComposed-C7PCzh-U.js +173 -0
- package/dist/document-capture/styles.css +1 -1
- package/dist/documentCapture-C0mO-RGE.js +692 -0
- package/dist/dropdownComposed-BpinYlrx.js +367 -0
- package/dist/ekyb/styles.css +1 -1
- package/dist/ekybModule-Dr6LJUg-.js +357 -0
- package/dist/ekyc/styles.css +1 -1
- package/dist/ekycModule-C3mswduI.js +291 -0
- package/dist/email/email.es.js +154 -110
- package/dist/email/styles.css +1 -1
- package/dist/errorContent-Cb8nmQAE.js +44 -0
- package/dist/errorIcon-DEARBrGx.js +26 -0
- package/dist/extensibility.es.js +150 -22
- package/dist/face-match/styles.css +73 -147
- package/dist/faceMatch-DbDp7D3d.js +237 -0
- package/dist/fileIcon-CCSvS10T.js +52 -0
- package/dist/flip-animation-COR596wy.js +29 -0
- package/dist/flipAnimation-BqV462TA.js +2059 -0
- package/dist/flow/flow.es.js +2613 -2273
- package/dist/flow/styles.css +73 -432
- package/dist/formField-CP6wDdfA.js +106 -0
- package/dist/front-horizontal-hint-lRLKd7vY.js +7 -0
- package/dist/front-vertical-hint-qQoJXRE3.js +7 -0
- package/dist/frontdevicelottie-KhKxT5n9.js +29 -0
- package/dist/geolocation/geolocation.es.js +832 -852
- package/dist/geolocation/styles.css +1 -1
- package/dist/glaredevicelottie-DLuIStvb.js +29 -0
- package/dist/governmentValidation/governmentValidation.es.js +106 -100
- package/dist/governmentValidation/styles.css +1 -1
- package/dist/id/id.es.js +59 -53
- package/dist/id/styles.css +1 -1
- package/dist/id-laser-h-BBV3r3rz.js +29 -0
- package/dist/id-laser-v-BTHJaSfx.js +29 -0
- package/dist/id-tutorial-B-F5Q28m.js +29 -0
- package/dist/incodeModule-C4XIllao.js +96 -0
- package/dist/index.es.js +25 -4
- package/dist/inputComposed-fUbAGrDy.js +103 -0
- package/dist/instance-BWYzq8dk.js +2163 -0
- package/dist/loadingIcon-DmuPXh70.js +195 -0
- package/dist/mandatoryConsent-5xPI0cor.js +94 -0
- package/dist/manualCaptureButton-BvFmTyJe.js +372 -0
- package/dist/numberedStep-DwUB__mh.js +5 -0
- package/dist/otpInput-BFXhqFRT.js +156 -0
- package/dist/page-SrUl0qtN.js +69 -0
- package/dist/passport-horizontal-hint-BCtpMp1Y.js +5 -0
- package/dist/passport-tutorial-CaYBFTqt.js +29 -0
- package/dist/passport-vertical-hint-GaLnzqHP.js +5 -0
- package/dist/permissions-DT4Fz9MR.js +709 -0
- package/dist/phone/phone.es.js +121 -87
- package/dist/phone/styles.css +1 -1
- package/dist/phoneInput-CGr8TxOO.js +158 -0
- package/dist/phoneInputComposed-Cm9O2Jba.js +206 -0
- package/dist/processing-szVOCQwZ.js +19 -0
- package/dist/redirect-to-mobile/styles.css +1 -1
- package/dist/richText-cspvNz2a.js +1807 -0
- package/dist/selfie/selfie.es.js +50 -29
- package/dist/selfie/styles.css +66 -170
- package/dist/selfieTutorial-Dm_p0ke9.js +29 -0
- package/dist/signature/signature.es.js +707 -557
- package/dist/signature/styles.css +1 -1
- package/dist/spinner-DygONskw.js +60 -0
- package/dist/successIcon-Bjsdc4lF.js +26 -0
- package/dist/tutorial-Cdz1025D.js +473 -0
- package/dist/types/ekyb/styles.d.ts +1 -0
- package/dist/types/ekyc/styles.d.ts +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/typography-BDACYR5i.js +14 -0
- package/dist/uiConfig-Dnt-2YWB.js +23 -0
- package/dist/useMediaQuery-lJdQBmC2.js +18 -0
- package/dist/vendor-preact-BoMmvSgn.js +694 -0
- package/dist/warningIcon-DQq_MrOB.js +26 -0
- package/package.json +11 -8
- package/dist/AsYouType-DPWqJvFu.js +0 -2482
- package/dist/addressAutocomplete-B3f6PGTT.js +0 -108
- package/dist/aligndevicelottie-C9xl1spu.js +0 -12757
- package/dist/back-horizontal-hint-Be3dUGk6.js +0 -137
- package/dist/back-tutorial-BNTyW-1N.js +0 -14584
- package/dist/back-vertical-hint-Bz_rnhd-.js +0 -128
- package/dist/backdevicelottie-DBB1YCtW.js +0 -16678
- package/dist/blurdevicelottie-9WvZCZ6C.js +0 -15939
- package/dist/browser-ponyfill-B4Qc6yfW.js +0 -299
- package/dist/button-DhL5eRT3.js +0 -123
- package/dist/checkbox-l8NxPf4o.js +0 -85
- package/dist/countries-y2ydYDhN.js +0 -8323
- package/dist/dateInputComposed-B9WqdYx9.js +0 -2
- package/dist/dateInputComposed-ndsGHX1M.js +0 -94
- package/dist/defineProperty-brqHEHA_.js +0 -39
- package/dist/documentCapture-wDgRLdon.js +0 -784
- package/dist/dropdownComposed-_Ey7wJNG.js +0 -258
- package/dist/ekyb/ekyb.es.js +0 -2
- package/dist/ekybModule-BBOm1y49.js +0 -2
- package/dist/ekybModule-fz6i9ZRt.js +0 -286
- package/dist/ekyc/ekyc.es.js +0 -2
- package/dist/ekycModule-SeTFG3AJ.js +0 -233
- package/dist/ekycModule-hxIcNX8n.js +0 -2
- package/dist/extensibility-DJihqIzM.js +0 -2248
- package/dist/faceMatch-DH8sLx34.js +0 -191
- package/dist/flip-animation-DOJzdXB-.js +0 -6983
- package/dist/formField-BRTbY8w9.js +0 -100
- package/dist/front-horizontal-hint-aGAhadA2.js +0 -380
- package/dist/front-vertical-hint-DZz1VeNp.js +0 -420
- package/dist/frontdevicelottie-DadDp6be.js +0 -17302
- package/dist/glaredevicelottie-BfI84cPw.js +0 -14466
- package/dist/i18n-DZOHbK9q.js +0 -1916
- package/dist/icons-BHbofCgJ.js +0 -245
- package/dist/id-laser-h-BWyU3VgL.js +0 -467
- package/dist/id-laser-v-JiWXUlv0.js +0 -467
- package/dist/id-tutorial-Cc9xg5_J.js +0 -13152
- package/dist/incodeModule-Bf6yJ8RB.js +0 -18
- package/dist/inputComposed-BhbfD8Ru.js +0 -77
- package/dist/loadingIcon-CeQt7Zgb.js +0 -146
- package/dist/mandatoryConsent-LBS8E0rj.js +0 -101
- package/dist/numberedStep-CQVRixRP.js +0 -11
- package/dist/otpInput-CDIG9el7.js +0 -143
- package/dist/page-SvlJWUfz.js +0 -61
- package/dist/passport-horizontal-hint-CFsGs7Dp.js +0 -293
- package/dist/passport-tutorial-z0LN7Hsp.js +0 -11688
- package/dist/passport-vertical-hint-BnCpKWeN.js +0 -267
- package/dist/phoneInput-C9T_8FJt.js +0 -138
- package/dist/phoneInputComposed-B-0zieIW.js +0 -407
- package/dist/processing-B5zhNH6I.js +0 -15
- package/dist/richText-Db0PfpkE.js +0 -1973
- package/dist/rolldown-runtime-CjdbFOpI.js +0 -13
- package/dist/selfieTutorial-B0MIyPrk.js +0 -2676
- package/dist/setup-Dq2bzNKH.js +0 -15
- package/dist/spacer-DCljE53A.js +0 -59
- package/dist/spinner-Bk0YuoLu.js +0 -1
- package/dist/spinner-snIGzmm8.js +0 -41
- package/dist/successIcon-AHrfmJvv.js +0 -17
- package/dist/tutorial-DNOd11tg.js +0 -2780
- package/dist/types/ekyb.d.ts +0 -29
- package/dist/types/ekyc.d.ts +0 -29
- package/dist/typography-BNbFNFek.js +0 -1
- package/dist/typography-DvHeVWfY.js +0 -29
- package/dist/uiConfig-CwpQ-IM6.js +0 -20
- package/dist/vendor-preact-D6SntenC.js +0 -958
- package/dist/warningIcon-Cvj-ayg1.js +0 -17
|
@@ -1,559 +1,709 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import "../
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
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
|
+
};
|