@buildbase/sdk 0.0.67 → 0.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("./react-DP8VKZUU.cjs"),s=require("./SettingsDialog-CcpkqG7N.cjs");require("clsx"),require("tailwind-merge"),require("intl-messageformat"),require("@hookform/resolvers/zod"),require("react-hook-form"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("lucide-react"),require("@radix-ui/react-label"),require("zod"),require("@radix-ui/react-avatar"),require("@radix-ui/react-dialog"),require("@radix-ui/react-icons"),require("@radix-ui/react-radio-group"),require("@radix-ui/react-scroll-area"),require("@radix-ui/react-separator"),require("@radix-ui/react-accordion"),require("@radix-ui/react-alert-dialog"),require("@radix-ui/react-switch"),require("cmdk"),require("@radix-ui/react-popover"),require("@radix-ui/react-select");const i={[t.BillingIntervals.Monthly]:"subscription.billingInterval.perMonth",[t.BillingIntervals.Quarterly]:"subscription.billingInterval.perQuarter",[t.BillingIntervals.Yearly]:"subscription.billingInterval.perYear"},n=(e,r,s)=>{if(!e||0===e)return null;let i;switch(s){case t.BillingIntervals.Yearly:i=r/12;break;case t.BillingIntervals.Quarterly:i=r/3;break;default:return null}const n=(e-i)/e*100;return n>0?Math.round(n):null},a=(e,r)=>t.getPricingVariant(e,r)?r:e.plan?.currency??r??"",l=e=>e.renewOnPeriod?"reset"===e.mode?"subscription.items.creditModeReset":"subscription.items.creditModeTopup":"subscription.items.creditModeLifetime",d=({planVersion:r})=>{const{t:s,fmtNum:i}=t.useTranslation(),n=r.creditGrant;return n?.enabled&&"object"==typeof n.creditPackage&&null!==n.creditPackage?e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-semibold text-info uppercase tracking-wider mb-1.5",children:s("subscription.items.credits")}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:n.renewOnPeriod?s("subscription.items.creditsPerMonth"):s("subscription.items.creditsOneTime")}),e.jsx("span",{className:"font-semibold text-info",children:i(n.creditPackage.creditAmount)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:s("subscription.items.creditRenewal")}),e.jsx("span",{className:"font-medium text-foreground",children:s(l(n))})]})]})]}):null},c=({hasVariant:r,price:s,displayCurrency:i,selectedInterval:n,getIntervalLabel:a})=>{const{t:l,fmtCents:d}=t.useTranslation();return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xl font-bold text-foreground",children:r&&null!==s?(c=s,o=i,(null==c||0===c?"":d(c,o))||l("pricing.free")):"—"}),null!==s&&s>0&&r&&e.jsx("span",{className:"text-sm text-muted-foreground",children:a(n)})]});var c,o},o=({planVersion:r,isCurrent:s,trialUsedAt:i,currentStripePriceId:n})=>{const{t:a}=t.useTranslation(),l=r.trial;return l?.enabled&&l.durationDays>0&&!s&&!i&&!n?e.jsx("span",{className:"shrink-0 rounded-md bg-success/15 text-success px-2 py-0.5 text-xs font-semibold uppercase tracking-wider",children:a("subscription.trialBadge",{days:l.durationDays})}):null};exports.default=({open:u,onOpenChange:m,source:x,planVersions:p,currentPlanVersionId:b,currentStripePriceId:g,billingCurrency:h,currentMemberCount:f,trialUsedAt:y,workspaceName:j,initialInterval:v,initialCurrency:N,onSelectPlan:k,loading:w=!1})=>{const[I,_]=r.useState(!1),{t:P,formattingLocale:S,dir:C,fmtNum:B,fmtCents:q}=t.useTranslation(),{settings:M}=t.useSaaSSettings(),T=M?.workspace?.mode===s.WorkspaceModes.Personal,D=e=>P(i[e]??i[t.BillingIntervals.Monthly]),[L,F]=r.useState(null),z=r.useRef(!1),V=r.useMemo(()=>t.getBillingIntervalAndCurrencyFromPriceId(g,p),[g,p]),K=V?.interval??null,Q=V?.currency??null,O=r.useMemo(()=>t.getAvailableCurrenciesFromPlans(p),[p]),U=r.useMemo(()=>{const e=h?.trim().toLowerCase();return e?O.includes(e)?[e]:[]:O},[h,O]),[A,W]=r.useState(v||K||t.BillingIntervals.Monthly),[G,Y]=r.useState(()=>N&&U.includes(N)?N:Q&&U.includes(Q)?Q:U.length>0?U[0]:""),R=h?.trim()||G;r.useEffect(()=>{if(u){W(v||K||t.BillingIntervals.Monthly);const e=N||Q;e&&U.includes(e)?Y(e):U.length>0&&!U.includes(G)&&Y(U[0])}},[u,v,N,K,Q,U]);const $=p,E=r.useMemo(()=>(e=>{const r=new Map;return e.forEach(e=>{e.subscriptionItems?.forEach(e=>{r.has(e._id)||r.set(e._id,e)})}),Array.from(r.values())})($),[$]),H=E.filter(e=>e.type===t.SubscriptionItemType.Feature),J=E.filter(e=>e.type===t.SubscriptionItemType.Limit),X=E.filter(e=>e.type===t.SubscriptionItemType.Quota),{emit:Z,ready:ee}=t.useFunnel(),re=r.useRef(!1),te=r.useRef(!1);r.useEffect(()=>{if(!u)return re.current&&!te.current&&Z("plan_picker_dismissed",{source:x,billing_interval:A}),re.current=!1,void(te.current=!1);!re.current&&ee&&(re.current=!0,Z("plan_picker_opened",{source:x,plan_count:p.length,has_subscription:!!b,current_plan_version_id:b,billing_interval:A,currency:R?R.toUpperCase():void 0}))},[u,ee]);const se=e=>{if(!b)return"new";if(e._id===b)return"interval_change";const r=p.find(e=>e._id===b),s=r?t.getBasePriceCents(r,R,A):null,i=t.getBasePriceCents(e,R,A);return null==s||null==i?"change":i>=s?"upgrade":"downgrade"},ie=async e=>{if(e===b&&K===A||w||I||z.current)return;const r=p.find(r=>r._id===e);if(r){const s=t.getBasePriceCents(r,R,A);te.current=!0,Z("plan_selected",{source:x,plan_version_id:e,plan_slug:r.plan?.slug,billing_interval:A,currency:R?R.toUpperCase():void 0,value:null==s?void 0:t.toMajorUnits(s,R),change:se(r),is_free:!!r.plan?.isFreemium})}z.current=!0,_(!0),F(e);try{await k(e,A,R),m(!1)}catch(e){}finally{z.current=!1,_(!1),F(null)}},ne=e=>t.getBasePriceCents(e,R,A),ae=e=>!!e.pricingVariants?.some(e=>e.currency?.toLowerCase()===R.toLowerCase()),le=w||I,de=e=>{switch(e){case t.BillingIntervals.Monthly:return P("subscription.billingInterval.monthly");case t.BillingIntervals.Quarterly:return P("subscription.billingInterval.quarterly");case t.BillingIntervals.Yearly:return P("subscription.billingInterval.yearly");default:return P("subscription.billingInterval.monthly")}},ce=e=>{const r=e._id===b,t=K===A;if(r&&t)return{labelKey:"subscription.currentPlan",variant:"outline",disabled:!0};if(r&&!t)return e.plan?.isFreemium?{labelKey:"subscription.currentPlan",variant:"outline",disabled:!0}:{labelKey:"_dynamic",dynamicLabel:P("subscription.switchToInterval",{interval:de(A)}),variant:"default",disabled:!1};const s=e.trial?.enabled&&e.trial.durationDays>0&&!y&&!g;if(!b)return s?{labelKey:"_dynamic",dynamicLabel:P("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.subscribe",variant:"default",disabled:!1};const i=$.findIndex(e=>e._id===b),n=$.findIndex(r=>r._id===e._id);return-1===i||-1===n?s?{labelKey:"_dynamic",dynamicLabel:P("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.checkout.select",variant:"default",disabled:!1}:n<i?{labelKey:"subscription.checkout.downgrade",variant:"outline",disabled:!1}:n>i?s?{labelKey:"_dynamic",dynamicLabel:P("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.checkout.upgrade",variant:"default",disabled:!1}:{labelKey:"subscription.checkout.select",variant:"default",disabled:!1}},oe=(e,r,s=t.BillingIntervals.Monthly)=>{if(r.type===t.SubscriptionItemType.Feature)return e.features?.[r.slug]??!1;if(r.type===t.SubscriptionItemType.Limit)return e.limits?.[r.slug]??null;if(r.type===t.SubscriptionItemType.Quota){const i=t.getQuotaDisplayWithVariant(e,R,r.slug,s);return i||t.getQuotaDisplayValue(e.quotas?.[r.slug],s)}return null},ue=(e,r,s)=>{if(r.type===t.SubscriptionItemType.Feature)return!0===e?"✓":"—";if(r.type===t.SubscriptionItemType.Limit)return null!=e&&"number"==typeof e?B(e):"—";if(r.type===t.SubscriptionItemType.Quota){const i="object"==typeof e&&null!==e&&"included"in e?e:null,n=t.getQuotaDisplayParts(i,r.name.toLowerCase(),{currency:s,locale:S});return n?n.allowOverage?n.hasOverage?P("quota.includedWithOverage",{count:n.included,price:n.price,unit:n.unit}):P("quota.includedOnly",{count:n.included}):P("quota.includedHardLimit",{count:n.included}):"—"}return"—"};return e.jsx(t.Dialog,{open:u,onOpenChange:m,children:e.jsxs(t.DialogContent,{dir:C,className:"inset-0 w-screen h-screen max-w-none rounded-none translate-x-0 translate-y-0 p-0 flex flex-col",children:[e.jsxs("div",{className:"flex-shrink-0 px-4 py-4 sm:px-6 sm:py-6 border-b space-y-3 sm:space-y-4",children:[e.jsxs("div",{children:[e.jsx(t.DialogTitle,{className:"text-xl font-semibold",children:P("pricing.title")}),e.jsxs(t.DialogDescription,{className:"mt-1 text-sm",children:[P("subscription.choosePlanDescription"),j&&e.jsx("span",{className:"ml-1 font-medium text-foreground",children:P("subscription.forWorkspace",{name:j})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[!h?.trim()&&U.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:P("pricing.currency")}),e.jsx("select",{"aria-label":P("pricing.selectCurrency"),value:G,onChange:e=>Y(e.target.value),className:"rounded-md border border-border bg-background px-3 py-2 text-sm font-medium text-foreground shadow-sm focus:outline-none focus:ring-2 focus:ring-primary",children:U.map(r=>{const s=t.getCurrencyFlag(r);return e.jsx("option",{value:r,children:s?`${s} ${r.toUpperCase()}`:r.toUpperCase()},r)})})]}),h?.trim()&&e.jsx("span",{className:"text-xs text-muted-foreground",children:P("subscription.billingInCurrency",{currency:h.toUpperCase()})})]}),e.jsx("div",{className:"flex items-center gap-0.5 sm:gap-1 p-1 bg-muted rounded-lg w-full sm:w-auto",role:"group","aria-label":P("pricing.billingInterval"),children:[t.BillingIntervals.Monthly,t.BillingIntervals.Quarterly,t.BillingIntervals.Yearly].map(r=>{const s=K===r;return e.jsx("button",{onClick:()=>(e=>{e!==A&&Z("billing_interval_changed",{from:A,to:e}),W(e)})(r),"aria-pressed":A===r,className:"flex-1 sm:flex-initial px-3 sm:px-4 py-2 text-sm font-medium rounded-md transition-all relative "+(A===r?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:e.jsxs("span",{className:"flex items-center justify-center gap-1 sm:gap-1.5",children:[r===t.BillingIntervals.Monthly&&P("subscription.billingInterval.monthly"),r===t.BillingIntervals.Quarterly&&P("subscription.billingInterval.quarterly"),r===t.BillingIntervals.Yearly&&P("subscription.billingInterval.yearly"),r===t.BillingIntervals.Yearly&&e.jsx("span",{className:"text-xs px-1 sm:px-1.5 py-0.5 bg-success/15 text-success rounded-full font-semibold",children:P("pricing.save")}),s&&b&&e.jsx("span",{className:"hidden sm:inline text-xs px-1.5 py-0.5 bg-info/15 text-info rounded-full font-semibold",children:P("pricing.current")})]})},r)})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:h?.trim()&&0===U.length?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("p",{className:"text-muted-foreground font-medium",children:P("pricing.noPlansCurrency")}),e.jsx("p",{className:"text-muted-foreground text-sm mt-2",children:P("pricing.noPlansCurrencyHint")})]}):0===$.length?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:e.jsx("p",{children:P("pricing.noPlans")})}):e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:[e.jsx("div",{className:"md:hidden overflow-auto h-full",style:{maxHeight:"calc(100vh - 13rem)"},children:e.jsx("div",{className:"p-4 space-y-4",children:$.map(r=>{const s=r._id===b,i=ce(r),l=le&&r._id===L,u=ne(r),m=ae(r),x=a(r,R),p=t.getBasePriceCents(r,R,t.BillingIntervals.Monthly)??0,h=A!==t.BillingIntervals.Monthly&&null!==u?n(p,u,A):null,j=t.getSeatPricing(r,R),v=j?t.getPerSeatPriceCents(r,R,A):null;return e.jsxs("div",{className:"rounded-xl border-2 p-4 "+(s?"border-info bg-info/5":"border-border bg-background"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-bold text-foreground",children:r.plan.name}),e.jsx(o,{planVersion:r,isCurrent:s,trialUsedAt:y,currentStripePriceId:g})]}),r.plan.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:r.plan.description})]}),s&&e.jsx("span",{className:"shrink-0 rounded-md bg-info px-2 py-0.5 text-xs font-semibold uppercase tracking-wider text-info-foreground",children:P("pricing.current")})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-baseline gap-1 whitespace-nowrap",children:e.jsx(c,{hasVariant:m,price:u,displayCurrency:x,selectedInterval:A,getIntervalLabel:D})}),null!==h&&h>0&&m&&e.jsx("span",{className:"text-xs text-success font-medium",children:P("subscription.savingsPercent",{percent:h})}),j?.enabled&&v&&v>0&&!T&&e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:P("subscription.seatPriceDisplay",{price:q(v,x),interval:D(A),included:B(j.includedSeats),includedLabel:P("pricing.included")})})]}),H.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5",children:P("subscription.items.features")}),e.jsx("div",{className:"space-y-1",children:H.map(s=>{const i=oe(r,s,A),n=s.type===t.SubscriptionItemType.Feature&&!0===i;return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.type===t.SubscriptionItemType.Feature?n?e.jsx("span",{className:"text-success text-xs",children:"✓"}):e.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"✕"}):null,e.jsx("span",{className:n?"text-foreground":"text-muted-foreground/70",children:s.name})]},s._id)})})]}),J.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5",children:P("subscription.items.limits")}),e.jsx("div",{className:"space-y-1",children:J.map(t=>{const s=oe(r,t,A);return e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t.name}),e.jsx("span",{className:"font-medium text-foreground",children:"number"==typeof s?B(s):"—"})]},t._id)})})]}),j?.enabled&&!T&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-semibold text-success uppercase tracking-wider mb-1.5",children:P("subscription.seats.title")}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:P("subscription.seats.included")}),e.jsx("span",{className:"font-medium",children:B(j.includedSeats||0)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:P("subscription.seats.maxSeats")}),e.jsx("span",{className:"font-medium",children:(j?.maxSeats??0)>0?B(j.maxSeats):P("subscription.seats.unlimited")})]}),null!=f&&f>0&&(()=>{const r=Math.max(0,f-(j.includedSeats||0));return e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:P("subscription.seats.billable")}),e.jsx("span",{className:"font-medium "+(0===r?"text-success":"text-warning"),children:0===r?P("subscription.seats.allIncluded"):`${B(r)} ${P("subscription.seats.extra")}`})]})})()]})]}),e.jsx(d,{planVersion:r}),e.jsx(t.Button,{className:"w-full mt-2",variant:i.variant,disabled:i.disabled||le||!m,progress:l,onClick:()=>ie(r._id),children:l?P("pricing.processing"):m?i.dynamicLabel??P(i.labelKey):P("pricing.unavailable")})]},r._id)})})}),e.jsx("div",{className:"hidden md:block overflow-auto h-full",style:{maxHeight:"calc(100vh - 12rem)"},children:e.jsxs("table",{"aria-label":P("subscription.choosePlan"),className:"w-full border-separate border-spacing-0",style:{minWidth:260+220*$.length+"px",borderCollapse:"separate"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:260,minWidth:260}}),$.map(r=>e.jsx("col",{style:{width:220,minWidth:220}},r._id))]}),e.jsx("thead",{children:e.jsxs("tr",{className:"align-top",children:[e.jsx("th",{className:"sticky top-0 start-0 z-30 p-0 bg-background text-start"}),$.map(r=>{const s=r._id===b,i=ce(r),l=le&&r._id===L,d=ne(r),u=t.getBasePriceCents(r,R,t.BillingIntervals.Monthly)??0,m=A!==t.BillingIntervals.Monthly&&null!==d?n(u,d,A):null,x=ae(r),p=a(r,R);return e.jsx("th",{className:"sticky top-0 z-20 border-b border-border p-3 shadow-sticky-row "+(r._id===b?"bg-info/10":"bg-background"),children:e.jsxs("div",{className:"flex h-full flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-base font-bold text-foreground truncate",children:r.plan.name}),e.jsx(o,{planVersion:r,isCurrent:s,trialUsedAt:y,currentStripePriceId:g})]}),s&&e.jsx("span",{className:"shrink-0 rounded-md bg-info px-2 py-0.5 text-xs font-semibold uppercase tracking-wider text-info-foreground",children:P("pricing.current")})]}),e.jsxs("div",{className:"flex flex-col items-start min-h-[3rem]",children:[e.jsxs("div",{className:"flex items-baseline gap-1 flex-wrap",children:[e.jsx(c,{hasVariant:x,price:d,displayCurrency:p,selectedInterval:A,getIntervalLabel:D}),null!==m&&m>0&&x&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-success/15 text-success rounded-full font-semibold whitespace-nowrap",children:P("subscription.savingsPercent",{percent:m})})]}),(()=>{if(T)return null;const s=t.getSeatPricing(r,R);if(!s)return null;const i=t.getPerSeatPriceCents(r,R,A);return!i||i<=0?null:e.jsx("div",{className:"text-xs text-muted-foreground mt-1.5 border-t border-border/60 pt-1 leading-tight",children:e.jsx("div",{children:P("subscription.seatPriceDisplay",{price:q(i,p),interval:D(A),included:B(s.includedSeats),includedLabel:P("pricing.included")})})})})()]}),r.plan.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed text-start",children:r.plan.description}),e.jsx(t.Button,{className:"mt-auto w-full",variant:i.variant,disabled:i.disabled||le||!x,progress:l,onClick:()=>ie(r._id),children:l?P("pricing.processing"):x?i.dynamicLabel??P(i.labelKey):P("pricing.unavailable")})]})},r._id)})]})}),e.jsxs("tbody",{children:[H.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:P("subscription.items.features")}),e.jsx("td",{colSpan:$.length,className:"border-t border-border bg-muted"})]}),H.map(r=>e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:r.name}),r.description&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:r.description})]}),$.map(s=>{const i=oe(s,r,A),n=a(s,R),l=ue(i,r,n),d=r.type===t.SubscriptionItemType.Feature&&!0===i;return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(s._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium "+(d?"text-success":"—"===l?"text-muted-foreground/70":"text-foreground"),children:l})},s._id)})]},r._id))]}),J.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:P("subscription.items.limits")}),e.jsx("td",{colSpan:$.length,className:"border-t border-border bg-muted"})]}),J.map(r=>e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:r.name}),r.description&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:r.description})]}),$.map(t=>{const s=oe(t,r,A),i=a(t,R),n=ue(s,r,i);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(t._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium "+("—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},t._id)})]},r._id))]}),X.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:P("subscription.items.quotas")}),e.jsx("td",{colSpan:$.length,className:"border-t border-border bg-muted"})]}),X.map(r=>e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:r.name}),r.description&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:r.description})]}),$.map(t=>{const s=oe(t,r,A),i=a(t,R),n=ue(s,r,i);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(t._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium "+("—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},t._id)})]},r._id))]}),!T&&$.some(e=>{const r=t.getSeatPricing(e,R);return r?.enabled})&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-success/20 bg-success/10 px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-success shadow-sticky-col",children:P("subscription.seats.title")}),e.jsx("td",{colSpan:$.length,className:"border-t border-success/20 bg-success/10"})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.seats.includedSeats")}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:P("subscription.seats.freeWithBase")})]}),$.map(r=>{const s=t.getSeatPricing(r,R);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:s?.enabled?B(s.includedSeats||0):"—"})},r._id)})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.seats.maxSeats")})}),$.map(r=>{const s=t.getSeatPricing(r,R);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:s?.enabled?(s?.maxSeats??0)>0?B(s.maxSeats):P("subscription.seats.unlimited"):"—"})},r._id)})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.seats.perExtraSeat")})}),$.map(r=>{const s=t.getPerSeatPriceCents(r,R,A),i=a(r,R);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:s&&s>0?`${q(s,i)}${D(A)}`:"—"})},r._id)})]}),null!=f&&f>0&&e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.seats.billable")}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:P("subscription.membersInWorkspace",{count:f})})]}),$.map(r=>{const s=t.getSeatPricing(r,R);if(!s?.enabled)return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm text-muted-foreground/70",children:"—"})},r._id);const i=s.includedSeats||0,n=Math.max(0,f-i);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:0===n?e.jsx("span",{className:"text-sm font-medium text-success",children:P("subscription.seats.allIncluded")}):e.jsxs("span",{className:"text-sm font-medium text-warning",children:[B(n)," ",P("subscription.seats.extra")]})},r._id)})]})]}),$.some(e=>e.creditGrant?.enabled&&"object"==typeof e.creditGrant.creditPackage&&null!==e.creditGrant.creditPackage)&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-info/20 bg-info/10 px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-info shadow-sticky-col",children:P("subscription.items.credits")}),e.jsx("td",{colSpan:$.length,className:"border-t border-info/20 bg-info/10"})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:e.jsx("div",{className:"font-medium text-sm text-foreground",children:$.every(e=>!e.creditGrant?.enabled||!e.creditGrant.renewOnPeriod)?P("subscription.items.creditsOneTime"):P("subscription.items.creditsPerMonth")})}),$.map(r=>{const t=r.creditGrant,s=t?.enabled&&"object"==typeof t.creditPackage&&null!==t.creditPackage?t.creditPackage:null;return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:s?e.jsx("span",{className:"text-sm font-semibold text-info",children:B(s.creditAmount)}):e.jsx("span",{className:"text-sm text-muted-foreground/70",children:"—"})},r._id)})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.items.creditRenewal")})}),$.map(r=>{const t=r.creditGrant;return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:t?.enabled?e.jsx("span",{className:"text-sm font-medium text-foreground",children:P(l(t))}):e.jsx("span",{className:"text-sm text-muted-foreground/70",children:"—"})},r._id)})]})]})]})]})})]})})]})})};
2
+ "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("./react-DSRfaDnZ.cjs"),s=require("./SettingsDialog-_kfJ6j25.cjs");require("clsx"),require("tailwind-merge"),require("intl-messageformat"),require("@hookform/resolvers/zod"),require("react-hook-form"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("lucide-react"),require("@radix-ui/react-label"),require("zod"),require("@radix-ui/react-avatar"),require("@radix-ui/react-dialog"),require("@radix-ui/react-icons"),require("@radix-ui/react-radio-group"),require("@radix-ui/react-scroll-area"),require("@radix-ui/react-separator"),require("@radix-ui/react-accordion"),require("@radix-ui/react-alert-dialog"),require("@radix-ui/react-switch"),require("cmdk"),require("@radix-ui/react-popover"),require("@radix-ui/react-select");const i={[t.BillingIntervals.Monthly]:"subscription.billingInterval.perMonth",[t.BillingIntervals.Quarterly]:"subscription.billingInterval.perQuarter",[t.BillingIntervals.Yearly]:"subscription.billingInterval.perYear"},n=(e,r,s)=>{if(!e||0===e)return null;let i;switch(s){case t.BillingIntervals.Yearly:i=r/12;break;case t.BillingIntervals.Quarterly:i=r/3;break;default:return null}const n=(e-i)/e*100;return n>0?Math.round(n):null},a=(e,r)=>t.getPricingVariant(e,r)?r:e.plan?.currency??r??"",l=e=>e.renewOnPeriod?"reset"===e.mode?"subscription.items.creditModeReset":"subscription.items.creditModeTopup":"subscription.items.creditModeLifetime",d=({planVersion:r})=>{const{t:s,fmtNum:i}=t.useTranslation(),n=r.creditGrant;return n?.enabled&&"object"==typeof n.creditPackage&&null!==n.creditPackage?e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-semibold text-info uppercase tracking-wider mb-1.5",children:s("subscription.items.credits")}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:n.renewOnPeriod?s("subscription.items.creditsPerMonth"):s("subscription.items.creditsOneTime")}),e.jsx("span",{className:"font-semibold text-info",children:i(n.creditPackage.creditAmount)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:s("subscription.items.creditRenewal")}),e.jsx("span",{className:"font-medium text-foreground",children:s(l(n))})]})]})]}):null},c=({hasVariant:r,price:s,displayCurrency:i,selectedInterval:n,getIntervalLabel:a})=>{const{t:l,fmtCents:d}=t.useTranslation();return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xl font-bold text-foreground",children:r&&null!==s?(c=s,o=i,(null==c||0===c?"":d(c,o))||l("pricing.free")):"—"}),null!==s&&s>0&&r&&e.jsx("span",{className:"text-sm text-muted-foreground",children:a(n)})]});var c,o},o=({planVersion:r,isCurrent:s,trialUsedAt:i,currentStripePriceId:n})=>{const{t:a}=t.useTranslation(),l=r.trial;return l?.enabled&&l.durationDays>0&&!s&&!i&&!n?e.jsx("span",{className:"shrink-0 rounded-md bg-success/15 text-success px-2 py-0.5 text-xs font-semibold uppercase tracking-wider",children:a("subscription.trialBadge",{days:l.durationDays})}):null};exports.default=({open:u,onOpenChange:m,source:x,planVersions:p,currentPlanVersionId:b,currentStripePriceId:g,billingCurrency:h,currentMemberCount:f,trialUsedAt:y,workspaceName:j,initialInterval:v,initialCurrency:N,onSelectPlan:k,loading:w=!1})=>{const[I,_]=r.useState(!1),{t:P,formattingLocale:S,dir:C,fmtNum:B,fmtCents:q}=t.useTranslation(),{settings:M}=t.useSaaSSettings(),T=M?.workspace?.mode===s.WorkspaceModes.Personal,D=e=>P(i[e]??i[t.BillingIntervals.Monthly]),[L,F]=r.useState(null),z=r.useRef(!1),V=r.useMemo(()=>t.getBillingIntervalAndCurrencyFromPriceId(g,p),[g,p]),K=V?.interval??null,Q=V?.currency??null,O=r.useMemo(()=>t.getAvailableCurrenciesFromPlans(p),[p]),U=r.useMemo(()=>{const e=h?.trim().toLowerCase();return e?O.includes(e)?[e]:[]:O},[h,O]),[A,W]=r.useState(v||K||t.BillingIntervals.Monthly),[G,Y]=r.useState(()=>N&&U.includes(N)?N:Q&&U.includes(Q)?Q:U.length>0?U[0]:""),R=h?.trim()||G;r.useEffect(()=>{if(u){W(v||K||t.BillingIntervals.Monthly);const e=N||Q;e&&U.includes(e)?Y(e):U.length>0&&!U.includes(G)&&Y(U[0])}},[u,v,N,K,Q,U]);const $=p,E=r.useMemo(()=>(e=>{const r=new Map;return e.forEach(e=>{e.subscriptionItems?.forEach(e=>{r.has(e._id)||r.set(e._id,e)})}),Array.from(r.values())})($),[$]),H=E.filter(e=>e.type===t.SubscriptionItemType.Feature),J=E.filter(e=>e.type===t.SubscriptionItemType.Limit),X=E.filter(e=>e.type===t.SubscriptionItemType.Quota),{emit:Z,ready:ee}=t.useFunnel(),re=r.useRef(!1),te=r.useRef(!1);r.useEffect(()=>{if(!u)return re.current&&!te.current&&Z("plan_picker_dismissed",{source:x,billing_interval:A}),re.current=!1,void(te.current=!1);!re.current&&ee&&(re.current=!0,Z("plan_picker_opened",{source:x,plan_count:p.length,has_subscription:!!b,current_plan_version_id:b,billing_interval:A,currency:R?R.toUpperCase():void 0}))},[u,ee]);const se=e=>{if(!b)return"new";if(e._id===b)return"interval_change";const r=p.find(e=>e._id===b),s=r?t.getBasePriceCents(r,R,A):null,i=t.getBasePriceCents(e,R,A);return null==s||null==i?"change":i>=s?"upgrade":"downgrade"},ie=async e=>{if(e===b&&K===A||w||I||z.current)return;const r=p.find(r=>r._id===e);if(r){const s=t.getBasePriceCents(r,R,A);te.current=!0,Z("plan_selected",{source:x,plan_version_id:e,plan_slug:r.plan?.slug,billing_interval:A,currency:R?R.toUpperCase():void 0,value:null==s?void 0:t.toMajorUnits(s,R),change:se(r),is_free:!!r.plan?.isFreemium})}z.current=!0,_(!0),F(e);try{await k(e,A,R),m(!1)}catch(e){}finally{z.current=!1,_(!1),F(null)}},ne=e=>t.getBasePriceCents(e,R,A),ae=e=>!!e.pricingVariants?.some(e=>e.currency?.toLowerCase()===R.toLowerCase()),le=w||I,de=e=>{switch(e){case t.BillingIntervals.Monthly:return P("subscription.billingInterval.monthly");case t.BillingIntervals.Quarterly:return P("subscription.billingInterval.quarterly");case t.BillingIntervals.Yearly:return P("subscription.billingInterval.yearly");default:return P("subscription.billingInterval.monthly")}},ce=e=>{const r=e._id===b,t=K===A;if(r&&t)return{labelKey:"subscription.currentPlan",variant:"outline",disabled:!0};if(r&&!t)return e.plan?.isFreemium?{labelKey:"subscription.currentPlan",variant:"outline",disabled:!0}:{labelKey:"_dynamic",dynamicLabel:P("subscription.switchToInterval",{interval:de(A)}),variant:"default",disabled:!1};const s=e.trial?.enabled&&e.trial.durationDays>0&&!y&&!g;if(!b)return s?{labelKey:"_dynamic",dynamicLabel:P("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.subscribe",variant:"default",disabled:!1};const i=$.findIndex(e=>e._id===b),n=$.findIndex(r=>r._id===e._id);return-1===i||-1===n?s?{labelKey:"_dynamic",dynamicLabel:P("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.checkout.select",variant:"default",disabled:!1}:n<i?{labelKey:"subscription.checkout.downgrade",variant:"outline",disabled:!1}:n>i?s?{labelKey:"_dynamic",dynamicLabel:P("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.checkout.upgrade",variant:"default",disabled:!1}:{labelKey:"subscription.checkout.select",variant:"default",disabled:!1}},oe=(e,r,s=t.BillingIntervals.Monthly)=>{if(r.type===t.SubscriptionItemType.Feature)return e.features?.[r.slug]??!1;if(r.type===t.SubscriptionItemType.Limit)return e.limits?.[r.slug]??null;if(r.type===t.SubscriptionItemType.Quota){const i=t.getQuotaDisplayWithVariant(e,R,r.slug,s);return i||t.getQuotaDisplayValue(e.quotas?.[r.slug],s)}return null},ue=(e,r,s)=>{if(r.type===t.SubscriptionItemType.Feature)return!0===e?"✓":"—";if(r.type===t.SubscriptionItemType.Limit)return null!=e&&"number"==typeof e?B(e):"—";if(r.type===t.SubscriptionItemType.Quota){const i="object"==typeof e&&null!==e&&"included"in e?e:null,n=t.getQuotaDisplayParts(i,r.name.toLowerCase(),{currency:s,locale:S});return n?n.allowOverage?n.hasOverage?P("quota.includedWithOverage",{count:n.included,price:n.price,unit:n.unit}):P("quota.includedOnly",{count:n.included}):P("quota.includedHardLimit",{count:n.included}):"—"}return"—"};return e.jsx(t.Dialog,{open:u,onOpenChange:m,children:e.jsxs(t.DialogContent,{dir:C,className:"inset-0 w-screen h-screen max-w-none rounded-none translate-x-0 translate-y-0 p-0 flex flex-col",children:[e.jsxs("div",{className:"flex-shrink-0 px-4 py-4 sm:px-6 sm:py-6 border-b space-y-3 sm:space-y-4",children:[e.jsxs("div",{children:[e.jsx(t.DialogTitle,{className:"text-xl font-semibold",children:P("pricing.title")}),e.jsxs(t.DialogDescription,{className:"mt-1 text-sm",children:[P("subscription.choosePlanDescription"),j&&e.jsx("span",{className:"ml-1 font-medium text-foreground",children:P("subscription.forWorkspace",{name:j})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[!h?.trim()&&U.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:P("pricing.currency")}),e.jsx("select",{"aria-label":P("pricing.selectCurrency"),value:G,onChange:e=>Y(e.target.value),className:"rounded-md border border-border bg-background px-3 py-2 text-sm font-medium text-foreground shadow-sm focus:outline-none focus:ring-2 focus:ring-primary",children:U.map(r=>{const s=t.getCurrencyFlag(r);return e.jsx("option",{value:r,children:s?`${s} ${r.toUpperCase()}`:r.toUpperCase()},r)})})]}),h?.trim()&&e.jsx("span",{className:"text-xs text-muted-foreground",children:P("subscription.billingInCurrency",{currency:h.toUpperCase()})})]}),e.jsx("div",{className:"flex items-center gap-0.5 sm:gap-1 p-1 bg-muted rounded-lg w-full sm:w-auto",role:"group","aria-label":P("pricing.billingInterval"),children:[t.BillingIntervals.Monthly,t.BillingIntervals.Quarterly,t.BillingIntervals.Yearly].map(r=>{const s=K===r;return e.jsx("button",{onClick:()=>(e=>{e!==A&&Z("billing_interval_changed",{from:A,to:e}),W(e)})(r),"aria-pressed":A===r,className:"flex-1 sm:flex-initial px-3 sm:px-4 py-2 text-sm font-medium rounded-md transition-all relative "+(A===r?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:e.jsxs("span",{className:"flex items-center justify-center gap-1 sm:gap-1.5",children:[r===t.BillingIntervals.Monthly&&P("subscription.billingInterval.monthly"),r===t.BillingIntervals.Quarterly&&P("subscription.billingInterval.quarterly"),r===t.BillingIntervals.Yearly&&P("subscription.billingInterval.yearly"),r===t.BillingIntervals.Yearly&&e.jsx("span",{className:"text-xs px-1 sm:px-1.5 py-0.5 bg-success/15 text-success rounded-full font-semibold",children:P("pricing.save")}),s&&b&&e.jsx("span",{className:"hidden sm:inline text-xs px-1.5 py-0.5 bg-info/15 text-info rounded-full font-semibold",children:P("pricing.current")})]})},r)})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:h?.trim()&&0===U.length?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("p",{className:"text-muted-foreground font-medium",children:P("pricing.noPlansCurrency")}),e.jsx("p",{className:"text-muted-foreground text-sm mt-2",children:P("pricing.noPlansCurrencyHint")})]}):0===$.length?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:e.jsx("p",{children:P("pricing.noPlans")})}):e.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:[e.jsx("div",{className:"md:hidden overflow-auto h-full",style:{maxHeight:"calc(100vh - 13rem)"},children:e.jsx("div",{className:"p-4 space-y-4",children:$.map(r=>{const s=r._id===b,i=ce(r),l=le&&r._id===L,u=ne(r),m=ae(r),x=a(r,R),p=t.getBasePriceCents(r,R,t.BillingIntervals.Monthly)??0,h=A!==t.BillingIntervals.Monthly&&null!==u?n(p,u,A):null,j=t.getSeatPricing(r,R),v=j?t.getPerSeatPriceCents(r,R,A):null;return e.jsxs("div",{className:"rounded-xl border-2 p-4 "+(s?"border-info bg-info/5":"border-border bg-background"),children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-bold text-foreground",children:r.plan.name}),e.jsx(o,{planVersion:r,isCurrent:s,trialUsedAt:y,currentStripePriceId:g})]}),r.plan.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:r.plan.description})]}),s&&e.jsx("span",{className:"shrink-0 rounded-md bg-info px-2 py-0.5 text-xs font-semibold uppercase tracking-wider text-info-foreground",children:P("pricing.current")})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-baseline gap-1 whitespace-nowrap",children:e.jsx(c,{hasVariant:m,price:u,displayCurrency:x,selectedInterval:A,getIntervalLabel:D})}),null!==h&&h>0&&m&&e.jsx("span",{className:"text-xs text-success font-medium",children:P("subscription.savingsPercent",{percent:h})}),j?.enabled&&v&&v>0&&!T&&e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:P("subscription.seatPriceDisplay",{price:q(v,x),interval:D(A),included:B(j.includedSeats),includedLabel:P("pricing.included")})})]}),H.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5",children:P("subscription.items.features")}),e.jsx("div",{className:"space-y-1",children:H.map(s=>{const i=oe(r,s,A),n=s.type===t.SubscriptionItemType.Feature&&!0===i;return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.type===t.SubscriptionItemType.Feature?n?e.jsx("span",{className:"text-success text-xs",children:"✓"}):e.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"✕"}):null,e.jsx("span",{className:n?"text-foreground":"text-muted-foreground/70",children:s.name})]},s._id)})})]}),J.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5",children:P("subscription.items.limits")}),e.jsx("div",{className:"space-y-1",children:J.map(t=>{const s=oe(r,t,A);return e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t.name}),e.jsx("span",{className:"font-medium text-foreground",children:"number"==typeof s?B(s):"—"})]},t._id)})})]}),j?.enabled&&!T&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-semibold text-success uppercase tracking-wider mb-1.5",children:P("subscription.seats.title")}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:P("subscription.seats.included")}),e.jsx("span",{className:"font-medium",children:B(j.includedSeats||0)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:P("subscription.seats.maxSeats")}),e.jsx("span",{className:"font-medium",children:(j?.maxSeats??0)>0?B(j.maxSeats):P("subscription.seats.unlimited")})]}),null!=f&&f>0&&(()=>{const r=Math.max(0,f-(j.includedSeats||0));return e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:P("subscription.seats.billable")}),e.jsx("span",{className:"font-medium "+(0===r?"text-success":"text-warning"),children:0===r?P("subscription.seats.allIncluded"):`${B(r)} ${P("subscription.seats.extra")}`})]})})()]})]}),e.jsx(d,{planVersion:r}),e.jsx(t.Button,{className:"w-full mt-2",variant:i.variant,disabled:i.disabled||le||!m,progress:l,onClick:()=>ie(r._id),children:l?P("pricing.processing"):m?i.dynamicLabel??P(i.labelKey):P("pricing.unavailable")})]},r._id)})})}),e.jsx("div",{className:"hidden md:block overflow-auto h-full",style:{maxHeight:"calc(100vh - 12rem)"},children:e.jsxs("table",{"aria-label":P("subscription.choosePlan"),className:"w-full border-separate border-spacing-0",style:{minWidth:260+220*$.length+"px",borderCollapse:"separate"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:260,minWidth:260}}),$.map(r=>e.jsx("col",{style:{width:220,minWidth:220}},r._id))]}),e.jsx("thead",{children:e.jsxs("tr",{className:"align-top",children:[e.jsx("th",{className:"sticky top-0 start-0 z-30 p-0 bg-background text-start"}),$.map(r=>{const s=r._id===b,i=ce(r),l=le&&r._id===L,d=ne(r),u=t.getBasePriceCents(r,R,t.BillingIntervals.Monthly)??0,m=A!==t.BillingIntervals.Monthly&&null!==d?n(u,d,A):null,x=ae(r),p=a(r,R);return e.jsx("th",{className:"sticky top-0 z-20 border-b border-border p-3 shadow-sticky-row "+(r._id===b?"bg-info/10":"bg-background"),children:e.jsxs("div",{className:"flex h-full flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-base font-bold text-foreground truncate",children:r.plan.name}),e.jsx(o,{planVersion:r,isCurrent:s,trialUsedAt:y,currentStripePriceId:g})]}),s&&e.jsx("span",{className:"shrink-0 rounded-md bg-info px-2 py-0.5 text-xs font-semibold uppercase tracking-wider text-info-foreground",children:P("pricing.current")})]}),e.jsxs("div",{className:"flex flex-col items-start min-h-[3rem]",children:[e.jsxs("div",{className:"flex items-baseline gap-1 flex-wrap",children:[e.jsx(c,{hasVariant:x,price:d,displayCurrency:p,selectedInterval:A,getIntervalLabel:D}),null!==m&&m>0&&x&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-success/15 text-success rounded-full font-semibold whitespace-nowrap",children:P("subscription.savingsPercent",{percent:m})})]}),(()=>{if(T)return null;const s=t.getSeatPricing(r,R);if(!s)return null;const i=t.getPerSeatPriceCents(r,R,A);return!i||i<=0?null:e.jsx("div",{className:"text-xs text-muted-foreground mt-1.5 border-t border-border/60 pt-1 leading-tight",children:e.jsx("div",{children:P("subscription.seatPriceDisplay",{price:q(i,p),interval:D(A),included:B(s.includedSeats),includedLabel:P("pricing.included")})})})})()]}),r.plan.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed text-start",children:r.plan.description}),e.jsx(t.Button,{className:"mt-auto w-full",variant:i.variant,disabled:i.disabled||le||!x,progress:l,onClick:()=>ie(r._id),children:l?P("pricing.processing"):x?i.dynamicLabel??P(i.labelKey):P("pricing.unavailable")})]})},r._id)})]})}),e.jsxs("tbody",{children:[H.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:P("subscription.items.features")}),e.jsx("td",{colSpan:$.length,className:"border-t border-border bg-muted"})]}),H.map(r=>e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:r.name}),r.description&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:r.description})]}),$.map(s=>{const i=oe(s,r,A),n=a(s,R),l=ue(i,r,n),d=r.type===t.SubscriptionItemType.Feature&&!0===i;return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(s._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium "+(d?"text-success":"—"===l?"text-muted-foreground/70":"text-foreground"),children:l})},s._id)})]},r._id))]}),J.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:P("subscription.items.limits")}),e.jsx("td",{colSpan:$.length,className:"border-t border-border bg-muted"})]}),J.map(r=>e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:r.name}),r.description&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:r.description})]}),$.map(t=>{const s=oe(t,r,A),i=a(t,R),n=ue(s,r,i);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(t._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium "+("—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},t._id)})]},r._id))]}),X.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:P("subscription.items.quotas")}),e.jsx("td",{colSpan:$.length,className:"border-t border-border bg-muted"})]}),X.map(r=>e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:r.name}),r.description&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:r.description})]}),$.map(t=>{const s=oe(t,r,A),i=a(t,R),n=ue(s,r,i);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(t._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium "+("—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},t._id)})]},r._id))]}),!T&&$.some(e=>{const r=t.getSeatPricing(e,R);return r?.enabled})&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-success/20 bg-success/10 px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-success shadow-sticky-col",children:P("subscription.seats.title")}),e.jsx("td",{colSpan:$.length,className:"border-t border-success/20 bg-success/10"})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.seats.includedSeats")}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:P("subscription.seats.freeWithBase")})]}),$.map(r=>{const s=t.getSeatPricing(r,R);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:s?.enabled?B(s.includedSeats||0):"—"})},r._id)})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.seats.maxSeats")})}),$.map(r=>{const s=t.getSeatPricing(r,R);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:s?.enabled?(s?.maxSeats??0)>0?B(s.maxSeats):P("subscription.seats.unlimited"):"—"})},r._id)})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.seats.perExtraSeat")})}),$.map(r=>{const s=t.getPerSeatPriceCents(r,R,A),i=a(r,R);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:s&&s>0?`${q(s,i)}${D(A)}`:"—"})},r._id)})]}),null!=f&&f>0&&e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsxs("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.seats.billable")}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:P("subscription.membersInWorkspace",{count:f})})]}),$.map(r=>{const s=t.getSeatPricing(r,R);if(!s?.enabled)return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:e.jsx("span",{className:"text-sm text-muted-foreground/70",children:"—"})},r._id);const i=s.includedSeats||0,n=Math.max(0,f-i);return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:0===n?e.jsx("span",{className:"text-sm font-medium text-success",children:P("subscription.seats.allIncluded")}):e.jsxs("span",{className:"text-sm font-medium text-warning",children:[B(n)," ",P("subscription.seats.extra")]})},r._id)})]})]}),$.some(e=>e.creditGrant?.enabled&&"object"==typeof e.creditGrant.creditPackage&&null!==e.creditGrant.creditPackage)&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-info/20 bg-info/10 px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-info shadow-sticky-col",children:P("subscription.items.credits")}),e.jsx("td",{colSpan:$.length,className:"border-t border-info/20 bg-info/10"})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:e.jsx("div",{className:"font-medium text-sm text-foreground",children:$.every(e=>!e.creditGrant?.enabled||!e.creditGrant.renewOnPeriod)?P("subscription.items.creditsOneTime"):P("subscription.items.creditsPerMonth")})}),$.map(r=>{const t=r.creditGrant,s=t?.enabled&&"object"==typeof t.creditPackage&&null!==t.creditPackage?t.creditPackage:null;return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:s?e.jsx("span",{className:"text-sm font-semibold text-info",children:B(s.creditAmount)}):e.jsx("span",{className:"text-sm text-muted-foreground/70",children:"—"})},r._id)})]}),e.jsxs("tr",{className:"group hover:bg-muted/30",children:[e.jsx("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:e.jsx("div",{className:"font-medium text-sm text-foreground",children:P("subscription.items.creditRenewal")})}),$.map(r=>{const t=r.creditGrant;return e.jsx("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(r._id===b?"bg-info/5":"bg-background"),children:t?.enabled?e.jsx("span",{className:"text-sm font-medium text-foreground",children:P(l(t))}):e.jsx("span",{className:"text-sm text-muted-foreground/70",children:"—"})},r._id)})]})]})]})]})})]})})]})})};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsxs as e,jsx as r,Fragment as t}from"react/jsx-runtime";import i,{useState as s,useMemo as n,useEffect as a}from"react";import{aP as d,ag as l,u as c,A as o,at as u,aQ as m,ah as p,as as b,D as g,a as h,b as x,c as f,a0 as y,au as N,av as v,aw as k,B as w,ai as _,aj as P,aR as C,af as I}from"./react-CHhQFy94.mjs";import{W as S}from"./SettingsDialog-D2lDYNYo.mjs";import"clsx";import"tailwind-merge";import"intl-messageformat";import"@hookform/resolvers/zod";import"react-hook-form";import"@radix-ui/react-slot";import"class-variance-authority";import"lucide-react";import"@radix-ui/react-label";import"zod";import"@radix-ui/react-avatar";import"@radix-ui/react-dialog";import"@radix-ui/react-icons";import"@radix-ui/react-radio-group";import"@radix-ui/react-scroll-area";import"@radix-ui/react-separator";import"@radix-ui/react-accordion";import"@radix-ui/react-alert-dialog";import"@radix-ui/react-switch";import"cmdk";import"@radix-ui/react-popover";import"@radix-ui/react-select";const M={[l.Monthly]:"subscription.billingInterval.perMonth",[l.Quarterly]:"subscription.billingInterval.perQuarter",[l.Yearly]:"subscription.billingInterval.perYear"},L=(e,r,t)=>{if(!e||0===e)return null;let i;switch(t){case l.Yearly:i=r/12;break;case l.Quarterly:i=r/3;break;default:return null}const s=(e-i)/e*100;return s>0?Math.round(s):null},j=(e,r)=>d(e,r)?r:e.plan?.currency??r??"",z=e=>e.renewOnPeriod?"reset"===e.mode?"subscription.items.creditModeReset":"subscription.items.creditModeTopup":"subscription.items.creditModeLifetime",D=({planVersion:t})=>{const{t:i,fmtNum:s}=c(),n=t.creditGrant;return n?.enabled&&"object"==typeof n.creditPackage&&null!==n.creditPackage?e("div",{className:"mb-3",children:[r("div",{className:"text-xs font-semibold text-info uppercase tracking-wider mb-1.5",children:i("subscription.items.credits")}),e("div",{className:"space-y-1 text-sm",children:[e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:n.renewOnPeriod?i("subscription.items.creditsPerMonth"):i("subscription.items.creditsOneTime")}),r("span",{className:"font-semibold text-info",children:s(n.creditPackage.creditAmount)})]}),e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:i("subscription.items.creditRenewal")}),r("span",{className:"font-medium text-foreground",children:i(z(n))})]})]})]}):null},K=({hasVariant:i,price:s,displayCurrency:n,selectedInterval:a,getIntervalLabel:d})=>{const{t:l,fmtCents:o}=c();return e(t,{children:[r("span",{className:"text-2xl font-bold text-foreground",children:i&&null!==s?(u=s,m=n,(null==u||0===u?"":o(u,m))||l("pricing.free")):"—"}),null!==s&&s>0&&i&&r("span",{className:"text-sm text-muted-foreground",children:d(a)})]});var u,m},O=({planVersion:e,isCurrent:t,trialUsedAt:i,currentStripePriceId:s})=>{const{t:n}=c(),a=e.trial;return a?.enabled&&a.durationDays>0&&!t&&!i&&!s?r("span",{className:"shrink-0 rounded-md bg-success/15 text-success px-2 py-0.5 text-xs font-semibold uppercase tracking-wider",children:n("subscription.trialBadge",{days:a.durationDays})}):null},V=({open:d,onOpenChange:V,source:Q,planVersions:U,currentPlanVersionId:A,currentStripePriceId:F,billingCurrency:G,currentMemberCount:W,trialUsedAt:q,workspaceName:R,initialInterval:T,initialCurrency:Y,onSelectPlan:$,loading:H=!1})=>{const[B,E]=s(!1),{t:J,formattingLocale:X,dir:Z,fmtNum:ee,fmtCents:re}=c(),{settings:te}=o(),ie=te?.workspace?.mode===S.Personal,se=e=>J(M[e]??M[l.Monthly]),[ne,ae]=s(null),de=i.useRef(!1),le=n(()=>u(F,U),[F,U]),ce=le?.interval??null,oe=le?.currency??null,ue=n(()=>m(U),[U]),me=n(()=>{const e=G?.trim().toLowerCase();return e?ue.includes(e)?[e]:[]:ue},[G,ue]),[pe,be]=s(T||ce||l.Monthly),[ge,he]=s(()=>Y&&me.includes(Y)?Y:oe&&me.includes(oe)?oe:me.length>0?me[0]:""),xe=G?.trim()||ge;a(()=>{if(d){be(T||ce||l.Monthly);const e=Y||oe;e&&me.includes(e)?he(e):me.length>0&&!me.includes(ge)&&he(me[0])}},[d,T,Y,ce,oe,me]);const fe=U,ye=n(()=>(e=>{const r=new Map;return e.forEach(e=>{e.subscriptionItems?.forEach(e=>{r.has(e._id)||r.set(e._id,e)})}),Array.from(r.values())})(fe),[fe]),Ne=ye.filter(e=>e.type===p.Feature),ve=ye.filter(e=>e.type===p.Limit),ke=ye.filter(e=>e.type===p.Quota),{emit:we,ready:_e}=b(),Pe=i.useRef(!1),Ce=i.useRef(!1);a(()=>{if(!d)return Pe.current&&!Ce.current&&we("plan_picker_dismissed",{source:Q,billing_interval:pe}),Pe.current=!1,void(Ce.current=!1);!Pe.current&&_e&&(Pe.current=!0,we("plan_picker_opened",{source:Q,plan_count:U.length,has_subscription:!!A,current_plan_version_id:A,billing_interval:pe,currency:xe?xe.toUpperCase():void 0}))},[d,_e]);const Ie=e=>{if(!A)return"new";if(e._id===A)return"interval_change";const r=U.find(e=>e._id===A),t=r?N(r,xe,pe):null,i=N(e,xe,pe);return null==t||null==i?"change":i>=t?"upgrade":"downgrade"},Se=async e=>{if(e===A&&ce===pe||H||B||de.current)return;const r=U.find(r=>r._id===e);if(r){const t=N(r,xe,pe);Ce.current=!0,we("plan_selected",{source:Q,plan_version_id:e,plan_slug:r.plan?.slug,billing_interval:pe,currency:xe?xe.toUpperCase():void 0,value:null==t?void 0:C(t,xe),change:Ie(r),is_free:!!r.plan?.isFreemium})}de.current=!0,E(!0),ae(e);try{await $(e,pe,xe),V(!1)}catch(e){}finally{de.current=!1,E(!1),ae(null)}},Me=e=>N(e,xe,pe),Le=e=>!!e.pricingVariants?.some(e=>e.currency?.toLowerCase()===xe.toLowerCase()),je=H||B,ze=e=>{switch(e){case l.Monthly:return J("subscription.billingInterval.monthly");case l.Quarterly:return J("subscription.billingInterval.quarterly");case l.Yearly:return J("subscription.billingInterval.yearly");default:return J("subscription.billingInterval.monthly")}},De=e=>{const r=e._id===A,t=ce===pe;if(r&&t)return{labelKey:"subscription.currentPlan",variant:"outline",disabled:!0};if(r&&!t)return e.plan?.isFreemium?{labelKey:"subscription.currentPlan",variant:"outline",disabled:!0}:{labelKey:"_dynamic",dynamicLabel:J("subscription.switchToInterval",{interval:ze(pe)}),variant:"default",disabled:!1};const i=e.trial?.enabled&&e.trial.durationDays>0&&!q&&!F;if(!A)return i?{labelKey:"_dynamic",dynamicLabel:J("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.subscribe",variant:"default",disabled:!1};const s=fe.findIndex(e=>e._id===A),n=fe.findIndex(r=>r._id===e._id);return-1===s||-1===n?i?{labelKey:"_dynamic",dynamicLabel:J("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.checkout.select",variant:"default",disabled:!1}:n<s?{labelKey:"subscription.checkout.downgrade",variant:"outline",disabled:!1}:n>s?i?{labelKey:"_dynamic",dynamicLabel:J("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.checkout.upgrade",variant:"default",disabled:!1}:{labelKey:"subscription.checkout.select",variant:"default",disabled:!1}},Ke=(e,r,t=l.Monthly)=>{if(r.type===p.Feature)return e.features?.[r.slug]??!1;if(r.type===p.Limit)return e.limits?.[r.slug]??null;if(r.type===p.Quota){const i=_(e,xe,r.slug,t);return i||P(e.quotas?.[r.slug],t)}return null},Oe=(e,r,t)=>{if(r.type===p.Feature)return!0===e?"✓":"—";if(r.type===p.Limit)return null!=e&&"number"==typeof e?ee(e):"—";if(r.type===p.Quota){const i=I("object"==typeof e&&null!==e&&"included"in e?e:null,r.name.toLowerCase(),{currency:t,locale:X});return i?i.allowOverage?i.hasOverage?J("quota.includedWithOverage",{count:i.included,price:i.price,unit:i.unit}):J("quota.includedOnly",{count:i.included}):J("quota.includedHardLimit",{count:i.included}):"—"}return"—"};return r(g,{open:d,onOpenChange:V,children:e(h,{dir:Z,className:"inset-0 w-screen h-screen max-w-none rounded-none translate-x-0 translate-y-0 p-0 flex flex-col",children:[e("div",{className:"flex-shrink-0 px-4 py-4 sm:px-6 sm:py-6 border-b space-y-3 sm:space-y-4",children:[e("div",{children:[r(x,{className:"text-xl font-semibold",children:J("pricing.title")}),e(f,{className:"mt-1 text-sm",children:[J("subscription.choosePlanDescription"),R&&r("span",{className:"ml-1 font-medium text-foreground",children:J("subscription.forWorkspace",{name:R})})]})]}),e("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-4",children:[e("div",{className:"flex items-center gap-2",children:[!G?.trim()&&me.length>1&&e(t,{children:[r("span",{className:"text-sm text-muted-foreground",children:J("pricing.currency")}),r("select",{"aria-label":J("pricing.selectCurrency"),value:ge,onChange:e=>he(e.target.value),className:"rounded-md border border-border bg-background px-3 py-2 text-sm font-medium text-foreground shadow-sm focus:outline-none focus:ring-2 focus:ring-primary",children:me.map(e=>{const t=y(e);return r("option",{value:e,children:t?`${t} ${e.toUpperCase()}`:e.toUpperCase()},e)})})]}),G?.trim()&&r("span",{className:"text-xs text-muted-foreground",children:J("subscription.billingInCurrency",{currency:G.toUpperCase()})})]}),r("div",{className:"flex items-center gap-0.5 sm:gap-1 p-1 bg-muted rounded-lg w-full sm:w-auto",role:"group","aria-label":J("pricing.billingInterval"),children:[l.Monthly,l.Quarterly,l.Yearly].map(t=>{const i=ce===t;return r("button",{onClick:()=>(e=>{e!==pe&&we("billing_interval_changed",{from:pe,to:e}),be(e)})(t),"aria-pressed":pe===t,className:"flex-1 sm:flex-initial px-3 sm:px-4 py-2 text-sm font-medium rounded-md transition-all relative "+(pe===t?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:e("span",{className:"flex items-center justify-center gap-1 sm:gap-1.5",children:[t===l.Monthly&&J("subscription.billingInterval.monthly"),t===l.Quarterly&&J("subscription.billingInterval.quarterly"),t===l.Yearly&&J("subscription.billingInterval.yearly"),t===l.Yearly&&r("span",{className:"text-xs px-1 sm:px-1.5 py-0.5 bg-success/15 text-success rounded-full font-semibold",children:J("pricing.save")}),i&&A&&r("span",{className:"hidden sm:inline text-xs px-1.5 py-0.5 bg-info/15 text-info rounded-full font-semibold",children:J("pricing.current")})]})},t)})})]})]}),r("div",{className:"flex-1 min-h-0 flex flex-col",children:G?.trim()&&0===me.length?e("div",{className:"text-center py-12 px-4",children:[r("p",{className:"text-muted-foreground font-medium",children:J("pricing.noPlansCurrency")}),r("p",{className:"text-muted-foreground text-sm mt-2",children:J("pricing.noPlansCurrencyHint")})]}):0===fe.length?r("div",{className:"text-center py-12 text-muted-foreground",children:r("p",{children:J("pricing.noPlans")})}):e("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:[r("div",{className:"md:hidden overflow-auto h-full",style:{maxHeight:"calc(100vh - 13rem)"},children:r("div",{className:"p-4 space-y-4",children:fe.map(t=>{const i=t._id===A,s=De(t),n=je&&t._id===ne,a=Me(t),d=Le(t),c=j(t,xe),o=N(t,xe,l.Monthly)??0,u=pe!==l.Monthly&&null!==a?L(o,a,pe):null,m=v(t,xe),b=m?k(t,xe,pe):null;return e("div",{className:"rounded-xl border-2 p-4 "+(i?"border-info bg-info/5":"border-border bg-background"),children:[e("div",{className:"flex items-start justify-between mb-3",children:[e("div",{children:[e("div",{className:"flex items-center gap-2",children:[r("h3",{className:"text-lg font-bold text-foreground",children:t.plan.name}),r(O,{planVersion:t,isCurrent:i,trialUsedAt:q,currentStripePriceId:F})]}),t.plan.description&&r("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:t.plan.description})]}),i&&r("span",{className:"shrink-0 rounded-md bg-info px-2 py-0.5 text-xs font-semibold uppercase tracking-wider text-info-foreground",children:J("pricing.current")})]}),e("div",{className:"mb-4",children:[r("div",{className:"flex items-baseline gap-1 whitespace-nowrap",children:r(K,{hasVariant:d,price:a,displayCurrency:c,selectedInterval:pe,getIntervalLabel:se})}),null!==u&&u>0&&d&&r("span",{className:"text-xs text-success font-medium",children:J("subscription.savingsPercent",{percent:u})}),m?.enabled&&b&&b>0&&!ie&&r("div",{className:"text-xs text-muted-foreground mt-1",children:J("subscription.seatPriceDisplay",{price:re(b,c),interval:se(pe),included:ee(m.includedSeats),includedLabel:J("pricing.included")})})]}),Ne.length>0&&e("div",{className:"mb-3",children:[r("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5",children:J("subscription.items.features")}),r("div",{className:"space-y-1",children:Ne.map(i=>{const s=Ke(t,i,pe),n=i.type===p.Feature&&!0===s;return e("div",{className:"flex items-center gap-2 text-sm",children:[i.type===p.Feature?r("span",n?{className:"text-success text-xs",children:"✓"}:{className:"text-muted-foreground/50 text-xs",children:"✕"}):null,r("span",{className:n?"text-foreground":"text-muted-foreground/70",children:i.name})]},i._id)})})]}),ve.length>0&&e("div",{className:"mb-3",children:[r("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5",children:J("subscription.items.limits")}),r("div",{className:"space-y-1",children:ve.map(i=>{const s=Ke(t,i,pe);return e("div",{className:"flex items-center justify-between text-sm",children:[r("span",{className:"text-muted-foreground",children:i.name}),r("span",{className:"font-medium text-foreground",children:"number"==typeof s?ee(s):"—"})]},i._id)})})]}),m?.enabled&&!ie&&e("div",{className:"mb-3",children:[r("div",{className:"text-xs font-semibold text-success uppercase tracking-wider mb-1.5",children:J("subscription.seats.title")}),e("div",{className:"space-y-1 text-sm",children:[e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:J("subscription.seats.included")}),r("span",{className:"font-medium",children:ee(m.includedSeats||0)})]}),e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:J("subscription.seats.maxSeats")}),r("span",{className:"font-medium",children:(m?.maxSeats??0)>0?ee(m.maxSeats):J("subscription.seats.unlimited")})]}),null!=W&&W>0&&(()=>{const t=Math.max(0,W-(m.includedSeats||0));return e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:J("subscription.seats.billable")}),r("span",{className:"font-medium "+(0===t?"text-success":"text-warning"),children:0===t?J("subscription.seats.allIncluded"):`${ee(t)} ${J("subscription.seats.extra")}`})]})})()]})]}),r(D,{planVersion:t}),r(w,{className:"w-full mt-2",variant:s.variant,disabled:s.disabled||je||!d,progress:n,onClick:()=>Se(t._id),children:n?J("pricing.processing"):d?s.dynamicLabel??J(s.labelKey):J("pricing.unavailable")})]},t._id)})})}),r("div",{className:"hidden md:block overflow-auto h-full",style:{maxHeight:"calc(100vh - 12rem)"},children:e("table",{"aria-label":J("subscription.choosePlan"),className:"w-full border-separate border-spacing-0",style:{minWidth:260+220*fe.length+"px",borderCollapse:"separate"},children:[e("colgroup",{children:[r("col",{style:{width:260,minWidth:260}}),fe.map(e=>r("col",{style:{width:220,minWidth:220}},e._id))]}),r("thead",{children:e("tr",{className:"align-top",children:[r("th",{className:"sticky top-0 start-0 z-30 p-0 bg-background text-start"}),fe.map(t=>{const i=t._id===A,s=De(t),n=je&&t._id===ne,a=Me(t),d=N(t,xe,l.Monthly)??0,c=pe!==l.Monthly&&null!==a?L(d,a,pe):null,o=Le(t),u=j(t,xe);return r("th",{className:"sticky top-0 z-20 border-b border-border p-3 shadow-sticky-row "+(t._id===A?"bg-info/10":"bg-background"),children:e("div",{className:"flex h-full flex-col gap-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[r("h3",{className:"text-base font-bold text-foreground truncate",children:t.plan.name}),r(O,{planVersion:t,isCurrent:i,trialUsedAt:q,currentStripePriceId:F})]}),i&&r("span",{className:"shrink-0 rounded-md bg-info px-2 py-0.5 text-xs font-semibold uppercase tracking-wider text-info-foreground",children:J("pricing.current")})]}),e("div",{className:"flex flex-col items-start min-h-[3rem]",children:[e("div",{className:"flex items-baseline gap-1 flex-wrap",children:[r(K,{hasVariant:o,price:a,displayCurrency:u,selectedInterval:pe,getIntervalLabel:se}),null!==c&&c>0&&o&&r("span",{className:"text-xs px-1.5 py-0.5 bg-success/15 text-success rounded-full font-semibold whitespace-nowrap",children:J("subscription.savingsPercent",{percent:c})})]}),(()=>{if(ie)return null;const e=v(t,xe);if(!e)return null;const i=k(t,xe,pe);return!i||i<=0?null:r("div",{className:"text-xs text-muted-foreground mt-1.5 border-t border-border/60 pt-1 leading-tight",children:r("div",{children:J("subscription.seatPriceDisplay",{price:re(i,u),interval:se(pe),included:ee(e.includedSeats),includedLabel:J("pricing.included")})})})})()]}),t.plan.description&&r("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed text-start",children:t.plan.description}),r(w,{className:"mt-auto w-full",variant:s.variant,disabled:s.disabled||je||!o,progress:n,onClick:()=>Se(t._id),children:n?J("pricing.processing"):o?s.dynamicLabel??J(s.labelKey):J("pricing.unavailable")})]})},t._id)})]})}),e("tbody",{children:[Ne.length>0&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:J("subscription.items.features")}),r("td",{colSpan:fe.length,className:"border-t border-border bg-muted"})]}),Ne.map(t=>e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:t.name}),t.description&&r("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),fe.map(e=>{const i=Ke(e,t,pe),s=j(e,xe),n=Oe(i,t,s),a=t.type===p.Feature&&!0===i;return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium "+(a?"text-success":"—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},e._id)})]},t._id))]}),ve.length>0&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:J("subscription.items.limits")}),r("td",{colSpan:fe.length,className:"border-t border-border bg-muted"})]}),ve.map(t=>e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:t.name}),t.description&&r("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),fe.map(e=>{const i=Ke(e,t,pe),s=j(e,xe),n=Oe(i,t,s);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium "+("—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},e._id)})]},t._id))]}),ke.length>0&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:J("subscription.items.quotas")}),r("td",{colSpan:fe.length,className:"border-t border-border bg-muted"})]}),ke.map(t=>e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:t.name}),t.description&&r("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),fe.map(e=>{const i=Ke(e,t,pe),s=j(e,xe),n=Oe(i,t,s);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium "+("—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},e._id)})]},t._id))]}),!ie&&fe.some(e=>{const r=v(e,xe);return r?.enabled})&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-success/20 bg-success/10 px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-success shadow-sticky-col",children:J("subscription.seats.title")}),r("td",{colSpan:fe.length,className:"border-t border-success/20 bg-success/10"})]}),e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.seats.includedSeats")}),r("div",{className:"text-xs text-muted-foreground mt-0.5",children:J("subscription.seats.freeWithBase")})]}),fe.map(e=>{const t=v(e,xe);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium text-foreground",children:t?.enabled?ee(t.includedSeats||0):"—"})},e._id)})]}),e("tr",{className:"group hover:bg-muted/30",children:[r("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.seats.maxSeats")})}),fe.map(e=>{const t=v(e,xe);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium text-foreground",children:t?.enabled?(t?.maxSeats??0)>0?ee(t.maxSeats):J("subscription.seats.unlimited"):"—"})},e._id)})]}),e("tr",{className:"group hover:bg-muted/30",children:[r("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.seats.perExtraSeat")})}),fe.map(e=>{const t=k(e,xe,pe),i=j(e,xe);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium text-foreground",children:t&&t>0?`${re(t,i)}${se(pe)}`:"—"})},e._id)})]}),null!=W&&W>0&&e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.seats.billable")}),r("div",{className:"text-xs text-muted-foreground mt-0.5",children:J("subscription.membersInWorkspace",{count:W})})]}),fe.map(t=>{const i=v(t,xe);if(!i?.enabled)return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(t._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm text-muted-foreground/70",children:"—"})},t._id);const s=i.includedSeats||0,n=Math.max(0,W-s);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(t._id===A?"bg-info/5":"bg-background"),children:0===n?r("span",{className:"text-sm font-medium text-success",children:J("subscription.seats.allIncluded")}):e("span",{className:"text-sm font-medium text-warning",children:[ee(n)," ",J("subscription.seats.extra")]})},t._id)})]})]}),fe.some(e=>e.creditGrant?.enabled&&"object"==typeof e.creditGrant.creditPackage&&null!==e.creditGrant.creditPackage)&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-info/20 bg-info/10 px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-info shadow-sticky-col",children:J("subscription.items.credits")}),r("td",{colSpan:fe.length,className:"border-t border-info/20 bg-info/10"})]}),e("tr",{className:"group hover:bg-muted/30",children:[r("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:r("div",{className:"font-medium text-sm text-foreground",children:fe.every(e=>!e.creditGrant?.enabled||!e.creditGrant.renewOnPeriod)?J("subscription.items.creditsOneTime"):J("subscription.items.creditsPerMonth")})}),fe.map(e=>{const t=e.creditGrant,i=t?.enabled&&"object"==typeof t.creditPackage&&null!==t.creditPackage?t.creditPackage:null;return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",i?{className:"text-sm font-semibold text-info",children:ee(i.creditAmount)}:{className:"text-sm text-muted-foreground/70",children:"—"})},e._id)})]}),e("tr",{className:"group hover:bg-muted/30",children:[r("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.items.creditRenewal")})}),fe.map(e=>{const t=e.creditGrant;return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",t?.enabled?{className:"text-sm font-medium text-foreground",children:J(z(t))}:{className:"text-sm text-muted-foreground/70",children:"—"})},e._id)})]})]})]})]})})]})})]})})};export{V as default};
2
+ import{jsxs as e,jsx as r,Fragment as t}from"react/jsx-runtime";import i,{useState as s,useMemo as n,useEffect as a}from"react";import{aP as d,ag as l,u as c,A as o,at as u,aQ as m,ah as p,as as b,D as g,a as h,b as x,c as f,a0 as y,au as N,av as v,aw as k,B as w,ai as _,aj as P,aR as C,af as I}from"./react-B0MFoaXI.mjs";import{W as S}from"./SettingsDialog-VKPguQBs.mjs";import"clsx";import"tailwind-merge";import"intl-messageformat";import"@hookform/resolvers/zod";import"react-hook-form";import"@radix-ui/react-slot";import"class-variance-authority";import"lucide-react";import"@radix-ui/react-label";import"zod";import"@radix-ui/react-avatar";import"@radix-ui/react-dialog";import"@radix-ui/react-icons";import"@radix-ui/react-radio-group";import"@radix-ui/react-scroll-area";import"@radix-ui/react-separator";import"@radix-ui/react-accordion";import"@radix-ui/react-alert-dialog";import"@radix-ui/react-switch";import"cmdk";import"@radix-ui/react-popover";import"@radix-ui/react-select";const M={[l.Monthly]:"subscription.billingInterval.perMonth",[l.Quarterly]:"subscription.billingInterval.perQuarter",[l.Yearly]:"subscription.billingInterval.perYear"},L=(e,r,t)=>{if(!e||0===e)return null;let i;switch(t){case l.Yearly:i=r/12;break;case l.Quarterly:i=r/3;break;default:return null}const s=(e-i)/e*100;return s>0?Math.round(s):null},j=(e,r)=>d(e,r)?r:e.plan?.currency??r??"",z=e=>e.renewOnPeriod?"reset"===e.mode?"subscription.items.creditModeReset":"subscription.items.creditModeTopup":"subscription.items.creditModeLifetime",D=({planVersion:t})=>{const{t:i,fmtNum:s}=c(),n=t.creditGrant;return n?.enabled&&"object"==typeof n.creditPackage&&null!==n.creditPackage?e("div",{className:"mb-3",children:[r("div",{className:"text-xs font-semibold text-info uppercase tracking-wider mb-1.5",children:i("subscription.items.credits")}),e("div",{className:"space-y-1 text-sm",children:[e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:n.renewOnPeriod?i("subscription.items.creditsPerMonth"):i("subscription.items.creditsOneTime")}),r("span",{className:"font-semibold text-info",children:s(n.creditPackage.creditAmount)})]}),e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:i("subscription.items.creditRenewal")}),r("span",{className:"font-medium text-foreground",children:i(z(n))})]})]})]}):null},K=({hasVariant:i,price:s,displayCurrency:n,selectedInterval:a,getIntervalLabel:d})=>{const{t:l,fmtCents:o}=c();return e(t,{children:[r("span",{className:"text-2xl font-bold text-foreground",children:i&&null!==s?(u=s,m=n,(null==u||0===u?"":o(u,m))||l("pricing.free")):"—"}),null!==s&&s>0&&i&&r("span",{className:"text-sm text-muted-foreground",children:d(a)})]});var u,m},O=({planVersion:e,isCurrent:t,trialUsedAt:i,currentStripePriceId:s})=>{const{t:n}=c(),a=e.trial;return a?.enabled&&a.durationDays>0&&!t&&!i&&!s?r("span",{className:"shrink-0 rounded-md bg-success/15 text-success px-2 py-0.5 text-xs font-semibold uppercase tracking-wider",children:n("subscription.trialBadge",{days:a.durationDays})}):null},V=({open:d,onOpenChange:V,source:Q,planVersions:U,currentPlanVersionId:A,currentStripePriceId:F,billingCurrency:G,currentMemberCount:W,trialUsedAt:q,workspaceName:R,initialInterval:T,initialCurrency:Y,onSelectPlan:$,loading:H=!1})=>{const[B,E]=s(!1),{t:J,formattingLocale:X,dir:Z,fmtNum:ee,fmtCents:re}=c(),{settings:te}=o(),ie=te?.workspace?.mode===S.Personal,se=e=>J(M[e]??M[l.Monthly]),[ne,ae]=s(null),de=i.useRef(!1),le=n(()=>u(F,U),[F,U]),ce=le?.interval??null,oe=le?.currency??null,ue=n(()=>m(U),[U]),me=n(()=>{const e=G?.trim().toLowerCase();return e?ue.includes(e)?[e]:[]:ue},[G,ue]),[pe,be]=s(T||ce||l.Monthly),[ge,he]=s(()=>Y&&me.includes(Y)?Y:oe&&me.includes(oe)?oe:me.length>0?me[0]:""),xe=G?.trim()||ge;a(()=>{if(d){be(T||ce||l.Monthly);const e=Y||oe;e&&me.includes(e)?he(e):me.length>0&&!me.includes(ge)&&he(me[0])}},[d,T,Y,ce,oe,me]);const fe=U,ye=n(()=>(e=>{const r=new Map;return e.forEach(e=>{e.subscriptionItems?.forEach(e=>{r.has(e._id)||r.set(e._id,e)})}),Array.from(r.values())})(fe),[fe]),Ne=ye.filter(e=>e.type===p.Feature),ve=ye.filter(e=>e.type===p.Limit),ke=ye.filter(e=>e.type===p.Quota),{emit:we,ready:_e}=b(),Pe=i.useRef(!1),Ce=i.useRef(!1);a(()=>{if(!d)return Pe.current&&!Ce.current&&we("plan_picker_dismissed",{source:Q,billing_interval:pe}),Pe.current=!1,void(Ce.current=!1);!Pe.current&&_e&&(Pe.current=!0,we("plan_picker_opened",{source:Q,plan_count:U.length,has_subscription:!!A,current_plan_version_id:A,billing_interval:pe,currency:xe?xe.toUpperCase():void 0}))},[d,_e]);const Ie=e=>{if(!A)return"new";if(e._id===A)return"interval_change";const r=U.find(e=>e._id===A),t=r?N(r,xe,pe):null,i=N(e,xe,pe);return null==t||null==i?"change":i>=t?"upgrade":"downgrade"},Se=async e=>{if(e===A&&ce===pe||H||B||de.current)return;const r=U.find(r=>r._id===e);if(r){const t=N(r,xe,pe);Ce.current=!0,we("plan_selected",{source:Q,plan_version_id:e,plan_slug:r.plan?.slug,billing_interval:pe,currency:xe?xe.toUpperCase():void 0,value:null==t?void 0:C(t,xe),change:Ie(r),is_free:!!r.plan?.isFreemium})}de.current=!0,E(!0),ae(e);try{await $(e,pe,xe),V(!1)}catch(e){}finally{de.current=!1,E(!1),ae(null)}},Me=e=>N(e,xe,pe),Le=e=>!!e.pricingVariants?.some(e=>e.currency?.toLowerCase()===xe.toLowerCase()),je=H||B,ze=e=>{switch(e){case l.Monthly:return J("subscription.billingInterval.monthly");case l.Quarterly:return J("subscription.billingInterval.quarterly");case l.Yearly:return J("subscription.billingInterval.yearly");default:return J("subscription.billingInterval.monthly")}},De=e=>{const r=e._id===A,t=ce===pe;if(r&&t)return{labelKey:"subscription.currentPlan",variant:"outline",disabled:!0};if(r&&!t)return e.plan?.isFreemium?{labelKey:"subscription.currentPlan",variant:"outline",disabled:!0}:{labelKey:"_dynamic",dynamicLabel:J("subscription.switchToInterval",{interval:ze(pe)}),variant:"default",disabled:!1};const i=e.trial?.enabled&&e.trial.durationDays>0&&!q&&!F;if(!A)return i?{labelKey:"_dynamic",dynamicLabel:J("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.subscribe",variant:"default",disabled:!1};const s=fe.findIndex(e=>e._id===A),n=fe.findIndex(r=>r._id===e._id);return-1===s||-1===n?i?{labelKey:"_dynamic",dynamicLabel:J("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.checkout.select",variant:"default",disabled:!1}:n<s?{labelKey:"subscription.checkout.downgrade",variant:"outline",disabled:!1}:n>s?i?{labelKey:"_dynamic",dynamicLabel:J("subscription.startTrialDays",{days:e.trial.durationDays}),variant:"default",disabled:!1}:{labelKey:"subscription.checkout.upgrade",variant:"default",disabled:!1}:{labelKey:"subscription.checkout.select",variant:"default",disabled:!1}},Ke=(e,r,t=l.Monthly)=>{if(r.type===p.Feature)return e.features?.[r.slug]??!1;if(r.type===p.Limit)return e.limits?.[r.slug]??null;if(r.type===p.Quota){const i=_(e,xe,r.slug,t);return i||P(e.quotas?.[r.slug],t)}return null},Oe=(e,r,t)=>{if(r.type===p.Feature)return!0===e?"✓":"—";if(r.type===p.Limit)return null!=e&&"number"==typeof e?ee(e):"—";if(r.type===p.Quota){const i=I("object"==typeof e&&null!==e&&"included"in e?e:null,r.name.toLowerCase(),{currency:t,locale:X});return i?i.allowOverage?i.hasOverage?J("quota.includedWithOverage",{count:i.included,price:i.price,unit:i.unit}):J("quota.includedOnly",{count:i.included}):J("quota.includedHardLimit",{count:i.included}):"—"}return"—"};return r(g,{open:d,onOpenChange:V,children:e(h,{dir:Z,className:"inset-0 w-screen h-screen max-w-none rounded-none translate-x-0 translate-y-0 p-0 flex flex-col",children:[e("div",{className:"flex-shrink-0 px-4 py-4 sm:px-6 sm:py-6 border-b space-y-3 sm:space-y-4",children:[e("div",{children:[r(x,{className:"text-xl font-semibold",children:J("pricing.title")}),e(f,{className:"mt-1 text-sm",children:[J("subscription.choosePlanDescription"),R&&r("span",{className:"ml-1 font-medium text-foreground",children:J("subscription.forWorkspace",{name:R})})]})]}),e("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 sm:gap-4",children:[e("div",{className:"flex items-center gap-2",children:[!G?.trim()&&me.length>1&&e(t,{children:[r("span",{className:"text-sm text-muted-foreground",children:J("pricing.currency")}),r("select",{"aria-label":J("pricing.selectCurrency"),value:ge,onChange:e=>he(e.target.value),className:"rounded-md border border-border bg-background px-3 py-2 text-sm font-medium text-foreground shadow-sm focus:outline-none focus:ring-2 focus:ring-primary",children:me.map(e=>{const t=y(e);return r("option",{value:e,children:t?`${t} ${e.toUpperCase()}`:e.toUpperCase()},e)})})]}),G?.trim()&&r("span",{className:"text-xs text-muted-foreground",children:J("subscription.billingInCurrency",{currency:G.toUpperCase()})})]}),r("div",{className:"flex items-center gap-0.5 sm:gap-1 p-1 bg-muted rounded-lg w-full sm:w-auto",role:"group","aria-label":J("pricing.billingInterval"),children:[l.Monthly,l.Quarterly,l.Yearly].map(t=>{const i=ce===t;return r("button",{onClick:()=>(e=>{e!==pe&&we("billing_interval_changed",{from:pe,to:e}),be(e)})(t),"aria-pressed":pe===t,className:"flex-1 sm:flex-initial px-3 sm:px-4 py-2 text-sm font-medium rounded-md transition-all relative "+(pe===t?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:e("span",{className:"flex items-center justify-center gap-1 sm:gap-1.5",children:[t===l.Monthly&&J("subscription.billingInterval.monthly"),t===l.Quarterly&&J("subscription.billingInterval.quarterly"),t===l.Yearly&&J("subscription.billingInterval.yearly"),t===l.Yearly&&r("span",{className:"text-xs px-1 sm:px-1.5 py-0.5 bg-success/15 text-success rounded-full font-semibold",children:J("pricing.save")}),i&&A&&r("span",{className:"hidden sm:inline text-xs px-1.5 py-0.5 bg-info/15 text-info rounded-full font-semibold",children:J("pricing.current")})]})},t)})})]})]}),r("div",{className:"flex-1 min-h-0 flex flex-col",children:G?.trim()&&0===me.length?e("div",{className:"text-center py-12 px-4",children:[r("p",{className:"text-muted-foreground font-medium",children:J("pricing.noPlansCurrency")}),r("p",{className:"text-muted-foreground text-sm mt-2",children:J("pricing.noPlansCurrencyHint")})]}):0===fe.length?r("div",{className:"text-center py-12 text-muted-foreground",children:r("p",{children:J("pricing.noPlans")})}):e("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:[r("div",{className:"md:hidden overflow-auto h-full",style:{maxHeight:"calc(100vh - 13rem)"},children:r("div",{className:"p-4 space-y-4",children:fe.map(t=>{const i=t._id===A,s=De(t),n=je&&t._id===ne,a=Me(t),d=Le(t),c=j(t,xe),o=N(t,xe,l.Monthly)??0,u=pe!==l.Monthly&&null!==a?L(o,a,pe):null,m=v(t,xe),b=m?k(t,xe,pe):null;return e("div",{className:"rounded-xl border-2 p-4 "+(i?"border-info bg-info/5":"border-border bg-background"),children:[e("div",{className:"flex items-start justify-between mb-3",children:[e("div",{children:[e("div",{className:"flex items-center gap-2",children:[r("h3",{className:"text-lg font-bold text-foreground",children:t.plan.name}),r(O,{planVersion:t,isCurrent:i,trialUsedAt:q,currentStripePriceId:F})]}),t.plan.description&&r("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:t.plan.description})]}),i&&r("span",{className:"shrink-0 rounded-md bg-info px-2 py-0.5 text-xs font-semibold uppercase tracking-wider text-info-foreground",children:J("pricing.current")})]}),e("div",{className:"mb-4",children:[r("div",{className:"flex items-baseline gap-1 whitespace-nowrap",children:r(K,{hasVariant:d,price:a,displayCurrency:c,selectedInterval:pe,getIntervalLabel:se})}),null!==u&&u>0&&d&&r("span",{className:"text-xs text-success font-medium",children:J("subscription.savingsPercent",{percent:u})}),m?.enabled&&b&&b>0&&!ie&&r("div",{className:"text-xs text-muted-foreground mt-1",children:J("subscription.seatPriceDisplay",{price:re(b,c),interval:se(pe),included:ee(m.includedSeats),includedLabel:J("pricing.included")})})]}),Ne.length>0&&e("div",{className:"mb-3",children:[r("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5",children:J("subscription.items.features")}),r("div",{className:"space-y-1",children:Ne.map(i=>{const s=Ke(t,i,pe),n=i.type===p.Feature&&!0===s;return e("div",{className:"flex items-center gap-2 text-sm",children:[i.type===p.Feature?r("span",n?{className:"text-success text-xs",children:"✓"}:{className:"text-muted-foreground/50 text-xs",children:"✕"}):null,r("span",{className:n?"text-foreground":"text-muted-foreground/70",children:i.name})]},i._id)})})]}),ve.length>0&&e("div",{className:"mb-3",children:[r("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5",children:J("subscription.items.limits")}),r("div",{className:"space-y-1",children:ve.map(i=>{const s=Ke(t,i,pe);return e("div",{className:"flex items-center justify-between text-sm",children:[r("span",{className:"text-muted-foreground",children:i.name}),r("span",{className:"font-medium text-foreground",children:"number"==typeof s?ee(s):"—"})]},i._id)})})]}),m?.enabled&&!ie&&e("div",{className:"mb-3",children:[r("div",{className:"text-xs font-semibold text-success uppercase tracking-wider mb-1.5",children:J("subscription.seats.title")}),e("div",{className:"space-y-1 text-sm",children:[e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:J("subscription.seats.included")}),r("span",{className:"font-medium",children:ee(m.includedSeats||0)})]}),e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:J("subscription.seats.maxSeats")}),r("span",{className:"font-medium",children:(m?.maxSeats??0)>0?ee(m.maxSeats):J("subscription.seats.unlimited")})]}),null!=W&&W>0&&(()=>{const t=Math.max(0,W-(m.includedSeats||0));return e("div",{className:"flex justify-between",children:[r("span",{className:"text-muted-foreground",children:J("subscription.seats.billable")}),r("span",{className:"font-medium "+(0===t?"text-success":"text-warning"),children:0===t?J("subscription.seats.allIncluded"):`${ee(t)} ${J("subscription.seats.extra")}`})]})})()]})]}),r(D,{planVersion:t}),r(w,{className:"w-full mt-2",variant:s.variant,disabled:s.disabled||je||!d,progress:n,onClick:()=>Se(t._id),children:n?J("pricing.processing"):d?s.dynamicLabel??J(s.labelKey):J("pricing.unavailable")})]},t._id)})})}),r("div",{className:"hidden md:block overflow-auto h-full",style:{maxHeight:"calc(100vh - 12rem)"},children:e("table",{"aria-label":J("subscription.choosePlan"),className:"w-full border-separate border-spacing-0",style:{minWidth:260+220*fe.length+"px",borderCollapse:"separate"},children:[e("colgroup",{children:[r("col",{style:{width:260,minWidth:260}}),fe.map(e=>r("col",{style:{width:220,minWidth:220}},e._id))]}),r("thead",{children:e("tr",{className:"align-top",children:[r("th",{className:"sticky top-0 start-0 z-30 p-0 bg-background text-start"}),fe.map(t=>{const i=t._id===A,s=De(t),n=je&&t._id===ne,a=Me(t),d=N(t,xe,l.Monthly)??0,c=pe!==l.Monthly&&null!==a?L(d,a,pe):null,o=Le(t),u=j(t,xe);return r("th",{className:"sticky top-0 z-20 border-b border-border p-3 shadow-sticky-row "+(t._id===A?"bg-info/10":"bg-background"),children:e("div",{className:"flex h-full flex-col gap-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[r("h3",{className:"text-base font-bold text-foreground truncate",children:t.plan.name}),r(O,{planVersion:t,isCurrent:i,trialUsedAt:q,currentStripePriceId:F})]}),i&&r("span",{className:"shrink-0 rounded-md bg-info px-2 py-0.5 text-xs font-semibold uppercase tracking-wider text-info-foreground",children:J("pricing.current")})]}),e("div",{className:"flex flex-col items-start min-h-[3rem]",children:[e("div",{className:"flex items-baseline gap-1 flex-wrap",children:[r(K,{hasVariant:o,price:a,displayCurrency:u,selectedInterval:pe,getIntervalLabel:se}),null!==c&&c>0&&o&&r("span",{className:"text-xs px-1.5 py-0.5 bg-success/15 text-success rounded-full font-semibold whitespace-nowrap",children:J("subscription.savingsPercent",{percent:c})})]}),(()=>{if(ie)return null;const e=v(t,xe);if(!e)return null;const i=k(t,xe,pe);return!i||i<=0?null:r("div",{className:"text-xs text-muted-foreground mt-1.5 border-t border-border/60 pt-1 leading-tight",children:r("div",{children:J("subscription.seatPriceDisplay",{price:re(i,u),interval:se(pe),included:ee(e.includedSeats),includedLabel:J("pricing.included")})})})})()]}),t.plan.description&&r("p",{className:"text-xs text-muted-foreground line-clamp-2 leading-relaxed text-start",children:t.plan.description}),r(w,{className:"mt-auto w-full",variant:s.variant,disabled:s.disabled||je||!o,progress:n,onClick:()=>Se(t._id),children:n?J("pricing.processing"):o?s.dynamicLabel??J(s.labelKey):J("pricing.unavailable")})]})},t._id)})]})}),e("tbody",{children:[Ne.length>0&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:J("subscription.items.features")}),r("td",{colSpan:fe.length,className:"border-t border-border bg-muted"})]}),Ne.map(t=>e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:t.name}),t.description&&r("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),fe.map(e=>{const i=Ke(e,t,pe),s=j(e,xe),n=Oe(i,t,s),a=t.type===p.Feature&&!0===i;return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium "+(a?"text-success":"—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},e._id)})]},t._id))]}),ve.length>0&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:J("subscription.items.limits")}),r("td",{colSpan:fe.length,className:"border-t border-border bg-muted"})]}),ve.map(t=>e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:t.name}),t.description&&r("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),fe.map(e=>{const i=Ke(e,t,pe),s=j(e,xe),n=Oe(i,t,s);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium "+("—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},e._id)})]},t._id))]}),ke.length>0&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-border bg-muted px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-muted-foreground shadow-sticky-col",children:J("subscription.items.quotas")}),r("td",{colSpan:fe.length,className:"border-t border-border bg-muted"})]}),ke.map(t=>e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:t.name}),t.description&&r("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.description})]}),fe.map(e=>{const i=Ke(e,t,pe),s=j(e,xe),n=Oe(i,t,s);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium "+("—"===n?"text-muted-foreground/70":"text-foreground"),children:n})},e._id)})]},t._id))]}),!ie&&fe.some(e=>{const r=v(e,xe);return r?.enabled})&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-success/20 bg-success/10 px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-success shadow-sticky-col",children:J("subscription.seats.title")}),r("td",{colSpan:fe.length,className:"border-t border-success/20 bg-success/10"})]}),e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.seats.includedSeats")}),r("div",{className:"text-xs text-muted-foreground mt-0.5",children:J("subscription.seats.freeWithBase")})]}),fe.map(e=>{const t=v(e,xe);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium text-foreground",children:t?.enabled?ee(t.includedSeats||0):"—"})},e._id)})]}),e("tr",{className:"group hover:bg-muted/30",children:[r("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.seats.maxSeats")})}),fe.map(e=>{const t=v(e,xe);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium text-foreground",children:t?.enabled?(t?.maxSeats??0)>0?ee(t.maxSeats):J("subscription.seats.unlimited"):"—"})},e._id)})]}),e("tr",{className:"group hover:bg-muted/30",children:[r("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.seats.perExtraSeat")})}),fe.map(e=>{const t=k(e,xe,pe),i=j(e,xe);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm font-medium text-foreground",children:t&&t>0?`${re(t,i)}${se(pe)}`:"—"})},e._id)})]}),null!=W&&W>0&&e("tr",{className:"group hover:bg-muted/30",children:[e("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:[r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.seats.billable")}),r("div",{className:"text-xs text-muted-foreground mt-0.5",children:J("subscription.membersInWorkspace",{count:W})})]}),fe.map(t=>{const i=v(t,xe);if(!i?.enabled)return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(t._id===A?"bg-info/5":"bg-background"),children:r("span",{className:"text-sm text-muted-foreground/70",children:"—"})},t._id);const s=i.includedSeats||0,n=Math.max(0,W-s);return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(t._id===A?"bg-info/5":"bg-background"),children:0===n?r("span",{className:"text-sm font-medium text-success",children:J("subscription.seats.allIncluded")}):e("span",{className:"text-sm font-medium text-warning",children:[ee(n)," ",J("subscription.seats.extra")]})},t._id)})]})]}),fe.some(e=>e.creditGrant?.enabled&&"object"==typeof e.creditGrant.creditPackage&&null!==e.creditGrant.creditPackage)&&e(t,{children:[e("tr",{children:[r("td",{className:"sticky start-0 z-10 border-t border-info/20 bg-info/10 px-4 py-2.5 font-semibold text-xs uppercase tracking-wider text-info shadow-sticky-col",children:J("subscription.items.credits")}),r("td",{colSpan:fe.length,className:"border-t border-info/20 bg-info/10"})]}),e("tr",{className:"group hover:bg-muted/30",children:[r("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:r("div",{className:"font-medium text-sm text-foreground",children:fe.every(e=>!e.creditGrant?.enabled||!e.creditGrant.renewOnPeriod)?J("subscription.items.creditsOneTime"):J("subscription.items.creditsPerMonth")})}),fe.map(e=>{const t=e.creditGrant,i=t?.enabled&&"object"==typeof t.creditPackage&&null!==t.creditPackage?t.creditPackage:null;return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",i?{className:"text-sm font-semibold text-info",children:ee(i.creditAmount)}:{className:"text-sm text-muted-foreground/70",children:"—"})},e._id)})]}),e("tr",{className:"group hover:bg-muted/30",children:[r("td",{className:"sticky start-0 z-10 border-t border-border/60 bg-background p-4 shadow-sticky-col group-hover:bg-muted/50",children:r("div",{className:"font-medium text-sm text-foreground",children:J("subscription.items.creditRenewal")})}),fe.map(e=>{const t=e.creditGrant;return r("td",{className:"border-t border-border/60 p-4 text-center align-middle "+(e._id===A?"bg-info/5":"bg-background"),children:r("span",t?.enabled?{className:"text-sm font-medium text-foreground",children:J(z(t))}:{className:"text-sm text-muted-foreground/70",children:"—"})},e._id)})]})]})]})]})})]})})]})})};export{V as default};