@drawbridge/components 0.1.47 → 0.1.48

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 (114) hide show
  1. package/dist/bridge/cart-drawer.js +152 -0
  2. package/dist/bridge/cart-drawer.mjs +123 -0
  3. package/dist/bridge/fields.js +278 -0
  4. package/dist/bridge/fields.mjs +276 -1
  5. package/dist/bridge/form-subdomain-checkout.js +687 -0
  6. package/dist/bridge/form-subdomain-checkout.mjs +665 -0
  7. package/dist/bridge/form-subdomain-shop-modal.js +234 -274
  8. package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
  9. package/dist/bridge/form-subdomain.js +1 -0
  10. package/dist/bridge/form-subdomain.mjs +2 -1
  11. package/dist/bridge/lib/age-gate.js +12 -0
  12. package/dist/bridge/lib/age-gate.mjs +11 -0
  13. package/dist/bridge/lib/cart.js +79 -0
  14. package/dist/bridge/lib/cart.mjs +48 -0
  15. package/dist/bridge/lib/checkout-kit.js +2 -32
  16. package/dist/bridge/lib/checkout-kit.mjs +2 -32
  17. package/dist/bridge/product-tile.js +9 -6
  18. package/dist/bridge/product-tile.mjs +9 -6
  19. package/dist/bridge/template-layout.js +237 -122
  20. package/dist/bridge/template-layout.mjs +237 -122
  21. package/dist/bridge/template-modal.js +28 -73
  22. package/dist/bridge/template-modal.mjs +29 -74
  23. package/dist/dashboard/buttons-subscription.js +1 -1
  24. package/dist/dashboard/buttons-subscription.mjs +1 -1
  25. package/dist/dashboard/campaign-form.js +7 -2
  26. package/dist/dashboard/campaign-form.mjs +7 -2
  27. package/dist/dashboard/card-order.js +22 -4
  28. package/dist/dashboard/card-order.mjs +22 -4
  29. package/dist/dashboard/embed-stripe.js +145 -0
  30. package/dist/dashboard/embed-stripe.mjs +116 -0
  31. package/dist/dashboard/form-admin-provider.js +71 -17
  32. package/dist/dashboard/form-admin-provider.mjs +71 -17
  33. package/dist/dashboard/form-file-upload.js +3 -2
  34. package/dist/dashboard/form-file-upload.mjs +4 -3
  35. package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
  36. package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
  37. package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
  38. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
  39. package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
  40. package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
  41. package/dist/dashboard/form-organization-campaign.js +82 -0
  42. package/dist/dashboard/form-organization-campaign.mjs +81 -0
  43. package/dist/dashboard/form-organization-connection.js +48 -6
  44. package/dist/dashboard/form-organization-connection.mjs +48 -7
  45. package/dist/dashboard/form-organization-product.js +1461 -0
  46. package/dist/dashboard/form-organization-product.mjs +1425 -0
  47. package/dist/dashboard/form-organization-workflow.js +72 -1
  48. package/dist/dashboard/form-organization-workflow.mjs +69 -1
  49. package/dist/dashboard/form-otc.js +4 -5
  50. package/dist/dashboard/form-otc.mjs +4 -5
  51. package/dist/dashboard/form-stripe.js +12 -5
  52. package/dist/dashboard/form-stripe.mjs +12 -5
  53. package/dist/dashboard/input-fields.js +11 -158
  54. package/dist/dashboard/input-fields.mjs +11 -158
  55. package/dist/dashboard/input-file.js +21 -4
  56. package/dist/dashboard/input-file.mjs +21 -4
  57. package/dist/dashboard/input-gallery.js +201 -0
  58. package/dist/dashboard/input-gallery.mjs +172 -0
  59. package/dist/dashboard/lib/connection-controls.js +5 -2
  60. package/dist/dashboard/lib/connection-controls.mjs +3 -1
  61. package/dist/dashboard/lib/form-page.js +1 -1
  62. package/dist/dashboard/lib/form-page.mjs +1 -1
  63. package/dist/dashboard/lib/products.js +169 -0
  64. package/dist/dashboard/lib/products.mjs +135 -0
  65. package/dist/dashboard/lib/settings-paths.js +35 -0
  66. package/dist/dashboard/lib/settings-paths.mjs +11 -0
  67. package/dist/dashboard/lib/uppy.js +10 -1
  68. package/dist/dashboard/lib/uppy.mjs +11 -2
  69. package/dist/dashboard/order-sections.js +456 -6
  70. package/dist/dashboard/order-sections.mjs +453 -7
  71. package/dist/dashboard/provider-ui.js +9 -7
  72. package/dist/dashboard/provider-ui.mjs +9 -7
  73. package/dist/dashboard/shipping-rates.js +404 -0
  74. package/dist/dashboard/shipping-rates.mjs +371 -0
  75. package/dist/dashboard/template-buyer.js +301 -0
  76. package/dist/dashboard/template-buyer.mjs +267 -0
  77. package/dist/input-checkbox.js +28 -10
  78. package/dist/input-checkbox.mjs +28 -10
  79. package/dist/product.js +96 -24
  80. package/dist/product.mjs +97 -25
  81. package/dist/shared/lib/helpers.js +54 -6
  82. package/dist/shared/lib/helpers.mjs +53 -8
  83. package/dist/shared/order-summary.js +139 -0
  84. package/dist/shared/order-summary.mjs +110 -0
  85. package/package.json +74 -4
  86. package/types/bridge/cart-drawer.d.ts +31 -0
  87. package/types/bridge/fields.d.ts +14 -2
  88. package/types/bridge/form-subdomain-checkout.d.ts +20 -0
  89. package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
  90. package/types/bridge/lib/age-gate.d.ts +5 -0
  91. package/types/bridge/lib/cart.d.ts +44 -0
  92. package/types/bridge/lib/checkout-kit.d.ts +2 -10
  93. package/types/dashboard/card-order.d.ts +6 -0
  94. package/types/dashboard/embed-stripe.d.ts +25 -0
  95. package/types/dashboard/form-admin-provider.d.ts +9 -2
  96. package/types/dashboard/form-file-upload.d.ts +2 -1
  97. package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
  98. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
  99. package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
  100. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  101. package/types/dashboard/form-organization-connection.d.ts +11 -0
  102. package/types/dashboard/form-organization-product.d.ts +24 -0
  103. package/types/dashboard/form-otc.d.ts +5 -1
  104. package/types/dashboard/form-stripe.d.ts +3 -2
  105. package/types/dashboard/input-file.d.ts +2 -0
  106. package/types/dashboard/input-gallery.d.ts +14 -0
  107. package/types/dashboard/lib/products.d.ts +14 -0
  108. package/types/dashboard/lib/settings-paths.d.ts +5 -0
  109. package/types/dashboard/order-sections.d.ts +24 -1
  110. package/types/dashboard/shipping-rates.d.ts +26 -0
  111. package/types/dashboard/template-buyer.d.ts +50 -0
  112. package/types/input-checkbox.d.ts +2 -0
  113. package/types/shared/lib/helpers.d.ts +4 -0
  114. package/types/shared/order-summary.d.ts +19 -0
@@ -0,0 +1,267 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { formatCurrency, formatDateString } from "@drawbridge/drawbridge-utils";
4
+ import CardSection from "./card-section.mjs";
5
+ import CardShortcut from "./card-shortcut.mjs";
6
+ import Link from "./link.mjs";
7
+ import Loader from "../shared/loader.mjs";
8
+ import Badge from "../shared/badge.mjs";
9
+ import Button from "../shared/button.mjs";
10
+ import LogoMark from "../icons/logo-mark.mjs";
11
+ const TemplateBuyer = ({
12
+ children,
13
+ home,
14
+ isLoading = false
15
+ }) => /* @__PURE__ */ jsx(
16
+ "div",
17
+ {
18
+ ...{
19
+ className: "fixed h-full w-full bg-gray-light scroll-smooth overflow-y-auto hide-scrollbar"
20
+ },
21
+ children: isLoading ? /* @__PURE__ */ jsx(Loader, {}) : /* @__PURE__ */ jsx(
22
+ "div",
23
+ {
24
+ ...{
25
+ className: "flex min-h-full items-center justify-center px-4 py-32"
26
+ },
27
+ children: /* @__PURE__ */ jsxs(
28
+ "div",
29
+ {
30
+ ...{
31
+ className: "space-y-6 mx-auto w-full max-w-[440px]"
32
+ },
33
+ children: [
34
+ /* @__PURE__ */ jsx(
35
+ "div",
36
+ {
37
+ ...{
38
+ className: "flex justify-center"
39
+ },
40
+ children: /* @__PURE__ */ jsx(
41
+ Button,
42
+ {
43
+ ...{
44
+ "aria-label": "Drawbridge",
45
+ element: Link,
46
+ href: home || "/",
47
+ inline: true,
48
+ variant: "link"
49
+ },
50
+ children: /* @__PURE__ */ jsx(
51
+ "span",
52
+ {
53
+ ...{
54
+ className: "flex items-center justify-center w-12 h-12 bg-green-dark rounded-sm"
55
+ },
56
+ children: /* @__PURE__ */ jsx(
57
+ LogoMark,
58
+ {
59
+ ...{
60
+ className: "w-6 h-6 text-black"
61
+ }
62
+ }
63
+ )
64
+ }
65
+ )
66
+ }
67
+ )
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsx(CardSection, { children })
71
+ ]
72
+ }
73
+ )
74
+ }
75
+ )
76
+ }
77
+ );
78
+ const BuyerOrder = ({
79
+ downloading = null,
80
+ onDownload,
81
+ order
82
+ }) => {
83
+ const code = ((order == null ? void 0 : order.currency) || "usd").toUpperCase();
84
+ const money = (value) => formatCurrency({ code, value: value || 0 });
85
+ const refunded = (order == null ? void 0 : order.payment) === "refunded";
86
+ const date = (order == null ? void 0 : order.purchasedAt) && formatDateString({
87
+ date: order.purchasedAt,
88
+ options: {
89
+ day: "numeric",
90
+ month: "short",
91
+ year: "numeric"
92
+ }
93
+ });
94
+ return /* @__PURE__ */ jsxs(
95
+ "div",
96
+ {
97
+ ...{
98
+ className: "space-y-6"
99
+ },
100
+ children: [
101
+ /* @__PURE__ */ jsxs(
102
+ "div",
103
+ {
104
+ ...{
105
+ className: "space-y-1 text-center"
106
+ },
107
+ children: [
108
+ /* @__PURE__ */ jsx(
109
+ "h1",
110
+ {
111
+ ...{
112
+ className: "text-xl"
113
+ },
114
+ children: (order == null ? void 0 : order.number) ? "Order " + order.number : "Your order"
115
+ }
116
+ ),
117
+ /* @__PURE__ */ jsx(
118
+ "p",
119
+ {
120
+ ...{
121
+ className: "text-sm text-gray-dark"
122
+ },
123
+ children: [order == null ? void 0 : order.organization, date].filter(Boolean).join(" \xB7 ")
124
+ }
125
+ )
126
+ ]
127
+ }
128
+ ),
129
+ /* @__PURE__ */ jsx(
130
+ "div",
131
+ {
132
+ ...{
133
+ className: "space-y-3"
134
+ },
135
+ children: ((order == null ? void 0 : order.lines) || []).map((line) => /* @__PURE__ */ jsx(
136
+ CardShortcut,
137
+ {
138
+ ...{
139
+ ...line.digital && {
140
+ controls: refunded ? /* @__PURE__ */ jsx(
141
+ Badge,
142
+ {
143
+ ...{
144
+ size: "small"
145
+ },
146
+ children: "Refunded"
147
+ }
148
+ ) : /* @__PURE__ */ jsx(
149
+ Button,
150
+ {
151
+ ...{
152
+ disabled: downloading !== null,
153
+ loading: downloading === line.index,
154
+ onClick: () => onDownload(line.index),
155
+ size: "small"
156
+ },
157
+ children: "Download"
158
+ }
159
+ )
160
+ },
161
+ description: [line.variantTitle, (line.quantity || 1) + " \xD7 " + money(line.price)].filter(Boolean).join(" \xB7 "),
162
+ title: line.title || "Item"
163
+ }
164
+ },
165
+ line.index
166
+ ))
167
+ }
168
+ ),
169
+ (order == null ? void 0 : order.amounts) && /* @__PURE__ */ jsxs(
170
+ "div",
171
+ {
172
+ ...{
173
+ className: "flex justify-between text-sm"
174
+ },
175
+ children: [
176
+ /* @__PURE__ */ jsx("span", { children: "Total" }),
177
+ /* @__PURE__ */ jsx("span", { children: money(order.amounts.total) })
178
+ ]
179
+ }
180
+ )
181
+ ]
182
+ }
183
+ );
184
+ };
185
+ const outcomes = {
186
+ expired: {
187
+ message: "Download links work for one day. Sign in to your order page to get a new one.",
188
+ title: "This link has expired"
189
+ },
190
+ failed: {
191
+ message: "Check your connection and try again.",
192
+ title: "We couldn't start your download"
193
+ },
194
+ refunded: {
195
+ message: "This order was refunded, so its downloads have stopped.",
196
+ title: "Downloads have stopped"
197
+ },
198
+ starting: {
199
+ message: "If it doesn't start, try again.",
200
+ title: "Your download is starting"
201
+ },
202
+ unavailable: {
203
+ message: "This download isn't available.",
204
+ title: "Nothing to download"
205
+ }
206
+ };
207
+ const BuyerDownload = ({
208
+ href,
209
+ onRetry,
210
+ status = "starting"
211
+ }) => {
212
+ const outcome = outcomes[status] || outcomes.unavailable;
213
+ return /* @__PURE__ */ jsxs(
214
+ "div",
215
+ {
216
+ ...{
217
+ className: "space-y-6 text-center"
218
+ },
219
+ children: [
220
+ /* @__PURE__ */ jsx(
221
+ "h1",
222
+ {
223
+ ...{
224
+ className: "text-xl"
225
+ },
226
+ children: outcome.title
227
+ }
228
+ ),
229
+ /* @__PURE__ */ jsx(
230
+ "p",
231
+ {
232
+ ...{
233
+ className: "text-gray-dark"
234
+ },
235
+ children: outcome.message
236
+ }
237
+ ),
238
+ ["failed", "starting"].includes(status) && onRetry && /* @__PURE__ */ jsx(
239
+ Button,
240
+ {
241
+ ...{
242
+ onClick: onRetry,
243
+ variant: "secondary"
244
+ },
245
+ children: "Try again"
246
+ }
247
+ ),
248
+ ["expired", "refunded", "unavailable"].includes(status) && href && /* @__PURE__ */ jsx(
249
+ Button,
250
+ {
251
+ ...{
252
+ element: Link,
253
+ href
254
+ },
255
+ children: "View my order"
256
+ }
257
+ )
258
+ ]
259
+ }
260
+ );
261
+ };
262
+ var template_buyer_default = TemplateBuyer;
263
+ export {
264
+ BuyerDownload,
265
+ BuyerOrder,
266
+ template_buyer_default as default
267
+ };
@@ -41,6 +41,9 @@ const InputCheckbox = ({
41
41
  label,
42
42
  labelId,
43
43
  onChange,
44
+ // @story fields/multiple-choice
45
+ // A round button for one choice among several: role radio, a dot for its tick.
46
+ round = false,
44
47
  style,
45
48
  value,
46
49
  ...rest
@@ -69,25 +72,40 @@ const InputCheckbox = ({
69
72
  id: boxId,
70
73
  inline: true,
71
74
  onClick: () => onChange(value ? false : true),
72
- role: "checkbox",
75
+ role: round ? "radio" : "checkbox",
73
76
  variant: "link",
74
77
  ...rest
75
78
  },
76
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
77
80
  "span",
78
81
  {
79
82
  ...{
80
83
  className: "relative flex items-center justify-center w-5 h-5 rounded-xs text-inherit bg-inherit border border-inherit",
81
- style: (0, import_styles.inputCheckboxStyle)(style)
82
- },
83
- children: Boolean(value) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
84
- import_check.default,
85
- {
86
- ...{
87
- className: "absolute top-0 w-3.5 h-full pointer-events-none"
84
+ style: {
85
+ ...(0, import_styles.inputCheckboxStyle)(style),
86
+ ...round && {
87
+ borderRadius: "9999px"
88
88
  }
89
89
  }
90
- )
90
+ },
91
+ children: [
92
+ Boolean(value) && round && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
+ "span",
94
+ {
95
+ ...{
96
+ className: "w-2.5 h-2.5 rounded-full bg-current pointer-events-none"
97
+ }
98
+ }
99
+ ),
100
+ Boolean(value) && !round && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
+ import_check.default,
102
+ {
103
+ ...{
104
+ className: "absolute top-0 w-3.5 h-full pointer-events-none"
105
+ }
106
+ }
107
+ )
108
+ ]
91
109
  }
92
110
  )
93
111
  }
@@ -9,6 +9,9 @@ const InputCheckbox = ({
9
9
  label,
10
10
  labelId,
11
11
  onChange,
12
+ // @story fields/multiple-choice
13
+ // A round button for one choice among several: role radio, a dot for its tick.
14
+ round = false,
12
15
  style,
13
16
  value,
14
17
  ...rest
@@ -37,25 +40,40 @@ const InputCheckbox = ({
37
40
  id: boxId,
38
41
  inline: true,
39
42
  onClick: () => onChange(value ? false : true),
40
- role: "checkbox",
43
+ role: round ? "radio" : "checkbox",
41
44
  variant: "link",
42
45
  ...rest
43
46
  },
44
- children: /* @__PURE__ */ jsx(
47
+ children: /* @__PURE__ */ jsxs(
45
48
  "span",
46
49
  {
47
50
  ...{
48
51
  className: "relative flex items-center justify-center w-5 h-5 rounded-xs text-inherit bg-inherit border border-inherit",
49
- style: inputCheckboxStyle(style)
50
- },
51
- children: Boolean(value) && /* @__PURE__ */ jsx(
52
- Check,
53
- {
54
- ...{
55
- className: "absolute top-0 w-3.5 h-full pointer-events-none"
52
+ style: {
53
+ ...inputCheckboxStyle(style),
54
+ ...round && {
55
+ borderRadius: "9999px"
56
56
  }
57
57
  }
58
- )
58
+ },
59
+ children: [
60
+ Boolean(value) && round && /* @__PURE__ */ jsx(
61
+ "span",
62
+ {
63
+ ...{
64
+ className: "w-2.5 h-2.5 rounded-full bg-current pointer-events-none"
65
+ }
66
+ }
67
+ ),
68
+ Boolean(value) && !round && /* @__PURE__ */ jsx(
69
+ Check,
70
+ {
71
+ ...{
72
+ className: "absolute top-0 w-3.5 h-full pointer-events-none"
73
+ }
74
+ }
75
+ )
76
+ ]
59
77
  }
60
78
  )
61
79
  }
package/dist/product.js CHANGED
@@ -35,7 +35,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
35
35
  var import_react = require("react");
36
36
  var import_embla_carousel_react = __toESM(require("embla-carousel-react"));
37
37
  var import_cdn = require("@drawbridge/drawbridge-utils/cdn");
38
- var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
38
+ var import_helpers = require("./shared/lib/helpers");
39
39
  var import_input_group = __toESM(require("./input-group"));
40
40
  var import_input_select = __toESM(require("./input-select"));
41
41
  var import_wrapper_gradient = __toESM(require("./wrapper-gradient"));
@@ -90,26 +90,43 @@ const Product = ({
90
90
  );
91
91
  const [activeImage, setActiveImage] = (0, import_react.useState)(0);
92
92
  const [emblaRef, emblaApi] = (0, import_embla_carousel_react.default)();
93
- const selectedVariant = available.find((v) => v.id === variant) || available[0] || null;
93
+ const chosen = available.find((v) => v.id === variant) || null;
94
+ const selectedVariant = chosen || available[0] || null;
95
+ const [picked, setPicked] = (0, import_react.useState)([]);
94
96
  const images = (0, import_react.useMemo)(
95
97
  () => {
98
+ var _a2;
96
99
  const variants = ((product == null ? void 0 : product.variants) || []).filter((v) => v.availableForSale);
97
100
  const result = [];
98
101
  const seen = /* @__PURE__ */ new Set();
99
- if (product == null ? void 0 : product.image) {
102
+ const remote = (url, variant2 = null) => ({
103
+ src: (0, import_cdn.cdnShopify)(url, "400x400", product == null ? void 0 : product.updatedAt) || url,
104
+ thumb: (0, import_cdn.cdnShopify)(url, "100x100", product == null ? void 0 : product.updatedAt) || url,
105
+ url,
106
+ variant: variant2
107
+ });
108
+ for (const item of (product == null ? void 0 : product.images) || []) {
109
+ if ((item == null ? void 0 : item.url) && !seen.has(item.url)) {
110
+ seen.add(item.url);
111
+ result.push(remote(item.url));
112
+ } else if ((_a2 = item == null ? void 0 : item.file) == null ? void 0 : _a2.sizes) {
113
+ const src = (0, import_cdn.cdnSrc)(item.file, "400x400", item.file.updatedAt) || (0, import_cdn.cdnSrc)(item.file, "original", item.file.updatedAt);
114
+ if (src) result.push({
115
+ src,
116
+ thumb: (0, import_cdn.cdnSrc)(item.file, "100x100", item.file.updatedAt) || src,
117
+ url: item.file.id,
118
+ variant: null
119
+ });
120
+ }
121
+ }
122
+ if (!result.length && (product == null ? void 0 : product.image)) {
100
123
  seen.add(product.image);
101
- result.push({
102
- src: product.image,
103
- variant: null
104
- });
124
+ result.push(remote(product.image));
105
125
  }
106
126
  for (const v of variants) {
107
127
  if (v.image && !seen.has(v.image)) {
108
128
  seen.add(v.image);
109
- result.push({
110
- src: v.image,
111
- variant: v
112
- });
129
+ result.push(remote(v.image, v));
113
130
  }
114
131
  }
115
132
  return result;
@@ -134,13 +151,25 @@ const Product = ({
134
151
  onVariantChange(value);
135
152
  const v = available.find((x) => x.id === value);
136
153
  if (!(v == null ? void 0 : v.image)) return;
137
- const idx = images.findIndex((img) => img.src === v.image);
154
+ const idx = images.findIndex((img) => img.url === v.image);
138
155
  if (idx >= 0) {
139
156
  setActiveImage(idx);
140
157
  emblaApi == null ? void 0 : emblaApi.scrollTo(idx);
141
158
  }
142
159
  ;
143
160
  };
161
+ const options = ((product == null ? void 0 : product.options) || []).filter(() => available.every((v) => (v.selectedOptions || []).length));
162
+ const values = chosen ? (chosen.selectedOptions || []).map((item) => item == null ? void 0 : item.value) : picked;
163
+ const pickOption = (index, value) => {
164
+ const wanted = options.map((item, key) => key === index ? value : values[key]);
165
+ setPicked(wanted);
166
+ if (wanted.some((item) => !item)) return onVariantChange("");
167
+ const match = available.find((v) => (v.selectedOptions || []).every((item, key) => (item == null ? void 0 : item.value) === wanted[key])) || available.find((v) => {
168
+ var _a2, _b2;
169
+ return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
170
+ });
171
+ if (match) handleVariant(match.id);
172
+ };
144
173
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
145
174
  "div",
146
175
  {
@@ -170,7 +199,7 @@ const Product = ({
170
199
  classNameScroll: "flex flex-col w-12 h-48 space-y-3",
171
200
  color: resolved.background.color.rgb
172
201
  },
173
- children: images.map(({ src }, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
202
+ children: images.map(({ thumb }, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
174
203
  import_button.default,
175
204
  {
176
205
  ...{
@@ -199,7 +228,7 @@ const Product = ({
199
228
  className: "object-cover",
200
229
  fill: true,
201
230
  sizes: "48px",
202
- src: (0, import_cdn.cdnShopify)(src, "100x100", product == null ? void 0 : product.updatedAt) || src,
231
+ src: thumb,
203
232
  // Always set opacity + transition so switching the active
204
233
  // thumbnail animates the fade in both directions.
205
234
  style: {
@@ -260,7 +289,7 @@ const Product = ({
260
289
  className: "object-cover",
261
290
  fill: true,
262
291
  sizes: "192px",
263
- src: (0, import_cdn.cdnShopify)(src, "400x400", product == null ? void 0 : product.updatedAt) || src,
292
+ src,
264
293
  unoptimized: true
265
294
  }
266
295
  }
@@ -292,11 +321,24 @@ const Product = ({
292
321
  children: product == null ? void 0 : product.title
293
322
  }
294
323
  ),
295
- !available.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: (0, import_drawbridge_utils.formatCurrency)({
296
- code: selectedVariant.currency,
297
- display: "parts",
298
- value: selectedVariant.price
299
- }) }),
324
+ !available.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Unavailable" }) : (selectedVariant == null ? void 0 : selectedVariant.price) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
325
+ (0, import_helpers.money)({
326
+ code: selectedVariant.currency,
327
+ value: selectedVariant.price
328
+ }),
329
+ selectedVariant.sale > selectedVariant.price && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
330
+ "s",
331
+ {
332
+ ...{
333
+ className: "ml-2 opacity-60"
334
+ },
335
+ children: (0, import_helpers.money)({
336
+ code: selectedVariant.currency,
337
+ value: selectedVariant.sale
338
+ })
339
+ }
340
+ )
341
+ ] }),
300
342
  (product == null ? void 0 : product.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
301
343
  import_wrapper_gradient.default,
302
344
  {
@@ -310,7 +352,37 @@ const Product = ({
310
352
  ]
311
353
  }
312
354
  ),
313
- available.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
355
+ options.length > 0 && available.length > 0 && options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
356
+ import_input_group.default,
357
+ {
358
+ ...{
359
+ error: index === options.length - 1 ? errors == null ? void 0 : errors.variant : null,
360
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
361
+ import_input_select.default,
362
+ {
363
+ ...{
364
+ "aria-label": option.name,
365
+ disabled,
366
+ onChange: (value) => pickOption(index, value),
367
+ options: option.values.filter((value) => available.some((v) => {
368
+ var _a2, _b2;
369
+ return ((_b2 = (_a2 = v.selectedOptions) == null ? void 0 : _a2[index]) == null ? void 0 : _b2.value) === value;
370
+ })).map((value) => ({
371
+ label: value,
372
+ value
373
+ })),
374
+ style: resolved,
375
+ value: values[index] || ""
376
+ }
377
+ }
378
+ ),
379
+ label: option.name,
380
+ style: resolved
381
+ }
382
+ },
383
+ "option-" + option.name
384
+ )),
385
+ !options.length && available.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
314
386
  import_input_group.default,
315
387
  {
316
388
  ...{
@@ -334,7 +406,7 @@ const Product = ({
334
406
  }
335
407
  }
336
408
  ),
337
- available.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
409
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
338
410
  import_input_group.default,
339
411
  {
340
412
  ...{
@@ -356,7 +428,7 @@ const Product = ({
356
428
  import_button.default,
357
429
  {
358
430
  ...{
359
- disabled: disabled || Boolean(action),
431
+ disabled: disabled || Boolean(action) || !available.length,
360
432
  onClick: onAdd,
361
433
  variant: "link"
362
434
  },
@@ -386,7 +458,7 @@ const Product = ({
386
458
  import_button.default,
387
459
  {
388
460
  ...{
389
- disabled: disabled || Boolean(action),
461
+ disabled: disabled || Boolean(action) || !available.length,
390
462
  loading: action === "buy",
391
463
  onClick: onBuy,
392
464
  style: resolved