@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
@@ -0,0 +1,577 @@
1
+ "use client";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var form_subdomain_missions_exports = {};
30
+ __export(form_subdomain_missions_exports, {
31
+ FormSubdomainMissions: () => FormSubdomainMissions,
32
+ bonusText: () => bonusText,
33
+ default: () => form_subdomain_missions_default,
34
+ openingScreen: () => openingScreen,
35
+ pillText: () => pillText,
36
+ screenFor: () => screenFor
37
+ });
38
+ module.exports = __toCommonJS(form_subdomain_missions_exports);
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ var import_react = require("react");
41
+ var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
42
+ var import_missions = require("@drawbridge/drawbridge-utils/missions");
43
+ var import_button = __toESM(require("../shared/button"));
44
+ var import_copy_to_clipboard = __toESM(require("../shared/copy-to-clipboard"));
45
+ var import_error = __toESM(require("../shared/error"));
46
+ var import_check = __toESM(require("../icons/check"));
47
+ var import_chevron_left = __toESM(require("../icons/chevron-left"));
48
+ var import_chevron_right = __toESM(require("../icons/chevron-right"));
49
+ var import_loader = __toESM(require("../icons/loader"));
50
+ var import_input_group = __toESM(require("../input-group"));
51
+ var import_input_code = __toESM(require("../input-code"));
52
+ var import_share_button = __toESM(require("./share-button"));
53
+ var import_form_subdomain_header = require("./form-subdomain-header");
54
+ var import_url = require("./lib/url");
55
+ var import_styles = require("../styles");
56
+ const screenFor = (type) => {
57
+ var _a;
58
+ return {
59
+ [import_missions.COMPLETIONS.code]: "send",
60
+ [import_missions.COMPLETIONS.referral]: "share"
61
+ }[(_a = import_missions.missions[type]) == null ? void 0 : _a.completion] || "missions";
62
+ };
63
+ const openingScreen = (items = [], type) => {
64
+ const item = items.find((row) => row.type === type);
65
+ return item && !item.completed ? screenFor(type) : "start";
66
+ };
67
+ const bonusText = (items = [], completed = items.filter((item) => item.completed).map((item) => item.type)) => {
68
+ const open = items.filter((item) => item.type !== "form" && !completed.includes(item.type));
69
+ const total = open.reduce((sum, item) => sum + Number(item.entries || 0), 0);
70
+ return total ? total + (open.some((item) => item.type === "share") ? "+" : "") : null;
71
+ };
72
+ const pillText = (item, completed) => (completed ? "+" : "") + Number((item == null ? void 0 : item.entries) || 0);
73
+ const Pill = ({ children, style }) => {
74
+ var _a, _b, _c, _d;
75
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
+ "span",
77
+ {
78
+ ...{
79
+ className: "inline-flex items-center justify-center min-w-8 h-6 px-2 rounded-full text-sm shrink-0",
80
+ style: {
81
+ backgroundColor: ((_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb) || "currentColor",
82
+ color: ((_d = (_c = style == null ? void 0 : style.background) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb) || "white"
83
+ }
84
+ },
85
+ children
86
+ }
87
+ );
88
+ };
89
+ const Back = ({ onClick, style }) => {
90
+ var _a, _b;
91
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ "div",
93
+ {
94
+ ...{
95
+ className: "pb-3 border-b",
96
+ style: {
97
+ borderColor: (_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb
98
+ }
99
+ },
100
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
+ import_button.default,
102
+ {
103
+ ...{
104
+ icon: import_chevron_left.default,
105
+ inline: true,
106
+ onClick,
107
+ reverse: true,
108
+ variant: "link"
109
+ },
110
+ children: "Back to missions"
111
+ }
112
+ )
113
+ }
114
+ );
115
+ };
116
+ const Centre = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
117
+ "div",
118
+ {
119
+ ...{
120
+ className: "space-y-1 text-center"
121
+ },
122
+ children
123
+ }
124
+ );
125
+ const Strong = ({ children, className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
126
+ "p",
127
+ {
128
+ ...{
129
+ className: "font-bold " + (className || "")
130
+ },
131
+ children
132
+ }
133
+ );
134
+ const CodeStep = ({ disabled, error, onComplete, style }) => {
135
+ const [code, setCode] = (0, import_react.useState)("");
136
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
+ import_input_group.default,
138
+ {
139
+ ...{
140
+ error,
141
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
142
+ import_input_code.default,
143
+ {
144
+ ...{
145
+ autoFocus: true,
146
+ disabled,
147
+ onChange: setCode,
148
+ onComplete,
149
+ style,
150
+ value: code
151
+ }
152
+ }
153
+ ),
154
+ label: "Verification code",
155
+ style
156
+ }
157
+ }
158
+ );
159
+ };
160
+ const FormSubdomainMissions = ({
161
+ advertisements,
162
+ button,
163
+ contact,
164
+ initial,
165
+ message,
166
+ missions: items = [],
167
+ shareLink,
168
+ slug,
169
+ style,
170
+ subdomain,
171
+ title,
172
+ token
173
+ }) => {
174
+ var _a, _b;
175
+ const [screen, setScreen] = (0, import_react.useState)(openingScreen(items, initial));
176
+ const [mission, setMission] = (0, import_react.useState)(initial);
177
+ const [completed, setCompleted] = (0, import_react.useState)(items.filter((item2) => item2.completed).map((item2) => item2.type));
178
+ const [busy, setBusy] = (0, import_react.useState)(false);
179
+ const [error, setError] = (0, import_react.useState)(null);
180
+ const [attempt, setAttempt] = (0, import_react.useState)(0);
181
+ const manifest = import_missions.missions[mission];
182
+ const item = items.find((row) => row.type === mission);
183
+ const words = (manifest == null ? void 0 : manifest.words) || {};
184
+ const go = (next, type = mission) => {
185
+ setError(null);
186
+ setMission(type);
187
+ setScreen(next);
188
+ };
189
+ const back = () => go("missions");
190
+ const header = (text, back2) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
191
+ import_form_subdomain_header.FormSubdomainHeader,
192
+ {
193
+ ...{
194
+ back: back2,
195
+ button,
196
+ style,
197
+ title: text
198
+ }
199
+ }
200
+ );
201
+ const call = async (action, body = {}) => (0, import_fetch.request)({
202
+ body: {
203
+ ...body,
204
+ token
205
+ },
206
+ endpoint: (0, import_url.missionEndpoint)({ action, slug, subdomain, type: mission }),
207
+ method: "POST"
208
+ });
209
+ const send = async () => {
210
+ setBusy(true);
211
+ try {
212
+ await call("send");
213
+ setError(null);
214
+ setAttempt(attempt + 1);
215
+ setScreen("code");
216
+ } catch ({ message: text }) {
217
+ setError(text);
218
+ }
219
+ setBusy(false);
220
+ };
221
+ const confirm = async (code) => {
222
+ setBusy(true);
223
+ try {
224
+ await call("confirm", { code });
225
+ setCompleted([.../* @__PURE__ */ new Set([...completed, mission])]);
226
+ go("done");
227
+ } catch ({ message: text }) {
228
+ setError(text || "Verification code incorrect");
229
+ setAttempt(attempt + 1);
230
+ }
231
+ setBusy(false);
232
+ };
233
+ if (screen === "send") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
234
+ "div",
235
+ {
236
+ ...{
237
+ className: "space-y-6"
238
+ },
239
+ children: [
240
+ header(words.title),
241
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Back, { ...{ onClick: back, style } }),
242
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Centre, { children: [
243
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: words.send }),
244
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Strong, { ...{ className: "break-all" }, children: contact == null ? void 0 : contact[import_missions.CODE_CHANNELS[manifest == null ? void 0 : manifest.channel]] })
245
+ ] }),
246
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
247
+ import_error.default,
248
+ {
249
+ ...{
250
+ error,
251
+ style
252
+ }
253
+ }
254
+ ),
255
+ (item == null ? void 0 : item.refused) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
256
+ "p",
257
+ {
258
+ ...{
259
+ className: "text-center"
260
+ },
261
+ children: words.refused
262
+ }
263
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
264
+ import_button.default,
265
+ {
266
+ ...{
267
+ loading: busy,
268
+ onClick: send,
269
+ style
270
+ },
271
+ children: "Verify"
272
+ }
273
+ )
274
+ ]
275
+ }
276
+ );
277
+ if (screen === "code") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
278
+ "div",
279
+ {
280
+ ...{
281
+ className: "space-y-6"
282
+ },
283
+ children: [
284
+ header(words.title),
285
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Back, { ...{ onClick: back, style } }),
286
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Centre, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Strong, { children: words.sent }) }),
287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
288
+ CodeStep,
289
+ {
290
+ ...{
291
+ disabled: busy,
292
+ error,
293
+ onComplete: confirm,
294
+ style
295
+ }
296
+ },
297
+ attempt
298
+ ),
299
+ busy && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
300
+ "div",
301
+ {
302
+ ...{
303
+ className: "flex justify-center"
304
+ },
305
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
306
+ import_loader.default,
307
+ {
308
+ ...{
309
+ className: "w-5 h-5 animate-spin"
310
+ }
311
+ }
312
+ )
313
+ }
314
+ ),
315
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
316
+ "p",
317
+ {
318
+ ...{
319
+ className: "text-sm text-center"
320
+ },
321
+ children: [
322
+ "Didn't get it? ",
323
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
324
+ import_button.default,
325
+ {
326
+ ...{
327
+ disabled: busy,
328
+ inline: true,
329
+ onClick: send,
330
+ variant: "link"
331
+ },
332
+ children: "Resend code"
333
+ }
334
+ )
335
+ ]
336
+ }
337
+ )
338
+ ]
339
+ }
340
+ );
341
+ if (screen === "share") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
342
+ "div",
343
+ {
344
+ ...{
345
+ className: "space-y-6"
346
+ },
347
+ children: [
348
+ header(words.title),
349
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Back, { ...{ onClick: back, style } }),
350
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Centre, { children: [
351
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Strong, { children: words.title }),
352
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: String(words.pays || "").replace("{entries}", (0, import_missions.entriesText)(item == null ? void 0 : item.entries)) })
353
+ ] }),
354
+ shareLink && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
355
+ "div",
356
+ {
357
+ ...{
358
+ className: "px-4 py-3 border",
359
+ style: (0, import_styles.inputStyle)(style)
360
+ },
361
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
362
+ import_copy_to_clipboard.default,
363
+ {
364
+ ...{
365
+ className: "justify-between",
366
+ message: "Copied",
367
+ style,
368
+ value: shareLink
369
+ },
370
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
371
+ "span",
372
+ {
373
+ ...{
374
+ className: "truncate"
375
+ },
376
+ children: shareLink
377
+ }
378
+ )
379
+ }
380
+ )
381
+ }
382
+ ),
383
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
384
+ import_share_button.default,
385
+ {
386
+ ...{
387
+ style,
388
+ values: {
389
+ url: shareLink
390
+ }
391
+ }
392
+ }
393
+ )
394
+ ]
395
+ }
396
+ );
397
+ if (screen === "done") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
398
+ "div",
399
+ {
400
+ ...{
401
+ className: "space-y-6"
402
+ },
403
+ children: [
404
+ header("Thank you!"),
405
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Back, { ...{ onClick: back, style } }),
406
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Centre, { children: [
407
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Strong, { children: "Mission accomplished!" }),
408
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Your bonus entries are in. Go back to missions to earn more." })
409
+ ] })
410
+ ]
411
+ }
412
+ );
413
+ if (screen === "start") {
414
+ const bonus = bonusText(items, completed);
415
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
416
+ "div",
417
+ {
418
+ ...{
419
+ className: "space-y-6"
420
+ },
421
+ children: [
422
+ header(title),
423
+ message && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
424
+ "p",
425
+ {
426
+ ...{
427
+ "aria-live": "polite",
428
+ className: "text-center",
429
+ role: "alert"
430
+ },
431
+ children: message
432
+ }
433
+ ),
434
+ bonus && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
435
+ import_button.default,
436
+ {
437
+ ...{
438
+ onClick: () => go("missions"),
439
+ variant: "link"
440
+ },
441
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
442
+ "span",
443
+ {
444
+ ...{
445
+ className: "flex w-full items-center gap-4 px-4 py-3 border text-left",
446
+ style: (0, import_styles.inputStyle)(style)
447
+ },
448
+ children: [
449
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { ...{ style }, children: bonus }),
450
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
451
+ "span",
452
+ {
453
+ ...{
454
+ className: "flex-1"
455
+ },
456
+ children: "Bonus entries available"
457
+ }
458
+ ),
459
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
460
+ import_chevron_right.default,
461
+ {
462
+ ...{
463
+ "aria-hidden": true,
464
+ className: "w-4 h-4"
465
+ }
466
+ }
467
+ )
468
+ ]
469
+ }
470
+ )
471
+ }
472
+ ),
473
+ advertisements
474
+ ]
475
+ }
476
+ );
477
+ }
478
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
479
+ "div",
480
+ {
481
+ ...{
482
+ className: "space-y-6"
483
+ },
484
+ children: [
485
+ header("Earn more entries", { onClick: () => go("start") }),
486
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
487
+ "ul",
488
+ {
489
+ ...{
490
+ className: "divide-y",
491
+ style: {
492
+ borderColor: (_b = (_a = style == null ? void 0 : style.text) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb
493
+ }
494
+ },
495
+ children: items.filter((row) => import_missions.missions[row.type]).map((row, index) => {
496
+ var _a2;
497
+ const finished = completed.includes(row.type);
498
+ const opens = screenFor(row.type);
499
+ const Mark = finished ? import_check.default : import_chevron_right.default;
500
+ const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
501
+ "span",
502
+ {
503
+ ...{
504
+ className: "flex w-full items-center gap-4 text-left " + (index ? "py-4" : "pb-4")
505
+ },
506
+ children: [
507
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
508
+ "span",
509
+ {
510
+ ...{
511
+ className: "flex items-center gap-4 flex-1 min-w-0" + (finished ? " opacity-40" : "")
512
+ },
513
+ children: [
514
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { ...{ style }, children: pillText(row, finished) }),
515
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
516
+ "span",
517
+ {
518
+ ...{
519
+ className: "text-sm"
520
+ },
521
+ children: import_missions.missions[row.type].sentence
522
+ }
523
+ )
524
+ ]
525
+ }
526
+ ),
527
+ (finished || opens !== "missions") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pill, { ...{ style }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
528
+ Mark,
529
+ {
530
+ ...{
531
+ "aria-hidden": true,
532
+ className: "w-4 h-4"
533
+ }
534
+ }
535
+ ) })
536
+ ]
537
+ }
538
+ );
539
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
540
+ "li",
541
+ {
542
+ ...{
543
+ style: {
544
+ borderColor: "inherit"
545
+ }
546
+ },
547
+ children: finished || opens === "missions" ? content : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
548
+ import_button.default,
549
+ {
550
+ ...{
551
+ "aria-label": ((_a2 = import_missions.missions[row.type].words) == null ? void 0 : _a2.title) || import_missions.missions[row.type].title,
552
+ onClick: () => go(opens, row.type),
553
+ variant: "link"
554
+ },
555
+ children: content
556
+ }
557
+ )
558
+ },
559
+ row.type
560
+ );
561
+ })
562
+ }
563
+ ),
564
+ advertisements
565
+ ]
566
+ }
567
+ );
568
+ };
569
+ var form_subdomain_missions_default = FormSubdomainMissions;
570
+ // Annotate the CommonJS export names for ESM import in node:
571
+ 0 && (module.exports = {
572
+ FormSubdomainMissions,
573
+ bonusText,
574
+ openingScreen,
575
+ pillText,
576
+ screenFor
577
+ });