@questwork/q-store-model 0.2.1 → 0.2.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.
@@ -1,16 +1,44 @@
1
- import { TenantAwareEntity as Ke } from "@questwork/q-utilities";
2
- class G extends Error {
1
+ import { TenantAwareEntity as Rt } from "@questwork/q-utilities";
2
+ const ht = Object.freeze({
3
+ CREATED: "CREATED",
4
+ PAYMENT_REQUIRED: "PAYMENT_REQUIRED",
5
+ PAYMENT_IN_PROGRESS: "PAYMENT_IN_PROGRESS",
6
+ PAID: "PAID",
7
+ COMPLETED: "COMPLETED",
8
+ CANCELLED: "CANCELLED",
9
+ EXPIRED: "EXPIRED"
10
+ }), It = Object.freeze({
11
+ HELD_FOR_CHECKOUT: "HELD_FOR_CHECKOUT",
12
+ HELD_FOR_PROVIDER: "HELD_FOR_PROVIDER",
13
+ HELD_FOR_REVIEW: "HELD_FOR_REVIEW",
14
+ CONSUMED: "CONSUMED",
15
+ RELEASED: "RELEASED",
16
+ EXPIRED: "EXPIRED"
17
+ }), Tt = Object.freeze({
18
+ CREATED: "CREATED",
19
+ PAYMENT_IN_PROGRESS: "PAYMENT_IN_PROGRESS",
20
+ SUCCEEDED: "SUCCEEDED",
21
+ FAILED: "FAILED",
22
+ CANCELLED: "CANCELLED",
23
+ EXPIRED: "EXPIRED"
24
+ }), Ce = Object.freeze({
25
+ PURCHASE: "PURCHASE",
26
+ ADMIN_ASSIGNMENT: "ADMIN_ASSIGNMENT",
27
+ ROLE_BENEFIT: "ROLE_BENEFIT",
28
+ PROMOTION_REDEMPTION: "PROMOTION_REDEMPTION"
29
+ });
30
+ class J extends Error {
3
31
  constructor({ contractName: o, issues: e }) {
4
32
  super(`${o} is invalid: ${e.join("; ")}`), this.name = "StoreContractValidationError", this.code = "STORE_CONTRACT_INVALID", this.contractName = o, this.issues = [...e];
5
33
  }
6
34
  }
7
- const We = ["boolean", "number", "string"];
35
+ const gt = ["boolean", "number", "string"];
8
36
  function D(n, o = "value") {
9
37
  if (n === null)
10
38
  return null;
11
39
  if (Array.isArray(n))
12
40
  return n.map((e, t) => D(e, `${o}[${t}]`));
13
- if (We.includes(typeof n)) {
41
+ if (gt.includes(typeof n)) {
14
42
  if (typeof n == "number" && !Number.isFinite(n))
15
43
  throw new TypeError(`${o} must be a finite number`);
16
44
  return n;
@@ -23,42 +51,185 @@ function D(n, o = "value") {
23
51
  }));
24
52
  throw new TypeError(`${o} must contain JSON-safe values only`);
25
53
  }
26
- function q(n) {
27
- return n && typeof n == "object" && !Object.isFrozen(n) && (Object.values(n).forEach(q), Object.freeze(n)), n;
54
+ function L(n) {
55
+ return n && typeof n == "object" && !Object.isFrozen(n) && (Object.values(n).forEach(L), Object.freeze(n)), n;
28
56
  }
29
- function xe({ contractName: n, object: o, fields: e }) {
30
- const t = Object.keys(o).filter((i) => !e.includes(i));
57
+ function nt({ contractName: n, object: o, fields: e }) {
58
+ const t = Object.keys(o).filter((r) => !e.includes(r));
31
59
  if (t.length > 0)
32
- throw new G({
60
+ throw new J({
33
61
  contractName: n,
34
- issues: t.map((i) => `unknown field "${i}"`)
62
+ issues: t.map((r) => `unknown field "${r}"`)
35
63
  });
36
64
  }
37
- function u(n, o, e) {
65
+ function s(n, o, e) {
38
66
  return typeof n != "string" || n.trim().length === 0 ? (e.push(`${o} must be a non-empty string`), "") : n;
39
67
  }
40
- function M(n, o, e) {
68
+ function N(n, o, e) {
41
69
  if (!(typeof n > "u" || n === null))
42
- return u(n, o, e);
70
+ return s(n, o, e);
43
71
  }
44
- function I(n, o, e, t = 1) {
72
+ function f(n, o, e, t = 1) {
45
73
  return !Number.isInteger(n) || n < 1 ? (e.push(`${o} must be a positive integer`), t) : n;
46
74
  }
47
- function He(n, o, e, t = 0) {
75
+ function x(n, o, e, t = 0) {
48
76
  return typeof n != "number" || !Number.isFinite(n) || n < 0 ? (e.push(`${o} must be a non-negative finite number`), t) : n;
49
77
  }
50
- function z(n, o, e) {
51
- return Array.isArray(n) ? n.map((t, i) => u(t, `${o}[${i}]`, e)) : (e.push(`${o} must be an array`), []);
78
+ function oe(n, o, e, t = 0) {
79
+ return !Number.isInteger(n) || n < 0 ? (e.push(`${o} must be a non-negative integer`), t) : n;
80
+ }
81
+ function $(n, o, e) {
82
+ const t = s(n, o, e);
83
+ return t && !Number.isFinite(Date.parse(t)) && e.push(`${o} must be an ISO-compatible timestamp`), t;
84
+ }
85
+ function ae(n, o, e) {
86
+ if (!(typeof n > "u" || n === null))
87
+ return $(n, o, e);
88
+ }
89
+ function B(n, o, e) {
90
+ return !n || typeof n != "object" || Array.isArray(n) ? (e.push(`${o} must be an object`), {}) : D(n, o);
91
+ }
92
+ function Z(n, o, e) {
93
+ return Array.isArray(n) ? D(n, o) : (e.push(`${o} must be an array`), []);
94
+ }
95
+ function U(n, o, e) {
96
+ return Array.isArray(n) ? n.map((t, r) => s(t, `${o}[${r}]`, e)) : (e.push(`${o} must be an array`), []);
97
+ }
98
+ const bt = [
99
+ "_id",
100
+ "_tenant",
101
+ "_type",
102
+ "id",
103
+ "meta",
104
+ "metadata",
105
+ "remarks",
106
+ "tenantCode"
107
+ ], ot = [
108
+ "active",
109
+ "created",
110
+ "creator",
111
+ "deleted",
112
+ "modified",
113
+ "owner",
114
+ "revision"
115
+ ];
116
+ class O extends Rt {
117
+ constructor({ contractName: o, object: e, fields: t, normalize: r }) {
118
+ var l;
119
+ if (!e || typeof e != "object" || Array.isArray(e))
120
+ throw new J({ contractName: o, issues: ["input must be an object"] });
121
+ nt({ contractName: o, object: e, fields: [...bt, ...t] });
122
+ const i = [], d = s(e.tenantCode, "tenantCode", i);
123
+ Dt(e.meta, i), Ve(e.metadata, "metadata", i), Ve(e.remarks, "remarks", i);
124
+ const c = D(Object.fromEntries(t.flatMap((m) => Object.hasOwn(e, m) ? [[m, e[m]]] : []))), a = r(c, i, { meta: D(e.meta || {}) });
125
+ if (i.length > 0)
126
+ throw new J({ contractName: o, issues: i });
127
+ super({ ...e, tenantCode: d });
128
+ const u = (l = e.meta) == null ? void 0 : l.revision;
129
+ Number.isInteger(u) && u >= 0 && (this.meta.revision = u), this._type = e._type || o, Object.assign(this, a), Object.defineProperty(this, "_storeContractFields", {
130
+ configurable: !1,
131
+ enumerable: !1,
132
+ value: Object.freeze([...t]),
133
+ writable: !1
134
+ });
135
+ }
136
+ getId() {
137
+ return this.id === null || typeof this.id > "u" ? "" : this.id.toString();
138
+ }
139
+ toJSON() {
140
+ return this.toObject();
141
+ }
142
+ toObject() {
143
+ const o = {
144
+ _type: this._type,
145
+ meta: Le(this.meta, ot),
146
+ metadata: qe(this.metadata),
147
+ remarks: qe(this.remarks),
148
+ tenantCode: this.tenantCode,
149
+ ...Le(this, this._storeContractFields)
150
+ }, e = this.getId();
151
+ return e && (o.id = e), D(o);
152
+ }
153
+ }
154
+ function Dt(n, o) {
155
+ if (!(typeof n > "u")) {
156
+ if (!n || typeof n != "object" || Array.isArray(n)) {
157
+ o.push("meta must be an object");
158
+ return;
159
+ }
160
+ Object.keys(n).forEach((e) => {
161
+ ot.includes(e) || o.push(`meta contains unknown field "${e}"`);
162
+ }), ["active", "deleted"].forEach((e) => {
163
+ typeof n[e] < "u" && typeof n[e] != "boolean" && o.push(`meta.${e} must be a boolean`);
164
+ }), ["created", "modified"].forEach((e) => {
165
+ typeof n[e] < "u" && (!Number.isFinite(n[e]) || n[e] < 0) && o.push(`meta.${e} must be a non-negative finite number`);
166
+ }), ["creator", "owner"].forEach((e) => {
167
+ typeof n[e] < "u" && typeof n[e] != "string" && o.push(`meta.${e} must be a string`);
168
+ }), typeof n.revision < "u" && (!Number.isInteger(n.revision) || n.revision < 0) && o.push("meta.revision must be a non-negative integer");
169
+ }
170
+ }
171
+ function qe(n) {
172
+ return Array.isArray(n) ? n.map((o) => ({ key: o.key, value: D(o.value) })) : [];
173
+ }
174
+ function Le(n, o) {
175
+ return Object.fromEntries(o.flatMap((e) => typeof n[e] > "u" ? [] : [[e, D(n[e])]]));
176
+ }
177
+ function Ve(n, o, e) {
178
+ if (!(typeof n > "u")) {
179
+ if (!Array.isArray(n)) {
180
+ e.push(`${o} must be an array`);
181
+ return;
182
+ }
183
+ n.forEach((t, r) => {
184
+ if (!t || typeof t != "object" || Array.isArray(t)) {
185
+ e.push(`${o}[${r}] must be an object`);
186
+ return;
187
+ }
188
+ Object.keys(t).forEach((i) => {
189
+ ["key", "value"].includes(i) || e.push(`${o}[${r}] contains unknown field "${i}"`);
190
+ }), s(t.key, `${o}[${r}].key`, e), Object.hasOwn(t, "value") ? D(t.value, `${o}[${r}].value`) : e.push(`${o}[${r}].value is required`);
191
+ });
192
+ }
52
193
  }
53
- class T {
54
- constructor({ contractName: o, object: e, fields: t, normalize: i }) {
194
+ class pn extends O {
195
+ constructor(o = {}) {
196
+ super({
197
+ contractName: "Acquisition",
198
+ object: o,
199
+ fields: ["acquisitionCode", "commandCode", "source", "eventRegistrationCode", "initiatedBy", "orderCode", "settlementCode", "merchandiseSnapshot", "productSnapshots", "walletItemCodes", "acquired"],
200
+ normalize(e, t) {
201
+ const r = s(e.source, "source", t);
202
+ Object.values(Ce).includes(r) || t.push(`source "${r}" is not supported`);
203
+ const i = N(e.orderCode, "orderCode", t), d = N(e.settlementCode, "settlementCode", t);
204
+ return r === Ce.PURCHASE && !i && t.push("orderCode is required for PURCHASE acquisition"), r !== Ce.PURCHASE && (i || d) && t.push("non-purchase acquisition must not reference an Order or Settlement"), {
205
+ acquisitionCode: s(e.acquisitionCode, "acquisitionCode", t),
206
+ commandCode: s(e.commandCode, "commandCode", t),
207
+ source: r,
208
+ eventRegistrationCode: s(e.eventRegistrationCode, "eventRegistrationCode", t),
209
+ initiatedBy: s(e.initiatedBy, "initiatedBy", t),
210
+ ...i ? { orderCode: i } : {},
211
+ ...d ? { settlementCode: d } : {},
212
+ merchandiseSnapshot: e.merchandiseSnapshot || {},
213
+ productSnapshots: Z(e.productSnapshots, "productSnapshots", t),
214
+ walletItemCodes: Z(e.walletItemCodes, "walletItemCodes", t),
215
+ acquired: $(e.acquired, "acquired", t)
216
+ };
217
+ }
218
+ });
219
+ }
220
+ getCode() {
221
+ return this.acquisitionCode;
222
+ }
223
+ }
224
+ class h {
225
+ constructor({ contractName: o, object: e, fields: t, normalize: r }) {
55
226
  if (!e || typeof e != "object" || Array.isArray(e))
56
- throw new G({ contractName: o, issues: ["input must be an object"] });
57
- xe({ contractName: o, object: e, fields: t });
58
- const r = [], s = i(D(e), r);
59
- if (r.length > 0)
60
- throw new G({ contractName: o, issues: r });
61
- Object.assign(this, q(s)), Object.freeze(this);
227
+ throw new J({ contractName: o, issues: ["input must be an object"] });
228
+ nt({ contractName: o, object: e, fields: t });
229
+ const i = [], d = r(D(e), i);
230
+ if (i.length > 0)
231
+ throw new J({ contractName: o, issues: i });
232
+ Object.assign(this, L(d)), Object.freeze(this);
62
233
  }
63
234
  toObject() {
64
235
  return D(Object.fromEntries(Object.entries(this)));
@@ -67,26 +238,26 @@ class T {
67
238
  return this.toObject();
68
239
  }
69
240
  }
70
- class Te extends T {
241
+ class ve extends h {
71
242
  constructor(o = {}) {
72
243
  super({
73
244
  contractName: "PriceEvaluationContext",
74
245
  object: o,
75
246
  fields: ["acquisitionSource", "countryCode", "countryRank", "currency", "instant"],
76
247
  normalize(e, t) {
77
- const i = u(e.instant, "instant", t);
78
- return i && !Number.isFinite(Date.parse(i)) && t.push("instant must be an ISO-compatible timestamp"), {
79
- acquisitionSource: u(e.acquisitionSource, "acquisitionSource", t),
80
- countryCode: u(e.countryCode, "countryCode", t),
81
- countryRank: I(e.countryRank, "countryRank", t),
82
- currency: u(e.currency, "currency", t),
83
- instant: i
248
+ const r = s(e.instant, "instant", t);
249
+ return r && !Number.isFinite(Date.parse(r)) && t.push("instant must be an ISO-compatible timestamp"), {
250
+ acquisitionSource: s(e.acquisitionSource, "acquisitionSource", t),
251
+ countryCode: s(e.countryCode, "countryCode", t),
252
+ countryRank: f(e.countryRank, "countryRank", t),
253
+ currency: s(e.currency, "currency", t),
254
+ instant: r
84
255
  };
85
256
  }
86
257
  });
87
258
  }
88
259
  }
89
- class ge extends T {
260
+ class Ue extends h {
90
261
  constructor(o = {}) {
91
262
  super({
92
263
  contractName: "PriceScheduleRef",
@@ -94,55 +265,56 @@ class ge extends T {
94
265
  fields: ["priceScheduleCode", "priceScheduleVersion"],
95
266
  normalize(e, t) {
96
267
  return {
97
- priceScheduleCode: u(e.priceScheduleCode, "priceScheduleCode", t),
98
- priceScheduleVersion: I(e.priceScheduleVersion, "priceScheduleVersion", t)
268
+ priceScheduleCode: s(e.priceScheduleCode, "priceScheduleCode", t),
269
+ priceScheduleVersion: f(e.priceScheduleVersion, "priceScheduleVersion", t)
99
270
  };
100
271
  }
101
272
  });
102
273
  }
103
274
  }
104
- const S = Object.freeze({
275
+ const _ = Object.freeze({
105
276
  ELIGIBILITY: "ELIGIBILITY",
106
277
  INVENTORY: "INVENTORY",
107
278
  PREREQUISITE: "PREREQUISITE",
108
279
  QUANTITY: "QUANTITY",
109
280
  REFUND: "REFUND",
110
281
  REQUIREMENT: "REQUIREMENT"
111
- }), V = Object.freeze({
282
+ }), q = Object.freeze({
112
283
  ACQUISITION_SOURCE: "ACQUISITION_SOURCE",
113
284
  CATEGORY: "CATEGORY",
114
285
  MERCHANDISE: "MERCHANDISE",
115
286
  PRODUCT: "PRODUCT"
116
- }), _ = Object.freeze({
287
+ }), M = Object.freeze({
117
288
  CATEGORY: "CATEGORY",
118
289
  MERCHANDISE: "MERCHANDISE",
119
290
  PRODUCT: "PRODUCT"
120
- }), K = Object.freeze({ ACTIVE: "ACTIVE", HOLDING: "HOLDING", ORDER: "ORDER" }), x = Object.freeze({
291
+ }), ee = Object.freeze({ ACTIVE: "ACTIVE", HOLDING: "HOLDING", ORDER: "ORDER" }), Y = Object.freeze({
121
292
  NOT_SUBMITTED: "NOT_SUBMITTED",
293
+ REOPENED: "REOPENED",
122
294
  REJECTED: "REJECTED",
123
295
  REVOKED: "REVOKED",
124
296
  UNDER_REVIEW: "UNDER_REVIEW",
125
297
  VALID: "VALID"
126
- }), se = Object.freeze({
298
+ }), Ee = Object.freeze({
127
299
  CAPACITY_ADMISSION: "CAPACITY_ADMISSION",
128
300
  PRODUCTION_DEMAND: "PRODUCTION_DEMAND",
129
301
  STOCKED_VARIANT: "STOCKED_VARIANT"
130
- }), ce = Object.freeze({ ALL: "ALL", ANY: "ANY" }), k = Object.freeze({ EXISTING: "EXISTING", SAME_ORDER: "SAME_ORDER" }), de = Object.freeze({ BEFORE_ITEM_VALID: "BEFORE_ITEM_VALID" }), Q = Object.freeze({
302
+ }), ye = Object.freeze({ ALL: "ALL", ANY: "ANY" }), K = Object.freeze({ EXISTING: "EXISTING", SAME_ORDER: "SAME_ORDER" }), Re = Object.freeze({ BEFORE_ITEM_VALID: "BEFORE_ITEM_VALID" }), j = Object.freeze({
131
303
  ALWAYS: "ALWAYS",
132
304
  LOCK_AFTER_COMPLETE: "LOCK_AFTER_COMPLETE",
133
305
  UNTIL_DEADLINE: "UNTIL_DEADLINE"
134
- }), ie = Object.freeze({
306
+ }), fe = Object.freeze({
135
307
  COMPLETE: "COMPLETE",
136
308
  INCOMPLETE: "INCOMPLETE",
137
309
  OVERDUE: "OVERDUE"
138
- }), H = Object.freeze({
310
+ }), ne = Object.freeze({
139
311
  EDITABLE: "EDITABLE",
140
312
  LOCKED: "LOCKED"
141
- }), re = Object.freeze({
313
+ }), X = Object.freeze({
142
314
  EMAIL: "email",
143
315
  TEXT: "text",
144
316
  VARIANT: "VARIANT"
145
- }), P = Object.freeze({
317
+ }), S = Object.freeze({
146
318
  CANCELLED: "CANCELLED",
147
319
  EXPIRED: "EXPIRED",
148
320
  PENDING_REQUIREMENT: "PENDING_REQUIREMENT",
@@ -151,7 +323,7 @@ const S = Object.freeze({
151
323
  REVOKED: "REVOKED",
152
324
  VALID: "VALID"
153
325
  });
154
- class be extends T {
326
+ class $e extends h {
155
327
  constructor(o = {}) {
156
328
  super({
157
329
  contractName: "RequirementFieldDefinition",
@@ -165,65 +337,65 @@ class be extends T {
165
337
  "optionValueKey"
166
338
  ],
167
339
  normalize(e, t) {
168
- const i = u(e.inputType, "inputType", t);
169
- Object.values(re).includes(i) || t.push(`inputType "${i}" is not supported`);
170
- const r = M(e.autocomplete, "autocomplete", t), s = M(e.deferredLabel, "deferredLabel", t), c = M(e.optionValueKey, "optionValueKey", t);
171
- return i === re.VARIANT && !c && t.push("optionValueKey is required when inputType is VARIANT"), i !== re.VARIANT && c && t.push("optionValueKey is only supported when inputType is VARIANT"), {
172
- fieldCode: u(e.fieldCode, "fieldCode", t),
173
- label: u(e.label, "label", t),
174
- inputType: i,
175
- ...r ? { autocomplete: r } : {},
176
- ...s ? { deferredLabel: s } : {},
340
+ const r = s(e.inputType, "inputType", t);
341
+ Object.values(X).includes(r) || t.push(`inputType "${r}" is not supported`);
342
+ const i = N(e.autocomplete, "autocomplete", t), d = N(e.deferredLabel, "deferredLabel", t), c = N(e.optionValueKey, "optionValueKey", t);
343
+ return r === X.VARIANT && !c && t.push("optionValueKey is required when inputType is VARIANT"), r !== X.VARIANT && c && t.push("optionValueKey is only supported when inputType is VARIANT"), {
344
+ fieldCode: s(e.fieldCode, "fieldCode", t),
345
+ label: s(e.label, "label", t),
346
+ inputType: r,
347
+ ...i ? { autocomplete: i } : {},
348
+ ...d ? { deferredLabel: d } : {},
177
349
  ...c ? { optionValueKey: c } : {}
178
350
  };
179
351
  }
180
352
  });
181
353
  }
182
354
  }
183
- class X extends T {
355
+ class ie extends h {
184
356
  constructor(o = {}) {
185
357
  super({
186
358
  contractName: "RequirementDefinition",
187
359
  object: o,
188
360
  fields: ["requirementCode", "label", "fields"],
189
361
  normalize(e, t) {
190
- const i = (Array.isArray(e.fields) ? e.fields : []).flatMap((s, c) => {
362
+ const r = (Array.isArray(e.fields) ? e.fields : []).flatMap((d, c) => {
191
363
  try {
192
- return [(s instanceof be ? s : new be(s)).toObject()];
193
- } catch (d) {
194
- return t.push(`fields[${c}]: ${d.message}`), [];
364
+ return [(d instanceof $e ? d : new $e(d)).toObject()];
365
+ } catch (a) {
366
+ return t.push(`fields[${c}]: ${a.message}`), [];
195
367
  }
196
368
  });
197
- Array.isArray(e.fields) || t.push("fields must be an array"), i.length === 0 && t.push("fields must contain at least one field");
198
- const r = /* @__PURE__ */ new Set();
199
- return i.forEach((s, c) => {
200
- r.has(s.fieldCode) && t.push(`fields[${c}].fieldCode duplicates "${s.fieldCode}"`), r.add(s.fieldCode);
369
+ Array.isArray(e.fields) || t.push("fields must be an array"), r.length === 0 && t.push("fields must contain at least one field");
370
+ const i = /* @__PURE__ */ new Set();
371
+ return r.forEach((d, c) => {
372
+ i.has(d.fieldCode) && t.push(`fields[${c}].fieldCode duplicates "${d.fieldCode}"`), i.add(d.fieldCode);
201
373
  }), {
202
- requirementCode: u(e.requirementCode, "requirementCode", t),
203
- label: u(e.label, "label", t),
204
- fields: i
374
+ requirementCode: s(e.requirementCode, "requirementCode", t),
375
+ label: s(e.label, "label", t),
376
+ fields: r
205
377
  };
206
378
  }
207
379
  });
208
380
  }
209
381
  }
210
- function ze({ values: n, allowedValues: o, path: e, issues: t }) {
211
- n.forEach((i) => {
212
- o.includes(i) || t.push(`${e} contains unsupported value "${i}"`);
382
+ function rt({ values: n, allowedValues: o, path: e, issues: t }) {
383
+ n.forEach((r) => {
384
+ o.includes(r) || t.push(`${e} contains unsupported value "${r}"`);
213
385
  });
214
386
  }
215
- function Je(n, o, e, t) {
216
- return !n || typeof n != "object" || Array.isArray(n) ? (e.push(`${o} must be an object`), {}) : new T({
387
+ function Nt(n, o, e, t) {
388
+ return !n || typeof n != "object" || Array.isArray(n) ? (e.push(`${o} must be an object`), {}) : new h({
217
389
  contractName: o,
218
390
  object: n,
219
391
  fields: ["code", "type"],
220
- normalize(r, s) {
221
- const c = typeof r.type == "string" ? r.type : "", d = typeof r.code == "string" ? r.code : "";
222
- return c.trim() || s.push("type must be a non-empty string"), d.trim() || s.push("code must be a non-empty string"), c && !t.includes(c) && s.push(`type "${c}" is not supported`), { type: c, code: d };
392
+ normalize(i, d) {
393
+ const c = typeof i.type == "string" ? i.type : "", a = typeof i.code == "string" ? i.code : "";
394
+ return c.trim() || d.push("type must be a non-empty string"), a.trim() || d.push("code must be a non-empty string"), c && !t.includes(c) && d.push(`type "${c}" is not supported`), { type: c, code: a };
223
395
  }
224
396
  }).toObject();
225
397
  }
226
- function Z(n, o, e) {
398
+ function de(n, o, e) {
227
399
  if (!(typeof n > "u" || n === null || n === "")) {
228
400
  if (typeof n != "string" || !Number.isFinite(Date.parse(n))) {
229
401
  e.push(`${o} must be an ISO-8601 timestamp`);
@@ -232,7 +404,7 @@ function Z(n, o, e) {
232
404
  return n;
233
405
  }
234
406
  }
235
- class ee extends T {
407
+ class ce extends h {
236
408
  constructor(o = {}) {
237
409
  super({
238
410
  contractName: "RequirementPlan",
@@ -252,40 +424,40 @@ class ee extends T {
252
424
  "values"
253
425
  ],
254
426
  normalize(e, t) {
255
- let i = {};
427
+ let r = {};
256
428
  try {
257
- i = (e.requirement instanceof X ? e.requirement : new X(e.requirement)).toObject();
258
- } catch (d) {
259
- t.push(`requirement: ${d.message}`);
429
+ r = (e.requirement instanceof ie ? e.requirement : new ie(e.requirement)).toObject();
430
+ } catch (a) {
431
+ t.push(`requirement: ${a.message}`);
260
432
  }
261
- Object.values(de).includes(e.completionTiming) || t.push(`completionTiming "${e.completionTiming}" is not supported`), Object.values(Q).includes(e.modificationMode) || t.push(`modificationMode "${e.modificationMode}" is not supported`);
262
- const r = Z(e.completionDeadline, "completionDeadline", t), s = Z(e.modificationDeadline, "modificationDeadline", t);
433
+ Object.values(Re).includes(e.completionTiming) || t.push(`completionTiming "${e.completionTiming}" is not supported`), Object.values(j).includes(e.modificationMode) || t.push(`modificationMode "${e.modificationMode}" is not supported`);
434
+ const i = de(e.completionDeadline, "completionDeadline", t), d = de(e.modificationDeadline, "modificationDeadline", t);
263
435
  (!Number.isInteger(e.componentIndex) || e.componentIndex < 0) && t.push("componentIndex must be a non-negative integer"), (!Number.isInteger(e.unitIndex) || e.unitIndex < 0) && t.push("unitIndex must be a non-negative integer"), typeof e.complete != "boolean" && t.push("complete must be a boolean");
264
436
  let c = {};
265
437
  try {
266
438
  !e.values || typeof e.values != "object" || Array.isArray(e.values) ? t.push("values must be an object") : c = D(e.values);
267
- } catch (d) {
268
- t.push(`values: ${d.message}`);
439
+ } catch (a) {
440
+ t.push(`values: ${a.message}`);
269
441
  }
270
442
  return {
271
- ruleCode: u(e.ruleCode, "ruleCode", t),
272
- requirement: i,
273
- productCode: u(e.productCode, "productCode", t),
443
+ ruleCode: s(e.ruleCode, "ruleCode", t),
444
+ requirement: r,
445
+ productCode: s(e.productCode, "productCode", t),
274
446
  componentIndex: Number.isInteger(e.componentIndex) && e.componentIndex >= 0 ? e.componentIndex : 0,
275
447
  unitIndex: Number.isInteger(e.unitIndex) && e.unitIndex >= 0 ? e.unitIndex : 0,
276
448
  completionTiming: e.completionTiming,
277
449
  modificationMode: e.modificationMode,
278
- ...r ? { completionDeadline: r } : {},
279
- ...s ? { modificationDeadline: s } : {},
450
+ ...i ? { completionDeadline: i } : {},
451
+ ...d ? { modificationDeadline: d } : {},
280
452
  values: c,
281
- missingFields: z(e.missingFields || [], "missingFields", t),
453
+ missingFields: U(e.missingFields || [], "missingFields", t),
282
454
  complete: e.complete === !0
283
455
  };
284
456
  }
285
457
  });
286
458
  }
287
459
  }
288
- class Xe extends T {
460
+ class At extends h {
289
461
  constructor(o = {}) {
290
462
  super({
291
463
  contractName: "AcquisitionSnapshot",
@@ -311,52 +483,52 @@ class Xe extends T {
311
483
  "evaluated"
312
484
  ],
313
485
  normalize(e, t) {
314
- let i = {};
486
+ let r = {};
315
487
  try {
316
- i = (e.priceEvaluationContext instanceof Te ? e.priceEvaluationContext : new Te(e.priceEvaluationContext)).toObject();
488
+ r = (e.priceEvaluationContext instanceof ve ? e.priceEvaluationContext : new ve(e.priceEvaluationContext)).toObject();
317
489
  } catch (c) {
318
490
  t.push(`priceEvaluationContext: ${c.message}`);
319
491
  }
320
- let r = {};
492
+ let i = {};
321
493
  try {
322
- r = (e.priceScheduleRef instanceof ge ? e.priceScheduleRef : new ge(e.priceScheduleRef)).toObject();
494
+ i = (e.priceScheduleRef instanceof Ue ? e.priceScheduleRef : new Ue(e.priceScheduleRef)).toObject();
323
495
  } catch (c) {
324
496
  t.push(`priceScheduleRef: ${c.message}`);
325
497
  }
326
- const s = (Array.isArray(e.requirementPlans) ? e.requirementPlans : []).flatMap((c, d) => {
498
+ const d = (Array.isArray(e.requirementPlans) ? e.requirementPlans : []).flatMap((c, a) => {
327
499
  try {
328
- return [(c instanceof ee ? c : new ee(c)).toObject()];
329
- } catch (a) {
330
- return t.push(`requirementPlans[${d}]: ${a.message}`), [];
500
+ return [(c instanceof ce ? c : new ce(c)).toObject()];
501
+ } catch (u) {
502
+ return t.push(`requirementPlans[${a}]: ${u.message}`), [];
331
503
  }
332
504
  });
333
505
  return Array.isArray(e.requirementPlans) || t.push("requirementPlans must be an array"), {
334
- id: u(e.id, "id", t),
335
- contractVersion: I(e.contractVersion, "contractVersion", t, 2),
336
- eventRegistrationCode: u(e.eventRegistrationCode, "eventRegistrationCode", t),
337
- purchaserEventRegistrationCode: u(
506
+ id: s(e.id, "id", t),
507
+ contractVersion: f(e.contractVersion, "contractVersion", t, 2),
508
+ eventRegistrationCode: s(e.eventRegistrationCode, "eventRegistrationCode", t),
509
+ purchaserEventRegistrationCode: s(
338
510
  e.purchaserEventRegistrationCode,
339
511
  "purchaserEventRegistrationCode",
340
512
  t
341
513
  ),
342
- payerEventRegistrationCode: u(
514
+ payerEventRegistrationCode: s(
343
515
  e.payerEventRegistrationCode,
344
516
  "payerEventRegistrationCode",
345
517
  t
346
518
  ),
347
- acquisitionSource: u(e.acquisitionSource, "acquisitionSource", t),
519
+ acquisitionSource: s(e.acquisitionSource, "acquisitionSource", t),
348
520
  merchandise: e.merchandise || {},
349
- quantity: I(e.quantity, "quantity", t),
521
+ quantity: f(e.quantity, "quantity", t),
350
522
  products: e.products || [],
351
- priceScheduleRef: r,
523
+ priceScheduleRef: i,
352
524
  matchedPriceRow: e.matchedPriceRow || {},
353
- priceEvaluationContext: i,
525
+ priceEvaluationContext: r,
354
526
  effectiveRules: e.effectiveRules || {},
355
527
  eligibilityDecisions: e.eligibilityDecisions || [],
356
- requirementPlans: s,
528
+ requirementPlans: d,
357
529
  inventoryDecisions: e.inventoryDecisions || [],
358
530
  variantSelections: e.variantSelections || [],
359
- evaluated: u(e.evaluated, "evaluated", t)
531
+ evaluated: s(e.evaluated, "evaluated", t)
360
532
  };
361
533
  }
362
534
  });
@@ -365,103 +537,7 @@ class Xe extends T {
365
537
  return this.id;
366
538
  }
367
539
  }
368
- const Ze = [
369
- "_id",
370
- "_tenant",
371
- "_type",
372
- "id",
373
- "meta",
374
- "metadata",
375
- "remarks",
376
- "tenantCode"
377
- ], Ye = [
378
- "active",
379
- "created",
380
- "creator",
381
- "deleted",
382
- "modified",
383
- "owner",
384
- "revision"
385
- ];
386
- class L extends Ke {
387
- constructor({ contractName: o, object: e, fields: t, normalize: i }) {
388
- var l;
389
- if (!e || typeof e != "object" || Array.isArray(e))
390
- throw new G({ contractName: o, issues: ["input must be an object"] });
391
- xe({ contractName: o, object: e, fields: [...Ze, ...t] });
392
- const r = [], s = u(e.tenantCode, "tenantCode", r);
393
- et(e.meta, r), Ne(e.metadata, "metadata", r), Ne(e.remarks, "remarks", r);
394
- const c = D(Object.fromEntries(t.flatMap((f) => Object.hasOwn(e, f) ? [[f, e[f]]] : []))), d = i(c, r);
395
- if (r.length > 0)
396
- throw new G({ contractName: o, issues: r });
397
- super({ ...e, tenantCode: s });
398
- const a = (l = e.meta) == null ? void 0 : l.revision;
399
- Number.isInteger(a) && a >= 0 && (this.meta.revision = a), this._type = e._type || o, Object.assign(this, d), Object.defineProperty(this, "_storeContractFields", {
400
- configurable: !1,
401
- enumerable: !1,
402
- value: Object.freeze([...t]),
403
- writable: !1
404
- });
405
- }
406
- getId() {
407
- return this.id === null || typeof this.id > "u" ? "" : this.id.toString();
408
- }
409
- toJSON() {
410
- return this.toObject();
411
- }
412
- toObject() {
413
- const o = {
414
- _type: this._type,
415
- meta: De(this.meta, Ye),
416
- metadata: Oe(this.metadata),
417
- remarks: Oe(this.remarks),
418
- tenantCode: this.tenantCode,
419
- ...De(this, this._storeContractFields)
420
- }, e = this.getId();
421
- return e && (o.id = e), D(o);
422
- }
423
- }
424
- function et(n, o) {
425
- if (!(typeof n > "u")) {
426
- if (!n || typeof n != "object" || Array.isArray(n)) {
427
- o.push("meta must be an object");
428
- return;
429
- }
430
- Object.keys(n).forEach((e) => {
431
- Ye.includes(e) || o.push(`meta contains unknown field "${e}"`);
432
- }), ["active", "deleted"].forEach((e) => {
433
- typeof n[e] < "u" && typeof n[e] != "boolean" && o.push(`meta.${e} must be a boolean`);
434
- }), ["created", "modified"].forEach((e) => {
435
- typeof n[e] < "u" && (!Number.isFinite(n[e]) || n[e] < 0) && o.push(`meta.${e} must be a non-negative finite number`);
436
- }), ["creator", "owner"].forEach((e) => {
437
- typeof n[e] < "u" && typeof n[e] != "string" && o.push(`meta.${e} must be a string`);
438
- }), typeof n.revision < "u" && (!Number.isInteger(n.revision) || n.revision < 0) && o.push("meta.revision must be a non-negative integer");
439
- }
440
- }
441
- function Oe(n) {
442
- return Array.isArray(n) ? n.map((o) => ({ key: o.key, value: D(o.value) })) : [];
443
- }
444
- function De(n, o) {
445
- return Object.fromEntries(o.flatMap((e) => typeof n[e] > "u" ? [] : [[e, D(n[e])]]));
446
- }
447
- function Ne(n, o, e) {
448
- if (!(typeof n > "u")) {
449
- if (!Array.isArray(n)) {
450
- e.push(`${o} must be an array`);
451
- return;
452
- }
453
- n.forEach((t, i) => {
454
- if (!t || typeof t != "object" || Array.isArray(t)) {
455
- e.push(`${o}[${i}] must be an object`);
456
- return;
457
- }
458
- Object.keys(t).forEach((r) => {
459
- ["key", "value"].includes(r) || e.push(`${o}[${i}] contains unknown field "${r}"`);
460
- }), u(t.key, `${o}[${i}].key`, e), Object.hasOwn(t, "value") ? D(t.value, `${o}[${i}].value`) : e.push(`${o}[${i}].value is required`);
461
- });
462
- }
463
- }
464
- class Lt extends L {
540
+ class ln extends O {
465
541
  constructor(o = {}) {
466
542
  super({
467
543
  contractName: "Category",
@@ -469,10 +545,10 @@ class Lt extends L {
469
545
  fields: ["categoryCode", "version", "name", "description"],
470
546
  normalize(e, t) {
471
547
  return {
472
- categoryCode: u(e.categoryCode, "categoryCode", t),
473
- version: I(e.version, "version", t),
474
- name: u(e.name, "name", t),
475
- ...M(e.description, "description", t) ? { description: e.description } : {}
548
+ categoryCode: s(e.categoryCode, "categoryCode", t),
549
+ version: f(e.version, "version", t),
550
+ name: s(e.name, "name", t),
551
+ ...N(e.description, "description", t) ? { description: e.description } : {}
476
552
  };
477
553
  }
478
554
  });
@@ -481,20 +557,46 @@ class Lt extends L {
481
557
  return this.categoryCode;
482
558
  }
483
559
  }
484
- class Ut extends L {
560
+ class we extends h {
561
+ constructor(o = {}) {
562
+ super({
563
+ contractName: "CommercialLifecycle",
564
+ object: o,
565
+ fields: ["stateCode", "changed", "reasonCode", "initiatedBy"],
566
+ normalize(e, t) {
567
+ const r = N(e.reasonCode, "reasonCode", t), i = N(e.initiatedBy, "initiatedBy", t);
568
+ return {
569
+ stateCode: s(e.stateCode, "stateCode", t),
570
+ changed: $(e.changed, "changed", t),
571
+ ...r ? { reasonCode: r } : {},
572
+ ...i ? { initiatedBy: i } : {}
573
+ };
574
+ }
575
+ });
576
+ }
577
+ }
578
+ function he(n, o, e, t) {
579
+ try {
580
+ const r = n instanceof we ? n : new we(n);
581
+ return e.includes(r.stateCode) || t.push(`${o}.stateCode "${r.stateCode}" is not supported`), r.toObject();
582
+ } catch (r) {
583
+ return t.push(`${o}: ${r.message}`), { stateCode: "", changed: ae(void 0, o, t) };
584
+ }
585
+ }
586
+ class mn extends O {
485
587
  constructor(o = {}) {
486
588
  super({
487
589
  contractName: "Currency",
488
590
  object: o,
489
591
  fields: ["currencyCode", "name", "symbol", "factor", "unit"],
490
592
  normalize(e, t) {
491
- const i = M(e.symbol, "symbol", t);
593
+ const r = N(e.symbol, "symbol", t);
492
594
  return {
493
- currencyCode: u(e.currencyCode, "currencyCode", t),
494
- name: u(e.name, "name", t),
495
- ...i ? { symbol: i } : {},
496
- factor: I(e.factor, "factor", t),
497
- unit: u(e.unit, "unit", t)
595
+ currencyCode: s(e.currencyCode, "currencyCode", t),
596
+ name: s(e.name, "name", t),
597
+ ...r ? { symbol: r } : {},
598
+ factor: f(e.factor, "factor", t),
599
+ unit: s(e.unit, "unit", t)
498
600
  };
499
601
  }
500
602
  });
@@ -503,7 +605,7 @@ class Ut extends L {
503
605
  return this.currencyCode;
504
606
  }
505
607
  }
506
- class vt extends T {
608
+ class Cn extends h {
507
609
  constructor(o = {}) {
508
610
  super({
509
611
  contractName: "EligibilityFact",
@@ -516,19 +618,120 @@ class vt extends T {
516
618
  "reasonCode"
517
619
  ],
518
620
  normalize(e, t) {
519
- const i = u(e.state, "state", t);
520
- return Object.values(x).includes(i) || t.push(`state "${i}" is not supported`), (!Number.isInteger(e.revision) || e.revision < 0) && t.push("revision must be a non-negative integer"), {
521
- eligibilityType: u(e.eligibilityType, "eligibilityType", t),
522
- state: i,
621
+ const r = s(e.state, "state", t);
622
+ return Object.values(Y).includes(r) || t.push(`state "${r}" is not supported`), (!Number.isInteger(e.revision) || e.revision < 0) && t.push("revision must be a non-negative integer"), {
623
+ eligibilityType: s(e.eligibilityType, "eligibilityType", t),
624
+ state: r,
523
625
  revision: Number.isInteger(e.revision) && e.revision >= 0 ? e.revision : 0,
524
- ...M(e.decisionReference, "decisionReference", t) ? { decisionReference: e.decisionReference } : {},
525
- ...M(e.reasonCode, "reasonCode", t) ? { reasonCode: e.reasonCode } : {}
626
+ ...N(e.decisionReference, "decisionReference", t) ? { decisionReference: e.decisionReference } : {},
627
+ ...N(e.reasonCode, "reasonCode", t) ? { reasonCode: e.reasonCode } : {}
628
+ };
629
+ }
630
+ });
631
+ }
632
+ }
633
+ class fn extends O {
634
+ constructor(o = {}) {
635
+ super({
636
+ contractName: "InventoryBalance",
637
+ object: o,
638
+ fields: ["inventoryBalanceCode", "inventoryPoolCode", "productCode", "variantCode", "capacity", "heldQuantity", "consumedQuantity"],
639
+ normalize(e, t) {
640
+ const r = N(e.variantCode, "variantCode", t), i = e.capacity === null ? null : oe(e.capacity, "capacity", t), d = oe(e.heldQuantity, "heldQuantity", t), c = oe(e.consumedQuantity, "consumedQuantity", t);
641
+ return i !== null && d + c > i && t.push("heldQuantity plus consumedQuantity must not exceed capacity"), {
642
+ inventoryBalanceCode: s(e.inventoryBalanceCode, "inventoryBalanceCode", t),
643
+ inventoryPoolCode: s(e.inventoryPoolCode, "inventoryPoolCode", t),
644
+ productCode: s(e.productCode, "productCode", t),
645
+ ...r ? { variantCode: r } : {},
646
+ capacity: i,
647
+ heldQuantity: d,
648
+ consumedQuantity: c
649
+ };
650
+ }
651
+ });
652
+ }
653
+ getCode() {
654
+ return this.inventoryBalanceCode;
655
+ }
656
+ }
657
+ const Ot = Object.freeze({ HELD: "HELD", CONSUMED: "CONSUMED", RELEASED: "RELEASED" });
658
+ class En extends O {
659
+ constructor(o = {}) {
660
+ super({
661
+ contractName: "InventoryLedgerEntry",
662
+ object: o,
663
+ fields: ["inventoryLedgerEntryCode", "inventoryBalanceCode", "reservationCode", "orderCode", "action", "quantity", "occurred"],
664
+ normalize(e, t) {
665
+ const r = s(e.action, "action", t);
666
+ Object.values(Ot).includes(r) || t.push(`action "${r}" is not supported`);
667
+ const i = N(e.orderCode, "orderCode", t);
668
+ return {
669
+ inventoryLedgerEntryCode: s(e.inventoryLedgerEntryCode, "inventoryLedgerEntryCode", t),
670
+ inventoryBalanceCode: s(e.inventoryBalanceCode, "inventoryBalanceCode", t),
671
+ reservationCode: s(e.reservationCode, "reservationCode", t),
672
+ ...i ? { orderCode: i } : {},
673
+ action: r,
674
+ quantity: f(e.quantity, "quantity", t),
675
+ occurred: $(e.occurred, "occurred", t)
676
+ };
677
+ }
678
+ });
679
+ }
680
+ getCode() {
681
+ return this.inventoryLedgerEntryCode;
682
+ }
683
+ }
684
+ class yn extends O {
685
+ constructor(o = {}) {
686
+ super({
687
+ contractName: "Invoice",
688
+ object: o,
689
+ fields: ["invoiceCode", "invoiceNumber", "orderCode", "currentRevisionCode", "currentRevisionNumber", "issued"],
690
+ normalize(e, t) {
691
+ return {
692
+ invoiceCode: s(e.invoiceCode, "invoiceCode", t),
693
+ invoiceNumber: s(e.invoiceNumber, "invoiceNumber", t),
694
+ orderCode: s(e.orderCode, "orderCode", t),
695
+ currentRevisionCode: s(e.currentRevisionCode, "currentRevisionCode", t),
696
+ currentRevisionNumber: f(e.currentRevisionNumber, "currentRevisionNumber", t),
697
+ issued: $(e.issued, "issued", t)
526
698
  };
527
699
  }
528
700
  });
529
701
  }
702
+ getCode() {
703
+ return this.invoiceCode;
704
+ }
530
705
  }
531
- class Ae extends T {
706
+ class Rn extends O {
707
+ constructor(o = {}) {
708
+ super({
709
+ contractName: "InvoiceRevision",
710
+ object: o,
711
+ fields: ["invoiceRevisionCode", "invoiceCode", "revisionNumber", "currency", "amount", "issuer", "billTo", "lines", "instructions", "issued", "due"],
712
+ normalize(e, t) {
713
+ const r = ae(e.due, "due", t);
714
+ return {
715
+ invoiceRevisionCode: s(e.invoiceRevisionCode, "invoiceRevisionCode", t),
716
+ invoiceCode: s(e.invoiceCode, "invoiceCode", t),
717
+ revisionNumber: f(e.revisionNumber, "revisionNumber", t),
718
+ currency: s(e.currency, "currency", t),
719
+ amount: x(e.amount, "amount", t),
720
+ issuer: B(e.issuer, "issuer", t),
721
+ billTo: B(e.billTo, "billTo", t),
722
+ lines: Z(e.lines, "lines", t),
723
+ instructions: B(e.instructions || {}, "instructions", t),
724
+ issued: $(e.issued, "issued", t),
725
+ ...r ? { due: r } : {}
726
+ };
727
+ }
728
+ });
729
+ }
730
+ getCode() {
731
+ return this.invoiceRevisionCode;
732
+ }
733
+ }
734
+ class je extends h {
532
735
  constructor(o = {}) {
533
736
  super({
534
737
  contractName: "MerchandiseComponent",
@@ -536,34 +739,34 @@ class Ae extends T {
536
739
  fields: ["productCode", "productVersion", "quantityPerUnit"],
537
740
  normalize(e, t) {
538
741
  return {
539
- productCode: u(e.productCode, "productCode", t),
540
- productVersion: I(e.productVersion, "productVersion", t),
541
- quantityPerUnit: I(e.quantityPerUnit, "quantityPerUnit", t)
742
+ productCode: s(e.productCode, "productCode", t),
743
+ productVersion: f(e.productVersion, "productVersion", t),
744
+ quantityPerUnit: f(e.quantityPerUnit, "quantityPerUnit", t)
542
745
  };
543
746
  }
544
747
  });
545
748
  }
546
749
  }
547
- class wt extends L {
750
+ class hn extends O {
548
751
  constructor(o = {}) {
549
752
  super({
550
753
  contractName: "Merchandise",
551
754
  object: o,
552
755
  fields: ["merchandiseCode", "version", "name", "description", "components", "priceScheduleCode"],
553
756
  normalize(e, t) {
554
- let i = [];
757
+ let r = [];
555
758
  try {
556
- i = (e.components || []).map((r) => (r instanceof Ae ? r : new Ae(r)).toObject());
557
- } catch (r) {
558
- t.push(`components: ${r.message}`);
759
+ r = (e.components || []).map((i) => (i instanceof je ? i : new je(i)).toObject());
760
+ } catch (i) {
761
+ t.push(`components: ${i.message}`);
559
762
  }
560
- return i.length === 0 && t.push("components must contain at least one component"), {
561
- merchandiseCode: u(e.merchandiseCode, "merchandiseCode", t),
562
- version: I(e.version, "version", t),
563
- name: u(e.name, "name", t),
564
- ...M(e.description, "description", t) ? { description: e.description } : {},
565
- components: i,
566
- priceScheduleCode: u(e.priceScheduleCode, "priceScheduleCode", t)
763
+ return r.length === 0 && t.push("components must contain at least one component"), {
764
+ merchandiseCode: s(e.merchandiseCode, "merchandiseCode", t),
765
+ version: f(e.version, "version", t),
766
+ name: s(e.name, "name", t),
767
+ ...N(e.description, "description", t) ? { description: e.description } : {},
768
+ components: r,
769
+ priceScheduleCode: s(e.priceScheduleCode, "priceScheduleCode", t)
567
770
  };
568
771
  }
569
772
  });
@@ -572,47 +775,227 @@ class wt extends L {
572
775
  return this.merchandiseCode;
573
776
  }
574
777
  }
575
- function Se(n, o, e) {
778
+ class xe extends h {
779
+ constructor(o = {}) {
780
+ super({
781
+ contractName: "OrderLine",
782
+ object: o,
783
+ fields: ["orderLineCode", "merchandiseCode", "merchandiseVersion", "quantity", "currency", "unitAmount", "totalAmount", "products", "commercialDecision"],
784
+ normalize(e, t) {
785
+ return {
786
+ orderLineCode: s(e.orderLineCode, "orderLineCode", t),
787
+ merchandiseCode: s(e.merchandiseCode, "merchandiseCode", t),
788
+ merchandiseVersion: f(e.merchandiseVersion, "merchandiseVersion", t),
789
+ quantity: f(e.quantity, "quantity", t),
790
+ currency: s(e.currency, "currency", t),
791
+ unitAmount: x(e.unitAmount, "unitAmount", t),
792
+ totalAmount: x(e.totalAmount, "totalAmount", t),
793
+ products: Z(e.products, "products", t),
794
+ commercialDecision: B(e.commercialDecision, "commercialDecision", t)
795
+ };
796
+ }
797
+ });
798
+ }
799
+ }
800
+ class ze extends h {
801
+ constructor(o = {}) {
802
+ super({
803
+ contractName: "Reservation",
804
+ object: o,
805
+ fields: ["reservationCode", "lifecycle", "heldUntil", "inventoryCommitments"],
806
+ normalize(e, t) {
807
+ const r = ae(e.heldUntil, "heldUntil", t);
808
+ return {
809
+ reservationCode: s(e.reservationCode, "reservationCode", t),
810
+ lifecycle: he(e.lifecycle, "lifecycle", Object.values(It), t),
811
+ ...r ? { heldUntil: r } : {},
812
+ inventoryCommitments: Z(e.inventoryCommitments, "inventoryCommitments", t)
813
+ };
814
+ }
815
+ });
816
+ }
817
+ }
818
+ class In extends O {
819
+ constructor(o = {}) {
820
+ super({
821
+ contractName: "Order",
822
+ object: o,
823
+ fields: ["orderCode", "submissionCode", "eventRegistrationCode", "purchaserEventRegistrationCode", "payerEventRegistrationCode", "currency", "amount", "catalogDecisionRevision", "lines", "lifecycle", "reservation", "invoiceCode", "paymentAttemptCodes", "settlementCode", "acquisitionCodes", "submitted"],
824
+ normalize(e, t) {
825
+ const r = (Array.isArray(e.lines) ? e.lines : []).flatMap((c, a) => {
826
+ try {
827
+ return [(c instanceof xe ? c : new xe(c)).toObject()];
828
+ } catch (u) {
829
+ return t.push(`lines[${a}]: ${u.message}`), [];
830
+ }
831
+ });
832
+ r.length === 0 && t.push("lines must contain at least one line");
833
+ let i = {};
834
+ try {
835
+ i = (e.reservation instanceof ze ? e.reservation : new ze(e.reservation)).toObject();
836
+ } catch (c) {
837
+ t.push(`reservation: ${c.message}`);
838
+ }
839
+ const d = N(e.settlementCode, "settlementCode", t);
840
+ return {
841
+ orderCode: s(e.orderCode, "orderCode", t),
842
+ submissionCode: s(e.submissionCode, "submissionCode", t),
843
+ eventRegistrationCode: s(e.eventRegistrationCode, "eventRegistrationCode", t),
844
+ purchaserEventRegistrationCode: s(e.purchaserEventRegistrationCode, "purchaserEventRegistrationCode", t),
845
+ payerEventRegistrationCode: s(e.payerEventRegistrationCode, "payerEventRegistrationCode", t),
846
+ currency: s(e.currency, "currency", t),
847
+ amount: x(e.amount, "amount", t),
848
+ catalogDecisionRevision: s(e.catalogDecisionRevision, "catalogDecisionRevision", t),
849
+ lines: r,
850
+ lifecycle: he(e.lifecycle, "lifecycle", Object.values(ht), t),
851
+ reservation: i,
852
+ invoiceCode: s(e.invoiceCode, "invoiceCode", t),
853
+ paymentAttemptCodes: U(e.paymentAttemptCodes || [], "paymentAttemptCodes", t),
854
+ ...d ? { settlementCode: d } : {},
855
+ acquisitionCodes: U(e.acquisitionCodes || [], "acquisitionCodes", t),
856
+ submitted: $(e.submitted, "submitted", t)
857
+ };
858
+ }
859
+ });
860
+ }
861
+ getCode() {
862
+ return this.orderCode;
863
+ }
864
+ }
865
+ function St({ paymentAttemptMeta: n, salesPeriodEnd: o }) {
866
+ const e = it(n), t = dt(o, "salesPeriodEnd");
867
+ return e < t;
868
+ }
869
+ function Qe({ paymentAttemptMeta: n, defaultPaymentDuration: o }) {
870
+ const e = it(n);
871
+ if (!Number.isInteger(o) || o <= 0)
872
+ throw new TypeError("defaultPaymentDuration must be a positive integer in milliseconds");
873
+ return new Date(e + o).toISOString();
874
+ }
875
+ function it(n) {
876
+ if (!n || typeof n != "object")
877
+ throw new TypeError("paymentAttemptMeta must be an object");
878
+ return dt(n.created, "paymentAttemptMeta.created");
879
+ }
880
+ function dt(n, o) {
881
+ const e = typeof n == "number" ? n : Date.parse(n);
882
+ if (!Number.isFinite(e) || e < 0)
883
+ throw new TypeError(`${o} must be an ISO-compatible timestamp`);
884
+ return e;
885
+ }
886
+ class Be extends h {
887
+ constructor(o = {}) {
888
+ super({
889
+ contractName: "PaymentMethodConfigurationSnapshot",
890
+ object: o,
891
+ fields: ["paymentMethodCode", "version", "adapterCode", "display", "supportedCurrencyCodes", "defaultPaymentDuration", "integrationBindingCode"],
892
+ normalize(e, t) {
893
+ const r = oe(e.defaultPaymentDuration, "defaultPaymentDuration", t);
894
+ return r === 0 && t.push("defaultPaymentDuration must be greater than zero"), {
895
+ paymentMethodCode: s(e.paymentMethodCode, "paymentMethodCode", t),
896
+ version: f(e.version, "version", t),
897
+ adapterCode: s(e.adapterCode, "adapterCode", t),
898
+ display: B(e.display, "display", t),
899
+ supportedCurrencyCodes: U(e.supportedCurrencyCodes, "supportedCurrencyCodes", t),
900
+ defaultPaymentDuration: r,
901
+ integrationBindingCode: s(e.integrationBindingCode, "integrationBindingCode", t)
902
+ };
903
+ }
904
+ });
905
+ }
906
+ }
907
+ class Tn extends O {
908
+ constructor(o = {}) {
909
+ super({
910
+ contractName: "PaymentAttempt",
911
+ object: o,
912
+ fields: ["paymentAttemptCode", "orderCode", "invoiceCode", "invoiceRevisionCode", "currency", "amount", "paymentMethodConfigurationSnapshot", "matchedCommercialDecision", "paymentDeadline", "lifecycle", "providerReference", "providerSession", "providerState", "providerOutcomeTime"],
913
+ normalize(e, t, { meta: r }) {
914
+ let i = {};
915
+ try {
916
+ i = (e.paymentMethodConfigurationSnapshot instanceof Be ? e.paymentMethodConfigurationSnapshot : new Be(e.paymentMethodConfigurationSnapshot)).toObject();
917
+ } catch (m) {
918
+ t.push(`paymentMethodConfigurationSnapshot: ${m.message}`);
919
+ }
920
+ let d = "";
921
+ try {
922
+ d = i.defaultPaymentDuration ? Qe({ paymentAttemptMeta: r, defaultPaymentDuration: i.defaultPaymentDuration }) : "";
923
+ } catch (m) {
924
+ t.push(m.message);
925
+ }
926
+ const c = $(e.paymentDeadline, "paymentDeadline", t);
927
+ d && c !== d && t.push("paymentDeadline must equal meta.created plus paymentMethodConfigurationSnapshot.defaultPaymentDuration");
928
+ const a = N(e.providerReference, "providerReference", t), u = N(e.providerState, "providerState", t), l = ae(e.providerOutcomeTime, "providerOutcomeTime", t);
929
+ return {
930
+ paymentAttemptCode: s(e.paymentAttemptCode, "paymentAttemptCode", t),
931
+ orderCode: s(e.orderCode, "orderCode", t),
932
+ invoiceCode: s(e.invoiceCode, "invoiceCode", t),
933
+ invoiceRevisionCode: s(e.invoiceRevisionCode, "invoiceRevisionCode", t),
934
+ currency: s(e.currency, "currency", t),
935
+ amount: x(e.amount, "amount", t),
936
+ paymentMethodConfigurationSnapshot: i,
937
+ matchedCommercialDecision: B(e.matchedCommercialDecision, "matchedCommercialDecision", t),
938
+ paymentDeadline: c,
939
+ lifecycle: he(e.lifecycle, "lifecycle", Object.values(Tt), t),
940
+ ...a ? { providerReference: a } : {},
941
+ providerSession: B(e.providerSession || {}, "providerSession", t),
942
+ ...u ? { providerState: u } : {},
943
+ ...l ? { providerOutcomeTime: l } : {}
944
+ };
945
+ }
946
+ });
947
+ }
948
+ getCode() {
949
+ return this.paymentAttemptCode;
950
+ }
951
+ static canStart(o) {
952
+ return St(o);
953
+ }
954
+ static calculateDeadline(o) {
955
+ return Qe(o);
956
+ }
957
+ }
958
+ function Ye(n, o, e) {
576
959
  if (!(typeof n > "u" || n === null))
577
- return I(n, o, e);
960
+ return f(n, o, e);
578
961
  }
579
- class Pe extends T {
962
+ class Fe extends h {
580
963
  constructor(o = {}) {
581
964
  super({
582
965
  contractName: "PriceMatchCriteria",
583
966
  object: o,
584
967
  fields: ["countryCodes", "excludedCountryCodes", "countryRank"],
585
968
  normalize(e, t) {
586
- const i = z(e.countryCodes || [], "countryCodes", t), r = z(
969
+ const r = U(e.countryCodes || [], "countryCodes", t), i = U(
587
970
  e.excludedCountryCodes || [],
588
971
  "excludedCountryCodes",
589
972
  t
590
- ), s = i.filter((d) => r.includes(d));
591
- s.length > 0 && t.push(
592
- `countryCodes and excludedCountryCodes overlap: ${[...new Set(s)].join(", ")}`
973
+ ), d = r.filter((a) => i.includes(a));
974
+ d.length > 0 && t.push(
975
+ `countryCodes and excludedCountryCodes overlap: ${[...new Set(d)].join(", ")}`
593
976
  );
594
977
  let c;
595
978
  if (typeof e.countryRank < "u" && e.countryRank !== null)
596
979
  if (typeof e.countryRank != "object" || Array.isArray(e.countryRank))
597
980
  t.push("countryRank must be an object");
598
981
  else {
599
- Object.keys(e.countryRank).filter((f) => !["min", "max"].includes(f)).forEach((f) => t.push(`countryRank contains unknown field "${f}"`));
600
- const a = Se(e.countryRank.min, "countryRank.min", t), l = Se(e.countryRank.max, "countryRank.max", t);
601
- typeof a > "u" && typeof l > "u" && t.push("countryRank must contain min or max"), a && l && a > l && t.push("countryRank.max must be greater than or equal to countryRank.min"), c = {
602
- ...a ? { min: a } : {},
982
+ Object.keys(e.countryRank).filter((m) => !["min", "max"].includes(m)).forEach((m) => t.push(`countryRank contains unknown field "${m}"`));
983
+ const u = Ye(e.countryRank.min, "countryRank.min", t), l = Ye(e.countryRank.max, "countryRank.max", t);
984
+ typeof u > "u" && typeof l > "u" && t.push("countryRank must contain min or max"), u && l && u > l && t.push("countryRank.max must be greater than or equal to countryRank.min"), c = {
985
+ ...u ? { min: u } : {},
603
986
  ...l ? { max: l } : {}
604
987
  };
605
988
  }
606
989
  return {
607
- countryCodes: i,
608
- excludedCountryCodes: r,
990
+ countryCodes: r,
991
+ excludedCountryCodes: i,
609
992
  ...c ? { countryRank: c } : {}
610
993
  };
611
994
  }
612
995
  });
613
996
  }
614
997
  }
615
- class _e extends T {
998
+ class ke extends h {
616
999
  constructor(o = {}) {
617
1000
  super({
618
1001
  contractName: "SalesPeriodRef",
@@ -620,20 +1003,20 @@ class _e extends T {
620
1003
  fields: ["salesPeriodCode", "salesPeriodVersion"],
621
1004
  normalize(e, t) {
622
1005
  return {
623
- salesPeriodCode: u(e.salesPeriodCode, "salesPeriodCode", t),
624
- salesPeriodVersion: I(e.salesPeriodVersion, "salesPeriodVersion", t)
1006
+ salesPeriodCode: s(e.salesPeriodCode, "salesPeriodCode", t),
1007
+ salesPeriodVersion: f(e.salesPeriodVersion, "salesPeriodVersion", t)
625
1008
  };
626
1009
  }
627
1010
  });
628
1011
  }
629
1012
  }
630
- function Ve(n, o, e) {
1013
+ function We(n, o, e) {
631
1014
  if (typeof n > "u" || n === null)
632
1015
  return;
633
- const t = M(n, o, e);
1016
+ const t = N(n, o, e);
634
1017
  return t && !Number.isFinite(Date.parse(t)) && e.push(`${o} must be an ISO-compatible timestamp`), t;
635
1018
  }
636
- class Me extends T {
1019
+ class Ge extends h {
637
1020
  constructor(o = {}) {
638
1021
  super({
639
1022
  contractName: "PriceRow",
@@ -649,54 +1032,52 @@ class Me extends T {
649
1032
  "acquisitionSources"
650
1033
  ],
651
1034
  normalize(e, t) {
652
- const i = Ve(e.validFrom, "validFrom", t), r = Ve(e.validUntil, "validUntil", t);
653
- i && r && Date.parse(i) >= Date.parse(r) && t.push("validUntil must be later than validFrom");
654
- let s;
655
- if (e.salesPeriodRef !== null && typeof e.salesPeriodRef < "u") {
1035
+ const r = We(e.validFrom, "validFrom", t), i = We(e.validUntil, "validUntil", t);
1036
+ r && i && Date.parse(r) >= Date.parse(i) && t.push("validUntil must be later than validFrom");
1037
+ let d;
1038
+ if (e.salesPeriodRef !== null && typeof e.salesPeriodRef < "u")
656
1039
  try {
657
- s = (e.salesPeriodRef instanceof _e ? e.salesPeriodRef : new _e(e.salesPeriodRef)).toObject();
658
- } catch (d) {
659
- t.push(`salesPeriodRef: ${d.message}`);
1040
+ d = (e.salesPeriodRef instanceof ke ? e.salesPeriodRef : new ke(e.salesPeriodRef)).toObject();
1041
+ } catch (a) {
1042
+ t.push(`salesPeriodRef: ${a.message}`);
660
1043
  }
661
- (!i || !r) && t.push("salesPeriodRef requires validFrom and validUntil snapshots");
662
- }
663
1044
  let c = {};
664
1045
  try {
665
- c = (e.match instanceof Pe ? e.match : new Pe(e.match || {})).toObject();
666
- } catch (d) {
667
- t.push(`match: ${d.message}`);
1046
+ c = (e.match instanceof Fe ? e.match : new Fe(e.match || {})).toObject();
1047
+ } catch (a) {
1048
+ t.push(`match: ${a.message}`);
668
1049
  }
669
1050
  return {
670
- priceRowCode: u(e.priceRowCode, "priceRowCode", t),
671
- currency: u(e.currency, "currency", t),
672
- amount: He(e.amount, "amount", t),
1051
+ priceRowCode: s(e.priceRowCode, "priceRowCode", t),
1052
+ currency: s(e.currency, "currency", t),
1053
+ amount: x(e.amount, "amount", t),
673
1054
  match: c,
674
- ...s ? { salesPeriodRef: s } : {},
675
- ...i ? { validFrom: i } : {},
676
- ...r ? { validUntil: r } : {},
677
- acquisitionSources: z(e.acquisitionSources || [], "acquisitionSources", t)
1055
+ ...d ? { salesPeriodRef: d } : {},
1056
+ ...r ? { validFrom: r } : {},
1057
+ ...i ? { validUntil: i } : {},
1058
+ acquisitionSources: U(e.acquisitionSources || [], "acquisitionSources", t)
678
1059
  };
679
1060
  }
680
1061
  });
681
1062
  }
682
1063
  }
683
- class jt extends L {
1064
+ class gn extends O {
684
1065
  constructor(o = {}) {
685
1066
  super({
686
1067
  contractName: "PriceSchedule",
687
1068
  object: o,
688
1069
  fields: ["priceScheduleCode", "version", "rows"],
689
1070
  normalize(e, t) {
690
- let i = [];
1071
+ let r = [];
691
1072
  try {
692
- i = (e.rows || []).map((r) => (r instanceof Me ? r : new Me(r)).toObject());
693
- } catch (r) {
694
- t.push(`rows: ${r.message}`);
1073
+ r = (e.rows || []).map((i) => (i instanceof Ge ? i : new Ge(i)).toObject());
1074
+ } catch (i) {
1075
+ t.push(`rows: ${i.message}`);
695
1076
  }
696
- return i.length === 0 && t.push("rows must contain at least one row"), {
697
- priceScheduleCode: u(e.priceScheduleCode, "priceScheduleCode", t),
698
- version: I(e.version, "version", t),
699
- rows: i
1077
+ return r.length === 0 && t.push("rows must contain at least one row"), {
1078
+ priceScheduleCode: s(e.priceScheduleCode, "priceScheduleCode", t),
1079
+ version: f(e.version, "version", t),
1080
+ rows: r
700
1081
  };
701
1082
  }
702
1083
  });
@@ -705,7 +1086,7 @@ class jt extends L {
705
1086
  return this.priceScheduleCode;
706
1087
  }
707
1088
  }
708
- class xt extends L {
1089
+ class bn extends O {
709
1090
  constructor(o = {}) {
710
1091
  super({
711
1092
  contractName: "Product",
@@ -713,11 +1094,11 @@ class xt extends L {
713
1094
  fields: ["productCode", "version", "name", "description", "categoryCodes"],
714
1095
  normalize(e, t) {
715
1096
  return {
716
- productCode: u(e.productCode, "productCode", t),
717
- version: I(e.version, "version", t),
718
- name: u(e.name, "name", t),
719
- ...M(e.description, "description", t) ? { description: e.description } : {},
720
- categoryCodes: z(e.categoryCodes || [], "categoryCodes", t)
1097
+ productCode: s(e.productCode, "productCode", t),
1098
+ version: f(e.version, "version", t),
1099
+ name: s(e.name, "name", t),
1100
+ ...N(e.description, "description", t) ? { description: e.description } : {},
1101
+ categoryCodes: U(e.categoryCodes || [], "categoryCodes", t)
721
1102
  };
722
1103
  }
723
1104
  });
@@ -726,43 +1107,43 @@ class xt extends L {
726
1107
  return this.productCode;
727
1108
  }
728
1109
  }
729
- class tt extends T {
1110
+ class Pt extends h {
730
1111
  constructor(o = {}) {
731
1112
  super({
732
1113
  contractName: "EligibilityRuleDetails",
733
1114
  object: o,
734
1115
  fields: ["acceptedStates", "eligibilityType"],
735
1116
  normalize(e, t) {
736
- const i = z(e.acceptedStates || [], "acceptedStates", t);
737
- return i.length === 0 && t.push("acceptedStates must contain at least one state"), ze({
738
- values: i,
739
- allowedValues: Object.values(x),
1117
+ const r = U(e.acceptedStates || [], "acceptedStates", t);
1118
+ return r.length === 0 && t.push("acceptedStates must contain at least one state"), rt({
1119
+ values: r,
1120
+ allowedValues: Object.values(Y),
740
1121
  path: "acceptedStates",
741
1122
  issues: t
742
1123
  }), {
743
- eligibilityType: u(e.eligibilityType, "eligibilityType", t),
744
- acceptedStates: i
1124
+ eligibilityType: s(e.eligibilityType, "eligibilityType", t),
1125
+ acceptedStates: r
745
1126
  };
746
1127
  }
747
1128
  });
748
1129
  }
749
1130
  }
750
- class nt extends T {
1131
+ class _t extends h {
751
1132
  constructor(o = {}) {
752
1133
  super({
753
1134
  contractName: "InventoryRuleDetails",
754
1135
  object: o,
755
1136
  fields: ["inventoryMode", "inventoryPoolCode"],
756
1137
  normalize(e, t) {
757
- return Object.values(se).includes(e.inventoryMode) || t.push(`inventoryMode "${e.inventoryMode}" is not supported`), {
1138
+ return Object.values(Ee).includes(e.inventoryMode) || t.push(`inventoryMode "${e.inventoryMode}" is not supported`), {
758
1139
  inventoryMode: e.inventoryMode,
759
- inventoryPoolCode: u(e.inventoryPoolCode, "inventoryPoolCode", t)
1140
+ inventoryPoolCode: s(e.inventoryPoolCode, "inventoryPoolCode", t)
760
1141
  };
761
1142
  }
762
1143
  });
763
1144
  }
764
1145
  }
765
- class ot extends T {
1146
+ class Mt extends h {
766
1147
  constructor(o = {}) {
767
1148
  super({
768
1149
  contractName: "PrerequisiteRuleDetails",
@@ -770,46 +1151,46 @@ class ot extends T {
770
1151
  fields: ["continuous", "evidenceSources", "matchMode", "requires"],
771
1152
  normalize(e, t) {
772
1153
  (!Array.isArray(e.requires) || e.requires.length === 0) && t.push("requires must contain at least one target");
773
- const i = (e.requires || []).map((s, c) => {
1154
+ const r = (e.requires || []).map((d, c) => {
774
1155
  try {
775
- return Je(s, `requires[${c}]`, t, Object.values(_));
776
- } catch (d) {
777
- return t.push(`requires[${c}]: ${d.message}`), {};
1156
+ return Nt(d, `requires[${c}]`, t, Object.values(M));
1157
+ } catch (a) {
1158
+ return t.push(`requires[${c}]: ${a.message}`), {};
778
1159
  }
779
1160
  });
780
- Object.values(ce).includes(e.matchMode) || t.push(`matchMode "${e.matchMode}" is not supported`);
781
- const r = z(e.evidenceSources || [], "evidenceSources", t);
782
- return ze({
783
- values: r,
784
- allowedValues: Object.values(k),
1161
+ Object.values(ye).includes(e.matchMode) || t.push(`matchMode "${e.matchMode}" is not supported`);
1162
+ const i = U(e.evidenceSources || [], "evidenceSources", t);
1163
+ return rt({
1164
+ values: i,
1165
+ allowedValues: Object.values(K),
785
1166
  path: "evidenceSources",
786
1167
  issues: t
787
1168
  }), {
788
- requires: i,
1169
+ requires: r,
789
1170
  matchMode: e.matchMode,
790
- evidenceSources: r,
1171
+ evidenceSources: i,
791
1172
  continuous: e.continuous === !0
792
1173
  };
793
1174
  }
794
1175
  });
795
1176
  }
796
1177
  }
797
- class it extends T {
1178
+ class qt extends h {
798
1179
  constructor(o = {}) {
799
1180
  super({
800
1181
  contractName: "QuantityRuleDetails",
801
1182
  object: o,
802
1183
  fields: ["limit", "limitType"],
803
1184
  normalize(e, t) {
804
- return Object.values(K).includes(e.limitType) || t.push(`limitType "${e.limitType}" is not supported`), {
1185
+ return Object.values(ee).includes(e.limitType) || t.push(`limitType "${e.limitType}" is not supported`), {
805
1186
  limitType: e.limitType,
806
- limit: I(e.limit, "limit", t)
1187
+ limit: f(e.limit, "limit", t)
807
1188
  };
808
1189
  }
809
1190
  });
810
1191
  }
811
1192
  }
812
- class qe extends T {
1193
+ class He extends h {
813
1194
  constructor(o = {}) {
814
1195
  super({
815
1196
  contractName: "RefundPolicyRef",
@@ -817,14 +1198,14 @@ class qe extends T {
817
1198
  fields: ["refundPolicyCode", "refundPolicyVersion"],
818
1199
  normalize(e, t) {
819
1200
  return {
820
- refundPolicyCode: u(e.refundPolicyCode, "refundPolicyCode", t),
821
- refundPolicyVersion: I(e.refundPolicyVersion, "refundPolicyVersion", t)
1201
+ refundPolicyCode: s(e.refundPolicyCode, "refundPolicyCode", t),
1202
+ refundPolicyVersion: f(e.refundPolicyVersion, "refundPolicyVersion", t)
822
1203
  };
823
1204
  }
824
1205
  });
825
1206
  }
826
1207
  }
827
- class rt extends T {
1208
+ class Lt extends h {
828
1209
  constructor(o = {}) {
829
1210
  super({
830
1211
  contractName: "RefundRuleDetails",
@@ -832,15 +1213,15 @@ class rt extends T {
832
1213
  fields: ["refundPolicyRef"],
833
1214
  normalize(e, t) {
834
1215
  try {
835
- return { refundPolicyRef: (e.refundPolicyRef instanceof qe ? e.refundPolicyRef : new qe(e.refundPolicyRef)).toObject() };
836
- } catch (i) {
837
- return t.push(`refundPolicyRef: ${i.message}`), { refundPolicyRef: {} };
1216
+ return { refundPolicyRef: (e.refundPolicyRef instanceof He ? e.refundPolicyRef : new He(e.refundPolicyRef)).toObject() };
1217
+ } catch (r) {
1218
+ return t.push(`refundPolicyRef: ${r.message}`), { refundPolicyRef: {} };
838
1219
  }
839
1220
  }
840
1221
  });
841
1222
  }
842
1223
  }
843
- class st extends T {
1224
+ class Vt extends h {
844
1225
  constructor(o = {}) {
845
1226
  super({
846
1227
  contractName: "RequirementRuleDetails",
@@ -853,48 +1234,48 @@ class st extends T {
853
1234
  "requirement"
854
1235
  ],
855
1236
  normalize(e, t) {
856
- let i = {};
1237
+ let r = {};
857
1238
  try {
858
- i = (e.requirement instanceof X ? e.requirement : new X(e.requirement)).toObject();
1239
+ r = (e.requirement instanceof ie ? e.requirement : new ie(e.requirement)).toObject();
859
1240
  } catch (c) {
860
1241
  t.push(`requirement: ${c.message}`);
861
1242
  }
862
- Object.values(de).includes(e.completionTiming) || t.push(`completionTiming "${e.completionTiming}" is not supported`), Object.values(Q).includes(e.modificationMode) || t.push(`modificationMode "${e.modificationMode}" is not supported`);
863
- const r = Z(e.completionDeadline, "completionDeadline", t), s = Z(e.modificationDeadline, "modificationDeadline", t);
864
- return e.modificationMode === Q.UNTIL_DEADLINE && !s && t.push("modificationDeadline is required when modificationMode is UNTIL_DEADLINE"), e.modificationMode !== Q.UNTIL_DEADLINE && s && t.push("modificationDeadline is only supported when modificationMode is UNTIL_DEADLINE"), {
865
- requirement: i,
1243
+ Object.values(Re).includes(e.completionTiming) || t.push(`completionTiming "${e.completionTiming}" is not supported`), Object.values(j).includes(e.modificationMode) || t.push(`modificationMode "${e.modificationMode}" is not supported`);
1244
+ const i = de(e.completionDeadline, "completionDeadline", t), d = de(e.modificationDeadline, "modificationDeadline", t);
1245
+ return e.modificationMode === j.UNTIL_DEADLINE && !d && t.push("modificationDeadline is required when modificationMode is UNTIL_DEADLINE"), e.modificationMode !== j.UNTIL_DEADLINE && d && t.push("modificationDeadline is only supported when modificationMode is UNTIL_DEADLINE"), {
1246
+ requirement: r,
866
1247
  completionTiming: e.completionTiming,
867
1248
  modificationMode: e.modificationMode,
868
- ...r ? { completionDeadline: r } : {},
869
- ...s ? { modificationDeadline: s } : {}
1249
+ ...i ? { completionDeadline: i } : {},
1250
+ ...d ? { modificationDeadline: d } : {}
870
1251
  };
871
1252
  }
872
1253
  });
873
1254
  }
874
1255
  }
875
- const ct = Object.freeze({
876
- [S.ELIGIBILITY]: tt,
877
- [S.INVENTORY]: nt,
878
- [S.PREREQUISITE]: ot,
879
- [S.QUANTITY]: it,
880
- [S.REFUND]: rt,
881
- [S.REQUIREMENT]: st
1256
+ const vt = Object.freeze({
1257
+ [_.ELIGIBILITY]: Pt,
1258
+ [_.INVENTORY]: _t,
1259
+ [_.PREREQUISITE]: Mt,
1260
+ [_.QUANTITY]: qt,
1261
+ [_.REFUND]: Lt,
1262
+ [_.REQUIREMENT]: Vt
882
1263
  });
883
- function dt(n, o) {
884
- const e = ct[n];
1264
+ function Ut(n, o) {
1265
+ const e = vt[n];
885
1266
  if (!e)
886
1267
  throw new TypeError(`Rule type "${n}" does not have a details contract`);
887
1268
  return new e(o);
888
1269
  }
889
- function at(n, o, e) {
1270
+ function $t(n, o, e) {
890
1271
  if (!n || typeof n != "object" || Array.isArray(n))
891
1272
  return e.push(`${o} must be an object`), {};
892
- const t = u(n.type, `${o}.type`, e), i = u(n.code, `${o}.code`, e);
893
- return Object.keys(n).forEach((r) => {
894
- ["code", "type"].includes(r) || e.push(`${o} contains unknown field "${r}"`);
895
- }), Object.values(_).includes(t) || e.push(`${o}.type "${t}" is not supported`), { type: t, code: i };
1273
+ const t = s(n.type, `${o}.type`, e), r = s(n.code, `${o}.code`, e);
1274
+ return Object.keys(n).forEach((i) => {
1275
+ ["code", "type"].includes(i) || e.push(`${o} contains unknown field "${i}"`);
1276
+ }), Object.values(M).includes(t) || e.push(`${o}.type "${t}" is not supported`), { type: t, code: r };
896
1277
  }
897
- class zt extends L {
1278
+ class Dn extends O {
898
1279
  constructor(o = {}) {
899
1280
  super({
900
1281
  contractName: "PublishedRule",
@@ -910,24 +1291,24 @@ class zt extends L {
910
1291
  "reason"
911
1292
  ],
912
1293
  normalize(e, t) {
913
- const i = u(e.ruleType, "ruleType", t);
914
- Object.values(S).includes(i) || t.push(`ruleType "${i}" is not supported`);
915
- const r = u(e.sourceType, "sourceType", t);
916
- Object.values(V).includes(r) || t.push(`sourceType "${r}" is not supported`);
917
- const s = at(e.appliesTo, "appliesTo", t);
1294
+ const r = s(e.ruleType, "ruleType", t);
1295
+ Object.values(_).includes(r) || t.push(`ruleType "${r}" is not supported`);
1296
+ const i = s(e.sourceType, "sourceType", t);
1297
+ Object.values(q).includes(i) || t.push(`sourceType "${i}" is not supported`);
1298
+ const d = $t(e.appliesTo, "appliesTo", t);
918
1299
  let c = {};
919
1300
  try {
920
- c = dt(i, e.details).toObject();
921
- } catch (d) {
922
- t.push(`details: ${d.message}`);
1301
+ c = Ut(r, e.details).toObject();
1302
+ } catch (a) {
1303
+ t.push(`details: ${a.message}`);
923
1304
  }
924
1305
  return {
925
- publishedRuleCode: u(e.publishedRuleCode, "publishedRuleCode", t),
926
- version: I(e.version, "version", t),
927
- ruleType: i,
928
- sourceType: r,
929
- sourceCode: u(e.sourceCode, "sourceCode", t),
930
- appliesTo: s,
1306
+ publishedRuleCode: s(e.publishedRuleCode, "publishedRuleCode", t),
1307
+ version: f(e.version, "version", t),
1308
+ ruleType: r,
1309
+ sourceType: i,
1310
+ sourceCode: s(e.sourceCode, "sourceCode", t),
1311
+ appliesTo: d,
931
1312
  details: c,
932
1313
  ...e.reason ? { reason: e.reason } : {}
933
1314
  };
@@ -938,7 +1319,7 @@ class zt extends L {
938
1319
  return this.publishedRuleCode;
939
1320
  }
940
1321
  }
941
- class Yt extends T {
1322
+ class Nn extends h {
942
1323
  constructor(o = {}) {
943
1324
  super({
944
1325
  contractName: "PublishedRuleRef",
@@ -946,14 +1327,39 @@ class Yt extends T {
946
1327
  fields: ["publishedRuleCode", "publishedRuleVersion"],
947
1328
  normalize(e, t) {
948
1329
  return {
949
- publishedRuleCode: u(e.publishedRuleCode, "publishedRuleCode", t),
950
- publishedRuleVersion: I(e.publishedRuleVersion, "publishedRuleVersion", t)
1330
+ publishedRuleCode: s(e.publishedRuleCode, "publishedRuleCode", t),
1331
+ publishedRuleVersion: f(e.publishedRuleVersion, "publishedRuleVersion", t)
951
1332
  };
952
1333
  }
953
1334
  });
954
1335
  }
955
1336
  }
956
- class Qt extends L {
1337
+ class An extends O {
1338
+ constructor(o = {}) {
1339
+ super({
1340
+ contractName: "Receipt",
1341
+ object: o,
1342
+ fields: ["receiptCode", "receiptNumber", "settlementCode", "orderCode", "invoiceCode", "invoiceRevisionCode", "currency", "amount", "issued"],
1343
+ normalize(e, t) {
1344
+ return {
1345
+ receiptCode: s(e.receiptCode, "receiptCode", t),
1346
+ receiptNumber: s(e.receiptNumber, "receiptNumber", t),
1347
+ settlementCode: s(e.settlementCode, "settlementCode", t),
1348
+ orderCode: s(e.orderCode, "orderCode", t),
1349
+ invoiceCode: s(e.invoiceCode, "invoiceCode", t),
1350
+ invoiceRevisionCode: s(e.invoiceRevisionCode, "invoiceRevisionCode", t),
1351
+ currency: s(e.currency, "currency", t),
1352
+ amount: x(e.amount, "amount", t),
1353
+ issued: $(e.issued, "issued", t)
1354
+ };
1355
+ }
1356
+ });
1357
+ }
1358
+ getCode() {
1359
+ return this.receiptCode;
1360
+ }
1361
+ }
1362
+ class On extends O {
957
1363
  constructor(o = {}) {
958
1364
  super({
959
1365
  contractName: "RefundPolicy",
@@ -961,9 +1367,9 @@ class Qt extends L {
961
1367
  fields: ["refundPolicyCode", "version", "name"],
962
1368
  normalize(e, t) {
963
1369
  return {
964
- refundPolicyCode: u(e.refundPolicyCode, "refundPolicyCode", t),
965
- version: I(e.version, "version", t),
966
- name: u(e.name, "name", t)
1370
+ refundPolicyCode: s(e.refundPolicyCode, "refundPolicyCode", t),
1371
+ version: f(e.version, "version", t),
1372
+ name: s(e.name, "name", t)
967
1373
  };
968
1374
  }
969
1375
  });
@@ -972,24 +1378,24 @@ class Qt extends L {
972
1378
  return this.refundPolicyCode;
973
1379
  }
974
1380
  }
975
- function $e(n, o, e) {
976
- const t = u(n, o, e);
1381
+ function Ke(n, o, e) {
1382
+ const t = s(n, o, e);
977
1383
  return t && !Number.isFinite(Date.parse(t)) && e.push(`${o} must be an ISO-compatible timestamp`), t;
978
1384
  }
979
- class Bt extends L {
1385
+ class Sn extends O {
980
1386
  constructor(o = {}) {
981
1387
  super({
982
1388
  contractName: "SalesPeriod",
983
1389
  object: o,
984
1390
  fields: ["salesPeriodCode", "version", "name", "validFrom", "validUntil"],
985
1391
  normalize(e, t) {
986
- const i = $e(e.validFrom, "validFrom", t), r = $e(e.validUntil, "validUntil", t);
987
- return i && r && Date.parse(i) >= Date.parse(r) && t.push("validUntil must be later than validFrom"), {
988
- salesPeriodCode: u(e.salesPeriodCode, "salesPeriodCode", t),
989
- version: I(e.version, "version", t),
990
- name: u(e.name, "name", t),
991
- validFrom: i,
992
- validUntil: r
1392
+ const r = Ke(e.validFrom, "validFrom", t), i = Ke(e.validUntil, "validUntil", t);
1393
+ return r && i && Date.parse(r) >= Date.parse(i) && t.push("validUntil must be later than validFrom"), {
1394
+ salesPeriodCode: s(e.salesPeriodCode, "salesPeriodCode", t),
1395
+ version: f(e.version, "version", t),
1396
+ name: s(e.name, "name", t),
1397
+ validFrom: r,
1398
+ validUntil: i
993
1399
  };
994
1400
  }
995
1401
  });
@@ -998,7 +1404,35 @@ class Bt extends L {
998
1404
  return this.salesPeriodCode;
999
1405
  }
1000
1406
  }
1001
- class Ft extends L {
1407
+ class Pn extends O {
1408
+ constructor(o = {}) {
1409
+ super({
1410
+ contractName: "Settlement",
1411
+ object: o,
1412
+ fields: ["settlementCode", "settlementCommandCode", "paymentAttemptCode", "orderCode", "invoiceCode", "invoiceRevisionCode", "currency", "amount", "providerCode", "providerReference", "providerEventCode", "confirmed"],
1413
+ normalize(e, t) {
1414
+ return {
1415
+ settlementCode: s(e.settlementCode, "settlementCode", t),
1416
+ settlementCommandCode: s(e.settlementCommandCode, "settlementCommandCode", t),
1417
+ paymentAttemptCode: s(e.paymentAttemptCode, "paymentAttemptCode", t),
1418
+ orderCode: s(e.orderCode, "orderCode", t),
1419
+ invoiceCode: s(e.invoiceCode, "invoiceCode", t),
1420
+ invoiceRevisionCode: s(e.invoiceRevisionCode, "invoiceRevisionCode", t),
1421
+ currency: s(e.currency, "currency", t),
1422
+ amount: x(e.amount, "amount", t),
1423
+ providerCode: s(e.providerCode, "providerCode", t),
1424
+ providerReference: s(e.providerReference, "providerReference", t),
1425
+ providerEventCode: s(e.providerEventCode, "providerEventCode", t),
1426
+ confirmed: $(e.confirmed, "confirmed", t)
1427
+ };
1428
+ }
1429
+ });
1430
+ }
1431
+ getCode() {
1432
+ return this.settlementCode;
1433
+ }
1434
+ }
1435
+ class _n extends O {
1002
1436
  constructor(o = {}) {
1003
1437
  super({
1004
1438
  contractName: "Variant",
@@ -1006,11 +1440,11 @@ class Ft extends L {
1006
1440
  fields: ["variantCode", "version", "productCode", "productVersion", "name", "optionValues"],
1007
1441
  normalize(e, t) {
1008
1442
  return (!e.optionValues || typeof e.optionValues != "object" || Array.isArray(e.optionValues)) && t.push("optionValues must be an object"), {
1009
- variantCode: u(e.variantCode, "variantCode", t),
1010
- version: I(e.version, "version", t),
1011
- productCode: u(e.productCode, "productCode", t),
1012
- productVersion: I(e.productVersion, "productVersion", t),
1013
- name: u(e.name, "name", t),
1443
+ variantCode: s(e.variantCode, "variantCode", t),
1444
+ version: f(e.version, "version", t),
1445
+ productCode: s(e.productCode, "productCode", t),
1446
+ productVersion: f(e.productVersion, "productVersion", t),
1447
+ name: s(e.name, "name", t),
1014
1448
  optionValues: e.optionValues || {}
1015
1449
  };
1016
1450
  }
@@ -1020,7 +1454,7 @@ class Ft extends L {
1020
1454
  return this.variantCode;
1021
1455
  }
1022
1456
  }
1023
- class Le extends T {
1457
+ class Xe extends h {
1024
1458
  constructor(o = {}) {
1025
1459
  super({
1026
1460
  contractName: "VariantRef",
@@ -1028,14 +1462,14 @@ class Le extends T {
1028
1462
  fields: ["variantCode", "variantVersion"],
1029
1463
  normalize(e, t) {
1030
1464
  return {
1031
- variantCode: u(e.variantCode, "variantCode", t),
1032
- variantVersion: I(e.variantVersion, "variantVersion", t)
1465
+ variantCode: s(e.variantCode, "variantCode", t),
1466
+ variantVersion: f(e.variantVersion, "variantVersion", t)
1033
1467
  };
1034
1468
  }
1035
1469
  });
1036
1470
  }
1037
1471
  }
1038
- class kt extends L {
1472
+ class se extends O {
1039
1473
  constructor(o = {}) {
1040
1474
  super({
1041
1475
  contractName: "WalletItem",
@@ -1053,26 +1487,26 @@ class kt extends L {
1053
1487
  "requirementPlans"
1054
1488
  ],
1055
1489
  normalize(e, t) {
1056
- const i = M(e.variantCode, "variantCode", t), r = typeof e.variantVersion > "u" || e.variantVersion === null ? void 0 : I(e.variantVersion, "variantVersion", t);
1057
- (i && typeof r > "u" || !i && typeof r < "u") && t.push("variantCode and variantVersion must be provided together"), Array.isArray(e.requirementPlans || []) || t.push("requirementPlans must be an array");
1058
- const s = u(e.state, "state", t);
1059
- Object.values(P).includes(s) || t.push(`state "${s}" is not supported`);
1060
- const c = (Array.isArray(e.requirementPlans) ? e.requirementPlans : []).flatMap((d, a) => {
1490
+ const r = N(e.variantCode, "variantCode", t), i = typeof e.variantVersion > "u" || e.variantVersion === null ? void 0 : f(e.variantVersion, "variantVersion", t);
1491
+ (r && typeof i > "u" || !r && typeof i < "u") && t.push("variantCode and variantVersion must be provided together"), Array.isArray(e.requirementPlans || []) || t.push("requirementPlans must be an array");
1492
+ const d = s(e.state, "state", t);
1493
+ Object.values(S).includes(d) || t.push(`state "${d}" is not supported`);
1494
+ const c = (Array.isArray(e.requirementPlans) ? e.requirementPlans : []).flatMap((a, u) => {
1061
1495
  try {
1062
- return [(d instanceof ee ? d : new ee(d)).toObject()];
1496
+ return [(a instanceof ce ? a : new ce(a)).toObject()];
1063
1497
  } catch (l) {
1064
- return t.push(`requirementPlans[${a}]: ${l.message}`), [];
1498
+ return t.push(`requirementPlans[${u}]: ${l.message}`), [];
1065
1499
  }
1066
1500
  });
1067
1501
  return {
1068
- walletItemCode: u(e.walletItemCode, "walletItemCode", t),
1069
- productCode: u(e.productCode, "productCode", t),
1070
- productVersion: I(e.productVersion, "productVersion", t),
1071
- state: s,
1072
- quantity: I(e.quantity, "quantity", t),
1073
- acquisitionCode: u(e.acquisitionCode, "acquisitionCode", t),
1074
- ...M(e.eventRegistrationCode, "eventRegistrationCode", t) ? { eventRegistrationCode: e.eventRegistrationCode } : {},
1075
- ...i ? { variantCode: i, variantVersion: r } : {},
1502
+ walletItemCode: s(e.walletItemCode, "walletItemCode", t),
1503
+ productCode: s(e.productCode, "productCode", t),
1504
+ productVersion: f(e.productVersion, "productVersion", t),
1505
+ state: d,
1506
+ quantity: f(e.quantity, "quantity", t),
1507
+ acquisitionCode: s(e.acquisitionCode, "acquisitionCode", t),
1508
+ ...N(e.eventRegistrationCode, "eventRegistrationCode", t) ? { eventRegistrationCode: e.eventRegistrationCode } : {},
1509
+ ...r ? { variantCode: r, variantVersion: i } : {},
1076
1510
  requirementPlans: c
1077
1511
  };
1078
1512
  }
@@ -1082,118 +1516,118 @@ class kt extends L {
1082
1516
  return this.walletItemCode;
1083
1517
  }
1084
1518
  }
1085
- const Ue = [
1086
- V.CATEGORY,
1087
- V.PRODUCT,
1088
- V.MERCHANDISE,
1089
- V.ACQUISITION_SOURCE
1519
+ const Je = [
1520
+ q.CATEGORY,
1521
+ q.PRODUCT,
1522
+ q.MERCHANDISE,
1523
+ q.ACQUISITION_SOURCE
1090
1524
  ];
1091
- function ve(n, o) {
1525
+ function Ze(n, o) {
1092
1526
  return `${n}:${o}`;
1093
1527
  }
1094
- function ut({ rule: n, relevantCategoryCodes: o, relevantProductCodes: e, merchandise: t }) {
1095
- if (n.sourceType === V.CATEGORY)
1096
- return n.appliesTo.type === _.CATEGORY && n.appliesTo.code === n.sourceCode;
1097
- if (n.sourceType === V.PRODUCT)
1098
- return n.appliesTo.type === _.PRODUCT && n.appliesTo.code === n.sourceCode;
1099
- if (n.sourceType === V.MERCHANDISE)
1100
- return n.appliesTo.type === _.MERCHANDISE ? n.appliesTo.code === t.merchandiseCode : n.appliesTo.type === _.PRODUCT ? e.has(n.appliesTo.code) : n.appliesTo.type === _.CATEGORY ? o.has(n.appliesTo.code) : !1;
1101
- if (n.sourceType === V.ACQUISITION_SOURCE) {
1102
- if (n.appliesTo.type === _.MERCHANDISE)
1528
+ function wt({ rule: n, relevantCategoryCodes: o, relevantProductCodes: e, merchandise: t }) {
1529
+ if (n.sourceType === q.CATEGORY)
1530
+ return n.appliesTo.type === M.CATEGORY && n.appliesTo.code === n.sourceCode;
1531
+ if (n.sourceType === q.PRODUCT)
1532
+ return n.appliesTo.type === M.PRODUCT && n.appliesTo.code === n.sourceCode;
1533
+ if (n.sourceType === q.MERCHANDISE)
1534
+ return n.appliesTo.type === M.MERCHANDISE ? n.appliesTo.code === t.merchandiseCode : n.appliesTo.type === M.PRODUCT ? e.has(n.appliesTo.code) : n.appliesTo.type === M.CATEGORY ? o.has(n.appliesTo.code) : !1;
1535
+ if (n.sourceType === q.ACQUISITION_SOURCE) {
1536
+ if (n.appliesTo.type === M.MERCHANDISE)
1103
1537
  return n.appliesTo.code === t.merchandiseCode;
1104
- if (n.appliesTo.type === _.PRODUCT)
1538
+ if (n.appliesTo.type === M.PRODUCT)
1105
1539
  return e.has(n.appliesTo.code);
1106
- if (n.appliesTo.type === _.CATEGORY)
1540
+ if (n.appliesTo.type === M.CATEGORY)
1107
1541
  return o.has(n.appliesTo.code);
1108
1542
  }
1109
1543
  return !1;
1110
1544
  }
1111
- function lt({ categories: n = [], products: o = [], merchandise: e, acquisitionSource: t, publishedRules: i = [] }) {
1112
- const r = new Set(e.components.map((p) => `${p.productCode}@${p.productVersion}`)), s = o.filter((p) => r.has(`${p.productCode}@${p.version}`)), c = new Set(s.map((p) => p.productCode)), d = new Set(s.flatMap((p) => p.categoryCodes || [])), l = [
1113
- ...n.filter((p) => d.has(p.categoryCode)).map((p) => ({
1114
- sourceType: V.CATEGORY,
1545
+ function jt({ categories: n = [], products: o = [], merchandise: e, acquisitionSource: t, publishedRules: r = [] }) {
1546
+ const i = new Set(e.components.map((p) => `${p.productCode}@${p.productVersion}`)), d = o.filter((p) => i.has(`${p.productCode}@${p.version}`)), c = new Set(d.map((p) => p.productCode)), a = new Set(d.flatMap((p) => p.categoryCodes || [])), l = [
1547
+ ...n.filter((p) => a.has(p.categoryCode)).map((p) => ({
1548
+ sourceType: q.CATEGORY,
1115
1549
  sourceCode: p.categoryCode
1116
1550
  })),
1117
- ...s.map((p) => ({
1118
- sourceType: V.PRODUCT,
1551
+ ...d.map((p) => ({
1552
+ sourceType: q.PRODUCT,
1119
1553
  sourceCode: p.productCode
1120
1554
  })),
1121
1555
  {
1122
- sourceType: V.MERCHANDISE,
1556
+ sourceType: q.MERCHANDISE,
1123
1557
  sourceCode: e.merchandiseCode
1124
1558
  },
1125
1559
  {
1126
- sourceType: V.ACQUISITION_SOURCE,
1560
+ sourceType: q.ACQUISITION_SOURCE,
1127
1561
  sourceCode: t
1128
1562
  }
1129
- ], f = new Set(l.map((p) => ve(p.sourceType, p.sourceCode))), N = i.filter((p) => f.has(ve(p.sourceType, p.sourceCode))).reduce((p, y) => {
1130
- const h = p.get(y.publishedRuleCode) || [];
1131
- return h.push(y), p.set(y.publishedRuleCode, h), p;
1132
- }, /* @__PURE__ */ new Map()), g = [], m = [], E = [], R = /* @__PURE__ */ new Set();
1133
- N.forEach((p, y) => {
1563
+ ], m = new Set(l.map((p) => Ze(p.sourceType, p.sourceCode))), y = r.filter((p) => m.has(Ze(p.sourceType, p.sourceCode))).reduce((p, R) => {
1564
+ const b = p.get(R.publishedRuleCode) || [];
1565
+ return b.push(R), p.set(R.publishedRuleCode, b), p;
1566
+ }, /* @__PURE__ */ new Map()), T = [], C = [], E = [], g = /* @__PURE__ */ new Set();
1567
+ y.forEach((p, R) => {
1134
1568
  if (p.length > 1) {
1135
- g.push({
1569
+ T.push({
1136
1570
  code: "RULE_PUBLICATION_AMBIGUOUS",
1137
- ruleCode: y,
1138
- sources: p.map((U) => ({
1139
- sourceType: U.sourceType,
1140
- sourceCode: U.sourceCode
1571
+ ruleCode: R,
1572
+ sources: p.map((F) => ({
1573
+ sourceType: F.sourceType,
1574
+ sourceCode: F.sourceCode
1141
1575
  })),
1142
- versions: p.map((U) => U.version)
1576
+ versions: p.map((F) => F.version)
1143
1577
  });
1144
1578
  return;
1145
1579
  }
1146
- const [h] = p;
1147
- if (h.tenantCode !== e.tenantCode) {
1148
- g.push({
1580
+ const [b] = p;
1581
+ if (b.tenantCode !== e.tenantCode) {
1582
+ T.push({
1149
1583
  code: "RULE_TENANT_MISMATCH",
1150
- ruleCode: h.publishedRuleCode,
1151
- ruleTenantCode: h.tenantCode,
1584
+ ruleCode: b.publishedRuleCode,
1585
+ ruleTenantCode: b.tenantCode,
1152
1586
  expectedTenantCode: e.tenantCode
1153
1587
  });
1154
1588
  return;
1155
1589
  }
1156
- if (!ut({ rule: h, relevantCategoryCodes: d, relevantProductCodes: c, merchandise: e })) {
1157
- g.push({
1590
+ if (!wt({ rule: b, relevantCategoryCodes: a, relevantProductCodes: c, merchandise: e })) {
1591
+ T.push({
1158
1592
  code: "RULE_TARGET_MISMATCH",
1159
- ruleCode: h.publishedRuleCode,
1160
- sourceType: h.sourceType,
1161
- sourceCode: h.sourceCode,
1162
- appliesTo: D(h.appliesTo)
1593
+ ruleCode: b.publishedRuleCode,
1594
+ sourceType: b.sourceType,
1595
+ sourceCode: b.sourceCode,
1596
+ appliesTo: D(b.appliesTo)
1163
1597
  });
1164
1598
  return;
1165
1599
  }
1166
- const W = `${h.publishedRuleCode}@${h.version}`;
1167
- R.has(W) || (R.add(W), E.push(h)), m.push({
1168
- ruleCode: h.publishedRuleCode,
1169
- ruleVersion: h.version,
1170
- ruleType: h.ruleType,
1171
- sourceType: h.sourceType,
1172
- sourceCode: h.sourceCode
1600
+ const te = `${b.publishedRuleCode}@${b.version}`;
1601
+ g.has(te) || (g.add(te), E.push(b)), C.push({
1602
+ ruleCode: b.publishedRuleCode,
1603
+ ruleVersion: b.version,
1604
+ ruleType: b.ruleType,
1605
+ sourceType: b.sourceType,
1606
+ sourceCode: b.sourceCode
1173
1607
  });
1174
- }), E.sort((p, y) => Ue.indexOf(p.sourceType) - Ue.indexOf(y.sourceType) || p.publishedRuleCode.localeCompare(y.publishedRuleCode));
1175
- const b = E.map((p) => typeof p.toObject == "function" ? p.toObject() : D(p)), C = Object.fromEntries(Object.values(S).map((p) => [
1608
+ }), E.sort((p, R) => Je.indexOf(p.sourceType) - Je.indexOf(R.sourceType) || p.publishedRuleCode.localeCompare(R.publishedRuleCode));
1609
+ const A = E.map((p) => typeof p.toObject == "function" ? p.toObject() : D(p)), v = Object.fromEntries(Object.values(_).map((p) => [
1176
1610
  p,
1177
- b.filter((y) => y.ruleType === p)
1611
+ A.filter((R) => R.ruleType === p)
1178
1612
  ]));
1179
- return q({
1180
- passed: g.length === 0,
1181
- rules: b,
1182
- byType: C,
1183
- trace: m,
1184
- errors: g
1613
+ return L({
1614
+ passed: T.length === 0,
1615
+ rules: A,
1616
+ byType: v,
1617
+ trace: C,
1618
+ errors: T
1185
1619
  });
1186
1620
  }
1187
- const pt = Object.freeze([
1188
- P.CANCELLED,
1189
- P.EXPIRED,
1190
- P.REFUNDED,
1191
- P.REVOKED
1192
- ]), mt = Object.freeze([
1193
- P.PENDING_REQUIREMENT,
1194
- P.RESERVED,
1195
- P.VALID
1196
- ]), A = Object.freeze({
1621
+ const xt = Object.freeze([
1622
+ S.CANCELLED,
1623
+ S.EXPIRED,
1624
+ S.REFUNDED,
1625
+ S.REVOKED
1626
+ ]), zt = Object.freeze([
1627
+ S.PENDING_REQUIREMENT,
1628
+ S.RESERVED,
1629
+ S.VALID
1630
+ ]), P = Object.freeze({
1197
1631
  DEFINITION_INVALID: "DEFINITION_INVALID",
1198
1632
  ELIGIBILITY_REJECTED: "ELIGIBILITY_REJECTED",
1199
1633
  ELIGIBILITY_REQUIRED: "ELIGIBILITY_REQUIRED",
@@ -1210,71 +1644,71 @@ const pt = Object.freeze([
1210
1644
  REVISION_CONFLICT: "REVISION_CONFLICT",
1211
1645
  VARIANT_SELECTION_REQUIRED: "VARIANT_SELECTION_REQUIRED"
1212
1646
  });
1213
- function $({ passed: n, code: o = null, message: e, details: t = {} }) {
1214
- return q({ passed: n, code: o, message: e, details: D(t) });
1647
+ function V({ passed: n, code: o = null, message: e, details: t = {} }) {
1648
+ return L({ passed: n, code: o, message: e, details: D(t) });
1215
1649
  }
1216
- function w(n, o) {
1217
- return n.type === _.PRODUCT ? o.productCode === n.code : n.type === _.CATEGORY ? (o.categoryCodes || []).includes(n.code) : n.type === _.MERCHANDISE ? o.merchandiseCode === n.code : !1;
1650
+ function z(n, o) {
1651
+ return n.type === M.PRODUCT ? o.productCode === n.code : n.type === M.CATEGORY ? (o.categoryCodes || []).includes(n.code) : n.type === M.MERCHANDISE ? o.merchandiseCode === n.code : !1;
1218
1652
  }
1219
- function J(n, o, e) {
1220
- return n.reduce((t, i) => !w(o, i) || e && !e.includes(i.state) ? t : t + (i.quantity || 1), 0);
1653
+ function re(n, o, e) {
1654
+ return n.reduce((t, r) => !z(o, r) || e && !e.includes(r.state) ? t : t + (r.quantity || 1), 0);
1221
1655
  }
1222
- function ft(n) {
1223
- return (n == null ? void 0 : n.state) === P.VALID;
1656
+ function Qt(n) {
1657
+ return (n == null ? void 0 : n.state) === S.VALID;
1224
1658
  }
1225
- function Ct({ rules: n = [], existingItems: o = [], candidateItems: e = [], activeItemStates: t = mt }) {
1226
- const i = n.filter((r) => r.ruleType === S.QUANTITY).filter((r) => e.some((s) => w(r.appliesTo, s))).map((r) => {
1227
- const s = J(e, r.appliesTo);
1659
+ function Bt({ rules: n = [], existingItems: o = [], candidateItems: e = [], activeItemStates: t = zt }) {
1660
+ const r = n.filter((i) => i.ruleType === _.QUANTITY).filter((i) => e.some((d) => z(i.appliesTo, d))).map((i) => {
1661
+ const d = re(e, i.appliesTo);
1228
1662
  let c = 0;
1229
- r.details.limitType === K.HOLDING ? c = J(
1230
- o.filter((l) => !pt.includes(l.state)),
1231
- r.appliesTo
1232
- ) : r.details.limitType === K.ACTIVE && (c = J(o, r.appliesTo, t));
1233
- const d = c + s, a = d <= r.details.limit;
1234
- return $({
1235
- passed: a,
1236
- ...a ? {} : { code: A.QUANTITY_LIMIT_EXCEEDED },
1237
- message: a ? "Quantity rule passed" : "Quantity limit would be exceeded",
1663
+ i.details.limitType === ee.HOLDING ? c = re(
1664
+ o.filter((l) => !xt.includes(l.state)),
1665
+ i.appliesTo
1666
+ ) : i.details.limitType === ee.ACTIVE && (c = re(o, i.appliesTo, t));
1667
+ const a = c + d, u = a <= i.details.limit;
1668
+ return V({
1669
+ passed: u,
1670
+ ...u ? {} : { code: P.QUANTITY_LIMIT_EXCEEDED },
1671
+ message: u ? "Quantity rule passed" : "Quantity limit would be exceeded",
1238
1672
  details: {
1239
- ruleCode: r.publishedRuleCode,
1240
- ruleVersion: r.version,
1241
- limitType: r.details.limitType,
1242
- target: r.appliesTo,
1673
+ ruleCode: i.publishedRuleCode,
1674
+ ruleVersion: i.version,
1675
+ limitType: i.details.limitType,
1676
+ target: i.appliesTo,
1243
1677
  current: c,
1244
- addition: s,
1245
- resulting: d,
1246
- limit: r.details.limit,
1247
- remaining: Math.max(0, r.details.limit - c)
1678
+ addition: d,
1679
+ resulting: a,
1680
+ limit: i.details.limit,
1681
+ remaining: Math.max(0, i.details.limit - c)
1248
1682
  }
1249
1683
  });
1250
1684
  });
1251
- return q({ passed: i.every((r) => r.passed), decisions: i });
1252
- }
1253
- function Et(n) {
1254
- return n === x.UNDER_REVIEW ? A.ELIGIBILITY_UNDER_REVIEW : n === x.REJECTED ? A.ELIGIBILITY_REJECTED : n === x.REVOKED ? A.ELIGIBILITY_REVOKED : A.ELIGIBILITY_REQUIRED;
1255
- }
1256
- function yt({ rules: n = [], eligibilityFacts: o = [], eventRegistrationCode: e, candidateItems: t = [] }) {
1257
- const i = n.filter((r) => r.ruleType === S.ELIGIBILITY).filter((r) => t.some((s) => w(r.appliesTo, s))).map((r) => {
1258
- const s = o.find((a) => a.eligibilityType === r.details.eligibilityType && (!e || !a.eventRegistrationCode || a.eventRegistrationCode === e)), c = (s == null ? void 0 : s.state) || x.NOT_SUBMITTED, d = (r.details.acceptedStates || [x.VALID]).includes(c);
1259
- return $({
1260
- passed: d,
1261
- ...d ? {} : { code: Et(c) },
1262
- message: d ? "Eligibility rule passed" : "Required eligibility is not valid",
1685
+ return L({ passed: r.every((i) => i.passed), decisions: r });
1686
+ }
1687
+ function Yt(n) {
1688
+ return n === Y.UNDER_REVIEW ? P.ELIGIBILITY_UNDER_REVIEW : n === Y.REJECTED ? P.ELIGIBILITY_REJECTED : n === Y.REVOKED ? P.ELIGIBILITY_REVOKED : P.ELIGIBILITY_REQUIRED;
1689
+ }
1690
+ function Ft({ rules: n = [], eligibilityFacts: o = [], eventRegistrationCode: e, candidateItems: t = [] }) {
1691
+ const r = n.filter((i) => i.ruleType === _.ELIGIBILITY).filter((i) => t.some((d) => z(i.appliesTo, d))).map((i) => {
1692
+ const d = o.find((u) => u.eligibilityType === i.details.eligibilityType && (!e || !u.eventRegistrationCode || u.eventRegistrationCode === e)), c = (d == null ? void 0 : d.state) || Y.NOT_SUBMITTED, a = (i.details.acceptedStates || [Y.VALID]).includes(c);
1693
+ return V({
1694
+ passed: a,
1695
+ ...a ? {} : { code: Yt(c) },
1696
+ message: a ? "Eligibility rule passed" : "Required eligibility is not valid",
1263
1697
  details: {
1264
- ruleCode: r.publishedRuleCode,
1265
- eligibilityType: r.details.eligibilityType,
1698
+ ruleCode: i.publishedRuleCode,
1699
+ eligibilityType: i.details.eligibilityType,
1266
1700
  eventRegistrationCode: e || null,
1267
1701
  state: c,
1268
- factRevision: (s == null ? void 0 : s.revision) || null
1702
+ factRevision: (d == null ? void 0 : d.revision) || null
1269
1703
  }
1270
1704
  });
1271
1705
  });
1272
- return q({ passed: i.every((r) => r.passed), decisions: i });
1706
+ return L({ passed: r.every((i) => i.passed), decisions: r });
1273
1707
  }
1274
- function It(n, o) {
1275
- return ft(n) && w(o, n);
1708
+ function kt(n, o) {
1709
+ return Qt(n) && z(o, n);
1276
1710
  }
1277
- function Rt(n) {
1711
+ function Wt(n) {
1278
1712
  return Object.fromEntries([
1279
1713
  "walletItemCode",
1280
1714
  "acquisitionCode",
@@ -1287,469 +1721,493 @@ function Rt(n) {
1287
1721
  "componentIndex"
1288
1722
  ].flatMap((e) => typeof n[e] > "u" ? [] : [[e, D(n[e])]]));
1289
1723
  }
1290
- function ht({ rules: n = [], existingItems: o = [], candidateItems: e = [] }) {
1291
- const t = n.filter((i) => i.ruleType === S.PREREQUISITE).filter((i) => e.some((r) => w(i.appliesTo, r))).map((i) => {
1292
- const r = i.details.evidenceSources || [
1293
- k.EXISTING,
1294
- k.SAME_ORDER
1295
- ], s = [
1296
- ...r.includes(k.EXISTING) ? o : [],
1297
- ...r.includes(k.SAME_ORDER) ? e : []
1298
- ], c = (i.details.requires || []).map((a) => ({
1299
- requirement: a,
1300
- matched: s.filter((l) => It(l, a)).map(Rt)
1301
- })), d = i.details.matchMode === ce.ALL ? c.every((a) => a.matched.length > 0) : c.some((a) => a.matched.length > 0);
1302
- return $({
1303
- passed: d,
1304
- ...d ? {} : { code: A.PREREQUISITE_NOT_MET },
1305
- message: d ? "Prerequisite rule passed" : "Prerequisite item was not found",
1724
+ function Gt({ rules: n = [], existingItems: o = [], candidateItems: e = [] }) {
1725
+ const t = n.filter((r) => r.ruleType === _.PREREQUISITE).filter((r) => e.some((i) => z(r.appliesTo, i))).map((r) => {
1726
+ const i = r.details.evidenceSources || [
1727
+ K.EXISTING,
1728
+ K.SAME_ORDER
1729
+ ], d = [
1730
+ ...i.includes(K.EXISTING) ? o : [],
1731
+ ...i.includes(K.SAME_ORDER) ? e : []
1732
+ ], c = (r.details.requires || []).map((u) => ({
1733
+ requirement: u,
1734
+ matched: d.filter((l) => kt(l, u)).map(Wt)
1735
+ })), a = r.details.matchMode === ye.ALL ? c.every((u) => u.matched.length > 0) : c.some((u) => u.matched.length > 0);
1736
+ return V({
1737
+ passed: a,
1738
+ ...a ? {} : { code: P.PREREQUISITE_NOT_MET },
1739
+ message: a ? "Prerequisite rule passed" : "Prerequisite item was not found",
1306
1740
  details: {
1307
- ruleCode: i.publishedRuleCode,
1308
- matchMode: i.details.matchMode || ce.ANY,
1309
- continuous: i.details.continuous || !1,
1741
+ ruleCode: r.publishedRuleCode,
1742
+ matchMode: r.details.matchMode || ye.ANY,
1743
+ continuous: r.details.continuous || !1,
1310
1744
  requirementResults: c
1311
1745
  }
1312
1746
  });
1313
1747
  });
1314
- return q({ passed: t.every((i) => i.passed), decisions: t });
1748
+ return L({ passed: t.every((r) => r.passed), decisions: t });
1315
1749
  }
1316
- function Tt({
1750
+ function Ht({
1317
1751
  rules: n = [],
1318
1752
  candidateItems: o = [],
1319
1753
  requirementInputs: e = [],
1320
1754
  requirementValues: t = {},
1321
- variantSelections: i = []
1755
+ variantSelections: r = []
1322
1756
  }) {
1323
- const r = n.filter((s) => s.ruleType === S.REQUIREMENT).filter((s) => o.some((c) => w(s.appliesTo, c))).flatMap((s) => o.filter((c) => w(s.appliesTo, c)).flatMap((c) => Array.from({ length: c.quantity }, (d, a) => {
1757
+ const i = n.filter((d) => d.ruleType === _.REQUIREMENT).filter((d) => o.some((c) => z(d.appliesTo, c))).flatMap((d) => o.filter((c) => z(d.appliesTo, c)).flatMap((c) => Array.from({ length: c.quantity }, (a, u) => {
1324
1758
  var p;
1325
- const l = s.details.requirement, f = l.requirementCode, O = e.find((y) => y.productCode === c.productCode && y.requirementCode === f), N = t[f], g = Array.isArray(N) ? N : [N || {}], E = O && a < O.inputs.length ? O.inputs[a] || {} : g[a] || {}, R = (p = i.find((y) => y.productCode === c.productCode)) == null ? void 0 : p.selections[a], b = Object.fromEntries(l.fields.map((y) => y.inputType === "VARIANT" ? [y.fieldCode, (R == null ? void 0 : R.variantCode) || ""] : [y.fieldCode, E[y.fieldCode] || ""])), C = l.fields.map((y) => y.fieldCode).filter((y) => typeof b[y] != "string" || b[y].trim().length === 0);
1759
+ const l = d.details.requirement, m = l.requirementCode, I = e.find((R) => R.productCode === c.productCode && R.requirementCode === m), y = t[m], T = Array.isArray(y) ? y : [y || {}], E = I && u < I.inputs.length ? I.inputs[u] || {} : T[u] || {}, g = (p = r.find((R) => R.productCode === c.productCode)) == null ? void 0 : p.selections[u], A = Object.fromEntries(l.fields.map((R) => R.inputType === "VARIANT" ? [R.fieldCode, (g == null ? void 0 : g.variantCode) || ""] : [R.fieldCode, E[R.fieldCode] || ""])), v = l.fields.map((R) => R.fieldCode).filter((R) => typeof A[R] != "string" || A[R].trim().length === 0);
1326
1760
  return {
1327
- ruleCode: s.publishedRuleCode,
1761
+ ruleCode: d.publishedRuleCode,
1328
1762
  requirement: l,
1329
1763
  productCode: c.productCode,
1330
1764
  componentIndex: c.componentIndex,
1331
- unitIndex: a,
1332
- completionTiming: s.details.completionTiming || de.BEFORE_ITEM_VALID,
1333
- modificationMode: s.details.modificationMode,
1334
- ...s.details.completionDeadline ? { completionDeadline: s.details.completionDeadline } : {},
1335
- ...s.details.modificationDeadline ? { modificationDeadline: s.details.modificationDeadline } : {},
1336
- values: D(b),
1337
- missingFields: C,
1338
- complete: C.length === 0
1765
+ unitIndex: u,
1766
+ completionTiming: d.details.completionTiming || Re.BEFORE_ITEM_VALID,
1767
+ modificationMode: d.details.modificationMode,
1768
+ ...d.details.completionDeadline ? { completionDeadline: d.details.completionDeadline } : {},
1769
+ ...d.details.modificationDeadline ? { modificationDeadline: d.details.modificationDeadline } : {},
1770
+ values: D(A),
1771
+ missingFields: v,
1772
+ complete: v.length === 0
1339
1773
  };
1340
1774
  })));
1341
- return q({
1775
+ return L({
1342
1776
  passed: !0,
1343
- itemValid: r.every((s) => s.complete),
1344
- code: r.every((s) => s.complete) ? null : A.REQUIREMENT_INCOMPLETE,
1345
- plans: r
1777
+ itemValid: i.every((d) => d.complete),
1778
+ code: i.every((d) => d.complete) ? null : P.REQUIREMENT_INCOMPLETE,
1779
+ plans: i
1346
1780
  });
1347
1781
  }
1348
- function Gt({ requirementPlan: n = {}, rule: o, instant: e }) {
1349
- if (!o || o.ruleType !== S.REQUIREMENT)
1782
+ function Mn({ requirementPlan: n = {}, rule: o, instant: e }) {
1783
+ if (!o || o.ruleType !== _.REQUIREMENT)
1350
1784
  throw new TypeError("rule must be a REQUIREMENT PublishedRule");
1351
1785
  const t = Date.parse(e);
1352
1786
  if (!Number.isFinite(t))
1353
1787
  throw new TypeError("instant must be an ISO-8601 timestamp");
1354
- const i = o.details, r = !!(i.completionDeadline && t >= Date.parse(i.completionDeadline)), s = n.complete ? ie.COMPLETE : r ? ie.OVERDUE : ie.INCOMPLETE;
1355
- let c = H.EDITABLE, d = null;
1356
- return i.modificationMode === Q.LOCK_AFTER_COMPLETE && n.complete ? (c = H.LOCKED, d = "REQUIREMENT_COMPLETE") : i.modificationMode === Q.UNTIL_DEADLINE && t >= Date.parse(i.modificationDeadline) && (c = H.LOCKED, d = "MODIFICATION_DEADLINE_PASSED"), q({
1357
- requirementCode: i.requirement.requirementCode,
1358
- completionState: s,
1788
+ const r = o.details, i = !!(r.completionDeadline && t >= Date.parse(r.completionDeadline)), d = n.complete ? fe.COMPLETE : i ? fe.OVERDUE : fe.INCOMPLETE;
1789
+ let c = ne.EDITABLE, a = null;
1790
+ return r.modificationMode === j.LOCK_AFTER_COMPLETE && n.complete ? (c = ne.LOCKED, a = "REQUIREMENT_COMPLETE") : r.modificationMode === j.UNTIL_DEADLINE && t >= Date.parse(r.modificationDeadline) && (c = ne.LOCKED, a = "MODIFICATION_DEADLINE_PASSED"), L({
1791
+ requirementCode: r.requirement.requirementCode,
1792
+ completionState: d,
1359
1793
  modificationState: c,
1360
- canModify: c === H.EDITABLE,
1361
- modificationReason: d,
1362
- completionDeadline: i.completionDeadline || null,
1363
- modificationDeadline: i.modificationDeadline || null,
1794
+ canModify: c === ne.EDITABLE,
1795
+ modificationReason: a,
1796
+ completionDeadline: r.completionDeadline || null,
1797
+ modificationDeadline: r.modificationDeadline || null,
1364
1798
  evaluated: e
1365
1799
  });
1366
1800
  }
1367
- function gt(n, o) {
1801
+ function Kt(n, o) {
1368
1802
  const e = Date.parse(o);
1369
1803
  return !(!Number.isFinite(e) || n.validFrom && e < Date.parse(n.validFrom) || n.validUntil && e >= Date.parse(n.validUntil));
1370
1804
  }
1371
- function bt(n, o, e) {
1372
- const t = n.countryCodes || [], i = n.excludedCountryCodes || [];
1373
- return t.length > 0 && !t.includes(o) || i.includes(o) ? !1 : n.countryRank ? !(!Number.isInteger(e) || e < 1 || n.countryRank.min && e < n.countryRank.min || n.countryRank.max && e > n.countryRank.max) : !0;
1805
+ function Xt({ row: n, salesPeriods: o }) {
1806
+ if (!n.salesPeriodRef) return { available: !0, salesPeriod: null, window: n };
1807
+ const e = o.find((r) => r.salesPeriodCode === n.salesPeriodRef.salesPeriodCode && r.version === n.salesPeriodRef.salesPeriodVersion);
1808
+ if (e) {
1809
+ const r = {
1810
+ salesPeriodCode: e.salesPeriodCode,
1811
+ version: e.version,
1812
+ validFrom: e.validFrom,
1813
+ validUntil: e.validUntil
1814
+ };
1815
+ return { available: !0, salesPeriod: r, window: r };
1816
+ }
1817
+ const t = !!n.validFrom || !!n.validUntil;
1818
+ return o.length === 0 && t ? { available: !0, salesPeriod: null, window: n } : { available: !1, salesPeriod: null, window: null };
1819
+ }
1820
+ function Jt(n = {}, o, e) {
1821
+ const t = n.countryCodes || [], r = n.excludedCountryCodes || [];
1822
+ return t.length > 0 && !t.includes(o) || r.includes(o) ? !1 : n.countryRank ? !(!Number.isInteger(e) || e < 1 || n.countryRank.min && e < n.countryRank.min || n.countryRank.max && e > n.countryRank.max) : !0;
1374
1823
  }
1375
- function we({ match: n, countryCode: o, countryRank: e }) {
1824
+ function et({ match: n = {}, countryCode: o, countryRank: e }) {
1376
1825
  if (typeof o != "string" || o.trim().length === 0 || !Number.isInteger(e) || e < 1)
1377
- return $({
1826
+ return V({
1378
1827
  passed: !1,
1379
- code: A.PRICE_COUNTRY_UNRESOLVED,
1828
+ code: P.PRICE_COUNTRY_UNRESOLVED,
1380
1829
  message: "Country code and rank are required to evaluate price match criteria",
1381
1830
  details: { countryCode: o || null, countryRank: e ?? null }
1382
1831
  });
1383
- const t = bt(n, o, e);
1384
- return $({
1832
+ const t = Jt(n, o, e);
1833
+ return V({
1385
1834
  passed: t,
1386
- ...t ? {} : { code: A.PRICE_MATCH_CRITERIA_NOT_MET },
1835
+ ...t ? {} : { code: P.PRICE_MATCH_CRITERIA_NOT_MET },
1387
1836
  message: t ? "Price match criteria passed" : "Price match criteria were not met",
1388
1837
  details: { countryCode: o, countryRank: e }
1389
1838
  });
1390
1839
  }
1391
- function Ot({ priceSchedule: n, currency: o, countryCode: e, countryRank: t, acquisitionSource: i, instant: r }) {
1392
- const s = we({ match: {}, countryCode: e, countryRank: t });
1393
- if (!s.passed)
1394
- return s;
1395
- const c = n.rows.filter((d) => d.currency === o && we({ match: d.match, countryCode: e, countryRank: t }).passed && (d.acquisitionSources.length === 0 || d.acquisitionSources.includes(i)) && gt(d, r));
1396
- return c.length === 0 ? $({
1840
+ function Zt({ priceSchedule: n, salesPeriods: o = [], currency: e, countryCode: t, countryRank: r, acquisitionSource: i, instant: d }) {
1841
+ const c = et({ match: {}, countryCode: t, countryRank: r });
1842
+ if (!c.passed)
1843
+ return c;
1844
+ const a = n.rows.flatMap((u) => {
1845
+ const l = Xt({ row: u, salesPeriods: o });
1846
+ return u.currency === e && et({ match: u.match, countryCode: t, countryRank: r }).passed && (u.acquisitionSources.length === 0 || u.acquisitionSources.includes(i)) && l.available && Kt(l.window, d) ? [{ row: u, salesPeriod: l.salesPeriod }] : [];
1847
+ });
1848
+ return a.length === 0 ? V({
1397
1849
  passed: !1,
1398
- code: A.PRICE_ROW_NOT_FOUND,
1850
+ code: P.PRICE_ROW_NOT_FOUND,
1399
1851
  message: "No price row matches the acquisition context",
1400
- details: { currency: o, countryCode: e, countryRank: t, acquisitionSource: i, instant: r }
1401
- }) : c.length > 1 ? $({
1852
+ details: { currency: e, countryCode: t, countryRank: r, acquisitionSource: i, instant: d }
1853
+ }) : a.length > 1 ? V({
1402
1854
  passed: !1,
1403
- code: A.PRICE_ROW_AMBIGUOUS,
1855
+ code: P.PRICE_ROW_AMBIGUOUS,
1404
1856
  message: "More than one price row matches the acquisition context",
1405
- details: { matchingPriceRowCodes: c.map((d) => d.priceRowCode) }
1406
- }) : $({
1857
+ details: { matchingPriceRowCodes: a.map(({ row: u }) => u.priceRowCode) }
1858
+ }) : V({
1407
1859
  passed: !0,
1408
1860
  message: "Price row resolved",
1409
- details: { countryCode: e, countryRank: t, matchedPriceRow: c[0] }
1861
+ details: {
1862
+ countryCode: t,
1863
+ countryRank: r,
1864
+ matchedPriceRow: a[0].row,
1865
+ matchedSalesPeriod: a[0].salesPeriod
1866
+ }
1410
1867
  });
1411
1868
  }
1412
- function Dt({ rules: n = [], candidateItems: o = [], inventoryFacts: e = [], variantSelections: t = [] }) {
1413
- const i = n.filter((r) => r.ruleType === S.INVENTORY).filter((r) => o.some((s) => w(r.appliesTo, s))).map((r) => {
1414
- const s = J(o, r.appliesTo), c = t.find((m) => m.productCode === r.appliesTo.code), d = Array.from({ length: s }, (m, E) => (c == null ? void 0 : c.selections[E]) || null), a = d.length === s && d.every(Boolean), f = [...d.reduce((m, E) => {
1415
- const b = (E == null ? void 0 : E.variantCode) || "UNSELECTED";
1416
- return m.set(b, (m.get(b) || 0) + 1), m;
1417
- }, /* @__PURE__ */ new Map())].map(([m, E]) => {
1418
- const R = e.find((b) => b.inventoryPoolCode === r.details.inventoryPoolCode && (m === "UNSELECTED" || b.variantCode === m));
1869
+ function en({ rules: n = [], candidateItems: o = [], inventoryFacts: e = [], variantSelections: t = [] }) {
1870
+ const r = n.filter((i) => i.ruleType === _.INVENTORY).filter((i) => o.some((d) => z(i.appliesTo, d))).map((i) => {
1871
+ const d = re(o, i.appliesTo), c = t.find((C) => C.productCode === i.appliesTo.code), a = Array.from({ length: d }, (C, E) => (c == null ? void 0 : c.selections[E]) || null), u = a.length === d && a.every(Boolean), m = [...a.reduce((C, E) => {
1872
+ const A = (E == null ? void 0 : E.variantCode) || "UNSELECTED";
1873
+ return C.set(A, (C.get(A) || 0) + 1), C;
1874
+ }, /* @__PURE__ */ new Map())].map(([C, E]) => {
1875
+ const g = e.find((A) => A.inventoryPoolCode === i.details.inventoryPoolCode && (C === "UNSELECTED" || A.variantCode === C));
1419
1876
  return {
1420
- variantCode: m === "UNSELECTED" ? null : m,
1877
+ variantCode: C === "UNSELECTED" ? null : C,
1421
1878
  requested: E,
1422
- available: (R == null ? void 0 : R.available) ?? 0,
1423
- revision: (R == null ? void 0 : R.revision) ?? null
1879
+ available: (g == null ? void 0 : g.available) ?? 0,
1880
+ revision: (g == null ? void 0 : g.revision) ?? null
1424
1881
  };
1425
- }), O = r.details.inventoryMode === se.STOCKED_VARIANT && !a, N = f.every((m) => m.available >= m.requested), g = r.details.inventoryMode === se.PRODUCTION_DEMAND || !O && N;
1426
- return $({
1427
- passed: g,
1428
- ...g ? {} : { code: O ? A.VARIANT_SELECTION_REQUIRED : A.INVENTORY_UNAVAILABLE },
1429
- message: g ? "Inventory rule passed" : O ? "A Variant must be selected for every unit" : "Inventory is unavailable",
1882
+ }), I = i.details.inventoryMode === Ee.STOCKED_VARIANT && !u, y = m.every((C) => C.available >= C.requested), T = i.details.inventoryMode === Ee.PRODUCTION_DEMAND || !I && y;
1883
+ return V({
1884
+ passed: T,
1885
+ ...T ? {} : { code: I ? P.VARIANT_SELECTION_REQUIRED : P.INVENTORY_UNAVAILABLE },
1886
+ message: T ? "Inventory rule passed" : I ? "A Variant must be selected for every unit" : "Inventory is unavailable",
1430
1887
  details: {
1431
- ruleCode: r.publishedRuleCode,
1432
- inventoryMode: r.details.inventoryMode,
1433
- inventoryPoolCode: r.details.inventoryPoolCode,
1434
- requested: s,
1435
- requests: f,
1436
- intent: g ? { type: "RESERVE_OR_RECORD_DEMAND", requests: f } : null
1888
+ ruleCode: i.publishedRuleCode,
1889
+ inventoryMode: i.details.inventoryMode,
1890
+ inventoryPoolCode: i.details.inventoryPoolCode,
1891
+ requested: d,
1892
+ requests: m,
1893
+ intent: T ? { type: "RESERVE_OR_RECORD_DEMAND", requests: m } : null
1437
1894
  }
1438
1895
  });
1439
1896
  });
1440
- return q({ passed: i.every((r) => r.passed), decisions: i });
1441
- }
1442
- function Nt({ merchandise: n, products: o, quantity: e }) {
1443
- const t = new Map(o.map((i) => [i.productCode, i]));
1444
- return n.components.map((i, r) => {
1445
- const s = t.get(i.productCode);
1446
- if (!s)
1447
- throw new Error(`Product ${i.productCode} is not available for Merchandise ${n.merchandiseCode}`);
1897
+ return L({ passed: r.every((i) => i.passed), decisions: r });
1898
+ }
1899
+ function tn({ merchandise: n, products: o, quantity: e }) {
1900
+ const t = new Map(o.map((r) => [r.productCode, r]));
1901
+ return n.components.map((r, i) => {
1902
+ const d = t.get(r.productCode);
1903
+ if (!d)
1904
+ throw new Error(`Product ${r.productCode} is not available for Merchandise ${n.merchandiseCode}`);
1448
1905
  return {
1449
- productCode: s.productCode,
1450
- productVersion: s.version,
1451
- categoryCodes: s.categoryCodes,
1906
+ productCode: d.productCode,
1907
+ productVersion: d.version,
1908
+ categoryCodes: d.categoryCodes,
1452
1909
  merchandiseCode: n.merchandiseCode,
1453
- componentIndex: r,
1454
- quantity: e * i.quantityPerUnit,
1455
- state: P.VALID
1910
+ componentIndex: i,
1911
+ quantity: e * r.quantityPerUnit,
1912
+ state: S.VALID
1456
1913
  };
1457
1914
  });
1458
1915
  }
1459
- function At(n, o) {
1460
- return n.flatMap((e) => Array.from({ length: e.quantity }, (t, i) => {
1461
- const r = o.filter((s) => s.componentIndex === e.componentIndex && s.unitIndex === i);
1916
+ function nn(n, o) {
1917
+ return n.flatMap((e) => Array.from({ length: e.quantity }, (t, r) => {
1918
+ const i = o.filter((d) => d.componentIndex === e.componentIndex && d.unitIndex === r);
1462
1919
  return {
1463
1920
  ...e,
1464
1921
  quantity: 1,
1465
- state: r.every((s) => s.complete) ? P.VALID : P.PENDING_REQUIREMENT
1922
+ state: i.every((d) => d.complete) ? S.VALID : S.PENDING_REQUIREMENT
1466
1923
  };
1467
1924
  }));
1468
1925
  }
1469
- function je({ items: n, path: o, productDefinitions: e }, t) {
1470
- return n.map((i, r) => {
1471
- const s = e.filter((d) => d.productCode === i.productCode && d.version === i.productVersion);
1472
- return s.length !== 1 && t.push({
1473
- path: `${o}[${r}].productCode`,
1474
- message: s.length === 0 ? `Product ${i.productCode}@${i.productVersion} is missing from recipient Product definitions` : `Product ${i.productCode}@${i.productVersion} is ambiguous in recipient Product definitions`
1926
+ function tt({ items: n, path: o, productDefinitions: e }, t) {
1927
+ return n.map((r, i) => {
1928
+ const d = e.filter((a) => a.productCode === r.productCode && a.version === r.productVersion);
1929
+ return d.length !== 1 && t.push({
1930
+ path: `${o}[${i}].productCode`,
1931
+ message: d.length === 0 ? `Product ${r.productCode}@${r.productVersion} is missing from recipient Product definitions` : `Product ${r.productCode}@${r.productVersion} is ambiguous in recipient Product definitions`
1475
1932
  }), {
1476
- ...typeof i.toObject == "function" ? i.toObject() : i,
1477
- categoryCodes: s.length === 1 ? [...s[0].categoryCodes] : []
1933
+ ...typeof r.toObject == "function" ? r.toObject() : r,
1934
+ categoryCodes: d.length === 1 ? [...d[0].categoryCodes] : []
1478
1935
  };
1479
1936
  });
1480
1937
  }
1481
- function St({ acquisitionSnapshots: n, items: o, path: e }, t) {
1482
- return o.map((i, r) => {
1483
- var d, a;
1484
- const s = n.filter((l) => l.id === i.acquisitionCode), c = (a = (d = s[0]) == null ? void 0 : d.merchandise) == null ? void 0 : a.merchandiseCode;
1485
- return (s.length !== 1 || !c) && t.push({
1486
- path: `${e}[${r}].acquisitionCode`,
1487
- message: s.length === 0 ? `Acquisition ${i.acquisitionCode} is missing from recipient Acquisition snapshots` : s.length > 1 ? `Acquisition ${i.acquisitionCode} is ambiguous in recipient Acquisition snapshots` : `Acquisition ${i.acquisitionCode} does not contain a Merchandise code`
1938
+ function on({ acquisitionSnapshots: n, items: o, path: e }, t) {
1939
+ return o.map((r, i) => {
1940
+ var a, u;
1941
+ const d = n.filter((l) => l.id === r.acquisitionCode), c = (u = (a = d[0]) == null ? void 0 : a.merchandise) == null ? void 0 : u.merchandiseCode;
1942
+ return (d.length !== 1 || !c) && t.push({
1943
+ path: `${e}[${i}].acquisitionCode`,
1944
+ message: d.length === 0 ? `Acquisition ${r.acquisitionCode} is missing from recipient Acquisition snapshots` : d.length > 1 ? `Acquisition ${r.acquisitionCode} is ambiguous in recipient Acquisition snapshots` : `Acquisition ${r.acquisitionCode} does not contain a Merchandise code`
1488
1945
  }), {
1489
- ...i,
1946
+ ...r,
1490
1947
  ...c ? { merchandiseCode: c } : {}
1491
1948
  };
1492
1949
  });
1493
1950
  }
1494
- function Pt(n, o) {
1951
+ function rn(n, o) {
1495
1952
  if (!Array.isArray(n))
1496
1953
  return o.push({ path: "variantSelections", message: "variantSelections must be an array" }), [];
1497
1954
  const e = /* @__PURE__ */ new Set();
1498
- return n.flatMap((t, i) => {
1499
- const r = `variantSelections[${i}]`;
1955
+ return n.flatMap((t, r) => {
1956
+ const i = `variantSelections[${r}]`;
1500
1957
  if (!t || typeof t != "object" || Array.isArray(t))
1501
- return o.push({ path: r, message: "variant selection group must be an object" }), [];
1502
- const s = typeof t.productCode == "string" ? t.productCode.trim() : "";
1503
- if (s ? e.has(s) ? o.push({ path: `${r}.productCode`, message: `duplicate Product ${s}` }) : e.add(s) : o.push({ path: `${r}.productCode`, message: "productCode must be a non-empty string" }), !Array.isArray(t.selections))
1504
- return o.push({ path: `${r}.selections`, message: "selections must be an array" }), [{ productCode: s, selections: [] }];
1505
- const c = t.selections.flatMap((d, a) => {
1506
- if (d === null)
1958
+ return o.push({ path: i, message: "variant selection group must be an object" }), [];
1959
+ const d = typeof t.productCode == "string" ? t.productCode.trim() : "";
1960
+ if (d ? e.has(d) ? o.push({ path: `${i}.productCode`, message: `duplicate Product ${d}` }) : e.add(d) : o.push({ path: `${i}.productCode`, message: "productCode must be a non-empty string" }), !Array.isArray(t.selections))
1961
+ return o.push({ path: `${i}.selections`, message: "selections must be an array" }), [{ productCode: d, selections: [] }];
1962
+ const c = t.selections.flatMap((a, u) => {
1963
+ if (a === null)
1507
1964
  return [null];
1508
1965
  try {
1509
- return [(d instanceof Le ? d : new Le(d)).toObject()];
1966
+ return [(a instanceof Xe ? a : new Xe(a)).toObject()];
1510
1967
  } catch (l) {
1511
- return o.push({ path: `${r}.selections[${a}]`, message: l.message }), [];
1968
+ return o.push({ path: `${i}.selections[${u}]`, message: l.message }), [];
1512
1969
  }
1513
1970
  });
1514
- return [{ productCode: s, selections: c }];
1971
+ return [{ productCode: d, selections: c }];
1515
1972
  });
1516
1973
  }
1517
- function _t(n, o) {
1974
+ function dn(n, o) {
1518
1975
  if (!Array.isArray(n))
1519
1976
  return o.push({ path: "requirementInputs", message: "requirementInputs must be an array" }), [];
1520
1977
  const e = /* @__PURE__ */ new Set();
1521
- return n.flatMap((t, i) => {
1522
- const r = `requirementInputs[${i}]`;
1978
+ return n.flatMap((t, r) => {
1979
+ const i = `requirementInputs[${r}]`;
1523
1980
  if (!t || typeof t != "object" || Array.isArray(t))
1524
- return o.push({ path: r, message: "requirement input group must be an object" }), [];
1525
- const s = typeof t.productCode == "string" ? t.productCode.trim() : "", c = typeof t.requirementCode == "string" ? t.requirementCode.trim() : "";
1526
- s || o.push({ path: `${r}.productCode`, message: "productCode must be a non-empty string" }), c || o.push({ path: `${r}.requirementCode`, message: "requirementCode must be a non-empty string" });
1527
- const d = `${s}:${c}`;
1528
- if (s && c && e.has(d) && o.push({ path: r, message: `duplicate Requirement ${c} for Product ${s}` }), e.add(d), !Array.isArray(t.inputs))
1529
- return o.push({ path: `${r}.inputs`, message: "inputs must be an array" }), [{ productCode: s, requirementCode: c, inputs: [] }];
1530
- const a = t.inputs.map((l, f) => l === null ? null : !l || typeof l != "object" || Array.isArray(l) ? (o.push({ path: `${r}.inputs[${f}]`, message: "input must be an object or null" }), null) : D(l));
1531
- return [{ productCode: s, requirementCode: c, inputs: a }];
1981
+ return o.push({ path: i, message: "requirement input group must be an object" }), [];
1982
+ const d = typeof t.productCode == "string" ? t.productCode.trim() : "", c = typeof t.requirementCode == "string" ? t.requirementCode.trim() : "";
1983
+ d || o.push({ path: `${i}.productCode`, message: "productCode must be a non-empty string" }), c || o.push({ path: `${i}.requirementCode`, message: "requirementCode must be a non-empty string" });
1984
+ const a = `${d}:${c}`;
1985
+ if (d && c && e.has(a) && o.push({ path: i, message: `duplicate Requirement ${c} for Product ${d}` }), e.add(a), !Array.isArray(t.inputs))
1986
+ return o.push({ path: `${i}.inputs`, message: "inputs must be an array" }), [{ productCode: d, requirementCode: c, inputs: [] }];
1987
+ const u = t.inputs.map((l, m) => l === null ? null : !l || typeof l != "object" || Array.isArray(l) ? (o.push({ path: `${i}.inputs[${m}]`, message: "input must be an object or null" }), null) : D(l));
1988
+ return [{ productCode: d, requirementCode: c, inputs: u }];
1532
1989
  });
1533
1990
  }
1534
- function Vt({ categories: n, merchandise: o, priceSchedule: e, products: t, variants: i }, r) {
1535
- const s = o.tenantCode;
1536
- [e, ...n, ...t, ...i].forEach((d) => {
1537
- var a;
1538
- d.tenantCode !== s && r.push({
1539
- path: `${d._type || ((a = d.constructor) == null ? void 0 : a.name) || "definition"}.tenantCode`,
1540
- message: `expected ${s} but received ${d.tenantCode}`
1991
+ function cn({ categories: n, merchandise: o, priceSchedule: e, products: t, variants: r }, i) {
1992
+ const d = o.tenantCode;
1993
+ [e, ...n, ...t, ...r].forEach((a) => {
1994
+ var u;
1995
+ a.tenantCode !== d && i.push({
1996
+ path: `${a._type || ((u = a.constructor) == null ? void 0 : u.name) || "definition"}.tenantCode`,
1997
+ message: `expected ${d} but received ${a.tenantCode}`
1541
1998
  });
1542
1999
  });
1543
2000
  }
1544
- function Mt({ merchandise: n, variants: o, variantSelections: e }, t) {
1545
- const i = new Map(n.components.map((r) => [r.productCode, r]));
1546
- e.forEach((r, s) => {
1547
- const { productCode: c, selections: d } = r, a = `variantSelections[${s}]`, l = i.get(c);
2001
+ function sn({ merchandise: n, variants: o, variantSelections: e }, t) {
2002
+ const r = new Map(n.components.map((i) => [i.productCode, i]));
2003
+ e.forEach((i, d) => {
2004
+ const { productCode: c, selections: a } = i, u = `variantSelections[${d}]`, l = r.get(c);
1548
2005
  if (!l) {
1549
2006
  t.push({
1550
- path: `${a}.productCode`,
2007
+ path: `${u}.productCode`,
1551
2008
  message: `Product ${c} is not a Merchandise component`
1552
2009
  });
1553
2010
  return;
1554
2011
  }
1555
- d.filter(Boolean).forEach((f, O) => {
1556
- const N = o.filter((m) => m.variantCode === f.variantCode && m.version === f.variantVersion);
1557
- if (N.length !== 1) {
2012
+ a.filter(Boolean).forEach((m, I) => {
2013
+ const y = o.filter((C) => C.variantCode === m.variantCode && C.version === m.variantVersion);
2014
+ if (y.length !== 1) {
1558
2015
  t.push({
1559
- path: `${a}.selections[${O}]`,
1560
- message: N.length === 0 ? `Variant ${f.variantCode}@${f.variantVersion} is missing` : `Variant ${f.variantCode}@${f.variantVersion} is ambiguous`
2016
+ path: `${u}.selections[${I}]`,
2017
+ message: y.length === 0 ? `Variant ${m.variantCode}@${m.variantVersion} is missing` : `Variant ${m.variantCode}@${m.variantVersion} is ambiguous`
1561
2018
  });
1562
2019
  return;
1563
2020
  }
1564
- const [g] = N;
1565
- (g.productCode !== c || g.productVersion !== l.productVersion) && t.push({
1566
- path: `${a}.selections[${O}]`,
1567
- message: `Variant ${f.variantCode}@${f.variantVersion} does not belong to Product ${c}@${l.productVersion}`
2021
+ const [T] = y;
2022
+ (T.productCode !== c || T.productVersion !== l.productVersion) && t.push({
2023
+ path: `${u}.selections[${I}]`,
2024
+ message: `Variant ${m.variantCode}@${m.variantVersion} does not belong to Product ${c}@${l.productVersion}`
1568
2025
  });
1569
2026
  });
1570
2027
  });
1571
2028
  }
1572
- function qt({
2029
+ function an({
1573
2030
  categories: n = [],
1574
2031
  merchandise: o,
1575
2032
  priceSchedule: e,
1576
2033
  products: t = [],
1577
- quantity: i,
1578
- requirementInputs: r = [],
1579
- variants: s = [],
2034
+ quantity: r,
2035
+ requirementInputs: i = [],
2036
+ variants: d = [],
1580
2037
  variantSelections: c = []
1581
2038
  }) {
1582
- const d = [], a = Pt(c, d), l = _t(r, d);
1583
- (!Number.isInteger(i) || i < 1) && d.push({ path: "quantity", message: "quantity must be a positive integer" }), Vt({ categories: n, merchandise: o, priceSchedule: e, products: t, variants: s }, d), e.priceScheduleCode !== o.priceScheduleCode && d.push({
2039
+ const a = [], u = rn(c, a), l = dn(i, a);
2040
+ (!Number.isInteger(r) || r < 1) && a.push({ path: "quantity", message: "quantity must be a positive integer" }), cn({ categories: n, merchandise: o, priceSchedule: e, products: t, variants: d }, a), e.priceScheduleCode !== o.priceScheduleCode && a.push({
1584
2041
  path: "priceSchedule.priceScheduleCode",
1585
2042
  message: `expected ${o.priceScheduleCode} but received ${e.priceScheduleCode}`
1586
2043
  });
1587
- const f = t.reduce((m, E) => {
1588
- const R = m.get(E.productCode) || [];
1589
- return R.push(E), m.set(E.productCode, R), m;
1590
- }, /* @__PURE__ */ new Map()), O = n.reduce((m, E) => (m.set(E.categoryCode, (m.get(E.categoryCode) || 0) + 1), m), /* @__PURE__ */ new Map()), N = /* @__PURE__ */ new Set();
1591
- o.components.forEach((m, E) => {
1592
- const R = `${m.productCode}@${m.productVersion}`;
1593
- N.has(R) && d.push({
2044
+ const m = t.reduce((C, E) => {
2045
+ const g = C.get(E.productCode) || [];
2046
+ return g.push(E), C.set(E.productCode, g), C;
2047
+ }, /* @__PURE__ */ new Map()), I = n.reduce((C, E) => (C.set(E.categoryCode, (C.get(E.categoryCode) || 0) + 1), C), /* @__PURE__ */ new Map()), y = /* @__PURE__ */ new Set();
2048
+ o.components.forEach((C, E) => {
2049
+ const g = `${C.productCode}@${C.productVersion}`;
2050
+ y.has(g) && a.push({
1594
2051
  path: `merchandise.components[${E}]`,
1595
- message: `duplicate component ${R}; use quantityPerUnit instead`
1596
- }), N.add(R);
1597
- const b = f.get(m.productCode) || [];
1598
- b.length === 0 ? d.push({
2052
+ message: `duplicate component ${g}; use quantityPerUnit instead`
2053
+ }), y.add(g);
2054
+ const A = m.get(C.productCode) || [];
2055
+ A.length === 0 ? a.push({
1599
2056
  path: `merchandise.components[${E}].productCode`,
1600
- message: `Product ${m.productCode} is missing`
1601
- }) : b.length > 1 ? d.push({
2057
+ message: `Product ${C.productCode} is missing`
2058
+ }) : A.length > 1 ? a.push({
1602
2059
  path: `merchandise.components[${E}].productCode`,
1603
- message: `Product ${m.productCode} is ambiguous`
1604
- }) : b[0].version !== m.productVersion ? d.push({
2060
+ message: `Product ${C.productCode} is ambiguous`
2061
+ }) : A[0].version !== C.productVersion ? a.push({
1605
2062
  path: `merchandise.components[${E}].productVersion`,
1606
- message: `expected Product version ${m.productVersion} but received ${b[0].version}`
1607
- }) : b[0].categoryCodes.forEach((C) => {
1608
- const p = O.get(C) || 0;
1609
- p !== 1 && d.push({
1610
- path: `products.${m.productCode}.categoryCodes`,
1611
- message: p === 0 ? `Category ${C} is missing` : `Category ${C} is ambiguous`
2063
+ message: `expected Product version ${C.productVersion} but received ${A[0].version}`
2064
+ }) : A[0].categoryCodes.forEach((v) => {
2065
+ const p = I.get(v) || 0;
2066
+ p !== 1 && a.push({
2067
+ path: `products.${C.productCode}.categoryCodes`,
2068
+ message: p === 0 ? `Category ${v} is missing` : `Category ${v} is ambiguous`
1612
2069
  });
1613
2070
  });
1614
- }), Mt({
2071
+ }), sn({
1615
2072
  merchandise: o,
1616
- variants: s,
1617
- variantSelections: a
1618
- }, d);
1619
- const g = new Set(o.components.map((m) => m.productCode));
1620
- return l.forEach((m, E) => {
1621
- g.has(m.productCode) || d.push({
2073
+ variants: d,
2074
+ variantSelections: u
2075
+ }, a);
2076
+ const T = new Set(o.components.map((C) => C.productCode));
2077
+ return l.forEach((C, E) => {
2078
+ T.has(C.productCode) || a.push({
1622
2079
  path: `requirementInputs[${E}].productCode`,
1623
- message: `Product ${m.productCode} is not a Merchandise component`
2080
+ message: `Product ${C.productCode} is not a Merchandise component`
1624
2081
  });
1625
- }), $({
1626
- passed: d.length === 0,
1627
- ...d.length === 0 ? {} : { code: A.DEFINITION_INVALID },
1628
- message: d.length === 0 ? "Acquisition definitions are consistent" : "Acquisition definitions are inconsistent",
2082
+ }), V({
2083
+ passed: a.length === 0,
2084
+ ...a.length === 0 ? {} : { code: P.DEFINITION_INVALID },
2085
+ message: a.length === 0 ? "Acquisition definitions are consistent" : "Acquisition definitions are inconsistent",
1629
2086
  details: {
1630
- issues: d,
2087
+ issues: a,
1631
2088
  requirementInputs: l,
1632
- variantSelections: a
2089
+ variantSelections: u
1633
2090
  }
1634
2091
  });
1635
2092
  }
1636
- function Kt({
2093
+ function qn({
1637
2094
  acquisitionSource: n,
1638
2095
  categories: o,
1639
2096
  countryCode: e,
1640
2097
  countryRank: t,
1641
- currency: i,
1642
- eligibilityFacts: r = [],
1643
- eventRegistrationCode: s,
2098
+ currency: r,
2099
+ eligibilityFacts: i = [],
2100
+ eventRegistrationCode: d,
1644
2101
  existingItems: c = [],
1645
- instant: d,
1646
- inventoryFacts: a = [],
2102
+ instant: a,
2103
+ inventoryFacts: u = [],
1647
2104
  merchandise: l,
1648
- priceSchedule: f,
1649
- products: O,
1650
- publishedRules: N,
1651
- quantity: g = 1,
1652
- requirementInputs: m = [],
2105
+ priceSchedule: m,
2106
+ products: I,
2107
+ publishedRules: y,
2108
+ quantity: T = 1,
2109
+ requirementInputs: C = [],
1653
2110
  requirementValues: E = {},
1654
- variants: R = [],
1655
- variantSelections: b = [],
1656
- recipientFacts: C
2111
+ salesPeriods: g = [],
2112
+ variants: A = [],
2113
+ variantSelections: v = [],
2114
+ recipientFacts: p
1657
2115
  }) {
1658
- const p = (C == null ? void 0 : C.eligibilityFacts) || r, y = (C == null ? void 0 : C.existingWalletItems) || (C == null ? void 0 : C.existingItems) || c, h = (C == null ? void 0 : C.projectedItems) || [], W = (C == null ? void 0 : C.eventRegistrationCode) || s, U = qt({
2116
+ const R = (p == null ? void 0 : p.eligibilityFacts) || i, b = (p == null ? void 0 : p.existingWalletItems) || (p == null ? void 0 : p.existingItems) || c, te = (p == null ? void 0 : p.projectedItems) || [], F = (p == null ? void 0 : p.eventRegistrationCode) || d, ue = an({
1659
2117
  categories: o,
1660
2118
  merchandise: l,
1661
- priceSchedule: f,
1662
- products: O,
1663
- quantity: g,
1664
- requirementInputs: m,
1665
- variants: R,
1666
- variantSelections: b
1667
- }), B = [], ae = (C == null ? void 0 : C.productDefinitions) || O, Qe = je({
1668
- items: y,
2119
+ priceSchedule: m,
2120
+ products: I,
2121
+ quantity: T,
2122
+ requirementInputs: C,
2123
+ variants: A,
2124
+ variantSelections: v
2125
+ }), G = [], Ie = (p == null ? void 0 : p.productDefinitions) || I, mt = tt({
2126
+ items: b,
1669
2127
  path: "recipientFacts.existingWalletItems",
1670
- productDefinitions: ae
1671
- }, B), ue = St({
1672
- acquisitionSnapshots: (C == null ? void 0 : C.acquisitionSnapshots) || [],
1673
- items: Qe,
2128
+ productDefinitions: Ie
2129
+ }, G), Te = on({
2130
+ acquisitionSnapshots: (p == null ? void 0 : p.acquisitionSnapshots) || [],
2131
+ items: mt,
1674
2132
  path: "recipientFacts.existingWalletItems"
1675
- }, B), Be = je({
1676
- items: h,
2133
+ }, G), Ct = tt({
2134
+ items: te,
1677
2135
  path: "recipientFacts.projectedItems",
1678
- productDefinitions: ae
1679
- }, B), Fe = [
1680
- ...U.details.issues,
1681
- ...B
1682
- ], Y = B.length === 0 ? U : $({
2136
+ productDefinitions: Ie
2137
+ }, G), ft = [
2138
+ ...ue.details.issues,
2139
+ ...G
2140
+ ], k = G.length === 0 ? ue : V({
1683
2141
  passed: !1,
1684
- code: A.DEFINITION_INVALID,
2142
+ code: P.DEFINITION_INVALID,
1685
2143
  message: "Acquisition definitions are inconsistent",
1686
2144
  details: {
1687
- ...U.details,
1688
- issues: Fe
2145
+ ...ue.details,
2146
+ issues: ft
1689
2147
  }
1690
- }), v = lt({ categories: o, products: O, merchandise: l, acquisitionSource: n, publishedRules: N }), F = Y.passed ? Nt({ merchandise: l, products: O, quantity: g }) : [], te = Y.details.variantSelections, le = Y.details.requirementInputs, pe = yt({
1691
- rules: v.rules,
1692
- eligibilityFacts: p,
1693
- eventRegistrationCode: W,
1694
- candidateItems: F
1695
- }), ne = Tt({
1696
- rules: v.rules,
1697
- candidateItems: F,
1698
- requirementInputs: le,
2148
+ }), w = jt({ categories: o, products: I, merchandise: l, acquisitionSource: n, publishedRules: y }), H = k.passed ? tn({ merchandise: l, products: I, quantity: T }) : [], pe = k.details.variantSelections, ge = k.details.requirementInputs, be = Ft({
2149
+ rules: w.rules,
2150
+ eligibilityFacts: R,
2151
+ eventRegistrationCode: F,
2152
+ candidateItems: H
2153
+ }), le = Ht({
2154
+ rules: w.rules,
2155
+ candidateItems: H,
2156
+ requirementInputs: ge,
1699
2157
  requirementValues: E,
1700
- variantSelections: te
1701
- }), me = [
1702
- ...Be,
1703
- ...At(F, ne.plans)
1704
- ], oe = Ct({
1705
- rules: v.rules,
1706
- existingItems: ue,
1707
- candidateItems: me
1708
- }), fe = ht({
1709
- rules: v.rules,
1710
- existingItems: ue,
1711
- candidateItems: me
1712
- }), Ce = Ot({ priceSchedule: f, currency: i, countryCode: e, countryRank: t, acquisitionSource: n, instant: d }), Ee = Dt({
1713
- rules: v.rules,
1714
- candidateItems: F,
1715
- inventoryFacts: a,
1716
- variantSelections: te
1717
- }), ke = oe.decisions.filter((j) => j.details.limitType === K.ORDER).every((j) => j.passed), Ge = oe.decisions.filter((j) => j.details.limitType !== K.ORDER).every((j) => j.passed), ye = Y.passed && v.passed && ke && Ce.passed && Ee.passed, Ie = Ge, Re = Y.passed && v.passed && pe.passed && Ie && fe.passed, he = ye && Re;
1718
- return q({
1719
- passed: he,
1720
- canPurchase: ye,
1721
- canAcquire: Re,
1722
- canHold: Ie,
1723
- itemValid: he && ne.itemValid,
1724
- candidateItems: F,
1725
- requirementInputs: le,
1726
- variantSelections: te,
1727
- effectiveRules: v,
2158
+ variantSelections: pe
2159
+ }), De = [
2160
+ ...Ct,
2161
+ ...nn(H, le.plans)
2162
+ ], me = Bt({
2163
+ rules: w.rules,
2164
+ existingItems: Te,
2165
+ candidateItems: De
2166
+ }), Ne = Gt({
2167
+ rules: w.rules,
2168
+ existingItems: Te,
2169
+ candidateItems: De
2170
+ }), Ae = Zt({ priceSchedule: m, salesPeriods: g, currency: r, countryCode: e, countryRank: t, acquisitionSource: n, instant: a }), Oe = en({
2171
+ rules: w.rules,
2172
+ candidateItems: H,
2173
+ inventoryFacts: u,
2174
+ variantSelections: pe
2175
+ }), Et = me.decisions.filter((Q) => Q.details.limitType === ee.ORDER).every((Q) => Q.passed), yt = me.decisions.filter((Q) => Q.details.limitType !== ee.ORDER).every((Q) => Q.passed), Se = k.passed && w.passed && Et && Ae.passed && Oe.passed, Pe = yt, _e = k.passed && w.passed && be.passed && Pe && Ne.passed, Me = Se && _e;
2176
+ return L({
2177
+ passed: Me,
2178
+ canPurchase: Se,
2179
+ canAcquire: _e,
2180
+ canHold: Pe,
2181
+ itemValid: Me && le.itemValid,
2182
+ candidateItems: H,
2183
+ requirementInputs: ge,
2184
+ variantSelections: pe,
2185
+ effectiveRules: w,
1728
2186
  evaluations: {
1729
- definitions: Y,
1730
- eligibility: pe,
1731
- quantity: oe,
1732
- prerequisites: fe,
1733
- requirements: ne,
1734
- price: Ce,
1735
- inventory: Ee
2187
+ definitions: k,
2188
+ eligibility: be,
2189
+ quantity: me,
2190
+ prerequisites: Ne,
2191
+ requirements: le,
2192
+ price: Ae,
2193
+ inventory: Oe
1736
2194
  }
1737
2195
  });
1738
2196
  }
1739
- function Wt({ id: n, evaluated: o, preview: e, context: t }) {
2197
+ function Ln({ id: n, evaluated: o, preview: e, context: t }) {
1740
2198
  if (!e.passed)
1741
2199
  throw new Error("Cannot snapshot a failed acquisition preview");
1742
- const i = typeof t.merchandise.toObject == "function" ? t.merchandise.toObject() : D(t.merchandise), r = t.products.map((s) => typeof s.toObject == "function" ? s.toObject() : D(s));
1743
- return new Xe({
2200
+ const r = typeof t.merchandise.toObject == "function" ? t.merchandise.toObject() : D(t.merchandise), i = t.products.map((d) => typeof d.toObject == "function" ? d.toObject() : D(d));
2201
+ return new At({
1744
2202
  id: n,
1745
2203
  contractVersion: 2,
1746
2204
  eventRegistrationCode: t.eventRegistrationCode,
1747
2205
  purchaserEventRegistrationCode: t.purchaserEventRegistrationCode || t.eventRegistrationCode,
1748
2206
  payerEventRegistrationCode: t.payerEventRegistrationCode || t.eventRegistrationCode,
1749
2207
  acquisitionSource: t.acquisitionSource,
1750
- merchandise: i,
2208
+ merchandise: r,
1751
2209
  quantity: t.quantity,
1752
- products: r,
2210
+ products: i,
1753
2211
  priceScheduleRef: {
1754
2212
  priceScheduleCode: t.priceSchedule.priceScheduleCode,
1755
2213
  priceScheduleVersion: t.priceSchedule.version
@@ -1770,86 +2228,182 @@ function Wt({ id: n, evaluated: o, preview: e, context: t }) {
1770
2228
  evaluated: o
1771
2229
  });
1772
2230
  }
1773
- function Ht({ acquisitionSnapshot: n, walletItemIdFactory: o }) {
2231
+ function Vn({ acquisitionSnapshot: n, walletItemIdFactory: o }) {
1774
2232
  const e = [];
1775
- return n.merchandise.components.forEach((t, i) => {
1776
- const r = n.quantity * t.quantityPerUnit;
1777
- for (let s = 0; s < r; s += 1) {
1778
- const c = n.requirementPlans.filter((l) => l.componentIndex === i && l.unitIndex === s), d = n.variantSelections.find((l) => l.productCode === t.productCode), a = d == null ? void 0 : d.selections[s];
2233
+ return n.merchandise.components.forEach((t, r) => {
2234
+ const i = n.quantity * t.quantityPerUnit;
2235
+ for (let d = 0; d < i; d += 1) {
2236
+ const c = n.requirementPlans.filter((l) => l.componentIndex === r && l.unitIndex === d), a = n.variantSelections.find((l) => l.productCode === t.productCode), u = a == null ? void 0 : a.selections[d];
1779
2237
  e.push({
1780
- walletItemCode: o({ component: t, index: s, acquisitionSnapshot: n }),
2238
+ walletItemCode: o({ component: t, index: d, acquisitionSnapshot: n }),
1781
2239
  eventRegistrationCode: n.eventRegistrationCode,
1782
2240
  productCode: t.productCode,
1783
2241
  productVersion: t.productVersion,
1784
2242
  acquisitionCode: n.id,
1785
2243
  quantity: 1,
1786
- variantCode: (a == null ? void 0 : a.variantCode) || null,
1787
- variantVersion: (a == null ? void 0 : a.variantVersion) || null,
1788
- state: c.every((l) => l.complete) ? P.VALID : P.PENDING_REQUIREMENT,
2244
+ variantCode: (u == null ? void 0 : u.variantCode) || null,
2245
+ variantVersion: (u == null ? void 0 : u.variantVersion) || null,
2246
+ state: c.every((l) => l.complete) ? S.VALID : S.PENDING_REQUIREMENT,
1789
2247
  requirementPlans: c.map((l) => ({ ...l, unitIndex: 0 }))
1790
2248
  });
1791
2249
  }
1792
- }), q(e);
2250
+ }), L(e);
2251
+ }
2252
+ function vn({ now: n = Date.now(), requirementCode: o, values: e, walletItem: t }) {
2253
+ const r = st(t), i = ut(e, "values"), d = pt(o, "requirementCode"), c = r.requirementPlans.findIndex((y) => {
2254
+ var T;
2255
+ return ((T = y.requirement) == null ? void 0 : T.requirementCode) === d;
2256
+ });
2257
+ if (c < 0)
2258
+ throw W("WALLET_ITEM_REQUIREMENT_NOT_FOUND", "The Wallet Item Requirement was not found.");
2259
+ const a = r.requirementPlans[c];
2260
+ ct({ now: n, plan: a });
2261
+ const u = a.requirement.fields || [], l = new Set(u.map((y) => y.fieldCode)), m = Object.keys(i).find((y) => !l.has(y));
2262
+ if (m)
2263
+ throw W("WALLET_ITEM_REQUIREMENT_FIELD_UNKNOWN", `Requirement field "${m}" is not defined.`);
2264
+ const I = u.map((y) => y.fieldCode).filter((y) => !lt(i[y]));
2265
+ return r.requirementPlans[c] = {
2266
+ ...a,
2267
+ complete: I.length === 0,
2268
+ missingFields: I,
2269
+ values: structuredClone(i)
2270
+ }, r.state = at(r.requirementPlans), new se(r).toObject();
2271
+ }
2272
+ function Un({ now: n = Date.now(), variant: o, walletItem: e }) {
2273
+ const t = st(e), r = ut(o, "variant"), i = pt(r.variantCode, "variant.variantCode"), d = Number(r.version);
2274
+ if (!Number.isSafeInteger(d) || d <= 0)
2275
+ throw new TypeError("variant.version must be a positive integer.");
2276
+ if (r.productCode !== t.productCode || r.productVersion !== t.productVersion)
2277
+ throw W("WALLET_ITEM_VARIANT_PRODUCT_MISMATCH", "The selected Variant does not belong to this Wallet Item Product version.");
2278
+ const c = t.requirementPlans.findIndex((m) => {
2279
+ var I;
2280
+ return (((I = m.requirement) == null ? void 0 : I.fields) || []).some((y) => y.inputType === X.VARIANT);
2281
+ });
2282
+ if (c < 0)
2283
+ throw W("WALLET_ITEM_VARIANT_REQUIREMENT_NOT_FOUND", "The Wallet Item does not have a Variant Requirement.");
2284
+ const a = t.requirementPlans[c];
2285
+ ct({ now: n, plan: a });
2286
+ const u = { ...a.values || {} };
2287
+ a.requirement.fields.filter((m) => m.inputType === X.VARIANT).forEach((m) => {
2288
+ u[m.fieldCode] = r[m.optionValueKey];
2289
+ });
2290
+ const l = a.requirement.fields.map((m) => m.fieldCode).filter((m) => !lt(u[m]));
2291
+ return t.requirementPlans[c] = {
2292
+ ...a,
2293
+ complete: l.length === 0,
2294
+ missingFields: l,
2295
+ values: u
2296
+ }, t.state = at(t.requirementPlans), t.variantCode = i, t.variantVersion = d, new se(t).toObject();
2297
+ }
2298
+ function ct({ now: n, plan: o }) {
2299
+ if (o.modificationMode === j.LOCK_AFTER_COMPLETE && o.complete)
2300
+ throw W("WALLET_ITEM_REQUIREMENT_LOCKED", "The completed Wallet Item Requirement is locked.");
2301
+ if (o.modificationMode === j.UNTIL_DEADLINE && (!o.modificationDeadline || Number(n) >= Date.parse(o.modificationDeadline)))
2302
+ throw W("WALLET_ITEM_REQUIREMENT_DEADLINE_PASSED", "The Wallet Item Requirement modification deadline has passed.");
2303
+ }
2304
+ function st(n) {
2305
+ return n instanceof se ? n.toObject() : new se(n).toObject();
2306
+ }
2307
+ function at(n) {
2308
+ return n.every((o) => o.complete) ? S.VALID : S.PENDING_REQUIREMENT;
2309
+ }
2310
+ function ut(n, o) {
2311
+ if (!n || typeof n != "object" || Array.isArray(n))
2312
+ throw new TypeError(`${o} must be an object.`);
2313
+ return structuredClone(n);
2314
+ }
2315
+ function pt(n, o) {
2316
+ if (typeof n != "string" || n.trim().length === 0)
2317
+ throw new TypeError(`${o} is required.`);
2318
+ return n.trim();
2319
+ }
2320
+ function lt(n) {
2321
+ return !(n === null || typeof n > "u" || typeof n == "string" && n.trim().length === 0);
2322
+ }
2323
+ function W(n, o) {
2324
+ return Object.assign(new Error(o), { code: n });
1793
2325
  }
1794
- const Jt = 2;
2326
+ const $n = 2;
1795
2327
  export {
1796
- Xe as AcquisitionSnapshot,
1797
- Lt as Category,
1798
- Ut as Currency,
1799
- A as DECISION_CODES,
1800
- mt as DEFAULT_ACTIVE_ITEM_STATES,
1801
- x as ELIGIBILITY_STATES,
1802
- vt as EligibilityFact,
1803
- se as INVENTORY_MODES,
1804
- ce as MATCH_MODES,
1805
- wt as Merchandise,
1806
- Ae as MerchandiseComponent,
1807
- k as PREREQUISITE_EVIDENCE_SOURCES,
1808
- Te as PriceEvaluationContext,
1809
- Pe as PriceMatchCriteria,
1810
- Me as PriceRow,
1811
- jt as PriceSchedule,
1812
- ge as PriceScheduleRef,
1813
- xt as Product,
1814
- zt as PublishedRule,
1815
- Yt as PublishedRuleRef,
1816
- K as QUANTITY_LIMIT_TYPES,
1817
- ie as REQUIREMENT_COMPLETION_STATES,
1818
- de as REQUIREMENT_COMPLETION_TIMINGS,
1819
- re as REQUIREMENT_INPUT_TYPES,
1820
- Q as REQUIREMENT_MODIFICATION_MODES,
1821
- H as REQUIREMENT_MODIFICATION_STATES,
1822
- V as RULE_SOURCES,
1823
- S as RULE_TYPES,
1824
- Qt as RefundPolicy,
1825
- qe as RefundPolicyRef,
1826
- X as RequirementDefinition,
1827
- be as RequirementFieldDefinition,
1828
- ee as RequirementPlan,
1829
- Jt as STORE_MODEL_V2_CONTRACT_VERSION,
1830
- Bt as SalesPeriod,
1831
- _e as SalesPeriodRef,
1832
- G as StoreContractValidationError,
1833
- L as StoreEntity,
1834
- _ as TARGET_TYPES,
1835
- pt as TERMINAL_ITEM_STATES,
1836
- Ft as Variant,
1837
- Le as VariantRef,
1838
- P as WALLET_ITEM_STATES,
1839
- kt as WalletItem,
1840
- lt as collectEffectiveRules,
1841
- Wt as createAcquisitionSnapshot,
1842
- Kt as evaluateAcquisitionPreview,
1843
- yt as evaluateEligibilityRules,
1844
- Dt as evaluateInventoryRules,
1845
- ht as evaluatePrerequisiteRules,
1846
- we as evaluatePriceMatchCriteria,
1847
- Ct as evaluateQuantityRules,
1848
- Gt as evaluateRequirementConfigurationState,
1849
- Nt as expandCandidateItems,
1850
- Tt as planItemRequirements,
1851
- Ht as projectWalletItems,
1852
- Ot as resolvePrice,
1853
- qt as validateAcquisitionDefinitions
2328
+ Ce as ACQUISITION_SOURCES,
2329
+ pn as Acquisition,
2330
+ At as AcquisitionSnapshot,
2331
+ ln as Category,
2332
+ we as CommercialLifecycle,
2333
+ mn as Currency,
2334
+ P as DECISION_CODES,
2335
+ zt as DEFAULT_ACTIVE_ITEM_STATES,
2336
+ Y as ELIGIBILITY_STATES,
2337
+ Cn as EligibilityFact,
2338
+ Ot as INVENTORY_LEDGER_ACTIONS,
2339
+ Ee as INVENTORY_MODES,
2340
+ fn as InventoryBalance,
2341
+ En as InventoryLedgerEntry,
2342
+ yn as Invoice,
2343
+ Rn as InvoiceRevision,
2344
+ ye as MATCH_MODES,
2345
+ hn as Merchandise,
2346
+ je as MerchandiseComponent,
2347
+ ht as ORDER_STATES,
2348
+ In as Order,
2349
+ xe as OrderLine,
2350
+ Tt as PAYMENT_ATTEMPT_STATES,
2351
+ K as PREREQUISITE_EVIDENCE_SOURCES,
2352
+ Tn as PaymentAttempt,
2353
+ Be as PaymentMethodConfigurationSnapshot,
2354
+ ve as PriceEvaluationContext,
2355
+ Fe as PriceMatchCriteria,
2356
+ Ge as PriceRow,
2357
+ gn as PriceSchedule,
2358
+ Ue as PriceScheduleRef,
2359
+ bn as Product,
2360
+ Dn as PublishedRule,
2361
+ Nn as PublishedRuleRef,
2362
+ ee as QUANTITY_LIMIT_TYPES,
2363
+ fe as REQUIREMENT_COMPLETION_STATES,
2364
+ Re as REQUIREMENT_COMPLETION_TIMINGS,
2365
+ X as REQUIREMENT_INPUT_TYPES,
2366
+ j as REQUIREMENT_MODIFICATION_MODES,
2367
+ ne as REQUIREMENT_MODIFICATION_STATES,
2368
+ It as RESERVATION_STATES,
2369
+ q as RULE_SOURCES,
2370
+ _ as RULE_TYPES,
2371
+ An as Receipt,
2372
+ On as RefundPolicy,
2373
+ He as RefundPolicyRef,
2374
+ ie as RequirementDefinition,
2375
+ $e as RequirementFieldDefinition,
2376
+ ce as RequirementPlan,
2377
+ ze as Reservation,
2378
+ $n as STORE_MODEL_V2_CONTRACT_VERSION,
2379
+ Sn as SalesPeriod,
2380
+ ke as SalesPeriodRef,
2381
+ Pn as Settlement,
2382
+ J as StoreContractValidationError,
2383
+ O as StoreEntity,
2384
+ M as TARGET_TYPES,
2385
+ xt as TERMINAL_ITEM_STATES,
2386
+ _n as Variant,
2387
+ Xe as VariantRef,
2388
+ S as WALLET_ITEM_STATES,
2389
+ se as WalletItem,
2390
+ vn as applyWalletItemRequirementValues,
2391
+ Un as applyWalletItemVariantSelection,
2392
+ Qe as calculatePaymentDeadline,
2393
+ St as canStartPaymentAttempt,
2394
+ jt as collectEffectiveRules,
2395
+ Ln as createAcquisitionSnapshot,
2396
+ qn as evaluateAcquisitionPreview,
2397
+ Ft as evaluateEligibilityRules,
2398
+ en as evaluateInventoryRules,
2399
+ Gt as evaluatePrerequisiteRules,
2400
+ et as evaluatePriceMatchCriteria,
2401
+ Bt as evaluateQuantityRules,
2402
+ Mn as evaluateRequirementConfigurationState,
2403
+ tn as expandCandidateItems,
2404
+ Ht as planItemRequirements,
2405
+ Vn as projectWalletItems,
2406
+ Zt as resolvePrice,
2407
+ an as validateAcquisitionDefinitions
1854
2408
  };
1855
2409
  //# sourceMappingURL=q-store-model-v2.esm.js.map