@feathery/react 2.23.3 → 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 (96) hide show
  1. package/cjs/Form/index.d.ts.map +1 -1
  2. package/cjs/auth/internal/utils.d.ts.map +1 -1
  3. package/cjs/elements/fields/PhoneField/CountryDropdown.d.ts.map +1 -1
  4. package/cjs/elements/fields/PhoneField/index.d.ts.map +1 -1
  5. package/cjs/elements/fields/PhoneField/tests/test-utils.d.ts.map +1 -1
  6. package/cjs/{fthry_FormControl.BgJi7H3j.js → fthry_FormControl.CscXHID3.js} +1 -1
  7. package/cjs/{fthry_InlineTooltip.C0fcrMAl.js → fthry_InlineTooltip.ZpgEmPO3.js} +2 -2
  8. package/cjs/{fthry_Overlay.DVxwKvvt.js → fthry_Overlay.BTS_EcV3.js} +1 -1
  9. package/cjs/{fthry_PaymentMethodField.B_GDmxLy.js → fthry_PaymentMethodField.D902pJlo.js} +4 -4
  10. package/cjs/{fthry_Placeholder.Djw0_HfW.js → fthry_Placeholder.Ctq06SYu.js} +1 -1
  11. package/cjs/{fthry_ShowEyeIcon.BzYc1Yga.js → fthry_ShowEyeIcon.q9BhUK2g.js} +1 -1
  12. package/cjs/{fthry_index.ByVaPSCt.js → fthry_index.-Y9ZJS34.js} +6 -6
  13. package/cjs/{fthry_index.BPf3q0bZ.js → fthry_index.9PFsbc4I.js} +1 -1
  14. package/cjs/{fthry_index.BrrNGZQn.js → fthry_index.B4YVBeqY.js} +3 -3
  15. package/cjs/{fthry_index.Cs1MGCSE.js → fthry_index.BS6b2BTF.js} +6 -6
  16. package/cjs/{fthry_index.B0KReyAP.js → fthry_index.BYTU7WTg.js} +4 -4
  17. package/cjs/{fthry_index.CRDDUT1I.js → fthry_index.B_UehadW.js} +1 -1
  18. package/cjs/{fthry_index.ly3gOUU_.js → fthry_index.Bh5jAAhx.js} +6 -6
  19. package/cjs/{fthry_index.2nJBzqdc.js → fthry_index.Bl2kuNOo.js} +14 -16
  20. package/cjs/{fthry_index.Feu6uyn6.js → fthry_index.BmT77CVY.js} +2 -2
  21. package/cjs/{fthry_index.Bn7LKMrK.js → fthry_index.Bsklltx4.js} +1 -1
  22. package/cjs/{fthry_index.C_qw3SH5.js → fthry_index.BuQ1HIIN.js} +8 -8
  23. package/cjs/{fthry_index.CLTU9AAQ.js → fthry_index.C6-dnyHD.js} +1 -1
  24. package/cjs/{fthry_index.yAmVGVxf.js → fthry_index.CSwhuTPY.js} +1 -1
  25. package/cjs/{fthry_index.CBucgTSF.js → fthry_index.CTqVrxjv.js} +1 -1
  26. package/cjs/{fthry_index.mj0_Tc2V.js → fthry_index.CWofoHQs.js} +4 -4
  27. package/cjs/{fthry_index.Bo0inH5r.js → fthry_index.CbASwLjr.js} +1 -1
  28. package/cjs/{fthry_index.DH3KDEwG.js → fthry_index.D36o5hns.js} +5 -5
  29. package/cjs/{fthry_index.D5CGTQKa.js → fthry_index.DGctX9WE.js} +5 -5
  30. package/cjs/fthry_index.DKgFa6Cd.js +7245 -0
  31. package/cjs/{fthry_index.DVrmPZ9A.js → fthry_index.Jp2CJ4is.js} +2 -2
  32. package/cjs/{fthry_index.DYqW71E8.js → fthry_index.Nrwqiq0j.js} +5 -5
  33. package/cjs/{fthry_index.Dje6TQOt.js → fthry_index._iQAHcD9.js} +1307 -1273
  34. package/cjs/{fthry_index.DT82qJhW.js → fthry_index.dGUMsRB1.js} +4 -4
  35. package/cjs/{fthry_index.h9jJa8zh.js → fthry_index.jot4NArP.js} +3 -3
  36. package/cjs/{fthry_index.DQZt7KIS.js → fthry_index.lGGMSnRj.js} +1 -1
  37. package/cjs/{fthry_index.xFsG3Jma.js → fthry_index.mEUshDAA.js} +1 -1
  38. package/cjs/{fthry_input.C7oRNtWz.js → fthry_input.3JtjJgPY.js} +1 -1
  39. package/cjs/{fthry_script.NtkfplNS.js → fthry_script.DOCG8gyM.js} +1 -1
  40. package/cjs/{fthry_styles.CJtigNS-.js → fthry_styles.CVqE6wer.js} +1 -1
  41. package/cjs/{fthry_useElementSize.B3LEGWLi.js → fthry_useElementSize.B5-XFuix.js} +1 -1
  42. package/cjs/{fthry_useSalesforceSync.CUVT8Mvb.js → fthry_useSalesforceSync.D9f_IkFv.js} +1 -1
  43. package/cjs/{fthry_webfontloader.Dgu1OvOA.js → fthry_webfontloader.5X-HEWHN.js} +1 -1
  44. package/cjs/index.js +1 -1
  45. package/cjs/utils/validation.d.ts +4 -3
  46. package/cjs/utils/validation.d.ts.map +1 -1
  47. package/dist/Form/index.d.ts.map +1 -1
  48. package/dist/auth/internal/utils.d.ts.map +1 -1
  49. package/dist/elements/fields/PhoneField/CountryDropdown.d.ts.map +1 -1
  50. package/dist/elements/fields/PhoneField/index.d.ts.map +1 -1
  51. package/dist/elements/fields/PhoneField/tests/test-utils.d.ts.map +1 -1
  52. package/dist/{fthry_FormControl.DZ-yelpB.js → fthry_FormControl.Bt83gTi3.js} +1 -1
  53. package/dist/{fthry_InlineTooltip.C-94aZft.js → fthry_InlineTooltip.BADFGh_F.js} +2 -2
  54. package/dist/{fthry_Overlay.D60Mo5sc.js → fthry_Overlay.CsBPXuR_.js} +1 -1
  55. package/dist/{fthry_PaymentMethodField.DOD4xxBf.js → fthry_PaymentMethodField.CVKE3t_i.js} +4 -4
  56. package/dist/{fthry_Placeholder.Q6LOYgfy.js → fthry_Placeholder.9MqCxqHS.js} +1 -1
  57. package/dist/{fthry_ShowEyeIcon.DudVwlqL.js → fthry_ShowEyeIcon.CxXoA4_B.js} +1 -1
  58. package/dist/{fthry_index.BIezS_Js.js → fthry_index.5oEnjTzQ.js} +3 -3
  59. package/dist/{fthry_index.D_445pef.js → fthry_index.7TulZeVg.js} +6 -6
  60. package/dist/{fthry_index.BbQn1vco.js → fthry_index.AdQD-dII.js} +1 -1
  61. package/dist/{fthry_index.LLvosXZC.js → fthry_index.B0_n9jqc.js} +4 -4
  62. package/dist/{fthry_index.hD4VI9ak.js → fthry_index.BIkyi9OD.js} +4 -4
  63. package/dist/{fthry_index.DhrE0rpb.js → fthry_index.BPmvHG0R.js} +1 -1
  64. package/dist/{fthry_index.CA8KDA0W.js → fthry_index.BQTGcd6O.js} +8 -8
  65. package/dist/{fthry_index.BykB3HX8.js → fthry_index.BbSZxIR5.js} +2 -2
  66. package/dist/{fthry_index.DITsZWwh.js → fthry_index.Beh4LhUb.js} +4 -4
  67. package/dist/{fthry_index.C1kvOEHl.js → fthry_index.C0FNSGu0.js} +5 -5
  68. package/dist/{fthry_index.Ce0LfPTs.js → fthry_index.C4cVkdmR.js} +5 -5
  69. package/dist/{fthry_index.7fQDnsUX.js → fthry_index.CefyT_Xy.js} +3 -3
  70. package/dist/{fthry_index.BJXPVhqn.js → fthry_index.CnNPiyfF.js} +6 -6
  71. package/dist/{fthry_index.BbESsk-g.js → fthry_index.CsQzji9M.js} +1 -1
  72. package/dist/{fthry_index.BJAdYqCo.js → fthry_index.Cy8OGyJ9.js} +14 -16
  73. package/dist/{fthry_index.LL5LHx6u.js → fthry_index.CyjNCuWE.js} +1 -1
  74. package/dist/{fthry_index.BdHFQJ4O.js → fthry_index.D4ENNIPP.js} +1 -1
  75. package/dist/{fthry_index.saXzLiO5.js → fthry_index.D86GTeP3.js} +6 -6
  76. package/dist/{fthry_index.SaBEl6_L.js → fthry_index.Degy27gw.js} +1 -1
  77. package/dist/{fthry_index.DjoYiCbm.js → fthry_index.DoxZOyru.js} +2 -2
  78. package/dist/{fthry_index.BHl66fdc.js → fthry_index.DpU0lL2P.js} +1 -1
  79. package/dist/{fthry_index.C_ReA4YV.js → fthry_index.Dte366nP.js} +1 -1
  80. package/dist/{fthry_index.hnaQSM0L.js → fthry_index.EFk2iysz.js} +1308 -1274
  81. package/dist/{fthry_index.DqN9FbBz.js → fthry_index.FjbxGNs2.js} +5 -5
  82. package/dist/fthry_index.FxHyaooV.js +7193 -0
  83. package/dist/{fthry_index.E97uBUJr.js → fthry_index.qQius3J9.js} +1 -1
  84. package/dist/{fthry_input.DYl95BsH.js → fthry_input.BMNwRyD_.js} +1 -1
  85. package/dist/{fthry_script.BzxDIntC.js → fthry_script.0KhNn8f9.js} +1 -1
  86. package/dist/{fthry_styles.r3froItr.js → fthry_styles.DtCYeZPi.js} +1 -1
  87. package/dist/{fthry_useElementSize.D0Sv0zhM.js → fthry_useElementSize.fW6iiT11.js} +1 -1
  88. package/dist/{fthry_useSalesforceSync.ijGABR2r.js → fthry_useSalesforceSync.BIkirclp.js} +1 -1
  89. package/dist/{fthry_webfontloader.CI8nQbb6.js → fthry_webfontloader.Dyilj6id.js} +1 -1
  90. package/dist/index.js +1 -1
  91. package/dist/utils/validation.d.ts +4 -3
  92. package/dist/utils/validation.d.ts.map +1 -1
  93. package/package.json +2 -1
  94. package/umd/{PhoneField.f52b5de44614b445feeb.js → PhoneField.42eae8ec161c28522777.js} +1 -1
  95. package/umd/index.js +1 -1
  96. package/umd/libphonenumber.d53d0d1347fa5545ff45.js +1 -0
@@ -17591,373 +17591,726 @@ var isBase64Image = function (string) {
17591
17591
  return BASE64_REGEX.test(string);
17592
17592
  };
17593
17593
 
17594
- var plaidPromise = null;
17595
- function installPlaid(isPlaidActive) {
17596
- if (plaidPromise)
17597
- return plaidPromise;
17598
- else if (!isPlaidActive)
17599
- return Promise.resolve();
17600
- else {
17601
- plaidPromise = dynamicImport('https://cdn.plaid.com/link/v2/stable/link-initialize.js');
17602
- return plaidPromise;
17603
- }
17604
- }
17605
- function openPlaidLink(client, onSuccess, onExit, updateFieldValues, action, handleError) {
17606
- return __awaiter$2(this, void 0, void 0, function () {
17607
- var kwargs, res, handler;
17608
- var _this = this;
17609
- return __generator(this, function (_a) {
17610
- switch (_a.label) {
17611
- case 0: return [4 /*yield*/, plaidPromise];
17612
- case 1:
17613
- _a.sent();
17614
- if (action.plaid_action === 'identity') {
17615
- kwargs = {
17616
- identity_template_id: action.template_id,
17617
- email_field: action.email_field
17618
- };
17619
- }
17620
- else {
17621
- kwargs = { liabilities: action.include_liabilities ? 'true' : 'false' };
17622
- }
17623
- return [4 /*yield*/, client.fetchPlaidLinkToken(kwargs)];
17624
- case 2:
17625
- res = _a.sent();
17626
- if (res.err) {
17627
- handleError(res.err);
17628
- return [2 /*return*/];
17629
- }
17630
- handler = global.Plaid.create({
17631
- token: res.token,
17632
- onExit: onExit,
17633
- onSuccess: function (publicToken, metadata) { return __awaiter$2(_this, void 0, void 0, function () {
17634
- var res_1, statusKey, newValues, res_2, fieldVals;
17635
- var _a;
17636
- var _b;
17637
- return __generator(this, function (_c) {
17638
- switch (_c.label) {
17639
- case 0:
17640
- _c.trys.push([0, 8, 9, 10]);
17641
- if (!(action.plaid_action === 'identity')) return [3 /*break*/, 4];
17642
- return [4 /*yield*/, client.fetchPlaidVerificationStatus(metadata.link_session_id)];
17643
- case 1:
17644
- res_1 = _c.sent();
17645
- statusKey = action.plaid_identity_field_key;
17646
- if (statusKey) {
17647
- newValues = (_a = {}, _a[statusKey] = res_1.status, _a);
17648
- updateFieldValues(newValues);
17649
- client.submitCustom(newValues, { shouldFlush: true });
17650
- }
17651
- if (!(res_1.status !== 'success')) return [3 /*break*/, 3];
17652
- handleError('Identity verification was not successful');
17653
- return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
17654
- case 2:
17655
- _c.sent();
17656
- return [2 /*return*/];
17657
- case 3: return [3 /*break*/, 6];
17658
- case 4:
17659
- if (!publicToken) return [3 /*break*/, 6];
17660
- res_2 = client.submitPlaidUserData(publicToken);
17661
- if (!((_b = action.wait_for_completion) !== null && _b !== void 0 ? _b : true)) return [3 /*break*/, 6];
17662
- return [4 /*yield*/, res_2];
17663
- case 5:
17664
- fieldVals = _c.sent();
17665
- updateFieldValues(fieldVals);
17666
- _c.label = 6;
17667
- case 6: return [4 /*yield*/, onSuccess()];
17668
- case 7:
17669
- _c.sent();
17670
- return [3 /*break*/, 10];
17671
- case 8:
17672
- _c.sent();
17673
- handleError();
17674
- return [3 /*break*/, 10];
17675
- case 9:
17676
- handler.exit();
17677
- handler.destroy();
17678
- return [7 /*endfinally*/];
17679
- case 10: return [2 /*return*/];
17680
- }
17681
- });
17682
- }); }
17683
- });
17684
- handler.open();
17685
- return [2 /*return*/];
17686
- }
17687
- });
17688
- });
17689
- }
17594
+ var isUrl_1;
17595
+ var hasRequiredIsUrl;
17690
17596
 
17691
- var RouterContext = React.createContext({
17692
- location: {
17693
- pathname: ''
17694
- },
17695
- navigate: function () { }
17696
- });
17697
- function RouterProvider(_a) {
17698
- var children = _a.children, _b = _a.initialPath, initialPath = _b === void 0 ? featheryWindow().location.pathname : _b;
17699
- var _c = __read(React.useState({ pathname: initialPath }), 2), location = _c[0], setLocation = _c[1];
17700
- var navigate = React.useCallback(function (to, options) {
17701
- if (options === void 0) { options = {}; }
17702
- var historyMethod = options.replace ? 'replaceState' : 'pushState';
17703
- featheryWindow().history[historyMethod](null, '', to);
17704
- setLocation({ pathname: to });
17705
- }, []);
17706
- // listen to browser back/forward navigation
17707
- React.useEffect(function () {
17708
- var window = featheryWindow();
17709
- var handlePopState = function () {
17710
- setLocation({ pathname: window.location.pathname });
17711
- };
17712
- window.addEventListener('popstate', handlePopState);
17713
- return function () { return window.removeEventListener('popstate', handlePopState); };
17714
- }, []);
17715
- var routerData = React.useMemo(function () { return ({
17716
- location: location,
17717
- navigate: navigate
17718
- }); }, [location, navigate]);
17719
- return (jsx$1(RouterContext.Provider, exports.__assign({ value: routerData }, { children: children })));
17720
- }
17721
- function useLocation() {
17722
- var context = React.useContext(RouterContext);
17723
- if (!context)
17724
- throw new Error('useLocation must be used within RouterProvider');
17725
- return context.location;
17726
- }
17727
- function useNavigate() {
17728
- var context = React.useContext(RouterContext);
17729
- if (!context)
17730
- throw new Error('useNavigate must be used within RouterProvider');
17731
- return context.navigate;
17597
+ function requireIsUrl () {
17598
+ if (hasRequiredIsUrl) return isUrl_1;
17599
+ hasRequiredIsUrl = 1;
17600
+ /**
17601
+ * Expose `isUrl`.
17602
+ */
17603
+
17604
+ isUrl_1 = isUrl;
17605
+
17606
+ /**
17607
+ * RegExps.
17608
+ * A URL must match #1 and then at least one of #2/#3.
17609
+ * Use two levels of REs to avoid REDOS.
17610
+ */
17611
+
17612
+ var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
17613
+
17614
+ var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
17615
+ var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
17616
+
17617
+ /**
17618
+ * Loosely validate a URL `string`.
17619
+ *
17620
+ * @param {String} string
17621
+ * @return {Boolean}
17622
+ */
17623
+
17624
+ function isUrl(string){
17625
+ if (typeof string !== 'string') {
17626
+ return false;
17627
+ }
17628
+
17629
+ var match = string.match(protocolAndDomainRE);
17630
+ if (!match) {
17631
+ return false;
17632
+ }
17633
+
17634
+ var everythingAfterProtocol = match[1];
17635
+ if (!everythingAfterProtocol) {
17636
+ return false;
17637
+ }
17638
+
17639
+ if (localhostDomainRE.test(everythingAfterProtocol) ||
17640
+ nonLocalhostDomainRE.test(everythingAfterProtocol)) {
17641
+ return true;
17642
+ }
17643
+
17644
+ return false;
17645
+ }
17646
+ return isUrl_1;
17732
17647
  }
17733
17648
 
17734
- var MIN_AXIS_SIZE = 15;
17735
- var FIT = 'fit';
17736
- var FILL = 'fill';
17737
- var isFill = function (v) { return v === FILL; };
17738
- var isFit = function (v) { return v === FIT; };
17739
- var isPx = function (v) {
17740
- return typeof v === 'string' && v.indexOf('px') >= 0 && v.indexOf('calc') < 0;
17741
- };
17742
- var getPxValue = function (size) {
17743
- return isPx(size) ? Number.parseFloat(size) : MIN_AXIS_SIZE;
17744
- };
17745
- var formatDimensionValue = function (value, type) {
17746
- // fit-content is needed to allow elements to push beyond the parent container's explicit height.
17747
- switch (value) {
17748
- case FILL:
17749
- return type === 'width' ? '100%' : 'auto';
17750
- case FIT:
17751
- return 'fit-content';
17752
- default:
17753
- return parseInt(value);
17754
- }
17755
- };
17756
- var calculateDimensionsHelper = function (root, p) {
17757
- if (p === void 0) { p = ''; }
17758
- var width = root["".concat(p, "width")] || root.width;
17759
- var height = root["".concat(p, "height")] || root.height;
17760
- var dimensions = {
17761
- maxWidth: formatDimensionValue(width, 'width'),
17762
- height: formatDimensionValue(height, 'height')
17763
- };
17764
- // to allow responsiveness, min width shouldn't be set for fixed widths
17765
- dimensions.minWidth = isNum(width) ? undefined : dimensions.maxWidth;
17766
- // min and max height must be 100% to prevent fit-content from collapsing, which would break fill's non-collapsing intent
17767
- dimensions.minHeight = isFill(height) ? '100%' : dimensions.height;
17768
- return dimensions;
17769
- };
17649
+ var isUrlExports = requireIsUrl();
17650
+ var isUrl = /*@__PURE__*/getDefaultExportFromCjs(isUrlExports);
17651
+
17652
+ var LETTER_MATCH = /[a-zA-Z]/;
17653
+ var UPPERCASE_LETTER_MATCH = /[A-Z]/;
17654
+ var LOWERCASE_LETTER_MATCH = /[a-z]/;
17655
+ var NUMBER_MATCH = /\d/;
17656
+ // eslint-disable-next-line no-useless-escape
17657
+ var SYMBOL_MATCH = /[#$\.%&'()\+,-/:;<=>!?@\\\[\]\^_`{|}~\*]/;
17658
+ var DOMAIN_ALLOWED_CHARACTERS = /^[a-zA-Z0-9.\\-]+$/;
17770
17659
  /**
17771
- * Calculates the dimensions of the provided step.
17772
- * Note: The provided step should be fully-hydrated (i.e. rows injected, etc.) to calculate dimensions accurately.
17660
+ * Validate elements on a form
17773
17661
  */
17774
- function calculateStepCSS(step) {
17775
- if (!step)
17776
- return {};
17777
- var root = step.subgrids.find(function (grid) { return grid.position.length === 0; });
17778
- var desktop = calculateDimensionsHelper(root);
17779
- var mobile = calculateDimensionsHelper(root, 'mobile_');
17780
- var stepCSS = exports.__assign({ backgroundSize: 'cover', width: '100%' }, desktop);
17781
- // width will be controlled by maxWidth in the case it is fixed below 478px
17782
- stepCSS["@media (max-width: 478px)"] = exports.__assign({ width: '100%' }, mobile);
17783
- return stepCSS;
17784
- }
17785
- function calculateGlobalCSS(globalStyles) {
17786
- var styles = new ResponsiveStyles({ styles: globalStyles }, ['form'], false, DEFAULT_MOBILE_BREAKPOINT);
17787
- if (globalStyles) {
17788
- styles.applyFontStyles('form');
17789
- }
17790
- return styles;
17791
- }
17792
-
17793
- function changeStep(newKey, oldKey, steps, setStepKey, navigate, client, trackHashes) {
17794
- var sameKey = oldKey === newKey;
17795
- if (!sameKey && newKey) {
17796
- if (newKey in steps) {
17797
- client.registerEvent({
17798
- step_key: oldKey,
17799
- next_step_key: newKey,
17800
- event: 'complete'
17801
- });
17802
- if (trackHashes)
17803
- navigate(location.pathname + location.search + "#".concat(newKey), {
17804
- replace: true
17805
- });
17806
- setStepKey(newKey);
17807
- return true;
17662
+ function validateElements(_a) {
17663
+ 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;
17664
+ var invalid = false;
17665
+ var inlineErrors = {};
17666
+ var errors = getVisibleElements(step, visiblePositions, ['servar_fields', 'buttons'], true).reduce(function (errors, _a) {
17667
+ var _b;
17668
+ var element = _a.element, repeat = _a.repeat, last = _a.last, elementType = _a.type;
17669
+ var key, type;
17670
+ if (elementType === 'servar_fields') {
17671
+ if (element.servar.repeat_trigger === 'set_value' && last && repeat) {
17672
+ // Skip validation on last repeat since it might be default value
17673
+ return errors;
17674
+ }
17675
+ type = element.servar.type;
17676
+ key = element.servar.key;
17677
+ }
17678
+ else {
17679
+ // if not a servar, then a button
17680
+ type = 'button';
17681
+ key = element.id;
17808
17682
  }
17683
+ var message = validateElement(element, repeat);
17684
+ // We want to clear button errors when the button is not "relevant" to what the user is doing.
17685
+ // If the element is a button and was NOT the trigger or no trigger,
17686
+ // then we don't show the error.
17687
+ if (type === 'button' && ((trigger && key !== trigger.id) || !trigger))
17688
+ message = '';
17689
+ if (!(key in errors))
17690
+ errors[key] = message;
17691
+ else if (Array.isArray(errors[key]))
17692
+ errors[key].push(message);
17809
17693
  else
17810
- console.warn("".concat(newKey, " is not a valid step to navigate to"));
17811
- }
17812
- return false;
17813
- }
17814
- function getNewStepUrl(stepKey) {
17815
- return location.pathname + location.search + "#".concat(stepKey);
17816
- }
17817
- function getPrevStepKey(curStep, stepMap) {
17818
- var newStepKey = stepMap[curStep.key];
17819
- if (!newStepKey) {
17820
- var prevCondition = curStep.previous_conditions[0];
17821
- if (prevCondition)
17822
- newStepKey = prevCondition.previous_step_key;
17694
+ errors[key] = [errors[key], message];
17695
+ if (message && !invalid)
17696
+ invalid = true;
17697
+ if (type === 'matrix' && message) {
17698
+ // Get question index where error is
17699
+ var fieldValue = exports.fieldValues[key];
17700
+ // handle repeated matrix fields
17701
+ if (repeat != null && Array.isArray(fieldValue))
17702
+ fieldValue = (_b = fieldValue[repeat]) !== null && _b !== void 0 ? _b : {};
17703
+ var questions = element.servar.metadata.questions;
17704
+ var questionIds = questions.map(function (q) { return q.id; });
17705
+ for (var i = 0; i < questionIds.length; i++) {
17706
+ var value = fieldValue[questionIds[i]];
17707
+ if (value === undefined ||
17708
+ (Array.isArray(value) && value.length === 0)) {
17709
+ key = "".concat(key, "-").concat(i);
17710
+ break;
17711
+ }
17712
+ }
17713
+ }
17714
+ if (triggerErrors) {
17715
+ setFormElementError({
17716
+ formRef: formRef,
17717
+ errorCallback: errorCallback,
17718
+ fieldKey: key,
17719
+ message: message,
17720
+ errorType: errorType,
17721
+ servarType: type,
17722
+ inlineErrors: inlineErrors,
17723
+ index: repeat
17724
+ });
17725
+ }
17726
+ return errors;
17727
+ }, {});
17728
+ if (triggerErrors) {
17729
+ setFormElementError({
17730
+ formRef: formRef,
17731
+ errorType: errorType,
17732
+ inlineErrors: inlineErrors,
17733
+ setInlineErrors: setInlineErrors,
17734
+ triggerErrors: true
17735
+ });
17823
17736
  }
17824
- return newStepKey;
17737
+ return { errors: errors, inlineErrors: inlineErrors, invalid: invalid };
17825
17738
  }
17826
- var nextStepKey = function (nextConditions, metadata) {
17827
- var newKey = null;
17828
- nextConditions
17829
- .filter(function (cond) {
17830
- return cond.element_type === metadata.elementType &&
17831
- metadata.elementIDs.includes(cond.element_id) &&
17832
- cond.metadata.start === metadata.start &&
17833
- cond.metadata.end === metadata.end;
17834
- })
17835
- .sort(function (cond1, cond2) {
17836
- return cond1.rules.length < cond2.rules.length ? 1 : -1;
17837
- })
17838
- .forEach(function (cond) {
17839
- if (newKey)
17840
- return;
17841
- var rulesMet = true;
17842
- cond.rules.forEach(function (rule) {
17843
- rulesMet && (rulesMet = evalComparisonRule(rule));
17844
- });
17845
- if (rulesMet)
17846
- newKey = cond.next_step_key;
17847
- });
17848
- return newKey;
17849
- };
17850
- // No origin is possible if there are no steps, e.g. form is disabled
17851
- var NO_ORIGIN_DEFAULT = { key: '' };
17852
- var getOrigin = function (steps) {
17853
- var _a;
17854
- return (_a = Object.values(steps).find(function (step) { return step.origin; })) !== null && _a !== void 0 ? _a : NO_ORIGIN_DEFAULT;
17855
- };
17856
17739
  /**
17857
- *
17858
- * @returns Url hash without the #, or '' if decodeURI fails
17740
+ * Performs all default/standard and custom validations on a field/element
17741
+ * and returns any validation message.
17859
17742
  */
17860
- function getUrlHash() {
17861
- try {
17862
- return decodeURI(location.hash.substr(1));
17863
- }
17864
- catch (e) {
17865
- console.warn(e);
17866
- return '';
17867
- }
17868
- }
17869
- function setUrlStepHash(navigate, steps, stepName) {
17870
- // No hash necessary if form only has one step
17871
- if (Object.keys(steps).length > 1) {
17872
- navigate(location.pathname + location.search + "#".concat(stepName), {
17873
- replace: true
17743
+ function validateElement(element, repeat) {
17744
+ var servar = element.servar, validations = element.validations;
17745
+ // First priority is custom validations for servar fields
17746
+ if (validations) {
17747
+ var firstMatchingValidation = validations.find(function (validation) {
17748
+ return validation.rules.every(function (rule) { return evalComparisonRule(rule, repeat); });
17874
17749
  });
17750
+ if (firstMatchingValidation)
17751
+ return firstMatchingValidation.message;
17875
17752
  }
17876
- }
17877
- function getInitialStep(_a) {
17878
- var initialStepId = _a.initialStepId, steps = _a.steps, sessionCurrentStep = _a.sessionCurrentStep, formId = _a.formId;
17879
- return ((formId && getSavedStepKey(formId)) || // saved step from remounting
17880
- initialStepId ||
17881
- sessionCurrentStep ||
17882
- getOrigin(steps).key);
17883
- }
17884
- // Store current step keys for each form during remount
17885
- var savedStepKeys = {};
17886
- function getSavedStepKey(formId) {
17887
- var savedKey = savedStepKeys[formId];
17888
- if (savedKey) {
17889
- delete savedStepKeys[formId];
17890
- return savedKey;
17753
+ // Now apply any standard validations
17754
+ if (servar) {
17755
+ var fieldVal = exports.fieldValues[servar.key];
17756
+ if (servar.repeated)
17757
+ fieldVal = fieldVal[repeat];
17758
+ var errorMsg = getStandardFieldError(fieldVal, servar, repeat);
17759
+ if (errorMsg)
17760
+ return errorMsg;
17891
17761
  }
17892
- return undefined;
17893
- }
17894
- function setSavedStepKey(formId, stepKey) {
17895
- savedStepKeys[formId] = stepKey;
17762
+ return '';
17896
17763
  }
17897
- function isStepTerminal(step) {
17898
- // If step is navigable to another step, it's not terminal
17899
- if (step.next_conditions.length > 0)
17900
- return false;
17901
- if (step.servar_fields.some(function (field) { return field.servar.required; }) &&
17902
- step.buttons.some(function (b) { return b.properties.submit; })) {
17903
- // Not terminal if there is a required field on the step that can be saved
17904
- return false;
17905
- }
17906
- var onlyExits = ['buttons', 'texts', 'subgrids'].every(function (key) {
17907
- return step[key].every(function (b) {
17908
- var _a;
17909
- return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).every(function (action) { return action.type === ACTION_URL; });
17910
- });
17911
- });
17912
- if (onlyExits && step.servar_fields.length === 0)
17913
- return true;
17914
- var hasNext = step.buttons.some(function (b) {
17915
- var _a;
17916
- return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).some(function (action) {
17917
- return action.type === ACTION_NEXT ||
17918
- (action.type === ACTION_URL && !action.open_tab);
17919
- });
17764
+ //
17765
+ // Standard Validations
17766
+ //
17767
+ var emailPatternStr = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]{2,63})+$";
17768
+ var emailPattern = new RegExp(emailPatternStr);
17769
+ exports.phoneLib = null;
17770
+ exports.phoneLibPromise = Promise.resolve();
17771
+ var loadPhoneValidator = function () {
17772
+ exports.phoneLibPromise = Promise.resolve().then(function () { return require(
17773
+ /* webpackChunkName: "libphonenumber" */ './fthry_index.DKgFa6Cd.js'); }).then(function (mod) {
17774
+ exports.phoneLib = mod;
17775
+ return mod;
17920
17776
  });
17921
- return !hasNext;
17922
- }
17923
- function _recurseQueue(depthMap, steps, hasProgressBar, queue, altQueue) {
17924
- var _loop_1 = function () {
17925
- var _a = __read(queue.shift(), 2), step = _a[0], depth = _a[1];
17926
- if (step.key in depthMap)
17927
- return "continue";
17928
- // Optionally filter only for steps with progress bar
17929
- var missingBar = hasProgressBar && step.progress_bars.length === 0;
17930
- depthMap[step.key] = missingBar ? 0 : depth;
17931
- var incr = missingBar ? 0 : 1;
17932
- step.next_conditions.forEach(function (condition) {
17933
- queue.push([steps[condition.next_step_key], depth + incr]);
17934
- });
17935
- // For calculating progress bar depth, deprioritize previous condition
17936
- // depths relative to next conditions
17937
- var previousQueue = hasProgressBar && altQueue ? altQueue : queue;
17938
- step.previous_conditions.forEach(function (condition) {
17939
- previousQueue.push([steps[condition.previous_step_key], depth + incr]);
17940
- });
17941
- };
17942
- while (queue.length > 0) {
17943
- _loop_1();
17944
- }
17945
- }
17946
- var getStepDepthMap = function (steps, hasProgressBar) {
17947
- if (hasProgressBar === void 0) { hasProgressBar = false; }
17948
- var depthMap = {};
17949
- var stepQueue = [[getOrigin(steps), 0]];
17950
- var reverseQueue = [];
17951
- _recurseQueue(depthMap, steps, hasProgressBar, stepQueue, reverseQueue);
17952
- if (hasProgressBar)
17953
- _recurseQueue(depthMap, steps, hasProgressBar, reverseQueue);
17954
- return depthMap;
17955
17777
  };
17956
- var recurseProgressDepth = function (steps, curKey) {
17957
- var depthMap = getStepDepthMap(steps, true);
17958
- return [depthMap[curKey], Math.max.apply(Math, __spreadArray([], __read(Object.values(depthMap)), false))];
17959
- };
17960
-
17778
+ var validators = {
17779
+ email: function (a) {
17780
+ if (!a)
17781
+ return false;
17782
+ var parts = a.split('@');
17783
+ if (parts.length !== 2)
17784
+ return false;
17785
+ // Email handle cannot end with '.'
17786
+ var part = parts[0];
17787
+ if (part.endsWith('.') || part.startsWith('.'))
17788
+ return false;
17789
+ if (part.includes('..'))
17790
+ return false;
17791
+ return emailPattern.test(a);
17792
+ },
17793
+ phone: function (a) {
17794
+ try {
17795
+ return exports.phoneLib.isValidPhoneNumber("+".concat(a));
17796
+ }
17797
+ catch (e) {
17798
+ // Invalid phone number
17799
+ return false;
17800
+ }
17801
+ },
17802
+ url: function (a) {
17803
+ if (!isUrl(a))
17804
+ return false;
17805
+ try {
17806
+ var urlObj = new URL(a);
17807
+ if (!urlObj)
17808
+ return false;
17809
+ var hostname = urlObj.hostname;
17810
+ if (hostname.length >= 64)
17811
+ return false;
17812
+ if (!DOMAIN_ALLOWED_CHARACTERS.test(hostname))
17813
+ return false;
17814
+ var parts = hostname.split('.');
17815
+ if (parts.some(function (part) { return !part; }))
17816
+ return false;
17817
+ // Last part of domain cannot contain digit
17818
+ if (NUMBER_MATCH.test(parts[parts.length - 1]))
17819
+ return false;
17820
+ // Colon at end of hostname gets filtered out by URL object but
17821
+ // should be invalid
17822
+ if (a[urlObj.origin.length] === ':')
17823
+ return false;
17824
+ // Check for filtered out special characters, e.g.
17825
+ // https://@google.com -> https://google.com
17826
+ if (!a.toLowerCase().includes("/".concat(hostname.toLowerCase())))
17827
+ return false;
17828
+ return parts.length > 1;
17829
+ }
17830
+ catch (e) {
17831
+ return false;
17832
+ }
17833
+ }
17834
+ };
17835
+ function isFieldValueEmpty(value, servar) {
17836
+ var _a;
17837
+ if (ARRAY_FIELD_TYPES.includes(servar.type)) {
17838
+ if (!value || value.length === 0)
17839
+ return true;
17840
+ // For file uploads and button groups, check if array contains only null/falsy values
17841
+ if (['file_upload', 'button_group'].includes(servar.type)) {
17842
+ // In repeatable containers, file upload values are stored as individual Files (not arrays)
17843
+ // because changeValue extracts value[0] for each row. Handle both cases:
17844
+ if (!Array.isArray(value)) {
17845
+ return !value; // Single file or null (from repeatable container)
17846
+ }
17847
+ if (value.every(function (val) { return !val; })) {
17848
+ return true;
17849
+ }
17850
+ }
17851
+ // If 'other' is selected for checkbox group, make sure it has a value
17852
+ return servar.type === 'multiselect' && value.some(function (val) { return !val; });
17853
+ }
17854
+ var noVal;
17855
+ switch (servar.type) {
17856
+ case 'matrix':
17857
+ // Each key in value needs to have an array with at least one value
17858
+ noVal = servar.metadata.questions.some(function (_a) {
17859
+ var id = _a.id;
17860
+ return !value[id] || value[id].length === 0;
17861
+ });
17862
+ break;
17863
+ case 'select':
17864
+ case 'signature':
17865
+ noVal = !value;
17866
+ break;
17867
+ case 'checkbox':
17868
+ // eslint-disable-next-line camelcase
17869
+ noVal = !value && ((_a = servar.metadata) === null || _a === void 0 ? void 0 : _a.must_check);
17870
+ break;
17871
+ case 'payment_method':
17872
+ noVal = !(value === null || value === void 0 ? void 0 : value.complete);
17873
+ break;
17874
+ case 'rating':
17875
+ noVal = !value;
17876
+ break;
17877
+ default:
17878
+ if (typeof value === 'string')
17879
+ value = value.trim();
17880
+ noVal = ['', null, undefined].includes(value);
17881
+ break;
17882
+ }
17883
+ return noVal;
17884
+ }
17885
+ /**
17886
+ * Default validations.
17887
+ * Returns the error message for a field value if it's invalid.
17888
+ * Returns an empty string if it's valid.
17889
+ */
17890
+ function getStandardFieldError(value, servar, repeat) {
17891
+ var defaultErrors = initInfo().defaultErrors;
17892
+ if (isFieldValueEmpty(value, servar)) {
17893
+ // If no value, error if field is required
17894
+ return servar.required ? defaultErrors.required : '';
17895
+ }
17896
+ if (servar.min_length && value.length < servar.min_length) {
17897
+ return defaultErrors.minimum.replace('{length}', servar.min_length);
17898
+ }
17899
+ var defaultErr = defaultErrors[servar.type];
17900
+ // Check if value is badly formatted
17901
+ if (servar.type === 'phone_number' && !validators.phone(value)) {
17902
+ return defaultErr;
17903
+ }
17904
+ else if (servar.type === 'email' && !validators.email(value)) {
17905
+ return defaultErr;
17906
+ }
17907
+ else if (servar.type === 'url' && !validators.url(value)) {
17908
+ // Try appending https since user may have just omitted the protocol
17909
+ var newVal = 'https://' + value;
17910
+ if (validators.url(newVal)) {
17911
+ if (servar.repeated) {
17912
+ // @ts-ignore
17913
+ exports.fieldValues[servar === null || servar === void 0 ? void 0 : servar.key][repeat] = newVal;
17914
+ }
17915
+ else
17916
+ exports.fieldValues[servar.key] = newVal;
17917
+ return '';
17918
+ }
17919
+ return defaultErr;
17920
+ }
17921
+ else if (servar.type === 'ssn' &&
17922
+ value.length !== (servar.metadata.last_four_digits ? 4 : 9)) {
17923
+ return defaultErr;
17924
+ }
17925
+ else if (servar.type === 'pin_input' &&
17926
+ value.length !== servar.max_length) {
17927
+ return defaultErr;
17928
+ }
17929
+ else if (servar.type === 'password') {
17930
+ var meta = servar.metadata;
17931
+ var msg = function (key) { return "Your password must have at least 1 ".concat(key); };
17932
+ if (meta.letter_required && !LETTER_MATCH.test(value))
17933
+ return msg('letter');
17934
+ if (meta.uppercase_letter_required && !UPPERCASE_LETTER_MATCH.test(value))
17935
+ return msg('uppercase letter');
17936
+ if (meta.lowercase_letter_required && !LOWERCASE_LETTER_MATCH.test(value))
17937
+ return msg('lowercase letter');
17938
+ if (meta.number_required && !NUMBER_MATCH.test(value))
17939
+ return msg('number');
17940
+ if (meta.symbol_required && !SYMBOL_MATCH.test(value))
17941
+ return msg('symbol');
17942
+ }
17943
+ // No error
17944
+ return '';
17945
+ }
17946
+
17947
+ var plaidPromise = null;
17948
+ function installPlaid(isPlaidActive) {
17949
+ if (plaidPromise)
17950
+ return plaidPromise;
17951
+ else if (!isPlaidActive)
17952
+ return Promise.resolve();
17953
+ else {
17954
+ plaidPromise = dynamicImport('https://cdn.plaid.com/link/v2/stable/link-initialize.js');
17955
+ return plaidPromise;
17956
+ }
17957
+ }
17958
+ function openPlaidLink(client, onSuccess, onExit, updateFieldValues, action, handleError) {
17959
+ return __awaiter$2(this, void 0, void 0, function () {
17960
+ var kwargs, res, handler;
17961
+ var _this = this;
17962
+ return __generator(this, function (_a) {
17963
+ switch (_a.label) {
17964
+ case 0: return [4 /*yield*/, plaidPromise];
17965
+ case 1:
17966
+ _a.sent();
17967
+ if (action.plaid_action === 'identity') {
17968
+ kwargs = {
17969
+ identity_template_id: action.template_id,
17970
+ email_field: action.email_field
17971
+ };
17972
+ }
17973
+ else {
17974
+ kwargs = { liabilities: action.include_liabilities ? 'true' : 'false' };
17975
+ }
17976
+ return [4 /*yield*/, client.fetchPlaidLinkToken(kwargs)];
17977
+ case 2:
17978
+ res = _a.sent();
17979
+ if (res.err) {
17980
+ handleError(res.err);
17981
+ return [2 /*return*/];
17982
+ }
17983
+ handler = global.Plaid.create({
17984
+ token: res.token,
17985
+ onExit: onExit,
17986
+ onSuccess: function (publicToken, metadata) { return __awaiter$2(_this, void 0, void 0, function () {
17987
+ var res_1, statusKey, newValues, res_2, fieldVals;
17988
+ var _a;
17989
+ var _b;
17990
+ return __generator(this, function (_c) {
17991
+ switch (_c.label) {
17992
+ case 0:
17993
+ _c.trys.push([0, 8, 9, 10]);
17994
+ if (!(action.plaid_action === 'identity')) return [3 /*break*/, 4];
17995
+ return [4 /*yield*/, client.fetchPlaidVerificationStatus(metadata.link_session_id)];
17996
+ case 1:
17997
+ res_1 = _c.sent();
17998
+ statusKey = action.plaid_identity_field_key;
17999
+ if (statusKey) {
18000
+ newValues = (_a = {}, _a[statusKey] = res_1.status, _a);
18001
+ updateFieldValues(newValues);
18002
+ client.submitCustom(newValues, { shouldFlush: true });
18003
+ }
18004
+ if (!(res_1.status !== 'success')) return [3 /*break*/, 3];
18005
+ handleError('Identity verification was not successful');
18006
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
18007
+ case 2:
18008
+ _c.sent();
18009
+ return [2 /*return*/];
18010
+ case 3: return [3 /*break*/, 6];
18011
+ case 4:
18012
+ if (!publicToken) return [3 /*break*/, 6];
18013
+ res_2 = client.submitPlaidUserData(publicToken);
18014
+ if (!((_b = action.wait_for_completion) !== null && _b !== void 0 ? _b : true)) return [3 /*break*/, 6];
18015
+ return [4 /*yield*/, res_2];
18016
+ case 5:
18017
+ fieldVals = _c.sent();
18018
+ updateFieldValues(fieldVals);
18019
+ _c.label = 6;
18020
+ case 6: return [4 /*yield*/, onSuccess()];
18021
+ case 7:
18022
+ _c.sent();
18023
+ return [3 /*break*/, 10];
18024
+ case 8:
18025
+ _c.sent();
18026
+ handleError();
18027
+ return [3 /*break*/, 10];
18028
+ case 9:
18029
+ handler.exit();
18030
+ handler.destroy();
18031
+ return [7 /*endfinally*/];
18032
+ case 10: return [2 /*return*/];
18033
+ }
18034
+ });
18035
+ }); }
18036
+ });
18037
+ handler.open();
18038
+ return [2 /*return*/];
18039
+ }
18040
+ });
18041
+ });
18042
+ }
18043
+
18044
+ var RouterContext = React.createContext({
18045
+ location: {
18046
+ pathname: ''
18047
+ },
18048
+ navigate: function () { }
18049
+ });
18050
+ function RouterProvider(_a) {
18051
+ var children = _a.children, _b = _a.initialPath, initialPath = _b === void 0 ? featheryWindow().location.pathname : _b;
18052
+ var _c = __read(React.useState({ pathname: initialPath }), 2), location = _c[0], setLocation = _c[1];
18053
+ var navigate = React.useCallback(function (to, options) {
18054
+ if (options === void 0) { options = {}; }
18055
+ var historyMethod = options.replace ? 'replaceState' : 'pushState';
18056
+ featheryWindow().history[historyMethod](null, '', to);
18057
+ setLocation({ pathname: to });
18058
+ }, []);
18059
+ // listen to browser back/forward navigation
18060
+ React.useEffect(function () {
18061
+ var window = featheryWindow();
18062
+ var handlePopState = function () {
18063
+ setLocation({ pathname: window.location.pathname });
18064
+ };
18065
+ window.addEventListener('popstate', handlePopState);
18066
+ return function () { return window.removeEventListener('popstate', handlePopState); };
18067
+ }, []);
18068
+ var routerData = React.useMemo(function () { return ({
18069
+ location: location,
18070
+ navigate: navigate
18071
+ }); }, [location, navigate]);
18072
+ return (jsx$1(RouterContext.Provider, exports.__assign({ value: routerData }, { children: children })));
18073
+ }
18074
+ function useLocation() {
18075
+ var context = React.useContext(RouterContext);
18076
+ if (!context)
18077
+ throw new Error('useLocation must be used within RouterProvider');
18078
+ return context.location;
18079
+ }
18080
+ function useNavigate() {
18081
+ var context = React.useContext(RouterContext);
18082
+ if (!context)
18083
+ throw new Error('useNavigate must be used within RouterProvider');
18084
+ return context.navigate;
18085
+ }
18086
+
18087
+ var MIN_AXIS_SIZE = 15;
18088
+ var FIT = 'fit';
18089
+ var FILL = 'fill';
18090
+ var isFill = function (v) { return v === FILL; };
18091
+ var isFit = function (v) { return v === FIT; };
18092
+ var isPx = function (v) {
18093
+ return typeof v === 'string' && v.indexOf('px') >= 0 && v.indexOf('calc') < 0;
18094
+ };
18095
+ var getPxValue = function (size) {
18096
+ return isPx(size) ? Number.parseFloat(size) : MIN_AXIS_SIZE;
18097
+ };
18098
+ var formatDimensionValue = function (value, type) {
18099
+ // fit-content is needed to allow elements to push beyond the parent container's explicit height.
18100
+ switch (value) {
18101
+ case FILL:
18102
+ return type === 'width' ? '100%' : 'auto';
18103
+ case FIT:
18104
+ return 'fit-content';
18105
+ default:
18106
+ return parseInt(value);
18107
+ }
18108
+ };
18109
+ var calculateDimensionsHelper = function (root, p) {
18110
+ if (p === void 0) { p = ''; }
18111
+ var width = root["".concat(p, "width")] || root.width;
18112
+ var height = root["".concat(p, "height")] || root.height;
18113
+ var dimensions = {
18114
+ maxWidth: formatDimensionValue(width, 'width'),
18115
+ height: formatDimensionValue(height, 'height')
18116
+ };
18117
+ // to allow responsiveness, min width shouldn't be set for fixed widths
18118
+ dimensions.minWidth = isNum(width) ? undefined : dimensions.maxWidth;
18119
+ // min and max height must be 100% to prevent fit-content from collapsing, which would break fill's non-collapsing intent
18120
+ dimensions.minHeight = isFill(height) ? '100%' : dimensions.height;
18121
+ return dimensions;
18122
+ };
18123
+ /**
18124
+ * Calculates the dimensions of the provided step.
18125
+ * Note: The provided step should be fully-hydrated (i.e. rows injected, etc.) to calculate dimensions accurately.
18126
+ */
18127
+ function calculateStepCSS(step) {
18128
+ if (!step)
18129
+ return {};
18130
+ var root = step.subgrids.find(function (grid) { return grid.position.length === 0; });
18131
+ var desktop = calculateDimensionsHelper(root);
18132
+ var mobile = calculateDimensionsHelper(root, 'mobile_');
18133
+ var stepCSS = exports.__assign({ backgroundSize: 'cover', width: '100%' }, desktop);
18134
+ // width will be controlled by maxWidth in the case it is fixed below 478px
18135
+ stepCSS["@media (max-width: 478px)"] = exports.__assign({ width: '100%' }, mobile);
18136
+ return stepCSS;
18137
+ }
18138
+ function calculateGlobalCSS(globalStyles) {
18139
+ var styles = new ResponsiveStyles({ styles: globalStyles }, ['form'], false, DEFAULT_MOBILE_BREAKPOINT);
18140
+ if (globalStyles) {
18141
+ styles.applyFontStyles('form');
18142
+ }
18143
+ return styles;
18144
+ }
18145
+
18146
+ function changeStep(newKey, oldKey, steps, setStepKey, navigate, client, trackHashes) {
18147
+ var sameKey = oldKey === newKey;
18148
+ if (!sameKey && newKey) {
18149
+ if (newKey in steps) {
18150
+ client.registerEvent({
18151
+ step_key: oldKey,
18152
+ next_step_key: newKey,
18153
+ event: 'complete'
18154
+ });
18155
+ if (trackHashes)
18156
+ navigate(location.pathname + location.search + "#".concat(newKey), {
18157
+ replace: true
18158
+ });
18159
+ setStepKey(newKey);
18160
+ return true;
18161
+ }
18162
+ else
18163
+ console.warn("".concat(newKey, " is not a valid step to navigate to"));
18164
+ }
18165
+ return false;
18166
+ }
18167
+ function getNewStepUrl(stepKey) {
18168
+ return location.pathname + location.search + "#".concat(stepKey);
18169
+ }
18170
+ function getPrevStepKey(curStep, stepMap) {
18171
+ var newStepKey = stepMap[curStep.key];
18172
+ if (!newStepKey) {
18173
+ var prevCondition = curStep.previous_conditions[0];
18174
+ if (prevCondition)
18175
+ newStepKey = prevCondition.previous_step_key;
18176
+ }
18177
+ return newStepKey;
18178
+ }
18179
+ var nextStepKey = function (nextConditions, metadata) {
18180
+ var newKey = null;
18181
+ nextConditions
18182
+ .filter(function (cond) {
18183
+ return cond.element_type === metadata.elementType &&
18184
+ metadata.elementIDs.includes(cond.element_id) &&
18185
+ cond.metadata.start === metadata.start &&
18186
+ cond.metadata.end === metadata.end;
18187
+ })
18188
+ .sort(function (cond1, cond2) {
18189
+ return cond1.rules.length < cond2.rules.length ? 1 : -1;
18190
+ })
18191
+ .forEach(function (cond) {
18192
+ if (newKey)
18193
+ return;
18194
+ var rulesMet = true;
18195
+ cond.rules.forEach(function (rule) {
18196
+ rulesMet && (rulesMet = evalComparisonRule(rule));
18197
+ });
18198
+ if (rulesMet)
18199
+ newKey = cond.next_step_key;
18200
+ });
18201
+ return newKey;
18202
+ };
18203
+ // No origin is possible if there are no steps, e.g. form is disabled
18204
+ var NO_ORIGIN_DEFAULT = { key: '' };
18205
+ var getOrigin = function (steps) {
18206
+ var _a;
18207
+ return (_a = Object.values(steps).find(function (step) { return step.origin; })) !== null && _a !== void 0 ? _a : NO_ORIGIN_DEFAULT;
18208
+ };
18209
+ /**
18210
+ *
18211
+ * @returns Url hash without the #, or '' if decodeURI fails
18212
+ */
18213
+ function getUrlHash() {
18214
+ try {
18215
+ return decodeURI(location.hash.substr(1));
18216
+ }
18217
+ catch (e) {
18218
+ console.warn(e);
18219
+ return '';
18220
+ }
18221
+ }
18222
+ function setUrlStepHash(navigate, steps, stepName) {
18223
+ // No hash necessary if form only has one step
18224
+ if (Object.keys(steps).length > 1) {
18225
+ navigate(location.pathname + location.search + "#".concat(stepName), {
18226
+ replace: true
18227
+ });
18228
+ }
18229
+ }
18230
+ function getInitialStep(_a) {
18231
+ var initialStepId = _a.initialStepId, steps = _a.steps, sessionCurrentStep = _a.sessionCurrentStep, formId = _a.formId;
18232
+ return ((formId && getSavedStepKey(formId)) || // saved step from remounting
18233
+ initialStepId ||
18234
+ sessionCurrentStep ||
18235
+ getOrigin(steps).key);
18236
+ }
18237
+ // Store current step keys for each form during remount
18238
+ var savedStepKeys = {};
18239
+ function getSavedStepKey(formId) {
18240
+ var savedKey = savedStepKeys[formId];
18241
+ if (savedKey) {
18242
+ delete savedStepKeys[formId];
18243
+ return savedKey;
18244
+ }
18245
+ return undefined;
18246
+ }
18247
+ function setSavedStepKey(formId, stepKey) {
18248
+ savedStepKeys[formId] = stepKey;
18249
+ }
18250
+ function isStepTerminal(step) {
18251
+ // If step is navigable to another step, it's not terminal
18252
+ if (step.next_conditions.length > 0)
18253
+ return false;
18254
+ if (step.servar_fields.some(function (field) { return field.servar.required; }) &&
18255
+ step.buttons.some(function (b) { return b.properties.submit; })) {
18256
+ // Not terminal if there is a required field on the step that can be saved
18257
+ return false;
18258
+ }
18259
+ var onlyExits = ['buttons', 'texts', 'subgrids'].every(function (key) {
18260
+ return step[key].every(function (b) {
18261
+ var _a;
18262
+ return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).every(function (action) { return action.type === ACTION_URL; });
18263
+ });
18264
+ });
18265
+ if (onlyExits && step.servar_fields.length === 0)
18266
+ return true;
18267
+ var hasNext = step.buttons.some(function (b) {
18268
+ var _a;
18269
+ return ((_a = b.properties.actions) !== null && _a !== void 0 ? _a : []).some(function (action) {
18270
+ return action.type === ACTION_NEXT ||
18271
+ (action.type === ACTION_URL && !action.open_tab);
18272
+ });
18273
+ });
18274
+ return !hasNext;
18275
+ }
18276
+ function _recurseQueue(depthMap, steps, hasProgressBar, queue, altQueue) {
18277
+ var _loop_1 = function () {
18278
+ var _a = __read(queue.shift(), 2), step = _a[0], depth = _a[1];
18279
+ if (step.key in depthMap)
18280
+ return "continue";
18281
+ // Optionally filter only for steps with progress bar
18282
+ var missingBar = hasProgressBar && step.progress_bars.length === 0;
18283
+ depthMap[step.key] = missingBar ? 0 : depth;
18284
+ var incr = missingBar ? 0 : 1;
18285
+ step.next_conditions.forEach(function (condition) {
18286
+ queue.push([steps[condition.next_step_key], depth + incr]);
18287
+ });
18288
+ // For calculating progress bar depth, deprioritize previous condition
18289
+ // depths relative to next conditions
18290
+ var previousQueue = hasProgressBar && altQueue ? altQueue : queue;
18291
+ step.previous_conditions.forEach(function (condition) {
18292
+ previousQueue.push([steps[condition.previous_step_key], depth + incr]);
18293
+ });
18294
+ };
18295
+ while (queue.length > 0) {
18296
+ _loop_1();
18297
+ }
18298
+ }
18299
+ var getStepDepthMap = function (steps, hasProgressBar) {
18300
+ if (hasProgressBar === void 0) { hasProgressBar = false; }
18301
+ var depthMap = {};
18302
+ var stepQueue = [[getOrigin(steps), 0]];
18303
+ var reverseQueue = [];
18304
+ _recurseQueue(depthMap, steps, hasProgressBar, stepQueue, reverseQueue);
18305
+ if (hasProgressBar)
18306
+ _recurseQueue(depthMap, steps, hasProgressBar, reverseQueue);
18307
+ return depthMap;
18308
+ };
18309
+ var recurseProgressDepth = function (steps, curKey) {
18310
+ var depthMap = getStepDepthMap(steps, true);
18311
+ return [depthMap[curKey], Math.max.apply(Math, __spreadArray([], __read(Object.values(depthMap)), false))];
18312
+ };
18313
+
17961
18314
  var pure$1 = {};
17962
18315
 
17963
18316
  var hasRequiredPure$1;
@@ -28625,12 +28978,21 @@ function hasAuthGatedSteps(integrations) {
28625
28978
  function getRedirectUrl() {
28626
28979
  var _a = featheryWindow().location, origin = _a.origin, pathname = _a.pathname, hash = _a.hash, search = _a.search;
28627
28980
  var queryParams = new URLSearchParams(search);
28981
+ // If no _slug param, extract slug from /to/<slug> path
28982
+ if (!queryParams.has('_slug')) {
28983
+ var toMatch = pathname.match(/\/to\/([^/]+)/);
28984
+ if (toMatch) {
28985
+ queryParams.set('_slug', toMatch[1]);
28986
+ }
28987
+ }
28628
28988
  queryParams.forEach(function (value, key) {
28629
28989
  if (!['_slug'].includes(key))
28630
28990
  queryParams.delete(key);
28631
28991
  });
28992
+ // Strip the /to/<slug> segment
28993
+ var cleanPathname = pathname.replace(/\/to\/[^/]+/, '');
28632
28994
  var queryString = queryParams.has('_slug') ? "?".concat(queryParams) : '';
28633
- return "".concat(origin).concat(pathname).concat(queryString).concat(hash);
28995
+ return "".concat(origin).concat(cleanPathname).concat(queryString).concat(hash);
28634
28996
  }
28635
28997
 
28636
28998
  var stytchPromise = null;
@@ -39096,7 +39458,7 @@ function useTrackUserInteraction(formRef, activeStep, stepKey, formName) {
39096
39458
  }, [activeStep, stepKey, formName]);
39097
39459
  }
39098
39460
 
39099
- var AssistantChat = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "AssistantChat" */ './fthry_index.DQZt7KIS.js'); }); });
39461
+ var AssistantChat = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "AssistantChat" */ './fthry_index.lGGMSnRj.js'); }); });
39100
39462
  var getSubmissionErrorMessage = function (error) {
39101
39463
  if (error instanceof TypeError && error.message === 'Failed to fetch') {
39102
39464
  return 'Unable to upload files. Please check your connection and try again.';
@@ -40003,7 +40365,28 @@ function Form(_a) {
40003
40365
  var newFieldVals_1 = {};
40004
40366
  activeStep.servar_fields.forEach(function (sf) {
40005
40367
  var key = getPositionKey(sf);
40006
- if (!visiblePositions[key][0]) {
40368
+ var flags = visiblePositions[key];
40369
+ var isRepeated = !!getRepeatedContainer(activeStep, sf);
40370
+ if (isRepeated) {
40371
+ var currentVal = exports.fieldValues[sf.servar.key];
40372
+ if (!Array.isArray(currentVal))
40373
+ return;
40374
+ var defaultVal_1 = getDefaultFieldValue(sf);
40375
+ var defaultJson_1 = JSON.stringify(defaultVal_1);
40376
+ var changed_1 = false;
40377
+ var newArray = currentVal.map(function (val, i) {
40378
+ if (i < flags.length &&
40379
+ !flags[i] &&
40380
+ JSON.stringify(val) !== defaultJson_1) {
40381
+ changed_1 = true;
40382
+ return defaultVal_1;
40383
+ }
40384
+ return val;
40385
+ });
40386
+ if (changed_1)
40387
+ newFieldVals_1[sf.servar.key] = newArray;
40388
+ }
40389
+ else if (!flags[0]) {
40007
40390
  var newVal = getDefaultFormFieldValue(sf);
40008
40391
  if (JSON.stringify(newVal) !== JSON.stringify(getFieldValue$1(sf).value)) {
40009
40392
  newFieldVals_1[sf.servar.key] = newVal;
@@ -43673,944 +44056,595 @@ function requireGa4 () {
43673
44056
  Object.keys(rest).filter(function (key) {
43674
44057
  return key.substr(0, "dimension".length) === "dimension";
43675
44058
  }).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());
44059
+ fieldObject[key] = rest[key];
44060
+ });
44061
+ Object.keys(rest).filter(function (key) {
44062
+ return key.substr(0, "metric".length) === "metric";
44063
+ }).forEach(function (key) {
44064
+ fieldObject[key] = rest[key];
44065
+ });
43832
44066
 
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); }
44067
+ _this._gaCommand("send", fieldObject);
44068
+ }
44069
+ });
43834
44070
 
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; }
44071
+ _defineProperty(this, "send", function (fieldObject) {
44072
+ _this._gaCommand("send", fieldObject);
44073
+ });
43836
44074
 
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
- }
44075
+ _defineProperty(this, "pageview", function (path, _, title) {
44076
+ var pathTrim = path === null || path === void 0 ? void 0 : path.trim();
43844
44077
 
43845
- var distExports = requireDist();
43846
- var ReactGA = /*@__PURE__*/getDefaultExportFromCjs(distExports);
44078
+ if (pathTrim === "") {
44079
+ console.warn("path cannot be an empty string in .pageview()");
44080
+ return;
44081
+ }
43847
44082
 
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
- }
44083
+ _this._gaCommand("send", "pageview", pathTrim, {
44084
+ title: title
44085
+ });
44086
+ });
43859
44087
 
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
- }
44088
+ this.reset();
44089
+ }
43897
44090
 
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
- }
44091
+ _createClass(GA4, [{
44092
+ key: "gtag",
44093
+ value: function gtag() {
44094
+ this._gtag.apply(this, arguments);
44095
+ }
44096
+ }, {
44097
+ key: "_appendCustomMap",
44098
+ value: function _appendCustomMap(options) {
44099
+ var legacyDimensionMetric = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
43945
44100
 
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
- }
44101
+ if (!legacyDimensionMetric) {
44102
+ return options;
44103
+ }
43986
44104
 
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
- }
44105
+ if (!options.custom_map) {
44106
+ options.custom_map = {};
44107
+ }
44060
44108
 
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
- }
44109
+ for (var i = 1; i <= 200; i++) {
44110
+ if (!options.custom_map["dimension".concat(i)]) {
44111
+ options.custom_map["dimension".concat(i)] = "dimension".concat(i);
44112
+ }
44111
44113
 
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 exports.fieldValues)) {
44141
- // Not stored yet
44142
- var el = featheryDoc().getElementsByName(fieldKey)[0];
44143
- if (el) {
44144
- var fieldVal = el.value;
44145
- exports.fieldValues[fieldKey] = fieldVal;
44146
- existingFields[fieldKey] = fieldVal;
44147
- }
44148
- }
44149
- });
44150
- }
44114
+ if (!options.custom_map["metric".concat(i)]) {
44115
+ options.custom_map["metric".concat(i)] = "metric".concat(i);
44116
+ }
44117
+ }
44151
44118
 
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 = exports.__assign({}, metadata);
44238
- if (fieldData === null || fieldData === void 0 ? void 0 : fieldData['google-tag-manager'])
44239
- gtmData = exports.__assign(exports.__assign({}, gtmData), fieldData['google-tag-manager']);
44240
- TagManager.dataLayer({ dataLayer: exports.__assign(exports.__assign({}, gtmData), { event: title }) });
44241
- }
44242
- // RudderStack
44243
- if (rudderStackInstalled) {
44244
- var rudderData = exports.__assign({}, metadata);
44245
- if (title === 'FeatheryFormComplete')
44246
- rudderData.fieldData = exports.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 = exports.__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 = exports.__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
- }
44119
+ return options;
44120
+ }
44121
+ /**
44122
+ * @since v1.0.2
44123
+ * @param {string} [path="location.href"]
44124
+ * @param {string[]} [_] unsupported
44125
+ * @param {string} [title="location.pathname"]
44126
+ * @deprecated Use `.send("pageview")` instead
44127
+ */
44128
+
44129
+ }, {
44130
+ key: "outboundLink",
44131
+ value:
44132
+ /**
44133
+ * @since v1.0.6
44134
+ * @param {Object} options
44135
+ * @param {string} options.label
44136
+ * @param {function} hitCallback
44137
+ * @deprecated Use `enhanced measurement` feature in Google Analytics.
44138
+ */
44139
+ function outboundLink(_ref3, hitCallback) {
44140
+ var label = _ref3.label;
44141
+
44142
+ if (typeof hitCallback !== "function") {
44143
+ console.warn("hitCallback function is required");
44144
+ return;
44145
+ }
44146
+
44147
+ if (!label) {
44148
+ console.warn("args.label is required in outboundLink()");
44149
+ return;
44150
+ } // Required Fields
44151
+
44152
+
44153
+ var fieldObject = {
44154
+ hitType: "event",
44155
+ eventCategory: "Outbound",
44156
+ eventAction: "Click",
44157
+ eventLabel: (0, _format["default"])(label)
44158
+ };
44159
+ var safetyCallbackCalled = false;
44160
+
44161
+ var safetyCallback = function safetyCallback() {
44162
+ // This prevents a delayed response from GA
44163
+ // causing hitCallback from being fired twice
44164
+ safetyCallbackCalled = true;
44165
+ hitCallback();
44166
+ }; // Using a timeout to ensure the execution of critical application code
44167
+ // in the case when the GA server might be down
44168
+ // or an ad blocker prevents sending the data
44169
+ // register safety net timeout:
44266
44170
 
44267
- var isUrl_1;
44268
- var hasRequiredIsUrl;
44269
44171
 
44270
- function requireIsUrl () {
44271
- if (hasRequiredIsUrl) return isUrl_1;
44272
- hasRequiredIsUrl = 1;
44273
- /**
44274
- * Expose `isUrl`.
44275
- */
44172
+ var t = setTimeout(safetyCallback, 250);
44276
44173
 
44277
- isUrl_1 = isUrl;
44174
+ var clearableCallbackForGA = function clearableCallbackForGA() {
44175
+ clearTimeout(t);
44278
44176
 
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
- */
44177
+ if (!safetyCallbackCalled) {
44178
+ hitCallback();
44179
+ }
44180
+ };
44284
44181
 
44285
- var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
44182
+ fieldObject.hitCallback = clearableCallbackForGA;
44286
44183
 
44287
- var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
44288
- var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
44184
+ this._gaCommand("send", fieldObject);
44185
+ }
44186
+ }]);
44289
44187
 
44290
- /**
44291
- * Loosely validate a URL `string`.
44292
- *
44293
- * @param {String} string
44294
- * @return {Boolean}
44295
- */
44188
+ return GA4;
44189
+ }();
44296
44190
 
44297
- function isUrl(string){
44298
- if (typeof string !== 'string') {
44299
- return false;
44300
- }
44191
+ exports$1.GA4 = GA4;
44301
44192
 
44302
- var match = string.match(protocolAndDomainRE);
44303
- if (!match) {
44304
- return false;
44305
- }
44193
+ var _default = new GA4();
44306
44194
 
44307
- var everythingAfterProtocol = match[1];
44308
- if (!everythingAfterProtocol) {
44309
- return false;
44310
- }
44195
+ exports$1["default"] = _default;
44196
+ } (ga4));
44197
+ return ga4;
44198
+ }
44311
44199
 
44312
- if (localhostDomainRE.test(everythingAfterProtocol) ||
44313
- nonLocalhostDomainRE.test(everythingAfterProtocol)) {
44314
- return true;
44315
- }
44200
+ var hasRequiredDist;
44316
44201
 
44317
- return false;
44318
- }
44319
- return isUrl_1;
44202
+ function requireDist () {
44203
+ if (hasRequiredDist) return dist;
44204
+ hasRequiredDist = 1;
44205
+ (function (exports$1) {
44206
+
44207
+ 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); }
44208
+
44209
+ Object.defineProperty(exports$1, "__esModule", {
44210
+ value: true
44211
+ });
44212
+ exports$1["default"] = exports$1.ReactGAImplementation = void 0;
44213
+
44214
+ var _ga = _interopRequireWildcard(requireGa4());
44215
+
44216
+ 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); }
44217
+
44218
+ 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; }
44219
+
44220
+ var ReactGAImplementation = _ga.GA4;
44221
+ exports$1.ReactGAImplementation = ReactGAImplementation;
44222
+ var _default = _ga["default"];
44223
+ exports$1["default"] = _default;
44224
+ } (dist));
44225
+ return dist;
44320
44226
  }
44321
44227
 
44322
- var isUrlExports = requireIsUrl();
44323
- var isUrl = /*@__PURE__*/getDefaultExportFromCjs(isUrlExports);
44228
+ var distExports = requireDist();
44229
+ var ReactGA = /*@__PURE__*/getDefaultExportFromCjs(distExports);
44324
44230
 
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;
44231
+ var gaInstalled = false;
44232
+ function installGoogleAnalytics(gaConfig) {
44233
+ if (gaConfig && !gaInstalled) {
44234
+ gaInstalled = true;
44235
+ ReactGA.initialize(gaConfig.metadata.api_key);
44236
+ }
44237
+ return Promise.resolve();
44238
+ }
44239
+ function trackGAEvent(category, action, label) {
44240
+ ReactGA.event({ category: category, action: action, label: label });
44241
+ }
44242
+
44243
+ var heapInstalled = false;
44244
+ function installHeap(heapConfig) {
44245
+ if (heapConfig && !heapInstalled) {
44246
+ heapInstalled = true;
44247
+ featheryWindow().heap = featheryWindow().heap || [];
44248
+ featheryWindow().heap.load = function (e) {
44249
+ featheryWindow().heap.appid = e;
44250
+ featheryWindow().heap.config = {};
44251
+ var r = featheryDoc().createElement('script');
44252
+ r.type = 'text/javascript';
44253
+ r.async = true;
44254
+ r.src = 'https://cdn.heapanalytics.com/js/heap-' + e + '.js';
44255
+ var a = featheryDoc().getElementsByTagName('script')[0];
44256
+ a.parentNode.insertBefore(r, a);
44257
+ for (var n = function (e) {
44258
+ return function () {
44259
+ featheryWindow().heap.push(
44260
+ // eslint-disable-next-line prefer-rest-params
44261
+ [e].concat(Array.prototype.slice.call(arguments, 0)));
44262
+ };
44263
+ }, p = [
44264
+ 'addEventProperties',
44265
+ 'addUserProperties',
44266
+ 'clearEventProperties',
44267
+ 'identify',
44268
+ 'resetIdentity',
44269
+ 'removeEventProperty',
44270
+ 'setEventProperties',
44271
+ 'track',
44272
+ 'unsetEventProperty'
44273
+ ], o = 0; o < p.length; o++)
44274
+ featheryWindow().heap[p[o]] = n(p[o]);
44275
+ };
44276
+ featheryWindow().heap.load(heapConfig.metadata.api_key);
44277
+ }
44278
+ return Promise.resolve();
44279
+ }
44280
+
44281
+ var intercomInstalled = false;
44282
+ function installIntercom(intercomConfig) {
44283
+ if (intercomConfig && !intercomInstalled) {
44284
+ intercomInstalled = true;
44285
+ var workspaceId_1 = intercomConfig.api_key;
44286
+ featheryWindow().intercomSettings = {
44287
+ api_base: 'https://api-iam.intercom.io',
44288
+ app_id: workspaceId_1
44289
+ };
44290
+ var w = featheryWindow();
44291
+ var ic = w.Intercom;
44292
+ if (typeof ic === 'function') {
44293
+ ic('reattach_activator');
44294
+ ic('update', w.intercomSettings);
44350
44295
  }
44351
44296
  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 = exports.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
- }
44297
+ var d_1 = featheryDoc();
44298
+ var i_1 = function () {
44299
+ // eslint-disable-next-line prefer-rest-params
44300
+ i_1.c(arguments);
44301
+ };
44302
+ i_1.q = [];
44303
+ i_1.c = function (args) {
44304
+ i_1.q.push(args);
44305
+ };
44306
+ w.Intercom = i_1;
44307
+ var l = function () {
44308
+ var s = d_1.createElement('script');
44309
+ s.type = 'text/javascript';
44310
+ s.async = true;
44311
+ s.src = "https://widget.intercom.io/widget/".concat(workspaceId_1);
44312
+ var x = d_1.getElementsByTagName('script')[0];
44313
+ x.parentNode.insertBefore(s, x);
44314
+ };
44315
+ if (featheryDoc().readyState === 'complete') {
44316
+ l();
44317
+ }
44318
+ else if (w.attachEvent) {
44319
+ w.attachEvent('onload', l);
44320
+ }
44321
+ else {
44322
+ w.addEventListener('load', l, false);
44385
44323
  }
44386
44324
  }
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
44325
  }
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); });
44326
+ return Promise.resolve();
44327
+ }
44328
+
44329
+ var amplitudeInstalled = false;
44330
+ function installAmplitude(amplitudeConfig) {
44331
+ return __awaiter$2(this, void 0, void 0, function () {
44332
+ var meta, apiKey, cdn, sessionReplayTracking, options;
44333
+ return __generator(this, function (_a) {
44334
+ switch (_a.label) {
44335
+ case 0:
44336
+ if (!amplitudeConfig || amplitudeInstalled)
44337
+ return [2 /*return*/];
44338
+ amplitudeInstalled = true;
44339
+ meta = amplitudeConfig.metadata;
44340
+ apiKey = meta.api_key;
44341
+ cdn = 'cdn';
44342
+ if (meta.eu_server)
44343
+ cdn = 'cdn.eu';
44344
+ return [4 /*yield*/, dynamicImport("https://".concat(cdn, ".amplitude.com/script/").concat(apiKey, ".js"))];
44345
+ case 1:
44346
+ _a.sent();
44347
+ if (!featheryWindow().amplitude) {
44348
+ console.warn('Failed to load Amplitude.');
44349
+ return [2 /*return*/];
44350
+ }
44351
+ if (meta.session_replay && featheryWindow().sessionReplay) {
44352
+ sessionReplayTracking = featheryWindow().sessionReplay.plugin();
44353
+ featheryWindow().amplitude.add(sessionReplayTracking);
44354
+ }
44355
+ options = {
44356
+ fetchRemoteConfig: true,
44357
+ autocapture: true
44358
+ };
44359
+ if (meta.eu_server)
44360
+ options.serverZone = 'EU';
44361
+ featheryWindow().amplitude.init(apiKey, options);
44362
+ if (meta.identify_user)
44363
+ featheryWindow().amplitude.setUserId(initInfo().userId);
44364
+ return [2 /*return*/];
44365
+ }
44422
44366
  });
44423
- if (firstMatchingValidation)
44424
- return firstMatchingValidation.message;
44425
- }
44426
- // Now apply any standard validations
44427
- if (servar) {
44428
- var fieldVal = exports.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
- exports.phoneLibPromise = Promise.resolve();
44444
- var loadPhoneValidator = function () {
44445
- return (exports.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
- }
44367
+ });
44368
+ }
44369
+
44370
+ var mixpanelInstalled = false;
44371
+ function installMixpanel(mixpanelConfig) {
44372
+ if (mixpanelConfig && !mixpanelInstalled && !featheryWindow().mixpanel) {
44373
+ mixpanelInstalled = true;
44374
+ (function (f, b) {
44375
+ if (!b.__SV) {
44376
+ var i_1, h_1;
44377
+ featheryWindow().mixpanel = b;
44378
+ b._i = [];
44379
+ b.init = function (e, f, c) {
44380
+ function g(a, d) {
44381
+ var b = d.split('.');
44382
+ // eslint-disable-next-line eqeqeq,no-unused-expressions
44383
+ b.length == 2 && ((a = a[b[0]]), (d = b[1]));
44384
+ a[d] = function () {
44385
+ // eslint-disable-next-line prefer-rest-params
44386
+ a.push([d].concat(Array.prototype.slice.call(arguments, 0)));
44387
+ };
44388
+ }
44389
+ var a = b;
44390
+ typeof c !== 'undefined' ? (a = b[c] = []) : (c = 'mixpanel');
44391
+ a.people = a.people || [];
44392
+ a.toString = function (a) {
44393
+ var d = 'mixpanel';
44394
+ c !== 'mixpanel' && (d += '.' + c);
44395
+ a || (d += ' (stub)');
44396
+ return d;
44397
+ };
44398
+ a.people.toString = function () {
44399
+ return a.toString(1) + '.people (stub)';
44400
+ };
44401
+ i_1 =
44402
+ '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(' ');
44403
+ for (h_1 = 0; h_1 < i_1.length; h_1++)
44404
+ g(a, i_1[h_1]);
44405
+ var j = 'set set_once union unset remove delete'.split(' ');
44406
+ a.get_group = function () {
44407
+ function b(c) {
44408
+ d[c] = function () {
44409
+ var call2 = [c].concat(
44410
+ // eslint-disable-next-line prefer-rest-params
44411
+ Array.prototype.slice.call(arguments, 0));
44412
+ a.push([e, call2]);
44413
+ };
44414
+ }
44415
+ var d;
44416
+ for (d = {},
44417
+ e = ['get_group'].concat(
44418
+ // eslint-disable-next-line prefer-rest-params
44419
+ Array.prototype.slice.call(arguments, 0)),
44420
+ c = 0; c < j.length; c++)
44421
+ b(j[c]);
44422
+ return d;
44423
+ };
44424
+ b._i.push([e, f, c]);
44425
+ };
44426
+ b.__SV = 1.2;
44427
+ var e = f.createElement('script');
44428
+ e.type = 'text/javascript';
44429
+ e.async = true;
44430
+ e.src =
44431
+ f.location.protocol === 'file:' &&
44432
+ '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'.match(/^\/\//)
44433
+ ? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
44434
+ : '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
44435
+ var g = f.getElementsByTagName('script')[0];
44436
+ g.parentNode.insertBefore(e, g);
44437
+ }
44438
+ })(featheryDoc(), featheryWindow().mixpanel || []);
44439
+ featheryWindow().mixpanel.init(mixpanelConfig.metadata.api_key);
44502
44440
  }
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)
44441
+ return Promise.resolve();
44442
+ }
44443
+
44444
+ var rudderStackInstalled = false;
44445
+ function installRudderStack(rudderStackConfig) {
44446
+ return __awaiter$2(this, void 0, void 0, function () {
44447
+ var rudderanalytics_1, methods, i, method;
44448
+ return __generator(this, function (_a) {
44449
+ if (rudderStackConfig && !rudderStackInstalled) {
44450
+ rudderStackInstalled = true;
44451
+ dynamicImport('https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js');
44452
+ rudderanalytics_1 = (featheryWindow().rudderanalytics = []);
44453
+ methods = [
44454
+ 'load',
44455
+ 'page',
44456
+ 'track',
44457
+ 'identify',
44458
+ 'alias',
44459
+ 'group',
44460
+ 'ready',
44461
+ 'reset',
44462
+ 'getAnonymousId',
44463
+ 'setAnonymousId',
44464
+ 'getUserId',
44465
+ 'getUserTraits',
44466
+ 'getGroupId',
44467
+ 'getGroupTraits',
44468
+ 'startSession',
44469
+ 'endSession',
44470
+ 'getSessionId'
44471
+ ];
44472
+ for (i = 0; i < methods.length; i++) {
44473
+ method = methods[i];
44474
+ rudderanalytics_1[method] = (function (methodName) {
44475
+ return function () {
44476
+ rudderanalytics_1.push(
44477
+ // eslint-disable-next-line prefer-rest-params
44478
+ [methodName].concat(Array.prototype.slice.call(arguments)));
44479
+ };
44480
+ })(method);
44481
+ }
44482
+ rudderanalytics_1.load(rudderStackConfig.metadata.write_key, rudderStackConfig.metadata.data_plane_url);
44483
+ rudderanalytics_1.identify(initInfo().userId);
44515
44484
  }
44516
- if (value.every(function (val) { return !val; })) {
44517
- return true;
44485
+ return [2 /*return*/, Promise.resolve()];
44486
+ });
44487
+ });
44488
+ }
44489
+ function trackRudderEvent(title, properties, integ) {
44490
+ var trackEvents = integ === null || integ === void 0 ? void 0 : integ.metadata.track_events;
44491
+ if (!trackEvents || trackEvents.includes(title))
44492
+ featheryWindow().rudderanalytics.track(title, properties);
44493
+ }
44494
+
44495
+ var configMap = {};
44496
+ function installTrustedForm(trustedformConfig, formKey) {
44497
+ return __awaiter$2(this, void 0, void 0, function () {
44498
+ var tf, protocol, certField, pingField, rand, s;
44499
+ return __generator(this, function (_a) {
44500
+ if (!trustedformConfig)
44501
+ return [2 /*return*/];
44502
+ configMap[formKey] = trustedformConfig;
44503
+ tf = featheryDoc().createElement('script');
44504
+ tf.type = 'text/javascript';
44505
+ tf.async = true;
44506
+ protocol = featheryDoc().location.protocol === 'https:' ? 'https' : 'http';
44507
+ certField = trustedformConfig.metadata.certificate_field_key;
44508
+ pingField = trustedformConfig.metadata.ping_field_key;
44509
+ rand = new Date().getTime() + Math.random();
44510
+ tf.src = "".concat(protocol, "://api.trustedform.com/trustedform.js?field=").concat(certField, "&ping_field=").concat(pingField, "&l=").concat(rand);
44511
+ s = featheryDoc().getElementsByTagName('script')[0];
44512
+ s.parentNode.insertBefore(tf, s);
44513
+ return [2 /*return*/];
44514
+ });
44515
+ });
44516
+ }
44517
+ function gatherTrustedFormFields(existingFields, formKey) {
44518
+ var config = configMap[formKey];
44519
+ if (!config)
44520
+ return;
44521
+ ['certificate_field_key', 'ping_field_key'].forEach(function (attr) {
44522
+ var fieldKey = config.metadata[attr];
44523
+ if (!(fieldKey in exports.fieldValues)) {
44524
+ // Not stored yet
44525
+ var el = featheryDoc().getElementsByName(fieldKey)[0];
44526
+ if (el) {
44527
+ var fieldVal = el.value;
44528
+ exports.fieldValues[fieldKey] = fieldVal;
44529
+ existingFields[fieldKey] = fieldVal;
44518
44530
  }
44519
44531
  }
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; });
44532
+ });
44533
+ }
44534
+
44535
+ var IMPORTED_URLS = new Set();
44536
+ function dynamicImport(dependencies, parallel, force) {
44537
+ if (parallel === void 0) { parallel = true; }
44538
+ if (force === void 0) { force = false; }
44539
+ if (typeof dependencies === 'string')
44540
+ dependencies = [dependencies];
44541
+ var newDependencies = [];
44542
+ dependencies.forEach(function (d) {
44543
+ var dup = IMPORTED_URLS.has(d);
44544
+ if (dup && force) {
44545
+ var base = d;
44546
+ var counter = 1;
44547
+ while (dup) {
44548
+ d = "".concat(base, "?version=").concat(counter);
44549
+ dup = IMPORTED_URLS.has(d);
44550
+ counter++;
44551
+ }
44552
+ }
44553
+ if (!dup) {
44554
+ IMPORTED_URLS.add(d);
44555
+ newDependencies.push(d);
44556
+ }
44557
+ });
44558
+ if (newDependencies.length === 0)
44559
+ return Promise.resolve();
44560
+ if (parallel) {
44561
+ return new Promise(function (resolve) {
44562
+ global.scriptjsLoadPromise.then(function ($script) {
44563
+ $script.default(newDependencies, function (lib) {
44564
+ resolve(lib);
44565
+ });
44566
+ });
44567
+ });
44522
44568
  }
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;
44569
+ else {
44570
+ return new Promise(function (resolve) {
44571
+ global.scriptjsLoadPromise.then(function ($script) {
44572
+ $script.default.order(newDependencies, resolve);
44530
44573
  });
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;
44574
+ });
44551
44575
  }
44552
- return noVal;
44553
44576
  }
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
- exports.fieldValues[servar === null || servar === void 0 ? void 0 : servar.key][repeat] = newVal;
44577
+ function initializeIntegrations(integs, featheryClient) {
44578
+ return __awaiter$2(this, void 0, void 0, function () {
44579
+ var gtm;
44580
+ return __generator(this, function (_a) {
44581
+ switch (_a.label) {
44582
+ case 0: return [4 /*yield*/, Promise.all([
44583
+ installArgyle(!!integs.argyle),
44584
+ installPlaid(!!integs.plaid),
44585
+ installFirebase(integs.firebase),
44586
+ installStytch(integs.stytch),
44587
+ installStripe(integs.stripe),
44588
+ installSegment(integs.segment),
44589
+ installGoogleAnalytics(integs['google-analytics']),
44590
+ installHeap(integs.heap),
44591
+ installAmplitude(integs.amplitude),
44592
+ installMixpanel(integs.mixpanel),
44593
+ installIntercom(integs['intercom-embedded']),
44594
+ installRudderStack(integs.rudderstack),
44595
+ installPersona(integs.persona),
44596
+ installAlloy(integs.alloy),
44597
+ installTrustedForm(integs.trustedform, featheryClient.formKey)
44598
+ ])];
44599
+ case 1:
44600
+ _a.sent();
44601
+ gtm = integs['google-tag-manager'];
44602
+ if (gtm)
44603
+ initializeTagManager(gtm);
44604
+ if (integs.firebase || integs.stytch) {
44605
+ authState.authFormKey = featheryClient.formKey;
44606
+ return [2 /*return*/, Auth.inferLoginOnLoad(featheryClient)];
44607
+ }
44608
+ return [2 /*return*/];
44583
44609
  }
44584
- else
44585
- exports.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;
44610
+ });
44611
+ });
44612
+ }
44613
+ function trackEvent(integrations, title, stepId, formName, fieldData) {
44614
+ var metadata = { formName: formName };
44615
+ if (stepId)
44616
+ metadata.stepId = stepId;
44617
+ // Google Tag Manager
44618
+ // @ts-expect-error TS(2551): Property 'initialized' does not exist on type '{ d... Remove this comment to see the full error message
44619
+ if (TagManager.initialized) {
44620
+ var gtmData = exports.__assign({}, metadata);
44621
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData['google-tag-manager'])
44622
+ gtmData = exports.__assign(exports.__assign({}, gtmData), fieldData['google-tag-manager']);
44623
+ TagManager.dataLayer({ dataLayer: exports.__assign(exports.__assign({}, gtmData), { event: title }) });
44597
44624
  }
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');
44625
+ // RudderStack
44626
+ if (rudderStackInstalled) {
44627
+ var rudderData = exports.__assign({}, metadata);
44628
+ if (title === 'FeatheryFormComplete')
44629
+ rudderData.fieldData = exports.fieldValues;
44630
+ trackRudderEvent(title, rudderData, integrations === null || integrations === void 0 ? void 0 : integrations.rudderstack);
44611
44631
  }
44612
- // No error
44613
- return '';
44632
+ // Google Analytics
44633
+ if (gaInstalled)
44634
+ trackGAEvent(formName, title, stepId);
44635
+ // Segment
44636
+ var segmentData = exports.__assign({}, metadata);
44637
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.segment)
44638
+ segmentData.submittedData = fieldData.segment;
44639
+ if (featheryWindow().analytics)
44640
+ featheryWindow().analytics.track(title, segmentData);
44641
+ var amplitudeData = exports.__assign({}, metadata);
44642
+ if (fieldData === null || fieldData === void 0 ? void 0 : fieldData.amplitude)
44643
+ amplitudeData.submittedData = fieldData.amplitude;
44644
+ if (featheryWindow().amplitude)
44645
+ featheryWindow().amplitude.track(title, amplitudeData);
44646
+ if (featheryWindow().mixpanel)
44647
+ featheryWindow().mixpanel.track(title, metadata);
44614
44648
  }
44615
44649
 
44616
44650
  var QR_SCANNER_LIB_URL = 'https://unpkg.com/html5-qrcode';
@@ -45968,9 +46002,9 @@ function init(sdkKey, options) {
45968
46002
  if (runningInClient()) {
45969
46003
  // Dynamically load libraries that must be client side
45970
46004
  global.scriptjsLoadPromise = Promise.resolve().then(function () { return require(
45971
- /* webpackChunkName: "scriptjs" */ './fthry_script.NtkfplNS.js'); }).then(function (n) { return n.script; });
46005
+ /* webpackChunkName: "scriptjs" */ './fthry_script.DOCG8gyM.js'); }).then(function (n) { return n.script; });
45972
46006
  global.webfontloaderPromise = Promise.resolve().then(function () { return require(
45973
- /* webpackChunkName: "webfontloader" */ './fthry_webfontloader.Dgu1OvOA.js'); }).then(function (n) { return n.webfontloader; });
46007
+ /* webpackChunkName: "webfontloader" */ './fthry_webfontloader.5X-HEWHN.js'); }).then(function (n) { return n.webfontloader; });
45974
46008
  // Client-side tracking logic
45975
46009
  if (initState.userTracking === 'cookie') {
45976
46010
  var cookieKey = "feathery-user-id-".concat(sdkKey);
@@ -46116,7 +46150,7 @@ function getFieldValues() {
46116
46150
  return exports.__assign({}, exports.fieldValues);
46117
46151
  }
46118
46152
  function logFeatheryBadge() {
46119
- console.log('%c Feathery %c v' + "2.23.3" + ' ', // replaced with real version during build
46153
+ console.log('%c Feathery %c v' + "2.23.5" + ' ', // replaced with real version during build
46120
46154
  '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
46155
  }
46122
46156
 
@@ -47549,39 +47583,39 @@ breakpoint) {
47549
47583
  return styles.getTarget('inner-container', undefined, viewport === 'mobile');
47550
47584
  };
47551
47585
 
47552
- var AddressLine1 = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "AddressField" */ './fthry_index.D5CGTQKa.js'); }); });
47553
- var ButtonGroupField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "ButtonGroupField" */ './fthry_index.B0KReyAP.js'); }); });
47554
- var CheckboxField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "CheckboxField" */ './fthry_index.xFsG3Jma.js'); }); });
47586
+ var AddressLine1 = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "AddressField" */ './fthry_index.DGctX9WE.js'); }); });
47587
+ var ButtonGroupField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "ButtonGroupField" */ './fthry_index.BYTU7WTg.js'); }); });
47588
+ var CheckboxField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "CheckboxField" */ './fthry_index.mEUshDAA.js'); }); });
47555
47589
  var CheckboxGroupField = React.lazy(function () {
47556
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "CheckboxGroupField" */ './fthry_index.ly3gOUU_.js'); });
47590
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "CheckboxGroupField" */ './fthry_index.Bh5jAAhx.js'); });
47557
47591
  });
47558
- var ColorPickerField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "ColorPickerField" */ './fthry_index.yAmVGVxf.js'); }); });
47559
- var CustomField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "CustomField" */ './fthry_index.Bn7LKMrK.js'); }); });
47592
+ var ColorPickerField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "ColorPickerField" */ './fthry_index.CSwhuTPY.js'); }); });
47593
+ var CustomField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "CustomField" */ './fthry_index.Bsklltx4.js'); }); });
47560
47594
  var DateSelectorField = React.lazy(function () {
47561
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "DateSelectorField" */ './fthry_index.Cs1MGCSE.js'); });
47595
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "DateSelectorField" */ './fthry_index.BS6b2BTF.js'); });
47562
47596
  });
47563
- var DropdownField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "DropdownField" */ './fthry_index.mj0_Tc2V.js'); }); });
47597
+ var DropdownField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "DropdownField" */ './fthry_index.CWofoHQs.js'); }); });
47564
47598
  var DropdownMultiField = React.lazy(function () {
47565
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "DropdownMultiField" */ './fthry_index.DYqW71E8.js'); });
47599
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "DropdownMultiField" */ './fthry_index.Nrwqiq0j.js'); });
47566
47600
  });
47567
- var FileUploadField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "FileUploadField" */ './fthry_index.CRDDUT1I.js'); }); });
47568
- var MatrixField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "MatrixField" */ './fthry_index.h9jJa8zh.js'); }); });
47569
- var PasswordField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "PasswordField" */ './fthry_index.DH3KDEwG.js'); }); });
47601
+ var FileUploadField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "FileUploadField" */ './fthry_index.B_UehadW.js'); }); });
47602
+ var MatrixField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "MatrixField" */ './fthry_index.jot4NArP.js'); }); });
47603
+ var PasswordField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "PasswordField" */ './fthry_index.D36o5hns.js'); }); });
47570
47604
  var PaymentMethodField = React.lazy(function () {
47571
- return Promise.resolve().then(function () { return require(/* webpackChunkName: "PaymentMethodField" */ './fthry_PaymentMethodField.B_GDmxLy.js'); });
47605
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "PaymentMethodField" */ './fthry_PaymentMethodField.D902pJlo.js'); });
47572
47606
  });
47573
- var PhoneField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "PhoneField" */ './fthry_index.2nJBzqdc.js'); }); });
47574
- var PinInputField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "PinInputField" */ './fthry_index.BPf3q0bZ.js'); }); });
47575
- var QRScanner = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "QRScanner" */ './fthry_index.DVrmPZ9A.js'); }); });
47607
+ var PhoneField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "PhoneField" */ './fthry_index.Bl2kuNOo.js'); }); });
47608
+ var PinInputField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "PinInputField" */ './fthry_index.9PFsbc4I.js'); }); });
47609
+ var QRScanner = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "QRScanner" */ './fthry_index.Jp2CJ4is.js'); }); });
47576
47610
  var RadioButtonGroupField = React.lazy(function () {
47577
47611
  return Promise.resolve().then(function () { return require(
47578
- /* webpackChunkName: "RadioButtonGroupField" */ './fthry_index.ByVaPSCt.js'); });
47612
+ /* webpackChunkName: "RadioButtonGroupField" */ './fthry_index.-Y9ZJS34.js'); });
47579
47613
  });
47580
- var RatingField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "RatingField" */ './fthry_index.CLTU9AAQ.js'); }); });
47581
- var SignatureField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "SignatureField" */ './fthry_index.BrrNGZQn.js'); }); });
47582
- var SliderField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "SliderField" */ './fthry_index.Feu6uyn6.js'); }); });
47583
- var TextField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "TextField" */ './fthry_index.C_qw3SH5.js'); }); });
47584
- var TextArea = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "TextArea" */ './fthry_index.DT82qJhW.js'); }); });
47614
+ var RatingField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "RatingField" */ './fthry_index.C6-dnyHD.js'); }); });
47615
+ var SignatureField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "SignatureField" */ './fthry_index.B4YVBeqY.js'); }); });
47616
+ var SliderField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "SliderField" */ './fthry_index.BmT77CVY.js'); }); });
47617
+ var TextField = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "TextField" */ './fthry_index.BuQ1HIIN.js'); }); });
47618
+ var TextArea = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "TextArea" */ './fthry_index.dGUMsRB1.js'); }); });
47585
47619
  var Fields = {
47586
47620
  AddressLine1: AddressLine1,
47587
47621
  ButtonGroupField: ButtonGroupField,
@@ -48521,7 +48555,7 @@ function ElementSkeleton(_a) {
48521
48555
  }
48522
48556
  var templateObject_1;
48523
48557
 
48524
- var TableElement = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "TableElement" */ './fthry_index.Bo0inH5r.js'); }); });
48558
+ var TableElement = React.lazy(function () { return Promise.resolve().then(function () { return require(/* webpackChunkName: "TableElement" */ './fthry_index.CbASwLjr.js'); }); });
48525
48559
  var Basic = {
48526
48560
  ImageElement: ImageElement,
48527
48561
  VideoElement: VideoElement,