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