@verbb/formie-browser 1.0.4 → 1.0.6

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 (197) hide show
  1. package/CHANGELOG.md +76 -22
  2. package/dist/chunks/address-country-Rx6GQTND.js +68 -0
  3. package/dist/chunks/address-finder-yXU5yMjG.js +30 -0
  4. package/dist/chunks/address-state-BQ0xGV9n.js +344 -0
  5. package/dist/chunks/api-CmwLRq_n.js +780 -0
  6. package/dist/chunks/api-DMK8NSUI.js +407 -0
  7. package/dist/chunks/api-sPqGbOww.js +125 -0
  8. package/dist/chunks/async-nPFRNQ06.js +25 -0
  9. package/dist/chunks/bpoint-DSjqRv63.js +24 -0
  10. package/dist/chunks/calculations-CeDgB9jt.js +299 -0
  11. package/dist/chunks/captcha-eu-CWJb64_j.js +31 -0
  12. package/dist/chunks/checkbox-radio-DQ0H67Tj.js +125 -0
  13. package/dist/chunks/chunk-3b4jIN3o.js +13 -0
  14. package/dist/chunks/combobox-D-2b42wn.js +1954 -0
  15. package/dist/chunks/conditions-DjZOtHfS.js +412 -0
  16. package/dist/chunks/constants-DVcJAvc5.js +38 -0
  17. package/dist/chunks/country-from-ip-BwxKaBuJ.js +26 -0
  18. package/dist/chunks/custom-google-maps-BsaSirEZ.js +194 -0
  19. package/dist/chunks/custom-link-CJ1-FjEM.js +46 -0
  20. package/dist/chunks/custom-maps-DYW_pBid.js +161 -0
  21. package/dist/chunks/date-picker-5CA_-zGb.js +5311 -0
  22. package/dist/chunks/debug-BV0DvdHx.js +41 -0
  23. package/dist/chunks/dist-BQ4a9hmy.js +2659 -0
  24. package/dist/chunks/event-names-BCI2FLD8.js +51 -0
  25. package/dist/chunks/eway-D3ctTbEk.js +70 -0
  26. package/dist/chunks/field-references.keys-58ZSTrCW.js +21 -0
  27. package/dist/chunks/field-references.resolver-CHwn0G0L.js +145 -0
  28. package/dist/chunks/file-upload-D49m8-DR.js +287 -0
  29. package/dist/chunks/friendly-captcha-v1-ByXzENYZ.js +31 -0
  30. package/dist/chunks/friendly-captcha-v2-BPdlmhQu.js +36 -0
  31. package/dist/chunks/friendly-challenge-8uPatWqk.js +832 -0
  32. package/dist/chunks/go-cardless-BwASSYSK.js +23 -0
  33. package/dist/chunks/google-address-OhKilPWE.js +161 -0
  34. package/dist/chunks/hcaptcha-CdCd9oEi.js +54 -0
  35. package/dist/chunks/hidden-D7_Ch-QN.js +26 -0
  36. package/dist/chunks/http-D-JExro7.js +27 -0
  37. package/dist/chunks/i18n-BY1ds1BL.js +121 -0
  38. package/dist/chunks/leaflet-src-j-lHNmhR.js +4585 -0
  39. package/dist/chunks/loqate-Cp2zvwpE.js +76 -0
  40. package/dist/chunks/mollie-COG-ko2D.js +23 -0
  41. package/dist/chunks/moneris-CMH8PlRc.js +117 -0
  42. package/dist/chunks/opayo-D2jsR5vh.js +113 -0
  43. package/dist/chunks/paddle-DxF88RfC.js +55 -0
  44. package/dist/chunks/paypal-b5pnwrA2.js +95 -0
  45. package/dist/chunks/payway-BJYu9DIR.js +55 -0
  46. package/dist/chunks/phone-country-D3ayr60L.js +2645 -0
  47. package/dist/chunks/place-kit-BGHklIZ-.js +48 -0
  48. package/dist/chunks/placekit-autocomplete.esm-DWVabQlq.js +1236 -0
  49. package/dist/chunks/recaptcha-enterprise-BSwi8IVX.js +65 -0
  50. package/dist/chunks/recaptcha-shared-B4zAescW.js +15 -0
  51. package/dist/chunks/recaptcha-v2-checkbox-CnDQmsKa.js +40 -0
  52. package/dist/chunks/recaptcha-v2-invisible-Cz5uIlp-.js +53 -0
  53. package/dist/chunks/recaptcha-v3-BtbbP111.js +27 -0
  54. package/dist/chunks/repeater-B5leVxZU.js +102 -0
  55. package/dist/chunks/rich-text-D0sb8bmX.js +349 -0
  56. package/dist/chunks/scripts-6CYSUGKQ.js +24 -0
  57. package/dist/chunks/sdk-BhHAYgga.js +1397 -0
  58. package/dist/chunks/shared-Bx9s0i0P.js +100 -0
  59. package/dist/chunks/signature-xz4QO7CR.js +536 -0
  60. package/dist/chunks/snaptcha-vz1RnZ15.js +8 -0
  61. package/dist/chunks/square-BP8RWAKB.js +40 -0
  62. package/dist/chunks/stripe-MihN63uC.js +184 -0
  63. package/dist/chunks/styles-BfoIZwJp.js +19 -0
  64. package/dist/chunks/summary-D3AjxpYN.js +114 -0
  65. package/dist/chunks/table-C-lkQN6I.js +78 -0
  66. package/dist/chunks/text-limit-DbgEFHLO.js +125 -0
  67. package/dist/chunks/theme-classes-Tv7q7ToE.js +44 -0
  68. package/dist/chunks/turnstile-D_Pi1CKM.js +58 -0
  69. package/dist/chunks/upload-manager-BpqWSHmU.js +2558 -0
  70. package/dist/chunks/utils-Vqp8i_RM.js +49401 -0
  71. package/dist/css/formie-theme.css +2 -0
  72. package/dist/css/theme/_buttons.css +16 -0
  73. package/dist/css/theme/_tokens.css +2 -0
  74. package/dist/css/theme/fields/_address-state.css +94 -0
  75. package/dist/css/theme/fields/_combobox.css +246 -0
  76. package/dist/css/theme/fields/_select.css +13 -0
  77. package/dist/css/theme/fields/_signature.css +19 -0
  78. package/dist/css/theme/fields/_upload-manager.css +279 -0
  79. package/dist/index.js +2448 -39
  80. package/dist/js/core/create-formie-client.d.ts.map +1 -1
  81. package/dist/js/core/submit-result-ui.d.ts.map +1 -1
  82. package/dist/js/core/validation-focus.d.ts +4 -0
  83. package/dist/js/core/validation-focus.d.ts.map +1 -0
  84. package/dist/js/modules/address/api.d.ts +1 -0
  85. package/dist/js/modules/address/api.d.ts.map +1 -1
  86. package/dist/js/modules/address/constants.d.ts +22 -1
  87. package/dist/js/modules/address/constants.d.ts.map +1 -1
  88. package/dist/js/modules/address/host.d.ts +2 -2
  89. package/dist/js/modules/address/host.d.ts.map +1 -1
  90. package/dist/js/modules/address/loqate.d.ts.map +1 -1
  91. package/dist/js/modules/fields/address-country.d.ts +3 -0
  92. package/dist/js/modules/fields/address-country.d.ts.map +1 -0
  93. package/dist/js/modules/fields/address-state.d.ts +3 -0
  94. package/dist/js/modules/fields/address-state.d.ts.map +1 -0
  95. package/dist/js/modules/fields/calculations.d.ts.map +1 -1
  96. package/dist/js/modules/fields/combobox.d.ts +17 -0
  97. package/dist/js/modules/fields/combobox.d.ts.map +1 -0
  98. package/dist/js/modules/fields/custom-google-maps.d.ts +64 -0
  99. package/dist/js/modules/fields/custom-google-maps.d.ts.map +1 -0
  100. package/dist/js/modules/fields/custom-link.d.ts +3 -0
  101. package/dist/js/modules/fields/custom-link.d.ts.map +1 -0
  102. package/dist/js/modules/fields/custom-maps.d.ts +3 -0
  103. package/dist/js/modules/fields/custom-maps.d.ts.map +1 -0
  104. package/dist/js/modules/fields/date-picker.d.ts.map +1 -1
  105. package/dist/js/modules/fields/index.d.ts.map +1 -1
  106. package/dist/js/modules/fields/phone-country.d.ts.map +1 -1
  107. package/dist/js/modules/fields/signature.d.ts.map +1 -1
  108. package/dist/js/modules/fields/upload-manager.d.ts +3 -0
  109. package/dist/js/modules/fields/upload-manager.d.ts.map +1 -0
  110. package/dist/js/submit/pipeline.d.ts.map +1 -1
  111. package/dist/js/utils/country-from-ip.d.ts +7 -0
  112. package/dist/js/utils/country-from-ip.d.ts.map +1 -0
  113. package/dist/js/utils/field-references.d.ts +1 -0
  114. package/dist/js/utils/field-references.d.ts.map +1 -1
  115. package/dist/js/utils/field-references.row-scope.d.ts +11 -0
  116. package/dist/js/utils/field-references.row-scope.d.ts.map +1 -0
  117. package/package.json +8 -3
  118. package/src/css/formie-theme.css +2 -0
  119. package/src/css/theme/_buttons.css +16 -0
  120. package/src/css/theme/_tokens.css +2 -0
  121. package/src/css/theme/fields/_address-state.css +94 -0
  122. package/src/css/theme/fields/_combobox.css +246 -0
  123. package/src/css/theme/fields/_select.css +13 -0
  124. package/src/css/theme/fields/_signature.css +19 -0
  125. package/src/css/theme/fields/_upload-manager.css +279 -0
  126. package/src/js/core/create-formie-client.ts +27 -0
  127. package/src/js/core/submit-result-ui.ts +4 -4
  128. package/src/js/core/validation-focus.ts +117 -0
  129. package/src/js/modules/address/api.ts +7 -0
  130. package/src/js/modules/address/constants.ts +82 -2
  131. package/src/js/modules/address/host.ts +16 -6
  132. package/src/js/modules/address/loqate.ts +3 -17
  133. package/src/js/modules/fields/address-country.ts +156 -0
  134. package/src/js/modules/fields/address-state.ts +946 -0
  135. package/src/js/modules/fields/calculations.ts +32 -0
  136. package/src/js/modules/fields/combobox.ts +188 -0
  137. package/src/js/modules/fields/custom-google-maps.ts +416 -0
  138. package/src/js/modules/fields/custom-link.ts +95 -0
  139. package/src/js/modules/fields/custom-maps.ts +339 -0
  140. package/src/js/modules/fields/date-picker.ts +96 -3
  141. package/src/js/modules/fields/index.ts +7 -0
  142. package/src/js/modules/fields/phone-country.ts +6 -0
  143. package/src/js/modules/fields/signature.ts +199 -15
  144. package/src/js/modules/fields/upload-manager.ts +1277 -0
  145. package/src/js/submit/pipeline.ts +11 -1
  146. package/src/js/utils/country-from-ip.ts +54 -0
  147. package/src/js/utils/field-references.row-scope.ts +303 -0
  148. package/src/js/utils/field-references.ts +1 -0
  149. package/src/vendor.d.ts +1 -1
  150. package/dist/chunks/address-finder-BU4roxT6.js +0 -37
  151. package/dist/chunks/bpoint-uNg5j6rt.js +0 -26
  152. package/dist/chunks/calculations-C9t6Zop9.js +0 -147
  153. package/dist/chunks/captcha-eu-BAPzHNts.js +0 -34
  154. package/dist/chunks/checkbox-radio-CHeLNVIK.js +0 -141
  155. package/dist/chunks/conditions-DKxVCsjD.js +0 -459
  156. package/dist/chunks/date-picker-B3iQ797Z.js +0 -4994
  157. package/dist/chunks/eway-DCielIML.js +0 -74
  158. package/dist/chunks/file-upload-DP2TOUYV.js +0 -316
  159. package/dist/chunks/friendly-captcha-v1-DdlcGiFY.js +0 -33
  160. package/dist/chunks/friendly-captcha-v2-76w-YnFm.js +0 -38
  161. package/dist/chunks/go-cardless-rwCkzbNK.js +0 -24
  162. package/dist/chunks/google-address-BD8IZ86V.js +0 -181
  163. package/dist/chunks/hcaptcha-BNNTL6uf.js +0 -56
  164. package/dist/chunks/hidden-CW6Rcf1N.js +0 -31
  165. package/dist/chunks/index-BEsfee-D.js +0 -1839
  166. package/dist/chunks/index-BP7Unm5Y.js +0 -863
  167. package/dist/chunks/index-D6npYxvr.js +0 -4423
  168. package/dist/chunks/loqate-B-ZNS65B.js +0 -55
  169. package/dist/chunks/mollie-BDAZ-1X4.js +0 -24
  170. package/dist/chunks/moneris-B1b0uEtY.js +0 -101
  171. package/dist/chunks/opayo-CC5hraHo.js +0 -122
  172. package/dist/chunks/paddle-B4GmrDsq.js +0 -60
  173. package/dist/chunks/paypal-BFS6XsIS.js +0 -100
  174. package/dist/chunks/payway-DekoJead.js +0 -56
  175. package/dist/chunks/phone-country-Cm5YUeXI.js +0 -3765
  176. package/dist/chunks/place-kit-DizZWV_e.js +0 -42
  177. package/dist/chunks/placekit-autocomplete.esm-LAwfbPZl.js +0 -1299
  178. package/dist/chunks/recaptcha-enterprise-BbOvO7JZ.js +0 -71
  179. package/dist/chunks/recaptcha-shared-Dwg1eVFS.js +0 -15
  180. package/dist/chunks/recaptcha-v2-checkbox-SY3ti5iQ.js +0 -41
  181. package/dist/chunks/recaptcha-v2-invisible-DSmQnn6c.js +0 -59
  182. package/dist/chunks/recaptcha-v3-DNh7YCnR.js +0 -28
  183. package/dist/chunks/repeater-DM0vuFNQ.js +0 -124
  184. package/dist/chunks/rich-text-C8aGYp70.js +0 -304
  185. package/dist/chunks/scripts-CKTFtxPO.js +0 -36
  186. package/dist/chunks/sdk-3SicTWby.js +0 -1559
  187. package/dist/chunks/shared--BU5CFoL.js +0 -80
  188. package/dist/chunks/signature-pFhZfH7d.js +0 -550
  189. package/dist/chunks/snaptcha-VuOUOaLj.js +0 -8
  190. package/dist/chunks/square-BR9pvToy.js +0 -46
  191. package/dist/chunks/stripe-OHUwoV9g.js +0 -202
  192. package/dist/chunks/styles-C3aqgtek.js +0 -21
  193. package/dist/chunks/summary-Da7Ktg3N.js +0 -126
  194. package/dist/chunks/table-C0PmR9bI.js +0 -95
  195. package/dist/chunks/text-limit-mLEwZDIa.js +0 -144
  196. package/dist/chunks/turnstile-9tM7q_LK.js +0 -59
  197. package/dist/chunks/utils-BntI3W4S.js +0 -6149
@@ -1,80 +0,0 @@
1
- import { k as u } from "./index-D6npYxvr.js";
2
- const f = (e) => e.replace(/["\\]/g, "\\$&"), a = /* @__PURE__ */ new WeakMap();
3
- function l(e) {
4
- return typeof window.CSS?.escape == "function" ? window.CSS.escape(e) : f(e);
5
- }
6
- function d(e) {
7
- return e.target instanceof HTMLElement && e.target.hasAttribute("data-formie-field-handle") ? [e.target] : e.target instanceof HTMLElement ? Array.from(e.target.querySelectorAll("[data-formie-field-handle]")).filter((t) => t instanceof HTMLElement) : [];
8
- }
9
- function g(e) {
10
- return d(e)[0] || null;
11
- }
12
- function s(e) {
13
- return e && e.formieValidation || null;
14
- }
15
- function E(e, t, i) {
16
- if (!e)
17
- return;
18
- const n = a.get(e) || /* @__PURE__ */ new Map(), r = n.get(t) || 0;
19
- if (r === 0) {
20
- const o = s(e);
21
- o && i(o);
22
- }
23
- n.set(t, r + 1), a.set(e, n);
24
- }
25
- function M(e, t, i) {
26
- if (!e)
27
- return;
28
- const n = a.get(e), r = n?.get(t) || 0;
29
- if (r <= 1) {
30
- const o = s(e);
31
- if (i.forEach((c) => {
32
- o?.removeValidator(c);
33
- }), n?.delete(t), !n || n.size === 0) {
34
- a.delete(e);
35
- return;
36
- }
37
- a.set(e, n);
38
- return;
39
- }
40
- n?.set(t, r - 1);
41
- }
42
- function m(e) {
43
- return e.ownerDocument || document;
44
- }
45
- function S(e, t) {
46
- const i = m(e);
47
- if (t) {
48
- const n = [
49
- e.querySelector(`template[data-formie-template-id="${l(t)}"]`),
50
- e.querySelector(`script[data-formie-template-id="${l(t)}"]`),
51
- i.querySelector(`template[data-formie-template-id="${l(t)}"]`),
52
- i.querySelector(`script[data-formie-template-id="${l(t)}"]`),
53
- i.getElementById(t)
54
- ];
55
- for (const r of n)
56
- if (r instanceof HTMLTemplateElement || r instanceof HTMLScriptElement)
57
- return r;
58
- }
59
- return null;
60
- }
61
- function T(e) {
62
- return e instanceof HTMLTemplateElement ? e.innerHTML : e instanceof HTMLScriptElement ? e.textContent || "" : e.innerHTML;
63
- }
64
- function H(e, t, i, n) {
65
- const r = u(t, i);
66
- e.dispatchEvent(new CustomEvent(r, {
67
- bubbles: !0,
68
- detail: n
69
- }));
70
- }
71
- export {
72
- M as a,
73
- T as b,
74
- S as c,
75
- H as d,
76
- l as e,
77
- g as f,
78
- d as g,
79
- E as r
80
- };
@@ -1,550 +0,0 @@
1
- import { g as C, d as M } from "./shared--BU5CFoL.js";
2
- import { e as T } from "./styles-C3aqgtek.js";
3
- var E = class {
4
- x;
5
- y;
6
- pressure;
7
- time;
8
- constructor(r, t, e, i) {
9
- if (isNaN(r) || isNaN(t))
10
- throw new Error(`Point is invalid: (${r}, ${t})`);
11
- this.x = +r, this.y = +t, this.pressure = e || 0, this.time = i || Date.now();
12
- }
13
- distanceTo(r) {
14
- return Math.sqrt(
15
- Math.pow(this.x - r.x, 2) + Math.pow(this.y - r.y, 2)
16
- );
17
- }
18
- equals(r) {
19
- return this.x === r.x && this.y === r.y && this.pressure === r.pressure && this.time === r.time;
20
- }
21
- velocityFrom(r) {
22
- return this.time !== r.time ? this.distanceTo(r) / (this.time - r.time) : 0;
23
- }
24
- }, L = class S {
25
- constructor(t, e, i, n, s, a) {
26
- this.startPoint = t, this.control2 = e, this.control1 = i, this.endPoint = n, this.startWidth = s, this.endWidth = a;
27
- }
28
- static fromPoints(t, e) {
29
- const i = this.calculateControlPoints(t[0], t[1], t[2]).c2, n = this.calculateControlPoints(t[1], t[2], t[3]).c1;
30
- return new S(t[1], i, n, t[2], e.start, e.end);
31
- }
32
- static calculateControlPoints(t, e, i) {
33
- const n = t.x - e.x, s = t.y - e.y, a = e.x - i.x, d = e.y - i.y, h = { x: (t.x + e.x) / 2, y: (t.y + e.y) / 2 }, l = { x: (e.x + i.x) / 2, y: (e.y + i.y) / 2 }, o = Math.sqrt(n * n + s * s), c = Math.sqrt(a * a + d * d), _ = h.x - l.x, f = h.y - l.y, m = o + c == 0 ? 0 : c / (o + c), u = { x: l.x + _ * m, y: l.y + f * m }, p = e.x - u.x, g = e.y - u.y;
34
- return {
35
- c1: new E(h.x + p, h.y + g),
36
- c2: new E(l.x + p, l.y + g)
37
- };
38
- }
39
- // Returns approximated length. Code taken from https://www.lemoda.net/maths/bezier-length/index.html.
40
- length() {
41
- let e = 0, i, n;
42
- for (let s = 0; s <= 10; s += 1) {
43
- const a = s / 10, d = this.point(
44
- a,
45
- this.startPoint.x,
46
- this.control1.x,
47
- this.control2.x,
48
- this.endPoint.x
49
- ), h = this.point(
50
- a,
51
- this.startPoint.y,
52
- this.control1.y,
53
- this.control2.y,
54
- this.endPoint.y
55
- );
56
- if (s > 0) {
57
- const l = d - i, o = h - n;
58
- e += Math.sqrt(l * l + o * o);
59
- }
60
- i = d, n = h;
61
- }
62
- return e;
63
- }
64
- // Calculate parametric value of x or y given t and the four point coordinates of a cubic bezier curve.
65
- point(t, e, i, n, s) {
66
- return e * (1 - t) * (1 - t) * (1 - t) + 3 * i * (1 - t) * (1 - t) * t + 3 * n * (1 - t) * t * t + s * t * t * t;
67
- }
68
- }, U = class {
69
- /* tslint:disable: variable-name */
70
- _et;
71
- /* tslint:enable: variable-name */
72
- constructor() {
73
- try {
74
- this._et = new EventTarget();
75
- } catch {
76
- this._et = document;
77
- }
78
- }
79
- addEventListener(r, t, e) {
80
- this._et.addEventListener(r, t, e);
81
- }
82
- dispatchEvent(r) {
83
- return this._et.dispatchEvent(r);
84
- }
85
- removeEventListener(r, t, e) {
86
- this._et.removeEventListener(r, t, e);
87
- }
88
- };
89
- function W(r, t = 250) {
90
- let e = 0, i = null, n, s, a;
91
- const d = () => {
92
- e = Date.now(), i = null, n = r.apply(s, a), i || (s = null, a = []);
93
- };
94
- return function(...l) {
95
- const o = Date.now(), c = t - (o - e);
96
- return s = this, a = l, c <= 0 || c > t ? (i && (clearTimeout(i), i = null), e = o, n = r.apply(s, a), i || (s = null, a = [])) : i || (i = window.setTimeout(d, c)), n;
97
- };
98
- }
99
- var D = class x extends U {
100
- /* tslint:enable: variable-name */
101
- constructor(t, e = {}) {
102
- super(), 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 ? W(x.prototype._strokeUpdate, this.throttle) : x.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(
103
- "2d",
104
- this.canvasContextOptions
105
- ), this.clear(), this.on();
106
- }
107
- // Public stuff
108
- dotSize;
109
- minWidth;
110
- maxWidth;
111
- penColor;
112
- minDistance;
113
- velocityFilterWeight;
114
- compositeOperation;
115
- backgroundColor;
116
- throttle;
117
- canvasContextOptions;
118
- // Private stuff
119
- /* tslint:disable: variable-name */
120
- _ctx;
121
- _drawingStroke = !1;
122
- _isEmpty = !0;
123
- _dataUrl;
124
- _dataUrlOptions;
125
- _lastPoints = [];
126
- // Stores up to 4 most recent points; used to generate a new curve
127
- _data = [];
128
- // Stores all points in groups (one group per line or dot)
129
- _lastVelocity = 0;
130
- _lastWidth = 0;
131
- _strokeMoveUpdate;
132
- _strokePointerId;
133
- clear() {
134
- const { _ctx: t, canvas: e } = this;
135
- 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;
136
- }
137
- redraw() {
138
- const t = this._data, e = this._dataUrl, i = this._dataUrlOptions;
139
- this.clear(), e && this.fromDataURL(e, i), this.fromData(t, { clear: !1 });
140
- }
141
- fromDataURL(t, e = {}) {
142
- return new Promise((i, n) => {
143
- const s = new Image(), a = e.ratio || window.devicePixelRatio || 1, d = e.width || this.canvas.width / a, h = e.height || this.canvas.height / a, l = e.xOffset || 0, o = e.yOffset || 0;
144
- this._reset(this._getPointGroupOptions()), s.onload = () => {
145
- this._ctx.drawImage(s, l, o, d, h), i();
146
- }, s.onerror = (c) => {
147
- n(c);
148
- }, s.crossOrigin = "anonymous", s.src = t, this._isEmpty = !1, this._dataUrl = t, this._dataUrlOptions = { ...e };
149
- });
150
- }
151
- toDataURL(t = "image/png", e) {
152
- return t === "image/svg+xml" ? (typeof e != "object" && (e = void 0), `data:image/svg+xml;base64,${btoa(
153
- this.toSVG(e)
154
- )}`) : (typeof e != "number" && (e = void 0), this.canvas.toDataURL(t, e));
155
- }
156
- on() {
157
- this.canvas.style.touchAction = "none", this.canvas.style.msTouchAction = "none", this.canvas.style.userSelect = "none", this.canvas.style.webkitUserSelect = "none";
158
- const t = /Macintosh/.test(navigator.userAgent) && "ontouchstart" in document;
159
- window.PointerEvent && !t ? this._handlePointerEvents() : (this._handleMouseEvents(), "ontouchstart" in window && this._handleTouchEvents());
160
- }
161
- off() {
162
- 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();
163
- }
164
- _getListenerFunctions() {
165
- const t = window.document === this.canvas.ownerDocument ? window : this.canvas.ownerDocument.defaultView ?? this.canvas.ownerDocument;
166
- return {
167
- addEventListener: t.addEventListener.bind(
168
- t
169
- ),
170
- removeEventListener: t.removeEventListener.bind(
171
- t
172
- )
173
- };
174
- }
175
- _removeMoveUpEventListeners() {
176
- const { removeEventListener: t } = this._getListenerFunctions();
177
- 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);
178
- }
179
- isEmpty() {
180
- return this._isEmpty;
181
- }
182
- fromData(t, { clear: e = !0 } = {}) {
183
- e && this.clear(), this._fromData(
184
- t,
185
- this._drawCurve.bind(this),
186
- this._drawDot.bind(this)
187
- ), this._data = this._data.concat(t);
188
- }
189
- toData() {
190
- return this._data;
191
- }
192
- _isLeftButtonPressed(t, e) {
193
- return e ? t.buttons === 1 : (t.buttons & 1) === 1;
194
- }
195
- _pointerEventToSignatureEvent(t) {
196
- return {
197
- event: t,
198
- type: t.type,
199
- x: t.clientX,
200
- y: t.clientY,
201
- pressure: "pressure" in t ? t.pressure : 0
202
- };
203
- }
204
- _touchEventToSignatureEvent(t) {
205
- const e = t.changedTouches[0];
206
- return {
207
- event: t,
208
- type: t.type,
209
- x: e.clientX,
210
- y: e.clientY,
211
- pressure: e.force
212
- };
213
- }
214
- // Event handlers
215
- _handleMouseDown(t) {
216
- !this._isLeftButtonPressed(t, !0) || this._drawingStroke || this._strokeBegin(this._pointerEventToSignatureEvent(t));
217
- }
218
- _handleMouseMove(t) {
219
- if (!this._isLeftButtonPressed(t, !0) || !this._drawingStroke) {
220
- this._strokeEnd(this._pointerEventToSignatureEvent(t), !1);
221
- return;
222
- }
223
- this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t));
224
- }
225
- _handleMouseUp(t) {
226
- this._isLeftButtonPressed(t) || this._strokeEnd(this._pointerEventToSignatureEvent(t));
227
- }
228
- _handleTouchStart(t) {
229
- t.targetTouches.length !== 1 || this._drawingStroke || (t.cancelable && t.preventDefault(), this._strokeBegin(this._touchEventToSignatureEvent(t)));
230
- }
231
- _handleTouchMove(t) {
232
- if (t.targetTouches.length === 1) {
233
- if (t.cancelable && t.preventDefault(), !this._drawingStroke) {
234
- this._strokeEnd(this._touchEventToSignatureEvent(t), !1);
235
- return;
236
- }
237
- this._strokeMoveUpdate(this._touchEventToSignatureEvent(t));
238
- }
239
- }
240
- _handleTouchEnd(t) {
241
- t.targetTouches.length === 0 && (t.cancelable && t.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(t)));
242
- }
243
- _handlePointerCancel(t) {
244
- this._allowPointerId(t) && (t.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(t), !1));
245
- }
246
- _handleTouchCancel(t) {
247
- t.cancelable && t.preventDefault(), this._strokeEnd(this._touchEventToSignatureEvent(t), !1);
248
- }
249
- _getPointerId(t) {
250
- return t.persistentDeviceId || t.pointerId;
251
- }
252
- _allowPointerId(t, e = !1) {
253
- return typeof this._strokePointerId > "u" ? e : this._getPointerId(t) === this._strokePointerId;
254
- }
255
- _handlePointerDown(t) {
256
- this._drawingStroke || !this._isLeftButtonPressed(t) || !this._allowPointerId(t, !0) || (this._strokePointerId = this._getPointerId(t), t.preventDefault(), this._strokeBegin(this._pointerEventToSignatureEvent(t)));
257
- }
258
- _handlePointerMove(t) {
259
- if (this._allowPointerId(t)) {
260
- if (!this._isLeftButtonPressed(t, !0) || !this._drawingStroke) {
261
- this._strokeEnd(this._pointerEventToSignatureEvent(t), !1);
262
- return;
263
- }
264
- t.preventDefault(), this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t));
265
- }
266
- }
267
- _handlePointerUp(t) {
268
- this._isLeftButtonPressed(t) || !this._allowPointerId(t) || (t.preventDefault(), this._strokeEnd(this._pointerEventToSignatureEvent(t)));
269
- }
270
- _getPointGroupOptions(t) {
271
- return {
272
- penColor: t && "penColor" in t ? t.penColor : this.penColor,
273
- dotSize: t && "dotSize" in t ? t.dotSize : this.dotSize,
274
- minWidth: t && "minWidth" in t ? t.minWidth : this.minWidth,
275
- maxWidth: t && "maxWidth" in t ? t.maxWidth : this.maxWidth,
276
- velocityFilterWeight: t && "velocityFilterWeight" in t ? t.velocityFilterWeight : this.velocityFilterWeight,
277
- compositeOperation: t && "compositeOperation" in t ? t.compositeOperation : this.compositeOperation
278
- };
279
- }
280
- // Private methods
281
- _strokeBegin(t) {
282
- if (!this.dispatchEvent(
283
- new CustomEvent("beginStroke", { detail: t, cancelable: !0 })
284
- ))
285
- return;
286
- const { addEventListener: i } = this._getListenerFunctions();
287
- switch (t.event.type) {
288
- case "mousedown":
289
- i("mousemove", this._handleMouseMove, {
290
- passive: !1
291
- }), i("mouseup", this._handleMouseUp, { passive: !1 });
292
- break;
293
- case "touchstart":
294
- i("touchmove", this._handleTouchMove, {
295
- passive: !1
296
- }), i("touchend", this._handleTouchEnd, { passive: !1 }), i("touchcancel", this._handleTouchCancel, { passive: !1 });
297
- break;
298
- case "pointerdown":
299
- i("pointermove", this._handlePointerMove, {
300
- passive: !1
301
- }), i("pointerup", this._handlePointerUp, {
302
- passive: !1
303
- }), i("pointercancel", this._handlePointerCancel, {
304
- passive: !1
305
- });
306
- break;
307
- }
308
- this._drawingStroke = !0;
309
- const n = this._getPointGroupOptions(), s = {
310
- ...n,
311
- points: []
312
- };
313
- this._data.push(s), this._reset(n), this._strokeUpdate(t);
314
- }
315
- _strokeUpdate(t) {
316
- if (!this._drawingStroke)
317
- return;
318
- if (this._data.length === 0) {
319
- this._strokeBegin(t);
320
- return;
321
- }
322
- this.dispatchEvent(
323
- new CustomEvent("beforeUpdateStroke", { detail: t })
324
- );
325
- const e = this._createPoint(t.x, t.y, t.pressure), i = this._data[this._data.length - 1], n = i.points, s = n.length > 0 && n[n.length - 1], a = s ? e.distanceTo(s) <= this.minDistance : !1, d = this._getPointGroupOptions(i);
326
- if (!s || !(s && a)) {
327
- const h = this._addPoint(e, d);
328
- s ? h && this._drawCurve(h, d) : this._drawDot(e, d), n.push({
329
- time: e.time,
330
- x: e.x,
331
- y: e.y,
332
- pressure: e.pressure
333
- });
334
- }
335
- this.dispatchEvent(new CustomEvent("afterUpdateStroke", { detail: t }));
336
- }
337
- _strokeEnd(t, e = !0) {
338
- this._removeMoveUpEventListeners(), this._drawingStroke && (e && this._strokeUpdate(t), this._drawingStroke = !1, this._strokePointerId = void 0, this.dispatchEvent(new CustomEvent("endStroke", { detail: t })));
339
- }
340
- _handlePointerEvents() {
341
- this._drawingStroke = !1, this.canvas.addEventListener("pointerdown", this._handlePointerDown, {
342
- passive: !1
343
- });
344
- }
345
- _handleMouseEvents() {
346
- this._drawingStroke = !1, this.canvas.addEventListener("mousedown", this._handleMouseDown, {
347
- passive: !1
348
- });
349
- }
350
- _handleTouchEvents() {
351
- this.canvas.addEventListener("touchstart", this._handleTouchStart, {
352
- passive: !1
353
- });
354
- }
355
- // Called when a new line is started
356
- _reset(t) {
357
- this._lastPoints = [], this._lastVelocity = 0, this._lastWidth = (t.minWidth + t.maxWidth) / 2, this._ctx.fillStyle = t.penColor, this._ctx.globalCompositeOperation = t.compositeOperation;
358
- }
359
- _createPoint(t, e, i) {
360
- const n = this.canvas.getBoundingClientRect();
361
- return new E(
362
- t - n.left,
363
- e - n.top,
364
- i,
365
- (/* @__PURE__ */ new Date()).getTime()
366
- );
367
- }
368
- // Add point to _lastPoints array and generate a new curve if there are enough points (i.e. 3)
369
- _addPoint(t, e) {
370
- const { _lastPoints: i } = this;
371
- if (i.push(t), i.length > 2) {
372
- i.length === 3 && i.unshift(i[0]);
373
- const n = this._calculateCurveWidths(
374
- i[1],
375
- i[2],
376
- e
377
- ), s = L.fromPoints(i, n);
378
- return i.shift(), s;
379
- }
380
- return null;
381
- }
382
- _calculateCurveWidths(t, e, i) {
383
- const n = i.velocityFilterWeight * e.velocityFrom(t) + (1 - i.velocityFilterWeight) * this._lastVelocity, s = this._strokeWidth(n, i), a = {
384
- end: s,
385
- start: this._lastWidth
386
- };
387
- return this._lastVelocity = n, this._lastWidth = s, a;
388
- }
389
- _strokeWidth(t, e) {
390
- return Math.max(e.maxWidth / (t + 1), e.minWidth);
391
- }
392
- _drawCurveSegment(t, e, i) {
393
- const n = this._ctx;
394
- n.moveTo(t, e), n.arc(t, e, i, 0, 2 * Math.PI, !1), this._isEmpty = !1;
395
- }
396
- _drawCurve(t, e) {
397
- const i = this._ctx, n = t.endWidth - t.startWidth, s = Math.ceil(t.length()) * 2;
398
- i.beginPath(), i.fillStyle = e.penColor;
399
- for (let a = 0; a < s; a += 1) {
400
- const d = a / s, h = d * d, l = h * d, o = 1 - d, c = o * o, _ = c * o;
401
- let f = _ * t.startPoint.x;
402
- f += 3 * c * d * t.control1.x, f += 3 * o * h * t.control2.x, f += l * t.endPoint.x;
403
- let m = _ * t.startPoint.y;
404
- m += 3 * c * d * t.control1.y, m += 3 * o * h * t.control2.y, m += l * t.endPoint.y;
405
- const u = Math.min(
406
- t.startWidth + l * n,
407
- e.maxWidth
408
- );
409
- this._drawCurveSegment(f, m, u);
410
- }
411
- i.closePath(), i.fill();
412
- }
413
- _drawDot(t, e) {
414
- const i = this._ctx, n = e.dotSize > 0 ? e.dotSize : (e.minWidth + e.maxWidth) / 2;
415
- i.beginPath(), this._drawCurveSegment(t.x, t.y, n), i.closePath(), i.fillStyle = e.penColor, i.fill();
416
- }
417
- _fromData(t, e, i) {
418
- for (const n of t) {
419
- const { points: s } = n, a = this._getPointGroupOptions(n);
420
- if (s.length > 1)
421
- for (let d = 0; d < s.length; d += 1) {
422
- const h = s[d], l = new E(
423
- h.x,
424
- h.y,
425
- h.pressure,
426
- h.time
427
- );
428
- d === 0 && this._reset(a);
429
- const o = this._addPoint(l, a);
430
- o && e(o, a);
431
- }
432
- else
433
- this._reset(a), i(s[0], a);
434
- }
435
- }
436
- toSVG({ includeBackgroundColor: t = !1, includeDataUrl: e = !1 } = {}) {
437
- const i = this._data, n = Math.max(window.devicePixelRatio || 1, 1), s = 0, a = 0, d = this.canvas.width / n, h = this.canvas.height / n, l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
438
- if (l.setAttribute("xmlns", "http://www.w3.org/2000/svg"), l.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), l.setAttribute("viewBox", `${s} ${a} ${d} ${h}`), l.setAttribute("width", d.toString()), l.setAttribute("height", h.toString()), t && this.backgroundColor) {
439
- const o = document.createElement("rect");
440
- o.setAttribute("width", "100%"), o.setAttribute("height", "100%"), o.setAttribute("fill", this.backgroundColor), l.appendChild(o);
441
- }
442
- if (e && this._dataUrl) {
443
- const o = this._dataUrlOptions?.ratio || window.devicePixelRatio || 1, c = this._dataUrlOptions?.width || this.canvas.width / o, _ = this._dataUrlOptions?.height || this.canvas.height / o, f = this._dataUrlOptions?.xOffset || 0, m = this._dataUrlOptions?.yOffset || 0, u = document.createElement("image");
444
- u.setAttribute("x", f.toString()), u.setAttribute("y", m.toString()), u.setAttribute("width", c.toString()), u.setAttribute("height", _.toString()), u.setAttribute("preserveAspectRatio", "none"), u.setAttribute("href", this._dataUrl), l.appendChild(u);
445
- }
446
- return this._fromData(
447
- i,
448
- (o, { penColor: c }) => {
449
- const _ = document.createElement("path");
450
- if (!isNaN(o.control1.x) && !isNaN(o.control1.y) && !isNaN(o.control2.x) && !isNaN(o.control2.y)) {
451
- const f = `M ${o.startPoint.x.toFixed(3)},${o.startPoint.y.toFixed(
452
- 3
453
- )} C ${o.control1.x.toFixed(3)},${o.control1.y.toFixed(3)} ${o.control2.x.toFixed(3)},${o.control2.y.toFixed(3)} ${o.endPoint.x.toFixed(3)},${o.endPoint.y.toFixed(3)}`;
454
- _.setAttribute("d", f), _.setAttribute("stroke-width", (o.endWidth * 2.25).toFixed(3)), _.setAttribute("stroke", c), _.setAttribute("fill", "none"), _.setAttribute("stroke-linecap", "round"), l.appendChild(_);
455
- }
456
- },
457
- (o, { penColor: c, dotSize: _, minWidth: f, maxWidth: m }) => {
458
- const u = document.createElement("circle"), p = _ > 0 ? _ : (f + m) / 2;
459
- u.setAttribute("r", p.toString()), u.setAttribute("cx", o.x.toString()), u.setAttribute("cy", o.y.toString()), u.setAttribute("fill", c), l.appendChild(u);
460
- }
461
- ), l.outerHTML;
462
- }
463
- };
464
- const O = "@layer formie-theme{[data-formie-field-type=signature] .formie-field-control{position:relative;transition:border-color .15s ease,box-shadow .15s ease,background-color .15s ease}[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{border-color:var(--formie-focus-ring-border-color);box-shadow:var(--formie-shadow-focus)}.formie-field-has-error[data-formie-field-type=signature] .formie-signature-canvas{border-color:var(--formie-color-danger)}.formie-field-has-error[data-formie-field-type=signature] .formie-field-control:focus-within .formie-signature-canvas{box-shadow:var(--formie-shadow-danger-focus)}[data-formie-field-type=signature] .formie-signature-canvas{display:block;width:var(--formie-signature-width);height:var(--formie-signature-height);border:var(--formie-signature-border);background:var(--formie-signature-background);border-radius:var(--formie-signature-border-radius);touch-action:none;transition:border-color .15s ease,box-shadow .15s ease,background-color .15s ease}[data-formie-field-type=signature] .formie-signature-remove-button{position:absolute;top:var(--formie-signature-remove-button-top);right:var(--formie-signature-remove-button-right);transform:var(--formie-signature-remove-button-transform);font-size:0;line-height:0}}", A = "input[data-formie-signature-input]", P = "canvas[data-formie-signature-canvas]", F = "[data-formie-signature-clear]", b = "signature";
465
- T(b, [O]);
466
- function I(r) {
467
- const t = r.getBoundingClientRect();
468
- return {
469
- width: Math.round(t.width),
470
- height: Math.round(t.height)
471
- };
472
- }
473
- function z(r, t) {
474
- if (!t)
475
- return;
476
- const e = new Image();
477
- e.src = t, e.onload = () => {
478
- const i = Math.max(window.devicePixelRatio || 1, 1), n = r.getContext("2d");
479
- n && n.drawImage(e, 0, 0, r.width / i, r.height / i);
480
- };
481
- }
482
- function R(r, t, e, i, n, s) {
483
- const a = parseFloat(s.penWeight || "2") || 2, d = i.parentElement instanceof HTMLElement ? i.parentElement : t, h = new D(i, {
484
- backgroundColor: s.backgroundColor || "rgba(255, 255, 255, 0)",
485
- penColor: s.penColor || "#000000",
486
- dotSize: a,
487
- minWidth: a,
488
- maxWidth: a
489
- }), l = () => {
490
- const { width: g, height: v } = I(i);
491
- if (!(g > 0) || !(v > 0))
492
- return;
493
- const w = Math.max(window.devicePixelRatio || 1, 1), y = i.getContext("2d");
494
- if (!y)
495
- return;
496
- const k = e.value || (h.isEmpty() ? "" : h.toDataURL());
497
- i.width = g * w, i.height = v * w, y.setTransform(1, 0, 0, 1, 0, 0), y.scale(w, w), h.clear(), z(i, k);
498
- }, o = (g = 0) => {
499
- window.setTimeout(() => {
500
- window.requestAnimationFrame(() => {
501
- l();
502
- });
503
- }, g);
504
- }, c = () => {
505
- o();
506
- }, _ = () => {
507
- o(100);
508
- }, f = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
509
- o();
510
- }), m = (g) => {
511
- const v = e.value !== g;
512
- e.value = g, v && (e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 })));
513
- }, u = () => {
514
- m(h.isEmpty() ? "" : h.toDataURL());
515
- }, p = () => {
516
- h.clear(), m("");
517
- };
518
- return h.addEventListener("endStroke", u), window.addEventListener("resize", c), r.addEventListener("formie:page:navigate:after", _), f?.observe(d), o(), n && n.addEventListener("click", p), M(t, b, "init", {
519
- signature: h
520
- }), () => {
521
- h.removeEventListener("endStroke", u), window.removeEventListener("resize", c), r.removeEventListener("formie:page:navigate:after", _), f?.disconnect(), n && n.removeEventListener("click", p), h.clear();
522
- };
523
- }
524
- const $ = {
525
- id: b,
526
- kind: "field",
527
- match: (r) => !!r.target.querySelector(P),
528
- setup: async (r) => {
529
- const t = r.options || {}, e = r.root instanceof HTMLElement ? r.root : r.target instanceof HTMLElement ? r.target : null;
530
- if (!e)
531
- return;
532
- const n = C(r).map((s) => {
533
- const a = s.querySelector(A), d = s.querySelector(P), h = s.querySelector(F);
534
- return !(a instanceof HTMLInputElement) || !(d instanceof HTMLCanvasElement) ? () => {
535
- } : R(e, s, a, d, h instanceof HTMLElement ? h : null, t);
536
- });
537
- return await r.emit("formie:module:signature:init", {
538
- count: n.length
539
- }), {
540
- destroy: () => {
541
- n.forEach((s) => {
542
- s();
543
- }), r.emit("formie:module:signature:destroy", {});
544
- }
545
- };
546
- }
547
- };
548
- export {
549
- $ as signatureModule
550
- };
@@ -1,8 +0,0 @@
1
- import { e as a } from "./index-D6npYxvr.js";
2
- const t = a({
3
- id: "snaptcha",
4
- defaultPlaceholderSelector: "[data-snaptcha-captcha-placeholder]"
5
- });
6
- export {
7
- t as snaptchaModule
8
- };
@@ -1,46 +0,0 @@
1
- import { v as c } from "./index-D6npYxvr.js";
2
- import { l as u } from "./scripts-CKTFtxPO.js";
3
- const l = "FORMIE_SQUARE_SCRIPT", f = c({
4
- id: "square",
5
- defaultRequiredInputSuffixes: ["squarePaymentId"],
6
- load: async (n) => {
7
- const { provider: e } = n.options, r = e.applicationId, t = e.locationId;
8
- if (!r?.trim() || !t?.trim())
9
- return console.error("[formie] Missing applicationId or locationId for Square."), null;
10
- const a = e.environment === "sandbox" ? "https://sandbox.web.squarecdn.com/v1/square.js" : "https://web.squarecdn.com/v1/square.js";
11
- return await u("Square", {
12
- id: l,
13
- src: a
14
- }), window.Square;
15
- },
16
- mount: async (n) => {
17
- const { api: e, field: r, services: t, options: s } = n, a = s.provider, i = r.querySelector("[data-formie-square-button]");
18
- if (!i || !e)
19
- return null;
20
- try {
21
- const d = await e.payments(a.applicationId || "", a.locationId || "").card();
22
- return await d.attach(i), d;
23
- } catch (o) {
24
- return t.addError(o instanceof Error ? o.message : "Unable to initialize payment."), null;
25
- }
26
- },
27
- unmount: async () => {
28
- },
29
- onBeforeAuthorize: async (n) => {
30
- const { widget: e, services: r } = n;
31
- if (!e)
32
- return r.addError("Square card is not ready."), !1;
33
- try {
34
- const t = await e.tokenize();
35
- return t.status === "OK" && t.token ? (r.updateInputs("squarePaymentId", t.token), !0) : (r.addError(t.errors?.[0]?.message || "Tokenization failed."), !1);
36
- } catch {
37
- return r.addError("Payment tokenization failed. Please try again."), !1;
38
- }
39
- },
40
- onAfterSubmit: async ({ services: n }) => {
41
- n.updateInputs("squarePaymentId", "");
42
- }
43
- });
44
- export {
45
- f as squareModule
46
- };