PageSourceSearch

https://aecharts.com/assets/useSubscription-D61utUPa.js

js aecharts.com collected 2026-09-24 12:56:59 UTC 4,225 bytes, 1 lines download raw bytes

1import{r as a}from"./chunk-EPOLDU6W-DIpkhZgL.js";import{b as w,d as E,a as S,o as x,t as C}from"./analytics-C1VJWLwm.js";import{A as _}from"./api-DabWmWwi.js";import{A as b}from"./index.esm-BHVHlmKG.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"acc43460c2f2119eb9918d4f2e6bbb38a1784977"};var i=new t.Error().stack;i&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[i]="3a5f012c-f977-4500-99bc-b079e48601c6",t._sentryDebugIdIdentifier="sentry-dbid-3a5f012c-f977-4500-99bc-b079e48601c6")}catch{}})();const k={status:"none",plan:"free",dodoCustomerId:null,dodoSubscriptionId:null,nextBillingDate:null,cancelAtNextBillingDate:!1,passExpiresAt:null};function M(){const[t,i]=a.useState(null),[n,l]=a.useState(null),[T,g]=a.useState(!0);a.useEffect(()=>{let e=null;const o=w.onAuthStateChanged(r=>{if(!r){i(k),l(null),g(!1);return}const c=E(S,"users",r.uid),f=x(c,d=>{if(d.exists()){const A=d.data(),s=A.subscription||{};i({status:s.status||"none",plan:s.plan||"free",dodoCustomerId:s.dodoCustomerId||null,dodoSubscriptionId:s.dodoSubscriptionId||null,nextBillingDate:s.nextBillingDate?new Date(s.nextBillingDate):null,cancelAtNextBillingDate:s.cancelAtNextBillingDate||!1,passExpiresAt:s.passExpiresAt?new Date(s.passExpiresAt):null});const y=A.teamId||null;if(y){if(!e){const v=E(S,"teams",y);e=x(v,m=>{if(m.exists()){const p=m.data();l({teamId:y,isActive:p.subscription?.status==="active",isAdmin:p.ownerId===r.uid,brandColors:Array.isArray(p.brandKit?.colors)&&p.brandKit.colors.length>0?p.brandKit.colors.filter(O=>typeof O=="string"):[],logoUrl:p.brandKit?.logoUrl??null})}else l(null)},m=>{console.error("Error listening to team:",m),l(null)})}}else e?.(),e=null,l(null)}else i(k),l(null);g(!1)},d=>{console.error("Error listening to subscription:",d),i(k),l(null),g(!1)});return()=>{f(),e?.(),e=null}});return()=>o()},[]);const h=a.useMemo(()=>!!n?.isActive,[n]),D=a.useMemo(()=>!!n?.isAdmin,[n]),u=a.useMemo(()=>h?!0:t?!!(t.status==="active"&&(t.plan==="pro"||t.plan==="pro_annual")||t.passExpiresAt&&t.passExpiresAt>new Date):!1,[t,h]),U=u,B=u,N=u;a.useEffect(()=>{u&&b.Checkout.isOpen()&&b.Checkout.close()},[u]);const I=()=>{const e=window.endorsely_referral;return typeof e=="string"&&e.length>0?(localStorage.setItem("endorsely_referral",e),e):localStorage.getItem("endorsely_referral")},R=async e=>{const o=w.currentUser;if(!o){console.error("User must be logged in to checkout");return}try{const r=await o.getIdToken();C(e);const c=await fetch(`${_}/api/subscriptions/create-checkout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({plan:e,email:o.email||"",name:o.displayName||"",return_url:`${window.location.origin}/editor?upgraded=true`,referral_id:I()})});if(!c.ok){const d=await c.text();throw new Error(`Failed to create checkout session: ${d}`)}const f=await c.json();b.Checkout.open({checkoutUrl:f.checkout_url})}catch(r){throw console.error("Error creating checkout session:",r),r}},$=async()=>{const e=w.currentUser;if(!e){console.error("User must be logged in to checkout");return}try{const o=await e.getIdToken();C("day_pass");const r=await fetch(`${_}/api/subscriptions/create-pass-checkout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({email:e.email||"",name:e.displayName||"",return_url:`${window.location.origin}/editor?upgraded=true`,referral_id:I()})});if(!r.ok){const f=await r.text();throw new Error(`Failed to create pass checkout session: ${f}`)}const c=await r.json();b.Checkout.open({checkoutUrl:c.checkout_url})}catch(o){throw console.error("Error creating pass checkout session:",o),o}},P=()=>{const e=t?.dodoCustomerId;if(!e){console.error("No Dodo customer ID found");return}const o=`https://customer.dodopayments.com/portal/${e}`;window.open(o,"_blank")};return{subscription:t,loading:T,teamId:n?.teamId??null,isTeam:h,isTeamAdmin:D,teamBrandColors:n?.brandColors??[],teamLogoUrl:n?.logoUrl??null,isPro:u,canExportVideo:U,canRemoveWatermark:B,canAccessPremiumTemplates:N,openCheckout:R,openPassCheckout:$,openCustomerPortal:P}}export{M as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.