@drawbridge/components 0.1.13 → 0.1.15

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 (242) hide show
  1. package/components/styles.css +364 -2
  2. package/dist/advertisement.js +3 -1
  3. package/dist/advertisement.mjs +3 -1
  4. package/dist/bridge/advertisements.js +2 -0
  5. package/dist/bridge/advertisements.mjs +2 -0
  6. package/dist/bridge/countdown.js +2 -1
  7. package/dist/bridge/countdown.mjs +2 -1
  8. package/dist/bridge/form-subdomain-embed.js +18 -20
  9. package/dist/bridge/form-subdomain-embed.mjs +18 -20
  10. package/dist/bridge/form-subdomain-header.js +24 -1
  11. package/dist/bridge/form-subdomain-header.mjs +24 -1
  12. package/dist/bridge/form-subdomain-missions.js +577 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +540 -0
  14. package/dist/bridge/form-subdomain.js +530 -220
  15. package/dist/bridge/form-subdomain.mjs +533 -222
  16. package/dist/bridge/lib/entry.js +59 -0
  17. package/dist/bridge/lib/entry.mjs +29 -0
  18. package/dist/bridge/lib/location.js +38 -0
  19. package/dist/bridge/lib/location.mjs +13 -0
  20. package/dist/bridge/lib/order.js +71 -0
  21. package/dist/bridge/lib/order.mjs +44 -0
  22. package/dist/bridge/lib/url.js +9 -0
  23. package/dist/bridge/lib/url.mjs +7 -0
  24. package/dist/bridge/share-button.js +5 -3
  25. package/dist/bridge/share-button.mjs +5 -3
  26. package/dist/bridge/subdomain-content.js +7 -6
  27. package/dist/bridge/subdomain-content.mjs +7 -6
  28. package/dist/bridge/template-layout.js +59 -21
  29. package/dist/bridge/template-layout.mjs +59 -21
  30. package/dist/bridge/template-modal.js +42 -76
  31. package/dist/bridge/template-modal.mjs +39 -73
  32. package/dist/bridge/template-preview.js +208 -0
  33. package/dist/bridge/template-preview.mjs +173 -0
  34. package/dist/bridge/template-subdomain-gallery.js +6 -2
  35. package/dist/bridge/template-subdomain-gallery.mjs +6 -2
  36. package/dist/bridge/template-subdomain-link.js +6 -1
  37. package/dist/bridge/template-subdomain-link.mjs +6 -1
  38. package/dist/bridge/template-subdomain.js +20 -15
  39. package/dist/bridge/template-subdomain.mjs +20 -15
  40. package/dist/dashboard/accordion.js +74 -39
  41. package/dist/dashboard/accordion.mjs +74 -39
  42. package/dist/dashboard/avatar.js +109 -3
  43. package/dist/dashboard/avatar.mjs +106 -4
  44. package/dist/dashboard/buttons-subscription.js +384 -0
  45. package/dist/dashboard/buttons-subscription.mjs +349 -0
  46. package/dist/dashboard/card-campaign-switch.js +277 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +243 -0
  48. package/dist/dashboard/card-order.js +231 -29
  49. package/dist/dashboard/card-order.mjs +231 -29
  50. package/dist/dashboard/card-section.js +26 -2
  51. package/dist/dashboard/card-section.mjs +26 -2
  52. package/dist/dashboard/card-tile.js +6 -7
  53. package/dist/dashboard/card-tile.mjs +6 -7
  54. package/dist/dashboard/connection-workflows.js +205 -0
  55. package/dist/dashboard/connection-workflows.mjs +171 -0
  56. package/dist/dashboard/device.js +95 -0
  57. package/dist/dashboard/device.mjs +72 -0
  58. package/dist/dashboard/form-admin-campaign.js +19 -50
  59. package/dist/dashboard/form-admin-campaign.mjs +20 -51
  60. package/dist/dashboard/form-ai.js +9 -6
  61. package/dist/dashboard/form-ai.mjs +9 -6
  62. package/dist/dashboard/form-auth.js +35 -25
  63. package/dist/dashboard/form-auth.mjs +36 -26
  64. package/dist/dashboard/form-file.js +10 -1
  65. package/dist/dashboard/form-file.mjs +10 -1
  66. package/dist/dashboard/form-filters-analytics.js +14 -1
  67. package/dist/dashboard/form-filters-analytics.mjs +15 -2
  68. package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
  69. package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
  70. package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
  72. package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
  73. package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
  74. package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
  75. package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
  76. package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
  77. package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
  78. package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
  79. package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
  80. package/dist/dashboard/form-organization-campaign-field-select.js +51 -5
  81. package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
  82. package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
  83. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
  84. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  87. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  88. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  89. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  90. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  91. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  92. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  93. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  94. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  95. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  96. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  97. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  99. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  100. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  101. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  102. package/dist/dashboard/form-organization-campaign-section.js +243 -0
  103. package/dist/dashboard/form-organization-campaign-section.mjs +214 -0
  104. package/dist/dashboard/form-organization-campaign.js +114 -469
  105. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  106. package/dist/dashboard/form-organization-export.js +4 -7
  107. package/dist/dashboard/form-organization-export.mjs +4 -7
  108. package/dist/dashboard/form-organization-identity.js +46 -51
  109. package/dist/dashboard/form-organization-identity.mjs +46 -51
  110. package/dist/dashboard/form-organization-workflow.js +708 -687
  111. package/dist/dashboard/form-organization-workflow.mjs +704 -683
  112. package/dist/dashboard/form-organization.js +82 -110
  113. package/dist/dashboard/form-organization.mjs +81 -109
  114. package/dist/dashboard/form-otc.js +4 -5
  115. package/dist/dashboard/form-otc.mjs +4 -5
  116. package/dist/dashboard/form-payment-methods.js +20 -9
  117. package/dist/dashboard/form-payment-methods.mjs +20 -9
  118. package/dist/dashboard/form-stripe.js +30 -0
  119. package/dist/dashboard/form-stripe.mjs +26 -0
  120. package/dist/dashboard/input-array.js +4 -2
  121. package/dist/dashboard/input-array.mjs +4 -2
  122. package/dist/dashboard/input-combobox.js +7 -3
  123. package/dist/dashboard/input-combobox.mjs +7 -3
  124. package/dist/dashboard/input-date.js +7 -0
  125. package/dist/dashboard/input-date.mjs +7 -0
  126. package/dist/dashboard/input-fields.js +80 -20
  127. package/dist/dashboard/input-fields.mjs +80 -20
  128. package/dist/dashboard/input-file.js +21 -1
  129. package/dist/dashboard/input-file.mjs +21 -1
  130. package/dist/dashboard/input-font.js +10 -1
  131. package/dist/dashboard/input-font.mjs +10 -1
  132. package/dist/dashboard/lib/item-list.js +57 -0
  133. package/dist/dashboard/lib/item-list.mjs +33 -0
  134. package/dist/dashboard/lib/menu.js +50 -0
  135. package/dist/dashboard/lib/menu.mjs +26 -0
  136. package/dist/dashboard/locked.js +82 -0
  137. package/dist/dashboard/locked.mjs +53 -0
  138. package/dist/dashboard/menu.js +72 -19
  139. package/dist/dashboard/menu.mjs +72 -19
  140. package/dist/dashboard/note-ai.js +69 -0
  141. package/dist/dashboard/note-ai.mjs +36 -0
  142. package/dist/dashboard/preview.js +419 -0
  143. package/dist/dashboard/preview.mjs +384 -0
  144. package/dist/dashboard/steps.js +39 -13
  145. package/dist/dashboard/steps.mjs +37 -12
  146. package/dist/dashboard/table-contacts.js +136 -0
  147. package/dist/dashboard/table-contacts.mjs +103 -0
  148. package/dist/dashboard/template-not-found.js +4 -2
  149. package/dist/dashboard/template-not-found.mjs +4 -2
  150. package/dist/dashboard/template-socket.js +20 -7
  151. package/dist/dashboard/template-socket.mjs +20 -7
  152. package/dist/icons/desktop.js +46 -0
  153. package/dist/icons/desktop.mjs +27 -0
  154. package/dist/icons/phone.js +46 -0
  155. package/dist/icons/phone.mjs +27 -0
  156. package/dist/icons/puzzle-piece.js +46 -0
  157. package/dist/icons/puzzle-piece.mjs +27 -0
  158. package/dist/icons/tablet.js +46 -0
  159. package/dist/icons/tablet.mjs +27 -0
  160. package/dist/icons/users.js +46 -0
  161. package/dist/icons/users.mjs +27 -0
  162. package/dist/input-checkbox.js +1 -0
  163. package/dist/input-checkbox.mjs +1 -0
  164. package/dist/input-code.js +83 -0
  165. package/dist/input-code.mjs +50 -0
  166. package/dist/input-text.js +2 -1
  167. package/dist/input-text.mjs +2 -1
  168. package/dist/shared/button.js +1 -1
  169. package/dist/shared/button.mjs +1 -1
  170. package/dist/shared/input-checkbox-list.js +0 -1
  171. package/dist/shared/input-checkbox-list.mjs +0 -1
  172. package/dist/shared/input-switch.js +6 -1
  173. package/dist/shared/input-switch.mjs +6 -1
  174. package/dist/shared/lib/campaign.js +123 -0
  175. package/dist/shared/lib/campaign.mjs +96 -0
  176. package/dist/shared/lib/helpers.js +14 -2
  177. package/dist/shared/lib/helpers.mjs +13 -2
  178. package/package.json +133 -13
  179. package/types/bridge/form-subdomain-header.d.ts +2 -0
  180. package/types/bridge/form-subdomain-missions.d.ts +38 -0
  181. package/types/bridge/form-subdomain.d.ts +23 -1
  182. package/types/bridge/lib/entry.d.ts +26 -0
  183. package/types/bridge/lib/location.d.ts +13 -0
  184. package/types/bridge/lib/order.d.ts +30 -0
  185. package/types/bridge/lib/url.d.ts +19 -0
  186. package/types/bridge/template-modal.d.ts +1 -1
  187. package/types/bridge/template-preview.d.ts +10 -0
  188. package/types/bridge/template-subdomain-link.d.ts +2 -0
  189. package/types/dashboard/accordion.d.ts +2 -0
  190. package/types/dashboard/avatar.d.ts +18 -2
  191. package/types/dashboard/buttons-subscription.d.ts +22 -0
  192. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  193. package/types/dashboard/card-order.d.ts +25 -1
  194. package/types/dashboard/card-section.d.ts +2 -0
  195. package/types/dashboard/connection-workflows.d.ts +33 -0
  196. package/types/dashboard/device.d.ts +12 -0
  197. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  198. package/types/dashboard/form-ai.d.ts +2 -2
  199. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  200. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  201. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  202. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  203. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  204. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  205. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  206. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  207. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  208. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  209. package/types/dashboard/form-organization-campaign-section.d.ts +29 -0
  210. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  211. package/types/dashboard/form-organization-identity.d.ts +2 -0
  212. package/types/dashboard/form-organization-workflow.d.ts +56 -47
  213. package/types/dashboard/form-organization.d.ts +7 -2
  214. package/types/dashboard/form-stripe.d.ts +3 -0
  215. package/types/dashboard/input-combobox.d.ts +2 -0
  216. package/types/dashboard/input-date.d.ts +2 -0
  217. package/types/dashboard/input-fields.d.ts +3 -2
  218. package/types/dashboard/input-file.d.ts +4 -0
  219. package/types/dashboard/lib/item-list.d.ts +14 -0
  220. package/types/dashboard/lib/menu.d.ts +17 -0
  221. package/types/dashboard/locked.d.ts +10 -0
  222. package/types/dashboard/menu.d.ts +10 -2
  223. package/types/dashboard/note-ai.d.ts +15 -0
  224. package/types/dashboard/preview.d.ts +33 -0
  225. package/types/dashboard/steps.d.ts +19 -4
  226. package/types/dashboard/table-cell-title.d.ts +2 -2
  227. package/types/dashboard/table-contacts.d.ts +2 -0
  228. package/types/icons/desktop.d.ts +5 -0
  229. package/types/icons/phone.d.ts +5 -0
  230. package/types/icons/puzzle-piece.d.ts +5 -0
  231. package/types/icons/tablet.d.ts +5 -0
  232. package/types/icons/users.d.ts +5 -0
  233. package/types/input-code.d.ts +23 -0
  234. package/types/shared/input-switch.d.ts +2 -0
  235. package/types/shared/lib/campaign.d.ts +35 -0
  236. package/types/shared/lib/helpers.d.ts +3 -0
  237. package/dist/dashboard/card-integration.js +0 -187
  238. package/dist/dashboard/card-integration.mjs +0 -158
  239. package/dist/dashboard/iframe.js +0 -159
  240. package/dist/dashboard/iframe.mjs +0 -130
  241. package/types/dashboard/card-integration.d.ts +0 -24
  242. package/types/dashboard/iframe.d.ts +0 -18
@@ -28,7 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var form_subdomain_exports = {};
30
30
  __export(form_subdomain_exports, {
31
- FormSubdomainHeader: () => import_form_subdomain_header.FormSubdomainHeader,
32
31
  FormSubdomainMessage: () => FormSubdomainMessage,
33
32
  FormSubdomainSubmission: () => FormSubdomainSubmission,
34
33
  default: () => form_subdomain_default
@@ -37,7 +36,11 @@ module.exports = __toCommonJS(form_subdomain_exports);
37
36
  var import_jsx_runtime = require("react/jsx-runtime");
38
37
  var import_react = require("react");
39
38
  var import_navigation = require("next/navigation");
39
+ var import_image = __toESM(require("next/image"));
40
40
  var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
41
+ var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
42
+ var import_cdn = require("@drawbridge/drawbridge-utils/cdn");
43
+ var import_fields_validate = require("@drawbridge/drawbridge-utils/fields-validate");
41
44
  var import_nextjs = require("@drawbridge/drawbridge-telemetry/nextjs");
42
45
  var import_react_hook_form = require("react-hook-form");
43
46
  var import_yup = __toESM(require("./lib/yup"));
@@ -45,11 +48,15 @@ var import_age_gate = require("./lib/age-gate");
45
48
  var import_react_google_recaptcha_v3 = require("react-google-recaptcha-v3");
46
49
  var import_recaptcha = require("./lib/recaptcha");
47
50
  var import_url = require("./lib/url");
51
+ var import_entry = require("./lib/entry");
52
+ var import_location = require("./lib/location");
53
+ var import_order = require("./lib/order");
48
54
  var import_form = __toESM(require("../shared/form"));
49
55
  var import_button = __toESM(require("../shared/button"));
50
56
  var import_fieldset = __toESM(require("../shared/fieldset"));
51
57
  var import_fields = require("./fields");
52
58
  var import_input_group = __toESM(require("../input-group"));
59
+ var import_input_number = __toESM(require("../input-number"));
53
60
  var import_error = __toESM(require("../shared/error"));
54
61
  var import_input_text = __toESM(require("../input-text"));
55
62
  var import_form_subdomain_header = require("./form-subdomain-header");
@@ -57,33 +64,44 @@ var import_loader = __toESM(require("../icons/loader"));
57
64
  var import_warning = __toESM(require("../icons/warning"));
58
65
  var import_input_checkbox = __toESM(require("../input-checkbox"));
59
66
  var import_advertisements = __toESM(require("./advertisements"));
67
+ var import_form_subdomain_missions = __toESM(require("./form-subdomain-missions"));
60
68
  var import_link = __toESM(require("next/link"));
61
69
  const appendPreview = (endpoint, token) => {
62
70
  if (!token) return endpoint;
63
71
  const separator = endpoint.includes("?") ? "&" : "?";
64
72
  return endpoint + separator + "drwbrdg_pre=" + encodeURIComponent(token);
65
73
  };
74
+ const scrollToCentre = (node) => {
75
+ let box = node == null ? void 0 : node.parentElement;
76
+ while (box && !(box.scrollHeight > box.clientHeight && /auto|scroll/.test(getComputedStyle(box).overflowY))) box = box.parentElement;
77
+ if (!box) return;
78
+ box.scrollTop += node.getBoundingClientRect().top - box.getBoundingClientRect().top - (box.clientHeight - node.offsetHeight) / 2;
79
+ };
66
80
  const FormSubdomainSubmission = ({
67
81
  affiliate,
68
82
  button,
69
83
  checkout,
84
+ giveaway,
70
85
  id,
71
86
  lead,
72
87
  message,
88
+ panel,
73
89
  preview,
90
+ repeat,
74
91
  slug,
75
92
  style,
76
93
  subdomain,
77
94
  title,
78
95
  tracking
79
96
  }) => {
80
- var _a;
81
- const [loading, setLoading] = (0, import_react.useState)(Boolean(id));
82
- const [data, setData] = (0, import_react.useState)();
97
+ var _a, _b;
98
+ const [loading, setLoading] = (0, import_react.useState)(Boolean(id) && !panel);
99
+ const [fetched, setFetched] = (0, import_react.useState)();
83
100
  const [error, setError] = (0, import_react.useState)();
101
+ const data = panel || fetched;
84
102
  const searchParams = (0, import_navigation.useSearchParams)();
85
103
  const token = searchParams.get("drwbrdg_pre");
86
- const endpoint = (0, import_url.submissionEndpoint)({ affiliate, id, slug, subdomain, token });
104
+ const endpoint = panel ? null : (0, import_url.submissionEndpoint)({ affiliate, id, slug, subdomain, token });
87
105
  const submission = (0, import_react.useCallback)(
88
106
  async () => {
89
107
  try {
@@ -92,7 +110,7 @@ const FormSubdomainSubmission = ({
92
110
  endpoint,
93
111
  method: "GET"
94
112
  });
95
- setData(response.result);
113
+ setFetched(response.result);
96
114
  setLoading(false);
97
115
  } catch ({ message: message2 }) {
98
116
  setError(message2);
@@ -141,6 +159,43 @@ const FormSubdomainSubmission = ({
141
159
  }
142
160
  );
143
161
  }
162
+ const advertisements = ((_a = data == null ? void 0 : data.advertisements) == null ? void 0 : _a.length) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
+ import_advertisements.default,
164
+ {
165
+ ...{
166
+ affiliate: data == null ? void 0 : data.affiliate,
167
+ campaign: data == null ? void 0 : data.campaign,
168
+ items: (data == null ? void 0 : data.advertisements) || [],
169
+ lead,
170
+ checkout,
171
+ organization: data == null ? void 0 : data.organization,
172
+ page: data == null ? void 0 : data.page,
173
+ preview,
174
+ slug,
175
+ style,
176
+ subdomain,
177
+ tracking
178
+ }
179
+ }
180
+ );
181
+ if (Boolean(giveaway) && ((_b = data == null ? void 0 : data.missions) == null ? void 0 : _b.length) > 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
+ import_form_subdomain_missions.default,
183
+ {
184
+ ...{
185
+ advertisements,
186
+ button,
187
+ contact: data == null ? void 0 : data.contact,
188
+ message,
189
+ missions: (0, import_entry.panelMissions)(data.missions, repeat),
190
+ shareLink: data == null ? void 0 : data.shareLink,
191
+ slug,
192
+ style,
193
+ subdomain,
194
+ title,
195
+ token: data == null ? void 0 : data.token
196
+ }
197
+ }
198
+ );
144
199
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
145
200
  "div",
146
201
  {
@@ -162,25 +217,7 @@ const FormSubdomainSubmission = ({
162
217
  }
163
218
  }
164
219
  ),
165
- ((_a = data == null ? void 0 : data.advertisements) == null ? void 0 : _a.length) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
166
- import_advertisements.default,
167
- {
168
- ...{
169
- affiliate: data == null ? void 0 : data.affiliate,
170
- campaign: data == null ? void 0 : data.campaign,
171
- items: (data == null ? void 0 : data.advertisements) || [],
172
- lead,
173
- checkout,
174
- organization: data == null ? void 0 : data.organization,
175
- page: data == null ? void 0 : data.page,
176
- preview,
177
- slug,
178
- style,
179
- subdomain,
180
- tracking
181
- }
182
- }
183
- )
220
+ advertisements
184
221
  ]
185
222
  }
186
223
  );
@@ -287,53 +324,88 @@ const FormSubdomainGeocode = ({
287
324
  style,
288
325
  values
289
326
  }) => {
290
- const [error, setError] = (0, import_react.useState)(disabled ? "Campaign is not currently active" : null);
327
+ const [state, setState] = (0, import_react.useState)(disabled ? { message: "Campaign is not currently active", status: "inactive" } : { status: "checking" });
328
+ const [attempt, setAttempt] = (0, import_react.useState)(0);
291
329
  const searchParams = (0, import_navigation.useSearchParams)();
292
330
  const token = searchParams.get("drwbrdg_pre");
331
+ const next = (0, import_react.useRef)(callback);
332
+ next.current = callback;
293
333
  (0, import_react.useEffect)(
294
334
  () => {
295
- if (navigator.geolocation) {
296
- navigator.geolocation.getCurrentPosition(
297
- async (position) => {
298
- try {
299
- const response = await (0, import_fetch.request)({
300
- body: {
301
- coordinates: [
302
- position.coords.longitude,
303
- position.coords.latitude
304
- ],
305
- preview
306
- },
307
- cache: "no-store",
308
- endpoint: appendPreview("/subdomain/" + (values == null ? void 0 : values.subdomain) + "/page/" + (values == null ? void 0 : values.slug) + "/location", token),
309
- method: "POST"
310
- });
311
- callback(response);
312
- } catch ({ message }) {
313
- setError(message);
314
- }
315
- },
316
- () => {
317
- setError("Location services are not enabled.");
318
- }
319
- );
320
- } else {
321
- setError("Location data is not supported with your current browser and or device.");
335
+ var _a, _b;
336
+ if (disabled) return;
337
+ if (!navigator.geolocation) {
338
+ setState({ status: "unsupported" });
339
+ return;
322
340
  }
341
+ let live = true;
342
+ setState({ status: "checking" });
343
+ (_b = (_a = navigator.permissions) == null ? void 0 : _a.query) == null ? void 0 : _b.call(_a, { name: "geolocation" }).then((permission) => live && (permission == null ? void 0 : permission.state) === "prompt" && setState((current) => current.status === "checking" ? { status: "asking" } : current)).catch(() => {
344
+ });
345
+ navigator.geolocation.getCurrentPosition(
346
+ async (position) => {
347
+ try {
348
+ const response = await (0, import_fetch.request)({
349
+ body: {
350
+ coordinates: [
351
+ position.coords.longitude,
352
+ position.coords.latitude
353
+ ],
354
+ preview
355
+ },
356
+ cache: "no-store",
357
+ endpoint: appendPreview("/subdomain/" + (values == null ? void 0 : values.subdomain) + "/page/" + (values == null ? void 0 : values.slug) + "/location", token),
358
+ method: "POST"
359
+ });
360
+ if (live) next.current(response);
361
+ } catch ({ message }) {
362
+ if (live) setState({ message, status: "outside" });
363
+ }
364
+ },
365
+ (error) => live && setState({ status: (0, import_location.locationStatus)(error) }),
366
+ {
367
+ timeout: import_location.LOCATION_TIMEOUT
368
+ }
369
+ );
370
+ return () => {
371
+ live = false;
372
+ };
323
373
  },
324
- [callback, preview, token, values]
374
+ [attempt, disabled, preview, token, values == null ? void 0 : values.slug, values == null ? void 0 : values.subdomain]
325
375
  );
326
- if (error) {
327
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
328
- FormSubdomainMessage,
376
+ if (["denied", "inactive", "missing", "outside", "unsupported"].includes(state.status)) {
377
+ const retry = ["denied", "missing"].includes(state.status);
378
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
379
+ "div",
329
380
  {
330
381
  ...{
331
- button,
332
- message: error,
333
- style,
334
- svg: import_warning.default,
335
- title: "Error"
336
- }
382
+ className: "space-y-6"
383
+ },
384
+ children: [
385
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
386
+ FormSubdomainMessage,
387
+ {
388
+ ...{
389
+ button,
390
+ message: state.message || import_location.locationCopy[state.status],
391
+ style,
392
+ svg: import_warning.default,
393
+ title: "Error"
394
+ }
395
+ }
396
+ ),
397
+ retry && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
398
+ import_button.default,
399
+ {
400
+ ...{
401
+ onClick: () => setAttempt((value) => value + 1),
402
+ style,
403
+ type: "button"
404
+ },
405
+ children: "Try again"
406
+ }
407
+ )
408
+ ]
337
409
  }
338
410
  );
339
411
  }
@@ -362,20 +434,32 @@ const FormSubdomainGeocode = ({
362
434
  }
363
435
  }
364
436
  ),
365
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
437
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
366
438
  "div",
367
439
  {
368
440
  ...{
369
- className: "flex items-center justify-center p-6"
441
+ className: "flex flex-col items-center justify-center gap-4 p-6"
370
442
  },
371
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
372
- import_loader.default,
373
- {
374
- ...{
375
- className: "w-6 h-6 animate-spin"
443
+ children: [
444
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
445
+ import_loader.default,
446
+ {
447
+ ...{
448
+ className: "w-6 h-6 animate-spin"
449
+ }
376
450
  }
377
- }
378
- )
451
+ ),
452
+ state.status === "asking" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
453
+ "p",
454
+ {
455
+ ...{
456
+ className: "text-center",
457
+ role: "status"
458
+ },
459
+ children: import_location.locationCopy.asking
460
+ }
461
+ )
462
+ ]
379
463
  }
380
464
  )
381
465
  ]
@@ -579,50 +663,200 @@ const FormSubdomainAge = ({
579
663
  }
580
664
  );
581
665
  };
582
- const FormSubdomainInformation = ({
666
+ const drawnAs = {
667
+ note: "textarea",
668
+ pickup: "select"
669
+ };
670
+ const FormSubdomainItemList = ({
671
+ currency,
672
+ field,
673
+ onChange,
674
+ prices,
675
+ style,
676
+ value
677
+ }) => {
678
+ var _a;
679
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
680
+ "div",
681
+ {
682
+ ...{
683
+ className: "space-y-2"
684
+ },
685
+ children: [
686
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
687
+ "p",
688
+ {
689
+ ...{
690
+ className: "text-xs uppercase tracking-wide opacity-60"
691
+ },
692
+ children: field == null ? void 0 : field.label
693
+ }
694
+ ),
695
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
696
+ "div",
697
+ {
698
+ ...{
699
+ className: "space-y-4"
700
+ },
701
+ children: (((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.items) || []).map((item) => {
702
+ var _a2, _b;
703
+ const quantity = Number(value == null ? void 0 : value[item.id]) || 0;
704
+ const src = (0, import_cdn.cdnSrc)(item.image, "200x200", (_a2 = item.image) == null ? void 0 : _a2.updatedAt);
705
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
706
+ import_input_group.default,
707
+ {
708
+ ...{
709
+ error: (0, import_order.limitMessage)(item, quantity),
710
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
711
+ "div",
712
+ {
713
+ ...{
714
+ className: "flex items-center space-x-3"
715
+ },
716
+ children: [
717
+ src && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
718
+ "div",
719
+ {
720
+ ...{
721
+ className: "relative w-14 h-14 rounded overflow-hidden shrink-0"
722
+ },
723
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
724
+ import_image.default,
725
+ {
726
+ ...{
727
+ // The image's own description, else its file name, as every image slot.
728
+ alt: item.description || ((_b = item.image) == null ? void 0 : _b.filename) || "",
729
+ className: "object-cover",
730
+ fill: true,
731
+ sizes: "56px",
732
+ src,
733
+ unoptimized: true
734
+ }
735
+ }
736
+ )
737
+ }
738
+ ),
739
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
740
+ "div",
741
+ {
742
+ ...{
743
+ className: "flex-1 space-y-0.5 min-w-0"
744
+ },
745
+ children: [
746
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
747
+ "p",
748
+ {
749
+ ...{
750
+ className: "text-sm font-medium leading-tight line-clamp-2"
751
+ },
752
+ children: item.name
753
+ }
754
+ ),
755
+ prices && typeof item.price === "number" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
756
+ "p",
757
+ {
758
+ ...{
759
+ className: "text-xs opacity-60"
760
+ },
761
+ children: (0, import_drawbridge_utils.formatCurrency)({
762
+ code: currency.toUpperCase(),
763
+ display: "parts",
764
+ value: item.price
765
+ })
766
+ }
767
+ )
768
+ ]
769
+ }
770
+ ),
771
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
772
+ import_input_number.default,
773
+ {
774
+ ...{
775
+ // The item's limit is a Number field's attributes, spread as
776
+ // FieldNumber spreads them (bridge/fields.js).
777
+ min: 0,
778
+ ...item.attributes,
779
+ "aria-label": "Quantity of " + item.name,
780
+ inline: true,
781
+ layout: "split",
782
+ onChange: (next) => onChange({
783
+ ...value,
784
+ [item.id]: next
785
+ }),
786
+ small: true,
787
+ style,
788
+ value: quantity
789
+ }
790
+ }
791
+ )
792
+ ]
793
+ }
794
+ ),
795
+ style
796
+ }
797
+ },
798
+ item.id
799
+ );
800
+ })
801
+ }
802
+ )
803
+ ]
804
+ }
805
+ );
806
+ };
807
+ const FormSubdomainSection = ({
808
+ back,
583
809
  button,
584
810
  callback = () => {
585
811
  },
586
812
  disabled,
813
+ focus,
814
+ initial,
815
+ last,
587
816
  preview,
817
+ section,
818
+ slugs = [],
588
819
  style,
589
820
  values
590
821
  }) => {
591
822
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
592
- const fields = [
593
- ...((_a = values == null ? void 0 : values.fields) == null ? void 0 : _a.lead) || [],
594
- ...((_b = values == null ? void 0 : values.fields) == null ? void 0 : _b.additional) || []
595
- ];
596
- const slugs = fields.map((field) => field == null ? void 0 : field.slug);
597
- const smsConsent = Boolean((_d = (_c = values == null ? void 0 : values.agreements) == null ? void 0 : _c.sms) == null ? void 0 : _d.enabled) || slugs.includes("phone");
598
- const marketingConsent = Boolean((_f = (_e = values == null ? void 0 : values.agreements) == null ? void 0 : _e.marketing) == null ? void 0 : _f.enabled);
823
+ const fields = (section == null ? void 0 : section.fields) || [];
824
+ const lists = fields.filter((field) => (field == null ? void 0 : field.slug) === "list");
825
+ const prices = ((_a = section == null ? void 0 : section.settings) == null ? void 0 : _a.prices) !== false;
826
+ const currency = ((_b = section == null ? void 0 : section.settings) == null ? void 0 : _b.currency) || "usd";
827
+ const smsConsent = Boolean(last) && (Boolean((_d = (_c = values == null ? void 0 : values.agreements) == null ? void 0 : _c.sms) == null ? void 0 : _d.enabled) || slugs.includes("phone"));
828
+ const marketingConsent = Boolean(last) && Boolean((_f = (_e = values == null ? void 0 : values.agreements) == null ? void 0 : _e.marketing) == null ? void 0 : _f.enabled);
829
+ const termsConsent = Boolean(last) && Boolean((_h = (_g = values == null ? void 0 : values.agreements) == null ? void 0 : _g.terms) == null ? void 0 : _h.enabled);
599
830
  const schema = (0, import_react.useMemo)(
600
831
  () => {
601
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
602
- const memoFields = [
603
- ...((_a2 = values == null ? void 0 : values.fields) == null ? void 0 : _a2.lead) || [],
604
- ...((_b2 = values == null ? void 0 : values.fields) == null ? void 0 : _b2.additional) || []
605
- ];
606
- const memoSlugs = memoFields.map((field) => field == null ? void 0 : field.slug);
832
+ var _a2;
833
+ const memoFields = (section == null ? void 0 : section.fields) || [];
834
+ const memoLists = memoFields.filter((field) => (field == null ? void 0 : field.slug) === "list");
607
835
  const shape = {
608
836
  fields: import_yup.default.object(
609
837
  memoFields.reduce(
610
838
  (accumulator, field) => {
611
- accumulator[field.id] = import_fields.validate[field == null ? void 0 : field.slug](field, import_yup.default);
839
+ accumulator[field.id] = import_fields.validate[drawnAs[field == null ? void 0 : field.slug] || (field == null ? void 0 : field.slug)](field, import_yup.default);
612
840
  return accumulator;
613
841
  },
614
842
  {}
615
843
  )
616
844
  )
617
845
  };
846
+ if (memoLists.length > 0) {
847
+ shape.items = import_yup.default.mixed().test("items", import_fields.errors.items, function() {
848
+ var _a3;
849
+ return (0, import_fields_validate.ordersItems)(memoLists, (_a3 = this.parent) == null ? void 0 : _a3.fields);
850
+ });
851
+ }
618
852
  const agreements = {};
619
- if ((_d2 = (_c2 = values == null ? void 0 : values.agreements) == null ? void 0 : _c2.terms) == null ? void 0 : _d2.enabled) {
620
- agreements.terms = import_fields.validate.agreement((_e2 = values == null ? void 0 : values.agreements) == null ? void 0 : _e2.terms, import_yup.default);
853
+ if (termsConsent) {
854
+ agreements.terms = import_fields.validate.agreement((_a2 = values == null ? void 0 : values.agreements) == null ? void 0 : _a2.terms, import_yup.default);
621
855
  }
622
- if (Boolean((_g2 = (_f2 = values == null ? void 0 : values.agreements) == null ? void 0 : _f2.marketing) == null ? void 0 : _g2.enabled)) {
856
+ if (marketingConsent) {
623
857
  agreements.marketing = import_yup.default.bool();
624
858
  }
625
- if (Boolean((_i2 = (_h2 = values == null ? void 0 : values.agreements) == null ? void 0 : _h2.sms) == null ? void 0 : _i2.enabled) || memoSlugs.includes("phone")) {
859
+ if (smsConsent) {
626
860
  agreements.sms = import_yup.default.bool();
627
861
  }
628
862
  if (Object.keys(agreements).length > 0) {
@@ -630,11 +864,15 @@ const FormSubdomainInformation = ({
630
864
  }
631
865
  return import_yup.default.object(shape);
632
866
  },
633
- [values]
867
+ [marketingConsent, section, smsConsent, termsConsent, values]
634
868
  );
635
- const { control, handleSubmit, formState } = (0, import_react_hook_form.useForm)({
636
- resolver: (0, import_yup.resolver)(schema),
637
- values: {}
869
+ const { control, getValues, handleSubmit, formState } = (0, import_react_hook_form.useForm)({
870
+ defaultValues: initial || {},
871
+ resolver: (0, import_yup.resolver)(schema)
872
+ });
873
+ const answers = (0, import_react_hook_form.useWatch)({
874
+ control,
875
+ name: "fields"
638
876
  });
639
877
  const checkbox = ({
640
878
  fallback,
@@ -668,6 +906,54 @@ const FormSubdomainInformation = ({
668
906
  }
669
907
  );
670
908
  };
909
+ const count = (0, import_order.itemCount)(lists, answers);
910
+ const itemsError = (_j = (_i = formState == null ? void 0 : formState.errors) == null ? void 0 : _i.items) == null ? void 0 : _j.message;
911
+ const totalBlock = (prices || itemsError) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
912
+ "div",
913
+ {
914
+ ...{
915
+ className: "space-y-4"
916
+ },
917
+ children: [
918
+ prices && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
919
+ "div",
920
+ {
921
+ ...{
922
+ className: "flex items-center justify-between text-sm"
923
+ },
924
+ children: [
925
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "ESTIMATED TOTAL \xB7 " + count + " " + (count === 1 ? "ITEM" : "ITEMS") }),
926
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: (0, import_drawbridge_utils.formatCurrency)({
927
+ code: currency.toUpperCase(),
928
+ display: "parts",
929
+ value: (0, import_order.orderTotal)(lists, answers)
930
+ }) })
931
+ ]
932
+ }
933
+ ),
934
+ itemsError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
935
+ import_error.default,
936
+ {
937
+ ...{
938
+ error: itemsError,
939
+ style
940
+ }
941
+ }
942
+ )
943
+ ]
944
+ }
945
+ );
946
+ const consent = [
947
+ termsConsent && ["terms"],
948
+ marketingConsent && ["marketing", import_entry.agreementWording.marketing],
949
+ smsConsent && ["sms", import_entry.agreementWording.sms]
950
+ ].filter(Boolean);
951
+ const faded = (key) => focus && key !== focus ? "opacity-25" : "";
952
+ const focused = (0, import_react.useRef)(null);
953
+ (0, import_react.useEffect)(
954
+ () => scrollToCentre(focused.current),
955
+ [focus]
956
+ );
671
957
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
672
958
  import_form.default,
673
959
  {
@@ -677,22 +963,45 @@ const FormSubdomainInformation = ({
677
963
  },
678
964
  children: [
679
965
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
680
- import_form_subdomain_header.FormSubdomainHeader,
966
+ "div",
681
967
  {
682
968
  ...{
683
- button,
684
- style,
685
- title: "Your information"
686
- }
969
+ className: faded()
970
+ },
971
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
972
+ import_form_subdomain_header.FormSubdomainHeader,
973
+ {
974
+ ...{
975
+ // Back keeps what this step holds so far, answered or not.
976
+ ...back && {
977
+ back: {
978
+ onClick: () => back(getValues())
979
+ }
980
+ },
981
+ button,
982
+ description: section == null ? void 0 : section.description,
983
+ style,
984
+ title: section == null ? void 0 : section.title
985
+ }
986
+ }
987
+ )
687
988
  }
688
989
  ),
689
990
  Boolean(preview) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
690
- import_error.default,
991
+ "div",
691
992
  {
692
993
  ...{
693
- error: "Preview mode: data not collected",
694
- style
695
- }
994
+ className: faded()
995
+ },
996
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
997
+ import_error.default,
998
+ {
999
+ ...{
1000
+ error: "Preview mode: data not collected",
1001
+ style
1002
+ }
1003
+ }
1004
+ )
696
1005
  }
697
1006
  ),
698
1007
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
@@ -707,134 +1016,111 @@ const FormSubdomainInformation = ({
707
1016
  "div",
708
1017
  {
709
1018
  ...{
710
- className: "space-y-4"
711
- },
712
- children: fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
713
- import_react_hook_form.Controller,
714
- {
715
- ...{
716
- control,
717
- name: "fields." + field.id,
718
- render: ({ field: { onChange, value } }) => {
719
- var _a2, _b2;
720
- return import_fields.components[field == null ? void 0 : field.slug]({
721
- error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.fields) == null ? void 0 : _b2[field == null ? void 0 : field.id],
722
- field,
723
- onChange,
724
- style,
725
- value
726
- });
727
- }
728
- }
729
- },
730
- field == null ? void 0 : field.id
731
- ))
732
- }
733
- ),
734
- (Boolean((_h = (_g = values == null ? void 0 : values.agreements) == null ? void 0 : _g.terms) == null ? void 0 : _h.enabled) || marketingConsent || smsConsent) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
735
- "div",
736
- {
737
- ...{
738
- className: "space-y-4"
1019
+ className: (lists.length > 0 ? "space-y-6 " : "space-y-4 ") + faded()
739
1020
  },
740
- children: [
741
- Boolean((_j = (_i = values == null ? void 0 : values.agreements) == null ? void 0 : _i.terms) == null ? void 0 : _j.enabled) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1021
+ children: fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
1022
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
742
1023
  import_react_hook_form.Controller,
743
1024
  {
744
1025
  ...{
745
1026
  control,
746
- name: "agreements.terms",
747
- render: ({ field: { value, onChange } }) => {
748
- var _a2, _b2, _c2;
749
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
750
- import_input_group.default,
1027
+ name: "fields." + field.id,
1028
+ render: ({ field: { onChange, value } }) => {
1029
+ var _a2, _b2;
1030
+ return (field == null ? void 0 : field.slug) === "list" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1031
+ FormSubdomainItemList,
751
1032
  {
752
1033
  ...{
753
- error: (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.agreements) == null ? void 0 : _b2.terms) == null ? void 0 : _c2.message,
754
- input: checkbox({
755
- key: "terms",
756
- onChange,
757
- value
758
- }),
759
- style
1034
+ currency,
1035
+ field,
1036
+ onChange,
1037
+ prices,
1038
+ style,
1039
+ value
760
1040
  }
761
1041
  }
762
- );
1042
+ ) : import_fields.components[drawnAs[field == null ? void 0 : field.slug] || (field == null ? void 0 : field.slug)]({
1043
+ error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.fields) == null ? void 0 : _b2[field == null ? void 0 : field.id],
1044
+ field,
1045
+ onChange,
1046
+ style,
1047
+ value
1048
+ });
763
1049
  }
764
1050
  }
765
1051
  }
766
1052
  ),
767
- marketingConsent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
768
- import_react_hook_form.Controller,
769
- {
770
- ...{
771
- control,
772
- name: "agreements.marketing",
773
- render: ({ field: { value, onChange } }) => {
774
- var _a2, _b2, _c2;
775
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
776
- import_input_group.default,
777
- {
778
- ...{
779
- error: (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.agreements) == null ? void 0 : _b2.marketing) == null ? void 0 : _c2.message,
780
- input: checkbox({
781
- fallback: "I agree to receive marketing emails about this campaign. Unsubscribe any time.",
782
- key: "marketing",
783
- onChange,
784
- value
785
- }),
786
- style
787
- }
788
- }
789
- );
790
- }
1053
+ (0, import_order.isLastList)(fields, field == null ? void 0 : field.id) && totalBlock
1054
+ ] }, field == null ? void 0 : field.id))
1055
+ }
1056
+ ),
1057
+ consent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1058
+ "div",
1059
+ {
1060
+ ...{
1061
+ className: "space-y-4"
1062
+ },
1063
+ children: consent.map(([key, fallback]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1064
+ "div",
1065
+ {
1066
+ ...{
1067
+ className: faded(key),
1068
+ ...key === focus && {
1069
+ ref: focused
791
1070
  }
792
- }
793
- ),
794
- smsConsent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
795
- import_react_hook_form.Controller,
796
- {
797
- ...{
798
- control,
799
- name: "agreements.sms",
800
- render: ({ field: { value, onChange } }) => {
801
- var _a2, _b2, _c2;
802
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
803
- import_input_group.default,
804
- {
805
- ...{
806
- error: (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.agreements) == null ? void 0 : _b2.sms) == null ? void 0 : _c2.message,
807
- input: checkbox({
808
- // The default wording carrier reviewers look
809
- // for: explicit texts, rates, and STOP.
810
- fallback: "I agree to receive text messages about this campaign. Message and data rates may apply. Reply STOP to opt out.",
811
- key: "sms",
812
- onChange,
813
- value
814
- }),
815
- style
1071
+ },
1072
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1073
+ import_react_hook_form.Controller,
1074
+ {
1075
+ ...{
1076
+ control,
1077
+ name: "agreements." + key,
1078
+ render: ({ field: { value, onChange } }) => {
1079
+ var _a2, _b2, _c2;
1080
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1081
+ import_input_group.default,
1082
+ {
1083
+ ...{
1084
+ error: (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.agreements) == null ? void 0 : _b2[key]) == null ? void 0 : _c2.message,
1085
+ input: checkbox({
1086
+ fallback,
1087
+ key,
1088
+ onChange,
1089
+ value
1090
+ }),
1091
+ style
1092
+ }
816
1093
  }
817
- }
818
- );
1094
+ );
1095
+ }
819
1096
  }
820
1097
  }
821
- }
822
- )
823
- ]
1098
+ )
1099
+ },
1100
+ key
1101
+ ))
824
1102
  }
825
1103
  )
826
1104
  ]
827
1105
  }
828
1106
  ),
829
1107
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
830
- FormSubdomainButton,
1108
+ "div",
831
1109
  {
832
1110
  ...{
833
- disabled,
834
- style,
835
- submitting: formState == null ? void 0 : formState.isSubmitting,
836
- text: "Submit"
837
- }
1111
+ className: faded()
1112
+ },
1113
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1114
+ FormSubdomainButton,
1115
+ {
1116
+ ...{
1117
+ disabled,
1118
+ style,
1119
+ submitting: formState == null ? void 0 : formState.isSubmitting,
1120
+ text: last ? "Submit" : "Next"
1121
+ }
1122
+ }
1123
+ )
838
1124
  }
839
1125
  )
840
1126
  ]
@@ -846,6 +1132,7 @@ const FormSubdomain = ({
846
1132
  button,
847
1133
  disabled,
848
1134
  fields,
1135
+ focus,
849
1136
  integrations,
850
1137
  onCheckout,
851
1138
  onError = () => {
@@ -854,6 +1141,7 @@ const FormSubdomain = ({
854
1141
  },
855
1142
  params,
856
1143
  preview,
1144
+ step: start = 0,
857
1145
  style,
858
1146
  tracking
859
1147
  }) => {
@@ -862,7 +1150,17 @@ const FormSubdomain = ({
862
1150
  const searchParams = (0, import_navigation.useSearchParams)();
863
1151
  const token = searchParams.get("drwbrdg_pre");
864
1152
  const [data, setData] = (0, import_react.useState)({});
865
- const [step, setStep] = (0, import_react.useState)(0);
1153
+ const [step, setStep] = (0, import_react.useState)(start);
1154
+ const sections = (0, import_order.sectionsOf)(fields);
1155
+ const slugs = sections.flatMap((section) => ((section == null ? void 0 : section.fields) || []).map((field) => field == null ? void 0 : field.slug));
1156
+ const merge = (object = {}) => ({
1157
+ ...data,
1158
+ ...object,
1159
+ fields: {
1160
+ ...data.fields,
1161
+ ...object.fields
1162
+ }
1163
+ });
866
1164
  const onSubmit = (0, import_react.useCallback)(
867
1165
  async (values) => {
868
1166
  var _a2, _b2;
@@ -879,7 +1177,6 @@ const FormSubdomain = ({
879
1177
  const response = await (0, import_fetch.request)({
880
1178
  body: {
881
1179
  ...values,
882
- entries: 1,
883
1180
  preview,
884
1181
  recaptcha,
885
1182
  tracking: (_b2 = tracking == null ? void 0 : tracking.context) == null ? void 0 : _b2.call(tracking)
@@ -964,26 +1261,40 @@ const FormSubdomain = ({
964
1261
  "form-subdomain-age"
965
1262
  )
966
1263
  ] : [],
967
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
968
- FormSubdomainInformation,
1264
+ ...sections.map((section, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1265
+ FormSubdomainSection,
969
1266
  {
970
1267
  ...{
1268
+ // Back moves between sections; it never returns into the location or age step.
1269
+ back: index > 0 ? (object) => {
1270
+ setData(merge(object));
1271
+ setStep(step - 1);
1272
+ } : null,
971
1273
  button,
972
- callback: async (object) => await onSubmit({
973
- ...data,
974
- ...object
975
- }),
1274
+ callback: async (object) => {
1275
+ const merged = merge(object);
1276
+ if (index < sections.length - 1) {
1277
+ setData(merged);
1278
+ setStep(step + 1);
1279
+ return;
1280
+ }
1281
+ await onSubmit(merged);
1282
+ },
976
1283
  disabled,
1284
+ focus,
1285
+ initial: data,
1286
+ last: index === sections.length - 1,
977
1287
  preview,
1288
+ section,
1289
+ slugs,
978
1290
  style,
979
1291
  values: {
980
- agreements,
981
- fields
1292
+ agreements
982
1293
  }
983
1294
  }
984
1295
  },
985
- "form-subdomain-information"
986
- )
1296
+ "form-subdomain-section-" + section.id
1297
+ ))
987
1298
  ];
988
1299
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
989
1300
  "div",
@@ -1006,7 +1317,6 @@ const FormSubdomain = ({
1006
1317
  var form_subdomain_default = FormSubdomain;
1007
1318
  // Annotate the CommonJS export names for ESM import in node:
1008
1319
  0 && (module.exports = {
1009
- FormSubdomainHeader,
1010
1320
  FormSubdomainMessage,
1011
1321
  FormSubdomainSubmission
1012
1322
  });