"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["30"],{6334:function(e,i,n){n.r(i),n.d(i,{PricingTable:()=>a.n});var a=n(1217)},7288:function(e,i,n){n.d(i,{A$:()=>m,D:()=>f,Ij:()=>d,Rs:()=>g,eT:()=>p,mu:()=>c,wD:()=>b});var a=n(9400),t=n(630),l=n(7477),r=n(5424),o=n(2861),s=n(6256);function d(e){return e.endsWith(".00")?e.slice(0,-3):e}let u=()=>{let e=(0,s.XX)(),i=(0,l.Fd)(e=>e({permission:"org:sys_billing:read"})||e({permission:"org:sys_billing:manage"})),n=(0,a.Wf)();return{for:e,keepPreviousData:!0,enabled:"organization"!==e||!!n?.organization&&i}},c=()=>{let e=u();return(0,a.X$)(e)},b=()=>{let e=u();return(0,a.t7)(e)},p=e=>{let i=u();return(0,a.tr)({...i,__experimental_mode:e?.mode})},g=()=>{let e=u(),i=(0,a.kH)(e),n=(0,t.useMemo)(()=>i.data?.subscriptionItems||[],[i.data?.subscriptionItems]);return{...i,subscriptionItems:n}},m=e=>{let i=(0,s.XX)();return(0,a.rg)({for:i,initialPage:1,pageSize:50,keepPreviousData:!0,enabled:!0,__experimental_mode:e?.mode})},f=()=>{let e=(0,a.ho)(),{session:i}=(0,a.wV)(),n=(0,s.XX)(),l=(0,t.useMemo)(()=>!!(!e.session||e?.session?.checkAuthorization({permission:"org:sys_billing:manage"})||"user"===n),[e,n]),{subscriptionItems:d,revalidate:u,data:b}=g(),{data:f,revalidate:h}=m({mode:"cache"}),{revalidate:_}=p({mode:"cache"}),{revalidate:k}=c(),A=(0,t.useCallback)(()=>{u(),h(),_(),k()},[u,h,_,k]),C=(0,t.useMemo)(()=>0===d.length||!d.some(e=>!e.canceledAt),[d]),v=(0,t.useCallback)(e=>d.find(i=>i.plan.id===e.id),[d]),P=(0,t.useCallback)(e=>d.filter(i=>i.plan.id===e.id),[d]),y=(0,t.useCallback)((e,i="month")=>{let n=P(e);if(n.length>1){let e=n.find(e=>e.planPeriod===i);return e||n[0]}if(1===n.length)return n[0]},[P]),G=(0,t.useCallback)(({plan:e,subscription:i})=>{let n=i??(e?v(e):void 0);return!n||!n.canceledAt},[v]),T=(0,t.useCallback)(({plan:e,subscription:n,isCompact:a=!1,selectedPlanPeriod:t="annual"})=>{let r=n??(e?y(e,t):void 0),s=t,u=!!e?.annualMonthlyFee;"annual"!==s||u||(s="month");let c=n=>{if(e?.freeTrialEnabled){let n=!i,a=b?.eligibleForFreeTrial;if(n||a)return(0,o.G)("billing.startFreeTrial__days",{days:e.freeTrialDays??0})}return n};return{localizationKey:c((()=>{if(r){if(s!==r.planPeriod&&r.canceledAt){if("month"===s)return(0,o.G)("billing.switchToMonthly");if(u)return(0,o.G)("billing.switchToAnnual")}if(r.canceledAt)return(0,o.G)("billing.reSubscribe");if(s!==r.planPeriod){if("month"===s)return(0,o.G)("billing.switchToMonthly");if(u)return(0,o.G)("billing.switchToAnnual")}return(0,o.G)("billing.manageSubscription")}return d.filter(e=>!e.plan.isDefault).length>0?(0,o.G)("billing.switchPlan"):c((0,o.G)("billing.subscribe"))})()),variant:a?"bordered":"solid",colorScheme:a?"secondary":"primary",isDisabled:!l,disabled:!l}},[y,l,d,b]),D=(0,t.useCallback)(e=>e.pastDueAt?(0,o.G)("badge__pastDueAt",{date:e.pastDueAt}):"upcoming"===e.status?(0,o.G)("badge__startsAt",{date:e.periodStart}):e.canceledAt?(0,o.G)("badge__canceledEndsAt",{date:e.periodEnd}):e.periodEnd?(0,o.G)(e.isFreeTrial?"badge__trialEndsAt":"badge__renewsAt",{date:e.periodEnd}):void 0,[]),w=(0,t.useCallback)(i=>{let a=(0,r.J)("modal",i);e.__internal_openSubscriptionDetails({for:n,onSubscriptionCancel:()=>{A()},portalRoot:a})},[e,n,A]);return{activeOrUpcomingSubscription:v,activeAndUpcomingSubscriptions:P,activeOrUpcomingSubscriptionBasedOnPlanPeriod:y,isDefaultPlanImplicitlyActiveOrUpcoming:C,handleSelectPlan:(0,t.useCallback)(({plan:a,planPeriod:t,mode:l="mounted",event:o,appearance:s,newSubscriptionRedirectUrl:d})=>{let u=(0,r.J)(l,o);e.__internal_openCheckout({planId:a.id,planPeriod:"annual"!==t||a.annualMonthlyFee?t:"month",for:n,onSubscriptionComplete:()=>{A()},onClose:()=>{i?.id&&e.setActive({session:i.id})},appearance:s,portalRoot:u,newSubscriptionRedirectUrl:d})},[e,A,n,i?.id]),openSubscriptionDetails:w,buttonPropsForPlan:T,canManageSubscription:G,captionForSubscription:D,defaultFreePlan:(0,t.useMemo)(()=>f?.find(e=>e.isDefault),[f]),revalidateAll:A}}},6256:function(e,i,n){n.d(i,{N7:()=>o,XX:()=>r,m$:()=>l});var a=n(630);let t="user",l=(0,a.createContext)(t),r=()=>(0,a.useContext)(l)||t,o=()=>"user"===r()?"userProfile":"organizationProfile"}}]);