@drawbridge/components 0.1.13 → 0.1.14

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 (236) 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 +538 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +502 -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 +265 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +231 -0
  48. package/dist/dashboard/card-order.js +28 -11
  49. package/dist/dashboard/card-order.mjs +28 -11
  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 +196 -0
  55. package/dist/dashboard/connection-workflows.mjs +162 -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-integration-age.js +6 -12
  81. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  82. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  83. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  84. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  87. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  88. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  89. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  90. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  91. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  94. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  95. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  96. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  97. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-section.js +223 -0
  99. package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
  100. package/dist/dashboard/form-organization-campaign.js +114 -469
  101. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  102. package/dist/dashboard/form-organization-export.js +4 -7
  103. package/dist/dashboard/form-organization-export.mjs +4 -7
  104. package/dist/dashboard/form-organization-identity.js +46 -51
  105. package/dist/dashboard/form-organization-identity.mjs +46 -51
  106. package/dist/dashboard/form-organization-workflow.js +518 -686
  107. package/dist/dashboard/form-organization-workflow.mjs +517 -682
  108. package/dist/dashboard/form-organization.js +82 -110
  109. package/dist/dashboard/form-organization.mjs +81 -109
  110. package/dist/dashboard/form-otc.js +4 -5
  111. package/dist/dashboard/form-otc.mjs +4 -5
  112. package/dist/dashboard/form-payment-methods.js +20 -9
  113. package/dist/dashboard/form-payment-methods.mjs +20 -9
  114. package/dist/dashboard/form-stripe.js +30 -0
  115. package/dist/dashboard/form-stripe.mjs +26 -0
  116. package/dist/dashboard/input-array.js +4 -2
  117. package/dist/dashboard/input-array.mjs +4 -2
  118. package/dist/dashboard/input-combobox.js +7 -3
  119. package/dist/dashboard/input-combobox.mjs +7 -3
  120. package/dist/dashboard/input-date.js +7 -0
  121. package/dist/dashboard/input-date.mjs +7 -0
  122. package/dist/dashboard/input-fields.js +80 -20
  123. package/dist/dashboard/input-fields.mjs +80 -20
  124. package/dist/dashboard/input-file.js +21 -1
  125. package/dist/dashboard/input-file.mjs +21 -1
  126. package/dist/dashboard/input-font.js +10 -1
  127. package/dist/dashboard/input-font.mjs +10 -1
  128. package/dist/dashboard/lib/item-list.js +57 -0
  129. package/dist/dashboard/lib/item-list.mjs +33 -0
  130. package/dist/dashboard/lib/menu.js +50 -0
  131. package/dist/dashboard/lib/menu.mjs +26 -0
  132. package/dist/dashboard/locked.js +82 -0
  133. package/dist/dashboard/locked.mjs +53 -0
  134. package/dist/dashboard/menu.js +72 -19
  135. package/dist/dashboard/menu.mjs +72 -19
  136. package/dist/dashboard/note-ai.js +69 -0
  137. package/dist/dashboard/note-ai.mjs +36 -0
  138. package/dist/dashboard/preview.js +419 -0
  139. package/dist/dashboard/preview.mjs +384 -0
  140. package/dist/dashboard/steps.js +39 -13
  141. package/dist/dashboard/steps.mjs +37 -12
  142. package/dist/dashboard/table-contacts.js +136 -0
  143. package/dist/dashboard/table-contacts.mjs +103 -0
  144. package/dist/dashboard/template-not-found.js +4 -2
  145. package/dist/dashboard/template-not-found.mjs +4 -2
  146. package/dist/dashboard/template-socket.js +20 -7
  147. package/dist/dashboard/template-socket.mjs +20 -7
  148. package/dist/icons/desktop.js +46 -0
  149. package/dist/icons/desktop.mjs +27 -0
  150. package/dist/icons/phone.js +46 -0
  151. package/dist/icons/phone.mjs +27 -0
  152. package/dist/icons/puzzle-piece.js +46 -0
  153. package/dist/icons/puzzle-piece.mjs +27 -0
  154. package/dist/icons/tablet.js +46 -0
  155. package/dist/icons/tablet.mjs +27 -0
  156. package/dist/icons/users.js +46 -0
  157. package/dist/icons/users.mjs +27 -0
  158. package/dist/input-checkbox.js +1 -0
  159. package/dist/input-checkbox.mjs +1 -0
  160. package/dist/input-code.js +101 -0
  161. package/dist/input-code.mjs +78 -0
  162. package/dist/input-text.js +2 -1
  163. package/dist/input-text.mjs +2 -1
  164. package/dist/shared/input-checkbox-list.js +0 -1
  165. package/dist/shared/input-checkbox-list.mjs +0 -1
  166. package/dist/shared/input-switch.js +6 -1
  167. package/dist/shared/input-switch.mjs +6 -1
  168. package/dist/shared/lib/campaign.js +117 -0
  169. package/dist/shared/lib/campaign.mjs +91 -0
  170. package/dist/shared/lib/helpers.js +14 -2
  171. package/dist/shared/lib/helpers.mjs +13 -2
  172. package/package.json +133 -13
  173. package/types/bridge/form-subdomain-header.d.ts +2 -0
  174. package/types/bridge/form-subdomain-missions.d.ts +36 -0
  175. package/types/bridge/form-subdomain.d.ts +23 -1
  176. package/types/bridge/lib/entry.d.ts +26 -0
  177. package/types/bridge/lib/location.d.ts +13 -0
  178. package/types/bridge/lib/order.d.ts +30 -0
  179. package/types/bridge/lib/url.d.ts +19 -0
  180. package/types/bridge/template-modal.d.ts +1 -1
  181. package/types/bridge/template-preview.d.ts +10 -0
  182. package/types/bridge/template-subdomain-link.d.ts +2 -0
  183. package/types/dashboard/accordion.d.ts +2 -0
  184. package/types/dashboard/avatar.d.ts +18 -2
  185. package/types/dashboard/buttons-subscription.d.ts +22 -0
  186. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  187. package/types/dashboard/card-order.d.ts +11 -0
  188. package/types/dashboard/card-section.d.ts +2 -0
  189. package/types/dashboard/connection-workflows.d.ts +33 -0
  190. package/types/dashboard/device.d.ts +12 -0
  191. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  192. package/types/dashboard/form-ai.d.ts +2 -2
  193. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  194. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  195. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  196. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  197. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  198. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  199. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  200. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  201. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  202. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  203. package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
  204. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  205. package/types/dashboard/form-organization-identity.d.ts +2 -0
  206. package/types/dashboard/form-organization-workflow.d.ts +43 -47
  207. package/types/dashboard/form-organization.d.ts +7 -2
  208. package/types/dashboard/form-stripe.d.ts +3 -0
  209. package/types/dashboard/input-combobox.d.ts +2 -0
  210. package/types/dashboard/input-date.d.ts +2 -0
  211. package/types/dashboard/input-fields.d.ts +3 -2
  212. package/types/dashboard/input-file.d.ts +4 -0
  213. package/types/dashboard/lib/item-list.d.ts +14 -0
  214. package/types/dashboard/lib/menu.d.ts +17 -0
  215. package/types/dashboard/locked.d.ts +10 -0
  216. package/types/dashboard/menu.d.ts +10 -2
  217. package/types/dashboard/note-ai.d.ts +15 -0
  218. package/types/dashboard/preview.d.ts +33 -0
  219. package/types/dashboard/steps.d.ts +19 -4
  220. package/types/dashboard/table-cell-title.d.ts +2 -2
  221. package/types/dashboard/table-contacts.d.ts +2 -0
  222. package/types/icons/desktop.d.ts +5 -0
  223. package/types/icons/phone.d.ts +5 -0
  224. package/types/icons/puzzle-piece.d.ts +5 -0
  225. package/types/icons/tablet.d.ts +5 -0
  226. package/types/icons/users.d.ts +5 -0
  227. package/types/input-code.d.ts +23 -0
  228. package/types/shared/input-switch.d.ts +2 -0
  229. package/types/shared/lib/campaign.d.ts +35 -0
  230. package/types/shared/lib/helpers.d.ts +3 -0
  231. package/dist/dashboard/card-integration.js +0 -187
  232. package/dist/dashboard/card-integration.mjs +0 -158
  233. package/dist/dashboard/iframe.js +0 -159
  234. package/dist/dashboard/iframe.mjs +0 -130
  235. package/types/dashboard/card-integration.d.ts +0 -24
  236. package/types/dashboard/iframe.d.ts +0 -18
@@ -46,17 +46,18 @@ var import_overlay = __toESM(require("../shared/overlay"));
46
46
  var import_button = __toESM(require("../shared/button"));
47
47
  var import_link = __toESM(require("next/link"));
48
48
  var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
49
- var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
50
49
  var import_constants = __toESM(require("./lib/constants"));
51
50
  var import_checkout_kit = require("./lib/checkout-kit");
52
51
  var import_provider_analytics = require("./provider-analytics");
52
+ var import_entry = require("./lib/entry");
53
+ var import_url = require("./lib/url");
53
54
  const TemplateModal = (0, import_dynamic.default)(() => import("./template-modal"), { ssr: false });
54
55
  const TemplateLayout = ({
55
56
  params,
56
57
  result,
57
58
  userAgent
58
59
  }) => {
59
- var _a, _b, _c, _d, _e;
60
+ var _a, _b, _c, _d;
60
61
  const searchParams = (0, import_navigation.useSearchParams)();
61
62
  const token = searchParams.get("drwbrdg_pre");
62
63
  const preview = Boolean(token);
@@ -79,6 +80,7 @@ const TemplateLayout = ({
79
80
  const [panel, setPanel] = (0, import_react.useState)(submissionId ? {
80
81
  name: "submission",
81
82
  data: {
83
+ giveaway: (0, import_entry.awardingOn)(result),
82
84
  id: submissionId,
83
85
  title: "Keep going",
84
86
  preview,
@@ -100,7 +102,6 @@ const TemplateLayout = ({
100
102
  affiliate,
101
103
  campaign: data == null ? void 0 : data.campaign,
102
104
  onComplete: () => {
103
- var _a2;
104
105
  if (typeof window !== "undefined") {
105
106
  window.localStorage.removeItem(cartStorageKey);
106
107
  window.localStorage.removeItem(cartStorageKey + "_expiry");
@@ -110,7 +111,7 @@ const TemplateLayout = ({
110
111
  setPanel({
111
112
  name: "purchase",
112
113
  data: {
113
- message: ((_a2 = data == null ? void 0 : data.defaults) == null ? void 0 : _a2.purchase) || "Thank you for your purchase"
114
+ message: (0, import_entry.copy)(data, "purchase")
114
115
  }
115
116
  });
116
117
  setModal(true);
@@ -123,7 +124,7 @@ const TemplateLayout = ({
123
124
  subdomain: params == null ? void 0 : params.subdomain,
124
125
  ...args
125
126
  }),
126
- [affiliate, cartStorageKey, data == null ? void 0 : data.campaign, (_a = data == null ? void 0 : data.defaults) == null ? void 0 : _a.purchase, data == null ? void 0 : data.organization, data == null ? void 0 : data.page, params == null ? void 0 : params.slug, params == null ? void 0 : params.subdomain, redirectToCheckout]
127
+ [affiliate, cartStorageKey, data, params == null ? void 0 : params.slug, params == null ? void 0 : params.subdomain, redirectToCheckout]
127
128
  );
128
129
  const openCheckout = (0, import_react.useCallback)(
129
130
  (checkoutUrl) => checkout({ checkoutUrl }),
@@ -313,7 +314,7 @@ const TemplateLayout = ({
313
314
  event,
314
315
  preview: preview2
315
316
  }) => {
316
- var _a2, _b2, _c2, _d2, _e2, _f, _g;
317
+ var _a2, _b2, _c2, _d2, _e, _f, _g;
317
318
  let trusted = false;
318
319
  try {
319
320
  trusted = Boolean(
@@ -326,7 +327,7 @@ const TemplateLayout = ({
326
327
  setIframe(true);
327
328
  }
328
329
  if (preview2 && trusted && ((_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.update)) {
329
- const headline = ((_c2 = (_b2 = event == null ? void 0 : event.data) == null ? void 0 : _b2.update) == null ? void 0 : _c2.headline) || ((_d2 = result == null ? void 0 : result.data) == null ? void 0 : _d2.headline) || ((_f = (_e2 = import_constants.default) == null ? void 0 : _e2.form) == null ? void 0 : _f.headline);
330
+ const headline = ((_c2 = (_b2 = event == null ? void 0 : event.data) == null ? void 0 : _b2.update) == null ? void 0 : _c2.headline) || ((_d2 = result == null ? void 0 : result.data) == null ? void 0 : _d2.headline) || ((_f = (_e = import_constants.default) == null ? void 0 : _e.form) == null ? void 0 : _f.headline);
330
331
  setData({
331
332
  ...result,
332
333
  ...(_g = event == null ? void 0 : event.data) == null ? void 0 : _g.update,
@@ -354,6 +355,13 @@ const TemplateLayout = ({
354
355
  preview
355
356
  });
356
357
  window.addEventListener("message", onRecievedMessage);
358
+ if (preview && window.parent !== window) {
359
+ try {
360
+ window.parent.postMessage({ ready: true }, new URL(process.env.NEXT_PUBLIC_DASHBOARD_URI).origin);
361
+ } catch {
362
+ }
363
+ }
364
+ ;
357
365
  return () => {
358
366
  window.removeEventListener("message", onRecievedMessage);
359
367
  document.documentElement.style.background = "";
@@ -361,18 +369,21 @@ const TemplateLayout = ({
361
369
  document.documentElement.style.color = "";
362
370
  };
363
371
  },
364
- [iframeMessageResponse, preview, tracking, (_c = (_b = style == null ? void 0 : style.background) == null ? void 0 : _b.color) == null ? void 0 : _c.rgb, (_e = (_d = style == null ? void 0 : style.text) == null ? void 0 : _d.color) == null ? void 0 : _e.rgb, userAgent]
372
+ [iframeMessageResponse, preview, tracking, (_b = (_a = style == null ? void 0 : style.background) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb, (_d = (_c = style == null ? void 0 : style.text) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb, userAgent]
365
373
  );
366
374
  const submission = (0, import_react.useCallback)(
367
- ({ id, lead, message, title }) => {
375
+ ({ id, lead, message, panel: answer, repeat, title }) => {
368
376
  setPanel({
369
377
  name: "submission",
370
378
  data: {
371
379
  affiliate,
380
+ giveaway: (0, import_entry.awardingOn)(data),
372
381
  id,
373
382
  lead,
374
383
  message,
384
+ panel: answer,
375
385
  preview,
386
+ repeat,
376
387
  style,
377
388
  title,
378
389
  ...params
@@ -380,11 +391,36 @@ const TemplateLayout = ({
380
391
  });
381
392
  setModal(true);
382
393
  },
383
- [affiliate, params, preview, style]
394
+ [affiliate, data, params, preview, style]
395
+ );
396
+ const leadMission = searchParams.get("mission");
397
+ const leadUrl = submissionId ? null : (0, import_url.leadEndpoint)({ lead: searchParams.get("lead"), slug: params == null ? void 0 : params.slug, subdomain: params == null ? void 0 : params.subdomain, token });
398
+ (0, import_react.useEffect)(
399
+ () => {
400
+ if (!leadUrl) return;
401
+ (0, import_fetch.request)({
402
+ cache: "no-store",
403
+ endpoint: leadUrl,
404
+ method: "GET"
405
+ }).then(({ result: result2 }) => {
406
+ var _a2;
407
+ if (!((_a2 = result2 == null ? void 0 : result2.missions) == null ? void 0 : _a2.length)) return;
408
+ setPanel({
409
+ name: "lead",
410
+ data: {
411
+ ...result2,
412
+ mission: leadMission
413
+ }
414
+ });
415
+ setModal(true);
416
+ }).catch(() => {
417
+ });
418
+ },
419
+ [leadMission, leadUrl]
384
420
  );
385
421
  const buttons = (0, import_react.useMemo)(
386
422
  () => {
387
- var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
423
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
388
424
  const branding = (compact = false) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
389
425
  "div",
390
426
  {
@@ -429,7 +465,7 @@ const TemplateLayout = ({
429
465
  branding: branding(),
430
466
  brandingCompact: branding(true),
431
467
  close: (name) => {
432
- var _a3, _b3, _c3, _d3, _e3, _f2, _g2, _h2, _i2, _j2, _k2;
468
+ var _a3, _b3, _c3, _d3, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
433
469
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
434
470
  import_button.default,
435
471
  {
@@ -451,7 +487,7 @@ const TemplateLayout = ({
451
487
  className: "flex items-center justify-center w-6 h-6 rounded-full",
452
488
  ...style && {
453
489
  style: {
454
- backgroundColor: ((_c3 = (_b3 = (_a3 = style == null ? void 0 : style.button) == null ? void 0 : _a3.background) == null ? void 0 : _b3.color) == null ? void 0 : _c3.rgb) || ((_e3 = (_d3 = style == null ? void 0 : style.text) == null ? void 0 : _d3.color) == null ? void 0 : _e3.rgb),
490
+ backgroundColor: ((_c3 = (_b3 = (_a3 = style == null ? void 0 : style.button) == null ? void 0 : _a3.background) == null ? void 0 : _b3.color) == null ? void 0 : _c3.rgb) || ((_e2 = (_d3 = style == null ? void 0 : style.text) == null ? void 0 : _d3.color) == null ? void 0 : _e2.rgb),
455
491
  borderRadius: ((_f2 = style == null ? void 0 : style.button) == null ? void 0 : _f2.radius) != null ? style.button.radius / 4 + "px" : void 0,
456
492
  color: ((_i2 = (_h2 = (_g2 = style == null ? void 0 : style.button) == null ? void 0 : _g2.text) == null ? void 0 : _h2.color) == null ? void 0 : _i2.rgb) || ((_k2 = (_j2 = style == null ? void 0 : style.background) == null ? void 0 : _j2.color) == null ? void 0 : _k2.rgb)
457
493
  }
@@ -471,7 +507,9 @@ const TemplateLayout = ({
471
507
  }
472
508
  );
473
509
  },
474
- enter: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
510
+ // @story public-entry/view-page
511
+ // The form off: no Enter button, the owner's preview included.
512
+ enter: (0, import_entry.formOn)(data) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
475
513
  import_button.default,
476
514
  {
477
515
  ...{
@@ -487,7 +525,7 @@ const TemplateLayout = ({
487
525
  },
488
526
  style
489
527
  },
490
- children: preview || Boolean(data == null ? void 0 : data.valid) ? ((_a2 = data == null ? void 0 : data.defaults) == null ? void 0 : _a2.active) || ((_d2 = (_c2 = (_b2 = import_drawbridge_utils.constants) == null ? void 0 : _b2.campaign) == null ? void 0 : _c2.defaults) == null ? void 0 : _d2.active) : ((_e2 = data == null ? void 0 : data.defaults) == null ? void 0 : _e2.inactive) || ((_h = (_g = (_f = import_drawbridge_utils.constants) == null ? void 0 : _f.campaign) == null ? void 0 : _g.defaults) == null ? void 0 : _h.inactive)
528
+ children: (0, import_entry.buttonText)(data, preview || Boolean(data == null ? void 0 : data.valid))
491
529
  }
492
530
  ),
493
531
  menu: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -514,10 +552,10 @@ const TemplateLayout = ({
514
552
  className: "flex items-center justify-center w-10 h-10 border border-current rounded-full",
515
553
  ...style && {
516
554
  style: {
517
- backgroundColor: ((_k = (_j = (_i = style == null ? void 0 : style.button) == null ? void 0 : _i.background) == null ? void 0 : _j.color) == null ? void 0 : _k.rgb) || ((_m = (_l = style == null ? void 0 : style.text) == null ? void 0 : _l.color) == null ? void 0 : _m.rgb),
518
- borderColor: ((_p = (_o = (_n = style == null ? void 0 : style.button) == null ? void 0 : _n.background) == null ? void 0 : _o.color) == null ? void 0 : _p.rgb) || ((_r = (_q = style == null ? void 0 : style.text) == null ? void 0 : _q.color) == null ? void 0 : _r.rgb),
519
- borderRadius: ((_s = style == null ? void 0 : style.button) == null ? void 0 : _s.radius) != null ? style.button.radius / 4 + "px" : void 0,
520
- color: ((_v = (_u = (_t = style == null ? void 0 : style.button) == null ? void 0 : _t.text) == null ? void 0 : _u.color) == null ? void 0 : _v.rgb) || ((_x = (_w = style == null ? void 0 : style.background) == null ? void 0 : _w.color) == null ? void 0 : _x.rgb)
555
+ backgroundColor: ((_c2 = (_b2 = (_a2 = style == null ? void 0 : style.button) == null ? void 0 : _a2.background) == null ? void 0 : _b2.color) == null ? void 0 : _c2.rgb) || ((_e = (_d2 = style == null ? void 0 : style.text) == null ? void 0 : _d2.color) == null ? void 0 : _e.rgb),
556
+ borderColor: ((_h = (_g = (_f = style == null ? void 0 : style.button) == null ? void 0 : _f.background) == null ? void 0 : _g.color) == null ? void 0 : _h.rgb) || ((_j = (_i = style == null ? void 0 : style.text) == null ? void 0 : _i.color) == null ? void 0 : _j.rgb),
557
+ borderRadius: ((_k = style == null ? void 0 : style.button) == null ? void 0 : _k.radius) != null ? style.button.radius / 4 + "px" : void 0,
558
+ color: ((_n = (_m = (_l = style == null ? void 0 : style.button) == null ? void 0 : _l.text) == null ? void 0 : _m.color) == null ? void 0 : _n.rgb) || ((_p = (_o = style == null ? void 0 : style.background) == null ? void 0 : _o.color) == null ? void 0 : _p.rgb)
521
559
  }
522
560
  }
523
561
  },
@@ -578,7 +616,7 @@ const TemplateLayout = ({
578
616
  );
579
617
  },
580
618
  shop: (name = "shop") => {
581
- var _a3, _b3, _c3, _d3, _e3, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
619
+ var _a3, _b3, _c3, _d3, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
582
620
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
583
621
  import_button.default,
584
622
  {
@@ -603,7 +641,7 @@ const TemplateLayout = ({
603
641
  className: "flex items-center justify-center h-10 border border-current rounded-full " + (cartCount > 0 ? "pl-3 pr-4 space-x-1" : "w-10"),
604
642
  ...style && {
605
643
  style: {
606
- backgroundColor: ((_c3 = (_b3 = (_a3 = style == null ? void 0 : style.button) == null ? void 0 : _a3.background) == null ? void 0 : _b3.color) == null ? void 0 : _c3.rgb) || ((_e3 = (_d3 = style == null ? void 0 : style.text) == null ? void 0 : _d3.color) == null ? void 0 : _e3.rgb),
644
+ backgroundColor: ((_c3 = (_b3 = (_a3 = style == null ? void 0 : style.button) == null ? void 0 : _a3.background) == null ? void 0 : _b3.color) == null ? void 0 : _c3.rgb) || ((_e2 = (_d3 = style == null ? void 0 : style.text) == null ? void 0 : _d3.color) == null ? void 0 : _e2.rgb),
607
645
  borderColor: ((_h2 = (_g2 = (_f2 = style == null ? void 0 : style.button) == null ? void 0 : _f2.background) == null ? void 0 : _g2.color) == null ? void 0 : _h2.rgb) || ((_j2 = (_i2 = style == null ? void 0 : style.text) == null ? void 0 : _i2.color) == null ? void 0 : _j2.rgb),
608
646
  borderRadius: ((_k2 = style == null ? void 0 : style.button) == null ? void 0 : _k2.radius) != null ? style.button.radius / 4 + "px" : void 0,
609
647
  color: ((_n2 = (_m2 = (_l2 = style == null ? void 0 : style.button) == null ? void 0 : _l2.text) == null ? void 0 : _m2.color) == null ? void 0 : _n2.rgb) || ((_p2 = (_o2 = style == null ? void 0 : style.background) == null ? void 0 : _o2.color) == null ? void 0 : _p2.rgb)
@@ -14,17 +14,18 @@ import Overlay from "../shared/overlay.mjs";
14
14
  import Button from "../shared/button.mjs";
15
15
  import Link from "next/link";
16
16
  import { request } from "@drawbridge/drawbridge-utils/fetch";
17
- import { constants as shared } from "@drawbridge/drawbridge-utils";
18
17
  import constants from "./lib/constants.mjs";
19
18
  import { checkout as checkoutKit, ensureCheckoutKit } from "./lib/checkout-kit.mjs";
20
19
  import { useTracking } from "./provider-analytics.mjs";
20
+ import { awardingOn, buttonText, copy, formOn } from "./lib/entry.mjs";
21
+ import { leadEndpoint } from "./lib/url.mjs";
21
22
  const TemplateModal = dynamic(() => import("./template-modal.mjs"), { ssr: false });
22
23
  const TemplateLayout = ({
23
24
  params,
24
25
  result,
25
26
  userAgent
26
27
  }) => {
27
- var _a, _b, _c, _d, _e;
28
+ var _a, _b, _c, _d;
28
29
  const searchParams = useSearchParams();
29
30
  const token = searchParams.get("drwbrdg_pre");
30
31
  const preview = Boolean(token);
@@ -47,6 +48,7 @@ const TemplateLayout = ({
47
48
  const [panel, setPanel] = useState(submissionId ? {
48
49
  name: "submission",
49
50
  data: {
51
+ giveaway: awardingOn(result),
50
52
  id: submissionId,
51
53
  title: "Keep going",
52
54
  preview,
@@ -68,7 +70,6 @@ const TemplateLayout = ({
68
70
  affiliate,
69
71
  campaign: data == null ? void 0 : data.campaign,
70
72
  onComplete: () => {
71
- var _a2;
72
73
  if (typeof window !== "undefined") {
73
74
  window.localStorage.removeItem(cartStorageKey);
74
75
  window.localStorage.removeItem(cartStorageKey + "_expiry");
@@ -78,7 +79,7 @@ const TemplateLayout = ({
78
79
  setPanel({
79
80
  name: "purchase",
80
81
  data: {
81
- message: ((_a2 = data == null ? void 0 : data.defaults) == null ? void 0 : _a2.purchase) || "Thank you for your purchase"
82
+ message: copy(data, "purchase")
82
83
  }
83
84
  });
84
85
  setModal(true);
@@ -91,7 +92,7 @@ const TemplateLayout = ({
91
92
  subdomain: params == null ? void 0 : params.subdomain,
92
93
  ...args
93
94
  }),
94
- [affiliate, cartStorageKey, data == null ? void 0 : data.campaign, (_a = data == null ? void 0 : data.defaults) == null ? void 0 : _a.purchase, data == null ? void 0 : data.organization, data == null ? void 0 : data.page, params == null ? void 0 : params.slug, params == null ? void 0 : params.subdomain, redirectToCheckout]
95
+ [affiliate, cartStorageKey, data, params == null ? void 0 : params.slug, params == null ? void 0 : params.subdomain, redirectToCheckout]
95
96
  );
96
97
  const openCheckout = useCallback(
97
98
  (checkoutUrl) => checkout({ checkoutUrl }),
@@ -281,7 +282,7 @@ const TemplateLayout = ({
281
282
  event,
282
283
  preview: preview2
283
284
  }) => {
284
- var _a2, _b2, _c2, _d2, _e2, _f, _g;
285
+ var _a2, _b2, _c2, _d2, _e, _f, _g;
285
286
  let trusted = false;
286
287
  try {
287
288
  trusted = Boolean(
@@ -294,7 +295,7 @@ const TemplateLayout = ({
294
295
  setIframe(true);
295
296
  }
296
297
  if (preview2 && trusted && ((_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.update)) {
297
- const headline = ((_c2 = (_b2 = event == null ? void 0 : event.data) == null ? void 0 : _b2.update) == null ? void 0 : _c2.headline) || ((_d2 = result == null ? void 0 : result.data) == null ? void 0 : _d2.headline) || ((_f = (_e2 = constants) == null ? void 0 : _e2.form) == null ? void 0 : _f.headline);
298
+ const headline = ((_c2 = (_b2 = event == null ? void 0 : event.data) == null ? void 0 : _b2.update) == null ? void 0 : _c2.headline) || ((_d2 = result == null ? void 0 : result.data) == null ? void 0 : _d2.headline) || ((_f = (_e = constants) == null ? void 0 : _e.form) == null ? void 0 : _f.headline);
298
299
  setData({
299
300
  ...result,
300
301
  ...(_g = event == null ? void 0 : event.data) == null ? void 0 : _g.update,
@@ -322,6 +323,13 @@ const TemplateLayout = ({
322
323
  preview
323
324
  });
324
325
  window.addEventListener("message", onRecievedMessage);
326
+ if (preview && window.parent !== window) {
327
+ try {
328
+ window.parent.postMessage({ ready: true }, new URL(process.env.NEXT_PUBLIC_DASHBOARD_URI).origin);
329
+ } catch {
330
+ }
331
+ }
332
+ ;
325
333
  return () => {
326
334
  window.removeEventListener("message", onRecievedMessage);
327
335
  document.documentElement.style.background = "";
@@ -329,18 +337,21 @@ const TemplateLayout = ({
329
337
  document.documentElement.style.color = "";
330
338
  };
331
339
  },
332
- [iframeMessageResponse, preview, tracking, (_c = (_b = style == null ? void 0 : style.background) == null ? void 0 : _b.color) == null ? void 0 : _c.rgb, (_e = (_d = style == null ? void 0 : style.text) == null ? void 0 : _d.color) == null ? void 0 : _e.rgb, userAgent]
340
+ [iframeMessageResponse, preview, tracking, (_b = (_a = style == null ? void 0 : style.background) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb, (_d = (_c = style == null ? void 0 : style.text) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb, userAgent]
333
341
  );
334
342
  const submission = useCallback(
335
- ({ id, lead, message, title }) => {
343
+ ({ id, lead, message, panel: answer, repeat, title }) => {
336
344
  setPanel({
337
345
  name: "submission",
338
346
  data: {
339
347
  affiliate,
348
+ giveaway: awardingOn(data),
340
349
  id,
341
350
  lead,
342
351
  message,
352
+ panel: answer,
343
353
  preview,
354
+ repeat,
344
355
  style,
345
356
  title,
346
357
  ...params
@@ -348,11 +359,36 @@ const TemplateLayout = ({
348
359
  });
349
360
  setModal(true);
350
361
  },
351
- [affiliate, params, preview, style]
362
+ [affiliate, data, params, preview, style]
363
+ );
364
+ const leadMission = searchParams.get("mission");
365
+ const leadUrl = submissionId ? null : leadEndpoint({ lead: searchParams.get("lead"), slug: params == null ? void 0 : params.slug, subdomain: params == null ? void 0 : params.subdomain, token });
366
+ useEffect(
367
+ () => {
368
+ if (!leadUrl) return;
369
+ request({
370
+ cache: "no-store",
371
+ endpoint: leadUrl,
372
+ method: "GET"
373
+ }).then(({ result: result2 }) => {
374
+ var _a2;
375
+ if (!((_a2 = result2 == null ? void 0 : result2.missions) == null ? void 0 : _a2.length)) return;
376
+ setPanel({
377
+ name: "lead",
378
+ data: {
379
+ ...result2,
380
+ mission: leadMission
381
+ }
382
+ });
383
+ setModal(true);
384
+ }).catch(() => {
385
+ });
386
+ },
387
+ [leadMission, leadUrl]
352
388
  );
353
389
  const buttons = useMemo(
354
390
  () => {
355
- var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
391
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
356
392
  const branding = (compact = false) => /* @__PURE__ */ jsx(
357
393
  "div",
358
394
  {
@@ -397,7 +433,7 @@ const TemplateLayout = ({
397
433
  branding: branding(),
398
434
  brandingCompact: branding(true),
399
435
  close: (name) => {
400
- var _a3, _b3, _c3, _d3, _e3, _f2, _g2, _h2, _i2, _j2, _k2;
436
+ var _a3, _b3, _c3, _d3, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
401
437
  return /* @__PURE__ */ jsx(
402
438
  Button,
403
439
  {
@@ -419,7 +455,7 @@ const TemplateLayout = ({
419
455
  className: "flex items-center justify-center w-6 h-6 rounded-full",
420
456
  ...style && {
421
457
  style: {
422
- backgroundColor: ((_c3 = (_b3 = (_a3 = style == null ? void 0 : style.button) == null ? void 0 : _a3.background) == null ? void 0 : _b3.color) == null ? void 0 : _c3.rgb) || ((_e3 = (_d3 = style == null ? void 0 : style.text) == null ? void 0 : _d3.color) == null ? void 0 : _e3.rgb),
458
+ backgroundColor: ((_c3 = (_b3 = (_a3 = style == null ? void 0 : style.button) == null ? void 0 : _a3.background) == null ? void 0 : _b3.color) == null ? void 0 : _c3.rgb) || ((_e2 = (_d3 = style == null ? void 0 : style.text) == null ? void 0 : _d3.color) == null ? void 0 : _e2.rgb),
423
459
  borderRadius: ((_f2 = style == null ? void 0 : style.button) == null ? void 0 : _f2.radius) != null ? style.button.radius / 4 + "px" : void 0,
424
460
  color: ((_i2 = (_h2 = (_g2 = style == null ? void 0 : style.button) == null ? void 0 : _g2.text) == null ? void 0 : _h2.color) == null ? void 0 : _i2.rgb) || ((_k2 = (_j2 = style == null ? void 0 : style.background) == null ? void 0 : _j2.color) == null ? void 0 : _k2.rgb)
425
461
  }
@@ -439,7 +475,9 @@ const TemplateLayout = ({
439
475
  }
440
476
  );
441
477
  },
442
- enter: /* @__PURE__ */ jsx(
478
+ // @story public-entry/view-page
479
+ // The form off: no Enter button, the owner's preview included.
480
+ enter: formOn(data) && /* @__PURE__ */ jsx(
443
481
  Button,
444
482
  {
445
483
  ...{
@@ -455,7 +493,7 @@ const TemplateLayout = ({
455
493
  },
456
494
  style
457
495
  },
458
- children: preview || Boolean(data == null ? void 0 : data.valid) ? ((_a2 = data == null ? void 0 : data.defaults) == null ? void 0 : _a2.active) || ((_d2 = (_c2 = (_b2 = shared) == null ? void 0 : _b2.campaign) == null ? void 0 : _c2.defaults) == null ? void 0 : _d2.active) : ((_e2 = data == null ? void 0 : data.defaults) == null ? void 0 : _e2.inactive) || ((_h = (_g = (_f = shared) == null ? void 0 : _f.campaign) == null ? void 0 : _g.defaults) == null ? void 0 : _h.inactive)
496
+ children: buttonText(data, preview || Boolean(data == null ? void 0 : data.valid))
459
497
  }
460
498
  ),
461
499
  menu: /* @__PURE__ */ jsx(
@@ -482,10 +520,10 @@ const TemplateLayout = ({
482
520
  className: "flex items-center justify-center w-10 h-10 border border-current rounded-full",
483
521
  ...style && {
484
522
  style: {
485
- backgroundColor: ((_k = (_j = (_i = style == null ? void 0 : style.button) == null ? void 0 : _i.background) == null ? void 0 : _j.color) == null ? void 0 : _k.rgb) || ((_m = (_l = style == null ? void 0 : style.text) == null ? void 0 : _l.color) == null ? void 0 : _m.rgb),
486
- borderColor: ((_p = (_o = (_n = style == null ? void 0 : style.button) == null ? void 0 : _n.background) == null ? void 0 : _o.color) == null ? void 0 : _p.rgb) || ((_r = (_q = style == null ? void 0 : style.text) == null ? void 0 : _q.color) == null ? void 0 : _r.rgb),
487
- borderRadius: ((_s = style == null ? void 0 : style.button) == null ? void 0 : _s.radius) != null ? style.button.radius / 4 + "px" : void 0,
488
- color: ((_v = (_u = (_t = style == null ? void 0 : style.button) == null ? void 0 : _t.text) == null ? void 0 : _u.color) == null ? void 0 : _v.rgb) || ((_x = (_w = style == null ? void 0 : style.background) == null ? void 0 : _w.color) == null ? void 0 : _x.rgb)
523
+ backgroundColor: ((_c2 = (_b2 = (_a2 = style == null ? void 0 : style.button) == null ? void 0 : _a2.background) == null ? void 0 : _b2.color) == null ? void 0 : _c2.rgb) || ((_e = (_d2 = style == null ? void 0 : style.text) == null ? void 0 : _d2.color) == null ? void 0 : _e.rgb),
524
+ borderColor: ((_h = (_g = (_f = style == null ? void 0 : style.button) == null ? void 0 : _f.background) == null ? void 0 : _g.color) == null ? void 0 : _h.rgb) || ((_j = (_i = style == null ? void 0 : style.text) == null ? void 0 : _i.color) == null ? void 0 : _j.rgb),
525
+ borderRadius: ((_k = style == null ? void 0 : style.button) == null ? void 0 : _k.radius) != null ? style.button.radius / 4 + "px" : void 0,
526
+ color: ((_n = (_m = (_l = style == null ? void 0 : style.button) == null ? void 0 : _l.text) == null ? void 0 : _m.color) == null ? void 0 : _n.rgb) || ((_p = (_o = style == null ? void 0 : style.background) == null ? void 0 : _o.color) == null ? void 0 : _p.rgb)
489
527
  }
490
528
  }
491
529
  },
@@ -546,7 +584,7 @@ const TemplateLayout = ({
546
584
  );
547
585
  },
548
586
  shop: (name = "shop") => {
549
- var _a3, _b3, _c3, _d3, _e3, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
587
+ var _a3, _b3, _c3, _d3, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
550
588
  return /* @__PURE__ */ jsx(
551
589
  Button,
552
590
  {
@@ -571,7 +609,7 @@ const TemplateLayout = ({
571
609
  className: "flex items-center justify-center h-10 border border-current rounded-full " + (cartCount > 0 ? "pl-3 pr-4 space-x-1" : "w-10"),
572
610
  ...style && {
573
611
  style: {
574
- backgroundColor: ((_c3 = (_b3 = (_a3 = style == null ? void 0 : style.button) == null ? void 0 : _a3.background) == null ? void 0 : _b3.color) == null ? void 0 : _c3.rgb) || ((_e3 = (_d3 = style == null ? void 0 : style.text) == null ? void 0 : _d3.color) == null ? void 0 : _e3.rgb),
612
+ backgroundColor: ((_c3 = (_b3 = (_a3 = style == null ? void 0 : style.button) == null ? void 0 : _a3.background) == null ? void 0 : _b3.color) == null ? void 0 : _c3.rgb) || ((_e2 = (_d3 = style == null ? void 0 : style.text) == null ? void 0 : _d3.color) == null ? void 0 : _e2.rgb),
575
613
  borderColor: ((_h2 = (_g2 = (_f2 = style == null ? void 0 : style.button) == null ? void 0 : _f2.background) == null ? void 0 : _g2.color) == null ? void 0 : _h2.rgb) || ((_j2 = (_i2 = style == null ? void 0 : style.text) == null ? void 0 : _i2.color) == null ? void 0 : _j2.rgb),
576
614
  borderRadius: ((_k2 = style == null ? void 0 : style.button) == null ? void 0 : _k2.radius) != null ? style.button.radius / 4 + "px" : void 0,
577
615
  color: ((_n2 = (_m2 = (_l2 = style == null ? void 0 : style.button) == null ? void 0 : _l2.text) == null ? void 0 : _m2.color) == null ? void 0 : _n2.rgb) || ((_p2 = (_o2 = style == null ? void 0 : style.background) == null ? void 0 : _o2.color) == null ? void 0 : _p2.rgb)
@@ -35,20 +35,20 @@ var import_jsx_runtime = require("react/jsx-runtime");
35
35
  var import_react = require("react");
36
36
  var import_react2 = require("@headlessui/react");
37
37
  var import_form_subdomain = __toESM(require("./form-subdomain"));
38
+ var import_form_subdomain_header = __toESM(require("./form-subdomain-header"));
38
39
  var import_form_subdomain_issue = __toESM(require("./form-subdomain-issue"));
39
40
  var import_form_subdomain_prize = __toESM(require("./form-subdomain-prize"));
40
41
  var import_provider_recaptcha = __toESM(require("../shared/provider-recaptcha"));
41
42
  var import_form_subdomain_shop_modal = require("./form-subdomain-shop-modal");
42
43
  var import_template_subdomain_link = __toESM(require("./template-subdomain-link"));
43
- var import_copy_to_clipboard = __toESM(require("../shared/copy-to-clipboard"));
44
- var import_share_button = __toESM(require("./share-button"));
44
+ var import_form_subdomain_missions = __toESM(require("./form-subdomain-missions"));
45
45
  var import_tabs = __toESM(require("../shared/tabs"));
46
46
  var import_empty = __toESM(require("../shared/empty"));
47
47
  var import_card_prize = __toESM(require("../shared/card-prize"));
48
48
  var import_arrow_right = __toESM(require("../icons/arrow-right"));
49
49
  var import_flag = __toESM(require("../icons/flag"));
50
- var import_link = __toESM(require("../icons/link"));
51
50
  var import_warning = __toESM(require("../icons/warning"));
51
+ var import_entry = require("./lib/entry");
52
52
  const TemplateModal = ({
53
53
  buttons,
54
54
  cart,
@@ -74,7 +74,7 @@ const TemplateModal = ({
74
74
  var _a, _b, _c, _d, _e, _f;
75
75
  const renderPanel = (0, import_react.useCallback)(
76
76
  () => {
77
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
77
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
78
78
  const agreements = (data == null ? void 0 : data.agreements) || {};
79
79
  switch (panel == null ? void 0 : panel.name) {
80
80
  case "cart":
@@ -99,6 +99,7 @@ const TemplateModal = ({
99
99
  }
100
100
  );
101
101
  case "enter":
102
+ if (!(0, import_entry.formOn)(data)) return null;
102
103
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
103
104
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
105
  import_form_subdomain.default,
@@ -113,12 +114,18 @@ const TemplateModal = ({
113
114
  message
114
115
  }
115
116
  }),
116
- onSuccess: ({ message, result }) => {
117
- var _a3, _b3;
117
+ onSuccess: ({ created, message, result }) => {
118
+ var _a3;
118
119
  return submission({
119
120
  id: (_a3 = result == null ? void 0 : result.submission) == null ? void 0 : _a3.id,
120
- message: message || ((_b3 = data == null ? void 0 : data.defaults) == null ? void 0 : _b3.confirmation),
121
- title: "Entry submitted"
121
+ message: message || (0, import_entry.copy)(data, "confirmation"),
122
+ // @story public-entry/submit
123
+ // The panel's ads and missions ride on the answer: nothing more to ask.
124
+ panel: result == null ? void 0 : result.panel,
125
+ // The api answers a submitter at the limit with created false.
126
+ repeat: created === false,
127
+ // @story public-entry/submit
128
+ title: (0, import_entry.panelTitle)(data)
122
129
  });
123
130
  },
124
131
  disabled: !preview && !(data == null ? void 0 : data.valid),
@@ -149,10 +156,32 @@ const TemplateModal = ({
149
156
  }
150
157
  }
151
158
  );
159
+ // @story public-entry/lead-link
160
+ // Opened by the lead's own link while entries are being awarded:
161
+ // the missions panel, at the mission a `&mission=` asked for. With
162
+ // no missions the link opens no panel (template-layout.js).
163
+ case "lead":
164
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
165
+ import_form_subdomain_missions.default,
166
+ {
167
+ ...{
168
+ button: buttons.close("lead"),
169
+ contact: panel.data.contact,
170
+ initial: panel.data.mission,
171
+ missions: panel.data.missions,
172
+ shareLink: panel.data.shareLink,
173
+ slug: params == null ? void 0 : params.slug,
174
+ style,
175
+ subdomain: params == null ? void 0 : params.subdomain,
176
+ title: "Your entries",
177
+ token: panel.data.token
178
+ }
179
+ }
180
+ );
152
181
  case "menu":
153
182
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
154
183
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
155
- import_form_subdomain.FormSubdomainHeader,
184
+ import_form_subdomain_header.default,
156
185
  {
157
186
  ...{
158
187
  button: buttons.close("menu"),
@@ -173,7 +202,7 @@ const TemplateModal = ({
173
202
  }
174
203
  },
175
204
  children: [
176
- ((_e2 = (_d2 = data == null ? void 0 : data.prizes) == null ? void 0 : _d2.pageInfo) == null ? void 0 : _e2.total) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
205
+ (0, import_entry.giveawayOn)(data) && ((_e2 = (_d2 = data == null ? void 0 : data.prizes) == null ? void 0 : _d2.pageInfo) == null ? void 0 : _e2.total) > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
177
206
  import_template_subdomain_link.default,
178
207
  {
179
208
  ...{
@@ -192,25 +221,6 @@ const TemplateModal = ({
192
221
  }
193
222
  }
194
223
  ),
195
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
196
- import_template_subdomain_link.default,
197
- {
198
- ...{
199
- disabled: iframe,
200
- onClick: () => {
201
- setPanel({
202
- name: "share"
203
- });
204
- tracking.track({
205
- name: "link-share"
206
- });
207
- },
208
- svg: import_arrow_right.default,
209
- text: "Share link",
210
- "aria-label": "Open to share this link"
211
- }
212
- }
213
- ),
214
224
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
215
225
  import_template_subdomain_link.default,
216
226
  {
@@ -237,7 +247,7 @@ const TemplateModal = ({
237
247
  case "prize":
238
248
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
239
249
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
240
- import_form_subdomain.FormSubdomainHeader,
250
+ import_form_subdomain_header.default,
241
251
  {
242
252
  ...{
243
253
  back: {
@@ -344,7 +354,7 @@ const TemplateModal = ({
344
354
  case "prizes":
345
355
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
346
356
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
347
- import_form_subdomain.FormSubdomainHeader,
357
+ import_form_subdomain_header.default,
348
358
  {
349
359
  ...{
350
360
  back: {
@@ -467,7 +477,7 @@ const TemplateModal = ({
467
477
  case "report":
468
478
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
469
479
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
470
- import_form_subdomain.FormSubdomainHeader,
480
+ import_form_subdomain_header.default,
471
481
  {
472
482
  ...{
473
483
  back: {
@@ -496,50 +506,6 @@ const TemplateModal = ({
496
506
  ),
497
507
  buttons.recaptcha()
498
508
  ] });
499
- case "share":
500
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
501
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
502
- import_form_subdomain.FormSubdomainHeader,
503
- {
504
- ...{
505
- back: {
506
- onClick: () => setPanel({
507
- name: "menu"
508
- })
509
- },
510
- button: buttons.close("menu"),
511
- style,
512
- title: "Share link"
513
- }
514
- }
515
- ),
516
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
517
- import_share_button.default,
518
- {
519
- ...{
520
- style,
521
- values: {
522
- description: data == null ? void 0 : data.description,
523
- headline: data == null ? void 0 : data.headline,
524
- image: (_v = data == null ? void 0 : data.images) == null ? void 0 : _v.preview,
525
- url: data == null ? void 0 : data.url
526
- }
527
- }
528
- }
529
- ),
530
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
531
- import_copy_to_clipboard.default,
532
- {
533
- ...{
534
- className: "justify-between w-full pt-5 pr-3 border-t border-inherit",
535
- icon: import_link.default,
536
- style,
537
- value: data == null ? void 0 : data.url
538
- },
539
- children: "Copy link"
540
- }
541
- )
542
- ] });
543
509
  case "submission":
544
510
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
545
511
  import_form_subdomain.FormSubdomainSubmission,