@rebuy/rebuy 3.47.0 → 3.48.0

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.
@@ -3228,6 +3228,20 @@ var tiptapPlainText = (doc) => listOf(doc?.content).map(
3228
3228
  (paragraph) => listOf(paragraph.content).map((node) => node.text ?? "").join("")
3229
3229
  ).join(" ").trim();
3230
3230
 
3231
+ // src/transforms/productCard/addToOrderButton.ts
3232
+ var labelSlot = (buttonField, defaults, override, knownTokens = [], legacyDefaults = []) => ({
3233
+ buttonField,
3234
+ content: localizedContent(defaults, override, knownTokens, legacyDefaults),
3235
+ sectionType: "text"
3236
+ });
3237
+ var addToOrderButton = (buttonStyle, sections, extra = {}) => ({
3238
+ action: "addToOrder",
3239
+ buttonStyle,
3240
+ sections,
3241
+ sectionType: "button",
3242
+ ...extra
3243
+ });
3244
+
3231
3245
  // src/transforms/productCard/earnedText.ts
3232
3246
  var contentMutator = (effect, variable, operator) => ({
3233
3247
  effect,
@@ -3296,16 +3310,13 @@ var quantitySection = ({ errorMessages, inputType, maxValue, minValue, name }) =
3296
3310
  var SWITCH_LABEL_TOKENS2 = ["subscriptionDiscount", "frequency", "interval"];
3297
3311
  var subscriptionToggle = (productType, labels = {}) => {
3298
3312
  if (productType !== "both" && productType !== "subscription") return [];
3299
- const slot = (buttonField, override) => ({
3313
+ const slot = (buttonField, override) => labelSlot(
3300
3314
  buttonField,
3301
- content: localizedContent(
3302
- SWITCH_LABELS[buttonField],
3303
- override,
3304
- SWITCH_LABEL_TOKENS2,
3305
- LEGACY_LABEL_DEFAULTS[buttonField]
3306
- ),
3307
- sectionType: "text"
3308
- });
3315
+ SWITCH_LABELS[buttonField],
3316
+ override,
3317
+ SWITCH_LABEL_TOKENS2,
3318
+ LEGACY_LABEL_DEFAULTS[buttonField]
3319
+ );
3309
3320
  return [
3310
3321
  {
3311
3322
  action: "switchToSubscription",
@@ -3504,20 +3515,16 @@ var buildRevealButton = (settings) => revealsVariants(settings) ? [
3504
3515
  }
3505
3516
  ] : [];
3506
3517
  var buildAddButton = (settings) => {
3507
- const slot = (buttonField, override) => ({
3518
+ const slot = (buttonField, override) => labelSlot(
3508
3519
  buttonField,
3509
- content: localizedContent(
3510
- OFFER_LABELS[buttonField],
3511
- override,
3512
- ADD_LABEL_TOKENS,
3513
- LEGACY_LABEL_DEFAULTS[buttonField]
3514
- ),
3515
- sectionType: "text"
3516
- });
3517
- return {
3518
- action: "addToOrder",
3519
- buttonStyle: buttonKind(settings),
3520
- sections: [
3520
+ OFFER_LABELS[buttonField],
3521
+ override,
3522
+ ADD_LABEL_TOKENS,
3523
+ LEGACY_LABEL_DEFAULTS[buttonField]
3524
+ );
3525
+ return addToOrderButton(
3526
+ buttonKind(settings),
3527
+ [
3521
3528
  slot("addToCart", settings.language?.addToCart),
3522
3529
  slot("addingToCart", settings.language?.addingToCart),
3523
3530
  slot("addedToCart", settings.language?.addedToCart),
@@ -3525,9 +3532,8 @@ var buildAddButton = (settings) => {
3525
3532
  // Off-checkout Buy Now: the label the button shows once it links to the created checkout.
3526
3533
  slot("redirectToCheckout", settings.language?.redirectToCheckout)
3527
3534
  ],
3528
- sectionType: "button",
3529
- ...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
3530
- };
3535
+ revealsVariants(settings) ? { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } } : {}
3536
+ );
3531
3537
  };
3532
3538
  var buildOfferCard = (settings, horizontal) => {
3533
3539
  const image = buildImage(settings);
@@ -4208,95 +4214,28 @@ var convertImageContentBlock = (raw, report) => {
4208
4214
  return [CABLayoutSection.parse({ frame: "offer-content", sections: [inner], spacing: "none" })];
4209
4215
  };
4210
4216
 
4211
- // src/transforms/postPurchase/convertPayButtonBlock.ts
4212
- var convertPayButtonBlock = (raw, report) => {
4213
- const omit = () => {
4214
- report?.({ detail: "Unreadable post-purchase Pay block", kind: "section" });
4215
- return [];
4216
- };
4217
- const parsed = PayButtonBlock.safeParse(raw);
4218
- if (!parsed.success) return omit();
4219
- const { settings, styles: styles2 } = parsed.data;
4220
- const label2 = settings.label ? `${settings.label} \xB7 {{total}}` : "{{total}}";
4221
- const text2 = CABTextSection.safeParse({ content: { en: label2 } });
4222
- if (!text2.success) return omit();
4223
- return [
4224
- CABLayoutSection.parse({
4225
- alignment: { horizontal: "center" },
4226
- direction: "grid",
4227
- grid: { columns: ["100%"] },
4228
- sections: [
4229
- CABButtonSection.parse({
4230
- action: "addToOrder",
4231
- sections: [text2.data]
4232
- })
4233
- ],
4234
- width: styles2.buttonWidth
4235
- })
4236
- ];
4237
- };
4238
-
4239
- // src/transforms/postPurchase/productCardControls.ts
4240
- var SELECT_VARIANT = { en: "Select Variant" };
4241
- var PRODUCT_GROUP = { en: "Option" };
4242
- var groupSelector = { label: PRODUCT_GROUP, sectionType: "variants", selector: "menu", variantMode: "productGroup" };
4243
- var variantSelector = ({ productOptions }) => {
4244
- if (!productOptions.showVariantSelectors) return [];
4245
- const single = productOptions.variantSelectorDisplayMode === "single";
4246
- return [
4247
- {
4248
- hideOutOfStockVariants: single || productOptions.hideOutOfStockVariants,
4249
- ...single && { label: SELECT_VARIANT },
4250
- sectionType: "variants",
4251
- selector: "menu",
4252
- variantMode: single ? "single" : "multiple"
4253
- }
4254
- ];
4255
- };
4256
- var quantity = ({ language: language3, quantityInputs: quantityInputs2 }) => quantityInputs2.enabled ? [
4257
- quantitySection({
4258
- maxValue: quantityInputs2.maxValue,
4259
- minValue: quantityInputs2.minValue,
4260
- name: language3.global.quantity.trim()
4261
- })
4262
- ] : [];
4263
- var productCardControls = (settings) => [
4264
- ...subscriptionToggle(settings.productType, { frequencyLabel: "planName" }),
4265
- groupSelector,
4266
- ...variantSelector(settings),
4267
- ...quantity(settings)
4217
+ // src/transforms/postPurchase/productCardPay.ts
4218
+ import { mapValues } from "es-toolkit";
4219
+ var PAY_NOW = { en: "Pay Now" };
4220
+ var DECLINE_THIS_OFFER = { en: "Decline this offer" };
4221
+ var NOT_AVAILABLE_DEFAULTS = ["Not available"];
4222
+ var soldOutSlot = ({ language: language3 }) => labelSlot("soldOut", OFFER_LABELS.soldOut, language3.global.notAvailable, [], NOT_AVAILABLE_DEFAULTS);
4223
+ var productCardPay = (settings) => {
4224
+ const payNow = labelSlot("payNow", PAY_NOW, settings.language.global.payNow);
4225
+ const priced = settings.language.displayCtaPrice ? { ...payNow, content: mapValues(payNow.content, (label2) => `${label2} \xB7 {{total}}`) } : payNow;
4226
+ return [addToOrderButton("primary", [priced, soldOutSlot(settings)])];
4227
+ };
4228
+ var productCardDecline = ({ language: language3 }) => [
4229
+ {
4230
+ action: "declineOffer",
4231
+ buttonStyle: "secondary",
4232
+ sections: [labelSlot("declineOffer", DECLINE_THIS_OFFER, language3.global.declineThisOffer)],
4233
+ sectionType: "button"
4234
+ }
4268
4235
  ];
4269
4236
 
4270
- // src/transforms/postPurchase/productCardRows.ts
4271
- var styledCopy = (text2, look) => ({
4272
- content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text: text2, type: "text" }], type: "paragraph" }],
4273
- type: "doc"
4274
- });
4275
- var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
4276
- var boundText = (variable, content) => ({
4277
- content,
4278
- sectionType: "text",
4279
- visibility: shownWhile(variable)
4280
- });
4281
- var earnedRow = ({ after, columns, label: label2, look, spacing, token, variable }) => {
4282
- const styled2 = (text2) => look ? styledCopy(text2, look) : text2;
4283
- const value = earnedText(variable, styled2(token));
4284
- return {
4285
- direction: "grid",
4286
- grid: { columns, rows: ["auto"] },
4287
- sections: [
4288
- boundText(variable, look ? { en: styled2(String(label2.en)) } : label2),
4289
- value,
4290
- ...after === void 0 ? [] : [boundText(variable, { en: styled2(String(after)) })]
4291
- ],
4292
- sectionType: "layout",
4293
- ...spacing && { spacing }
4294
- };
4295
- };
4296
- var earnedVariables = (names) => names.map((name) => ({ defaultValue: false, name }));
4297
-
4298
4237
  // src/transforms/postPurchase/productCardSettings.ts
4299
- import { mapValues } from "es-toolkit";
4238
+ import { mapValues as mapValues2 } from "es-toolkit";
4300
4239
  import { z as z38 } from "zod";
4301
4240
 
4302
4241
  // src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
@@ -4488,9 +4427,12 @@ var PostPurchaseSettings = z37.object({
4488
4427
  // src/transforms/postPurchase/productCardSettings.ts
4489
4428
  var { shape } = PostPurchaseSettings;
4490
4429
  var Labels = z38.object(
4491
- mapValues(shape.language.shape.global.unwrap().unwrap().shape, (label2) => label2.catch(() => label2.parse(void 0)))
4430
+ mapValues2(shape.language.shape.global.unwrap().unwrap().shape, (label2) => label2.catch(() => label2.parse(void 0)))
4492
4431
  );
4493
- var Language = z38.object({ global: Labels.catch(() => Labels.parse({})) });
4432
+ var Language = z38.object({
4433
+ displayCtaPrice: shape.language.shape.displayCtaPrice.catch(true),
4434
+ global: Labels.catch(() => Labels.parse({}))
4435
+ });
4494
4436
  var Fields = z38.object({
4495
4437
  discount: shape.discount.catch(() => shape.discount.parse({})),
4496
4438
  language: Language.catch(() => Language.parse({})),
@@ -4504,6 +4446,93 @@ var Fields = z38.object({
4504
4446
  var ProductCardSettings = Fields.catch(() => Fields.parse({}));
4505
4447
  var sellsSubscription = ({ productType, upgradeToSubscription }) => productType !== "one-time" || upgradeToSubscription.allow;
4506
4448
 
4449
+ // src/transforms/postPurchase/convertPayButtonBlock.ts
4450
+ var convertPayButtonBlock = (raw, report, widgetSettings) => {
4451
+ const omit = () => {
4452
+ report?.({ detail: "Unreadable post-purchase Pay block", kind: "section" });
4453
+ return [];
4454
+ };
4455
+ const parsed = PayButtonBlock.safeParse(raw);
4456
+ if (!parsed.success) return omit();
4457
+ const { settings, styles: styles2 } = parsed.data;
4458
+ const label2 = settings.label ? `${settings.label} \xB7 {{total}}` : "{{total}}";
4459
+ const text2 = CABTextSection.safeParse({ content: { en: label2 } });
4460
+ if (!text2.success) return omit();
4461
+ return [
4462
+ CABLayoutSection.parse({
4463
+ alignment: { horizontal: "center" },
4464
+ direction: "grid",
4465
+ grid: { columns: ["100%"] },
4466
+ sections: [
4467
+ CABButtonSection.parse({
4468
+ action: "addToOrder",
4469
+ sections: [text2.data, soldOutSlot(ProductCardSettings.parse(widgetSettings ?? {}))]
4470
+ })
4471
+ ],
4472
+ width: styles2.buttonWidth
4473
+ })
4474
+ ];
4475
+ };
4476
+
4477
+ // src/transforms/postPurchase/productCardControls.ts
4478
+ var SELECT_VARIANT = { en: "Select Variant" };
4479
+ var PRODUCT_GROUP = { en: "Option" };
4480
+ var groupSelector = { label: PRODUCT_GROUP, sectionType: "variants", selector: "menu", variantMode: "productGroup" };
4481
+ var variantSelector = ({ productOptions }) => {
4482
+ if (!productOptions.showVariantSelectors) return [];
4483
+ const single = productOptions.variantSelectorDisplayMode === "single";
4484
+ return [
4485
+ {
4486
+ hideOutOfStockVariants: single || productOptions.hideOutOfStockVariants,
4487
+ ...single && { label: SELECT_VARIANT },
4488
+ sectionType: "variants",
4489
+ selector: "menu",
4490
+ variantMode: single ? "single" : "multiple"
4491
+ }
4492
+ ];
4493
+ };
4494
+ var quantity = ({ language: language3, quantityInputs: quantityInputs2 }) => quantityInputs2.enabled ? [
4495
+ quantitySection({
4496
+ maxValue: quantityInputs2.maxValue,
4497
+ minValue: quantityInputs2.minValue,
4498
+ name: language3.global.quantity.trim()
4499
+ })
4500
+ ] : [];
4501
+ var productCardControls = (settings) => [
4502
+ ...subscriptionToggle(settings.productType, { frequencyLabel: "planName" }),
4503
+ groupSelector,
4504
+ ...variantSelector(settings),
4505
+ ...quantity(settings)
4506
+ ];
4507
+
4508
+ // src/transforms/postPurchase/productCardRows.ts
4509
+ var styledCopy = (text2, look) => ({
4510
+ content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text: text2, type: "text" }], type: "paragraph" }],
4511
+ type: "doc"
4512
+ });
4513
+ var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
4514
+ var boundText = (variable, content) => ({
4515
+ content,
4516
+ sectionType: "text",
4517
+ visibility: shownWhile(variable)
4518
+ });
4519
+ var earnedRow = ({ after, columns, label: label2, look, spacing, token, variable }) => {
4520
+ const styled2 = (text2) => look ? styledCopy(text2, look) : text2;
4521
+ const value = earnedText(variable, styled2(token));
4522
+ return {
4523
+ direction: "grid",
4524
+ grid: { columns, rows: ["auto"] },
4525
+ sections: [
4526
+ boundText(variable, look ? { en: styled2(String(label2.en)) } : label2),
4527
+ value,
4528
+ ...after === void 0 ? [] : [boundText(variable, { en: styled2(String(after)) })]
4529
+ ],
4530
+ sectionType: "layout",
4531
+ ...spacing && { spacing }
4532
+ };
4533
+ };
4534
+ var earnedVariables = (names) => names.map((name) => ({ defaultValue: false, name }));
4535
+
4507
4536
  // src/transforms/postPurchase/productCardCosts.ts
4508
4537
  var COST_ROWS = [
4509
4538
  ["showSubtotal", "subtotal", "Subtotal", "hasSubtotal"],
@@ -4660,7 +4689,9 @@ var convertProductInformation = (raw, report, widgetSettings) => {
4660
4689
  CABReviewsSection.parse({}),
4661
4690
  CABTextSection.parse({ content: { en: "{{productDescription}}" } }),
4662
4691
  ...productCardControls(settings),
4663
- ...productCardCosts(settings)
4692
+ ...productCardCosts(settings),
4693
+ ...productCardPay(settings),
4694
+ ...productCardDecline(settings)
4664
4695
  ]
4665
4696
  })
4666
4697
  ],
@@ -3096,6 +3096,20 @@ var tiptapPlainText = (doc) => listOf(doc?.content).map(
3096
3096
  (paragraph) => listOf(paragraph.content).map((node) => node.text ?? "").join("")
3097
3097
  ).join(" ").trim();
3098
3098
 
3099
+ // src/transforms/productCard/addToOrderButton.ts
3100
+ var labelSlot = (buttonField, defaults, override, knownTokens = [], legacyDefaults = []) => ({
3101
+ buttonField,
3102
+ content: localizedContent(defaults, override, knownTokens, legacyDefaults),
3103
+ sectionType: "text"
3104
+ });
3105
+ var addToOrderButton = (buttonStyle, sections, extra = {}) => ({
3106
+ action: "addToOrder",
3107
+ buttonStyle,
3108
+ sections,
3109
+ sectionType: "button",
3110
+ ...extra
3111
+ });
3112
+
3099
3113
  // src/transforms/productCard/earnedText.ts
3100
3114
  var contentMutator = (effect, variable, operator) => ({
3101
3115
  effect,
@@ -3164,16 +3178,13 @@ var quantitySection = ({ errorMessages, inputType, maxValue, minValue, name }) =
3164
3178
  var SWITCH_LABEL_TOKENS2 = ["subscriptionDiscount", "frequency", "interval"];
3165
3179
  var subscriptionToggle = (productType, labels = {}) => {
3166
3180
  if (productType !== "both" && productType !== "subscription") return [];
3167
- const slot = (buttonField, override) => ({
3181
+ const slot = (buttonField, override) => labelSlot(
3168
3182
  buttonField,
3169
- content: localizedContent(
3170
- SWITCH_LABELS[buttonField],
3171
- override,
3172
- SWITCH_LABEL_TOKENS2,
3173
- LEGACY_LABEL_DEFAULTS[buttonField]
3174
- ),
3175
- sectionType: "text"
3176
- });
3183
+ SWITCH_LABELS[buttonField],
3184
+ override,
3185
+ SWITCH_LABEL_TOKENS2,
3186
+ LEGACY_LABEL_DEFAULTS[buttonField]
3187
+ );
3177
3188
  return [
3178
3189
  {
3179
3190
  action: "switchToSubscription",
@@ -3372,20 +3383,16 @@ var buildRevealButton = (settings) => revealsVariants(settings) ? [
3372
3383
  }
3373
3384
  ] : [];
3374
3385
  var buildAddButton = (settings) => {
3375
- const slot = (buttonField, override) => ({
3386
+ const slot = (buttonField, override) => labelSlot(
3376
3387
  buttonField,
3377
- content: localizedContent(
3378
- OFFER_LABELS[buttonField],
3379
- override,
3380
- ADD_LABEL_TOKENS,
3381
- LEGACY_LABEL_DEFAULTS[buttonField]
3382
- ),
3383
- sectionType: "text"
3384
- });
3385
- return {
3386
- action: "addToOrder",
3387
- buttonStyle: buttonKind(settings),
3388
- sections: [
3388
+ OFFER_LABELS[buttonField],
3389
+ override,
3390
+ ADD_LABEL_TOKENS,
3391
+ LEGACY_LABEL_DEFAULTS[buttonField]
3392
+ );
3393
+ return addToOrderButton(
3394
+ buttonKind(settings),
3395
+ [
3389
3396
  slot("addToCart", settings.language?.addToCart),
3390
3397
  slot("addingToCart", settings.language?.addingToCart),
3391
3398
  slot("addedToCart", settings.language?.addedToCart),
@@ -3393,9 +3400,8 @@ var buildAddButton = (settings) => {
3393
3400
  // Off-checkout Buy Now: the label the button shows once it links to the created checkout.
3394
3401
  slot("redirectToCheckout", settings.language?.redirectToCheckout)
3395
3402
  ],
3396
- sectionType: "button",
3397
- ...revealsVariants(settings) && { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } }
3398
- };
3403
+ revealsVariants(settings) ? { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } } : {}
3404
+ );
3399
3405
  };
3400
3406
  var buildOfferCard = (settings, horizontal) => {
3401
3407
  const image = buildImage(settings);
@@ -4084,95 +4090,28 @@ var convertImageContentBlock = (raw, report) => {
4084
4090
  return [CABLayoutSection.parse({ frame: "offer-content", sections: [inner], spacing: "none" })];
4085
4091
  };
4086
4092
 
4087
- // src/transforms/postPurchase/convertPayButtonBlock.ts
4088
- var convertPayButtonBlock = (raw, report) => {
4089
- const omit = () => {
4090
- report?.({ detail: "Unreadable post-purchase Pay block", kind: "section" });
4091
- return [];
4092
- };
4093
- const parsed = PayButtonBlock.safeParse(raw);
4094
- if (!parsed.success) return omit();
4095
- const { settings, styles: styles2 } = parsed.data;
4096
- const label = settings.label ? `${settings.label} \xB7 {{total}}` : "{{total}}";
4097
- const text = CABTextSection.safeParse({ content: { en: label } });
4098
- if (!text.success) return omit();
4099
- return [
4100
- CABLayoutSection.parse({
4101
- alignment: { horizontal: "center" },
4102
- direction: "grid",
4103
- grid: { columns: ["100%"] },
4104
- sections: [
4105
- CABButtonSection.parse({
4106
- action: "addToOrder",
4107
- sections: [text.data]
4108
- })
4109
- ],
4110
- width: styles2.buttonWidth
4111
- })
4112
- ];
4113
- };
4114
-
4115
- // src/transforms/postPurchase/productCardControls.ts
4116
- var SELECT_VARIANT = { en: "Select Variant" };
4117
- var PRODUCT_GROUP = { en: "Option" };
4118
- var groupSelector = { label: PRODUCT_GROUP, sectionType: "variants", selector: "menu", variantMode: "productGroup" };
4119
- var variantSelector = ({ productOptions }) => {
4120
- if (!productOptions.showVariantSelectors) return [];
4121
- const single = productOptions.variantSelectorDisplayMode === "single";
4122
- return [
4123
- {
4124
- hideOutOfStockVariants: single || productOptions.hideOutOfStockVariants,
4125
- ...single && { label: SELECT_VARIANT },
4126
- sectionType: "variants",
4127
- selector: "menu",
4128
- variantMode: single ? "single" : "multiple"
4129
- }
4130
- ];
4093
+ // src/transforms/postPurchase/productCardPay.ts
4094
+ var import_es_toolkit6 = require("es-toolkit");
4095
+ var PAY_NOW = { en: "Pay Now" };
4096
+ var DECLINE_THIS_OFFER = { en: "Decline this offer" };
4097
+ var NOT_AVAILABLE_DEFAULTS = ["Not available"];
4098
+ var soldOutSlot = ({ language }) => labelSlot("soldOut", OFFER_LABELS.soldOut, language.global.notAvailable, [], NOT_AVAILABLE_DEFAULTS);
4099
+ var productCardPay = (settings) => {
4100
+ const payNow = labelSlot("payNow", PAY_NOW, settings.language.global.payNow);
4101
+ const priced = settings.language.displayCtaPrice ? { ...payNow, content: (0, import_es_toolkit6.mapValues)(payNow.content, (label) => `${label} \xB7 {{total}}`) } : payNow;
4102
+ return [addToOrderButton("primary", [priced, soldOutSlot(settings)])];
4131
4103
  };
4132
- var quantity = ({ language, quantityInputs: quantityInputs2 }) => quantityInputs2.enabled ? [
4133
- quantitySection({
4134
- maxValue: quantityInputs2.maxValue,
4135
- minValue: quantityInputs2.minValue,
4136
- name: language.global.quantity.trim()
4137
- })
4138
- ] : [];
4139
- var productCardControls = (settings) => [
4140
- ...subscriptionToggle(settings.productType, { frequencyLabel: "planName" }),
4141
- groupSelector,
4142
- ...variantSelector(settings),
4143
- ...quantity(settings)
4104
+ var productCardDecline = ({ language }) => [
4105
+ {
4106
+ action: "declineOffer",
4107
+ buttonStyle: "secondary",
4108
+ sections: [labelSlot("declineOffer", DECLINE_THIS_OFFER, language.global.declineThisOffer)],
4109
+ sectionType: "button"
4110
+ }
4144
4111
  ];
4145
4112
 
4146
- // src/transforms/postPurchase/productCardRows.ts
4147
- var styledCopy = (text, look) => ({
4148
- content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text, type: "text" }], type: "paragraph" }],
4149
- type: "doc"
4150
- });
4151
- var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
4152
- var boundText = (variable, content) => ({
4153
- content,
4154
- sectionType: "text",
4155
- visibility: shownWhile(variable)
4156
- });
4157
- var earnedRow = ({ after, columns, label, look, spacing, token, variable }) => {
4158
- const styled = (text) => look ? styledCopy(text, look) : text;
4159
- const value = earnedText(variable, styled(token));
4160
- return {
4161
- direction: "grid",
4162
- grid: { columns, rows: ["auto"] },
4163
- sections: [
4164
- boundText(variable, look ? { en: styled(String(label.en)) } : label),
4165
- value,
4166
- ...after === void 0 ? [] : [boundText(variable, { en: styled(String(after)) })]
4167
- ],
4168
- sectionType: "layout",
4169
- ...spacing && { spacing }
4170
- };
4171
- };
4172
- var earnedVariables = (names) => names.map((name) => ({ defaultValue: false, name }));
4173
-
4174
4113
  // src/transforms/postPurchase/productCardSettings.ts
4175
- var import_es_toolkit6 = require("es-toolkit");
4114
+ var import_es_toolkit7 = require("es-toolkit");
4176
4115
  var import_zod32 = require("zod");
4177
4116
 
4178
4117
  // src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
@@ -4364,9 +4303,12 @@ var PostPurchaseSettings = import_zod31.z.object({
4364
4303
  // src/transforms/postPurchase/productCardSettings.ts
4365
4304
  var { shape } = PostPurchaseSettings;
4366
4305
  var Labels = import_zod32.z.object(
4367
- (0, import_es_toolkit6.mapValues)(shape.language.shape.global.unwrap().unwrap().shape, (label) => label.catch(() => label.parse(void 0)))
4306
+ (0, import_es_toolkit7.mapValues)(shape.language.shape.global.unwrap().unwrap().shape, (label) => label.catch(() => label.parse(void 0)))
4368
4307
  );
4369
- var Language = import_zod32.z.object({ global: Labels.catch(() => Labels.parse({})) });
4308
+ var Language = import_zod32.z.object({
4309
+ displayCtaPrice: shape.language.shape.displayCtaPrice.catch(true),
4310
+ global: Labels.catch(() => Labels.parse({}))
4311
+ });
4370
4312
  var Fields = import_zod32.z.object({
4371
4313
  discount: shape.discount.catch(() => shape.discount.parse({})),
4372
4314
  language: Language.catch(() => Language.parse({})),
@@ -4380,6 +4322,93 @@ var Fields = import_zod32.z.object({
4380
4322
  var ProductCardSettings = Fields.catch(() => Fields.parse({}));
4381
4323
  var sellsSubscription = ({ productType, upgradeToSubscription }) => productType !== "one-time" || upgradeToSubscription.allow;
4382
4324
 
4325
+ // src/transforms/postPurchase/convertPayButtonBlock.ts
4326
+ var convertPayButtonBlock = (raw, report, widgetSettings) => {
4327
+ const omit = () => {
4328
+ report?.({ detail: "Unreadable post-purchase Pay block", kind: "section" });
4329
+ return [];
4330
+ };
4331
+ const parsed = PayButtonBlock.safeParse(raw);
4332
+ if (!parsed.success) return omit();
4333
+ const { settings, styles: styles2 } = parsed.data;
4334
+ const label = settings.label ? `${settings.label} \xB7 {{total}}` : "{{total}}";
4335
+ const text = CABTextSection.safeParse({ content: { en: label } });
4336
+ if (!text.success) return omit();
4337
+ return [
4338
+ CABLayoutSection.parse({
4339
+ alignment: { horizontal: "center" },
4340
+ direction: "grid",
4341
+ grid: { columns: ["100%"] },
4342
+ sections: [
4343
+ CABButtonSection.parse({
4344
+ action: "addToOrder",
4345
+ sections: [text.data, soldOutSlot(ProductCardSettings.parse(widgetSettings ?? {}))]
4346
+ })
4347
+ ],
4348
+ width: styles2.buttonWidth
4349
+ })
4350
+ ];
4351
+ };
4352
+
4353
+ // src/transforms/postPurchase/productCardControls.ts
4354
+ var SELECT_VARIANT = { en: "Select Variant" };
4355
+ var PRODUCT_GROUP = { en: "Option" };
4356
+ var groupSelector = { label: PRODUCT_GROUP, sectionType: "variants", selector: "menu", variantMode: "productGroup" };
4357
+ var variantSelector = ({ productOptions }) => {
4358
+ if (!productOptions.showVariantSelectors) return [];
4359
+ const single = productOptions.variantSelectorDisplayMode === "single";
4360
+ return [
4361
+ {
4362
+ hideOutOfStockVariants: single || productOptions.hideOutOfStockVariants,
4363
+ ...single && { label: SELECT_VARIANT },
4364
+ sectionType: "variants",
4365
+ selector: "menu",
4366
+ variantMode: single ? "single" : "multiple"
4367
+ }
4368
+ ];
4369
+ };
4370
+ var quantity = ({ language, quantityInputs: quantityInputs2 }) => quantityInputs2.enabled ? [
4371
+ quantitySection({
4372
+ maxValue: quantityInputs2.maxValue,
4373
+ minValue: quantityInputs2.minValue,
4374
+ name: language.global.quantity.trim()
4375
+ })
4376
+ ] : [];
4377
+ var productCardControls = (settings) => [
4378
+ ...subscriptionToggle(settings.productType, { frequencyLabel: "planName" }),
4379
+ groupSelector,
4380
+ ...variantSelector(settings),
4381
+ ...quantity(settings)
4382
+ ];
4383
+
4384
+ // src/transforms/postPurchase/productCardRows.ts
4385
+ var styledCopy = (text, look) => ({
4386
+ content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text, type: "text" }], type: "paragraph" }],
4387
+ type: "doc"
4388
+ });
4389
+ var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
4390
+ var boundText = (variable, content) => ({
4391
+ content,
4392
+ sectionType: "text",
4393
+ visibility: shownWhile(variable)
4394
+ });
4395
+ var earnedRow = ({ after, columns, label, look, spacing, token, variable }) => {
4396
+ const styled = (text) => look ? styledCopy(text, look) : text;
4397
+ const value = earnedText(variable, styled(token));
4398
+ return {
4399
+ direction: "grid",
4400
+ grid: { columns, rows: ["auto"] },
4401
+ sections: [
4402
+ boundText(variable, look ? { en: styled(String(label.en)) } : label),
4403
+ value,
4404
+ ...after === void 0 ? [] : [boundText(variable, { en: styled(String(after)) })]
4405
+ ],
4406
+ sectionType: "layout",
4407
+ ...spacing && { spacing }
4408
+ };
4409
+ };
4410
+ var earnedVariables = (names) => names.map((name) => ({ defaultValue: false, name }));
4411
+
4383
4412
  // src/transforms/postPurchase/productCardCosts.ts
4384
4413
  var COST_ROWS = [
4385
4414
  ["showSubtotal", "subtotal", "Subtotal", "hasSubtotal"],
@@ -4536,7 +4565,9 @@ var convertProductInformation = (raw, report, widgetSettings) => {
4536
4565
  CABReviewsSection.parse({}),
4537
4566
  CABTextSection.parse({ content: { en: "{{productDescription}}" } }),
4538
4567
  ...productCardControls(settings),
4539
- ...productCardCosts(settings)
4568
+ ...productCardCosts(settings),
4569
+ ...productCardPay(settings),
4570
+ ...productCardDecline(settings)
4540
4571
  ]
4541
4572
  })
4542
4573
  ],