@cimplify/sdk 0.46.0 → 0.46.2

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 (65) hide show
  1. package/dist/advanced.d.mts +3 -3
  2. package/dist/advanced.d.ts +3 -3
  3. package/dist/advanced.js +22 -22
  4. package/dist/advanced.mjs +3 -3
  5. package/dist/{chunk-RQ3ILHUQ.mjs → chunk-632JEJUS.mjs} +1 -1
  6. package/dist/{chunk-IF22UYTT.mjs → chunk-6HYKWYUF.mjs} +2 -2
  7. package/dist/{chunk-BN2CXGMO.js → chunk-6RP6OPYO.js} +3 -3
  8. package/dist/{chunk-GVLWRI5I.js → chunk-7ZACMER7.js} +49 -25
  9. package/dist/{chunk-AIXUFSA6.mjs → chunk-CKRMA5F7.mjs} +29 -5
  10. package/dist/{chunk-K6FCVLZA.js → chunk-GEWFWQYK.js} +234 -234
  11. package/dist/{chunk-QBQCMQ4F.js → chunk-TKOTACKZ.js} +24 -2
  12. package/dist/{chunk-ZH6ZST5T.js → chunk-TW4OFRWV.js} +4 -4
  13. package/dist/{chunk-RR3ZJQW5.mjs → chunk-WUIERJ6J.mjs} +4 -4
  14. package/dist/{chunk-NRT6PVW5.mjs → chunk-XY2DFX5K.mjs} +1 -1
  15. package/dist/{chunk-XPXAZXF2.mjs → chunk-Z2AYLZDF.mjs} +23 -3
  16. package/dist/{chunk-LLZZMHSU.js → chunk-Z2MLAIID.js} +62 -62
  17. package/dist/{client-BDYBB-ME.d.ts → client-B76ZNW5r.d.ts} +2 -2
  18. package/dist/{client-MUD63aYS.d.mts → client-CT9NwIDX.d.mts} +2 -2
  19. package/dist/{client-aZInadOY.d.ts → client-G2WCoxv2.d.mts} +5 -2
  20. package/dist/{client-CDUY-6nC.d.mts → client-QVINYu1X.d.ts} +5 -2
  21. package/dist/{index-DC_ZcSgO.d.ts → index-BAohYhdg.d.ts} +3 -3
  22. package/dist/{index-3C9J8Wb-.d.mts → index-Bo0NjgR6.d.mts} +3 -3
  23. package/dist/index.d.mts +6 -6
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.js +115 -107
  26. package/dist/index.mjs +4 -4
  27. package/dist/mock/cli.mjs +2 -0
  28. package/dist/mock/library.js +2 -0
  29. package/dist/mock/library.mjs +2 -0
  30. package/dist/mock/msw.js +2 -0
  31. package/dist/mock/msw.mjs +2 -0
  32. package/dist/{payment-Bse2XJ-c.d.mts → payment-9L_-GWqQ.d.mts} +1 -1
  33. package/dist/{payment-JcNqOf_T.d.ts → payment-_e99nSRj.d.ts} +1 -1
  34. package/dist/{price-YBGk5seG.d.mts → price-BjehlIhG.d.mts} +1 -1
  35. package/dist/{price-mHkRncgW.d.ts → price-CWQ5TQmk.d.ts} +1 -1
  36. package/dist/{product-DiX-HGkT.d.ts → product-C-xLzh7Q.d.mts} +16 -1
  37. package/dist/{product-DiX-HGkT.d.mts → product-C-xLzh7Q.d.ts} +16 -1
  38. package/dist/react.d.mts +4 -4
  39. package/dist/react.d.ts +4 -4
  40. package/dist/react.js +85 -85
  41. package/dist/react.mjs +4 -4
  42. package/dist/{server-Bg3VtA1D.d.ts → server-72rzvJ4Y.d.ts} +1 -1
  43. package/dist/{server-kakjHRgj.d.mts → server-BgccqOLT.d.mts} +1 -1
  44. package/dist/server.d.mts +4 -4
  45. package/dist/server.d.ts +4 -4
  46. package/dist/server.js +6 -6
  47. package/dist/server.mjs +4 -4
  48. package/dist/styles.css +1 -1
  49. package/dist/testing/msw.d.mts +2 -2
  50. package/dist/testing/msw.d.ts +2 -2
  51. package/dist/testing/msw.js +3 -3
  52. package/dist/testing/msw.mjs +2 -2
  53. package/dist/testing/suite.d.mts +6 -6
  54. package/dist/testing/suite.d.ts +6 -6
  55. package/dist/testing/suite.js +25 -25
  56. package/dist/testing/suite.mjs +6 -6
  57. package/dist/testing.d.mts +5 -5
  58. package/dist/testing.d.ts +5 -5
  59. package/dist/testing.js +81 -81
  60. package/dist/testing.mjs +7 -7
  61. package/dist/utils.d.mts +4 -4
  62. package/dist/utils.d.ts +4 -4
  63. package/dist/utils.js +29 -29
  64. package/dist/utils.mjs +2 -2
  65. package/package.json +1 -1
@@ -115,6 +115,8 @@ var ErrorCode = {
115
115
  QUOTE_EXPIRED: "QUOTE_EXPIRED",
116
116
  QUOTE_CONSUMED: "QUOTE_CONSUMED",
117
117
  QUOTE_STORAGE_UNAVAILABLE: "QUOTE_STORAGE_UNAVAILABLE",
118
+ QUOTE_VALIDATION_FAILED: "QUOTE_VALIDATION_FAILED",
119
+ PRICE_CHANGED: "PRICE_CHANGED",
118
120
  PAYMENT_FAILED: "PAYMENT_FAILED",
119
121
  PAYMENT_CANCELLED: "PAYMENT_CANCELLED",
120
122
  INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS",
@@ -156,6 +158,8 @@ var ERROR_SUGGESTIONS = {
156
158
  QUOTE_EXPIRED: "Quote has expired. Re-fetch pricing to generate a new quote with a valid expiry window.",
157
159
  QUOTE_CONSUMED: "Quote has already been used. Request a fresh quote to prevent duplicate checkout attempts.",
158
160
  QUOTE_STORAGE_UNAVAILABLE: "Quote storage is temporarily unavailable. Retry shortly and avoid charging until quote fetch succeeds.",
161
+ QUOTE_VALIDATION_FAILED: "Cart contents diverged from the locked quote (different items, options, or quantity). Refresh quotes for the affected lines and resubmit.",
162
+ PRICE_CHANGED: "Prices changed since the quote was created. Refresh pricing, show the new total to the shopper, and require explicit confirmation before re-submitting.",
159
163
  PAYMENT_FAILED: "Payment provider rejected or failed processing. Show retry/change-method options to the shopper.",
160
164
  PAYMENT_CANCELLED: "Payment was cancelled by the shopper or provider flow. Allow a safe retry path.",
161
165
  INSUFFICIENT_FUNDS: "Payment method has insufficient funds. Prompt shopper to use another method.",
@@ -215,6 +219,22 @@ var IdempotencyMismatchError = class extends CimplifyError {
215
219
  function isCimplifyError(error) {
216
220
  return error instanceof CimplifyError;
217
221
  }
222
+ var QUOTE_ERROR_CODES = /* @__PURE__ */ new Set([
223
+ ErrorCode.QUOTE_NOT_FOUND,
224
+ ErrorCode.QUOTE_EXPIRED,
225
+ ErrorCode.QUOTE_CONSUMED,
226
+ ErrorCode.QUOTE_STORAGE_UNAVAILABLE,
227
+ ErrorCode.QUOTE_VALIDATION_FAILED,
228
+ ErrorCode.PRICE_CHANGED
229
+ ]);
230
+ function isQuoteError(error) {
231
+ if (!isCimplifyError(error)) return false;
232
+ return QUOTE_ERROR_CODES.has(error.code);
233
+ }
234
+ function isQuoteConflictRequiringConsent(error) {
235
+ if (!isCimplifyError(error)) return false;
236
+ return error.code === ErrorCode.PRICE_CHANGED || error.code === ErrorCode.QUOTE_VALIDATION_FAILED;
237
+ }
218
238
  function isIdempotencyMismatchError(error) {
219
239
  return error instanceof IdempotencyMismatchError;
220
240
  }
@@ -229,10 +249,10 @@ function enrichError(error, options = {}) {
229
249
  const docsUrl = error.docs_url || hint?.docs_url || docsUrlForCode(error.code || ErrorCode.UNKNOWN_ERROR);
230
250
  const suggestion = error.suggestion || hint?.suggestion;
231
251
  let message = error.message;
232
- if (options.isTestMode && !message.includes("pk_test_")) {
252
+ if (options.isTestMode && !message.includes("cpk_test_")) {
233
253
  message = `${message}
234
254
 
235
- \u2139 Your API key is a test-mode key (pk_test_...). Verify test data/session before retrying.`;
255
+ \u2139 Your API key is a test-mode key (cpk_test_...). Verify test data/session before retrying.`;
236
256
  }
237
257
  const enriched = new CimplifyError(error.code, message, error.retryable, docsUrl, suggestion);
238
258
  enriched.stack = error.stack;
@@ -265,6 +285,8 @@ exports.enrichError = enrichError;
265
285
  exports.getErrorHint = getErrorHint;
266
286
  exports.isCimplifyError = isCimplifyError;
267
287
  exports.isIdempotencyMismatchError = isIdempotencyMismatchError;
288
+ exports.isQuoteConflictRequiringConsent = isQuoteConflictRequiringConsent;
289
+ exports.isQuoteError = isQuoteError;
268
290
  exports.isRetryableError = isRetryableError;
269
291
  exports.isSupportedCurrency = isSupportedCurrency;
270
292
  exports.money = money;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkLLZZMHSU_js = require('./chunk-LLZZMHSU.js');
4
- var chunkK6FCVLZA_js = require('./chunk-K6FCVLZA.js');
3
+ var chunkZ2MLAIID_js = require('./chunk-Z2MLAIID.js');
4
+ var chunkGEWFWQYK_js = require('./chunk-GEWFWQYK.js');
5
5
  var zod = require('zod');
6
6
 
7
7
  var cimplifyRegistry = zod.z.registry();
@@ -595,7 +595,7 @@ async function toForwardedRequest(input, init) {
595
595
  };
596
596
  }
597
597
  function createTestClient(options = {}) {
598
- const mock = chunkK6FCVLZA_js.createMockApp(options);
598
+ const mock = chunkGEWFWQYK_js.createMockApp(options);
599
599
  let sessionToken;
600
600
  const fetchImpl = async (input, init) => {
601
601
  const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
@@ -614,7 +614,7 @@ function createTestClient(options = {}) {
614
614
  if (echoed) sessionToken = echoed;
615
615
  return res;
616
616
  };
617
- const client = chunkLLZZMHSU_js.createCimplifyClient({
617
+ const client = chunkZ2MLAIID_js.createCimplifyClient({
618
618
  baseUrl: TEST_BASE_URL,
619
619
  // Link mock lives at /v1/link on the same Hono app, so point the SDK's
620
620
  // separate Link transport at the same TEST_BASE_URL.
@@ -1,5 +1,5 @@
1
- import { safe, generateIdempotencyKey, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-AIXUFSA6.mjs';
2
- import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-XPXAZXF2.mjs';
1
+ import { safe, generateIdempotencyKey, CatalogueQueries, CartOperations, CheckoutService, OrderQueries, LinkService, AuthService, BusinessService, InventoryService, SchedulingService, LiteService, FxService, createElements } from './chunk-CKRMA5F7.mjs';
2
+ import { CimplifyError, ErrorCode, IdempotencyMismatchError, enrichError } from './chunk-Z2AYLZDF.mjs';
3
3
 
4
4
  // src/activity.ts
5
5
  var ActivityService = class {
@@ -396,7 +396,7 @@ var CimplifyClient = class {
396
396
  this.sessionToken = this.loadSessionToken();
397
397
  if (!this.publicKey && !config.suppressPublicKeyWarning) {
398
398
  console.warn(
399
- '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "pk_..." } to createCimplifyClient().'
399
+ '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "cpk_..." } to createCimplifyClient().'
400
400
  );
401
401
  }
402
402
  }
@@ -414,7 +414,7 @@ var CimplifyClient = class {
414
414
  return this.publicKey;
415
415
  }
416
416
  isTestMode() {
417
- return this.publicKey.trim().startsWith("pk_test_");
417
+ return this.publicKey.trim().startsWith("cpk_test_");
418
418
  }
419
419
  setAccessToken(token) {
420
420
  const previous = this.accessToken;
@@ -1,4 +1,4 @@
1
- import { moneyFromNumber, money } from './chunk-XPXAZXF2.mjs';
1
+ import { moneyFromNumber, money } from './chunk-Z2AYLZDF.mjs';
2
2
 
3
3
  // src/utils/price.ts
4
4
  var CURRENCY_SYMBOLS = {
@@ -113,6 +113,8 @@ var ErrorCode = {
113
113
  QUOTE_EXPIRED: "QUOTE_EXPIRED",
114
114
  QUOTE_CONSUMED: "QUOTE_CONSUMED",
115
115
  QUOTE_STORAGE_UNAVAILABLE: "QUOTE_STORAGE_UNAVAILABLE",
116
+ QUOTE_VALIDATION_FAILED: "QUOTE_VALIDATION_FAILED",
117
+ PRICE_CHANGED: "PRICE_CHANGED",
116
118
  PAYMENT_FAILED: "PAYMENT_FAILED",
117
119
  PAYMENT_CANCELLED: "PAYMENT_CANCELLED",
118
120
  INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS",
@@ -154,6 +156,8 @@ var ERROR_SUGGESTIONS = {
154
156
  QUOTE_EXPIRED: "Quote has expired. Re-fetch pricing to generate a new quote with a valid expiry window.",
155
157
  QUOTE_CONSUMED: "Quote has already been used. Request a fresh quote to prevent duplicate checkout attempts.",
156
158
  QUOTE_STORAGE_UNAVAILABLE: "Quote storage is temporarily unavailable. Retry shortly and avoid charging until quote fetch succeeds.",
159
+ QUOTE_VALIDATION_FAILED: "Cart contents diverged from the locked quote (different items, options, or quantity). Refresh quotes for the affected lines and resubmit.",
160
+ PRICE_CHANGED: "Prices changed since the quote was created. Refresh pricing, show the new total to the shopper, and require explicit confirmation before re-submitting.",
157
161
  PAYMENT_FAILED: "Payment provider rejected or failed processing. Show retry/change-method options to the shopper.",
158
162
  PAYMENT_CANCELLED: "Payment was cancelled by the shopper or provider flow. Allow a safe retry path.",
159
163
  INSUFFICIENT_FUNDS: "Payment method has insufficient funds. Prompt shopper to use another method.",
@@ -213,6 +217,22 @@ var IdempotencyMismatchError = class extends CimplifyError {
213
217
  function isCimplifyError(error) {
214
218
  return error instanceof CimplifyError;
215
219
  }
220
+ var QUOTE_ERROR_CODES = /* @__PURE__ */ new Set([
221
+ ErrorCode.QUOTE_NOT_FOUND,
222
+ ErrorCode.QUOTE_EXPIRED,
223
+ ErrorCode.QUOTE_CONSUMED,
224
+ ErrorCode.QUOTE_STORAGE_UNAVAILABLE,
225
+ ErrorCode.QUOTE_VALIDATION_FAILED,
226
+ ErrorCode.PRICE_CHANGED
227
+ ]);
228
+ function isQuoteError(error) {
229
+ if (!isCimplifyError(error)) return false;
230
+ return QUOTE_ERROR_CODES.has(error.code);
231
+ }
232
+ function isQuoteConflictRequiringConsent(error) {
233
+ if (!isCimplifyError(error)) return false;
234
+ return error.code === ErrorCode.PRICE_CHANGED || error.code === ErrorCode.QUOTE_VALIDATION_FAILED;
235
+ }
216
236
  function isIdempotencyMismatchError(error) {
217
237
  return error instanceof IdempotencyMismatchError;
218
238
  }
@@ -227,10 +247,10 @@ function enrichError(error, options = {}) {
227
247
  const docsUrl = error.docs_url || hint?.docs_url || docsUrlForCode(error.code || ErrorCode.UNKNOWN_ERROR);
228
248
  const suggestion = error.suggestion || hint?.suggestion;
229
249
  let message = error.message;
230
- if (options.isTestMode && !message.includes("pk_test_")) {
250
+ if (options.isTestMode && !message.includes("cpk_test_")) {
231
251
  message = `${message}
232
252
 
233
- \u2139 Your API key is a test-mode key (pk_test_...). Verify test data/session before retrying.`;
253
+ \u2139 Your API key is a test-mode key (cpk_test_...). Verify test data/session before retrying.`;
234
254
  }
235
255
  const enriched = new CimplifyError(error.code, message, error.retryable, docsUrl, suggestion);
236
256
  enriched.stack = error.stack;
@@ -247,4 +267,4 @@ function isRetryableError(error) {
247
267
  return false;
248
268
  }
249
269
 
250
- export { CimplifyError, ERROR_HINTS, ErrorCode, IdempotencyMismatchError, ZERO, __privateAdd, __privateGet, __privateMethod, __privateSet, __privateWrapper, __publicField, currencyCode, enrichError, getErrorHint, isCimplifyError, isIdempotencyMismatchError, isRetryableError, isSupportedCurrency, money, moneyFromNumber };
270
+ export { CimplifyError, ERROR_HINTS, ErrorCode, IdempotencyMismatchError, ZERO, __privateAdd, __privateGet, __privateMethod, __privateSet, __privateWrapper, __publicField, currencyCode, enrichError, getErrorHint, isCimplifyError, isIdempotencyMismatchError, isQuoteConflictRequiringConsent, isQuoteError, isRetryableError, isSupportedCurrency, money, moneyFromNumber };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkGVLWRI5I_js = require('./chunk-GVLWRI5I.js');
4
- var chunkQBQCMQ4F_js = require('./chunk-QBQCMQ4F.js');
3
+ var chunk7ZACMER7_js = require('./chunk-7ZACMER7.js');
4
+ var chunkTKOTACKZ_js = require('./chunk-TKOTACKZ.js');
5
5
 
6
6
  // src/activity.ts
7
7
  var ActivityService = class {
@@ -29,7 +29,7 @@ var ActivityService = class {
29
29
  this.sendEvents([event]);
30
30
  }
31
31
  async getState() {
32
- return chunkGVLWRI5I_js.safe(this.client.get("/api/v1/activity/state"));
32
+ return chunk7ZACMER7_js.safe(this.client.get("/api/v1/activity/state"));
33
33
  }
34
34
  async getRecommendations(options) {
35
35
  const params = new URLSearchParams();
@@ -37,10 +37,10 @@ var ActivityService = class {
37
37
  if (options?.limit) params.set("limit", String(options.limit));
38
38
  const query = params.toString();
39
39
  const path = query ? `/api/v1/activity/recommendations?${query}` : "/api/v1/activity/recommendations";
40
- return chunkGVLWRI5I_js.safe(this.client.get(path));
40
+ return chunk7ZACMER7_js.safe(this.client.get(path));
41
41
  }
42
42
  async dismissMessage(code) {
43
- return chunkGVLWRI5I_js.safe(
43
+ return chunk7ZACMER7_js.safe(
44
44
  this.client.post("/api/v1/activity/messages/dismiss", { code })
45
45
  );
46
46
  }
@@ -62,16 +62,16 @@ var SubscriptionService = class {
62
62
  this.client = client;
63
63
  }
64
64
  async list() {
65
- return chunkGVLWRI5I_js.safe(this.client.get("/api/v1/subscriptions"));
65
+ return chunk7ZACMER7_js.safe(this.client.get("/api/v1/subscriptions"));
66
66
  }
67
67
  async get(id) {
68
68
  const encodedId = encodeURIComponent(id);
69
- return chunkGVLWRI5I_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
69
+ return chunk7ZACMER7_js.safe(this.client.get(`/api/v1/subscriptions/${encodedId}`));
70
70
  }
71
71
  async cancel(id, reason, opts) {
72
72
  const encodedId = encodeURIComponent(id);
73
- const idempotencyKey = opts?.idempotencyKey ?? chunkGVLWRI5I_js.generateIdempotencyKey();
74
- return chunkGVLWRI5I_js.safe(
73
+ const idempotencyKey = opts?.idempotencyKey ?? chunk7ZACMER7_js.generateIdempotencyKey();
74
+ return chunk7ZACMER7_js.safe(
75
75
  this.client.post(
76
76
  `/api/v1/subscriptions/${encodedId}/cancel`,
77
77
  { reason },
@@ -81,20 +81,20 @@ var SubscriptionService = class {
81
81
  }
82
82
  async pause(id) {
83
83
  const encodedId = encodeURIComponent(id);
84
- return chunkGVLWRI5I_js.safe(
84
+ return chunk7ZACMER7_js.safe(
85
85
  this.client.post(`/api/v1/subscriptions/${encodedId}/pause`)
86
86
  );
87
87
  }
88
88
  async resume(id) {
89
89
  const encodedId = encodeURIComponent(id);
90
- return chunkGVLWRI5I_js.safe(
90
+ return chunk7ZACMER7_js.safe(
91
91
  this.client.post(`/api/v1/subscriptions/${encodedId}/resume`)
92
92
  );
93
93
  }
94
94
  async skipNextRenewal(id, opts) {
95
95
  const encodedId = encodeURIComponent(id);
96
- const idempotencyKey = opts?.idempotencyKey ?? chunkGVLWRI5I_js.generateIdempotencyKey();
97
- return chunkGVLWRI5I_js.safe(
96
+ const idempotencyKey = opts?.idempotencyKey ?? chunk7ZACMER7_js.generateIdempotencyKey();
97
+ return chunk7ZACMER7_js.safe(
98
98
  this.client.post(
99
99
  `/api/v1/subscriptions/${encodedId}/skip`,
100
100
  void 0,
@@ -110,8 +110,8 @@ var UploadService = class {
110
110
  this.client = client;
111
111
  }
112
112
  async init(filename, contentType, sizeBytes, opts) {
113
- const idempotencyKey = opts?.idempotencyKey ?? chunkGVLWRI5I_js.generateIdempotencyKey();
114
- return chunkGVLWRI5I_js.safe(
113
+ const idempotencyKey = opts?.idempotencyKey ?? chunk7ZACMER7_js.generateIdempotencyKey();
114
+ return chunk7ZACMER7_js.safe(
115
115
  this.client.post(
116
116
  "/api/v1/uploads/init",
117
117
  {
@@ -124,7 +124,7 @@ var UploadService = class {
124
124
  );
125
125
  }
126
126
  async confirm(uploadId) {
127
- return chunkGVLWRI5I_js.safe(
127
+ return chunk7ZACMER7_js.safe(
128
128
  this.client.post("/api/v1/uploads/confirm", {
129
129
  upload_id: uploadId
130
130
  })
@@ -143,7 +143,7 @@ var UploadService = class {
143
143
  if (!uploadResponse.ok) {
144
144
  return {
145
145
  ok: false,
146
- error: new chunkQBQCMQ4F_js.CimplifyError(
146
+ error: new chunkTKOTACKZ_js.CimplifyError(
147
147
  "UPLOAD_FAILED",
148
148
  `Upload failed with status ${uploadResponse.status}`,
149
149
  true
@@ -153,7 +153,7 @@ var UploadService = class {
153
153
  } catch (error) {
154
154
  return {
155
155
  ok: false,
156
- error: new chunkQBQCMQ4F_js.CimplifyError(
156
+ error: new chunkTKOTACKZ_js.CimplifyError(
157
157
  "UPLOAD_FAILED",
158
158
  error instanceof Error ? error.message : "Upload failed",
159
159
  true
@@ -170,7 +170,7 @@ var PlacesService = class {
170
170
  this.client = client;
171
171
  }
172
172
  async autocomplete(input, sessionToken) {
173
- return chunkGVLWRI5I_js.safe(
173
+ return chunk7ZACMER7_js.safe(
174
174
  this.client.post("/api/v1/places/autocomplete", {
175
175
  input,
176
176
  sessionToken
@@ -178,7 +178,7 @@ var PlacesService = class {
178
178
  );
179
179
  }
180
180
  async details(placeId, sessionToken) {
181
- return chunkGVLWRI5I_js.safe(
181
+ return chunk7ZACMER7_js.safe(
182
182
  this.client.post("/api/v1/places/details", {
183
183
  place_id: placeId,
184
184
  sessionToken
@@ -197,7 +197,7 @@ var DeliveryService = class {
197
197
  params.set("dropoff_lat", String(dropoffLat));
198
198
  params.set("dropoff_lng", String(dropoffLng));
199
199
  if (country) params.set("country", country);
200
- return chunkGVLWRI5I_js.safe(
200
+ return chunk7ZACMER7_js.safe(
201
201
  this.client.get(`/api/v1/delivery/fee?${params.toString()}`)
202
202
  );
203
203
  }
@@ -210,8 +210,8 @@ var SupportService = class {
210
210
  }
211
211
  /** Open (or resume) the customer's widget conversation. */
212
212
  async openConversation(opts) {
213
- const idempotencyKey = opts?.idempotencyKey ?? chunkGVLWRI5I_js.generateIdempotencyKey();
214
- return chunkGVLWRI5I_js.safe(
213
+ const idempotencyKey = opts?.idempotencyKey ?? chunk7ZACMER7_js.generateIdempotencyKey();
214
+ return chunk7ZACMER7_js.safe(
215
215
  this.client.post("/api/v1/support/conversation", void 0, {
216
216
  idempotencyKey
217
217
  })
@@ -219,8 +219,8 @@ var SupportService = class {
219
219
  }
220
220
  /** Send a message in the active conversation. */
221
221
  async sendMessage(content, opts) {
222
- const idempotencyKey = opts?.idempotencyKey ?? chunkGVLWRI5I_js.generateIdempotencyKey();
223
- return chunkGVLWRI5I_js.safe(
222
+ const idempotencyKey = opts?.idempotencyKey ?? chunk7ZACMER7_js.generateIdempotencyKey();
223
+ return chunk7ZACMER7_js.safe(
224
224
  this.client.post(
225
225
  "/api/v1/support/conversation/messages",
226
226
  { content },
@@ -235,7 +235,7 @@ var SupportService = class {
235
235
  if (options.limit) params.set("limit", String(options.limit));
236
236
  const query = params.toString();
237
237
  const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
238
- return chunkGVLWRI5I_js.safe(this.client.get(path));
238
+ return chunk7ZACMER7_js.safe(this.client.get(path));
239
239
  }
240
240
  };
241
241
 
@@ -304,16 +304,16 @@ function isRetryable(error) {
304
304
  if (error instanceof DOMException && error.name === "AbortError") {
305
305
  return true;
306
306
  }
307
- if (error instanceof chunkQBQCMQ4F_js.CimplifyError) {
307
+ if (error instanceof chunkTKOTACKZ_js.CimplifyError) {
308
308
  return error.retryable;
309
309
  }
310
310
  return false;
311
311
  }
312
312
  function toNetworkError(error, isTestMode) {
313
313
  if (error instanceof DOMException && error.name === "AbortError") {
314
- return chunkQBQCMQ4F_js.enrichError(
315
- new chunkQBQCMQ4F_js.CimplifyError(
316
- chunkQBQCMQ4F_js.ErrorCode.TIMEOUT,
314
+ return chunkTKOTACKZ_js.enrichError(
315
+ new chunkTKOTACKZ_js.CimplifyError(
316
+ chunkTKOTACKZ_js.ErrorCode.TIMEOUT,
317
317
  "Request timed out. Please check your connection and try again.",
318
318
  true
319
319
  ),
@@ -321,21 +321,21 @@ function toNetworkError(error, isTestMode) {
321
321
  );
322
322
  }
323
323
  if (error instanceof TypeError && error.message.includes("fetch")) {
324
- return chunkQBQCMQ4F_js.enrichError(
325
- new chunkQBQCMQ4F_js.CimplifyError(
326
- chunkQBQCMQ4F_js.ErrorCode.NETWORK_ERROR,
324
+ return chunkTKOTACKZ_js.enrichError(
325
+ new chunkTKOTACKZ_js.CimplifyError(
326
+ chunkTKOTACKZ_js.ErrorCode.NETWORK_ERROR,
327
327
  "Network error. Please check your internet connection.",
328
328
  true
329
329
  ),
330
330
  { isTestMode }
331
331
  );
332
332
  }
333
- if (error instanceof chunkQBQCMQ4F_js.CimplifyError) {
334
- return chunkQBQCMQ4F_js.enrichError(error, { isTestMode });
333
+ if (error instanceof chunkTKOTACKZ_js.CimplifyError) {
334
+ return chunkTKOTACKZ_js.enrichError(error, { isTestMode });
335
335
  }
336
- return chunkQBQCMQ4F_js.enrichError(
337
- new chunkQBQCMQ4F_js.CimplifyError(
338
- chunkQBQCMQ4F_js.ErrorCode.UNKNOWN_ERROR,
336
+ return chunkTKOTACKZ_js.enrichError(
337
+ new chunkTKOTACKZ_js.CimplifyError(
338
+ chunkTKOTACKZ_js.ErrorCode.UNKNOWN_ERROR,
339
339
  error instanceof Error ? error.message : "An unknown error occurred",
340
340
  false
341
341
  ),
@@ -398,7 +398,7 @@ var CimplifyClient = class {
398
398
  this.sessionToken = this.loadSessionToken();
399
399
  if (!this.publicKey && !config.suppressPublicKeyWarning) {
400
400
  console.warn(
401
- '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "pk_..." } to createCimplifyClient().'
401
+ '[Cimplify] No public key found. Set NEXT_PUBLIC_CIMPLIFY_PUBLIC_KEY in your environment, or pass { publicKey: "cpk_..." } to createCimplifyClient().'
402
402
  );
403
403
  }
404
404
  }
@@ -416,7 +416,7 @@ var CimplifyClient = class {
416
416
  return this.publicKey;
417
417
  }
418
418
  isTestMode() {
419
- return this.publicKey.trim().startsWith("pk_test_");
419
+ return this.publicKey.trim().startsWith("cpk_test_");
420
420
  }
421
421
  setAccessToken(token) {
422
422
  const previous = this.accessToken;
@@ -510,8 +510,8 @@ var CimplifyClient = class {
510
510
  this.businessIdResolvePromise = (async () => {
511
511
  const result = await this.business.getInfo();
512
512
  if (!result.ok || !result.value?.id) {
513
- throw new chunkQBQCMQ4F_js.CimplifyError(
514
- chunkQBQCMQ4F_js.ErrorCode.NOT_FOUND,
513
+ throw new chunkTKOTACKZ_js.CimplifyError(
514
+ chunkTKOTACKZ_js.ErrorCode.NOT_FOUND,
515
515
  "Unable to resolve business ID from the current public key.",
516
516
  true
517
517
  );
@@ -628,7 +628,7 @@ var CimplifyClient = class {
628
628
  if (response.status >= 400 && response.status < 500) {
629
629
  this.hooks.onRequestError?.({
630
630
  ...context,
631
- error: new chunkQBQCMQ4F_js.CimplifyError(
631
+ error: new chunkTKOTACKZ_js.CimplifyError(
632
632
  `HTTP_${response.status}`,
633
633
  `Request failed with status ${response.status}`,
634
634
  false
@@ -654,7 +654,7 @@ var CimplifyClient = class {
654
654
  }
655
655
  this.hooks.onRequestError?.({
656
656
  ...context,
657
- error: new chunkQBQCMQ4F_js.CimplifyError(
657
+ error: new chunkTKOTACKZ_js.CimplifyError(
658
658
  "SERVER_ERROR",
659
659
  `Server error ${response.status} after ${retryCount} retries`,
660
660
  false
@@ -787,17 +787,17 @@ var CimplifyClient = class {
787
787
  const retryable = typeof json.error === "object" && typeof json.error?.retryable === "boolean" ? json.error.retryable : false;
788
788
  if (errorCode === "IDEMPOTENCY_MISMATCH") {
789
789
  const originalCreatedAt = typeof json.error === "object" && json.error?.original_created_at || "";
790
- throw new chunkQBQCMQ4F_js.IdempotencyMismatchError(errorMessage, originalCreatedAt);
790
+ throw new chunkTKOTACKZ_js.IdempotencyMismatchError(errorMessage, originalCreatedAt);
791
791
  }
792
- const error = chunkQBQCMQ4F_js.enrichError(
793
- new chunkQBQCMQ4F_js.CimplifyError(
792
+ const error = chunkTKOTACKZ_js.enrichError(
793
+ new chunkTKOTACKZ_js.CimplifyError(
794
794
  errorCode,
795
795
  errorMessage,
796
796
  retryable
797
797
  ),
798
798
  { isTestMode: this.isTestMode() }
799
799
  );
800
- if ((response.status === 401 || error.code === chunkQBQCMQ4F_js.ErrorCode.UNAUTHORIZED) && this.accessToken) {
800
+ if ((response.status === 401 || error.code === chunkTKOTACKZ_js.ErrorCode.UNAUTHORIZED) && this.accessToken) {
801
801
  console.warn(
802
802
  "[Cimplify] Received 401 Unauthorized. Access token may be missing/expired. Refresh authentication and retry the request."
803
803
  );
@@ -805,8 +805,8 @@ var CimplifyClient = class {
805
805
  throw error;
806
806
  }
807
807
  if (json?.success === false || json?.error?.code || json?.error?.message) {
808
- const error = chunkQBQCMQ4F_js.enrichError(
809
- new chunkQBQCMQ4F_js.CimplifyError(
808
+ const error = chunkTKOTACKZ_js.enrichError(
809
+ new chunkTKOTACKZ_js.CimplifyError(
810
810
  json.error?.code || "API_ERROR",
811
811
  json.error?.message || "An error occurred",
812
812
  json.error?.retryable || false
@@ -822,25 +822,25 @@ var CimplifyClient = class {
822
822
  }
823
823
  get catalogue() {
824
824
  if (!this._catalogue) {
825
- this._catalogue = new chunkGVLWRI5I_js.CatalogueQueries(this);
825
+ this._catalogue = new chunk7ZACMER7_js.CatalogueQueries(this);
826
826
  }
827
827
  return this._catalogue;
828
828
  }
829
829
  get cart() {
830
830
  if (!this._cart) {
831
- this._cart = new chunkGVLWRI5I_js.CartOperations(this);
831
+ this._cart = new chunk7ZACMER7_js.CartOperations(this);
832
832
  }
833
833
  return this._cart;
834
834
  }
835
835
  get checkout() {
836
836
  if (!this._checkout) {
837
- this._checkout = new chunkGVLWRI5I_js.CheckoutService(this);
837
+ this._checkout = new chunk7ZACMER7_js.CheckoutService(this);
838
838
  }
839
839
  return this._checkout;
840
840
  }
841
841
  get orders() {
842
842
  if (!this._orders) {
843
- this._orders = new chunkGVLWRI5I_js.OrderQueries(this);
843
+ this._orders = new chunk7ZACMER7_js.OrderQueries(this);
844
844
  }
845
845
  return this._orders;
846
846
  }
@@ -864,43 +864,43 @@ var CimplifyClient = class {
864
864
  }
865
865
  get link() {
866
866
  if (!this._link) {
867
- this._link = new chunkGVLWRI5I_js.LinkService(this);
867
+ this._link = new chunk7ZACMER7_js.LinkService(this);
868
868
  }
869
869
  return this._link;
870
870
  }
871
871
  get auth() {
872
872
  if (!this._auth) {
873
- this._auth = new chunkGVLWRI5I_js.AuthService(this);
873
+ this._auth = new chunk7ZACMER7_js.AuthService(this);
874
874
  }
875
875
  return this._auth;
876
876
  }
877
877
  get business() {
878
878
  if (!this._business) {
879
- this._business = new chunkGVLWRI5I_js.BusinessService(this);
879
+ this._business = new chunk7ZACMER7_js.BusinessService(this);
880
880
  }
881
881
  return this._business;
882
882
  }
883
883
  get inventory() {
884
884
  if (!this._inventory) {
885
- this._inventory = new chunkGVLWRI5I_js.InventoryService(this);
885
+ this._inventory = new chunk7ZACMER7_js.InventoryService(this);
886
886
  }
887
887
  return this._inventory;
888
888
  }
889
889
  get scheduling() {
890
890
  if (!this._scheduling) {
891
- this._scheduling = new chunkGVLWRI5I_js.SchedulingService(this);
891
+ this._scheduling = new chunk7ZACMER7_js.SchedulingService(this);
892
892
  }
893
893
  return this._scheduling;
894
894
  }
895
895
  get lite() {
896
896
  if (!this._lite) {
897
- this._lite = new chunkGVLWRI5I_js.LiteService(this);
897
+ this._lite = new chunk7ZACMER7_js.LiteService(this);
898
898
  }
899
899
  return this._lite;
900
900
  }
901
901
  get fx() {
902
902
  if (!this._fx) {
903
- this._fx = new chunkGVLWRI5I_js.FxService(this);
903
+ this._fx = new chunk7ZACMER7_js.FxService(this);
904
904
  }
905
905
  return this._fx;
906
906
  }
@@ -935,7 +935,7 @@ var CimplifyClient = class {
935
935
  if (businessId) {
936
936
  this.setBusinessId(businessId);
937
937
  }
938
- return chunkGVLWRI5I_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
938
+ return chunk7ZACMER7_js.createElements(this, businessId ?? this.businessId ?? void 0, options);
939
939
  }
940
940
  };
941
941
  function createCimplifyClient(config = {}) {
@@ -1,5 +1,5 @@
1
- import { C as CimplifyClient } from './client-aZInadOY.js';
2
- import { C as CreateAppOptions, A as AppHandle } from './server-Bg3VtA1D.js';
1
+ import { C as CimplifyClient } from './client-QVINYu1X.js';
2
+ import { C as CreateAppOptions, A as AppHandle } from './server-72rzvJ4Y.js';
3
3
 
4
4
  /**
5
5
  * Test client + fixtures.
@@ -1,5 +1,5 @@
1
- import { C as CimplifyClient } from './client-CDUY-6nC.mjs';
2
- import { C as CreateAppOptions, A as AppHandle } from './server-kakjHRgj.mjs';
1
+ import { C as CimplifyClient } from './client-G2WCoxv2.mjs';
2
+ import { C as CreateAppOptions, A as AppHandle } from './server-BgccqOLT.mjs';
3
3
 
4
4
  /**
5
5
  * Test client + fixtures.
@@ -1,5 +1,5 @@
1
- import { h as CimplifyError, an as Category, U as Product, aj as AddOnWithOptions, d as Pagination, a8 as ProductWithDetails, aa as ProductVariant, ac as VariantAxis, ah as VariantAxisSelection, ai as AddOn, ap as Collection, au as BundleSummary, at as Bundle, aG as Composite, aN as ComponentSelectionInput, aO as CompositePriceResult, C as ChosenPrice, aV as ProductTaxonomy, aW as TaxonomyWithChildren, bP as EligiblePlansQuery, bO as ProductBillingPlan, aU as ProductTimeProfile, aX as ProductAvailabilityNow, aZ as Deal, a_ as ProductDealInfo, a$ as DiscountValidation, b1 as TagsResponse, H as CustomAttributeDefinition, J as CustomAttributeValue, N as PropertyFacet, T as TaxonomyAttributeTemplate, Q as KnowledgeArticle, bF as UICart, br as CartItem, bK as CartSummary, bI as AddToCartInput, bH as CartMutationResult, bJ as UpdateCartItemInput, bd as DiscountDetails, M as Money, a as CurrencyCode, bp as LineConfiguration, S as SchedulingMode, v as DurationUnit, bS as Subscription, bV as SubscriptionWithDetails } from './product-DiX-HGkT.js';
2
- import { c as AuthorizationType, e as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, h as PaymentStatusResponse } from './payment-JcNqOf_T.js';
1
+ import { h as CimplifyError, ap as Category, X as Product, al as AddOnWithOptions, d as Pagination, aa as ProductWithDetails, ac as ProductVariant, ae as VariantAxis, aj as VariantAxisSelection, ak as AddOn, ar as Collection, aw as BundleSummary, av as Bundle, aI as Composite, aP as ComponentSelectionInput, aQ as CompositePriceResult, C as ChosenPrice, aX as ProductTaxonomy, aY as TaxonomyWithChildren, bR as EligiblePlansQuery, bQ as ProductBillingPlan, aW as ProductTimeProfile, aZ as ProductAvailabilityNow, a$ as Deal, b0 as ProductDealInfo, b1 as DiscountValidation, b3 as TagsResponse, K as CustomAttributeDefinition, L as CustomAttributeValue, Q as PropertyFacet, U as TaxonomyAttributeTemplate, W as KnowledgeArticle, bH as UICart, bt as CartItem, bM as CartSummary, bK as AddToCartInput, bJ as CartMutationResult, bL as UpdateCartItemInput, bf as DiscountDetails, M as Money, a as CurrencyCode, br as LineConfiguration, S as SchedulingMode, x as DurationUnit, bU as Subscription, bX as SubscriptionWithDetails } from './product-C-xLzh7Q.mjs';
2
+ import { c as AuthorizationType, e as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, h as PaymentStatusResponse } from './payment-9L_-GWqQ.mjs';
3
3
 
4
4
  interface RequestContext {
5
5
  method: "GET" | "POST" | "PATCH" | "DELETE";
@@ -2299,6 +2299,8 @@ declare class CimplifyElement {
2299
2299
  private iframe;
2300
2300
  private container;
2301
2301
  private mounted;
2302
+ private ready;
2303
+ private pendingMessages;
2302
2304
  private pendingInit;
2303
2305
  private eventHandlers;
2304
2306
  private resolvers;
@@ -2312,6 +2314,7 @@ declare class CimplifyElement {
2312
2314
  getData(): Promise<unknown>;
2313
2315
  setCart(cart: CheckoutCartData): void;
2314
2316
  sendMessage(message: ParentToIframeMessage): void;
2317
+ private flushPending;
2315
2318
  getContentWindow(): Window | null;
2316
2319
  isMounted(): boolean;
2317
2320
  private createIframe;
@@ -1,5 +1,5 @@
1
- import { h as CimplifyError, an as Category, U as Product, aj as AddOnWithOptions, d as Pagination, a8 as ProductWithDetails, aa as ProductVariant, ac as VariantAxis, ah as VariantAxisSelection, ai as AddOn, ap as Collection, au as BundleSummary, at as Bundle, aG as Composite, aN as ComponentSelectionInput, aO as CompositePriceResult, C as ChosenPrice, aV as ProductTaxonomy, aW as TaxonomyWithChildren, bP as EligiblePlansQuery, bO as ProductBillingPlan, aU as ProductTimeProfile, aX as ProductAvailabilityNow, aZ as Deal, a_ as ProductDealInfo, a$ as DiscountValidation, b1 as TagsResponse, H as CustomAttributeDefinition, J as CustomAttributeValue, N as PropertyFacet, T as TaxonomyAttributeTemplate, Q as KnowledgeArticle, bF as UICart, br as CartItem, bK as CartSummary, bI as AddToCartInput, bH as CartMutationResult, bJ as UpdateCartItemInput, bd as DiscountDetails, M as Money, a as CurrencyCode, bp as LineConfiguration, S as SchedulingMode, v as DurationUnit, bS as Subscription, bV as SubscriptionWithDetails } from './product-DiX-HGkT.mjs';
2
- import { c as AuthorizationType, e as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, h as PaymentStatusResponse } from './payment-Bse2XJ-c.mjs';
1
+ import { h as CimplifyError, ap as Category, X as Product, al as AddOnWithOptions, d as Pagination, aa as ProductWithDetails, ac as ProductVariant, ae as VariantAxis, aj as VariantAxisSelection, ak as AddOn, ar as Collection, aw as BundleSummary, av as Bundle, aI as Composite, aP as ComponentSelectionInput, aQ as CompositePriceResult, C as ChosenPrice, aX as ProductTaxonomy, aY as TaxonomyWithChildren, bR as EligiblePlansQuery, bQ as ProductBillingPlan, aW as ProductTimeProfile, aZ as ProductAvailabilityNow, a$ as Deal, b0 as ProductDealInfo, b1 as DiscountValidation, b3 as TagsResponse, K as CustomAttributeDefinition, L as CustomAttributeValue, Q as PropertyFacet, U as TaxonomyAttributeTemplate, W as KnowledgeArticle, bH as UICart, bt as CartItem, bM as CartSummary, bK as AddToCartInput, bJ as CartMutationResult, bL as UpdateCartItemInput, bf as DiscountDetails, M as Money, a as CurrencyCode, br as LineConfiguration, S as SchedulingMode, x as DurationUnit, bU as Subscription, bX as SubscriptionWithDetails } from './product-C-xLzh7Q.js';
2
+ import { c as AuthorizationType, e as PaymentMethod, I as InitializePaymentResult, S as SubmitAuthorizationInput, h as PaymentStatusResponse } from './payment-_e99nSRj.js';
3
3
 
4
4
  interface RequestContext {
5
5
  method: "GET" | "POST" | "PATCH" | "DELETE";
@@ -2299,6 +2299,8 @@ declare class CimplifyElement {
2299
2299
  private iframe;
2300
2300
  private container;
2301
2301
  private mounted;
2302
+ private ready;
2303
+ private pendingMessages;
2302
2304
  private pendingInit;
2303
2305
  private eventHandlers;
2304
2306
  private resolvers;
@@ -2312,6 +2314,7 @@ declare class CimplifyElement {
2312
2314
  getData(): Promise<unknown>;
2313
2315
  setCart(cart: CheckoutCartData): void;
2314
2316
  sendMessage(message: ParentToIframeMessage): void;
2317
+ private flushPending;
2315
2318
  getContentWindow(): Window | null;
2316
2319
  isMounted(): boolean;
2317
2320
  private createIframe;
@@ -1,6 +1,6 @@
1
- import { M as Money, a as CurrencyCode, b8 as PricePathTaxInfo, a6 as QuantityPricingTier, U as Product, a8 as ProductWithDetails } from './product-DiX-HGkT.js';
2
- import { P as ProductWithPrice } from './price-mHkRncgW.js';
3
- import { i as PaymentErrorDetails, g as PaymentResponse, h as PaymentStatusResponse } from './payment-JcNqOf_T.js';
1
+ import { M as Money, a as CurrencyCode, ba as PricePathTaxInfo, a8 as QuantityPricingTier, X as Product, aa as ProductWithDetails } from './product-C-xLzh7Q.js';
2
+ import { P as ProductWithPrice } from './price-CWQ5TQmk.js';
3
+ import { i as PaymentErrorDetails, g as PaymentResponse, h as PaymentStatusResponse } from './payment-_e99nSRj.js';
4
4
  import { CountryCode } from 'libphonenumber-js';
5
5
 
6
6
  declare const CURRENCY_SYMBOLS: Record<string, string>;