PageSourceSearch

https://hopelia.com/assets/usePlan-D7X9LkHX.js

js hopelia.com collected 2026-10-02 01:32:26 UTC 3,267 bytes, 1 lines download raw bytes

1import{a5 as c,a0 as E,h as w,o as y,r as h,aT as b,k as P,aU as L,aV as O,s as _}from"./index-Bf345cdl.js";import{u as A,o as v,a as I}from"./useViewAs-C4sUdePs.js";import{u as C}from"./useMutation-D1XpQOaK.js";import{u as k}from"./useProfile-C76L2fG5.js";import{r as F,f as N}from"./subscription-T4ha2ROn.js";import{S as K}from"./social-GpM-F0Gm.js";const l="hopelia:checkout-continuation:v1",q=3600*1e3;function d(){try{return typeof window>"u"?void 0:window.sessionStorage}catch{return}}function g(e=d()){try{e?.removeItem(l)}catch{}}function D(e,r=d(),t=Date.now()){try{r?.setItem(l,JSON.stringify({interval:e.interval==="year"?"year":"month",returnTo:c(e.returnTo),savedAt:t}))}catch{}}function j(e=d(),r=Date.now()){try{const t=e?.getItem(l);if(!t||t.length>2e3)return null;const n=JSON.parse(t);return!Number.isFinite(n.savedAt)||n.savedAt>r||r-n.savedAt>=q||!["month","year"].includes(n.interval)?(g(e),null):{interval:n.interval,returnTo:c(n.returnTo)}}catch{return g(e),null}}const R=()=>({social:K}),T={social_discord:e=>!!e.social.discord,social_instagram:e=>!!e.social.instagram,social_x:e=>!!e.social.x};Object.keys(T).sort();function z(e,r=R()){return T[e](r)}const x={billing:()=>E(()=>import("./index-Bf345cdl.js").then(e=>e.db),[]).then(e=>e.apiBillingConfig())};function M(e,r=x){return r[e]()}const U=["subscription"];function S(){const{user:e}=w();return b({queryKey:U,enabled:!!e,staleTime:5*6e4,queryFn:async()=>{const{data:r}=await _.auth.getSession(),t=r.session?.user?.id;if(!t)return null;const{data:n,error:s}=await _.from("subscriptions").select("status, stripe_customer_id, stripe_subscription_id, price_id, current_period_end, cancel_at_period_end, plan").eq("user_id",t).maybeSingle();if(s)throw s;return n??null}})}function W(){const{user:e,loading:r}=w(),t=k(),n=S(),{isAdmin:s}=y(),{viewAs:o}=A(),{data:i}=t,{data:p}=n,f=t.isSuccess||t.isError,m=n.isSuccess||n.isError,a=h.useMemo(()=>F({authLoading:r,userPresent:!!e,profileSettled:f,subSettled:m,profile:i,sub:p,nowMs:Date.now()}),[r,e,f,m,i,p]);return{access:h.useMemo(()=>{if(a.isLoading)return null;const u=a.access;return s&&o!=="reel"?v(o,u):s?v("perso",u):u},[a,s,o]),isLoading:a.isLoading}}function X(){return C({mutationFn:async e=>{const r=e?.plan??"perso",t=e?.interval??"month";if(r==="pro"&&!N)throw new Error("Le plan Pro n'est pas encore disponible.");P("checkout_clic",{plan:r,interval:t});const n=c(e?.returnTo);D({interval:t,returnTo:n});const s=await L(r,t,n);if(s.url){window.location.href=s.url;return}throw new Error(s.error||"Paiement indisponible.")}})}function Z(){const{data:e,isLoading:r}=b({queryKey:["billing","config"],staleTime:6e5,retry:1,queryFn:()=>M("billing")});return{perso:e?.perso??!0,persoAnnuel:e?.persoAnnuel??!0,pro:e?.pro??!0,proAnnuel:e?.proAnnuel??!1,isLoading:r}}function $(){return C({mutationFn:async()=>{const e=await O();if(e.url){window.location.href=e.url;return}throw new Error(e.error||"Portail indisponible.")}})}function ee(){const{isAdmin:e}=y(),{viewAs:r}=A(),{data:t,isLoading:n}=S(),o=!!t&&["active","trialing","past_due"].includes(t.status)&&t?.plan==="pro"?"pro":"perso",i=e?r==="reel"?"pro":I(r,o):o;return{plan:i,isPro:i==="pro",isLoading:n}}export{S as a,X as b,Z as c,ee as d,$ as e,g as f,z as h,j as r,W 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.