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