@churnkey/react 0.2.0 → 0.4.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.
Files changed (37) hide show
  1. package/dist/{chunk-YSNMTOAW.cjs → chunk-4BMB42WI.cjs} +9 -7
  2. package/dist/chunk-4BMB42WI.cjs.map +1 -0
  3. package/dist/{chunk-EHZJAQQ5.cjs → chunk-BDBZ5OS3.cjs} +21 -2
  4. package/dist/chunk-BDBZ5OS3.cjs.map +1 -0
  5. package/dist/{chunk-CPCWJTSG.js → chunk-F4ESJBOS.js} +6 -4
  6. package/dist/chunk-F4ESJBOS.js.map +1 -0
  7. package/dist/{chunk-SXGORJOX.js → chunk-G57YLYM5.js} +20 -3
  8. package/dist/chunk-G57YLYM5.js.map +1 -0
  9. package/dist/{chunk-OL5HQUE4.js → chunk-QYNW3HF3.js} +66 -26
  10. package/dist/chunk-QYNW3HF3.js.map +1 -0
  11. package/dist/{chunk-ZEYUKGAR.cjs → chunk-SNTKIKHU.cjs} +66 -26
  12. package/dist/chunk-SNTKIKHU.cjs.map +1 -0
  13. package/dist/core.cjs +20 -12
  14. package/dist/core.d.cts +30 -5
  15. package/dist/core.d.ts +30 -5
  16. package/dist/core.js +2 -2
  17. package/dist/headless.cjs +3 -3
  18. package/dist/headless.d.cts +5 -1
  19. package/dist/headless.d.ts +5 -1
  20. package/dist/headless.js +2 -2
  21. package/dist/index.cjs +218 -135
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +10 -8
  24. package/dist/index.d.ts +10 -8
  25. package/dist/index.js +125 -51
  26. package/dist/index.js.map +1 -1
  27. package/dist/{step-graph-Cbi0DRHX.d.cts → step-graph-DKvaV3Dg.d.cts} +56 -21
  28. package/dist/{step-graph-Cbi0DRHX.d.ts → step-graph-DKvaV3Dg.d.ts} +56 -21
  29. package/dist/styles.css +95 -19
  30. package/package.json +10 -10
  31. package/dist/chunk-CPCWJTSG.js.map +0 -1
  32. package/dist/chunk-EHZJAQQ5.cjs.map +0 -1
  33. package/dist/chunk-OL5HQUE4.js.map +0 -1
  34. package/dist/chunk-SXGORJOX.js.map +0 -1
  35. package/dist/chunk-YSNMTOAW.cjs.map +0 -1
  36. package/dist/chunk-ZEYUKGAR.cjs.map +0 -1
  37. package/dist/styles.css.d.ts +0 -1
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkYSNMTOAW_cjs = require('./chunk-YSNMTOAW.cjs');
4
- var chunkEHZJAQQ5_cjs = require('./chunk-EHZJAQQ5.cjs');
5
- var chunkZEYUKGAR_cjs = require('./chunk-ZEYUKGAR.cjs');
3
+ var chunk4BMB42WI_cjs = require('./chunk-4BMB42WI.cjs');
4
+ var chunkBDBZ5OS3_cjs = require('./chunk-BDBZ5OS3.cjs');
5
+ var chunkSNTKIKHU_cjs = require('./chunk-SNTKIKHU.cjs');
6
6
  var react = require('react');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
 
@@ -20,28 +20,29 @@ function RichText({ html, as = "p", className }) {
20
20
  function DefaultConfirm({
21
21
  title,
22
22
  description,
23
+ subscriptions,
23
24
  losses,
24
25
  lossesLabel,
25
26
  confirmLabel,
26
27
  goBackLabel,
27
- periodEnd,
28
28
  onConfirm,
29
29
  onGoBack,
30
30
  isProcessing,
31
31
  classNames
32
32
  }) {
33
33
  const hasLosses = Array.isArray(losses) && losses.length > 0;
34
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-confirm", classNames?.root), children: [
35
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: title }),
36
- description && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: description, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
37
- hasLosses && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-loss-block", classNames?.lossList), children: [
38
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkEHZJAQQ5_cjs.cn("ck-loss-label", classNames?.lossLabel), children: lossesLabel ?? "You'll lose access to:" }),
39
- /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "ck-loss-list", children: losses.map((item) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: chunkEHZJAQQ5_cjs.cn("ck-loss-item", classNames?.lossItem), children: [
40
- /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: chunkEHZJAQQ5_cjs.cn("ck-loss-bullet", classNames?.lossBullet), children: "\u25CF" }),
34
+ const periodEnd = chunkBDBZ5OS3_cjs.formatPeriodEnd(subscriptions);
35
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-confirm", classNames?.root), children: [
36
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: title }),
37
+ description && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: description, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
38
+ hasLosses && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-loss-block", classNames?.lossList), children: [
39
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkBDBZ5OS3_cjs.cn("ck-loss-label", classNames?.lossLabel), children: lossesLabel ?? "You'll lose access to:" }),
40
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "ck-loss-list", children: losses.map((item) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: chunkBDBZ5OS3_cjs.cn("ck-loss-item", classNames?.lossItem), children: [
41
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: chunkBDBZ5OS3_cjs.cn("ck-loss-bullet", classNames?.lossBullet), children: "\u25CF" }),
41
42
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: item })
42
43
  ] }, item)) })
43
44
  ] }),
44
- periodEnd && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: chunkEHZJAQQ5_cjs.cn("ck-period-end", classNames?.periodEndNotice), children: [
45
+ periodEnd && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: chunkBDBZ5OS3_cjs.cn("ck-period-end", classNames?.periodEndNotice), children: [
45
46
  "Your access continues until ",
46
47
  periodEnd,
47
48
  "."
@@ -50,13 +51,13 @@ function DefaultConfirm({
50
51
  "button",
51
52
  {
52
53
  type: "button",
53
- className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-danger", classNames?.confirmButton),
54
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-danger", classNames?.confirmButton),
54
55
  onClick: onConfirm,
55
56
  disabled: isProcessing,
56
57
  children: isProcessing ? "Processing..." : confirmLabel
57
58
  }
58
59
  ),
59
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-button-link", classNames?.goBackButton), onClick: onGoBack, children: goBackLabel })
60
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button-link", classNames?.goBackButton), onClick: onGoBack, children: goBackLabel })
60
61
  ] });
61
62
  }
62
63
  function DefaultFeedback({
@@ -75,13 +76,13 @@ function DefaultFeedback({
75
76
  const isUnderMin = hasMin && value.length > 0 && value.length < minLength;
76
77
  const isValid = !required || value.length >= minLength;
77
78
  const placeholderText = placeholder ?? (hasMin ? `At least ${minLength} characters\u2026` : "Type your thoughts\u2026");
78
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-feedback", classNames?.root), children: [
79
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: title }),
80
- description && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: description, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
79
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-feedback", classNames?.root), children: [
80
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: title }),
81
+ description && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: description, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
81
82
  /* @__PURE__ */ jsxRuntime.jsxs(
82
83
  "div",
83
84
  {
84
- className: chunkEHZJAQQ5_cjs.cn(
85
+ className: chunkBDBZ5OS3_cjs.cn(
85
86
  "ck-feedback-field",
86
87
  focused && "ck-feedback-field--focused",
87
88
  isUnderMin && "ck-feedback-field--invalid"
@@ -90,7 +91,7 @@ function DefaultFeedback({
90
91
  /* @__PURE__ */ jsxRuntime.jsx(
91
92
  "textarea",
92
93
  {
93
- className: chunkEHZJAQQ5_cjs.cn("ck-textarea", classNames?.textarea),
94
+ className: chunkBDBZ5OS3_cjs.cn("ck-textarea", classNames?.textarea),
94
95
  placeholder: placeholderText,
95
96
  value,
96
97
  onChange: (e) => onChange(e.target.value),
@@ -102,7 +103,7 @@ function DefaultFeedback({
102
103
  hasMin && /* @__PURE__ */ jsxRuntime.jsxs(
103
104
  "div",
104
105
  {
105
- className: chunkEHZJAQQ5_cjs.cn(
106
+ className: chunkBDBZ5OS3_cjs.cn(
106
107
  "ck-character-count",
107
108
  isUnderMin && "ck-character-count--invalid",
108
109
  classNames?.characterCount
@@ -121,7 +122,7 @@ function DefaultFeedback({
121
122
  "button",
122
123
  {
123
124
  type: "button",
124
- className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-primary", classNames?.submitButton),
125
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.submitButton),
125
126
  onClick: onSubmit,
126
127
  disabled: !isValid,
127
128
  children: "Continue"
@@ -140,21 +141,21 @@ function DefaultContactOffer({
140
141
  }) {
141
142
  const headline = title ?? offer.copy.headline;
142
143
  const body = description ?? offer.copy.body;
143
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
144
- headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: headline }),
145
- body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
146
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-offer-card", classNames?.card), children: [
144
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
145
+ headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: headline }),
146
+ body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
147
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-offer-card", classNames?.card), children: [
147
148
  /* @__PURE__ */ jsxRuntime.jsx(
148
149
  "button",
149
150
  {
150
151
  type: "button",
151
- className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
152
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
152
153
  onClick: () => onAccept(),
153
154
  disabled: isProcessing,
154
155
  children: isProcessing ? "Processing..." : offer.copy.cta
155
156
  }
156
157
  ),
157
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
158
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
158
159
  ] })
159
160
  ] });
160
161
  }
@@ -170,11 +171,11 @@ function DefaultDiscountOffer({
170
171
  const o = offer;
171
172
  const headline = title ?? offer.copy.headline;
172
173
  const body = description ?? offer.copy.body;
173
- const phrase = chunkEHZJAQQ5_cjs.discountPhrase(o);
174
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
175
- headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: headline }),
176
- body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
177
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-offer-card", classNames?.card), children: [
174
+ const phrase = chunkBDBZ5OS3_cjs.discountPhrase(o);
175
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
176
+ headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: headline }),
177
+ body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
178
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-offer-card", classNames?.card), children: [
178
179
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-offer-details ck-offer-discount", children: [
179
180
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-offer-discount-eyebrow", children: "Limited-time offer" }),
180
181
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-offer-discount-phrase", children: phrase })
@@ -183,13 +184,13 @@ function DefaultDiscountOffer({
183
184
  "button",
184
185
  {
185
186
  type: "button",
186
- className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
187
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
187
188
  onClick: () => onAccept(),
188
189
  disabled: isProcessing,
189
190
  children: isProcessing ? "Processing..." : offer.copy.cta
190
191
  }
191
192
  ),
192
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
193
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
193
194
  ] })
194
195
  ] });
195
196
  }
@@ -209,19 +210,19 @@ function DefaultPauseOffer({
209
210
  const body = description ?? offer.copy.body;
210
211
  const resume = /* @__PURE__ */ new Date();
211
212
  resume.setMonth(resume.getMonth() + months);
212
- const resumeDate = chunkEHZJAQQ5_cjs.formatMonthDayLong(resume);
213
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
214
- headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: headline }),
215
- body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
216
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-offer-card ck-pause-card", classNames?.card), children: [
213
+ const resumeDate = chunkBDBZ5OS3_cjs.formatMonthDayLong(resume);
214
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
215
+ headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: headline }),
216
+ body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
217
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-offer-card ck-pause-card", classNames?.card), children: [
217
218
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-pause-eyebrow", children: "We'll see you back on" }),
218
219
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-pause-date", children: resumeDate }),
219
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkEHZJAQQ5_cjs.cn("ck-pause-chips", classNames?.pauseSlider), children: Array.from({ length: max }, (_, i) => i + 1).map((m) => /* @__PURE__ */ jsxRuntime.jsxs(
220
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkBDBZ5OS3_cjs.cn("ck-pause-chips", classNames?.pauseSlider), children: Array.from({ length: max }, (_, i) => i + 1).map((m) => /* @__PURE__ */ jsxRuntime.jsxs(
220
221
  "button",
221
222
  {
222
223
  type: "button",
223
224
  onClick: () => setMonths(m),
224
- className: chunkEHZJAQQ5_cjs.cn("ck-pause-chip", m === months && "ck-pause-chip--selected"),
225
+ className: chunkBDBZ5OS3_cjs.cn("ck-pause-chip", m === months && "ck-pause-chip--selected"),
225
226
  "aria-pressed": m === months,
226
227
  children: [
227
228
  m,
@@ -236,13 +237,13 @@ function DefaultPauseOffer({
236
237
  "button",
237
238
  {
238
239
  type: "button",
239
- className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
240
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
240
241
  onClick: () => onAccept({ months }),
241
242
  disabled: isProcessing,
242
243
  children: isProcessing ? "Processing..." : offer.copy.cta
243
244
  }
244
245
  ),
245
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
246
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
246
247
  ] });
247
248
  }
248
249
  function Checkmark({ color = "currentColor", size = 14 }) {
@@ -251,6 +252,7 @@ function Checkmark({ color = "currentColor", size = 14 }) {
251
252
  function DefaultPlanChangeOffer({
252
253
  title,
253
254
  description,
255
+ subscriptions,
254
256
  offer,
255
257
  onAccept,
256
258
  onDecline,
@@ -259,31 +261,42 @@ function DefaultPlanChangeOffer({
259
261
  }) {
260
262
  const o = offer;
261
263
  const plans = o.plans ?? [];
262
- const [selectedPlanId, setSelectedPlanId] = react.useState(plans[0]?.id ?? null);
264
+ const currentPlanId = subscriptions[0]?.items[0]?.price.id;
265
+ const initialPlanId = plans.find((p) => p.id !== currentPlanId)?.id ?? null;
266
+ const [selectedPlanId, setSelectedPlanId] = react.useState(initialPlanId);
263
267
  const selectedPlan = plans.find((p) => p.id === selectedPlanId) ?? null;
264
268
  const headline = title ?? offer.copy.headline;
265
269
  const body = description ?? offer.copy.body;
266
270
  const ctaLabel = isProcessing ? "Processing..." : selectedPlan?.name ? `Switch to ${selectedPlan.name}` : offer.copy.cta;
267
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
268
- headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: headline }),
269
- body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
270
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-offer-card", classNames?.card), children: [
271
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
272
+ headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: headline }),
273
+ body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
274
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-offer-card", classNames?.card), children: [
271
275
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-offer-details ck-plan-grid", children: plans.map((plan) => {
272
276
  const interval = plan.duration?.interval ?? "month";
273
277
  const currency = plan.amount.currency ?? "USD";
274
278
  const isSelected = plan.id === selectedPlanId;
279
+ const isCurrent = plan.id === currentPlanId;
275
280
  return /* @__PURE__ */ jsxRuntime.jsxs(
276
281
  "button",
277
282
  {
278
283
  type: "button",
279
284
  onClick: () => setSelectedPlanId(plan.id),
280
- className: chunkEHZJAQQ5_cjs.cn("ck-plan-card", isSelected && "ck-plan-card--selected"),
285
+ disabled: isCurrent,
286
+ className: chunkBDBZ5OS3_cjs.cn(
287
+ "ck-plan-card",
288
+ isSelected && "ck-plan-card--selected",
289
+ isCurrent && "ck-plan-card--current"
290
+ ),
281
291
  "aria-pressed": isSelected,
282
292
  children: [
283
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-plan-name", children: plan.name ?? plan.id }),
293
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-plan-name", children: [
294
+ plan.name ?? plan.id,
295
+ isCurrent && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ck-plan-current-badge", children: "Current" })
296
+ ] }),
284
297
  plan.tagline && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-plan-tagline", children: plan.tagline }),
285
298
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-plan-price-row", children: [
286
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ck-plan-amount", children: chunkEHZJAQQ5_cjs.formatPriceFromMinor(plan.amount.value, currency) }),
299
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ck-plan-amount", children: chunkBDBZ5OS3_cjs.formatPriceFromMinor(plan.amount.value, currency) }),
287
300
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ck-plan-period", children: [
288
301
  "/",
289
302
  interval
@@ -303,13 +316,62 @@ function DefaultPlanChangeOffer({
303
316
  "button",
304
317
  {
305
318
  type: "button",
306
- className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
319
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
307
320
  onClick: () => selectedPlanId && onAccept({ planId: selectedPlanId }),
308
321
  disabled: isProcessing || !selectedPlanId,
309
322
  children: ctaLabel
310
323
  }
311
324
  ),
312
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
325
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
326
+ ] })
327
+ ] });
328
+ }
329
+ function DefaultRebateOffer({
330
+ title,
331
+ description,
332
+ offer,
333
+ onAccept,
334
+ onDecline,
335
+ isProcessing,
336
+ classNames
337
+ }) {
338
+ const o = offer;
339
+ const headline = title ?? offer.copy.headline;
340
+ const body = description ?? offer.copy.body;
341
+ const currency = o.currency ?? "usd";
342
+ const amount = o.amountMinor ?? 0;
343
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
344
+ headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: headline }),
345
+ body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
346
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-offer-card", classNames?.card), children: [
347
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-offer-rebate", children: [
348
+ o.amountPaidMinor != null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-offer-rebate-row", children: [
349
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Subscription \xB7 this period" }),
350
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: chunkBDBZ5OS3_cjs.formatPriceFromMinor(o.amountPaidMinor, currency) })
351
+ ] }),
352
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-offer-rebate-row ck-offer-rebate-credit", children: [
353
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Cancellation rebate" }),
354
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
355
+ "\u2212",
356
+ chunkBDBZ5OS3_cjs.formatPriceFromMinor(amount, currency)
357
+ ] })
358
+ ] }),
359
+ o.netAfterRebateMinor != null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-offer-rebate-row ck-offer-rebate-total", children: [
360
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Due for this period" }),
361
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: chunkBDBZ5OS3_cjs.formatPriceFromMinor(o.netAfterRebateMinor, currency) })
362
+ ] })
363
+ ] }),
364
+ /* @__PURE__ */ jsxRuntime.jsx(
365
+ "button",
366
+ {
367
+ type: "button",
368
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
369
+ onClick: () => onAccept(),
370
+ disabled: isProcessing,
371
+ children: isProcessing ? "Processing..." : offer.copy.cta
372
+ }
373
+ ),
374
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
313
375
  ] })
314
376
  ] });
315
377
  }
@@ -317,15 +379,15 @@ function DefaultRedirectOffer({ title, description, offer, onDecline, classNames
317
379
  const url = offer.url;
318
380
  const headline = title ?? offer.copy.headline;
319
381
  const body = description ?? offer.copy.body;
320
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
321
- headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: headline }),
322
- body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
323
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-offer-card", classNames?.card), children: [
382
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
383
+ headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: headline }),
384
+ body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
385
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-offer-card", classNames?.card), children: [
324
386
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-offer-details", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "ck-redirect-link", children: [
325
387
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: offer.copy.cta }),
326
388
  /* @__PURE__ */ jsxRuntime.jsx(ExternalIcon, {})
327
389
  ] }) }),
328
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
390
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
329
391
  ] })
330
392
  ] });
331
393
  }
@@ -365,11 +427,11 @@ function DefaultTrialExtensionOffer({
365
427
  const body = description ?? offer.copy.body;
366
428
  const end = /* @__PURE__ */ new Date();
367
429
  end.setDate(end.getDate() + o.days);
368
- const newEnd = chunkEHZJAQQ5_cjs.formatMonthDay(end);
369
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
370
- headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: headline }),
371
- body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
372
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-offer-card", classNames?.card), children: [
430
+ const newEnd = chunkBDBZ5OS3_cjs.formatMonthDay(end);
431
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-offer", classNames?.root), children: [
432
+ headline && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: headline }),
433
+ body && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: body, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
434
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-offer-card", classNames?.card), children: [
373
435
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-offer-details ck-trial-block", children: [
374
436
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-trial-badge", children: [
375
437
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-trial-days", children: [
@@ -387,13 +449,13 @@ function DefaultTrialExtensionOffer({
387
449
  "button",
388
450
  {
389
451
  type: "button",
390
- className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
452
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.acceptButton),
391
453
  onClick: () => onAccept(),
392
454
  disabled: isProcessing,
393
455
  children: isProcessing ? "Processing..." : offer.copy.cta
394
456
  }
395
457
  ),
396
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
458
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button-link", classNames?.declineButton), onClick: onDecline, children: offer.copy.declineCta })
397
459
  ] })
398
460
  ] });
399
461
  }
@@ -423,16 +485,18 @@ function pickOfferComponent(type, components) {
423
485
  return components?.ContactOffer ?? DefaultContactOffer;
424
486
  case "redirect":
425
487
  return components?.RedirectOffer ?? DefaultRedirectOffer;
488
+ case "rebate":
489
+ return components?.RebateOffer ?? DefaultRebateOffer;
426
490
  default:
427
491
  return null;
428
492
  }
429
493
  }
430
494
  function DefaultSuccess({ title, description, onClose, classNames }) {
431
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-success", classNames?.root), children: [
432
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkEHZJAQQ5_cjs.cn("ck-success-icon", classNames?.icon), children: /* @__PURE__ */ jsxRuntime.jsx(Checkmark, { color: "currentColor", size: 26 }) }),
433
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: title }),
434
- description && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: description, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
435
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-success-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-primary", classNames?.closeButton), onClick: onClose, children: "Done" }) })
495
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-success", classNames?.root), children: [
496
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkBDBZ5OS3_cjs.cn("ck-success-icon", classNames?.icon), children: /* @__PURE__ */ jsxRuntime.jsx(Checkmark, { color: "currentColor", size: 26 }) }),
497
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: title }),
498
+ description && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: description, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
499
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-success-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.closeButton), onClick: onClose, children: "Done" }) })
436
500
  ] });
437
501
  }
438
502
  function DefaultReasonButton({ reason, index, isSelected, onSelect }) {
@@ -443,9 +507,8 @@ function DefaultReasonButton({ reason, index, isSelected, onSelect }) {
443
507
  type: "button",
444
508
  role: "radio",
445
509
  "aria-checked": isSelected,
446
- tabIndex: isSelected ? 0 : -1,
447
510
  onClick: () => onSelect(reason.id),
448
- className: chunkEHZJAQQ5_cjs.cn("ck-reason-button", isSelected && "ck-reason-button--selected"),
511
+ className: chunkBDBZ5OS3_cjs.cn("ck-reason-button", isSelected && "ck-reason-button--selected"),
449
512
  children: [
450
513
  /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "ck-reason-badge", children: isSelected ? /* @__PURE__ */ jsxRuntime.jsx(Checkmark, { color: "#fff", size: 12 }) : letter }),
451
514
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ck-reason-label", children: reason.label })
@@ -459,57 +522,44 @@ function DefaultSurvey({
459
522
  reasons,
460
523
  selectedReason,
461
524
  onSelectReason,
525
+ followupResponse,
526
+ onFollowupResponseChange,
462
527
  onNext,
463
528
  classNames,
464
529
  components
465
530
  }) {
466
531
  const ReasonButton = components?.ReasonButton ?? DefaultReasonButton;
467
- const listRef = react.useRef(null);
468
- const handleKeyDown = react.useCallback(
469
- (e) => {
470
- if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
471
- e.preventDefault();
472
- const currentIdx = reasons.findIndex((r) => r.id === selectedReason);
473
- let nextIdx;
474
- if (e.key === "ArrowDown") {
475
- nextIdx = currentIdx < reasons.length - 1 ? currentIdx + 1 : 0;
476
- } else {
477
- nextIdx = currentIdx > 0 ? currentIdx - 1 : reasons.length - 1;
478
- }
479
- onSelectReason(reasons[nextIdx].id);
480
- const buttons = listRef.current?.querySelectorAll('[role="radio"]');
481
- buttons?.[nextIdx]?.focus();
482
- },
483
- [reasons, selectedReason, onSelectReason]
484
- );
485
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkEHZJAQQ5_cjs.cn("ck-step ck-step-survey", classNames?.root), children: [
486
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkEHZJAQQ5_cjs.cn("ck-step-title", classNames?.title), children: title }),
487
- description && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: description, className: chunkEHZJAQQ5_cjs.cn("ck-step-description", classNames?.description) }),
488
- /* @__PURE__ */ jsxRuntime.jsx(
489
- "div",
532
+ const selected = reasons.find((r) => r.id === selectedReason);
533
+ const showFollowup = selected?.freeform === true;
534
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkBDBZ5OS3_cjs.cn("ck-step ck-step-survey", classNames?.root), children: [
535
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: chunkBDBZ5OS3_cjs.cn("ck-step-title", classNames?.title), children: title }),
536
+ description && /* @__PURE__ */ jsxRuntime.jsx(RichText, { html: description, className: chunkBDBZ5OS3_cjs.cn("ck-step-description", classNames?.description) }),
537
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkBDBZ5OS3_cjs.cn("ck-reason-list", classNames?.reasonList), role: "radiogroup", "aria-label": title, children: reasons.map((reason, i) => /* @__PURE__ */ jsxRuntime.jsx(
538
+ ReasonButton,
490
539
  {
491
- ref: listRef,
492
- className: chunkEHZJAQQ5_cjs.cn("ck-reason-list", classNames?.reasonList),
493
- role: "radiogroup",
494
- "aria-label": title,
495
- onKeyDown: handleKeyDown,
496
- children: reasons.map((reason, i) => /* @__PURE__ */ jsxRuntime.jsx(
497
- ReasonButton,
498
- {
499
- reason,
500
- index: i,
501
- isSelected: selectedReason === reason.id,
502
- onSelect: onSelectReason
503
- },
504
- reason.id
505
- ))
540
+ reason,
541
+ index: i,
542
+ isSelected: selectedReason === reason.id,
543
+ onSelect: onSelectReason
544
+ },
545
+ reason.id
546
+ )) }),
547
+ showFollowup && /* @__PURE__ */ jsxRuntime.jsx(
548
+ "textarea",
549
+ {
550
+ className: chunkBDBZ5OS3_cjs.cn("ck-reason-followup", classNames?.followupInput),
551
+ placeholder: "Tell us more (optional)",
552
+ rows: 3,
553
+ value: followupResponse,
554
+ onChange: (e) => onFollowupResponseChange(e.target.value),
555
+ "aria-label": "Additional detail"
506
556
  }
507
557
  ),
508
558
  /* @__PURE__ */ jsxRuntime.jsx(
509
559
  "button",
510
560
  {
511
561
  type: "button",
512
- className: chunkEHZJAQQ5_cjs.cn("ck-button ck-button-primary", classNames?.continueButton),
562
+ className: chunkBDBZ5OS3_cjs.cn("ck-button ck-button-primary", classNames?.continueButton),
513
563
  onClick: onNext,
514
564
  disabled: !selectedReason,
515
565
  children: "Continue"
@@ -518,7 +568,7 @@ function DefaultSurvey({
518
568
  ] });
519
569
  }
520
570
  function DefaultBackButton({ onBack, className }) {
521
- return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-back-button", className), onClick: onBack, children: [
571
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-back-button", className), onClick: onBack, children: [
522
572
  /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
523
573
  "path",
524
574
  {
@@ -533,7 +583,7 @@ function DefaultBackButton({ onBack, className }) {
533
583
  ] });
534
584
  }
535
585
  function DefaultCloseButton({ onClose, className }) {
536
- return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkEHZJAQQ5_cjs.cn("ck-close-button", className), onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 5L5 15M5 5l10 10", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) });
586
+ return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: chunkBDBZ5OS3_cjs.cn("ck-close-button", className), onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 5L5 15M5 5l10 10", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) });
537
587
  }
538
588
  function trapFocus(container) {
539
589
  const focusableSelector = [
@@ -563,7 +613,7 @@ function trapFocus(container) {
563
613
  container.addEventListener("keydown", handleKeyDown);
564
614
  return () => container.removeEventListener("keydown", handleKeyDown);
565
615
  }
566
- function DefaultModal({ open, onClose, children, className }) {
616
+ function DefaultModal({ open, onClose, children, className, overlayClassName }) {
567
617
  const overlayRef = react.useRef(null);
568
618
  const modalRef = react.useRef(null);
569
619
  const previousFocusRef = react.useRef(null);
@@ -593,7 +643,7 @@ function DefaultModal({ open, onClose, children, className }) {
593
643
  "div",
594
644
  {
595
645
  ref: overlayRef,
596
- className: "ck-overlay",
646
+ className: chunkBDBZ5OS3_cjs.cn("ck-overlay", overlayClassName),
597
647
  onClick: (e) => {
598
648
  if (e.target === overlayRef.current) onClose();
599
649
  },
@@ -605,7 +655,7 @@ function DefaultModal({ open, onClose, children, className }) {
605
655
  "aria-modal": "true",
606
656
  "aria-labelledby": "ck-dialog-title",
607
657
  tabIndex: -1,
608
- className: chunkEHZJAQQ5_cjs.cn("ck-modal", className),
658
+ className: chunkBDBZ5OS3_cjs.cn("ck-modal", className),
609
659
  children
610
660
  }
611
661
  )
@@ -631,7 +681,7 @@ function useColorScheme(preference) {
631
681
  return system;
632
682
  }
633
683
  function CancelFlow(props) {
634
- const { machine, state, isLoading, loadError, retry } = chunkYSNMTOAW_cjs.useCancelFlowMachine(props);
684
+ const { machine, state, isLoading, loadError, retry } = chunk4BMB42WI_cjs.useCancelFlowMachine(props);
635
685
  if (isLoading || loadError) {
636
686
  return /* @__PURE__ */ jsxRuntime.jsx(
637
687
  LoadStatus,
@@ -668,12 +718,12 @@ function LoadStatus({
668
718
  onRetry
669
719
  }) {
670
720
  const scheme = useColorScheme(appearance?.colorScheme);
671
- const appearanceStyle = chunkEHZJAQQ5_cjs.appearanceToStyle(appearance);
721
+ const appearanceStyle = chunkBDBZ5OS3_cjs.appearanceToStyle(appearance);
672
722
  const Modal = components?.Modal ?? DefaultModal;
673
723
  const CloseButton = components?.CloseButton ?? DefaultCloseButton;
674
724
  const handleClose = onClose ?? (() => {
675
725
  });
676
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-cancel-flow", "data-color-scheme": scheme, style: appearanceStyle, children: /* @__PURE__ */ jsxRuntime.jsxs(Modal, { open: true, onClose: handleClose, className: classNames?.modal, children: [
726
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-cancel-flow", "data-color-scheme": scheme, style: appearanceStyle, children: /* @__PURE__ */ jsxRuntime.jsxs(Modal, { open: true, onClose: handleClose, className: classNames?.modal, overlayClassName: classNames?.overlay, children: [
677
727
  /* @__PURE__ */ jsxRuntime.jsx(CloseButton, { onClose: handleClose, className: classNames?.closeButton }),
678
728
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-content", children: [
679
729
  isLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-loading", style: { padding: "32px", textAlign: "center" }, children: [
@@ -721,11 +771,11 @@ function LoadStatus({
721
771
  }
722
772
  function FlowShell({ machine, state, appearance, classNames, components, customComponents }) {
723
773
  const scheme = useColorScheme(appearance?.colorScheme);
724
- const appearanceStyle = chunkEHZJAQQ5_cjs.appearanceToStyle(appearance);
774
+ const appearanceStyle = chunkBDBZ5OS3_cjs.appearanceToStyle(appearance);
725
775
  const Modal = components?.Modal ?? DefaultModal;
726
776
  const CloseButton = components?.CloseButton ?? DefaultCloseButton;
727
777
  const BackButton = components?.BackButton ?? DefaultBackButton;
728
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-cancel-flow", "data-color-scheme": scheme, style: appearanceStyle, children: /* @__PURE__ */ jsxRuntime.jsxs(Modal, { open: true, onClose: machine.close, className: classNames?.modal, children: [
778
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ck-cancel-flow", "data-color-scheme": scheme, style: appearanceStyle, children: /* @__PURE__ */ jsxRuntime.jsxs(Modal, { open: true, onClose: machine.close, className: classNames?.modal, overlayClassName: classNames?.overlay, children: [
729
779
  /* @__PURE__ */ jsxRuntime.jsx(CloseButton, { onClose: machine.close, className: classNames?.closeButton }),
730
780
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ck-content", children: [
731
781
  machine.canGoBack && /* @__PURE__ */ jsxRuntime.jsx(BackButton, { onBack: machine.back, className: classNames?.backButton }),
@@ -748,11 +798,15 @@ function StepRenderer({
748
798
  return /* @__PURE__ */ jsxRuntime.jsx(
749
799
  Survey,
750
800
  {
751
- title: config?.title ?? chunkEHZJAQQ5_cjs.defaultTitles.survey,
801
+ title: config?.title ?? chunkBDBZ5OS3_cjs.defaultTitles.survey,
752
802
  description: config?.description,
803
+ customer: state.customer,
804
+ subscriptions: state.subscriptions,
753
805
  reasons: machine.reasons,
754
806
  selectedReason: state.selectedReason,
755
807
  onSelectReason: machine.selectReason,
808
+ followupResponse: state.followupResponse,
809
+ onFollowupResponseChange: machine.setFollowupResponse,
756
810
  onNext: machine.next,
757
811
  classNames: config?.classNames,
758
812
  components
@@ -769,12 +823,16 @@ function StepRenderer({
769
823
  {
770
824
  offer,
771
825
  customer: state.customer,
826
+ subscriptions: state.subscriptions,
772
827
  onAccept: machine.accept,
773
828
  onDecline: machine.decline,
774
829
  isProcessing: state.isProcessing
775
830
  }
776
831
  );
777
832
  }
833
+ if (!chunkBDBZ5OS3_cjs.BUILT_IN_OFFER_TYPES.includes(offer.type)) {
834
+ return /* @__PURE__ */ jsxRuntime.jsx(UnregisteredOfferFallback, { offerType: offer.type, onSkip: machine.decline });
835
+ }
778
836
  const Offer = components?.Offer ?? DefaultOffer;
779
837
  const config = stepConfig;
780
838
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -782,6 +840,8 @@ function StepRenderer({
782
840
  {
783
841
  title: config?.title,
784
842
  description: config?.description,
843
+ customer: state.customer,
844
+ subscriptions: state.subscriptions,
785
845
  offer,
786
846
  onAccept: machine.accept,
787
847
  onDecline: machine.decline,
@@ -797,8 +857,10 @@ function StepRenderer({
797
857
  return /* @__PURE__ */ jsxRuntime.jsx(
798
858
  Feedback,
799
859
  {
800
- title: config?.title ?? chunkEHZJAQQ5_cjs.defaultTitles.feedback,
860
+ title: config?.title ?? chunkBDBZ5OS3_cjs.defaultTitles.feedback,
801
861
  description: config?.description,
862
+ customer: state.customer,
863
+ subscriptions: state.subscriptions,
802
864
  placeholder: config?.placeholder,
803
865
  required: config?.required ?? false,
804
866
  minLength: config?.minLength ?? 0,
@@ -815,8 +877,10 @@ function StepRenderer({
815
877
  return /* @__PURE__ */ jsxRuntime.jsx(
816
878
  Confirm,
817
879
  {
818
- title: config?.title ?? chunkEHZJAQQ5_cjs.defaultTitles.confirm,
880
+ title: config?.title ?? chunkBDBZ5OS3_cjs.defaultTitles.confirm,
819
881
  description: config?.description,
882
+ customer: state.customer,
883
+ subscriptions: state.subscriptions,
820
884
  losses: config?.losses,
821
885
  lossesLabel: config?.lossesLabel,
822
886
  confirmLabel: config?.confirmLabel ?? "Cancel subscription",
@@ -839,6 +903,8 @@ function StepRenderer({
839
903
  offer: machine.currentOffer ?? void 0,
840
904
  title: isSaved ? config?.savedTitle ?? "Welcome back!" : config?.cancelledTitle ?? "Subscription cancelled",
841
905
  description: isSaved ? config?.savedDescription ?? "Your offer has been applied." : config?.cancelledDescription ?? "We're sorry to see you go.",
906
+ customer: state.customer,
907
+ subscriptions: state.subscriptions,
842
908
  onClose: machine.close,
843
909
  classNames: config?.classNames
844
910
  }
@@ -860,6 +926,7 @@ function StepRenderer({
860
926
  data: config?.data
861
927
  },
862
928
  customer: state.customer,
929
+ subscriptions: state.subscriptions,
863
930
  onNext: machine.next,
864
931
  onBack: machine.back
865
932
  }
@@ -874,50 +941,65 @@ function UnregisteredStepFallback({ step, onSkip }) {
874
941
  }, [step, onSkip]);
875
942
  return null;
876
943
  }
944
+ function UnregisteredOfferFallback({ offerType, onSkip }) {
945
+ react.useEffect(() => {
946
+ console.warn(`[churnkey] No component registered for offer type "${offerType}". Skipping.`);
947
+ onSkip();
948
+ }, [offerType, onSkip]);
949
+ return null;
950
+ }
877
951
 
878
952
  Object.defineProperty(exports, "useCancelFlow", {
879
953
  enumerable: true,
880
- get: function () { return chunkYSNMTOAW_cjs.useCancelFlow; }
954
+ get: function () { return chunk4BMB42WI_cjs.useCancelFlow; }
955
+ });
956
+ Object.defineProperty(exports, "BUILT_IN_OFFER_TYPES", {
957
+ enumerable: true,
958
+ get: function () { return chunkBDBZ5OS3_cjs.BUILT_IN_OFFER_TYPES; }
881
959
  });
882
960
  Object.defineProperty(exports, "BUILT_IN_STEP_TYPES", {
883
961
  enumerable: true,
884
- get: function () { return chunkEHZJAQQ5_cjs.BUILT_IN_STEP_TYPES; }
962
+ get: function () { return chunkBDBZ5OS3_cjs.BUILT_IN_STEP_TYPES; }
885
963
  });
886
964
  Object.defineProperty(exports, "appearanceToStyle", {
887
965
  enumerable: true,
888
- get: function () { return chunkEHZJAQQ5_cjs.appearanceToStyle; }
966
+ get: function () { return chunkBDBZ5OS3_cjs.appearanceToStyle; }
889
967
  });
890
968
  Object.defineProperty(exports, "calculateDiscountedPrice", {
891
969
  enumerable: true,
892
- get: function () { return chunkEHZJAQQ5_cjs.calculateDiscountedPrice; }
970
+ get: function () { return chunkBDBZ5OS3_cjs.calculateDiscountedPrice; }
893
971
  });
894
972
  Object.defineProperty(exports, "cn", {
895
973
  enumerable: true,
896
- get: function () { return chunkEHZJAQQ5_cjs.cn; }
974
+ get: function () { return chunkBDBZ5OS3_cjs.cn; }
897
975
  });
898
976
  Object.defineProperty(exports, "defaultTitles", {
899
977
  enumerable: true,
900
- get: function () { return chunkEHZJAQQ5_cjs.defaultTitles; }
978
+ get: function () { return chunkBDBZ5OS3_cjs.defaultTitles; }
979
+ });
980
+ Object.defineProperty(exports, "formatPeriodEnd", {
981
+ enumerable: true,
982
+ get: function () { return chunkBDBZ5OS3_cjs.formatPeriodEnd; }
901
983
  });
902
984
  Object.defineProperty(exports, "formatPrice", {
903
985
  enumerable: true,
904
- get: function () { return chunkEHZJAQQ5_cjs.formatPrice; }
986
+ get: function () { return chunkBDBZ5OS3_cjs.formatPrice; }
905
987
  });
906
988
  Object.defineProperty(exports, "AnalyticsClient", {
907
989
  enumerable: true,
908
- get: function () { return chunkZEYUKGAR_cjs.AnalyticsClient; }
990
+ get: function () { return chunkSNTKIKHU_cjs.AnalyticsClient; }
909
991
  });
910
992
  Object.defineProperty(exports, "CancelFlowMachine", {
911
993
  enumerable: true,
912
- get: function () { return chunkZEYUKGAR_cjs.CancelFlowMachine; }
994
+ get: function () { return chunkSNTKIKHU_cjs.CancelFlowMachine; }
913
995
  });
914
996
  Object.defineProperty(exports, "ChurnkeyApi", {
915
997
  enumerable: true,
916
- get: function () { return chunkZEYUKGAR_cjs.ChurnkeyApi; }
998
+ get: function () { return chunkSNTKIKHU_cjs.ChurnkeyApi; }
917
999
  });
918
1000
  Object.defineProperty(exports, "decodeSessionToken", {
919
1001
  enumerable: true,
920
- get: function () { return chunkZEYUKGAR_cjs.decodeSessionToken; }
1002
+ get: function () { return chunkSNTKIKHU_cjs.decodeSessionToken; }
921
1003
  });
922
1004
  exports.CancelFlow = CancelFlow;
923
1005
  exports.DefaultBackButton = DefaultBackButton;
@@ -931,6 +1013,7 @@ exports.DefaultOffer = DefaultOffer;
931
1013
  exports.DefaultPauseOffer = DefaultPauseOffer;
932
1014
  exports.DefaultPlanChangeOffer = DefaultPlanChangeOffer;
933
1015
  exports.DefaultReasonButton = DefaultReasonButton;
1016
+ exports.DefaultRebateOffer = DefaultRebateOffer;
934
1017
  exports.DefaultRedirectOffer = DefaultRedirectOffer;
935
1018
  exports.DefaultSuccess = DefaultSuccess;
936
1019
  exports.DefaultSurvey = DefaultSurvey;