@feathery/react 2.23.4 → 2.23.5

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 (94) hide show
  1. package/cjs/auth/internal/utils.d.ts.map +1 -1
  2. package/cjs/elements/fields/PhoneField/CountryDropdown.d.ts.map +1 -1
  3. package/cjs/elements/fields/PhoneField/index.d.ts.map +1 -1
  4. package/cjs/elements/fields/PhoneField/tests/test-utils.d.ts.map +1 -1
  5. package/cjs/{fthry_FormControl.CP_mLa1m.js → fthry_FormControl.CscXHID3.js} +1 -1
  6. package/cjs/{fthry_InlineTooltip.B8DmZAm_.js → fthry_InlineTooltip.ZpgEmPO3.js} +2 -2
  7. package/cjs/{fthry_Overlay.NbtN0szY.js → fthry_Overlay.BTS_EcV3.js} +1 -1
  8. package/cjs/{fthry_PaymentMethodField.Chdv_-BE.js → fthry_PaymentMethodField.D902pJlo.js} +4 -4
  9. package/cjs/{fthry_Placeholder.DqfWdyxL.js → fthry_Placeholder.Ctq06SYu.js} +1 -1
  10. package/cjs/{fthry_ShowEyeIcon.D0r8cp_B.js → fthry_ShowEyeIcon.q9BhUK2g.js} +1 -1
  11. package/cjs/{fthry_index.C5j86Jvn.js → fthry_index.-Y9ZJS34.js} +6 -6
  12. package/cjs/{fthry_index.xSHVUU1i.js → fthry_index.9PFsbc4I.js} +1 -1
  13. package/cjs/{fthry_index.jPrS6PXj.js → fthry_index.B4YVBeqY.js} +3 -3
  14. package/cjs/{fthry_index.DYCqVDAy.js → fthry_index.BS6b2BTF.js} +6 -6
  15. package/cjs/{fthry_index.BYHR4MSY.js → fthry_index.BYTU7WTg.js} +4 -4
  16. package/cjs/{fthry_index.D12V6N10.js → fthry_index.B_UehadW.js} +1 -1
  17. package/cjs/{fthry_index.BEVeNRzV.js → fthry_index.Bh5jAAhx.js} +6 -6
  18. package/cjs/{fthry_index.DMpC4pzK.js → fthry_index.Bl2kuNOo.js} +14 -16
  19. package/cjs/{fthry_index.D4Wh5Gae.js → fthry_index.BmT77CVY.js} +2 -2
  20. package/cjs/{fthry_index.DHiNhZNV.js → fthry_index.Bsklltx4.js} +1 -1
  21. package/cjs/{fthry_index.CwZQzFeM.js → fthry_index.BuQ1HIIN.js} +8 -8
  22. package/cjs/{fthry_index.Cmq71Bt9.js → fthry_index.C6-dnyHD.js} +1 -1
  23. package/cjs/{fthry_index.B2zNdCo9.js → fthry_index.CSwhuTPY.js} +1 -1
  24. package/cjs/{fthry_index.nk3LibkG.js → fthry_index.CTqVrxjv.js} +1 -1
  25. package/cjs/{fthry_index.DxlmMil4.js → fthry_index.CWofoHQs.js} +4 -4
  26. package/cjs/{fthry_index.CJcXFlqa.js → fthry_index.CbASwLjr.js} +1 -1
  27. package/cjs/{fthry_index.NQG80c7p.js → fthry_index.D36o5hns.js} +5 -5
  28. package/cjs/{fthry_index.DnxpWsMc.js → fthry_index.DGctX9WE.js} +5 -5
  29. package/cjs/fthry_index.DKgFa6Cd.js +7245 -0
  30. package/cjs/{fthry_index.CxSsfqmh.js → fthry_index.Jp2CJ4is.js} +2 -2
  31. package/cjs/{fthry_index.Bsfl9n6o.js → fthry_index.Nrwqiq0j.js} +5 -5
  32. package/cjs/{fthry_index.BwJ8UbV0.js → fthry_index._iQAHcD9.js} +1285 -1272
  33. package/cjs/{fthry_index.MhBBvjf4.js → fthry_index.dGUMsRB1.js} +4 -4
  34. package/cjs/{fthry_index.D48NiLIf.js → fthry_index.jot4NArP.js} +3 -3
  35. package/cjs/{fthry_index.qt3C-Qt1.js → fthry_index.lGGMSnRj.js} +1 -1
  36. package/cjs/{fthry_index.BUWCPnkW.js → fthry_index.mEUshDAA.js} +1 -1
  37. package/cjs/{fthry_input.BtD9rhOL.js → fthry_input.3JtjJgPY.js} +1 -1
  38. package/cjs/{fthry_script.Bse2qene.js → fthry_script.DOCG8gyM.js} +1 -1
  39. package/cjs/{fthry_styles.CBS4ziaS.js → fthry_styles.CVqE6wer.js} +1 -1
  40. package/cjs/{fthry_useElementSize.1JZE9_XK.js → fthry_useElementSize.B5-XFuix.js} +1 -1
  41. package/cjs/{fthry_useSalesforceSync.BDWg3Re_.js → fthry_useSalesforceSync.D9f_IkFv.js} +1 -1
  42. package/cjs/{fthry_webfontloader.C5EOl2GC.js → fthry_webfontloader.5X-HEWHN.js} +1 -1
  43. package/cjs/index.js +1 -1
  44. package/cjs/utils/validation.d.ts +4 -3
  45. package/cjs/utils/validation.d.ts.map +1 -1
  46. package/dist/auth/internal/utils.d.ts.map +1 -1
  47. package/dist/elements/fields/PhoneField/CountryDropdown.d.ts.map +1 -1
  48. package/dist/elements/fields/PhoneField/index.d.ts.map +1 -1
  49. package/dist/elements/fields/PhoneField/tests/test-utils.d.ts.map +1 -1
  50. package/dist/{fthry_FormControl.pCOAO7LM.js → fthry_FormControl.Bt83gTi3.js} +1 -1
  51. package/dist/{fthry_InlineTooltip.C_1nocB9.js → fthry_InlineTooltip.BADFGh_F.js} +2 -2
  52. package/dist/{fthry_Overlay.B71_lHCP.js → fthry_Overlay.CsBPXuR_.js} +1 -1
  53. package/dist/{fthry_PaymentMethodField.DWQiQajb.js → fthry_PaymentMethodField.CVKE3t_i.js} +4 -4
  54. package/dist/{fthry_Placeholder.CmfLMsuU.js → fthry_Placeholder.9MqCxqHS.js} +1 -1
  55. package/dist/{fthry_ShowEyeIcon.CwsDOp-1.js → fthry_ShowEyeIcon.CxXoA4_B.js} +1 -1
  56. package/dist/{fthry_index.qSUOQAau.js → fthry_index.5oEnjTzQ.js} +3 -3
  57. package/dist/{fthry_index.DrbC7Yvj.js → fthry_index.7TulZeVg.js} +6 -6
  58. package/dist/{fthry_index.B6e40TNH.js → fthry_index.AdQD-dII.js} +1 -1
  59. package/dist/{fthry_index.3I3TFRij.js → fthry_index.B0_n9jqc.js} +4 -4
  60. package/dist/{fthry_index.CTNmp4Uu.js → fthry_index.BIkyi9OD.js} +4 -4
  61. package/dist/{fthry_index.lUtvQLwf.js → fthry_index.BPmvHG0R.js} +1 -1
  62. package/dist/{fthry_index.Boum24kr.js → fthry_index.BQTGcd6O.js} +8 -8
  63. package/dist/{fthry_index.CRHUBRQI.js → fthry_index.BbSZxIR5.js} +2 -2
  64. package/dist/{fthry_index.fgPxSncQ.js → fthry_index.Beh4LhUb.js} +4 -4
  65. package/dist/{fthry_index.xiCtRiXP.js → fthry_index.C0FNSGu0.js} +5 -5
  66. package/dist/{fthry_index.DNkI9rK_.js → fthry_index.C4cVkdmR.js} +5 -5
  67. package/dist/{fthry_index.B662KpzL.js → fthry_index.CefyT_Xy.js} +3 -3
  68. package/dist/{fthry_index.B-1AsITd.js → fthry_index.CnNPiyfF.js} +6 -6
  69. package/dist/{fthry_index.Du7-Siwz.js → fthry_index.CsQzji9M.js} +1 -1
  70. package/dist/{fthry_index.DZzcdxua.js → fthry_index.Cy8OGyJ9.js} +14 -16
  71. package/dist/{fthry_index.DkOfnwMo.js → fthry_index.CyjNCuWE.js} +1 -1
  72. package/dist/{fthry_index.BdiPlpSw.js → fthry_index.D4ENNIPP.js} +1 -1
  73. package/dist/{fthry_index.B_MGu0vq.js → fthry_index.D86GTeP3.js} +6 -6
  74. package/dist/{fthry_index.Zw_6EeQW.js → fthry_index.Degy27gw.js} +1 -1
  75. package/dist/{fthry_index.CDEcS8bU.js → fthry_index.DoxZOyru.js} +2 -2
  76. package/dist/{fthry_index.BM9D8gpq.js → fthry_index.DpU0lL2P.js} +1 -1
  77. package/dist/{fthry_index.DpJv-8TU.js → fthry_index.Dte366nP.js} +1 -1
  78. package/dist/{fthry_index.EsYuFuWJ.js → fthry_index.EFk2iysz.js} +1286 -1273
  79. package/dist/{fthry_index.BFjEVX8Q.js → fthry_index.FjbxGNs2.js} +5 -5
  80. package/dist/fthry_index.FxHyaooV.js +7193 -0
  81. package/dist/{fthry_index.UgzTpusQ.js → fthry_index.qQius3J9.js} +1 -1
  82. package/dist/{fthry_input.DDJESt6C.js → fthry_input.BMNwRyD_.js} +1 -1
  83. package/dist/{fthry_script.BZXm6Hk6.js → fthry_script.0KhNn8f9.js} +1 -1
  84. package/dist/{fthry_styles.LF8XhlRV.js → fthry_styles.DtCYeZPi.js} +1 -1
  85. package/dist/{fthry_useElementSize.Bs-CqmP2.js → fthry_useElementSize.fW6iiT11.js} +1 -1
  86. package/dist/{fthry_useSalesforceSync.DWx9gd0A.js → fthry_useSalesforceSync.BIkirclp.js} +1 -1
  87. package/dist/{fthry_webfontloader.Fmt0quEr.js → fthry_webfontloader.Dyilj6id.js} +1 -1
  88. package/dist/index.js +1 -1
  89. package/dist/utils/validation.d.ts +4 -3
  90. package/dist/utils/validation.d.ts.map +1 -1
  91. package/package.json +2 -1
  92. package/umd/{PhoneField.f52b5de44614b445feeb.js → PhoneField.42eae8ec161c28522777.js} +1 -1
  93. package/umd/index.js +1 -1
  94. package/umd/libphonenumber.d53d0d1347fa5545ff45.js +1 -0
@@ -17570,373 +17570,726 @@ var isBase64Image = function (string) {
17570
17570
  return BASE64_REGEX.test(string);
17571
17571
  };
17572
17572
 
17573
- var plaidPromise = null;
17574
- function installPlaid(isPlaidActive) {
17575
- if (plaidPromise)
17576
- return plaidPromise;
17577
- else if (!isPlaidActive)
17578
- return Promise.resolve();
17579
- else {
17580
- plaidPromise = dynamicImport('https://cdn.plaid.com/link/v2/stable/link-initialize.js');
17581
- return plaidPromise;
17582
- }
17583
- }
17584
- function openPlaidLink(client, onSuccess, onExit, updateFieldValues, action, handleError) {
17585
- return __awaiter$2(this, void 0, void 0, function () {
17586
- var kwargs, res, handler;
17587
- var _this = this;
17588
- return __generator(this, function (_a) {
17589
- switch (_a.label) {
17590
- case 0: return [4 /*yield*/, plaidPromise];
17591
- case 1:
17592
- _a.sent();
17593
- if (action.plaid_action === 'identity') {
17594
- kwargs = {
17595
- identity_template_id: action.template_id,
17596
- email_field: action.email_field
17597
- };
17598
- }
17599
- else {
17600
- kwargs = { liabilities: action.include_liabilities ? 'true' : 'false' };
17601
- }
17602
- return [4 /*yield*/, client.fetchPlaidLinkToken(kwargs)];
17603
- case 2:
17604
- res = _a.sent();
17605
- if (res.err) {
17606
- handleError(res.err);
17607
- return [2 /*return*/];
17608
- }
17609
- handler = global.Plaid.create({
17610
- token: res.token,
17611
- onExit: onExit,
17612
- onSuccess: function (publicToken, metadata) { return __awaiter$2(_this, void 0, void 0, function () {
17613
- var res_1, statusKey, newValues, res_2, fieldVals;
17614
- var _a;
17615
- var _b;
17616
- return __generator(this, function (_c) {
17617
- switch (_c.label) {
17618
- case 0:
17619
- _c.trys.push([0, 8, 9, 10]);
17620
- if (!(action.plaid_action === 'identity')) return [3 /*break*/, 4];
17621
- return [4 /*yield*/, client.fetchPlaidVerificationStatus(metadata.link_session_id)];
17622
- case 1:
17623
- res_1 = _c.sent();
17624
- statusKey = action.plaid_identity_field_key;
17625
- if (statusKey) {
17626
- newValues = (_a = {}, _a[statusKey] = res_1.status, _a);
17627
- updateFieldValues(newValues);
17628
- client.submitCustom(newValues, { shouldFlush: true });
17629
- }
17630
- if (!(res_1.status !== 'success')) return [3 /*break*/, 3];
17631
- handleError('Identity verification was not successful');
17632
- return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
17633
- case 2:
17634
- _c.sent();
17635
- return [2 /*return*/];
17636
- case 3: return [3 /*break*/, 6];
17637
- case 4:
17638
- if (!publicToken) return [3 /*break*/, 6];
17639
- res_2 = client.submitPlaidUserData(publicToken);
17640
- if (!((_b = action.wait_for_completion) !== null && _b !== void 0 ? _b : true)) return [3 /*break*/, 6];
17641
- return [4 /*yield*/, res_2];
17642
- case 5:
17643
- fieldVals = _c.sent();
17644
- updateFieldValues(fieldVals);
17645
- _c.label = 6;
17646
- case 6: return [4 /*yield*/, onSuccess()];
17647
- case 7:
17648
- _c.sent();
17649
- return [3 /*break*/, 10];
17650
- case 8:
17651
- _c.sent();
17652
- handleError();
17653
- return [3 /*break*/, 10];
17654
- case 9:
17655
- handler.exit();
17656
- handler.destroy();
17657
- return [7 /*endfinally*/];
17658
- case 10: return [2 /*return*/];
17659
- }
17660
- });
17661
- }); }
17662
- });
17663
- handler.open();
17664
- return [2 /*return*/];
17665
- }
17666
- });
17667
- });
17668
- }
17573
+ var isUrl_1;
17574
+ var hasRequiredIsUrl;
17669
17575
 
17670
- var RouterContext = createContext({
17671
- location: {
17672
- pathname: ''
17673
- },
17674
- navigate: function () { }
17675
- });
17676
- function RouterProvider(_a) {
17677
- var children = _a.children, _b = _a.initialPath, initialPath = _b === void 0 ? featheryWindow().location.pathname : _b;
17678
- var _c = __read(useState({ pathname: initialPath }), 2), location = _c[0], setLocation = _c[1];
17679
- var navigate = useCallback(function (to, options) {
17680
- if (options === void 0) { options = {}; }
17681
- var historyMethod = options.replace ? 'replaceState' : 'pushState';
17682
- featheryWindow().history[historyMethod](null, '', to);
17683
- setLocation({ pathname: to });
17684
- }, []);
17685
- // listen to browser back/forward navigation
17686
- useEffect(function () {
17687
- var window = featheryWindow();
17688
- var handlePopState = function () {
17689
- setLocation({ pathname: window.location.pathname });
17690
- };
17691
- window.addEventListener('popstate', handlePopState);
17692
- return function () { return window.removeEventListener('popstate', handlePopState); };
17693
- }, []);
17694
- var routerData = useMemo(function () { return ({
17695
- location: location,
17696
- navigate: navigate
17697
- }); }, [location, navigate]);
17698
- return (jsx$1(RouterContext.Provider, __assign({ value: routerData }, { children: children })));
17699
- }
17700
- function useLocation() {
17701
- var context = useContext(RouterContext);
17702
- if (!context)
17703
- throw new Error('useLocation must be used within RouterProvider');
17704
- return context.location;
17705
- }
17706
- function useNavigate() {
17707
- var context = useContext(RouterContext);
17708
- if (!context)
17709
- throw new Error('useNavigate must be used within RouterProvider');
17710
- return context.navigate;
17576
+ function requireIsUrl () {
17577
+ if (hasRequiredIsUrl) return isUrl_1;
17578
+ hasRequiredIsUrl = 1;
17579
+ /**
17580
+ * Expose `isUrl`.
17581
+ */
17582
+
17583
+ isUrl_1 = isUrl;
17584
+
17585
+ /**
17586
+ * RegExps.
17587
+ * A URL must match #1 and then at least one of #2/#3.
17588
+ * Use two levels of REs to avoid REDOS.
17589
+ */
17590
+
17591
+ var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
17592
+
17593
+ var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
17594
+ var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
17595
+
17596
+ /**
17597
+ * Loosely validate a URL `string`.
17598
+ *
17599
+ * @param {String} string
17600
+ * @return {Boolean}
17601
+ */
17602
+
17603
+ function isUrl(string){
17604
+ if (typeof string !== 'string') {
17605
+ return false;
17606
+ }
17607
+
17608
+ var match = string.match(protocolAndDomainRE);
17609
+ if (!match) {
17610
+ return false;
17611
+ }
17612
+
17613
+ var everythingAfterProtocol = match[1];
17614
+ if (!everythingAfterProtocol) {
17615
+ return false;
17616
+ }
17617
+
17618
+ if (localhostDomainRE.test(everythingAfterProtocol) ||
17619
+ nonLocalhostDomainRE.test(everythingAfterProtocol)) {
17620
+ return true;
17621
+ }
17622
+
17623
+ return false;
17624
+ }
17625
+ return isUrl_1;
17711
17626
  }
17712
17627
 
17713
- var MIN_AXIS_SIZE = 15;
17714
- var FIT = 'fit';
17715
- var FILL = 'fill';
17716
- var isFill = function (v) { return v === FILL; };
17717
- var isFit = function (v) { return v === FIT; };
17718
- var isPx = function (v) {
17719
- return typeof v === 'string' && v.indexOf('px') >= 0 && v.indexOf('calc') < 0;
17720
- };
17721
- var getPxValue = function (size) {
17722
- return isPx(size) ? Number.parseFloat(size) : MIN_AXIS_SIZE;
17723
- };
17724
- var formatDimensionValue = function (value, type) {
17725
- // fit-content is needed to allow elements to push beyond the parent container's explicit height.
17726
- switch (value) {
17727
- case FILL:
17728
- return type === 'width' ? '100%' : 'auto';
17729
- case FIT:
17730
- return 'fit-content';
17731
- default:
17732
- return parseInt(value);
17733
- }
17734
- };
17735
- var calculateDimensionsHelper = function (root, p) {
17736
- if (p === void 0) { p = ''; }
17737
- var width = root["".concat(p, "width")] || root.width;
17738
- var height = root["".concat(p, "height")] || root.height;
17739
- var dimensions = {
17740
- maxWidth: formatDimensionValue(width, 'width'),
17741
- height: formatDimensionValue(height, 'height')
17742
- };
17743
- // to allow responsiveness, min width shouldn't be set for fixed widths
17744
- dimensions.minWidth = isNum(width) ? undefined : dimensions.maxWidth;
17745
- // min and max height must be 100% to prevent fit-content from collapsing, which would break fill's non-collapsing intent
17746
- dimensions.minHeight = isFill(height) ? '100%' : dimensions.height;
17747
- return dimensions;
17748
- };
17628
+ var isUrlExports = requireIsUrl();
17629
+ var isUrl = /*@__PURE__*/getDefaultExportFromCjs(isUrlExports);
17630
+
17631
+ var LETTER_MATCH = /[a-zA-Z]/;
17632
+ var UPPERCASE_LETTER_MATCH = /[A-Z]/;
17633
+ var LOWERCASE_LETTER_MATCH = /[a-z]/;
17634
+ var NUMBER_MATCH = /\d/;
17635
+ // eslint-disable-next-line no-useless-escape
17636
+ var SYMBOL_MATCH = /[#$\.%&'()\+,-/:;<=>!?@\\\[\]\^_`{|}~\*]/;
17637
+ var DOMAIN_ALLOWED_CHARACTERS = /^[a-zA-Z0-9.\\-]+$/;
17749
17638
  /**
17750
- * Calculates the dimensions of the provided step.
17751
- * Note: The provided step should be fully-hydrated (i.e. rows injected, etc.) to calculate dimensions accurately.
17639
+ * Validate elements on a form
17752
17640
  */
17753
- function calculateStepCSS(step) {
17754
- if (!step)
17755
- return {};
17756
- var root = step.subgrids.find(function (grid) { return grid.position.length === 0; });
17757
- var desktop = calculateDimensionsHelper(root);
17758
- var mobile = calculateDimensionsHelper(root, 'mobile_');
17759
- var stepCSS = __assign({ backgroundSize: 'cover', width: '100%' }, desktop);
17760
- // width will be controlled by maxWidth in the case it is fixed below 478px
17761
- stepCSS["@media (max-width: 478px)"] = __assign({ width: '100%' }, mobile);
17762
- return stepCSS;
17763
- }
17764
- function calculateGlobalCSS(globalStyles) {
17765
- var styles = new ResponsiveStyles({ styles: globalStyles }, ['form'], false, DEFAULT_MOBILE_BREAKPOINT);
17766
- if (globalStyles) {
17767
- styles.applyFontStyles('form');
17768
- }
17769
- return styles;
17770
- }
17771
-
17772
- function changeStep(newKey, oldKey, steps, setStepKey, navigate, client, trackHashes) {
17773
- var sameKey = oldKey === newKey;
17774
- if (!sameKey && newKey) {
17775
- if (newKey in steps) {
17776
- client.registerEvent({
17777
- step_key: oldKey,
17778
- next_step_key: newKey,
17779
- event: 'complete'
17780
- });
17781
- if (trackHashes)
17782
- navigate(location.pathname + location.search + "#".concat(newKey), {
17783
- replace: true
17784
- });
17785
- setStepKey(newKey);
17786
- return true;
17641
+ function validateElements(_a) {
17642
+ var step = _a.step, visiblePositions = _a.visiblePositions, triggerErrors = _a.triggerErrors, errorType = _a.errorType, formRef = _a.formRef, _b = _a.errorCallback, errorCallback = _b === void 0 ? function () { } : _b, setInlineErrors = _a.setInlineErrors, trigger = _a.trigger;
17643
+ var invalid = false;
17644
+ var inlineErrors = {};
17645
+ var errors = getVisibleElements(step, visiblePositions, ['servar_fields', 'buttons'], true).reduce(function (errors, _a) {
17646
+ var _b;
17647
+ var element = _a.element, repeat = _a.repeat, last = _a.last, elementType = _a.type;
17648
+ var key, type;
17649
+ if (elementType === 'servar_fields') {
17650
+ if (element.servar.repeat_trigger === 'set_value' && last && repeat) {
17651
+ // Skip validation on last repeat since it might be default value
17652
+ return errors;
17653
+ }
17654
+ type = element.servar.type;
17655
+ key = element.servar.key;
17656
+ }
17657
+ else {
17658
+ // if not a servar, then a button
17659
+ type = 'button';
17660
+ key = element.id;
17787
17661
  }
17662
+ var message = validateElement(element, repeat);
17663
+ // We want to clear button errors when the button is not "relevant" to what the user is doing.
17664
+ // If the element is a button and was NOT the trigger or no trigger,
17665
+ // then we don't show the error.
17666
+ if (type === 'button' && ((trigger && key !== trigger.id) || !trigger))
17667
+ message = '';
17668
+ if (!(key in errors))
17669
+ errors[key] = message;
17670
+ else if (Array.isArray(errors[key]))
17671
+ errors[key].push(message);
17788
17672
  else
17789
- console.warn("".concat(newKey, " is not a valid step to navigate to"));
17790
- }
17791
- return false;
17792
- }
17793
- function getNewStepUrl(stepKey) {
17794
- return location.pathname + location.search + "#".concat(stepKey);
17795
- }
17796
- function getPrevStepKey(curStep, stepMap) {
17797
- var newStepKey = stepMap[curStep.key];
17798
- if (!newStepKey) {
17799
- var prevCondition = curStep.previous_conditions[0];
17800
- if (prevCondition)
17801
- newStepKey = prevCondition.previous_step_key;
17673
+ errors[key] = [errors[key], message];
17674
+ if (message && !invalid)
17675
+ invalid = true;
17676
+ if (type === 'matrix' && message) {
17677
+ // Get question index where error is
17678
+ var fieldValue = fieldValues[key];
17679
+ // handle repeated matrix fields
17680
+ if (repeat != null && Array.isArray(fieldValue))
17681
+ fieldValue = (_b = fieldValue[repeat]) !== null && _b !== void 0 ? _b : {};
17682
+ var questions = element.servar.metadata.questions;
17683
+ var questionIds = questions.map(function (q) { return q.id; });
17684
+ for (var i = 0; i < questionIds.length; i++) {
17685
+ var value = fieldValue[questionIds[i]];
17686
+ if (value === undefined ||
17687
+ (Array.isArray(value) && value.length === 0)) {
17688
+ key = "".concat(key, "-").concat(i);
17689
+ break;
17690
+ }
17691
+ }
17692
+ }
17693
+ if (triggerErrors) {
17694
+ setFormElementError({
17695
+ formRef: formRef,
17696
+ errorCallback: errorCallback,
17697
+ fieldKey: key,
17698
+ message: message,
17699
+ errorType: errorType,
17700
+ servarType: type,
17701
+ inlineErrors: inlineErrors,
17702
+ index: repeat
17703
+ });
17704
+ }
17705
+ return errors;
17706
+ }, {});
17707
+ if (triggerErrors) {
17708
+ setFormElementError({
17709
+ formRef: formRef,
17710
+ errorType: errorType,
17711
+ inlineErrors: inlineErrors,
17712
+ setInlineErrors: setInlineErrors,
17713
+ triggerErrors: true
17714
+ });
17802
17715
  }
17803
- return newStepKey;
17716
+ return { errors: errors, inlineErrors: inlineErrors, invalid: invalid };
17804
17717
  }
17805
- var nextStepKey = function (nextConditions, metadata) {
17806
- var newKey = null;
17807
- nextConditions
17808
- .filter(function (cond) {
17809
- return cond.element_type === metadata.elementType &&
17810
- metadata.elementIDs.includes(cond.element_id) &&
17811
- cond.metadata.start === metadata.start &&
17812
- cond.metadata.end === metadata.end;
17813
- })
17814
- .sort(function (cond1, cond2) {
17815
- return cond1.rules.length < cond2.rules.length ? 1 : -1;
17816
- })
17817
- .forEach(function (cond) {
17818
- if (newKey)
17819
- return;
17820
- var rulesMet = true;
17821
- cond.rules.forEach(function (rule) {
17822
- rulesMet && (rulesMet = evalComparisonRule(rule));
17823
- });
17824
- if (rulesMet)
17825
- newKey = cond.next_step_key;
17826
- });
17827
- return newKey;
17828
- };
17829
- // No origin is possible if there are no steps, e.g. form is disabled
17830
- var NO_ORIGIN_DEFAULT = { key: '' };
17831
- var getOrigin = function (steps) {
17832
- var _a;
17833
- return (_a = Object.values(steps).find(function (step) { return step.origin; })) !== null && _a !== void 0 ? _a : NO_ORIGIN_DEFAULT;
17834
- };
17835
17718
  /**
17836
- *
17837
- * @returns Url hash without the #, or '' if decodeURI fails
17719
+ * Performs all default/standard and custom validations on a field/element
17720
+ * and returns any validation message.
17838
17721
  */
17839
- function getUrlHash() {
17840
- try {
17841
- return decodeURI(location.hash.substr(1));
17842
- }
17843
- catch (e) {
17844
- console.warn(e);
17845
- return '';
17846
- }
17847
- }
17848
- function setUrlStepHash(navigate, steps, stepName) {
17849
- // No hash necessary if form only has one step
17850
- if (Object.keys(steps).length > 1) {
17851
- navigate(location.pathname + location.search + "#".concat(stepName), {
17852
- replace: true
17722
+ function validateElement(element, repeat) {
17723
+ var servar = element.servar, validations = element.validations;
17724
+ // First priority is custom validations for servar fields
17725
+ if (validations) {
17726
+ var firstMatchingValidation = validations.find(function (validation) {
17727
+ return validation.rules.every(function (rule) { return evalComparisonRule(rule, repeat); });
17853
17728
  });
17729
+ if (firstMatchingValidation)
17730
+ return firstMatchingValidation.message;
17854
17731
  }
17855
- }
17856
- function getInitialStep(_a) {
17857
- var initialStepId = _a.initialStepId, steps = _a.steps, sessionCurrentStep = _a.sessionCurrentStep, formId = _a.formId;
17858
- return ((formId && getSavedStepKey(formId)) || // saved step from remounting
17859
- initialStepId ||
17860
- sessionCurrentStep ||
17861
- getOrigin(steps).key);
17862
- }
17863
- // Store current step keys for each form during remount
17864
- var savedStepKeys = {};
17865
- function getSavedStepKey(formId) {
17866
- var savedKey = savedStepKeys[formId];
17867
- if (savedKey) {
17868
- delete savedStepKeys[formId];
17869
- return savedKey;
17732
+ // Now apply any standard validations
17733
+ if (servar) {
17734
+ var fieldVal = fieldValues[servar.key];
17735
+ if (servar.repeated)
17736
+ fieldVal = fieldVal[repeat];
17737
+ var errorMsg = getStandardFieldError(fieldVal, servar, repeat);
17738
+ if (errorMsg)
17739
+ return errorMsg;
17870
17740
  }
17871
- return undefined;
17872
- }
17873
- function setSavedStepKey(formId, stepKey) {
17874
- savedStepKeys[formId] = stepKey;
17741
+ return '';
17875
17742
  }
17876
- function isStepTerminal(step) {
17877
- // If step is navigable to another step, it's not terminal
17878
- if (step.next_conditions.length > 0)
17879
- return false;
17880
- if (step.servar_fields.some(function (field) { return field.servar.required; }) &&
17881
- step.buttons.some(function (b) { return b.properties.submit; })) {
17882
- // Not terminal if there is a required field on the step that can be saved
17883
- return false;
17884
- }
17885
- var onlyExits = ['buttons', 'texts', 'subgrids'].every(function (key) {
17886
- return step[key].every(function (b) {
17887
- var _a;
17888
- return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).every(function (action) { return action.type === ACTION_URL; });
17889
- });
17890
- });
17891
- if (onlyExits && step.servar_fields.length === 0)
17892
- return true;
17893
- var hasNext = step.buttons.some(function (b) {
17894
- var _a;
17895
- return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).some(function (action) {
17896
- return action.type === ACTION_NEXT ||
17897
- (action.type === ACTION_URL && !action.open_tab);
17898
- });
17743
+ //
17744
+ // Standard Validations
17745
+ //
17746
+ var emailPatternStr = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]{2,63})+$";
17747
+ var emailPattern = new RegExp(emailPatternStr);
17748
+ var phoneLib = null;
17749
+ var phoneLibPromise = Promise.resolve();
17750
+ var loadPhoneValidator = function () {
17751
+ phoneLibPromise = import(
17752
+ /* webpackChunkName: "libphonenumber" */ './fthry_index.FxHyaooV.js').then(function (mod) {
17753
+ phoneLib = mod;
17754
+ return mod;
17899
17755
  });
17900
- return !hasNext;
17901
- }
17902
- function _recurseQueue(depthMap, steps, hasProgressBar, queue, altQueue) {
17903
- var _loop_1 = function () {
17904
- var _a = __read(queue.shift(), 2), step = _a[0], depth = _a[1];
17905
- if (step.key in depthMap)
17906
- return "continue";
17907
- // Optionally filter only for steps with progress bar
17908
- var missingBar = hasProgressBar && step.progress_bars.length === 0;
17909
- depthMap[step.key] = missingBar ? 0 : depth;
17910
- var incr = missingBar ? 0 : 1;
17911
- step.next_conditions.forEach(function (condition) {
17912
- queue.push([steps[condition.next_step_key], depth + incr]);
17913
- });
17914
- // For calculating progress bar depth, deprioritize previous condition
17915
- // depths relative to next conditions
17916
- var previousQueue = hasProgressBar && altQueue ? altQueue : queue;
17917
- step.previous_conditions.forEach(function (condition) {
17918
- previousQueue.push([steps[condition.previous_step_key], depth + incr]);
17919
- });
17920
- };
17921
- while (queue.length > 0) {
17922
- _loop_1();
17923
- }
17924
- }
17925
- var getStepDepthMap = function (steps, hasProgressBar) {
17926
- if (hasProgressBar === void 0) { hasProgressBar = false; }
17927
- var depthMap = {};
17928
- var stepQueue = [[getOrigin(steps), 0]];
17929
- var reverseQueue = [];
17930
- _recurseQueue(depthMap, steps, hasProgressBar, stepQueue, reverseQueue);
17931
- if (hasProgressBar)
17932
- _recurseQueue(depthMap, steps, hasProgressBar, reverseQueue);
17933
- return depthMap;
17934
17756
  };
17935
- var recurseProgressDepth = function (steps, curKey) {
17936
- var depthMap = getStepDepthMap(steps, true);
17937
- return [depthMap[curKey], Math.max.apply(Math, __spreadArray([], __read(Object.values(depthMap)), false))];
17938
- };
17939
-
17757
+ var validators = {
17758
+ email: function (a) {
17759
+ if (!a)
17760
+ return false;
17761
+ var parts = a.split('@');
17762
+ if (parts.length !== 2)
17763
+ return false;
17764
+ // Email handle cannot end with '.'
17765
+ var part = parts[0];
17766
+ if (part.endsWith('.') || part.startsWith('.'))
17767
+ return false;
17768
+ if (part.includes('..'))
17769
+ return false;
17770
+ return emailPattern.test(a);
17771
+ },
17772
+ phone: function (a) {
17773
+ try {
17774
+ return phoneLib.isValidPhoneNumber("+".concat(a));
17775
+ }
17776
+ catch (e) {
17777
+ // Invalid phone number
17778
+ return false;
17779
+ }
17780
+ },
17781
+ url: function (a) {
17782
+ if (!isUrl(a))
17783
+ return false;
17784
+ try {
17785
+ var urlObj = new URL(a);
17786
+ if (!urlObj)
17787
+ return false;
17788
+ var hostname = urlObj.hostname;
17789
+ if (hostname.length >= 64)
17790
+ return false;
17791
+ if (!DOMAIN_ALLOWED_CHARACTERS.test(hostname))
17792
+ return false;
17793
+ var parts = hostname.split('.');
17794
+ if (parts.some(function (part) { return !part; }))
17795
+ return false;
17796
+ // Last part of domain cannot contain digit
17797
+ if (NUMBER_MATCH.test(parts[parts.length - 1]))
17798
+ return false;
17799
+ // Colon at end of hostname gets filtered out by URL object but
17800
+ // should be invalid
17801
+ if (a[urlObj.origin.length] === ':')
17802
+ return false;
17803
+ // Check for filtered out special characters, e.g.
17804
+ // https://@google.com -> https://google.com
17805
+ if (!a.toLowerCase().includes("/".concat(hostname.toLowerCase())))
17806
+ return false;
17807
+ return parts.length > 1;
17808
+ }
17809
+ catch (e) {
17810
+ return false;
17811
+ }
17812
+ }
17813
+ };
17814
+ function isFieldValueEmpty(value, servar) {
17815
+ var _a;
17816
+ if (ARRAY_FIELD_TYPES.includes(servar.type)) {
17817
+ if (!value || value.length === 0)
17818
+ return true;
17819
+ // For file uploads and button groups, check if array contains only null/falsy values
17820
+ if (['file_upload', 'button_group'].includes(servar.type)) {
17821
+ // In repeatable containers, file upload values are stored as individual Files (not arrays)
17822
+ // because changeValue extracts value[0] for each row. Handle both cases:
17823
+ if (!Array.isArray(value)) {
17824
+ return !value; // Single file or null (from repeatable container)
17825
+ }
17826
+ if (value.every(function (val) { return !val; })) {
17827
+ return true;
17828
+ }
17829
+ }
17830
+ // If 'other' is selected for checkbox group, make sure it has a value
17831
+ return servar.type === 'multiselect' && value.some(function (val) { return !val; });
17832
+ }
17833
+ var noVal;
17834
+ switch (servar.type) {
17835
+ case 'matrix':
17836
+ // Each key in value needs to have an array with at least one value
17837
+ noVal = servar.metadata.questions.some(function (_a) {
17838
+ var id = _a.id;
17839
+ return !value[id] || value[id].length === 0;
17840
+ });
17841
+ break;
17842
+ case 'select':
17843
+ case 'signature':
17844
+ noVal = !value;
17845
+ break;
17846
+ case 'checkbox':
17847
+ // eslint-disable-next-line camelcase
17848
+ noVal = !value && ((_a = servar.metadata) === null || _a === void 0 ? void 0 : _a.must_check);
17849
+ break;
17850
+ case 'payment_method':
17851
+ noVal = !(value === null || value === void 0 ? void 0 : value.complete);
17852
+ break;
17853
+ case 'rating':
17854
+ noVal = !value;
17855
+ break;
17856
+ default:
17857
+ if (typeof value === 'string')
17858
+ value = value.trim();
17859
+ noVal = ['', null, undefined].includes(value);
17860
+ break;
17861
+ }
17862
+ return noVal;
17863
+ }
17864
+ /**
17865
+ * Default validations.
17866
+ * Returns the error message for a field value if it's invalid.
17867
+ * Returns an empty string if it's valid.
17868
+ */
17869
+ function getStandardFieldError(value, servar, repeat) {
17870
+ var defaultErrors = initInfo().defaultErrors;
17871
+ if (isFieldValueEmpty(value, servar)) {
17872
+ // If no value, error if field is required
17873
+ return servar.required ? defaultErrors.required : '';
17874
+ }
17875
+ if (servar.min_length && value.length < servar.min_length) {
17876
+ return defaultErrors.minimum.replace('{length}', servar.min_length);
17877
+ }
17878
+ var defaultErr = defaultErrors[servar.type];
17879
+ // Check if value is badly formatted
17880
+ if (servar.type === 'phone_number' && !validators.phone(value)) {
17881
+ return defaultErr;
17882
+ }
17883
+ else if (servar.type === 'email' && !validators.email(value)) {
17884
+ return defaultErr;
17885
+ }
17886
+ else if (servar.type === 'url' && !validators.url(value)) {
17887
+ // Try appending https since user may have just omitted the protocol
17888
+ var newVal = 'https://' + value;
17889
+ if (validators.url(newVal)) {
17890
+ if (servar.repeated) {
17891
+ // @ts-ignore
17892
+ fieldValues[servar === null || servar === void 0 ? void 0 : servar.key][repeat] = newVal;
17893
+ }
17894
+ else
17895
+ fieldValues[servar.key] = newVal;
17896
+ return '';
17897
+ }
17898
+ return defaultErr;
17899
+ }
17900
+ else if (servar.type === 'ssn' &&
17901
+ value.length !== (servar.metadata.last_four_digits ? 4 : 9)) {
17902
+ return defaultErr;
17903
+ }
17904
+ else if (servar.type === 'pin_input' &&
17905
+ value.length !== servar.max_length) {
17906
+ return defaultErr;
17907
+ }
17908
+ else if (servar.type === 'password') {
17909
+ var meta = servar.metadata;
17910
+ var msg = function (key) { return "Your password must have at least 1 ".concat(key); };
17911
+ if (meta.letter_required && !LETTER_MATCH.test(value))
17912
+ return msg('letter');
17913
+ if (meta.uppercase_letter_required && !UPPERCASE_LETTER_MATCH.test(value))
17914
+ return msg('uppercase letter');
17915
+ if (meta.lowercase_letter_required && !LOWERCASE_LETTER_MATCH.test(value))
17916
+ return msg('lowercase letter');
17917
+ if (meta.number_required && !NUMBER_MATCH.test(value))
17918
+ return msg('number');
17919
+ if (meta.symbol_required && !SYMBOL_MATCH.test(value))
17920
+ return msg('symbol');
17921
+ }
17922
+ // No error
17923
+ return '';
17924
+ }
17925
+
17926
+ var plaidPromise = null;
17927
+ function installPlaid(isPlaidActive) {
17928
+ if (plaidPromise)
17929
+ return plaidPromise;
17930
+ else if (!isPlaidActive)
17931
+ return Promise.resolve();
17932
+ else {
17933
+ plaidPromise = dynamicImport('https://cdn.plaid.com/link/v2/stable/link-initialize.js');
17934
+ return plaidPromise;
17935
+ }
17936
+ }
17937
+ function openPlaidLink(client, onSuccess, onExit, updateFieldValues, action, handleError) {
17938
+ return __awaiter$2(this, void 0, void 0, function () {
17939
+ var kwargs, res, handler;
17940
+ var _this = this;
17941
+ return __generator(this, function (_a) {
17942
+ switch (_a.label) {
17943
+ case 0: return [4 /*yield*/, plaidPromise];
17944
+ case 1:
17945
+ _a.sent();
17946
+ if (action.plaid_action === 'identity') {
17947
+ kwargs = {
17948
+ identity_template_id: action.template_id,
17949
+ email_field: action.email_field
17950
+ };
17951
+ }
17952
+ else {
17953
+ kwargs = { liabilities: action.include_liabilities ? 'true' : 'false' };
17954
+ }
17955
+ return [4 /*yield*/, client.fetchPlaidLinkToken(kwargs)];
17956
+ case 2:
17957
+ res = _a.sent();
17958
+ if (res.err) {
17959
+ handleError(res.err);
17960
+ return [2 /*return*/];
17961
+ }
17962
+ handler = global.Plaid.create({
17963
+ token: res.token,
17964
+ onExit: onExit,
17965
+ onSuccess: function (publicToken, metadata) { return __awaiter$2(_this, void 0, void 0, function () {
17966
+ var res_1, statusKey, newValues, res_2, fieldVals;
17967
+ var _a;
17968
+ var _b;
17969
+ return __generator(this, function (_c) {
17970
+ switch (_c.label) {
17971
+ case 0:
17972
+ _c.trys.push([0, 8, 9, 10]);
17973
+ if (!(action.plaid_action === 'identity')) return [3 /*break*/, 4];
17974
+ return [4 /*yield*/, client.fetchPlaidVerificationStatus(metadata.link_session_id)];
17975
+ case 1:
17976
+ res_1 = _c.sent();
17977
+ statusKey = action.plaid_identity_field_key;
17978
+ if (statusKey) {
17979
+ newValues = (_a = {}, _a[statusKey] = res_1.status, _a);
17980
+ updateFieldValues(newValues);
17981
+ client.submitCustom(newValues, { shouldFlush: true });
17982
+ }
17983
+ if (!(res_1.status !== 'success')) return [3 /*break*/, 3];
17984
+ handleError('Identity verification was not successful');
17985
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
17986
+ case 2:
17987
+ _c.sent();
17988
+ return [2 /*return*/];
17989
+ case 3: return [3 /*break*/, 6];
17990
+ case 4:
17991
+ if (!publicToken) return [3 /*break*/, 6];
17992
+ res_2 = client.submitPlaidUserData(publicToken);
17993
+ if (!((_b = action.wait_for_completion) !== null && _b !== void 0 ? _b : true)) return [3 /*break*/, 6];
17994
+ return [4 /*yield*/, res_2];
17995
+ case 5:
17996
+ fieldVals = _c.sent();
17997
+ updateFieldValues(fieldVals);
17998
+ _c.label = 6;
17999
+ case 6: return [4 /*yield*/, onSuccess()];
18000
+ case 7:
18001
+ _c.sent();
18002
+ return [3 /*break*/, 10];
18003
+ case 8:
18004
+ _c.sent();
18005
+ handleError();
18006
+ return [3 /*break*/, 10];
18007
+ case 9:
18008
+ handler.exit();
18009
+ handler.destroy();
18010
+ return [7 /*endfinally*/];
18011
+ case 10: return [2 /*return*/];
18012
+ }
18013
+ });
18014
+ }); }
18015
+ });
18016
+ handler.open();
18017
+ return [2 /*return*/];
18018
+ }
18019
+ });
18020
+ });
18021
+ }
18022
+
18023
+ var RouterContext = createContext({
18024
+ location: {
18025
+ pathname: ''
18026
+ },
18027
+ navigate: function () { }
18028
+ });
18029
+ function RouterProvider(_a) {
18030
+ var children = _a.children, _b = _a.initialPath, initialPath = _b === void 0 ? featheryWindow().location.pathname : _b;
18031
+ var _c = __read(useState({ pathname: initialPath }), 2), location = _c[0], setLocation = _c[1];
18032
+ var navigate = useCallback(function (to, options) {
18033
+ if (options === void 0) { options = {}; }
18034
+ var historyMethod = options.replace ? 'replaceState' : 'pushState';
18035
+ featheryWindow().history[historyMethod](null, '', to);
18036
+ setLocation({ pathname: to });
18037
+ }, []);
18038
+ // listen to browser back/forward navigation
18039
+ useEffect(function () {
18040
+ var window = featheryWindow();
18041
+ var handlePopState = function () {
18042
+ setLocation({ pathname: window.location.pathname });
18043
+ };
18044
+ window.addEventListener('popstate', handlePopState);
18045
+ return function () { return window.removeEventListener('popstate', handlePopState); };
18046
+ }, []);
18047
+ var routerData = useMemo(function () { return ({
18048
+ location: location,
18049
+ navigate: navigate
18050
+ }); }, [location, navigate]);
18051
+ return (jsx$1(RouterContext.Provider, __assign({ value: routerData }, { children: children })));
18052
+ }
18053
+ function useLocation() {
18054
+ var context = useContext(RouterContext);
18055
+ if (!context)
18056
+ throw new Error('useLocation must be used within RouterProvider');
18057
+ return context.location;
18058
+ }
18059
+ function useNavigate() {
18060
+ var context = useContext(RouterContext);
18061
+ if (!context)
18062
+ throw new Error('useNavigate must be used within RouterProvider');
18063
+ return context.navigate;
18064
+ }
18065
+
18066
+ var MIN_AXIS_SIZE = 15;
18067
+ var FIT = 'fit';
18068
+ var FILL = 'fill';
18069
+ var isFill = function (v) { return v === FILL; };
18070
+ var isFit = function (v) { return v === FIT; };
18071
+ var isPx = function (v) {
18072
+ return typeof v === 'string' && v.indexOf('px') >= 0 && v.indexOf('calc') < 0;
18073
+ };
18074
+ var getPxValue = function (size) {
18075
+ return isPx(size) ? Number.parseFloat(size) : MIN_AXIS_SIZE;
18076
+ };
18077
+ var formatDimensionValue = function (value, type) {
18078
+ // fit-content is needed to allow elements to push beyond the parent container's explicit height.
18079
+ switch (value) {
18080
+ case FILL:
18081
+ return type === 'width' ? '100%' : 'auto';
18082
+ case FIT:
18083
+ return 'fit-content';
18084
+ default:
18085
+ return parseInt(value);
18086
+ }
18087
+ };
18088
+ var calculateDimensionsHelper = function (root, p) {
18089
+ if (p === void 0) { p = ''; }
18090
+ var width = root["".concat(p, "width")] || root.width;
18091
+ var height = root["".concat(p, "height")] || root.height;
18092
+ var dimensions = {
18093
+ maxWidth: formatDimensionValue(width, 'width'),
18094
+ height: formatDimensionValue(height, 'height')
18095
+ };
18096
+ // to allow responsiveness, min width shouldn't be set for fixed widths
18097
+ dimensions.minWidth = isNum(width) ? undefined : dimensions.maxWidth;
18098
+ // min and max height must be 100% to prevent fit-content from collapsing, which would break fill's non-collapsing intent
18099
+ dimensions.minHeight = isFill(height) ? '100%' : dimensions.height;
18100
+ return dimensions;
18101
+ };
18102
+ /**
18103
+ * Calculates the dimensions of the provided step.
18104
+ * Note: The provided step should be fully-hydrated (i.e. rows injected, etc.) to calculate dimensions accurately.
18105
+ */
18106
+ function calculateStepCSS(step) {
18107
+ if (!step)
18108
+ return {};
18109
+ var root = step.subgrids.find(function (grid) { return grid.position.length === 0; });
18110
+ var desktop = calculateDimensionsHelper(root);
18111
+ var mobile = calculateDimensionsHelper(root, 'mobile_');
18112
+ var stepCSS = __assign({ backgroundSize: 'cover', width: '100%' }, desktop);
18113
+ // width will be controlled by maxWidth in the case it is fixed below 478px
18114
+ stepCSS["@media (max-width: 478px)"] = __assign({ width: '100%' }, mobile);
18115
+ return stepCSS;
18116
+ }
18117
+ function calculateGlobalCSS(globalStyles) {
18118
+ var styles = new ResponsiveStyles({ styles: globalStyles }, ['form'], false, DEFAULT_MOBILE_BREAKPOINT);
18119
+ if (globalStyles) {
18120
+ styles.applyFontStyles('form');
18121
+ }
18122
+ return styles;
18123
+ }
18124
+
18125
+ function changeStep(newKey, oldKey, steps, setStepKey, navigate, client, trackHashes) {
18126
+ var sameKey = oldKey === newKey;
18127
+ if (!sameKey && newKey) {
18128
+ if (newKey in steps) {
18129
+ client.registerEvent({
18130
+ step_key: oldKey,
18131
+ next_step_key: newKey,
18132
+ event: 'complete'
18133
+ });
18134
+ if (trackHashes)
18135
+ navigate(location.pathname + location.search + "#".concat(newKey), {
18136
+ replace: true
18137
+ });
18138
+ setStepKey(newKey);
18139
+ return true;
18140
+ }
18141
+ else
18142
+ console.warn("".concat(newKey, " is not a valid step to navigate to"));
18143
+ }
18144
+ return false;
18145
+ }
18146
+ function getNewStepUrl(stepKey) {
18147
+ return location.pathname + location.search + "#".concat(stepKey);
18148
+ }
18149
+ function getPrevStepKey(curStep, stepMap) {
18150
+ var newStepKey = stepMap[curStep.key];
18151
+ if (!newStepKey) {
18152
+ var prevCondition = curStep.previous_conditions[0];
18153
+ if (prevCondition)
18154
+ newStepKey = prevCondition.previous_step_key;
18155
+ }
18156
+ return newStepKey;
18157
+ }
18158
+ var nextStepKey = function (nextConditions, metadata) {
18159
+ var newKey = null;
18160
+ nextConditions
18161
+ .filter(function (cond) {
18162
+ return cond.element_type === metadata.elementType &&
18163
+ metadata.elementIDs.includes(cond.element_id) &&
18164
+ cond.metadata.start === metadata.start &&
18165
+ cond.metadata.end === metadata.end;
18166
+ })
18167
+ .sort(function (cond1, cond2) {
18168
+ return cond1.rules.length < cond2.rules.length ? 1 : -1;
18169
+ })
18170
+ .forEach(function (cond) {
18171
+ if (newKey)
18172
+ return;
18173
+ var rulesMet = true;
18174
+ cond.rules.forEach(function (rule) {
18175
+ rulesMet && (rulesMet = evalComparisonRule(rule));
18176
+ });
18177
+ if (rulesMet)
18178
+ newKey = cond.next_step_key;
18179
+ });
18180
+ return newKey;
18181
+ };
18182
+ // No origin is possible if there are no steps, e.g. form is disabled
18183
+ var NO_ORIGIN_DEFAULT = { key: '' };
18184
+ var getOrigin = function (steps) {
18185
+ var _a;
18186
+ return (_a = Object.values(steps).find(function (step) { return step.origin; })) !== null && _a !== void 0 ? _a : NO_ORIGIN_DEFAULT;
18187
+ };
18188
+ /**
18189
+ *
18190
+ * @returns Url hash without the #, or '' if decodeURI fails
18191
+ */
18192
+ function getUrlHash() {
18193
+ try {
18194
+ return decodeURI(location.hash.substr(1));
18195
+ }
18196
+ catch (e) {
18197
+ console.warn(e);
18198
+ return '';
18199
+ }
18200
+ }
18201
+ function setUrlStepHash(navigate, steps, stepName) {
18202
+ // No hash necessary if form only has one step
18203
+ if (Object.keys(steps).length > 1) {
18204
+ navigate(location.pathname + location.search + "#".concat(stepName), {
18205
+ replace: true
18206
+ });
18207
+ }
18208
+ }
18209
+ function getInitialStep(_a) {
18210
+ var initialStepId = _a.initialStepId, steps = _a.steps, sessionCurrentStep = _a.sessionCurrentStep, formId = _a.formId;
18211
+ return ((formId && getSavedStepKey(formId)) || // saved step from remounting
18212
+ initialStepId ||
18213
+ sessionCurrentStep ||
18214
+ getOrigin(steps).key);
18215
+ }
18216
+ // Store current step keys for each form during remount
18217
+ var savedStepKeys = {};
18218
+ function getSavedStepKey(formId) {
18219
+ var savedKey = savedStepKeys[formId];
18220
+ if (savedKey) {
18221
+ delete savedStepKeys[formId];
18222
+ return savedKey;
18223
+ }
18224
+ return undefined;
18225
+ }
18226
+ function setSavedStepKey(formId, stepKey) {
18227
+ savedStepKeys[formId] = stepKey;
18228
+ }
18229
+ function isStepTerminal(step) {
18230
+ // If step is navigable to another step, it's not terminal
18231
+ if (step.next_conditions.length > 0)
18232
+ return false;
18233
+ if (step.servar_fields.some(function (field) { return field.servar.required; }) &&
18234
+ step.buttons.some(function (b) { return b.properties.submit; })) {
18235
+ // Not terminal if there is a required field on the step that can be saved
18236
+ return false;
18237
+ }
18238
+ var onlyExits = ['buttons', 'texts', 'subgrids'].every(function (key) {
18239
+ return step[key].every(function (b) {
18240
+ var _a;
18241
+ return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).every(function (action) { return action.type === ACTION_URL; });
18242
+ });
18243
+ });
18244
+ if (onlyExits && step.servar_fields.length === 0)
18245
+ return true;
18246
+ var hasNext = step.buttons.some(function (b) {
18247
+ var _a;
18248
+ return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).some(function (action) {
18249
+ return action.type === ACTION_NEXT ||
18250
+ (action.type === ACTION_URL && !action.open_tab);
18251
+ });
18252
+ });
18253
+ return !hasNext;
18254
+ }
18255
+ function _recurseQueue(depthMap, steps, hasProgressBar, queue, altQueue) {
18256
+ var _loop_1 = function () {
18257
+ var _a = __read(queue.shift(), 2), step = _a[0], depth = _a[1];
18258
+ if (step.key in depthMap)
18259
+ return "continue";
18260
+ // Optionally filter only for steps with progress bar
18261
+ var missingBar = hasProgressBar && step.progress_bars.length === 0;
18262
+ depthMap[step.key] = missingBar ? 0 : depth;
18263
+ var incr = missingBar ? 0 : 1;
18264
+ step.next_conditions.forEach(function (condition) {
18265
+ queue.push([steps[condition.next_step_key], depth + incr]);
18266
+ });
18267
+ // For calculating progress bar depth, deprioritize previous condition
18268
+ // depths relative to next conditions
18269
+ var previousQueue = hasProgressBar && altQueue ? altQueue : queue;
18270
+ step.previous_conditions.forEach(function (condition) {
18271
+ previousQueue.push([steps[condition.previous_step_key], depth + incr]);
18272
+ });
18273
+ };
18274
+ while (queue.length > 0) {
18275
+ _loop_1();
18276
+ }
18277
+ }
18278
+ var getStepDepthMap = function (steps, hasProgressBar) {
18279
+ if (hasProgressBar === void 0) { hasProgressBar = false; }
18280
+ var depthMap = {};
18281
+ var stepQueue = [[getOrigin(steps), 0]];
18282
+ var reverseQueue = [];
18283
+ _recurseQueue(depthMap, steps, hasProgressBar, stepQueue, reverseQueue);
18284
+ if (hasProgressBar)
18285
+ _recurseQueue(depthMap, steps, hasProgressBar, reverseQueue);
18286
+ return depthMap;
18287
+ };
18288
+ var recurseProgressDepth = function (steps, curKey) {
18289
+ var depthMap = getStepDepthMap(steps, true);
18290
+ return [depthMap[curKey], Math.max.apply(Math, __spreadArray([], __read(Object.values(depthMap)), false))];
18291
+ };
18292
+
17940
18293
  var pure$1 = {};
17941
18294
 
17942
18295
  var hasRequiredPure$1;
@@ -28604,12 +28957,21 @@ function hasAuthGatedSteps(integrations) {
28604
28957
  function getRedirectUrl() {
28605
28958
  var _a = featheryWindow().location, origin = _a.origin, pathname = _a.pathname, hash = _a.hash, search = _a.search;
28606
28959
  var queryParams = new URLSearchParams(search);
28960
+ // If no _slug param, extract slug from /to/<slug> path
28961
+ if (!queryParams.has('_slug')) {
28962
+ var toMatch = pathname.match(/\/to\/([^/]+)/);
28963
+ if (toMatch) {
28964
+ queryParams.set('_slug', toMatch[1]);
28965
+ }
28966
+ }
28607
28967
  queryParams.forEach(function (value, key) {
28608
28968
  if (!['_slug'].includes(key))
28609
28969
  queryParams.delete(key);
28610
28970
  });
28971
+ // Strip the /to/<slug> segment
28972
+ var cleanPathname = pathname.replace(/\/to\/[^/]+/, '');
28611
28973
  var queryString = queryParams.has('_slug') ? "?".concat(queryParams) : '';
28612
- return "".concat(origin).concat(pathname).concat(queryString).concat(hash);
28974
+ return "".concat(origin).concat(cleanPathname).concat(queryString).concat(hash);
28613
28975
  }
28614
28976
 
28615
28977
  var stytchPromise = null;
@@ -39075,7 +39437,7 @@ function useTrackUserInteraction(formRef, activeStep, stepKey, formName) {
39075
39437
  }, [activeStep, stepKey, formName]);
39076
39438
  }
39077
39439
 
39078
- var AssistantChat = lazy(function () { return import(/* webpackChunkName: "AssistantChat" */ './fthry_index.DpJv-8TU.js'); });
39440
+ var AssistantChat = lazy(function () { return import(/* webpackChunkName: "AssistantChat" */ './fthry_index.Dte366nP.js'); });
39079
39441
  var getSubmissionErrorMessage = function (error) {
39080
39442
  if (error instanceof TypeError && error.message === 'Failed to fetch') {
39081
39443
  return 'Unable to upload files. Please check your connection and try again.';
@@ -43673,944 +44035,595 @@ function requireGa4 () {
43673
44035
  Object.keys(rest).filter(function (key) {
43674
44036
  return key.substr(0, "dimension".length) === "dimension";
43675
44037
  }).forEach(function (key) {
43676
- fieldObject[key] = rest[key];
43677
- });
43678
- Object.keys(rest).filter(function (key) {
43679
- return key.substr(0, "metric".length) === "metric";
43680
- }).forEach(function (key) {
43681
- fieldObject[key] = rest[key];
43682
- });
43683
-
43684
- _this._gaCommand("send", fieldObject);
43685
- }
43686
- });
43687
-
43688
- _defineProperty(this, "send", function (fieldObject) {
43689
- _this._gaCommand("send", fieldObject);
43690
- });
43691
-
43692
- _defineProperty(this, "pageview", function (path, _, title) {
43693
- var pathTrim = path === null || path === void 0 ? void 0 : path.trim();
43694
-
43695
- if (pathTrim === "") {
43696
- console.warn("path cannot be an empty string in .pageview()");
43697
- return;
43698
- }
43699
-
43700
- _this._gaCommand("send", "pageview", pathTrim, {
43701
- title: title
43702
- });
43703
- });
43704
-
43705
- this.reset();
43706
- }
43707
-
43708
- _createClass(GA4, [{
43709
- key: "gtag",
43710
- value: function gtag() {
43711
- this._gtag.apply(this, arguments);
43712
- }
43713
- }, {
43714
- key: "_appendCustomMap",
43715
- value: function _appendCustomMap(options) {
43716
- var legacyDimensionMetric = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
43717
-
43718
- if (!legacyDimensionMetric) {
43719
- return options;
43720
- }
43721
-
43722
- if (!options.custom_map) {
43723
- options.custom_map = {};
43724
- }
43725
-
43726
- for (var i = 1; i <= 200; i++) {
43727
- if (!options.custom_map["dimension".concat(i)]) {
43728
- options.custom_map["dimension".concat(i)] = "dimension".concat(i);
43729
- }
43730
-
43731
- if (!options.custom_map["metric".concat(i)]) {
43732
- options.custom_map["metric".concat(i)] = "metric".concat(i);
43733
- }
43734
- }
43735
-
43736
- return options;
43737
- }
43738
- /**
43739
- * @since v1.0.2
43740
- * @param {string} [path="location.href"]
43741
- * @param {string[]} [_] unsupported
43742
- * @param {string} [title="location.pathname"]
43743
- * @deprecated Use `.send("pageview")` instead
43744
- */
43745
-
43746
- }, {
43747
- key: "outboundLink",
43748
- value:
43749
- /**
43750
- * @since v1.0.6
43751
- * @param {Object} options
43752
- * @param {string} options.label
43753
- * @param {function} hitCallback
43754
- * @deprecated Use `enhanced measurement` feature in Google Analytics.
43755
- */
43756
- function outboundLink(_ref3, hitCallback) {
43757
- var label = _ref3.label;
43758
-
43759
- if (typeof hitCallback !== "function") {
43760
- console.warn("hitCallback function is required");
43761
- return;
43762
- }
43763
-
43764
- if (!label) {
43765
- console.warn("args.label is required in outboundLink()");
43766
- return;
43767
- } // Required Fields
43768
-
43769
-
43770
- var fieldObject = {
43771
- hitType: "event",
43772
- eventCategory: "Outbound",
43773
- eventAction: "Click",
43774
- eventLabel: (0, _format["default"])(label)
43775
- };
43776
- var safetyCallbackCalled = false;
43777
-
43778
- var safetyCallback = function safetyCallback() {
43779
- // This prevents a delayed response from GA
43780
- // causing hitCallback from being fired twice
43781
- safetyCallbackCalled = true;
43782
- hitCallback();
43783
- }; // Using a timeout to ensure the execution of critical application code
43784
- // in the case when the GA server might be down
43785
- // or an ad blocker prevents sending the data
43786
- // register safety net timeout:
43787
-
43788
-
43789
- var t = setTimeout(safetyCallback, 250);
43790
-
43791
- var clearableCallbackForGA = function clearableCallbackForGA() {
43792
- clearTimeout(t);
43793
-
43794
- if (!safetyCallbackCalled) {
43795
- hitCallback();
43796
- }
43797
- };
43798
-
43799
- fieldObject.hitCallback = clearableCallbackForGA;
43800
-
43801
- this._gaCommand("send", fieldObject);
43802
- }
43803
- }]);
43804
-
43805
- return GA4;
43806
- }();
43807
-
43808
- exports$1.GA4 = GA4;
43809
-
43810
- var _default = new GA4();
43811
-
43812
- exports$1["default"] = _default;
43813
- } (ga4));
43814
- return ga4;
43815
- }
43816
-
43817
- var hasRequiredDist;
43818
-
43819
- function requireDist () {
43820
- if (hasRequiredDist) return dist;
43821
- hasRequiredDist = 1;
43822
- (function (exports$1) {
43823
-
43824
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
43825
-
43826
- Object.defineProperty(exports$1, "__esModule", {
43827
- value: true
43828
- });
43829
- exports$1["default"] = exports$1.ReactGAImplementation = void 0;
43830
-
43831
- var _ga = _interopRequireWildcard(requireGa4());
44038
+ fieldObject[key] = rest[key];
44039
+ });
44040
+ Object.keys(rest).filter(function (key) {
44041
+ return key.substr(0, "metric".length) === "metric";
44042
+ }).forEach(function (key) {
44043
+ fieldObject[key] = rest[key];
44044
+ });
43832
44045
 
43833
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
44046
+ _this._gaCommand("send", fieldObject);
44047
+ }
44048
+ });
43834
44049
 
43835
- function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44050
+ _defineProperty(this, "send", function (fieldObject) {
44051
+ _this._gaCommand("send", fieldObject);
44052
+ });
43836
44053
 
43837
- var ReactGAImplementation = _ga.GA4;
43838
- exports$1.ReactGAImplementation = ReactGAImplementation;
43839
- var _default = _ga["default"];
43840
- exports$1["default"] = _default;
43841
- } (dist));
43842
- return dist;
43843
- }
44054
+ _defineProperty(this, "pageview", function (path, _, title) {
44055
+ var pathTrim = path === null || path === void 0 ? void 0 : path.trim();
43844
44056
 
43845
- var distExports = requireDist();
43846
- var ReactGA = /*@__PURE__*/getDefaultExportFromCjs(distExports);
44057
+ if (pathTrim === "") {
44058
+ console.warn("path cannot be an empty string in .pageview()");
44059
+ return;
44060
+ }
43847
44061
 
43848
- var gaInstalled = false;
43849
- function installGoogleAnalytics(gaConfig) {
43850
- if (gaConfig && !gaInstalled) {
43851
- gaInstalled = true;
43852
- ReactGA.initialize(gaConfig.metadata.api_key);
43853
- }
43854
- return Promise.resolve();
43855
- }
43856
- function trackGAEvent(category, action, label) {
43857
- ReactGA.event({ category: category, action: action, label: label });
43858
- }
44062
+ _this._gaCommand("send", "pageview", pathTrim, {
44063
+ title: title
44064
+ });
44065
+ });
43859
44066
 
43860
- var heapInstalled = false;
43861
- function installHeap(heapConfig) {
43862
- if (heapConfig && !heapInstalled) {
43863
- heapInstalled = true;
43864
- featheryWindow().heap = featheryWindow().heap || [];
43865
- featheryWindow().heap.load = function (e) {
43866
- featheryWindow().heap.appid = e;
43867
- featheryWindow().heap.config = {};
43868
- var r = featheryDoc().createElement('script');
43869
- r.type = 'text/javascript';
43870
- r.async = true;
43871
- r.src = 'https://cdn.heapanalytics.com/js/heap-' + e + '.js';
43872
- var a = featheryDoc().getElementsByTagName('script')[0];
43873
- a.parentNode.insertBefore(r, a);
43874
- for (var n = function (e) {
43875
- return function () {
43876
- featheryWindow().heap.push(
43877
- // eslint-disable-next-line prefer-rest-params
43878
- [e].concat(Array.prototype.slice.call(arguments, 0)));
43879
- };
43880
- }, p = [
43881
- 'addEventProperties',
43882
- 'addUserProperties',
43883
- 'clearEventProperties',
43884
- 'identify',
43885
- 'resetIdentity',
43886
- 'removeEventProperty',
43887
- 'setEventProperties',
43888
- 'track',
43889
- 'unsetEventProperty'
43890
- ], o = 0; o < p.length; o++)
43891
- featheryWindow().heap[p[o]] = n(p[o]);
43892
- };
43893
- featheryWindow().heap.load(heapConfig.metadata.api_key);
43894
- }
43895
- return Promise.resolve();
43896
- }
44067
+ this.reset();
44068
+ }
43897
44069
 
43898
- var intercomInstalled = false;
43899
- function installIntercom(intercomConfig) {
43900
- if (intercomConfig && !intercomInstalled) {
43901
- intercomInstalled = true;
43902
- var workspaceId_1 = intercomConfig.api_key;
43903
- featheryWindow().intercomSettings = {
43904
- api_base: 'https://api-iam.intercom.io',
43905
- app_id: workspaceId_1
43906
- };
43907
- var w = featheryWindow();
43908
- var ic = w.Intercom;
43909
- if (typeof ic === 'function') {
43910
- ic('reattach_activator');
43911
- ic('update', w.intercomSettings);
43912
- }
43913
- else {
43914
- var d_1 = featheryDoc();
43915
- var i_1 = function () {
43916
- // eslint-disable-next-line prefer-rest-params
43917
- i_1.c(arguments);
43918
- };
43919
- i_1.q = [];
43920
- i_1.c = function (args) {
43921
- i_1.q.push(args);
43922
- };
43923
- w.Intercom = i_1;
43924
- var l = function () {
43925
- var s = d_1.createElement('script');
43926
- s.type = 'text/javascript';
43927
- s.async = true;
43928
- s.src = "https://widget.intercom.io/widget/".concat(workspaceId_1);
43929
- var x = d_1.getElementsByTagName('script')[0];
43930
- x.parentNode.insertBefore(s, x);
43931
- };
43932
- if (featheryDoc().readyState === 'complete') {
43933
- l();
43934
- }
43935
- else if (w.attachEvent) {
43936
- w.attachEvent('onload', l);
43937
- }
43938
- else {
43939
- w.addEventListener('load', l, false);
43940
- }
43941
- }
43942
- }
43943
- return Promise.resolve();
43944
- }
44070
+ _createClass(GA4, [{
44071
+ key: "gtag",
44072
+ value: function gtag() {
44073
+ this._gtag.apply(this, arguments);
44074
+ }
44075
+ }, {
44076
+ key: "_appendCustomMap",
44077
+ value: function _appendCustomMap(options) {
44078
+ var legacyDimensionMetric = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
43945
44079
 
43946
- var amplitudeInstalled = false;
43947
- function installAmplitude(amplitudeConfig) {
43948
- return __awaiter$2(this, void 0, void 0, function () {
43949
- var meta, apiKey, cdn, sessionReplayTracking, options;
43950
- return __generator(this, function (_a) {
43951
- switch (_a.label) {
43952
- case 0:
43953
- if (!amplitudeConfig || amplitudeInstalled)
43954
- return [2 /*return*/];
43955
- amplitudeInstalled = true;
43956
- meta = amplitudeConfig.metadata;
43957
- apiKey = meta.api_key;
43958
- cdn = 'cdn';
43959
- if (meta.eu_server)
43960
- cdn = 'cdn.eu';
43961
- return [4 /*yield*/, dynamicImport("https://".concat(cdn, ".amplitude.com/script/").concat(apiKey, ".js"))];
43962
- case 1:
43963
- _a.sent();
43964
- if (!featheryWindow().amplitude) {
43965
- console.warn('Failed to load Amplitude.');
43966
- return [2 /*return*/];
43967
- }
43968
- if (meta.session_replay && featheryWindow().sessionReplay) {
43969
- sessionReplayTracking = featheryWindow().sessionReplay.plugin();
43970
- featheryWindow().amplitude.add(sessionReplayTracking);
43971
- }
43972
- options = {
43973
- fetchRemoteConfig: true,
43974
- autocapture: true
43975
- };
43976
- if (meta.eu_server)
43977
- options.serverZone = 'EU';
43978
- featheryWindow().amplitude.init(apiKey, options);
43979
- if (meta.identify_user)
43980
- featheryWindow().amplitude.setUserId(initInfo().userId);
43981
- return [2 /*return*/];
43982
- }
43983
- });
43984
- });
43985
- }
44080
+ if (!legacyDimensionMetric) {
44081
+ return options;
44082
+ }
43986
44083
 
43987
- var mixpanelInstalled = false;
43988
- function installMixpanel(mixpanelConfig) {
43989
- if (mixpanelConfig && !mixpanelInstalled && !featheryWindow().mixpanel) {
43990
- mixpanelInstalled = true;
43991
- (function (f, b) {
43992
- if (!b.__SV) {
43993
- var i_1, h_1;
43994
- featheryWindow().mixpanel = b;
43995
- b._i = [];
43996
- b.init = function (e, f, c) {
43997
- function g(a, d) {
43998
- var b = d.split('.');
43999
- // eslint-disable-next-line eqeqeq,no-unused-expressions
44000
- b.length == 2 && ((a = a[b[0]]), (d = b[1]));
44001
- a[d] = function () {
44002
- // eslint-disable-next-line prefer-rest-params
44003
- a.push([d].concat(Array.prototype.slice.call(arguments, 0)));
44004
- };
44005
- }
44006
- var a = b;
44007
- typeof c !== 'undefined' ? (a = b[c] = []) : (c = 'mixpanel');
44008
- a.people = a.people || [];
44009
- a.toString = function (a) {
44010
- var d = 'mixpanel';
44011
- c !== 'mixpanel' && (d += '.' + c);
44012
- a || (d += ' (stub)');
44013
- return d;
44014
- };
44015
- a.people.toString = function () {
44016
- return a.toString(1) + '.people (stub)';
44017
- };
44018
- i_1 =
44019
- 'disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove'.split(' ');
44020
- for (h_1 = 0; h_1 < i_1.length; h_1++)
44021
- g(a, i_1[h_1]);
44022
- var j = 'set set_once union unset remove delete'.split(' ');
44023
- a.get_group = function () {
44024
- function b(c) {
44025
- d[c] = function () {
44026
- var call2 = [c].concat(
44027
- // eslint-disable-next-line prefer-rest-params
44028
- Array.prototype.slice.call(arguments, 0));
44029
- a.push([e, call2]);
44030
- };
44031
- }
44032
- var d;
44033
- for (d = {},
44034
- e = ['get_group'].concat(
44035
- // eslint-disable-next-line prefer-rest-params
44036
- Array.prototype.slice.call(arguments, 0)),
44037
- c = 0; c < j.length; c++)
44038
- b(j[c]);
44039
- return d;
44040
- };
44041
- b._i.push([e, f, c]);
44042
- };
44043
- b.__SV = 1.2;
44044
- var e = f.createElement('script');
44045
- e.type = 'text/javascript';
44046
- e.async = true;
44047
- e.src =
44048
- f.location.protocol === 'file:' &&
44049
- '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'.match(/^\/\//)
44050
- ? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
44051
- : '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
44052
- var g = f.getElementsByTagName('script')[0];
44053
- g.parentNode.insertBefore(e, g);
44054
- }
44055
- })(featheryDoc(), featheryWindow().mixpanel || []);
44056
- featheryWindow().mixpanel.init(mixpanelConfig.metadata.api_key);
44057
- }
44058
- return Promise.resolve();
44059
- }
44084
+ if (!options.custom_map) {
44085
+ options.custom_map = {};
44086
+ }
44060
44087
 
44061
- var rudderStackInstalled = false;
44062
- function installRudderStack(rudderStackConfig) {
44063
- return __awaiter$2(this, void 0, void 0, function () {
44064
- var rudderanalytics_1, methods, i, method;
44065
- return __generator(this, function (_a) {
44066
- if (rudderStackConfig && !rudderStackInstalled) {
44067
- rudderStackInstalled = true;
44068
- dynamicImport('https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js');
44069
- rudderanalytics_1 = (featheryWindow().rudderanalytics = []);
44070
- methods = [
44071
- 'load',
44072
- 'page',
44073
- 'track',
44074
- 'identify',
44075
- 'alias',
44076
- 'group',
44077
- 'ready',
44078
- 'reset',
44079
- 'getAnonymousId',
44080
- 'setAnonymousId',
44081
- 'getUserId',
44082
- 'getUserTraits',
44083
- 'getGroupId',
44084
- 'getGroupTraits',
44085
- 'startSession',
44086
- 'endSession',
44087
- 'getSessionId'
44088
- ];
44089
- for (i = 0; i < methods.length; i++) {
44090
- method = methods[i];
44091
- rudderanalytics_1[method] = (function (methodName) {
44092
- return function () {
44093
- rudderanalytics_1.push(
44094
- // eslint-disable-next-line prefer-rest-params
44095
- [methodName].concat(Array.prototype.slice.call(arguments)));
44096
- };
44097
- })(method);
44098
- }
44099
- rudderanalytics_1.load(rudderStackConfig.metadata.write_key, rudderStackConfig.metadata.data_plane_url);
44100
- rudderanalytics_1.identify(initInfo().userId);
44101
- }
44102
- return [2 /*return*/, Promise.resolve()];
44103
- });
44104
- });
44105
- }
44106
- function trackRudderEvent(title, properties, integ) {
44107
- var trackEvents = integ === null || integ === void 0 ? void 0 : integ.metadata.track_events;
44108
- if (!trackEvents || trackEvents.includes(title))
44109
- featheryWindow().rudderanalytics.track(title, properties);
44110
- }
44088
+ for (var i = 1; i <= 200; i++) {
44089
+ if (!options.custom_map["dimension".concat(i)]) {
44090
+ options.custom_map["dimension".concat(i)] = "dimension".concat(i);
44091
+ }
44111
44092
 
44112
- var configMap = {};
44113
- function installTrustedForm(trustedformConfig, formKey) {
44114
- return __awaiter$2(this, void 0, void 0, function () {
44115
- var tf, protocol, certField, pingField, rand, s;
44116
- return __generator(this, function (_a) {
44117
- if (!trustedformConfig)
44118
- return [2 /*return*/];
44119
- configMap[formKey] = trustedformConfig;
44120
- tf = featheryDoc().createElement('script');
44121
- tf.type = 'text/javascript';
44122
- tf.async = true;
44123
- protocol = featheryDoc().location.protocol === 'https:' ? 'https' : 'http';
44124
- certField = trustedformConfig.metadata.certificate_field_key;
44125
- pingField = trustedformConfig.metadata.ping_field_key;
44126
- rand = new Date().getTime() + Math.random();
44127
- tf.src = "".concat(protocol, "://api.trustedform.com/trustedform.js?field=").concat(certField, "&ping_field=").concat(pingField, "&l=").concat(rand);
44128
- s = featheryDoc().getElementsByTagName('script')[0];
44129
- s.parentNode.insertBefore(tf, s);
44130
- return [2 /*return*/];
44131
- });
44132
- });
44133
- }
44134
- function gatherTrustedFormFields(existingFields, formKey) {
44135
- var config = configMap[formKey];
44136
- if (!config)
44137
- return;
44138
- ['certificate_field_key', 'ping_field_key'].forEach(function (attr) {
44139
- var fieldKey = config.metadata[attr];
44140
- if (!(fieldKey in fieldValues)) {
44141
- // Not stored yet
44142
- var el = featheryDoc().getElementsByName(fieldKey)[0];
44143
- if (el) {
44144
- var fieldVal = el.value;
44145
- fieldValues[fieldKey] = fieldVal;
44146
- existingFields[fieldKey] = fieldVal;
44147
- }
44148
- }
44149
- });
44150
- }
44093
+ if (!options.custom_map["metric".concat(i)]) {
44094
+ options.custom_map["metric".concat(i)] = "metric".concat(i);
44095
+ }
44096
+ }
44151
44097
 
44152
- var IMPORTED_URLS = new Set();
44153
- function dynamicImport(dependencies, parallel, force) {
44154
- if (parallel === void 0) { parallel = true; }
44155
- if (force === void 0) { force = false; }
44156
- if (typeof dependencies === 'string')
44157
- dependencies = [dependencies];
44158
- var newDependencies = [];
44159
- dependencies.forEach(function (d) {
44160
- var dup = IMPORTED_URLS.has(d);
44161
- if (dup && force) {
44162
- var base = d;
44163
- var counter = 1;
44164
- while (dup) {
44165
- d = "".concat(base, "?version=").concat(counter);
44166
- dup = IMPORTED_URLS.has(d);
44167
- counter++;
44168
- }
44169
- }
44170
- if (!dup) {
44171
- IMPORTED_URLS.add(d);
44172
- newDependencies.push(d);
44173
- }
44174
- });
44175
- if (newDependencies.length === 0)
44176
- return Promise.resolve();
44177
- if (parallel) {
44178
- return new Promise(function (resolve) {
44179
- global.scriptjsLoadPromise.then(function ($script) {
44180
- $script.default(newDependencies, function (lib) {
44181
- resolve(lib);
44182
- });
44183
- });
44184
- });
44185
- }
44186
- else {
44187
- return new Promise(function (resolve) {
44188
- global.scriptjsLoadPromise.then(function ($script) {
44189
- $script.default.order(newDependencies, resolve);
44190
- });
44191
- });
44192
- }
44193
- }
44194
- function initializeIntegrations(integs, featheryClient) {
44195
- return __awaiter$2(this, void 0, void 0, function () {
44196
- var gtm;
44197
- return __generator(this, function (_a) {
44198
- switch (_a.label) {
44199
- case 0: return [4 /*yield*/, Promise.all([
44200
- installArgyle(!!integs.argyle),
44201
- installPlaid(!!integs.plaid),
44202
- installFirebase(integs.firebase),
44203
- installStytch(integs.stytch),
44204
- installStripe(integs.stripe),
44205
- installSegment(integs.segment),
44206
- installGoogleAnalytics(integs['google-analytics']),
44207
- installHeap(integs.heap),
44208
- installAmplitude(integs.amplitude),
44209
- installMixpanel(integs.mixpanel),
44210
- installIntercom(integs['intercom-embedded']),
44211
- installRudderStack(integs.rudderstack),
44212
- installPersona(integs.persona),
44213
- installAlloy(integs.alloy),
44214
- installTrustedForm(integs.trustedform, featheryClient.formKey)
44215
- ])];
44216
- case 1:
44217
- _a.sent();
44218
- gtm = integs['google-tag-manager'];
44219
- if (gtm)
44220
- initializeTagManager(gtm);
44221
- if (integs.firebase || integs.stytch) {
44222
- authState.authFormKey = featheryClient.formKey;
44223
- return [2 /*return*/, Auth.inferLoginOnLoad(featheryClient)];
44224
- }
44225
- return [2 /*return*/];
44226
- }
44227
- });
44228
- });
44229
- }
44230
- function trackEvent(integrations, title, stepId, formName, fieldData) {
44231
- var metadata = { formName: formName };
44232
- if (stepId)
44233
- metadata.stepId = stepId;
44234
- // Google Tag Manager
44235
- // @ts-expect-error TS(2551): Property 'initialized' does not exist on type '{ d... Remove this comment to see the full error message
44236
- if (TagManager.initialized) {
44237
- var gtmData = __assign({}, metadata);
44238
- if (fieldData === null || fieldData === void 0 ? void 0 : fieldData['google-tag-manager'])
44239
- gtmData = __assign(__assign({}, gtmData), fieldData['google-tag-manager']);
44240
- TagManager.dataLayer({ dataLayer: __assign(__assign({}, gtmData), { event: title }) });
44241
- }
44242
- // RudderStack
44243
- if (rudderStackInstalled) {
44244
- var rudderData = __assign({}, metadata);
44245
- if (title === 'FeatheryFormComplete')
44246
- rudderData.fieldData = fieldValues;
44247
- trackRudderEvent(title, rudderData, integrations === null || integrations === void 0 ? void 0 : integrations.rudderstack);
44248
- }
44249
- // Google Analytics
44250
- if (gaInstalled)
44251
- trackGAEvent(formName, title, stepId);
44252
- // Segment
44253
- var segmentData = __assign({}, metadata);
44254
- if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.segment)
44255
- segmentData.submittedData = fieldData.segment;
44256
- if (featheryWindow().analytics)
44257
- featheryWindow().analytics.track(title, segmentData);
44258
- var amplitudeData = __assign({}, metadata);
44259
- if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.amplitude)
44260
- amplitudeData.submittedData = fieldData.amplitude;
44261
- if (featheryWindow().amplitude)
44262
- featheryWindow().amplitude.track(title, amplitudeData);
44263
- if (featheryWindow().mixpanel)
44264
- featheryWindow().mixpanel.track(title, metadata);
44265
- }
44098
+ return options;
44099
+ }
44100
+ /**
44101
+ * @since v1.0.2
44102
+ * @param {string} [path="location.href"]
44103
+ * @param {string[]} [_] unsupported
44104
+ * @param {string} [title="location.pathname"]
44105
+ * @deprecated Use `.send("pageview")` instead
44106
+ */
44107
+
44108
+ }, {
44109
+ key: "outboundLink",
44110
+ value:
44111
+ /**
44112
+ * @since v1.0.6
44113
+ * @param {Object} options
44114
+ * @param {string} options.label
44115
+ * @param {function} hitCallback
44116
+ * @deprecated Use `enhanced measurement` feature in Google Analytics.
44117
+ */
44118
+ function outboundLink(_ref3, hitCallback) {
44119
+ var label = _ref3.label;
44120
+
44121
+ if (typeof hitCallback !== "function") {
44122
+ console.warn("hitCallback function is required");
44123
+ return;
44124
+ }
44125
+
44126
+ if (!label) {
44127
+ console.warn("args.label is required in outboundLink()");
44128
+ return;
44129
+ } // Required Fields
44130
+
44131
+
44132
+ var fieldObject = {
44133
+ hitType: "event",
44134
+ eventCategory: "Outbound",
44135
+ eventAction: "Click",
44136
+ eventLabel: (0, _format["default"])(label)
44137
+ };
44138
+ var safetyCallbackCalled = false;
44139
+
44140
+ var safetyCallback = function safetyCallback() {
44141
+ // This prevents a delayed response from GA
44142
+ // causing hitCallback from being fired twice
44143
+ safetyCallbackCalled = true;
44144
+ hitCallback();
44145
+ }; // Using a timeout to ensure the execution of critical application code
44146
+ // in the case when the GA server might be down
44147
+ // or an ad blocker prevents sending the data
44148
+ // register safety net timeout:
44266
44149
 
44267
- var isUrl_1;
44268
- var hasRequiredIsUrl;
44269
44150
 
44270
- function requireIsUrl () {
44271
- if (hasRequiredIsUrl) return isUrl_1;
44272
- hasRequiredIsUrl = 1;
44273
- /**
44274
- * Expose `isUrl`.
44275
- */
44151
+ var t = setTimeout(safetyCallback, 250);
44276
44152
 
44277
- isUrl_1 = isUrl;
44153
+ var clearableCallbackForGA = function clearableCallbackForGA() {
44154
+ clearTimeout(t);
44278
44155
 
44279
- /**
44280
- * RegExps.
44281
- * A URL must match #1 and then at least one of #2/#3.
44282
- * Use two levels of REs to avoid REDOS.
44283
- */
44156
+ if (!safetyCallbackCalled) {
44157
+ hitCallback();
44158
+ }
44159
+ };
44284
44160
 
44285
- var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
44161
+ fieldObject.hitCallback = clearableCallbackForGA;
44286
44162
 
44287
- var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
44288
- var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
44163
+ this._gaCommand("send", fieldObject);
44164
+ }
44165
+ }]);
44289
44166
 
44290
- /**
44291
- * Loosely validate a URL `string`.
44292
- *
44293
- * @param {String} string
44294
- * @return {Boolean}
44295
- */
44167
+ return GA4;
44168
+ }();
44296
44169
 
44297
- function isUrl(string){
44298
- if (typeof string !== 'string') {
44299
- return false;
44300
- }
44170
+ exports$1.GA4 = GA4;
44301
44171
 
44302
- var match = string.match(protocolAndDomainRE);
44303
- if (!match) {
44304
- return false;
44305
- }
44172
+ var _default = new GA4();
44306
44173
 
44307
- var everythingAfterProtocol = match[1];
44308
- if (!everythingAfterProtocol) {
44309
- return false;
44310
- }
44174
+ exports$1["default"] = _default;
44175
+ } (ga4));
44176
+ return ga4;
44177
+ }
44311
44178
 
44312
- if (localhostDomainRE.test(everythingAfterProtocol) ||
44313
- nonLocalhostDomainRE.test(everythingAfterProtocol)) {
44314
- return true;
44315
- }
44179
+ var hasRequiredDist;
44316
44180
 
44317
- return false;
44318
- }
44319
- return isUrl_1;
44181
+ function requireDist () {
44182
+ if (hasRequiredDist) return dist;
44183
+ hasRequiredDist = 1;
44184
+ (function (exports$1) {
44185
+
44186
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
44187
+
44188
+ Object.defineProperty(exports$1, "__esModule", {
44189
+ value: true
44190
+ });
44191
+ exports$1["default"] = exports$1.ReactGAImplementation = void 0;
44192
+
44193
+ var _ga = _interopRequireWildcard(requireGa4());
44194
+
44195
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
44196
+
44197
+ function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44198
+
44199
+ var ReactGAImplementation = _ga.GA4;
44200
+ exports$1.ReactGAImplementation = ReactGAImplementation;
44201
+ var _default = _ga["default"];
44202
+ exports$1["default"] = _default;
44203
+ } (dist));
44204
+ return dist;
44320
44205
  }
44321
44206
 
44322
- var isUrlExports = requireIsUrl();
44323
- var isUrl = /*@__PURE__*/getDefaultExportFromCjs(isUrlExports);
44207
+ var distExports = requireDist();
44208
+ var ReactGA = /*@__PURE__*/getDefaultExportFromCjs(distExports);
44324
44209
 
44325
- var LETTER_MATCH = /[a-zA-Z]/;
44326
- var UPPERCASE_LETTER_MATCH = /[A-Z]/;
44327
- var LOWERCASE_LETTER_MATCH = /[a-z]/;
44328
- var NUMBER_MATCH = /\d/;
44329
- // eslint-disable-next-line no-useless-escape
44330
- var SYMBOL_MATCH = /[#$\.%&'()\+,-/:;<=>!?@\\\[\]\^_`{|}~\*]/;
44331
- var DOMAIN_ALLOWED_CHARACTERS = /^[a-zA-Z0-9.\\-]+$/;
44332
- /**
44333
- * Validate elements on a form
44334
- */
44335
- function validateElements(_a) {
44336
- var step = _a.step, visiblePositions = _a.visiblePositions, triggerErrors = _a.triggerErrors, errorType = _a.errorType, formRef = _a.formRef, _b = _a.errorCallback, errorCallback = _b === void 0 ? function () { } : _b, setInlineErrors = _a.setInlineErrors, trigger = _a.trigger;
44337
- var invalid = false;
44338
- var inlineErrors = {};
44339
- var errors = getVisibleElements(step, visiblePositions, ['servar_fields', 'buttons'], true).reduce(function (errors, _a) {
44340
- var _b;
44341
- var element = _a.element, repeat = _a.repeat, last = _a.last, elementType = _a.type;
44342
- var key, type;
44343
- if (elementType === 'servar_fields') {
44344
- if (element.servar.repeat_trigger === 'set_value' && last && repeat) {
44345
- // Skip validation on last repeat since it might be default value
44346
- return errors;
44347
- }
44348
- type = element.servar.type;
44349
- key = element.servar.key;
44210
+ var gaInstalled = false;
44211
+ function installGoogleAnalytics(gaConfig) {
44212
+ if (gaConfig && !gaInstalled) {
44213
+ gaInstalled = true;
44214
+ ReactGA.initialize(gaConfig.metadata.api_key);
44215
+ }
44216
+ return Promise.resolve();
44217
+ }
44218
+ function trackGAEvent(category, action, label) {
44219
+ ReactGA.event({ category: category, action: action, label: label });
44220
+ }
44221
+
44222
+ var heapInstalled = false;
44223
+ function installHeap(heapConfig) {
44224
+ if (heapConfig && !heapInstalled) {
44225
+ heapInstalled = true;
44226
+ featheryWindow().heap = featheryWindow().heap || [];
44227
+ featheryWindow().heap.load = function (e) {
44228
+ featheryWindow().heap.appid = e;
44229
+ featheryWindow().heap.config = {};
44230
+ var r = featheryDoc().createElement('script');
44231
+ r.type = 'text/javascript';
44232
+ r.async = true;
44233
+ r.src = 'https://cdn.heapanalytics.com/js/heap-' + e + '.js';
44234
+ var a = featheryDoc().getElementsByTagName('script')[0];
44235
+ a.parentNode.insertBefore(r, a);
44236
+ for (var n = function (e) {
44237
+ return function () {
44238
+ featheryWindow().heap.push(
44239
+ // eslint-disable-next-line prefer-rest-params
44240
+ [e].concat(Array.prototype.slice.call(arguments, 0)));
44241
+ };
44242
+ }, p = [
44243
+ 'addEventProperties',
44244
+ 'addUserProperties',
44245
+ 'clearEventProperties',
44246
+ 'identify',
44247
+ 'resetIdentity',
44248
+ 'removeEventProperty',
44249
+ 'setEventProperties',
44250
+ 'track',
44251
+ 'unsetEventProperty'
44252
+ ], o = 0; o < p.length; o++)
44253
+ featheryWindow().heap[p[o]] = n(p[o]);
44254
+ };
44255
+ featheryWindow().heap.load(heapConfig.metadata.api_key);
44256
+ }
44257
+ return Promise.resolve();
44258
+ }
44259
+
44260
+ var intercomInstalled = false;
44261
+ function installIntercom(intercomConfig) {
44262
+ if (intercomConfig && !intercomInstalled) {
44263
+ intercomInstalled = true;
44264
+ var workspaceId_1 = intercomConfig.api_key;
44265
+ featheryWindow().intercomSettings = {
44266
+ api_base: 'https://api-iam.intercom.io',
44267
+ app_id: workspaceId_1
44268
+ };
44269
+ var w = featheryWindow();
44270
+ var ic = w.Intercom;
44271
+ if (typeof ic === 'function') {
44272
+ ic('reattach_activator');
44273
+ ic('update', w.intercomSettings);
44350
44274
  }
44351
44275
  else {
44352
- // if not a servar, then a button
44353
- type = 'button';
44354
- key = element.id;
44355
- }
44356
- var message = validateElement(element, repeat);
44357
- // We want to clear button errors when the button is not "relevant" to what the user is doing.
44358
- // If the element is a button and was NOT the trigger or no trigger,
44359
- // then we don't show the error.
44360
- if (type === 'button' && ((trigger && key !== trigger.id) || !trigger))
44361
- message = '';
44362
- if (!(key in errors))
44363
- errors[key] = message;
44364
- else if (Array.isArray(errors[key]))
44365
- errors[key].push(message);
44366
- else
44367
- errors[key] = [errors[key], message];
44368
- if (message && !invalid)
44369
- invalid = true;
44370
- if (type === 'matrix' && message) {
44371
- // Get question index where error is
44372
- var fieldValue = fieldValues[key];
44373
- // handle repeated matrix fields
44374
- if (repeat != null && Array.isArray(fieldValue))
44375
- fieldValue = (_b = fieldValue[repeat]) !== null && _b !== void 0 ? _b : {};
44376
- var questions = element.servar.metadata.questions;
44377
- var questionIds = questions.map(function (q) { return q.id; });
44378
- for (var i = 0; i < questionIds.length; i++) {
44379
- var value = fieldValue[questionIds[i]];
44380
- if (value === undefined ||
44381
- (Array.isArray(value) && value.length === 0)) {
44382
- key = "".concat(key, "-").concat(i);
44383
- break;
44384
- }
44276
+ var d_1 = featheryDoc();
44277
+ var i_1 = function () {
44278
+ // eslint-disable-next-line prefer-rest-params
44279
+ i_1.c(arguments);
44280
+ };
44281
+ i_1.q = [];
44282
+ i_1.c = function (args) {
44283
+ i_1.q.push(args);
44284
+ };
44285
+ w.Intercom = i_1;
44286
+ var l = function () {
44287
+ var s = d_1.createElement('script');
44288
+ s.type = 'text/javascript';
44289
+ s.async = true;
44290
+ s.src = "https://widget.intercom.io/widget/".concat(workspaceId_1);
44291
+ var x = d_1.getElementsByTagName('script')[0];
44292
+ x.parentNode.insertBefore(s, x);
44293
+ };
44294
+ if (featheryDoc().readyState === 'complete') {
44295
+ l();
44296
+ }
44297
+ else if (w.attachEvent) {
44298
+ w.attachEvent('onload', l);
44299
+ }
44300
+ else {
44301
+ w.addEventListener('load', l, false);
44385
44302
  }
44386
44303
  }
44387
- if (triggerErrors) {
44388
- setFormElementError({
44389
- formRef: formRef,
44390
- errorCallback: errorCallback,
44391
- fieldKey: key,
44392
- message: message,
44393
- errorType: errorType,
44394
- servarType: type,
44395
- inlineErrors: inlineErrors,
44396
- index: repeat
44397
- });
44398
- }
44399
- return errors;
44400
- }, {});
44401
- if (triggerErrors) {
44402
- setFormElementError({
44403
- formRef: formRef,
44404
- errorType: errorType,
44405
- inlineErrors: inlineErrors,
44406
- setInlineErrors: setInlineErrors,
44407
- triggerErrors: true
44408
- });
44409
44304
  }
44410
- return { errors: errors, inlineErrors: inlineErrors, invalid: invalid };
44411
- }
44412
- /**
44413
- * Performs all default/standard and custom validations on a field/element
44414
- * and returns any validation message.
44415
- */
44416
- function validateElement(element, repeat) {
44417
- var servar = element.servar, validations = element.validations;
44418
- // First priority is custom validations for servar fields
44419
- if (validations) {
44420
- var firstMatchingValidation = validations.find(function (validation) {
44421
- return validation.rules.every(function (rule) { return evalComparisonRule(rule, repeat); });
44305
+ return Promise.resolve();
44306
+ }
44307
+
44308
+ var amplitudeInstalled = false;
44309
+ function installAmplitude(amplitudeConfig) {
44310
+ return __awaiter$2(this, void 0, void 0, function () {
44311
+ var meta, apiKey, cdn, sessionReplayTracking, options;
44312
+ return __generator(this, function (_a) {
44313
+ switch (_a.label) {
44314
+ case 0:
44315
+ if (!amplitudeConfig || amplitudeInstalled)
44316
+ return [2 /*return*/];
44317
+ amplitudeInstalled = true;
44318
+ meta = amplitudeConfig.metadata;
44319
+ apiKey = meta.api_key;
44320
+ cdn = 'cdn';
44321
+ if (meta.eu_server)
44322
+ cdn = 'cdn.eu';
44323
+ return [4 /*yield*/, dynamicImport("https://".concat(cdn, ".amplitude.com/script/").concat(apiKey, ".js"))];
44324
+ case 1:
44325
+ _a.sent();
44326
+ if (!featheryWindow().amplitude) {
44327
+ console.warn('Failed to load Amplitude.');
44328
+ return [2 /*return*/];
44329
+ }
44330
+ if (meta.session_replay && featheryWindow().sessionReplay) {
44331
+ sessionReplayTracking = featheryWindow().sessionReplay.plugin();
44332
+ featheryWindow().amplitude.add(sessionReplayTracking);
44333
+ }
44334
+ options = {
44335
+ fetchRemoteConfig: true,
44336
+ autocapture: true
44337
+ };
44338
+ if (meta.eu_server)
44339
+ options.serverZone = 'EU';
44340
+ featheryWindow().amplitude.init(apiKey, options);
44341
+ if (meta.identify_user)
44342
+ featheryWindow().amplitude.setUserId(initInfo().userId);
44343
+ return [2 /*return*/];
44344
+ }
44422
44345
  });
44423
- if (firstMatchingValidation)
44424
- return firstMatchingValidation.message;
44425
- }
44426
- // Now apply any standard validations
44427
- if (servar) {
44428
- var fieldVal = fieldValues[servar.key];
44429
- if (servar.repeated)
44430
- fieldVal = fieldVal[repeat];
44431
- var errorMsg = getStandardFieldError(fieldVal, servar, repeat);
44432
- if (errorMsg)
44433
- return errorMsg;
44434
- }
44435
- return '';
44436
- }
44437
- //
44438
- // Standard Validations
44439
- //
44440
- var emailPatternStr = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]{2,63})+$";
44441
- var emailPattern = new RegExp(emailPatternStr);
44442
- var LIB_PHONE_NUMBER_URL = 'https://cdn.jsdelivr.net/npm/libphonenumber-js@1.11.16/bundle/libphonenumber-js.min.js';
44443
- var phoneLibPromise = Promise.resolve();
44444
- var loadPhoneValidator = function () {
44445
- return (phoneLibPromise = dynamicImport(LIB_PHONE_NUMBER_URL));
44446
- };
44447
- var validators = {
44448
- email: function (a) {
44449
- if (!a)
44450
- return false;
44451
- var parts = a.split('@');
44452
- if (parts.length !== 2)
44453
- return false;
44454
- // Email handle cannot end with '.'
44455
- var part = parts[0];
44456
- if (part.endsWith('.') || part.startsWith('.'))
44457
- return false;
44458
- if (part.includes('..'))
44459
- return false;
44460
- return emailPattern.test(a);
44461
- },
44462
- phone: function (a) {
44463
- try {
44464
- return global.libphonenumber.isValidPhoneNumber("+".concat(a));
44465
- }
44466
- catch (e) {
44467
- // Invalid phone number
44468
- return false;
44469
- }
44470
- },
44471
- url: function (a) {
44472
- if (!isUrl(a))
44473
- return false;
44474
- try {
44475
- var urlObj = new URL(a);
44476
- if (!urlObj)
44477
- return false;
44478
- var hostname = urlObj.hostname;
44479
- if (hostname.length >= 64)
44480
- return false;
44481
- if (!DOMAIN_ALLOWED_CHARACTERS.test(hostname))
44482
- return false;
44483
- var parts = hostname.split('.');
44484
- if (parts.some(function (part) { return !part; }))
44485
- return false;
44486
- // Last part of domain cannot contain digit
44487
- if (NUMBER_MATCH.test(parts[parts.length - 1]))
44488
- return false;
44489
- // Colon at end of hostname gets filtered out by URL object but
44490
- // should be invalid
44491
- if (a[urlObj.origin.length] === ':')
44492
- return false;
44493
- // Check for filtered out special characters, e.g.
44494
- // https://@google.com -> https://google.com
44495
- if (!a.toLowerCase().includes("/".concat(hostname.toLowerCase())))
44496
- return false;
44497
- return parts.length > 1;
44498
- }
44499
- catch (e) {
44500
- return false;
44501
- }
44346
+ });
44347
+ }
44348
+
44349
+ var mixpanelInstalled = false;
44350
+ function installMixpanel(mixpanelConfig) {
44351
+ if (mixpanelConfig && !mixpanelInstalled && !featheryWindow().mixpanel) {
44352
+ mixpanelInstalled = true;
44353
+ (function (f, b) {
44354
+ if (!b.__SV) {
44355
+ var i_1, h_1;
44356
+ featheryWindow().mixpanel = b;
44357
+ b._i = [];
44358
+ b.init = function (e, f, c) {
44359
+ function g(a, d) {
44360
+ var b = d.split('.');
44361
+ // eslint-disable-next-line eqeqeq,no-unused-expressions
44362
+ b.length == 2 && ((a = a[b[0]]), (d = b[1]));
44363
+ a[d] = function () {
44364
+ // eslint-disable-next-line prefer-rest-params
44365
+ a.push([d].concat(Array.prototype.slice.call(arguments, 0)));
44366
+ };
44367
+ }
44368
+ var a = b;
44369
+ typeof c !== 'undefined' ? (a = b[c] = []) : (c = 'mixpanel');
44370
+ a.people = a.people || [];
44371
+ a.toString = function (a) {
44372
+ var d = 'mixpanel';
44373
+ c !== 'mixpanel' && (d += '.' + c);
44374
+ a || (d += ' (stub)');
44375
+ return d;
44376
+ };
44377
+ a.people.toString = function () {
44378
+ return a.toString(1) + '.people (stub)';
44379
+ };
44380
+ i_1 =
44381
+ 'disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove'.split(' ');
44382
+ for (h_1 = 0; h_1 < i_1.length; h_1++)
44383
+ g(a, i_1[h_1]);
44384
+ var j = 'set set_once union unset remove delete'.split(' ');
44385
+ a.get_group = function () {
44386
+ function b(c) {
44387
+ d[c] = function () {
44388
+ var call2 = [c].concat(
44389
+ // eslint-disable-next-line prefer-rest-params
44390
+ Array.prototype.slice.call(arguments, 0));
44391
+ a.push([e, call2]);
44392
+ };
44393
+ }
44394
+ var d;
44395
+ for (d = {},
44396
+ e = ['get_group'].concat(
44397
+ // eslint-disable-next-line prefer-rest-params
44398
+ Array.prototype.slice.call(arguments, 0)),
44399
+ c = 0; c < j.length; c++)
44400
+ b(j[c]);
44401
+ return d;
44402
+ };
44403
+ b._i.push([e, f, c]);
44404
+ };
44405
+ b.__SV = 1.2;
44406
+ var e = f.createElement('script');
44407
+ e.type = 'text/javascript';
44408
+ e.async = true;
44409
+ e.src =
44410
+ f.location.protocol === 'file:' &&
44411
+ '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'.match(/^\/\//)
44412
+ ? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
44413
+ : '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
44414
+ var g = f.getElementsByTagName('script')[0];
44415
+ g.parentNode.insertBefore(e, g);
44416
+ }
44417
+ })(featheryDoc(), featheryWindow().mixpanel || []);
44418
+ featheryWindow().mixpanel.init(mixpanelConfig.metadata.api_key);
44502
44419
  }
44503
- };
44504
- function isFieldValueEmpty(value, servar) {
44505
- var _a;
44506
- if (ARRAY_FIELD_TYPES.includes(servar.type)) {
44507
- if (!value || value.length === 0)
44508
- return true;
44509
- // For file uploads and button groups, check if array contains only null/falsy values
44510
- if (['file_upload', 'button_group'].includes(servar.type)) {
44511
- // In repeatable containers, file upload values are stored as individual Files (not arrays)
44512
- // because changeValue extracts value[0] for each row. Handle both cases:
44513
- if (!Array.isArray(value)) {
44514
- return !value; // Single file or null (from repeatable container)
44420
+ return Promise.resolve();
44421
+ }
44422
+
44423
+ var rudderStackInstalled = false;
44424
+ function installRudderStack(rudderStackConfig) {
44425
+ return __awaiter$2(this, void 0, void 0, function () {
44426
+ var rudderanalytics_1, methods, i, method;
44427
+ return __generator(this, function (_a) {
44428
+ if (rudderStackConfig && !rudderStackInstalled) {
44429
+ rudderStackInstalled = true;
44430
+ dynamicImport('https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js');
44431
+ rudderanalytics_1 = (featheryWindow().rudderanalytics = []);
44432
+ methods = [
44433
+ 'load',
44434
+ 'page',
44435
+ 'track',
44436
+ 'identify',
44437
+ 'alias',
44438
+ 'group',
44439
+ 'ready',
44440
+ 'reset',
44441
+ 'getAnonymousId',
44442
+ 'setAnonymousId',
44443
+ 'getUserId',
44444
+ 'getUserTraits',
44445
+ 'getGroupId',
44446
+ 'getGroupTraits',
44447
+ 'startSession',
44448
+ 'endSession',
44449
+ 'getSessionId'
44450
+ ];
44451
+ for (i = 0; i < methods.length; i++) {
44452
+ method = methods[i];
44453
+ rudderanalytics_1[method] = (function (methodName) {
44454
+ return function () {
44455
+ rudderanalytics_1.push(
44456
+ // eslint-disable-next-line prefer-rest-params
44457
+ [methodName].concat(Array.prototype.slice.call(arguments)));
44458
+ };
44459
+ })(method);
44460
+ }
44461
+ rudderanalytics_1.load(rudderStackConfig.metadata.write_key, rudderStackConfig.metadata.data_plane_url);
44462
+ rudderanalytics_1.identify(initInfo().userId);
44515
44463
  }
44516
- if (value.every(function (val) { return !val; })) {
44517
- return true;
44464
+ return [2 /*return*/, Promise.resolve()];
44465
+ });
44466
+ });
44467
+ }
44468
+ function trackRudderEvent(title, properties, integ) {
44469
+ var trackEvents = integ === null || integ === void 0 ? void 0 : integ.metadata.track_events;
44470
+ if (!trackEvents || trackEvents.includes(title))
44471
+ featheryWindow().rudderanalytics.track(title, properties);
44472
+ }
44473
+
44474
+ var configMap = {};
44475
+ function installTrustedForm(trustedformConfig, formKey) {
44476
+ return __awaiter$2(this, void 0, void 0, function () {
44477
+ var tf, protocol, certField, pingField, rand, s;
44478
+ return __generator(this, function (_a) {
44479
+ if (!trustedformConfig)
44480
+ return [2 /*return*/];
44481
+ configMap[formKey] = trustedformConfig;
44482
+ tf = featheryDoc().createElement('script');
44483
+ tf.type = 'text/javascript';
44484
+ tf.async = true;
44485
+ protocol = featheryDoc().location.protocol === 'https:' ? 'https' : 'http';
44486
+ certField = trustedformConfig.metadata.certificate_field_key;
44487
+ pingField = trustedformConfig.metadata.ping_field_key;
44488
+ rand = new Date().getTime() + Math.random();
44489
+ tf.src = "".concat(protocol, "://api.trustedform.com/trustedform.js?field=").concat(certField, "&ping_field=").concat(pingField, "&l=").concat(rand);
44490
+ s = featheryDoc().getElementsByTagName('script')[0];
44491
+ s.parentNode.insertBefore(tf, s);
44492
+ return [2 /*return*/];
44493
+ });
44494
+ });
44495
+ }
44496
+ function gatherTrustedFormFields(existingFields, formKey) {
44497
+ var config = configMap[formKey];
44498
+ if (!config)
44499
+ return;
44500
+ ['certificate_field_key', 'ping_field_key'].forEach(function (attr) {
44501
+ var fieldKey = config.metadata[attr];
44502
+ if (!(fieldKey in fieldValues)) {
44503
+ // Not stored yet
44504
+ var el = featheryDoc().getElementsByName(fieldKey)[0];
44505
+ if (el) {
44506
+ var fieldVal = el.value;
44507
+ fieldValues[fieldKey] = fieldVal;
44508
+ existingFields[fieldKey] = fieldVal;
44518
44509
  }
44519
44510
  }
44520
- // If 'other' is selected for checkbox group, make sure it has a value
44521
- return servar.type === 'multiselect' && value.some(function (val) { return !val; });
44511
+ });
44512
+ }
44513
+
44514
+ var IMPORTED_URLS = new Set();
44515
+ function dynamicImport(dependencies, parallel, force) {
44516
+ if (parallel === void 0) { parallel = true; }
44517
+ if (force === void 0) { force = false; }
44518
+ if (typeof dependencies === 'string')
44519
+ dependencies = [dependencies];
44520
+ var newDependencies = [];
44521
+ dependencies.forEach(function (d) {
44522
+ var dup = IMPORTED_URLS.has(d);
44523
+ if (dup && force) {
44524
+ var base = d;
44525
+ var counter = 1;
44526
+ while (dup) {
44527
+ d = "".concat(base, "?version=").concat(counter);
44528
+ dup = IMPORTED_URLS.has(d);
44529
+ counter++;
44530
+ }
44531
+ }
44532
+ if (!dup) {
44533
+ IMPORTED_URLS.add(d);
44534
+ newDependencies.push(d);
44535
+ }
44536
+ });
44537
+ if (newDependencies.length === 0)
44538
+ return Promise.resolve();
44539
+ if (parallel) {
44540
+ return new Promise(function (resolve) {
44541
+ global.scriptjsLoadPromise.then(function ($script) {
44542
+ $script.default(newDependencies, function (lib) {
44543
+ resolve(lib);
44544
+ });
44545
+ });
44546
+ });
44522
44547
  }
44523
- var noVal;
44524
- switch (servar.type) {
44525
- case 'matrix':
44526
- // Each key in value needs to have an array with at least one value
44527
- noVal = servar.metadata.questions.some(function (_a) {
44528
- var id = _a.id;
44529
- return !value[id] || value[id].length === 0;
44548
+ else {
44549
+ return new Promise(function (resolve) {
44550
+ global.scriptjsLoadPromise.then(function ($script) {
44551
+ $script.default.order(newDependencies, resolve);
44530
44552
  });
44531
- break;
44532
- case 'select':
44533
- case 'signature':
44534
- noVal = !value;
44535
- break;
44536
- case 'checkbox':
44537
- // eslint-disable-next-line camelcase
44538
- noVal = !value && ((_a = servar.metadata) === null || _a === void 0 ? void 0 : _a.must_check);
44539
- break;
44540
- case 'payment_method':
44541
- noVal = !(value === null || value === void 0 ? void 0 : value.complete);
44542
- break;
44543
- case 'rating':
44544
- noVal = !value;
44545
- break;
44546
- default:
44547
- if (typeof value === 'string')
44548
- value = value.trim();
44549
- noVal = ['', null, undefined].includes(value);
44550
- break;
44553
+ });
44551
44554
  }
44552
- return noVal;
44553
44555
  }
44554
- /**
44555
- * Default validations.
44556
- * Returns the error message for a field value if it's invalid.
44557
- * Returns an empty string if it's valid.
44558
- */
44559
- function getStandardFieldError(value, servar, repeat) {
44560
- var defaultErrors = initInfo().defaultErrors;
44561
- if (isFieldValueEmpty(value, servar)) {
44562
- // If no value, error if field is required
44563
- return servar.required ? defaultErrors.required : '';
44564
- }
44565
- if (servar.min_length && value.length < servar.min_length) {
44566
- return defaultErrors.minimum.replace('{length}', servar.min_length);
44567
- }
44568
- var defaultErr = defaultErrors[servar.type];
44569
- // Check if value is badly formatted
44570
- if (servar.type === 'phone_number' && !validators.phone(value)) {
44571
- return defaultErr;
44572
- }
44573
- else if (servar.type === 'email' && !validators.email(value)) {
44574
- return defaultErr;
44575
- }
44576
- else if (servar.type === 'url' && !validators.url(value)) {
44577
- // Try appending https since user may have just omitted the protocol
44578
- var newVal = 'https://' + value;
44579
- if (validators.url(newVal)) {
44580
- if (servar.repeated) {
44581
- // @ts-ignore
44582
- fieldValues[servar === null || servar === void 0 ? void 0 : servar.key][repeat] = newVal;
44556
+ function initializeIntegrations(integs, featheryClient) {
44557
+ return __awaiter$2(this, void 0, void 0, function () {
44558
+ var gtm;
44559
+ return __generator(this, function (_a) {
44560
+ switch (_a.label) {
44561
+ case 0: return [4 /*yield*/, Promise.all([
44562
+ installArgyle(!!integs.argyle),
44563
+ installPlaid(!!integs.plaid),
44564
+ installFirebase(integs.firebase),
44565
+ installStytch(integs.stytch),
44566
+ installStripe(integs.stripe),
44567
+ installSegment(integs.segment),
44568
+ installGoogleAnalytics(integs['google-analytics']),
44569
+ installHeap(integs.heap),
44570
+ installAmplitude(integs.amplitude),
44571
+ installMixpanel(integs.mixpanel),
44572
+ installIntercom(integs['intercom-embedded']),
44573
+ installRudderStack(integs.rudderstack),
44574
+ installPersona(integs.persona),
44575
+ installAlloy(integs.alloy),
44576
+ installTrustedForm(integs.trustedform, featheryClient.formKey)
44577
+ ])];
44578
+ case 1:
44579
+ _a.sent();
44580
+ gtm = integs['google-tag-manager'];
44581
+ if (gtm)
44582
+ initializeTagManager(gtm);
44583
+ if (integs.firebase || integs.stytch) {
44584
+ authState.authFormKey = featheryClient.formKey;
44585
+ return [2 /*return*/, Auth.inferLoginOnLoad(featheryClient)];
44586
+ }
44587
+ return [2 /*return*/];
44583
44588
  }
44584
- else
44585
- fieldValues[servar.key] = newVal;
44586
- return '';
44587
- }
44588
- return defaultErr;
44589
- }
44590
- else if (servar.type === 'ssn' &&
44591
- value.length !== (servar.metadata.last_four_digits ? 4 : 9)) {
44592
- return defaultErr;
44593
- }
44594
- else if (servar.type === 'pin_input' &&
44595
- value.length !== servar.max_length) {
44596
- return defaultErr;
44589
+ });
44590
+ });
44591
+ }
44592
+ function trackEvent(integrations, title, stepId, formName, fieldData) {
44593
+ var metadata = { formName: formName };
44594
+ if (stepId)
44595
+ metadata.stepId = stepId;
44596
+ // Google Tag Manager
44597
+ // @ts-expect-error TS(2551): Property 'initialized' does not exist on type '{ d... Remove this comment to see the full error message
44598
+ if (TagManager.initialized) {
44599
+ var gtmData = __assign({}, metadata);
44600
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData['google-tag-manager'])
44601
+ gtmData = __assign(__assign({}, gtmData), fieldData['google-tag-manager']);
44602
+ TagManager.dataLayer({ dataLayer: __assign(__assign({}, gtmData), { event: title }) });
44597
44603
  }
44598
- else if (servar.type === 'password') {
44599
- var meta = servar.metadata;
44600
- var msg = function (key) { return "Your password must have at least 1 ".concat(key); };
44601
- if (meta.letter_required && !LETTER_MATCH.test(value))
44602
- return msg('letter');
44603
- if (meta.uppercase_letter_required && !UPPERCASE_LETTER_MATCH.test(value))
44604
- return msg('uppercase letter');
44605
- if (meta.lowercase_letter_required && !LOWERCASE_LETTER_MATCH.test(value))
44606
- return msg('lowercase letter');
44607
- if (meta.number_required && !NUMBER_MATCH.test(value))
44608
- return msg('number');
44609
- if (meta.symbol_required && !SYMBOL_MATCH.test(value))
44610
- return msg('symbol');
44604
+ // RudderStack
44605
+ if (rudderStackInstalled) {
44606
+ var rudderData = __assign({}, metadata);
44607
+ if (title === 'FeatheryFormComplete')
44608
+ rudderData.fieldData = fieldValues;
44609
+ trackRudderEvent(title, rudderData, integrations === null || integrations === void 0 ? void 0 : integrations.rudderstack);
44611
44610
  }
44612
- // No error
44613
- return '';
44611
+ // Google Analytics
44612
+ if (gaInstalled)
44613
+ trackGAEvent(formName, title, stepId);
44614
+ // Segment
44615
+ var segmentData = __assign({}, metadata);
44616
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.segment)
44617
+ segmentData.submittedData = fieldData.segment;
44618
+ if (featheryWindow().analytics)
44619
+ featheryWindow().analytics.track(title, segmentData);
44620
+ var amplitudeData = __assign({}, metadata);
44621
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.amplitude)
44622
+ amplitudeData.submittedData = fieldData.amplitude;
44623
+ if (featheryWindow().amplitude)
44624
+ featheryWindow().amplitude.track(title, amplitudeData);
44625
+ if (featheryWindow().mixpanel)
44626
+ featheryWindow().mixpanel.track(title, metadata);
44614
44627
  }
44615
44628
 
44616
44629
  var QR_SCANNER_LIB_URL = 'https://unpkg.com/html5-qrcode';
@@ -45968,9 +45981,9 @@ function init(sdkKey, options) {
45968
45981
  if (runningInClient()) {
45969
45982
  // Dynamically load libraries that must be client side
45970
45983
  global.scriptjsLoadPromise = import(
45971
- /* webpackChunkName: "scriptjs" */ './fthry_script.BZXm6Hk6.js').then(function (n) { return n.s; });
45984
+ /* webpackChunkName: "scriptjs" */ './fthry_script.0KhNn8f9.js').then(function (n) { return n.s; });
45972
45985
  global.webfontloaderPromise = import(
45973
- /* webpackChunkName: "webfontloader" */ './fthry_webfontloader.Fmt0quEr.js').then(function (n) { return n.w; });
45986
+ /* webpackChunkName: "webfontloader" */ './fthry_webfontloader.Dyilj6id.js').then(function (n) { return n.w; });
45974
45987
  // Client-side tracking logic
45975
45988
  if (initState.userTracking === 'cookie') {
45976
45989
  var cookieKey = "feathery-user-id-".concat(sdkKey);
@@ -46116,7 +46129,7 @@ function getFieldValues() {
46116
46129
  return __assign({}, fieldValues);
46117
46130
  }
46118
46131
  function logFeatheryBadge() {
46119
- console.log('%c Feathery %c v' + "2.23.4" + ' ', // replaced with real version during build
46132
+ console.log('%c Feathery %c v' + "2.23.5" + ' ', // replaced with real version during build
46120
46133
  'background: #e2626e; color: white; padding: 2px 6px; border-radius: 3px 0 0 3px; font-weight: bold;', 'background: #fce7e9; color: #c5495a; padding: 2px 6px; border-radius: 0 3px 3px 0;');
46121
46134
  }
46122
46135
 
@@ -47549,39 +47562,39 @@ breakpoint) {
47549
47562
  return styles.getTarget('inner-container', undefined, viewport === 'mobile');
47550
47563
  };
47551
47564
 
47552
- var AddressLine1 = lazy(function () { return import(/* webpackChunkName: "AddressField" */ './fthry_index.DNkI9rK_.js'); });
47553
- var ButtonGroupField = lazy(function () { return import(/* webpackChunkName: "ButtonGroupField" */ './fthry_index.CTNmp4Uu.js'); });
47554
- var CheckboxField = lazy(function () { return import(/* webpackChunkName: "CheckboxField" */ './fthry_index.DkOfnwMo.js'); });
47565
+ var AddressLine1 = lazy(function () { return import(/* webpackChunkName: "AddressField" */ './fthry_index.C4cVkdmR.js'); });
47566
+ var ButtonGroupField = lazy(function () { return import(/* webpackChunkName: "ButtonGroupField" */ './fthry_index.BIkyi9OD.js'); });
47567
+ var CheckboxField = lazy(function () { return import(/* webpackChunkName: "CheckboxField" */ './fthry_index.CyjNCuWE.js'); });
47555
47568
  var CheckboxGroupField = lazy(function () {
47556
- return import(/* webpackChunkName: "CheckboxGroupField" */ './fthry_index.B-1AsITd.js');
47569
+ return import(/* webpackChunkName: "CheckboxGroupField" */ './fthry_index.CnNPiyfF.js');
47557
47570
  });
47558
- var ColorPickerField = lazy(function () { return import(/* webpackChunkName: "ColorPickerField" */ './fthry_index.Zw_6EeQW.js'); });
47559
- var CustomField = lazy(function () { return import(/* webpackChunkName: "CustomField" */ './fthry_index.UgzTpusQ.js'); });
47571
+ var ColorPickerField = lazy(function () { return import(/* webpackChunkName: "ColorPickerField" */ './fthry_index.Degy27gw.js'); });
47572
+ var CustomField = lazy(function () { return import(/* webpackChunkName: "CustomField" */ './fthry_index.qQius3J9.js'); });
47560
47573
  var DateSelectorField = lazy(function () {
47561
- return import(/* webpackChunkName: "DateSelectorField" */ './fthry_index.B_MGu0vq.js');
47574
+ return import(/* webpackChunkName: "DateSelectorField" */ './fthry_index.D86GTeP3.js');
47562
47575
  });
47563
- var DropdownField = lazy(function () { return import(/* webpackChunkName: "DropdownField" */ './fthry_index.3I3TFRij.js'); });
47576
+ var DropdownField = lazy(function () { return import(/* webpackChunkName: "DropdownField" */ './fthry_index.B0_n9jqc.js'); });
47564
47577
  var DropdownMultiField = lazy(function () {
47565
- return import(/* webpackChunkName: "DropdownMultiField" */ './fthry_index.BFjEVX8Q.js');
47578
+ return import(/* webpackChunkName: "DropdownMultiField" */ './fthry_index.FjbxGNs2.js');
47566
47579
  });
47567
- var FileUploadField = lazy(function () { return import(/* webpackChunkName: "FileUploadField" */ './fthry_index.BdiPlpSw.js'); });
47568
- var MatrixField = lazy(function () { return import(/* webpackChunkName: "MatrixField" */ './fthry_index.B662KpzL.js'); });
47569
- var PasswordField = lazy(function () { return import(/* webpackChunkName: "PasswordField" */ './fthry_index.xiCtRiXP.js'); });
47580
+ var FileUploadField = lazy(function () { return import(/* webpackChunkName: "FileUploadField" */ './fthry_index.D4ENNIPP.js'); });
47581
+ var MatrixField = lazy(function () { return import(/* webpackChunkName: "MatrixField" */ './fthry_index.CefyT_Xy.js'); });
47582
+ var PasswordField = lazy(function () { return import(/* webpackChunkName: "PasswordField" */ './fthry_index.C0FNSGu0.js'); });
47570
47583
  var PaymentMethodField = lazy(function () {
47571
- return import(/* webpackChunkName: "PaymentMethodField" */ './fthry_PaymentMethodField.DWQiQajb.js');
47584
+ return import(/* webpackChunkName: "PaymentMethodField" */ './fthry_PaymentMethodField.CVKE3t_i.js');
47572
47585
  });
47573
- var PhoneField = lazy(function () { return import(/* webpackChunkName: "PhoneField" */ './fthry_index.DZzcdxua.js'); });
47574
- var PinInputField = lazy(function () { return import(/* webpackChunkName: "PinInputField" */ './fthry_index.Du7-Siwz.js'); });
47575
- var QRScanner = lazy(function () { return import(/* webpackChunkName: "QRScanner" */ './fthry_index.CRHUBRQI.js'); });
47586
+ var PhoneField = lazy(function () { return import(/* webpackChunkName: "PhoneField" */ './fthry_index.Cy8OGyJ9.js'); });
47587
+ var PinInputField = lazy(function () { return import(/* webpackChunkName: "PinInputField" */ './fthry_index.CsQzji9M.js'); });
47588
+ var QRScanner = lazy(function () { return import(/* webpackChunkName: "QRScanner" */ './fthry_index.BbSZxIR5.js'); });
47576
47589
  var RadioButtonGroupField = lazy(function () {
47577
47590
  return import(
47578
- /* webpackChunkName: "RadioButtonGroupField" */ './fthry_index.DrbC7Yvj.js');
47591
+ /* webpackChunkName: "RadioButtonGroupField" */ './fthry_index.7TulZeVg.js');
47579
47592
  });
47580
- var RatingField = lazy(function () { return import(/* webpackChunkName: "RatingField" */ './fthry_index.lUtvQLwf.js'); });
47581
- var SignatureField = lazy(function () { return import(/* webpackChunkName: "SignatureField" */ './fthry_index.qSUOQAau.js'); });
47582
- var SliderField = lazy(function () { return import(/* webpackChunkName: "SliderField" */ './fthry_index.CDEcS8bU.js'); });
47583
- var TextField = lazy(function () { return import(/* webpackChunkName: "TextField" */ './fthry_index.Boum24kr.js'); });
47584
- var TextArea = lazy(function () { return import(/* webpackChunkName: "TextArea" */ './fthry_index.fgPxSncQ.js'); });
47593
+ var RatingField = lazy(function () { return import(/* webpackChunkName: "RatingField" */ './fthry_index.BPmvHG0R.js'); });
47594
+ var SignatureField = lazy(function () { return import(/* webpackChunkName: "SignatureField" */ './fthry_index.5oEnjTzQ.js'); });
47595
+ var SliderField = lazy(function () { return import(/* webpackChunkName: "SliderField" */ './fthry_index.DoxZOyru.js'); });
47596
+ var TextField = lazy(function () { return import(/* webpackChunkName: "TextField" */ './fthry_index.BQTGcd6O.js'); });
47597
+ var TextArea = lazy(function () { return import(/* webpackChunkName: "TextArea" */ './fthry_index.Beh4LhUb.js'); });
47585
47598
  var Fields = {
47586
47599
  AddressLine1: AddressLine1,
47587
47600
  ButtonGroupField: ButtonGroupField,
@@ -48521,7 +48534,7 @@ function ElementSkeleton(_a) {
48521
48534
  }
48522
48535
  var templateObject_1;
48523
48536
 
48524
- var TableElement = lazy(function () { return import(/* webpackChunkName: "TableElement" */ './fthry_index.B6e40TNH.js'); });
48537
+ var TableElement = lazy(function () { return import(/* webpackChunkName: "TableElement" */ './fthry_index.AdQD-dII.js'); });
48525
48538
  var Basic = {
48526
48539
  ImageElement: ImageElement,
48527
48540
  VideoElement: VideoElement,
@@ -48818,4 +48831,4 @@ var Feathery = {
48818
48831
  renderAt: renderAt
48819
48832
  };
48820
48833
 
48821
- export { strlen as $, API_URL as A, formatDateString as B, countryData as C, DROPDOWN_Z_INDEX as D, ErrorInput as E, Fragment as F, Global as G, stringify$2 as H, rulesheet as I, COMMENT as J, middleware as K, combine as L, match as M, serialize as N, copy as O, replace as P, MOZ as Q, RULESET as R, MS as S, KEYFRAMES as T, DECLARATION as U, dealloc as V, WEBKIT as W, alloc as X, hash as Y, charat as Z, __assign as _, jsxs as a, indexof as a0, next as a1, token as a2, from as a3, peek as a4, delimit as a5, slice as a6, position as a7, compile as a8, isEmptyArray as a9, updateUserId as aA, updateTheme as aB, setFieldValues as aC, getFieldValues as aD, renderAt as aE, LoginForm as aF, useAuthClient as aG, Feathery as aH, StyledContainer as aI, toList as aa, useThumbnailData as ab, downloadFile as ac, CloseIcon as ad, justRemove as ae, getStripe as af, filterKeys as ag, ERROR_COLOR as ah, authState as ai, firebaseSMSCountries as aj, phoneLibPromise as ak, isNum as al, loadQRScanner as am, throttle as an, qrPromise as ao, devicePixelRatio as ap, toBase64 as aq, MODAL_Z_INDEX as ar, dataURLToFile as as, cls as at, getFieldValue$1 as au, emailPatternStr as av, replaceTextVariables as aw, ReactForm as ax, Elements as ay, init as az, __read as b, fieldValues as c, __values as d, __spreadArray as e, featheryDoc as f, getDefaultExportFromCjs as g, hoverStylesGuard as h, initInfo as i, jsx$1 as j, iosScrollOnFocus as k, __awaiter$2 as l, __generator as m, FeatheryClient as n, debounce as o, imgMaxSizeStyles as p, noTextSelectStyles as q, resetStyles as r, stringifyWithNull as s, FORM_Z_INDEX as t, useBorder as u, featheryWindow as v, css as w, __makeTemplateObject as x, isMobile as y, __rest$1 as z };
48834
+ export { strlen as $, API_URL as A, formatDateString as B, countryData as C, DROPDOWN_Z_INDEX as D, ErrorInput as E, Fragment as F, Global as G, stringify$2 as H, rulesheet as I, COMMENT as J, middleware as K, combine as L, match as M, serialize as N, copy as O, replace as P, MOZ as Q, RULESET as R, MS as S, KEYFRAMES as T, DECLARATION as U, dealloc as V, WEBKIT as W, alloc as X, hash as Y, charat as Z, __assign as _, jsxs as a, indexof as a0, next as a1, token as a2, from as a3, peek as a4, delimit as a5, slice as a6, position as a7, compile as a8, isEmptyArray as a9, init as aA, updateUserId as aB, updateTheme as aC, setFieldValues as aD, getFieldValues as aE, renderAt as aF, LoginForm as aG, useAuthClient as aH, Feathery as aI, StyledContainer as aJ, toList as aa, useThumbnailData as ab, downloadFile as ac, CloseIcon as ad, justRemove as ae, getStripe as af, filterKeys as ag, ERROR_COLOR as ah, phoneLib as ai, authState as aj, firebaseSMSCountries as ak, phoneLibPromise as al, isNum as am, loadQRScanner as an, throttle as ao, qrPromise as ap, devicePixelRatio as aq, toBase64 as ar, MODAL_Z_INDEX as as, dataURLToFile as at, cls as au, getFieldValue$1 as av, emailPatternStr as aw, replaceTextVariables as ax, ReactForm as ay, Elements as az, __read as b, fieldValues as c, __values as d, __spreadArray as e, featheryDoc as f, getDefaultExportFromCjs as g, hoverStylesGuard as h, initInfo as i, jsx$1 as j, iosScrollOnFocus as k, __awaiter$2 as l, __generator as m, FeatheryClient as n, debounce as o, imgMaxSizeStyles as p, noTextSelectStyles as q, resetStyles as r, stringifyWithNull as s, FORM_Z_INDEX as t, useBorder as u, featheryWindow as v, css as w, __makeTemplateObject as x, isMobile as y, __rest$1 as z };