@fantastic.dev/better-stripe 0.87.0 → 0.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalObservation/active-scheduled.d.ts +6 -0
  4. package/dist/client/billing/renewalObservation/active-scheduled.d.ts.map +1 -0
  5. package/dist/client/billing/renewalObservation/active-scheduled.js +37 -0
  6. package/dist/client/billing/renewalObservation/active-scheduled.js.map +1 -0
  7. package/dist/client/billing/renewalObservation/common.d.ts +47 -0
  8. package/dist/client/billing/renewalObservation/common.d.ts.map +1 -0
  9. package/dist/client/billing/renewalObservation/common.js +39 -0
  10. package/dist/client/billing/renewalObservation/common.js.map +1 -0
  11. package/dist/client/billing/renewalObservation/configured-baseline.d.ts +76 -0
  12. package/dist/client/billing/renewalObservation/configured-baseline.d.ts.map +1 -0
  13. package/dist/client/billing/renewalObservation/configured-baseline.js +26 -0
  14. package/dist/client/billing/renewalObservation/configured-baseline.js.map +1 -0
  15. package/dist/client/billing/renewalObservation/coupon-discount-joins.d.ts +53 -0
  16. package/dist/client/billing/renewalObservation/coupon-discount-joins.d.ts.map +1 -0
  17. package/dist/client/billing/renewalObservation/coupon-discount-joins.js +103 -0
  18. package/dist/client/billing/renewalObservation/coupon-discount-joins.js.map +1 -0
  19. package/dist/client/billing/renewalObservation/invoice-tax-identity.d.ts +52 -0
  20. package/dist/client/billing/renewalObservation/invoice-tax-identity.d.ts.map +1 -0
  21. package/dist/client/billing/renewalObservation/invoice-tax-identity.js +49 -0
  22. package/dist/client/billing/renewalObservation/invoice-tax-identity.js.map +1 -0
  23. package/dist/client/billing/renewalObservation/pending-and-stage.d.ts +76 -0
  24. package/dist/client/billing/renewalObservation/pending-and-stage.d.ts.map +1 -0
  25. package/dist/client/billing/renewalObservation/pending-and-stage.js +36 -0
  26. package/dist/client/billing/renewalObservation/pending-and-stage.js.map +1 -0
  27. package/dist/client/billing/renewalObservation/phase-price-normalization.d.ts +57 -0
  28. package/dist/client/billing/renewalObservation/phase-price-normalization.d.ts.map +1 -0
  29. package/dist/client/billing/renewalObservation/phase-price-normalization.js +70 -0
  30. package/dist/client/billing/renewalObservation/phase-price-normalization.js.map +1 -0
  31. package/dist/client/billing/renewalObservation/planProjection.d.ts +8 -0
  32. package/dist/client/billing/renewalObservation/planProjection.d.ts.map +1 -0
  33. package/dist/client/billing/renewalObservation/planProjection.js +150 -0
  34. package/dist/client/billing/renewalObservation/planProjection.js.map +1 -0
  35. package/dist/client/billing/renewalObservation/reference-catalog.d.ts +37 -0
  36. package/dist/client/billing/renewalObservation/reference-catalog.d.ts.map +1 -0
  37. package/dist/client/billing/renewalObservation/reference-catalog.js +109 -0
  38. package/dist/client/billing/renewalObservation/reference-catalog.js.map +1 -0
  39. package/dist/client/billing/renewalObservation/schedule-templates.d.ts +74 -0
  40. package/dist/client/billing/renewalObservation/schedule-templates.d.ts.map +1 -0
  41. package/dist/client/billing/renewalObservation/schedule-templates.js +72 -0
  42. package/dist/client/billing/renewalObservation/schedule-templates.js.map +1 -0
  43. package/dist/client/billing/renewalObservation/scheduled-context.d.ts +44 -0
  44. package/dist/client/billing/renewalObservation/scheduled-context.d.ts.map +1 -0
  45. package/dist/client/billing/renewalObservation/scheduled-context.js +64 -0
  46. package/dist/client/billing/renewalObservation/scheduled-context.js.map +1 -0
  47. package/dist/client/billing/renewalObservation/scheduled-identity.d.ts +53 -0
  48. package/dist/client/billing/renewalObservation/scheduled-identity.d.ts.map +1 -0
  49. package/dist/client/billing/renewalObservation/scheduled-identity.js +95 -0
  50. package/dist/client/billing/renewalObservation/scheduled-identity.js.map +1 -0
  51. package/dist/client/billing/renewalObservation/scheduled-normalization.d.ts +59 -0
  52. package/dist/client/billing/renewalObservation/scheduled-normalization.d.ts.map +1 -0
  53. package/dist/client/billing/renewalObservation/scheduled-normalization.js +29 -0
  54. package/dist/client/billing/renewalObservation/scheduled-normalization.js.map +1 -0
  55. package/dist/client/billing/renewalObservation/settings-normalization.d.ts +54 -0
  56. package/dist/client/billing/renewalObservation/settings-normalization.d.ts.map +1 -0
  57. package/dist/client/billing/renewalObservation/settings-normalization.js +53 -0
  58. package/dist/client/billing/renewalObservation/settings-normalization.js.map +1 -0
  59. package/dist/client/billing/renewalObservation/stage-runner.d.ts +4 -0
  60. package/dist/client/billing/renewalObservation/stage-runner.d.ts.map +1 -0
  61. package/dist/client/billing/renewalObservation/stage-runner.js +34 -0
  62. package/dist/client/billing/renewalObservation/stage-runner.js.map +1 -0
  63. package/dist/client/billing/renewalObservation/weeklyPending.d.ts +13 -0
  64. package/dist/client/billing/renewalObservation/weeklyPending.d.ts.map +1 -0
  65. package/dist/client/billing/renewalObservation/weeklyPending.js +55 -0
  66. package/dist/client/billing/renewalObservation/weeklyPending.js.map +1 -0
  67. package/dist/client/billing/renewalV2/index.d.ts +383 -0
  68. package/dist/client/billing/renewalV2/index.d.ts.map +1 -1
  69. package/dist/client/billing/renewalV2/index.js +8 -3
  70. package/dist/client/billing/renewalV2/index.js.map +1 -1
  71. package/dist/client/billing/renewalV2/observation.d.ts +19 -0
  72. package/dist/client/billing/renewalV2/observation.d.ts.map +1 -0
  73. package/dist/client/billing/renewalV2/observation.js +95 -0
  74. package/dist/client/billing/renewalV2/observation.js.map +1 -0
  75. package/dist/client/billing/renewalV2/observationInput.d.ts +77 -0
  76. package/dist/client/billing/renewalV2/observationInput.d.ts.map +1 -0
  77. package/dist/client/billing/renewalV2/observationInput.js +140 -0
  78. package/dist/client/billing/renewalV2/observationInput.js.map +1 -0
  79. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  80. package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
  81. package/dist/client/renewal.d.ts +2 -0
  82. package/dist/client/renewal.d.ts.map +1 -1
  83. package/dist/client/renewal.js +1 -0
  84. package/dist/client/renewal.js.map +1 -1
  85. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  86. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  87. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  88. package/dist/component/earnings/triggers.d.ts +16 -16
  89. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  90. package/docs/client-api.md +26 -0
  91. package/docs/renewal-material-observation.md +124 -0
  92. package/docs/renewal-price-replacements.md +3 -0
  93. package/package.json +1 -1
  94. package/src/client/billing/renewalObservation/active-scheduled.ts +67 -0
  95. package/src/client/billing/renewalObservation/common.ts +83 -0
  96. package/src/client/billing/renewalObservation/configured-baseline.ts +55 -0
  97. package/src/client/billing/renewalObservation/coupon-discount-joins.ts +163 -0
  98. package/src/client/billing/renewalObservation/invoice-tax-identity.ts +65 -0
  99. package/src/client/billing/renewalObservation/pending-and-stage.ts +89 -0
  100. package/src/client/billing/renewalObservation/phase-price-normalization.ts +106 -0
  101. package/src/client/billing/renewalObservation/planProjection.ts +177 -0
  102. package/src/client/billing/renewalObservation/reference-catalog.ts +150 -0
  103. package/src/client/billing/renewalObservation/schedule-templates.ts +118 -0
  104. package/src/client/billing/renewalObservation/scheduled-context.ts +98 -0
  105. package/src/client/billing/renewalObservation/scheduled-identity.ts +175 -0
  106. package/src/client/billing/renewalObservation/scheduled-normalization.ts +49 -0
  107. package/src/client/billing/renewalObservation/settings-normalization.ts +60 -0
  108. package/src/client/billing/renewalObservation/stage-runner.ts +30 -0
  109. package/src/client/billing/renewalObservation/weeklyPending.ts +81 -0
  110. package/src/client/billing/renewalV2/index.ts +14 -6
  111. package/src/client/billing/renewalV2/observation.boundary-review.test.ts +49 -0
  112. package/src/client/billing/renewalV2/observation.test.ts +334 -0
  113. package/src/client/billing/renewalV2/observation.ts +149 -0
  114. package/src/client/billing/renewalV2/observationInput.ts +167 -0
  115. package/src/client/renewal.ts +7 -0
package/CHANGELOG.md CHANGED
@@ -26,6 +26,12 @@
26
26
  - Remove internal tracker references from public documentation and add a
27
27
  regression check that prevents their reintroduction.
28
28
 
29
+ ## [0.88.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.87.0...v0.88.0) (2026-10-29)
30
+
31
+ ### Features
32
+
33
+ - inspect V2 renewal schedule material ([#412](https://github.com/FantasticDevHQ/better-stripe/issues/412)) ([f009139](https://github.com/FantasticDevHQ/better-stripe/commit/f009139d2036b281a7a06f515cfd622e7c187c5f))
34
+
29
35
  ## [0.87.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.86.0...v0.87.0) (2026-10-29)
30
36
 
31
37
  ### Features
package/README.md CHANGED
@@ -5,7 +5,7 @@ billing, and Connect marketplaces. It provides checkout, subscriptions, webhook
5
5
  syncing, marketplace fees and splits, payouts, refunds, and disputes, with React
6
6
  hooks and headless UI components.
7
7
 
8
- **Version**: `0.87.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
8
+ **Version**: `0.88.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
9
9
 
10
10
  Connect platforms use the default GA API version. Non-Connect merchants using
11
11
  customer-only Accounts v2 need preview access and an explicit preview version.
@@ -0,0 +1,6 @@
1
+ import { type ObserverCandidateResult } from "./common.js";
2
+ import type { pending } from "./pending-and-stage.js";
3
+ export declare function active(state: Extract<ReturnType<typeof pending>, {
4
+ kind: "continue";
5
+ }>["state"]): ObserverCandidateResult;
6
+ //# sourceMappingURL=active-scheduled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active-scheduled.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/active-scheduled.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,uBAAuB,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,wBAAgB,MAAM,CACpB,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC,OAAO,CAAC,GACxE,uBAAuB,CAoDzB"}
@@ -0,0 +1,37 @@
1
+ import { object, array, need, clone, get, equal, timestamp, planTemplateForPrice, } from "./common.js";
2
+ export function active(state) {
3
+ const { rawReads, base, originalItem, sub, target, context, actualItem, current, actualItemDiscounts, normalizeSub, sourceWithAssociation, targetTemplate, } = state;
4
+ // BEGIN original 927-961
5
+ const effectiveTemplate = clone(sourceWithAssociation), expectedItem = clone(originalItem);
6
+ expectedItem.id = actualItem.id;
7
+ expectedItem.price = clone(target);
8
+ const targetPlanTemplate = planTemplateForPrice(target, context);
9
+ need(targetPlanTemplate, "unproven_target_plan_price_mapping", "unknown");
10
+ // Expected comparison view from explicit field mapping; raw actual Plan stays in rawReads.
11
+ expectedItem.plan = targetPlanTemplate;
12
+ expectedItem.current_period_start = current.start_date;
13
+ expectedItem.current_period_end = current.end_date;
14
+ get(effectiveTemplate, "items").data = [expectedItem];
15
+ if (targetTemplate.billing_cycle_anchor === "phase_start")
16
+ effectiveTemplate.billing_cycle_anchor = current.start_date;
17
+ const normalizedActual = normalizeSub(sub, "target", target), normalizedExpected = normalizeSub(effectiveTemplate, "original", target);
18
+ get(normalizedExpected, "items").data = [
19
+ {
20
+ ...object(array(get(normalizedExpected, "items").data)[0]),
21
+ discounts: actualItemDiscounts,
22
+ },
23
+ ];
24
+ need(equal(normalizedActual, normalizedExpected), "effective_full_material_drift");
25
+ return {
26
+ ...base,
27
+ predicate: "active_effective_match",
28
+ observedItemId: String(actualItem.id),
29
+ nativePeriod: {
30
+ start: timestamp.parse(current.start_date),
31
+ end: timestamp.parse(current.end_date),
32
+ },
33
+ rawReads,
34
+ };
35
+ // END original 927-961
36
+ }
37
+ //# sourceMappingURL=active-scheduled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"active-scheduled.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/active-scheduled.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,GAAG,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ACE,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1D,SAAS,EAAE,mBAAmB;SAC/B;KACF,CAAC;IACF,IAAI,CACF,KAAK,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,EAC3C,+BAA+B,CAChC,CAAC;IACF,OAAO;QACL,GAAG,IAAI;QACP,SAAS,EAAE,wBAAwB;QACnC,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QACrC,YAAY,EAAE;YACZ,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;YAC1C,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;SACvC;QACD,QAAQ;KACT,CAAC;IACF,uBAAuB;AACzB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
2
+ import { equal, referenceId, productId, timestamp } from "../renewalAggregate/shared.js";
3
+ import { planMatchesPrice, planTemplateForPrice } from "./planProjection.js";
4
+ export type O = Record<string, unknown>;
5
+ export declare class Stop extends Error {
6
+ readonly reason: string;
7
+ readonly kind: "unknown" | "conflict";
8
+ constructor(reason: string, kind?: "unknown" | "conflict");
9
+ }
10
+ export declare const object: (v: unknown) => O;
11
+ export declare const array: (v: unknown) => unknown[];
12
+ export declare function need(value: unknown, reason: string, kind?: "unknown" | "conflict"): asserts value;
13
+ export declare const clone: <T>(v: T) => T;
14
+ export declare const get: (v: O, key: string) => O;
15
+ export declare function compareFullBaseline(left: unknown, right: unknown): {
16
+ equal: boolean;
17
+ acknowledgementEstablished: false;
18
+ };
19
+ export type ObserverCandidateResult = {
20
+ candidateOnly: true;
21
+ providerQualification: "required";
22
+ configureAcknowledged: false;
23
+ configureDispatchOutcome: "unknown";
24
+ providerCallsRequested: false;
25
+ predicate: "terminal_facts_only" | "attached_unconfigured_match" | "active_effective_match" | "configured_baseline_material_match" | "confirmed_pending" | "unknown" | "conflict";
26
+ reason?: string;
27
+ observedItemId?: string;
28
+ nativePeriod?: {
29
+ start: number;
30
+ end: number;
31
+ };
32
+ providerStatus?: unknown;
33
+ effectiveness?: "unknown";
34
+ rawReads?: unknown;
35
+ comparableSchedule?: unknown;
36
+ proofTargetEnd?: number;
37
+ proofStage?: "original" | "target";
38
+ };
39
+ /** Private SOURCE candidate only; no transport, public integration or ack adapter. */
40
+ export { renewalSnapshot, equal, referenceId, productId, timestamp, planMatchesPrice, planTemplateForPrice, };
41
+ export type Purpose = "baseline" | "live";
42
+ export type Evidence = {
43
+ targetEnd: number;
44
+ comparable: unknown;
45
+ stage: "original" | "target";
46
+ };
47
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EACL,KAAK,EACL,WAAW,EACX,SAAS,EACT,SAAS,EACV,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,MAAM,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACxC,qBAAa,IAAK,SAAQ,KAAK;IAE3B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU;IAFvC,YACW,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,SAAS,GAAG,UAAuB,EAGnD;CACF;AACD,eAAO,MAAM,MAAM,MAAO,OAAO,KAAG,CAInC,CAAC;AACF,eAAO,MAAM,KAAK,MAAO,OAAO,KAAG,OAAO,EAGzC,CAAC;AACF,wBAAgB,IAAI,CAClB,KAAK,EAAE,OAAO,EACd,MAAM,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,GAAG;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,UAAU,GAAG,QAAQ,CAAC;CAC9B,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
2
+ import { equal, referenceId, productId, timestamp, } from "../renewalAggregate/shared.js";
3
+ import { planMatchesPrice, planTemplateForPrice } from "./planProjection.js";
4
+ export class Stop extends Error {
5
+ reason;
6
+ kind;
7
+ constructor(reason, kind = "conflict") {
8
+ super(reason);
9
+ this.reason = reason;
10
+ this.kind = kind;
11
+ }
12
+ }
13
+ export const object = (v) => {
14
+ if (!v || typeof v !== "object" || Array.isArray(v))
15
+ throw new Stop("incomplete_object", "unknown");
16
+ return v;
17
+ };
18
+ export const array = (v) => {
19
+ if (!Array.isArray(v))
20
+ throw new Stop("incomplete_array", "unknown");
21
+ return v;
22
+ };
23
+ export function need(value, reason, kind = "conflict") {
24
+ if (!value)
25
+ throw new Stop(reason, kind);
26
+ }
27
+ export const clone = (v) => renewalSnapshot(v);
28
+ export const get = (v, key) => object(v[key]);
29
+ export function compareFullBaseline(left, right) {
30
+ let same = false;
31
+ try {
32
+ same = equal(left, right);
33
+ }
34
+ catch { }
35
+ return { equal: same, acknowledgementEstablished: false };
36
+ }
37
+ /** Private SOURCE candidate only; no transport, public integration or ack adapter. */
38
+ export { renewalSnapshot, equal, referenceId, productId, timestamp, planMatchesPrice, planTemplateForPrice, };
39
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EACL,KAAK,EACL,WAAW,EACX,SAAS,EACT,SAAS,GACV,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,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5B,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,0BAA0B,EAAE,KAAc,EAAE,CAAC;AACrE,CAAC;AAyBD,sFAAsF;AAEtF,OAAO,EACL,eAAe,EACf,KAAK,EACL,WAAW,EACX,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,oBAAoB,GACrB,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { type ObserverCandidateResult } from "./common.js";
2
+ import type { templates } from "./schedule-templates.js";
3
+ export declare function baseline(state: Extract<ReturnType<typeof templates>, {
4
+ kind: "continue";
5
+ }>["state"]): {
6
+ state?: undefined;
7
+ kind: "result";
8
+ result: ObserverCandidateResult;
9
+ } | {
10
+ result?: undefined;
11
+ kind: "continue";
12
+ state: {
13
+ input: import("./common.js").O;
14
+ rawReads: unknown;
15
+ base: {
16
+ readonly candidateOnly: true;
17
+ readonly providerQualification: "required";
18
+ readonly configureAcknowledged: false;
19
+ readonly configureDispatchOutcome: "unknown";
20
+ readonly providerCallsRequested: false;
21
+ };
22
+ purpose: import("./common.js").Purpose;
23
+ evidence: import("./common.js").Evidence | undefined;
24
+ projection: import("./common.js").O;
25
+ request: import("./common.js").O;
26
+ prepared: import("./common.js").O;
27
+ expected: import("./common.js").O;
28
+ receipt: import("./common.js").O;
29
+ original: import("./common.js").O;
30
+ originalSub: import("./common.js").O;
31
+ originalItem: import("./common.js").O;
32
+ originalSchedule: import("./common.js").O;
33
+ expectedPrice: import("./common.js").O;
34
+ reads: import("./common.js").O;
35
+ schedule: import("./common.js").O;
36
+ sub: import("./common.js").O;
37
+ target: import("./common.js").O;
38
+ customer: import("./common.js").O;
39
+ context: {
40
+ customerAccountId: string;
41
+ livemode: boolean;
42
+ };
43
+ desired: import("./common.js").O;
44
+ ref: (v: unknown, prefix: string, kind: string) => string;
45
+ customerId: string;
46
+ items: import("./common.js").O;
47
+ actualItem: import("./common.js").O;
48
+ current: import("./common.js").O;
49
+ phases: unknown[];
50
+ originalPhase: import("./common.js").O;
51
+ currentOriginal: boolean;
52
+ activeTarget: boolean;
53
+ coupon: (v: unknown) => import("./common.js").O;
54
+ actualItemDiscounts: import("./common.js").O[];
55
+ actualSubDiscounts: import("./common.js").O[];
56
+ originalItemDiscounts: import("./common.js").O[];
57
+ originalSubDiscounts: import("./common.js").O[];
58
+ currentRedemptions: Map<string, import("./common.js").O>;
59
+ invoiceTaxId: (value: unknown) => string;
60
+ retainedPMs: import("./common.js").O[];
61
+ settings: (v: import("./common.js").O) => import("./common.js").O;
62
+ phaseDiscounts: (v: unknown) => import("./common.js").O[];
63
+ priceRef: (v: unknown, known: import("./common.js").O, kind?: string) => string;
64
+ normalizePhase: (v: import("./common.js").O, known: import("./common.js").O) => import("./common.js").O;
65
+ normalizeSchedule: (v: import("./common.js").O) => import("./common.js").O;
66
+ normalizeSub: (v: import("./common.js").O, stage: "original" | "target", knownPrice: import("./common.js").O) => import("./common.js").O;
67
+ sourceWithAssociation: import("./common.js").O;
68
+ attachedTemplate: import("./common.js").O;
69
+ candidateSchedule: import("./common.js").O;
70
+ targetPhase: import("./common.js").O;
71
+ targetTemplate: import("./common.js").O;
72
+ completeTemplate: import("./common.js").O;
73
+ comparableSchedule: import("./common.js").O;
74
+ };
75
+ };
76
+ //# sourceMappingURL=configured-baseline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configured-baseline.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/configured-baseline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC,OAAO,CAAC;;UAsCjE,QAAQ;YAQT,uBAAuB;;;UAIjB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAC1B"}
@@ -0,0 +1,26 @@
1
+ import { need, get, equal } from "./common.js";
2
+ export function baseline(state) {
3
+ const { rawReads, base, purpose, originalItem, sub, current, currentOriginal, activeTarget, normalizeSub, sourceWithAssociation, targetPhase, comparableSchedule, } = state;
4
+ // BEGIN original 851-879
5
+ if (purpose === "baseline") {
6
+ need(currentOriginal ||
7
+ (activeTarget &&
8
+ current.start_date === targetPhase.start_date &&
9
+ current.end_date === targetPhase.end_date), "configured_ack_phase_relation_unproven", "unknown");
10
+ need(equal(normalizeSub(sub, "original", get(originalItem, "price")), normalizeSub(sourceWithAssociation, "original", get(originalItem, "price"))), "historical_original_material_drift");
11
+ return {
12
+ kind: "result",
13
+ result: {
14
+ ...base,
15
+ predicate: "configured_baseline_material_match",
16
+ rawReads,
17
+ comparableSchedule,
18
+ proofTargetEnd: Number(targetPhase.end_date),
19
+ proofStage: currentOriginal ? "original" : "target",
20
+ },
21
+ };
22
+ }
23
+ // END original 851-879
24
+ return { kind: "continue", state: { ...state } };
25
+ }
26
+ //# sourceMappingURL=configured-baseline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configured-baseline.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/configured-baseline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAgC,MAAM,aAAa,CAAC;AAE7E,MAAM,UAAU,QAAQ,CACtB,KAA2E;IAE3E,MAAM,EACJ,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,GAAG,EACH,OAAO,EACP,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,kBAAkB,GACnB,GAAG,KAAK,CAAC;IACV,yBAAyB;IACzB,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;QAC3B,IAAI,CACF,eAAe;YACb,CAAC,YAAY;gBACX,OAAO,CAAC,UAAU,KAAK,WAAW,CAAC,UAAU;gBAC7C,OAAO,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ,CAAC,EAC9C,wCAAwC,EACxC,SAAS,CACV,CAAC;QACF,IAAI,CACF,KAAK,CACH,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,EACzD,YAAY,CACV,qBAAqB,EACrB,UAAU,EACV,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAC3B,CACF,EACD,oCAAoC,CACrC,CAAC;QACF,OAAO;YACL,IAAI,EAAE,QAAiB;YACvB,MAAM,EAAE;gBACN,GAAG,IAAI;gBACP,SAAS,EAAE,oCAAoC;gBAC/C,QAAQ;gBACR,kBAAkB;gBAClB,cAAc,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC;gBAC5C,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ;aACzB;SAC7B,CAAC;IACJ,CAAC;IACD,uBAAuB;IACvB,OAAO,EAAE,IAAI,EAAE,UAAmB,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type O } from "./common.js";
2
+ import type { identities } from "./scheduled-identity.js";
3
+ export declare function redemptions(state: Extract<ReturnType<typeof identities>, {
4
+ kind: "continue";
5
+ }>["state"]): {
6
+ input: O;
7
+ rawReads: unknown;
8
+ base: {
9
+ readonly candidateOnly: true;
10
+ readonly providerQualification: "required";
11
+ readonly configureAcknowledged: false;
12
+ readonly configureDispatchOutcome: "unknown";
13
+ readonly providerCallsRequested: false;
14
+ };
15
+ purpose: import("./common.js").Purpose;
16
+ evidence: import("./common.js").Evidence | undefined;
17
+ projection: O;
18
+ request: O;
19
+ prepared: O;
20
+ expected: O;
21
+ receipt: O;
22
+ original: O;
23
+ originalSub: O;
24
+ originalItem: O;
25
+ originalSchedule: O;
26
+ expectedPrice: O;
27
+ reads: O;
28
+ schedule: O;
29
+ sub: O;
30
+ target: O;
31
+ customer: O;
32
+ context: {
33
+ customerAccountId: string;
34
+ livemode: boolean;
35
+ };
36
+ desired: O;
37
+ ref: (v: unknown, prefix: string, kind: string) => string;
38
+ customerId: string;
39
+ items: O;
40
+ actualItem: O;
41
+ current: O;
42
+ phases: unknown[];
43
+ originalPhase: O;
44
+ currentOriginal: boolean;
45
+ activeTarget: boolean;
46
+ coupon: (v: unknown) => O;
47
+ actualItemDiscounts: O[];
48
+ actualSubDiscounts: O[];
49
+ originalItemDiscounts: O[];
50
+ originalSubDiscounts: O[];
51
+ currentRedemptions: Map<string, O>;
52
+ };
53
+ //# sourceMappingURL=coupon-discount-joins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coupon-discount-joins.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/coupon-discount-joins.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,CAAC,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,wBAAgB,WAAW,CACzB,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA6BzD,OAAO,KAAG,CAAC;;;;;;EAkI/B"}
@@ -0,0 +1,103 @@
1
+ import { object, array, need, clone, get, equal } from "./common.js";
2
+ export function redemptions(state) {
3
+ const { expected, originalSub, originalItem, reads, sub, ref, customerId, actualItem, } = state;
4
+ // BEGIN original 416-559
5
+ const couponRows = array(reads.coupons);
6
+ need(couponRows.length <= 40, "coupon_budget_exceeded", "unknown");
7
+ const couponMap = new Map();
8
+ for (const row of couponRows) {
9
+ const c = object(row);
10
+ need(typeof c.id === "string" &&
11
+ c.id.trim().length > 0 &&
12
+ c.object === "coupon" &&
13
+ c.deleted !== true &&
14
+ c.livemode === expected.livemode, "coupon_join_identity_mismatch");
15
+ need(!couponMap.has(c.id), "duplicate_coupon_read", "unknown");
16
+ couponMap.set(c.id, c);
17
+ }
18
+ const coupon = (v) => {
19
+ const id = typeof v === "string" ? v : object(v).id;
20
+ need(typeof id === "string" && couponMap.has(id), "missing_correlated_coupon", "unknown");
21
+ const fetched = couponMap.get(id);
22
+ if (typeof v !== "string")
23
+ need(equal(v, fetched), "expanded_coupon_read_drift");
24
+ return clone(fetched);
25
+ };
26
+ const discounts = (v, level, itemId) => {
27
+ const rows = array(v);
28
+ need(rows.length <= 20, "discount_budget_exceeded", "unknown");
29
+ return rows.map((row) => {
30
+ const d = clone(object(row));
31
+ need(typeof d.id === "string" &&
32
+ /^di_[A-Za-z0-9_]+$/.test(d.id) &&
33
+ d.object === "discount" &&
34
+ d.deleted !== true &&
35
+ d.customer_account === expected.customerAccountId, "discount_identity_mismatch");
36
+ if (d.customer !== undefined)
37
+ need(ref(d.customer, "cus", "customer") === customerId, "discount_customer_mismatch");
38
+ need(level === "subscription"
39
+ ? d.subscription === expected.subscriptionId &&
40
+ d.subscription_item === null
41
+ : d.subscription_item === itemId &&
42
+ (d.subscription === null ||
43
+ d.subscription === expected.subscriptionId), "discount_level_owner_mismatch", "unknown");
44
+ const source = get(d, "source");
45
+ need(source.type === "coupon", "unsupported_discount_source", "unknown");
46
+ source.coupon = coupon(source.coupon);
47
+ const c = object(source.coupon);
48
+ need(c.duration === "forever" && d.end === null, "discount_duration_unqualified", "unknown");
49
+ if (c.applies_to !== undefined) {
50
+ const products = array(get(c, "applies_to").products);
51
+ need(products.includes(expected.currentProductId) &&
52
+ products.includes(expected.targetProductId), "coupon_product_applicability");
53
+ }
54
+ d.source = source;
55
+ d.customer = d.customer === undefined ? undefined : customerId;
56
+ if (d.customer === undefined)
57
+ delete d.customer;
58
+ // Validation-view marker only. Both actual ownerships are checked first;
59
+ // raw historical/current IDs remain untouched in rawReads/original records.
60
+ if (level === "item") {
61
+ d.subscription = expected.subscriptionId;
62
+ d.subscription_item = "AUTHORIZED_CURRENT_ITEM";
63
+ }
64
+ return d;
65
+ });
66
+ };
67
+ const wantedItemId = String(actualItem.id);
68
+ const actualSubDiscounts = discounts(sub.discounts, "subscription", wantedItemId), actualItemDiscounts = discounts(actualItem.discounts, "item", wantedItemId);
69
+ const originalSubDiscounts = discounts(originalSub.discounts, "subscription", String(expected.itemId));
70
+ const originalItemDiscounts = discounts(originalItem.discounts, "item", String(expected.itemId));
71
+ need(equal(actualSubDiscounts, originalSubDiscounts) &&
72
+ equal(actualItemDiscounts, originalItemDiscounts), "redemption_full_read_drift");
73
+ const neededCouponIds = new Set([
74
+ ...array(originalSub.discounts),
75
+ ...array(originalItem.discounts),
76
+ ...array(sub.discounts),
77
+ ...array(actualItem.discounts),
78
+ ].map((row) => {
79
+ const value = get(object(row), "source").coupon;
80
+ return typeof value === "string" ? value : String(object(value).id);
81
+ }));
82
+ need(couponMap.size === neededCouponIds.size &&
83
+ [...couponMap.keys()].every((id) => neededCouponIds.has(id)), "unreferenced_coupon_read", "unknown");
84
+ const currentRedemptions = new Map();
85
+ for (const d of [...array(sub.discounts), ...array(actualItem.discounts)]) {
86
+ const raw = clone(object(d));
87
+ const source = get(raw, "source");
88
+ source.coupon = coupon(source.coupon);
89
+ raw.source = source;
90
+ currentRedemptions.set(String(raw.id), raw);
91
+ }
92
+ // END original 416-559
93
+ return {
94
+ ...state,
95
+ coupon,
96
+ actualItemDiscounts,
97
+ actualSubDiscounts,
98
+ originalItemDiscounts,
99
+ originalSubDiscounts,
100
+ currentRedemptions,
101
+ };
102
+ }
103
+ //# sourceMappingURL=coupon-discount-joins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coupon-discount-joins.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/coupon-discount-joins.ts"],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AQ,CAAC,CAAC,MAAM,CAAC;QAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CACH,CAAC;IACF,IAAI,CACF,SAAS,CAAC,IAAI,KAAK,eAAe,CAAC,IAAI;QACrC,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAC9D,0BAA0B,EAC1B,SAAS,CACV,CAAC;IACF,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAa,CAAC;IAChD,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;QAC1E,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAClC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QACpB,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;IACD,uBAAuB;IACvB,OAAO;QACL,GAAG,KAAK;QACR,MAAM;QACN,mBAAmB;QACnB,kBAAkB;QAClB,qBAAqB;QACrB,oBAAoB;QACpB,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { redemptions } from "./coupon-discount-joins.js";
2
+ export declare function taxes(state: ReturnType<typeof redemptions>): {
3
+ input: import("./common.js").O;
4
+ rawReads: unknown;
5
+ base: {
6
+ readonly candidateOnly: true;
7
+ readonly providerQualification: "required";
8
+ readonly configureAcknowledged: false;
9
+ readonly configureDispatchOutcome: "unknown";
10
+ readonly providerCallsRequested: false;
11
+ };
12
+ purpose: import("./common.js").Purpose;
13
+ evidence: import("./common.js").Evidence | undefined;
14
+ projection: import("./common.js").O;
15
+ request: import("./common.js").O;
16
+ prepared: import("./common.js").O;
17
+ expected: import("./common.js").O;
18
+ receipt: import("./common.js").O;
19
+ original: import("./common.js").O;
20
+ originalSub: import("./common.js").O;
21
+ originalItem: import("./common.js").O;
22
+ originalSchedule: import("./common.js").O;
23
+ expectedPrice: import("./common.js").O;
24
+ reads: import("./common.js").O;
25
+ schedule: import("./common.js").O;
26
+ sub: import("./common.js").O;
27
+ target: import("./common.js").O;
28
+ customer: import("./common.js").O;
29
+ context: {
30
+ customerAccountId: string;
31
+ livemode: boolean;
32
+ };
33
+ desired: import("./common.js").O;
34
+ ref: (v: unknown, prefix: string, kind: string) => string;
35
+ customerId: string;
36
+ items: import("./common.js").O;
37
+ actualItem: import("./common.js").O;
38
+ current: import("./common.js").O;
39
+ phases: unknown[];
40
+ originalPhase: import("./common.js").O;
41
+ currentOriginal: boolean;
42
+ activeTarget: boolean;
43
+ coupon: (v: unknown) => import("./common.js").O;
44
+ actualItemDiscounts: import("./common.js").O[];
45
+ actualSubDiscounts: import("./common.js").O[];
46
+ originalItemDiscounts: import("./common.js").O[];
47
+ originalSubDiscounts: import("./common.js").O[];
48
+ currentRedemptions: Map<string, import("./common.js").O>;
49
+ invoiceTaxId: (value: unknown) => string;
50
+ retainedPMs: import("./common.js").O[];
51
+ };
52
+ //# sourceMappingURL=invoice-tax-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice-tax-identity.d.ts","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/invoice-tax-identity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BA0B5B,OAAO;;EAoCrC"}
@@ -0,0 +1,49 @@
1
+ import { object, array, need, get, equal } from "./common.js";
2
+ export function taxes(state) {
3
+ const { expected, originalSub, originalSchedule, ref, originalPhase } = state;
4
+ // BEGIN original 560-617
5
+ const originalDefaults = get(originalSchedule, "default_settings");
6
+ const invoiceObjects = [
7
+ originalSub.invoice_settings,
8
+ originalDefaults.invoice_settings,
9
+ originalPhase.invoice_settings,
10
+ ]
11
+ .filter((v) => v !== null && v !== undefined)
12
+ .map(object);
13
+ const retainedTaxIds = invoiceObjects
14
+ .flatMap((inv) => inv.account_tax_ids === null || inv.account_tax_ids === undefined
15
+ ? []
16
+ : array(inv.account_tax_ids))
17
+ .filter((v) => typeof v !== "string")
18
+ .map(object);
19
+ const retainedPMs = [
20
+ originalSub.default_payment_method,
21
+ originalDefaults.default_payment_method,
22
+ originalPhase.default_payment_method,
23
+ ]
24
+ .filter((v) => v !== null && v !== undefined && typeof v !== "string")
25
+ .map(object);
26
+ const invoiceTaxId = (value) => {
27
+ const id = ref(value, "txi", "tax_id");
28
+ if (typeof value !== "string") {
29
+ const tax = object(value);
30
+ need(tax.livemode === expected.livemode &&
31
+ (tax.customer_account === undefined || tax.customer_account === null), "invoice_tax_mode_or_scope_mismatch");
32
+ const owner = get(tax, "owner"), issuer = get(get(originalSub, "invoice_settings"), "issuer");
33
+ need(owner.type === issuer.type && owner.customer_account === null, "invoice_tax_owner_mismatch");
34
+ if (owner.type === "account")
35
+ need(ref(owner.account, "acct", "account") ===
36
+ ref(issuer.account, "acct", "account"), "invoice_tax_issuer_mismatch");
37
+ else
38
+ need(owner.type === "self" &&
39
+ (owner.account === undefined || owner.account === null), "invoice_tax_owner_unsupported", "unknown");
40
+ for (const retained of retainedTaxIds)
41
+ if (retained.id === id)
42
+ need(equal(tax, retained), "invoice_tax_full_read_drift");
43
+ }
44
+ return id;
45
+ };
46
+ // END original 560-617
47
+ return { ...state, invoiceTaxId, retainedPMs };
48
+ }
49
+ //# sourceMappingURL=invoice-tax-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice-tax-identity.js","sourceRoot":"","sources":["../../../../src/client/billing/renewalObservation/invoice-tax-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,UAAU,KAAK,CAAC,KAAqC;IACzD,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAC9E,yBAAyB;IACzB,MAAM,gBAAgB,GAAG,GAAG,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IACnE,MAAM,cAAc,GAAG;QACrB,WAAW,CAAC,gBAAgB;QAC5B,gBAAgB,CAAC,gBAAgB;QACjC,aAAa,CAAC,gBAAgB;KAC/B;SACE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC;SAC5C,GAAG,CAAC,MAAM,CAAC,CAAC;IACf,MAAM,cAAc,GAAG,cAAc;SAClC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CACf,GAAG,CAAC,eAAe,KAAK,IAAI,IAAI,GAAG,CAAC,eAAe,KAAK,SAAS;QAC/D,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAC/B;SACA,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;SACpC,GAAG,CAAC,MAAM,CAAC,CAAC;IACf,MAAM,WAAW,GAAG;QAClB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