@stigmer/react 3.39.0 → 3.40.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.
- package/billing/AutoRechargeCard.js +1 -1
- package/billing/AutoRechargeCard.js.map +1 -1
- package/billing/BillingSection.d.ts +18 -1
- package/billing/BillingSection.d.ts.map +1 -1
- package/billing/BillingSection.js +21 -11
- package/billing/BillingSection.js.map +1 -1
- package/billing/ChangePlanDialog.d.ts +46 -0
- package/billing/ChangePlanDialog.d.ts.map +1 -0
- package/billing/ChangePlanDialog.js +90 -0
- package/billing/ChangePlanDialog.js.map +1 -0
- package/billing/CreditPackGrid.d.ts +1 -1
- package/billing/CreditPackGrid.js +1 -1
- package/billing/LowBalanceBanner.js +1 -1
- package/billing/LowBalanceBanner.js.map +1 -1
- package/billing/PaymentMethodCard.d.ts +9 -1
- package/billing/PaymentMethodCard.d.ts.map +1 -1
- package/billing/PaymentMethodCard.js +2 -2
- package/billing/PaymentMethodCard.js.map +1 -1
- package/billing/PlanCard.d.ts +27 -0
- package/billing/PlanCard.d.ts.map +1 -0
- package/billing/PlanCard.js +68 -0
- package/billing/PlanCard.js.map +1 -0
- package/billing/PlanPicker.d.ts +34 -0
- package/billing/PlanPicker.d.ts.map +1 -0
- package/billing/PlanPicker.js +46 -0
- package/billing/PlanPicker.js.map +1 -0
- package/billing/PlanSection.d.ts +45 -0
- package/billing/PlanSection.d.ts.map +1 -0
- package/billing/PlanSection.js +136 -0
- package/billing/PlanSection.js.map +1 -0
- package/billing/UpgradeNotice.d.ts +47 -0
- package/billing/UpgradeNotice.d.ts.map +1 -0
- package/billing/UpgradeNotice.js +49 -0
- package/billing/UpgradeNotice.js.map +1 -0
- package/billing/credit-packs.d.ts.map +1 -1
- package/billing/credit-packs.js +4 -1
- package/billing/credit-packs.js.map +1 -1
- package/billing/index.d.ts +26 -1
- package/billing/index.d.ts.map +1 -1
- package/billing/index.js +12 -0
- package/billing/index.js.map +1 -1
- package/billing/plan-features.d.ts +60 -0
- package/billing/plan-features.d.ts.map +1 -0
- package/billing/plan-features.js +128 -0
- package/billing/plan-features.js.map +1 -0
- package/billing/plan-state.d.ts +43 -0
- package/billing/plan-state.d.ts.map +1 -0
- package/billing/plan-state.js +69 -0
- package/billing/plan-state.js.map +1 -0
- package/billing/redirect.d.ts +31 -0
- package/billing/redirect.d.ts.map +1 -0
- package/billing/redirect.js +30 -0
- package/billing/redirect.js.map +1 -0
- package/billing/useBillingAccount.d.ts +10 -1
- package/billing/useBillingAccount.d.ts.map +1 -1
- package/billing/useBillingAccount.js +2 -2
- package/billing/useBillingAccount.js.map +1 -1
- package/billing/useChangePlan.d.ts +51 -0
- package/billing/useChangePlan.d.ts.map +1 -0
- package/billing/useChangePlan.js +61 -0
- package/billing/useChangePlan.js.map +1 -0
- package/billing/useCreateBillingPortalSession.d.ts +6 -3
- package/billing/useCreateBillingPortalSession.d.ts.map +1 -1
- package/billing/useCreateBillingPortalSession.js +11 -4
- package/billing/useCreateBillingPortalSession.js.map +1 -1
- package/billing/useCreateCheckoutSession.d.ts +7 -5
- package/billing/useCreateCheckoutSession.d.ts.map +1 -1
- package/billing/useCreateCheckoutSession.js +5 -3
- package/billing/useCreateCheckoutSession.js.map +1 -1
- package/billing/useCreatePaymentMethodSetupSession.d.ts +28 -0
- package/billing/useCreatePaymentMethodSetupSession.d.ts.map +1 -0
- package/billing/useCreatePaymentMethodSetupSession.js +50 -0
- package/billing/useCreatePaymentMethodSetupSession.js.map +1 -0
- package/billing/useEntitlements.d.ts +46 -0
- package/billing/useEntitlements.d.ts.map +1 -0
- package/billing/useEntitlements.js +37 -0
- package/billing/useEntitlements.js.map +1 -0
- package/billing/usePeriodEstimate.d.ts +35 -0
- package/billing/usePeriodEstimate.d.ts.map +1 -0
- package/billing/usePeriodEstimate.js +29 -0
- package/billing/usePeriodEstimate.js.map +1 -0
- package/billing/usePlans.d.ts +38 -0
- package/billing/usePlans.d.ts.map +1 -0
- package/billing/usePlans.js +33 -0
- package/billing/usePlans.js.map +1 -0
- package/billing/useSubscription.d.ts +39 -0
- package/billing/useSubscription.d.ts.map +1 -0
- package/billing/useSubscription.js +40 -0
- package/billing/useSubscription.js.map +1 -0
- package/index.d.ts +4 -2
- package/index.d.ts.map +1 -1
- package/index.js +4 -1
- package/index.js.map +1 -1
- package/internal/features.d.ts +11 -0
- package/internal/features.d.ts.map +1 -0
- package/internal/features.js +42 -0
- package/internal/features.js.map +1 -0
- package/licenses/license-format.d.ts +5 -3
- package/licenses/license-format.d.ts.map +1 -1
- package/licenses/license-format.js +10 -19
- package/licenses/license-format.js.map +1 -1
- package/package.json +5 -5
- package/plan-catalog/PlanCatalogConsole.d.ts +22 -0
- package/plan-catalog/PlanCatalogConsole.d.ts.map +1 -0
- package/plan-catalog/PlanCatalogConsole.js +90 -0
- package/plan-catalog/PlanCatalogConsole.js.map +1 -0
- package/plan-catalog/PlanCreateForm.d.ts +17 -0
- package/plan-catalog/PlanCreateForm.d.ts.map +1 -0
- package/plan-catalog/PlanCreateForm.js +52 -0
- package/plan-catalog/PlanCreateForm.js.map +1 -0
- package/plan-catalog/PlansAccessNotice.d.ts +10 -0
- package/plan-catalog/PlansAccessNotice.d.ts.map +1 -0
- package/plan-catalog/PlansAccessNotice.js +13 -0
- package/plan-catalog/PlansAccessNotice.js.map +1 -0
- package/plan-catalog/index.d.ts +8 -0
- package/plan-catalog/index.d.ts.map +1 -0
- package/plan-catalog/index.js +10 -0
- package/plan-catalog/index.js.map +1 -0
- package/plan-catalog/plan-draft.d.ts +30 -0
- package/plan-catalog/plan-draft.d.ts.map +1 -0
- package/plan-catalog/plan-draft.js +91 -0
- package/plan-catalog/plan-draft.js.map +1 -0
- package/plan-catalog/usePlanMutations.d.ts +42 -0
- package/plan-catalog/usePlanMutations.d.ts.map +1 -0
- package/plan-catalog/usePlanMutations.js +57 -0
- package/plan-catalog/usePlanMutations.js.map +1 -0
- package/settings/TeamsSection.d.ts.map +1 -1
- package/settings/TeamsSection.js +19 -2
- package/settings/TeamsSection.js.map +1 -1
- package/settings/settings-nav.d.ts.map +1 -1
- package/settings/settings-nav.js +7 -1
- package/settings/settings-nav.js.map +1 -1
- package/settings/useSettingsNavGroups.d.ts.map +1 -1
- package/settings/useSettingsNavGroups.js +4 -1
- package/settings/useSettingsNavGroups.js.map +1 -1
- package/src/billing/AutoRechargeCard.tsx +2 -2
- package/src/billing/BillingSection.tsx +68 -11
- package/src/billing/ChangePlanDialog.tsx +221 -0
- package/src/billing/CreditPackGrid.tsx +1 -1
- package/src/billing/LowBalanceBanner.tsx +1 -1
- package/src/billing/PaymentMethodCard.tsx +28 -2
- package/src/billing/PlanCard.tsx +171 -0
- package/src/billing/PlanPicker.tsx +178 -0
- package/src/billing/PlanSection.tsx +234 -0
- package/src/billing/UpgradeNotice.tsx +95 -0
- package/src/billing/credit-packs.ts +4 -1
- package/src/billing/index.ts +26 -1
- package/src/billing/plan-features.ts +162 -0
- package/src/billing/plan-state.ts +92 -0
- package/src/billing/redirect.ts +45 -0
- package/src/billing/useBillingAccount.ts +12 -0
- package/src/billing/useChangePlan.ts +115 -0
- package/src/billing/useCreateBillingPortalSession.ts +17 -6
- package/src/billing/useCreateCheckoutSession.ts +12 -7
- package/src/billing/useCreatePaymentMethodSetupSession.ts +77 -0
- package/src/billing/useEntitlements.ts +80 -0
- package/src/billing/usePeriodEstimate.ts +59 -0
- package/src/billing/usePlans.ts +65 -0
- package/src/billing/useSubscription.ts +70 -0
- package/src/index.ts +54 -0
- package/src/internal/features.ts +49 -0
- package/src/licenses/license-format.ts +10 -19
- package/src/plan-catalog/PlanCatalogConsole.tsx +197 -0
- package/src/plan-catalog/PlanCreateForm.tsx +167 -0
- package/src/plan-catalog/PlansAccessNotice.tsx +20 -0
- package/src/plan-catalog/index.ts +14 -0
- package/src/plan-catalog/plan-draft.ts +116 -0
- package/src/plan-catalog/usePlanMutations.ts +94 -0
- package/src/settings/TeamsSection.tsx +20 -2
- package/src/settings/settings-nav.ts +7 -0
- package/src/settings/useSettingsNavGroups.ts +8 -1
- package/src/team/CreateTeamForm.tsx +12 -3
- package/src/team/TeamMembersPanel.tsx +6 -2
- package/team/CreateTeamForm.d.ts +6 -1
- package/team/CreateTeamForm.d.ts.map +1 -1
- package/team/CreateTeamForm.js +4 -2
- package/team/CreateTeamForm.js.map +1 -1
- package/team/TeamMembersPanel.d.ts.map +1 -1
- package/team/TeamMembersPanel.js +3 -1
- package/team/TeamMembersPanel.js.map +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Plan } from "@stigmer/protos/ai/stigmer/billing/plan/v1/api_pb";
|
|
2
|
+
import { type PlanMove, type PlanStanding } from "./plan-state.js";
|
|
3
|
+
/** Where Enterprise enquiries go by default. */
|
|
4
|
+
export declare const ENTERPRISE_CONTACT_URL = "https://stigmer.ai/contact-sales";
|
|
5
|
+
/** Props for {@link PlanPicker}. */
|
|
6
|
+
export interface PlanPickerProps {
|
|
7
|
+
/** The plans that can be bought, cheapest first, as `buyablePlans` orders them. */
|
|
8
|
+
readonly plans: readonly Plan[];
|
|
9
|
+
/** Where the organization stands. */
|
|
10
|
+
readonly standing: PlanStanding;
|
|
11
|
+
/** The live period's end, which a cancel runs to. */
|
|
12
|
+
readonly periodEnd?: Date;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the viewer may change the plan (`can_manage_billing`). Without
|
|
15
|
+
* it the comparison is read-only.
|
|
16
|
+
*/
|
|
17
|
+
readonly canManage: boolean;
|
|
18
|
+
/** Called with the move a choice makes; the host confirms it. */
|
|
19
|
+
readonly onChoose: (move: PlanMove) => void;
|
|
20
|
+
/** Disables every choice, e.g. while a change is in flight. */
|
|
21
|
+
readonly disabled?: boolean;
|
|
22
|
+
/** Where "Talk to us" for Enterprise links. Defaults to {@link ENTERPRISE_CONTACT_URL}. */
|
|
23
|
+
readonly enterpriseHref?: string;
|
|
24
|
+
/** Additional CSS class names. */
|
|
25
|
+
readonly className?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The plan comparison: Free, each plan that can be bought, and
|
|
29
|
+
* Enterprise, each with its price and what it offers today. A choice
|
|
30
|
+
* reports the move it makes (subscribe, switch, resume or cancel) for the
|
|
31
|
+
* host to confirm; the plan in force reads "Current plan".
|
|
32
|
+
*/
|
|
33
|
+
export declare function PlanPicker({ plans, standing, periodEnd, canManage, onChoose, disabled, enterpriseHref, className, }: PlanPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
//# sourceMappingURL=PlanPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlanPicker.d.ts","sourceRoot":"","sources":["../src/billing/PlanPicker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mDAAmD,CAAC;AAS9E,OAAO,EAAY,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE7E,gDAAgD;AAChD,eAAO,MAAM,sBAAsB,qCAAqC,CAAC;AAEzE,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC5C,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,2FAA2F;IAC3F,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,kCAAkC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,cAAuC,EACvC,SAAS,GACV,EAAE,eAAe,2CAkDjB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@stigmer/theme";
|
|
4
|
+
import { Button } from "../button/index.js";
|
|
5
|
+
import { UNSTYLED_LIST } from "../internal/element-resets.js";
|
|
6
|
+
import { formatManagedOrganizations, formatMonthlyMinimum, explainUsageShare, offeredFeatures, } from "./plan-features.js";
|
|
7
|
+
import { planMove } from "./plan-state.js";
|
|
8
|
+
/** Where Enterprise enquiries go by default. */
|
|
9
|
+
export const ENTERPRISE_CONTACT_URL = "https://stigmer.ai/contact-sales";
|
|
10
|
+
/**
|
|
11
|
+
* The plan comparison: Free, each plan that can be bought, and
|
|
12
|
+
* Enterprise, each with its price and what it offers today. A choice
|
|
13
|
+
* reports the move it makes (subscribe, switch, resume or cancel) for the
|
|
14
|
+
* host to confirm; the plan in force reads "Current plan".
|
|
15
|
+
*/
|
|
16
|
+
export function PlanPicker({ plans, standing, periodEnd, canManage, onChoose, disabled, enterpriseHref = ENTERPRISE_CONTACT_URL, className, }) {
|
|
17
|
+
const freeMove = planMove(standing, "free", periodEnd);
|
|
18
|
+
return (_jsxs("ul", { className: cn(UNSTYLED_LIST, "stg:grid stg:gap-3 stg:sm:grid-cols-2", className), "aria-label": "Plans", children: [_jsx(PlanOption, { name: "Free", price: "$0/month", detail: "Usage is paid from credits.", features: ["Channels", "Sharing", "Unlimited members"], current: standing.kind === "free", action: canManage && freeMove !== null ? { label: "Move to Free", move: freeMove } : undefined, disabled: disabled, onChoose: onChoose }), plans.map((plan) => {
|
|
19
|
+
const move = planMove(standing, plan, periodEnd);
|
|
20
|
+
const managed = formatManagedOrganizations(plan.spec?.entitlements, plan.spec?.terms);
|
|
21
|
+
return (_jsx(PlanOption, { name: plan.metadata?.name ?? "", price: formatMonthlyMinimum(plan.spec?.terms), detail: explainUsageShare(plan.spec?.terms), features: [
|
|
22
|
+
...offeredFeatures(plan.spec?.entitlements).map((feature) => feature.label),
|
|
23
|
+
...(managed === "" ? [] : [managed]),
|
|
24
|
+
], current: move === null && standing.kind !== "free", action: canManage && move !== null ? { label: actionLabel(move), move } : undefined, disabled: disabled, onChoose: onChoose }, plan.metadata?.id ?? plan.metadata?.slug));
|
|
25
|
+
}), _jsxs("li", { className: "stg:flex stg:flex-col stg:rounded-lg stg:border stg:border-border stg:bg-card stg:p-4", children: [_jsx("p", { className: "stg:text-sm stg:font-medium stg:text-foreground", children: "Enterprise" }), _jsx("p", { className: "stg:mt-1 stg:text-xs stg:text-muted-foreground", children: "A dedicated deployment, SSO enforcement, an SLA and annual invoicing, quoted for your organization." }), _jsx("a", { href: enterpriseHref, target: "_blank", rel: "noreferrer", className: "stg:mt-3 stg:self-start stg:text-xs stg:font-medium stg:text-primary stg:hover:underline", children: "Talk to us" })] })] }));
|
|
26
|
+
}
|
|
27
|
+
function PlanOption({ name, price, detail, features, current, action, disabled, onChoose, }) {
|
|
28
|
+
return (_jsxs("li", { className: cn("stg:flex stg:flex-col stg:rounded-lg stg:border stg:bg-card stg:p-4", current ? "stg:border-primary" : "stg:border-border"), "aria-current": current ? "true" : undefined, children: [_jsxs("div", { className: "stg:flex stg:items-baseline stg:justify-between stg:gap-2", children: [_jsx("p", { className: "stg:text-sm stg:font-medium stg:text-foreground", children: name }), _jsx("p", { className: "stg:text-xs stg:tabular-nums stg:text-foreground", children: price })] }), detail !== "" && _jsx("p", { className: "stg:mt-1 stg:text-xs stg:text-muted-foreground", children: detail }), _jsx("ul", { className: cn(UNSTYLED_LIST, "stg:mt-2 stg:space-y-0.5 stg:text-xs stg:text-muted-foreground"), children: features.map((feature) => (_jsx("li", { children: feature }, feature))) }), _jsx("div", { className: "stg:mt-auto stg:pt-3", children: current ? (_jsx("span", { className: "stg:text-xs stg:font-medium stg:text-primary", children: "Current plan" })) : action ? (_jsx(Button, { variant: action.move.kind === "cancel" ? "outline" : "primary", size: "xs", disabled: disabled, onClick: () => onChoose(action.move), children: action.label })) : null })] }));
|
|
29
|
+
}
|
|
30
|
+
function actionLabel(move) {
|
|
31
|
+
switch (move.kind) {
|
|
32
|
+
case "subscribe":
|
|
33
|
+
return "Subscribe";
|
|
34
|
+
case "switch":
|
|
35
|
+
return `Switch to ${move.to.metadata?.name ?? "this plan"}`;
|
|
36
|
+
case "resume":
|
|
37
|
+
return `Keep ${move.to.metadata?.name ?? "this plan"}`;
|
|
38
|
+
case "cancel":
|
|
39
|
+
return "Move to Free";
|
|
40
|
+
default: {
|
|
41
|
+
const exhaustive = move;
|
|
42
|
+
return String(exhaustive);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=PlanPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlanPicker.js","sourceRoot":"","sources":["../src/billing/PlanPicker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAoC,MAAM,iBAAiB,CAAC;AAE7E,gDAAgD;AAChD,MAAM,CAAC,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AAyBzE;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,cAAc,GAAG,sBAA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,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BillingRedirect } from "./redirect.js";
|
|
2
|
+
/** Props for {@link PlanSection}. */
|
|
3
|
+
export interface PlanSectionProps {
|
|
4
|
+
/** The organization whose plan is shown. */
|
|
5
|
+
readonly orgId: string;
|
|
6
|
+
/**
|
|
7
|
+
* The organization is platform-managed: it runs on its integrator's
|
|
8
|
+
* plan, and the section says so instead of offering plans.
|
|
9
|
+
*/
|
|
10
|
+
readonly managed?: boolean;
|
|
11
|
+
/** Whether the organization's billing account holds a saved card. */
|
|
12
|
+
readonly hasPaymentMethod: boolean;
|
|
13
|
+
/** Re-read the billing account, so a card saved on Stripe's page shows. */
|
|
14
|
+
readonly onRefreshAccount?: () => void;
|
|
15
|
+
/** The host's seam for Stripe-hosted pages (see {@link BillingRedirect}). */
|
|
16
|
+
readonly redirect?: BillingRedirect;
|
|
17
|
+
/**
|
|
18
|
+
* The plan the person was choosing when they left to save a card (the
|
|
19
|
+
* `plan` query Stripe returns with). The section reopens that choice for
|
|
20
|
+
* an explicit confirm; it never subscribes on its own.
|
|
21
|
+
*/
|
|
22
|
+
readonly resumePlanId?: string;
|
|
23
|
+
/** Called once the resumed choice has been taken up, so the host can clear its query. */
|
|
24
|
+
readonly onResumeHandled?: () => void;
|
|
25
|
+
/** The clock the standing reads. Defaults to each render's time. */
|
|
26
|
+
readonly now?: Date;
|
|
27
|
+
/** Additional CSS class names. */
|
|
28
|
+
readonly className?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* An organization's plan on Stigmer Cloud: the current plan with its
|
|
32
|
+
* standing and the period's estimated invoice, the plan comparison, and
|
|
33
|
+
* the confirm step for a subscribe, switch, resume or cancel.
|
|
34
|
+
*
|
|
35
|
+
* Everyone who can view the organization's billing reads it; only those
|
|
36
|
+
* who can manage billing (its admins) see the choices. Renders nothing on
|
|
37
|
+
* an edition that serves no subscriptions.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <PlanSection orgId={orgId} hasPaymentMethod={hasCard} />
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function PlanSection({ orgId, managed, hasPaymentMethod, onRefreshAccount, redirect, resumePlanId, onResumeHandled, now, className, }: PlanSectionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
45
|
+
//# sourceMappingURL=PlanSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlanSection.d.ts","sourceRoot":"","sources":["../src/billing/PlanSection.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAWrD,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,2EAA2E;IAC3E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,yFAAyF;IACzF,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC,oEAAoE;IACpE,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,GAAG,EACH,SAAS,GACV,EAAE,gBAAgB,kDA4JlB"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { timestampDate } from "@bufbuild/protobuf/wkt";
|
|
5
|
+
import { cn } from "@stigmer/theme";
|
|
6
|
+
import { getUserMessage } from "@stigmer/sdk";
|
|
7
|
+
import { ApiResourceKind, useResourceAvailable } from "../deployment-mode.js";
|
|
8
|
+
import { useCheckPermission } from "../iam-policy/useCheckPermission.js";
|
|
9
|
+
import { ChangePlanDialog } from "./ChangePlanDialog.js";
|
|
10
|
+
import { PlanCard } from "./PlanCard.js";
|
|
11
|
+
import { PlanPicker } from "./PlanPicker.js";
|
|
12
|
+
import { buyablePlans, featuresLost } from "./plan-features.js";
|
|
13
|
+
import { planMove, planStanding, standingPlanId } from "./plan-state.js";
|
|
14
|
+
import { useCancelSubscription, useChangePlan } from "./useChangePlan.js";
|
|
15
|
+
import { useCreatePaymentMethodSetupSession } from "./useCreatePaymentMethodSetupSession.js";
|
|
16
|
+
import { usePeriodEstimate } from "./usePeriodEstimate.js";
|
|
17
|
+
import { usePlans } from "./usePlans.js";
|
|
18
|
+
import { useSubscription } from "./useSubscription.js";
|
|
19
|
+
/** How often, and how long, the section waits for a just-saved card to reach the account. */
|
|
20
|
+
const CARD_POLL_MS = 2_000;
|
|
21
|
+
const CARD_WAIT_MS = 30_000;
|
|
22
|
+
/**
|
|
23
|
+
* An organization's plan on Stigmer Cloud: the current plan with its
|
|
24
|
+
* standing and the period's estimated invoice, the plan comparison, and
|
|
25
|
+
* the confirm step for a subscribe, switch, resume or cancel.
|
|
26
|
+
*
|
|
27
|
+
* Everyone who can view the organization's billing reads it; only those
|
|
28
|
+
* who can manage billing (its admins) see the choices. Renders nothing on
|
|
29
|
+
* an edition that serves no subscriptions.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <PlanSection orgId={orgId} hasPaymentMethod={hasCard} />
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function PlanSection({ orgId, managed = false, hasPaymentMethod, onRefreshAccount, redirect, resumePlanId, onResumeHandled, now, className, }) {
|
|
37
|
+
const available = useResourceAvailable(ApiResourceKind.subscription);
|
|
38
|
+
const renderNow = now ?? new Date();
|
|
39
|
+
const catalog = usePlans({ includeRetired: true, enabled: available });
|
|
40
|
+
const current = useSubscription(available ? orgId : null);
|
|
41
|
+
const standing = planStanding(current.subscription, renderNow);
|
|
42
|
+
const livePlanId = standingPlanId(standing);
|
|
43
|
+
const estimate = usePeriodEstimate(orgId, { enabled: available && !managed && livePlanId !== "" });
|
|
44
|
+
const manage = useCheckPermission(available && orgId ? { kind: "organization", id: orgId } : null, "can_manage_billing");
|
|
45
|
+
const canManage = !managed && !manage.isLoading && manage.allowed;
|
|
46
|
+
const changer = useChangePlan();
|
|
47
|
+
const canceler = useCancelSubscription();
|
|
48
|
+
const setup = useCreatePaymentMethodSetupSession(redirect);
|
|
49
|
+
const [move, setMove] = useState(null);
|
|
50
|
+
const [awaitingCard, setAwaitingCard] = useState(false);
|
|
51
|
+
const buyable = useMemo(() => buyablePlans(catalog.plans ?? []), [catalog.plans]);
|
|
52
|
+
const planById = useCallback((planId) => catalog.plans?.find((plan) => plan.metadata?.id === planId), [catalog.plans]);
|
|
53
|
+
const planName = useCallback((planId) => planById(planId)?.metadata?.name ?? "your plan", [planById]);
|
|
54
|
+
const periodEndStamp = current.subscription?.status?.currentPeriodEnd;
|
|
55
|
+
const periodEnd = periodEndStamp === undefined ? undefined : timestampDate(periodEndStamp);
|
|
56
|
+
// Back from Stripe's card page: reopen the choice the person was making.
|
|
57
|
+
// Keyed by the plan resumed, and cleared once the host drops the query,
|
|
58
|
+
// because a desktop host stays mounted across returns and may resume again.
|
|
59
|
+
const resumedFor = useRef(null);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (resumePlanId === undefined || resumePlanId === "") {
|
|
62
|
+
resumedFor.current = null;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (resumedFor.current === resumePlanId || catalog.plans === null || current.isLoading) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
resumedFor.current = resumePlanId;
|
|
69
|
+
const target = buyable.find((plan) => plan.metadata?.id === resumePlanId);
|
|
70
|
+
const resumedMove = target === undefined ? null : planMove(standing, target, periodEnd);
|
|
71
|
+
if (resumedMove !== null) {
|
|
72
|
+
setMove(resumedMove);
|
|
73
|
+
setAwaitingCard(!hasPaymentMethod);
|
|
74
|
+
}
|
|
75
|
+
onResumeHandled?.();
|
|
76
|
+
}, [resumePlanId, catalog.plans, current.isLoading, buyable, standing, periodEnd, hasPaymentMethod, onResumeHandled]);
|
|
77
|
+
// The card lands on the account by webhook a few seconds after Stripe's
|
|
78
|
+
// page returns; poll the account until it does, bounded.
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (!awaitingCard)
|
|
81
|
+
return;
|
|
82
|
+
if (hasPaymentMethod) {
|
|
83
|
+
setAwaitingCard(false);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const started = Date.now();
|
|
87
|
+
const timer = setInterval(() => {
|
|
88
|
+
if (Date.now() - started > CARD_WAIT_MS) {
|
|
89
|
+
setAwaitingCard(false);
|
|
90
|
+
clearInterval(timer);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
onRefreshAccount?.();
|
|
94
|
+
}, CARD_POLL_MS);
|
|
95
|
+
return () => clearInterval(timer);
|
|
96
|
+
}, [awaitingCard, hasPaymentMethod, onRefreshAccount]);
|
|
97
|
+
const close = useCallback(() => {
|
|
98
|
+
setMove(null);
|
|
99
|
+
setAwaitingCard(false);
|
|
100
|
+
changer.clearError();
|
|
101
|
+
canceler.clearError();
|
|
102
|
+
setup.clearError();
|
|
103
|
+
}, [changer.clearError, canceler.clearError, setup.clearError]);
|
|
104
|
+
const refreshAll = useCallback(() => {
|
|
105
|
+
current.refetch();
|
|
106
|
+
estimate.refetch();
|
|
107
|
+
}, [current.refetch, estimate.refetch]);
|
|
108
|
+
const confirm = useCallback(() => {
|
|
109
|
+
if (move === null)
|
|
110
|
+
return;
|
|
111
|
+
const done = move.kind === "cancel" ? canceler.cancel(orgId) : changer.changePlan(orgId, move.to.metadata?.id ?? "");
|
|
112
|
+
done.then(() => {
|
|
113
|
+
setMove(null);
|
|
114
|
+
refreshAll();
|
|
115
|
+
}, () => undefined);
|
|
116
|
+
}, [move, orgId, canceler.cancel, changer.changePlan, refreshAll]);
|
|
117
|
+
const addPaymentMethod = useCallback(() => {
|
|
118
|
+
const planId = move !== null && move.kind !== "cancel" ? move.to.metadata?.id : undefined;
|
|
119
|
+
setup.addPaymentMethod(orgId, planId).catch(() => undefined);
|
|
120
|
+
}, [move, orgId, setup.addPaymentMethod]);
|
|
121
|
+
if (!available) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
if (current.isLoading || catalog.isLoading) {
|
|
125
|
+
return (_jsx("div", { className: cn("stg:space-y-3", className), "aria-busy": "true", "aria-label": "Loading plan", children: _jsx("div", { className: "stg:h-24 stg:animate-pulse stg:rounded-lg stg:bg-muted-subtle" }) }));
|
|
126
|
+
}
|
|
127
|
+
const readError = current.error ?? catalog.error;
|
|
128
|
+
if (readError) {
|
|
129
|
+
return (_jsx("p", { className: cn("stg:text-xs stg:text-destructive", className), role: "alert", children: getUserMessage(readError) }));
|
|
130
|
+
}
|
|
131
|
+
const nameInForce = livePlanId === "" ? "Free" : planName(livePlanId);
|
|
132
|
+
const moveError = move?.kind === "cancel" ? canceler.error : (changer.error ?? setup.error);
|
|
133
|
+
const losing = move?.kind === "switch" ? featuresLost(planById(move.fromPlanId), move.to) : [];
|
|
134
|
+
return (_jsxs("section", { className: cn("stg:space-y-3", className), "aria-label": "Plan", children: [_jsx(PlanCard, { planName: nameInForce, standing: standing, estimate: estimate.estimate, estimateError: estimate.error, managed: managed }), !managed && (_jsx(PlanPicker, { plans: buyable, standing: standing, periodEnd: periodEnd, canManage: canManage, onChoose: setMove, disabled: changer.isSubmitting || canceler.isSubmitting })), _jsx(ChangePlanDialog, { move: move, planName: planName, losing: losing, hasPaymentMethod: hasPaymentMethod, awaitingPaymentMethod: awaitingCard, isSubmitting: changer.isSubmitting || canceler.isSubmitting || setup.isSubmitting, error: moveError, onConfirm: confirm, onAddPaymentMethod: addPaymentMethod, onClose: close })] }));
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=PlanSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlanSection.js","sourceRoot":"","sources":["../src/billing/PlanSection.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAiB,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO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I,QAAQ,CAAC,YAAY,IAAI,KAAK,CAAC,YAAY,EACjF,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,OAAO,EAClB,kBAAkB,EAAE,gBAAgB,EACpC,OAAO,EAAE,KAAK,GACd,IACM,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Feature } from "@stigmer/protos/ai/stigmer/platform/v1/entitlement_pb";
|
|
2
|
+
/**
|
|
3
|
+
* The reason Stigmer Cloud refuses an act the organization's plan does not
|
|
4
|
+
* include (iam/team/v1 and tenancy/organization/v1 command.proto).
|
|
5
|
+
*/
|
|
6
|
+
export declare const PLAN_UPGRADE_REQUIRED = "PLAN_UPGRADE_REQUIRED";
|
|
7
|
+
/** The billing page the notice links to by default: the settings route every client serves. */
|
|
8
|
+
export declare const DEFAULT_BILLING_HREF = "/settings/billing";
|
|
9
|
+
/**
|
|
10
|
+
* The feature a refusal says the organization's plan lacks, when `error`
|
|
11
|
+
* is Stigmer Cloud's `PLAN_UPGRADE_REQUIRED`; `null` for any other error.
|
|
12
|
+
*/
|
|
13
|
+
export declare function planUpgradeFeature(error: unknown): Feature | null;
|
|
14
|
+
/** Props for {@link UpgradeNotice}. */
|
|
15
|
+
export interface UpgradeNoticeProps {
|
|
16
|
+
/** The feature the organization's plan lacks. */
|
|
17
|
+
readonly feature: Feature;
|
|
18
|
+
/**
|
|
19
|
+
* The refusal, when there was one: its message is the server's own
|
|
20
|
+
* copy, which names the plan that unlocks the act. Absent, the notice is
|
|
21
|
+
* shown ahead of an attempt.
|
|
22
|
+
*/
|
|
23
|
+
readonly error?: Error | null;
|
|
24
|
+
/**
|
|
25
|
+
* The plan that unlocks the feature, named ahead of an attempt, e.g. the
|
|
26
|
+
* cheapest one that includes it (`lowestPlanWith`). With a refusal,
|
|
27
|
+
* the server's copy names it instead.
|
|
28
|
+
*/
|
|
29
|
+
readonly unlockingPlanName?: string;
|
|
30
|
+
/** Where the plans are, in the host's routing. Defaults to {@link DEFAULT_BILLING_HREF}. */
|
|
31
|
+
readonly billingHref?: string;
|
|
32
|
+
/** Additional CSS class names. */
|
|
33
|
+
readonly className?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Says an act needs a plan that includes it, and where to change the plan,
|
|
37
|
+
* in place of a bare refusal. Everything the organization already has keeps
|
|
38
|
+
* working; only creating more is refused.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const feature = planUpgradeFeature(error);
|
|
43
|
+
* if (feature !== null) return <UpgradeNotice feature={feature} error={error} />;
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function UpgradeNotice({ feature, error, unlockingPlanName, billingHref, className, }: UpgradeNoticeProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
//# sourceMappingURL=UpgradeNotice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpgradeNotice.d.ts","sourceRoot":"","sources":["../src/billing/UpgradeNotice.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,uDAAuD,CAAC;AAGhF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,+FAA+F;AAC/F,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AAQxD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAMjE;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,4FAA4F;IAC5F,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,kCAAkC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,KAAK,EACL,iBAAiB,EACjB,WAAkC,EAClC,SAAS,GACV,EAAE,kBAAkB,2CAqBpB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@stigmer/theme";
|
|
4
|
+
import { getErrorReason, getUserMessage } from "@stigmer/sdk";
|
|
5
|
+
import { Feature } from "@stigmer/protos/ai/stigmer/platform/v1/entitlement_pb";
|
|
6
|
+
import { FEATURE_COPY, isNamedFeature } from "../internal/features.js";
|
|
7
|
+
/**
|
|
8
|
+
* The reason Stigmer Cloud refuses an act the organization's plan does not
|
|
9
|
+
* include (iam/team/v1 and tenancy/organization/v1 command.proto).
|
|
10
|
+
*/
|
|
11
|
+
export const PLAN_UPGRADE_REQUIRED = "PLAN_UPGRADE_REQUIRED";
|
|
12
|
+
/** The billing page the notice links to by default: the settings route every client serves. */
|
|
13
|
+
export const DEFAULT_BILLING_HREF = "/settings/billing";
|
|
14
|
+
/** The wire names the refusal's `feature` metadata carries. */
|
|
15
|
+
const FEATURE_BY_WIRE_NAME = {
|
|
16
|
+
teams: Feature.teams,
|
|
17
|
+
managed_organizations: Feature.managed_organizations,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The feature a refusal says the organization's plan lacks, when `error`
|
|
21
|
+
* is Stigmer Cloud's `PLAN_UPGRADE_REQUIRED`; `null` for any other error.
|
|
22
|
+
*/
|
|
23
|
+
export function planUpgradeFeature(error) {
|
|
24
|
+
const reason = getErrorReason(error);
|
|
25
|
+
if (reason?.reason !== PLAN_UPGRADE_REQUIRED) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return FEATURE_BY_WIRE_NAME[reason.metadata.feature ?? ""] ?? null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Says an act needs a plan that includes it, and where to change the plan,
|
|
32
|
+
* in place of a bare refusal. Everything the organization already has keeps
|
|
33
|
+
* working; only creating more is refused.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* const feature = planUpgradeFeature(error);
|
|
38
|
+
* if (feature !== null) return <UpgradeNotice feature={feature} error={error} />;
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function UpgradeNotice({ feature, error, unlockingPlanName, billingHref = DEFAULT_BILLING_HREF, className, }) {
|
|
42
|
+
const label = isNamedFeature(feature) ? FEATURE_COPY[feature].label : "This feature";
|
|
43
|
+
const ahead = unlockingPlanName === undefined || unlockingPlanName === ""
|
|
44
|
+
? `${label} are not included in this organization's plan.`
|
|
45
|
+
: `${label} need the ${unlockingPlanName} plan or above.`;
|
|
46
|
+
const message = error ? getUserMessage(error) : ahead;
|
|
47
|
+
return (_jsxs("div", { className: cn("stg:rounded-md stg:border stg:border-border stg:bg-muted-subtle stg:px-3 stg:py-2 stg:text-xs", className), role: "status", children: [_jsx("p", { className: "stg:text-foreground", children: message }), _jsx("a", { href: billingHref, className: "stg:mt-1 stg:inline-block stg:font-medium stg:text-primary stg:hover:underline", children: "View plans" })] }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=UpgradeNotice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpgradeNotice.js","sourceRoot":"","sources":["../src/billing/UpgradeNotice.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,uDAAuD,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,cAAc,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,aAEb,YAAG,SAAS,EAAC,qBAAqB,YAAE,OAAO,GAAK,EAChD,YAAG,IAAI,EAAE,WAAW,EAAE,SAAS,EAAC,gFAAgF,2BAE5G,IACA,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit-packs.d.ts","sourceRoot":"","sources":["../src/billing/credit-packs.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,cAAc,
|
|
1
|
+
{"version":3,"file":"credit-packs.d.ts","sourceRoot":"","sources":["../src/billing/credit-packs.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,cAAc,EAyBjD,CAAC;AAEF,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
package/billing/credit-packs.js
CHANGED
|
@@ -20,8 +20,11 @@ export const CREDIT_PACKS = [
|
|
|
20
20
|
credits: 5_000,
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
+
// Named "Scale", not "Team", so it never reads as the Team plan on the
|
|
24
|
+
// page that sells both; its id stays "team", the wire value every
|
|
25
|
+
// purchase row and checkout call carries.
|
|
23
26
|
packId: "team",
|
|
24
|
-
displayName: "
|
|
27
|
+
displayName: "Scale",
|
|
25
28
|
description: "For production workloads",
|
|
26
29
|
priceCents: 20_000,
|
|
27
30
|
credits: 20_000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit-packs.js","sourceRoot":"","sources":["../src/billing/credit-packs.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAA8B;IACrD;QACE,MAAM,EAAE,SAAS;QACjB,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE,uBAAuB;QACpC,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;KACf;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,QAAQ;QACrB,WAAW,EAAE,mBAAmB;QAChC,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;KACf;IACD;QACE,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"credit-packs.js","sourceRoot":"","sources":["../src/billing/credit-packs.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAA8B;IACrD;QACE,MAAM,EAAE,SAAS;QACjB,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE,uBAAuB;QACpC,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;KACf;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,QAAQ;QACrB,WAAW,EAAE,mBAAmB;QAChC,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;KACf;IACD;QACE,uEAAuE;QACvE,kEAAkE;QAClE,0CAA0C;QAC1C,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,OAAO;QACpB,WAAW,EAAE,0BAA0B;QACvC,UAAU,EAAE,MAAM;QAClB,OAAO,EAAE,MAAM;KAChB;CACF,CAAC;AAEF,qEAAqE;AACrE,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,OAAO,GAAG,KAAK,GAAG,GAAG,CAAC;IAC5B,OAAO,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AACtE,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
package/billing/index.d.ts
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
export { useBillingAccount } from "./useBillingAccount.js";
|
|
2
|
-
export type { UseBillingAccountReturn } from "./useBillingAccount.js";
|
|
2
|
+
export type { UseBillingAccountOptions, UseBillingAccountReturn } from "./useBillingAccount.js";
|
|
3
3
|
export { useCreditLedger } from "./useCreditLedger.js";
|
|
4
4
|
export type { UseCreditLedgerReturn, UseCreditLedgerOptions } from "./useCreditLedger.js";
|
|
5
5
|
export { useBillingUsageReport } from "./useBillingUsageReport.js";
|
|
6
6
|
export type { UseBillingUsageReportReturn } from "./useBillingUsageReport.js";
|
|
7
7
|
export { useCustomerModelPricing } from "./useCustomerModelPricing.js";
|
|
8
8
|
export type { UseCustomerModelPricingReturn } from "./useCustomerModelPricing.js";
|
|
9
|
+
export { usePlans } from "./usePlans.js";
|
|
10
|
+
export type { UsePlansOptions, UsePlansReturn } from "./usePlans.js";
|
|
11
|
+
export { useSubscription } from "./useSubscription.js";
|
|
12
|
+
export type { UseSubscriptionReturn } from "./useSubscription.js";
|
|
13
|
+
export { useEntitlements } from "./useEntitlements.js";
|
|
14
|
+
export type { UseEntitlementsOptions, UseEntitlementsReturn } from "./useEntitlements.js";
|
|
15
|
+
export { usePeriodEstimate } from "./usePeriodEstimate.js";
|
|
16
|
+
export type { UsePeriodEstimateOptions, UsePeriodEstimateReturn } from "./usePeriodEstimate.js";
|
|
9
17
|
export { useCreateCheckoutSession } from "./useCreateCheckoutSession.js";
|
|
10
18
|
export type { CreateCheckoutSessionInput, UseCreateCheckoutSessionReturn, } from "./useCreateCheckoutSession.js";
|
|
11
19
|
export { useCreateBillingPortalSession } from "./useCreateBillingPortalSession.js";
|
|
12
20
|
export type { UseCreateBillingPortalSessionReturn } from "./useCreateBillingPortalSession.js";
|
|
21
|
+
export { useChangePlan, useCancelSubscription } from "./useChangePlan.js";
|
|
22
|
+
export type { UseChangePlanReturn, UseCancelSubscriptionReturn } from "./useChangePlan.js";
|
|
23
|
+
export { useCreatePaymentMethodSetupSession } from "./useCreatePaymentMethodSetupSession.js";
|
|
24
|
+
export type { UseCreatePaymentMethodSetupSessionReturn } from "./useCreatePaymentMethodSetupSession.js";
|
|
25
|
+
export type { BillingRedirect } from "./redirect.js";
|
|
26
|
+
export { planStanding, planMove } from "./plan-state.js";
|
|
27
|
+
export type { PlanStanding, PlanMove } from "./plan-state.js";
|
|
13
28
|
export { useSetAutoRechargeConfig } from "./useSetAutoRechargeConfig.js";
|
|
14
29
|
export type { SetAutoRechargeConfigInput, UseSetAutoRechargeConfigReturn, } from "./useSetAutoRechargeConfig.js";
|
|
15
30
|
export { BillingSection } from "./BillingSection.js";
|
|
@@ -26,6 +41,16 @@ export { CreditLedgerTable } from "./CreditLedgerTable.js";
|
|
|
26
41
|
export type { CreditLedgerTableProps } from "./CreditLedgerTable.js";
|
|
27
42
|
export { LowBalanceBanner } from "./LowBalanceBanner.js";
|
|
28
43
|
export type { LowBalanceBannerProps } from "./LowBalanceBanner.js";
|
|
44
|
+
export { PlanSection } from "./PlanSection.js";
|
|
45
|
+
export type { PlanSectionProps } from "./PlanSection.js";
|
|
46
|
+
export { PlanCard } from "./PlanCard.js";
|
|
47
|
+
export type { PlanCardProps } from "./PlanCard.js";
|
|
48
|
+
export { PlanPicker, ENTERPRISE_CONTACT_URL } from "./PlanPicker.js";
|
|
49
|
+
export type { PlanPickerProps } from "./PlanPicker.js";
|
|
50
|
+
export { ChangePlanDialog, PAYMENT_METHOD_REQUIRED } from "./ChangePlanDialog.js";
|
|
51
|
+
export type { ChangePlanDialogProps } from "./ChangePlanDialog.js";
|
|
52
|
+
export { UpgradeNotice, planUpgradeFeature, PLAN_UPGRADE_REQUIRED, DEFAULT_BILLING_HREF } from "./UpgradeNotice.js";
|
|
53
|
+
export type { UpgradeNoticeProps } from "./UpgradeNotice.js";
|
|
29
54
|
export { CREDIT_PACKS, formatPackPrice, formatCreditCount } from "./credit-packs.js";
|
|
30
55
|
export type { CreditPackInfo } from "./credit-packs.js";
|
|
31
56
|
export { formatCreditBalance, formatLedgerAmount, ledgerEntryLabel, isCredit, isHold, formatLedgerDate, } from "./format.js";
|
package/billing/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/billing/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/billing/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACv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,UAAU,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACrE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAClF,YAAY,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACpH,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrF,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
|
package/billing/index.js
CHANGED
|
@@ -7,9 +7,16 @@ export { useBillingAccount } from "./useBillingAccount.js";
|
|
|
7
7
|
export { useCreditLedger } from "./useCreditLedger.js";
|
|
8
8
|
export { useBillingUsageReport } from "./useBillingUsageReport.js";
|
|
9
9
|
export { useCustomerModelPricing } from "./useCustomerModelPricing.js";
|
|
10
|
+
export { usePlans } from "./usePlans.js";
|
|
11
|
+
export { useSubscription } from "./useSubscription.js";
|
|
12
|
+
export { useEntitlements } from "./useEntitlements.js";
|
|
13
|
+
export { usePeriodEstimate } from "./usePeriodEstimate.js";
|
|
10
14
|
// Behavior hooks
|
|
11
15
|
export { useCreateCheckoutSession } from "./useCreateCheckoutSession.js";
|
|
12
16
|
export { useCreateBillingPortalSession } from "./useCreateBillingPortalSession.js";
|
|
17
|
+
export { useChangePlan, useCancelSubscription } from "./useChangePlan.js";
|
|
18
|
+
export { useCreatePaymentMethodSetupSession } from "./useCreatePaymentMethodSetupSession.js";
|
|
19
|
+
export { planStanding, planMove } from "./plan-state.js";
|
|
13
20
|
export { useSetAutoRechargeConfig } from "./useSetAutoRechargeConfig.js";
|
|
14
21
|
// Styled components
|
|
15
22
|
export { BillingSection } from "./BillingSection.js";
|
|
@@ -19,6 +26,11 @@ export { AutoRechargeCard } from "./AutoRechargeCard.js";
|
|
|
19
26
|
export { CreditPackGrid } from "./CreditPackGrid.js";
|
|
20
27
|
export { CreditLedgerTable } from "./CreditLedgerTable.js";
|
|
21
28
|
export { LowBalanceBanner } from "./LowBalanceBanner.js";
|
|
29
|
+
export { PlanSection } from "./PlanSection.js";
|
|
30
|
+
export { PlanCard } from "./PlanCard.js";
|
|
31
|
+
export { PlanPicker, ENTERPRISE_CONTACT_URL } from "./PlanPicker.js";
|
|
32
|
+
export { ChangePlanDialog, PAYMENT_METHOD_REQUIRED } from "./ChangePlanDialog.js";
|
|
33
|
+
export { UpgradeNotice, planUpgradeFeature, PLAN_UPGRADE_REQUIRED, DEFAULT_BILLING_HREF } from "./UpgradeNotice.js";
|
|
22
34
|
// Credit pack catalog and formatting utilities
|
|
23
35
|
export { CREDIT_PACKS, formatPackPrice, formatCreditCount } from "./credit-packs.js";
|
|
24
36
|
export { formatCreditBalance, formatLedgerAmount, ledgerEntryLabel, isCredit, isHold, formatLedgerDate, } from "./format.js";
|
package/billing/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/billing/index.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,yEAAyE;AACzE,oEAAoE;AACpE,iEAAiE;AAEjE,aAAa;AACb,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceR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AAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAElF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGpH,+CAA+C;AAC/C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAErF,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Timestamp } from "@bufbuild/protobuf/wkt";
|
|
2
|
+
import type { Plan } from "@stigmer/protos/ai/stigmer/billing/plan/v1/api_pb";
|
|
3
|
+
import { type PlanTerms } from "@stigmer/protos/ai/stigmer/billing/plan/v1/spec_pb";
|
|
4
|
+
import { Feature, type Entitlements } from "@stigmer/protos/ai/stigmer/platform/v1/entitlement_pb";
|
|
5
|
+
import { type NamedFeature } from "../internal/features.js";
|
|
6
|
+
/**
|
|
7
|
+
* Features a plan may list ahead of the gate that serves them, which
|
|
8
|
+
* Stigmer Cloud does not offer yet. The console leaves them out of every
|
|
9
|
+
* comparison. Bring-your-own provider keys leaves this set when the proxy
|
|
10
|
+
* uses an organization's own key.
|
|
11
|
+
*/
|
|
12
|
+
export declare const NOT_YET_OFFERED: ReadonlySet<Feature>;
|
|
13
|
+
/** One feature a plan offers today, with its words. */
|
|
14
|
+
export interface OfferedFeature {
|
|
15
|
+
readonly feature: NamedFeature;
|
|
16
|
+
readonly label: string;
|
|
17
|
+
readonly description: string;
|
|
18
|
+
}
|
|
19
|
+
/** The features `entitlements` grant that Cloud offers today, in contract order. */
|
|
20
|
+
export declare function offeredFeatures(entitlements: Entitlements | undefined): readonly OfferedFeature[];
|
|
21
|
+
/**
|
|
22
|
+
* The plans an organization can subscribe to, cheapest monthly minimum
|
|
23
|
+
* first, so a comparison reads upward from Free; equal minimums keep the
|
|
24
|
+
* catalog's order. Retired rows and prepaid instruments are left out.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buyablePlans(plans: readonly Plan[]): readonly Plan[];
|
|
27
|
+
/** The cheapest plan that can be bought and includes `feature`, if any. */
|
|
28
|
+
export declare function lowestPlanWith(plans: readonly Plan[], feature: Feature): Plan | undefined;
|
|
29
|
+
/** What `from` offers that `to` does not: what a switch stops the organization creating. */
|
|
30
|
+
export declare function featuresLost(from: Plan | undefined, to: Plan): readonly OfferedFeature[];
|
|
31
|
+
/** A plan's monthly minimum, e.g. "$99.00/month". */
|
|
32
|
+
export declare function formatMonthlyMinimum(terms: PlanTerms | undefined): string;
|
|
33
|
+
/**
|
|
34
|
+
* A plan's usage share as its terms state it, for operators who read terms,
|
|
35
|
+
* e.g. "or 10% of provider cost, whichever is greater; the commission
|
|
36
|
+
* already paid on tokens counts toward it". Empty when the plan has no
|
|
37
|
+
* usage share.
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatUsageShare(terms: PlanTerms | undefined): string;
|
|
40
|
+
/**
|
|
41
|
+
* The same share as a customer reads it: usage stays paid from credits,
|
|
42
|
+
* and the commission on it counts toward the minimum up to the spend at
|
|
43
|
+
* which the plan costs nothing extra, e.g. "Usage is still paid from
|
|
44
|
+
* credits. The 10% commission on it counts toward the minimum, so from
|
|
45
|
+
* $990.00 a month in provider costs the plan costs nothing extra." Empty
|
|
46
|
+
* when the plan has no usage share.
|
|
47
|
+
*/
|
|
48
|
+
export declare function explainUsageShare(terms: PlanTerms | undefined): string;
|
|
49
|
+
/** The usage share as a percentage, e.g. "10%" or "12.50%"; empty when there is none. */
|
|
50
|
+
export declare function sharePercent(terms: PlanTerms | undefined): string;
|
|
51
|
+
/** The managed organizations a plan includes and what each beyond costs, or empty. */
|
|
52
|
+
export declare function formatManagedOrganizations(entitlements: Entitlements | undefined, terms: PlanTerms | undefined): string;
|
|
53
|
+
/**
|
|
54
|
+
* A period boundary as a UTC calendar day, e.g. "Feb 28, 2027". Periods
|
|
55
|
+
* run anniversary to anniversary in UTC, the rule the invoice follows.
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatPeriodDay(timestamp: Timestamp | undefined): string;
|
|
58
|
+
/** An instant as its UTC calendar day, the way {@link formatPeriodDay} shows a period boundary. */
|
|
59
|
+
export declare function formatDay(date: Date): string;
|
|
60
|
+
//# sourceMappingURL=plan-features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-features.d.ts","sourceRoot":"","sources":["../src/billing/plan-features.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mDAAmD,CAAC;AAC9E,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,oDAAoD,CAAC;AAEpG,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,uDAAuD,CAAC;AACnG,OAAO,EAAgC,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAO1F;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,OAAO,CAAwC,CAAC;AAE1F,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS,GAAG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