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