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