1import{r as d,j as r,f as p,s as u}from"./index-CUnD0zRX.js";import{B as n}from"./button-xYvlBXNV.js";import{C as T}from"./card-CPmLZw49.js";import{B as x}from"./badge-BTeiXzHl.js";import{S as A}from"./switch-BO1UJlQm.js";import{u as E}from"./useAuth-Avra37EG.js";import{e as R,T as F,P as L}from"./DashboardPage-nuS0ECi-.js";import{A as $}from"./arrow-left-BHmIwLpj.js";import{C as z}from"./check-CC1A47Eq.js";import{L as h}from"./loader-circle-CpOmg-m6.js";import{S as b}from"./sparkles-3l4fd-43.js";import{H as _}from"./heart-Bcb7vS64.js";import{U as B}from"./users-C0OG_exl.js";import{a as M}from"./type-B16LdtB4.js";import"./index-BRQ7lubN.js";import"./MobileLayout-C-YbJTep.js";import"./clipboard-check-BG49AG8l.js";import"./message-circle-BbhbtKIi.js";import"./user-Bjq8PFd8.js";import"./dialog-Y31n5cbw.js";import"./index-eZ5YWuhi.js";import"./index-CkDZxNze.js";import"./award-pITKgnAt.js";import"./mail-DFtNe6So.js";import"./circle-check-0FSlN9jk.js";import"./trending-up-B7mBHc5E.js";import"./party-popper-Bq6i2vUo.js";import"./arrow-right-0TUBhQDL.js";import"./flame-BgtpToBH.js";import"./SignUpPromptDialog-BGXZ323o.js";import"./chevron-right-C19x5mxb.js";import"./download-BpMck9RB.js";import"./trending-down-Dn9FhgHx.js";import"./minus-e19nFTj3.js";import"./history-9b6NaI-R.js";import"./calendar-CdAalm0O.js";import"./shield-CfSk5CII.js";import"./smartphone-DDtW_bdT.js";import"./ocupath360-one-sheet.pdf.asset-CHnVCl2I.js";import"./dropdown-menu-bmi_VGNv.js";import"./index-DoBXn26i.js";import"./index-CNdE3s1N.js";import"./circle-BfJk6pkN.js";import"./SleepFingerprintQuiz-CrHKzDDV.js";import"./jspdf.es.min-DokfTp3X.js";import"./progress-DZZX3cSn.js";import"./input-CpvQ5L1O.js";import"./InclineBedIcon-CSTWNSLW.js";import"./fingerprint-Bz58ZA8J.js";import"./chevron-left-3Hm53-2p.js";import"./moon-DeZeHfzX.js";import"./clock-BZUOdO0j.js";import"./thermometer-Mau9Q6d1.js";import"./shopping-bag-BswXJBMv.js";import"./index-BR7ctsNG.js";import"./play-W-r5BlsH.js";import"./circle-check-big-BBYOy6qD.js";import"./calendar-check-BDN_JaUz.js";import"./log-out-aMk2GH3g.js";import"./eye-JFaXVKuM.js";import"./use-mobile-IjdJ9jKh.js";import"./ocupath-logo-dark-CDhYifz8.js";import"./textarea-_ZkJiQpS.js";import"./scroll-area-DFh94G0t.js";import"./select-BVxM4hu5.js";import"./chevron-down-gOqt3Re9.js";import"./chevron-up-CMUamj5h.js";import"./alert-dialog-BUJzXpS0.js";import"./label-BSdZfXg9.js";import"./user-plus-uMMMigHH.js";import"./send-C8-VjUZN.js";import"./types-Da-z-dEq.js";import"./external-link-eMrhQJKB.js";import"./rotate-ccw-gjjXO07B.js";import"./file-down-C_ngOxWr.js";import"./thermometer-snowflake-DwsGzpGq.js";import"./bed-double-DLI4Kk6w.js";import"./clipboard-list-DCuTajkc.js";import"./time-picker-Dh_l_iu3.js";import"./activity-DsXAinyf.js";import"./timezone-D5Tn-te-.js";import"./settings-CTWG6M7-.js";import"./radio-group-L4SzwJKh.js";import"./checkbox-D3S9VQcD.js";import"./triangle-alert-DBwMZz6C.js";import"./flower-2-pRciYEWn.js";import"./trash-2-CId8qmkm.js";import"./log-in-Dg1io7se.js";import"./save-KiDs5Te_.js";import"./message-square-qN_weX03.js";import"./bell-3WK4ywZx.js";import"./phone-nmgmfv43.js";import"./pencil-BCUqZbWP.js";import"./globe-6vN8DtX6.js";import"./sun-C_4G4YTo.js";import"./plus-CTasjrhZ.js";import"./star-BBuw5bQY.js";import"./info-DjQWxC3U.js";import"./file-text-BqTmF8A7.js";import"./wind-DLGZecZ6.js";const O={free:b,personal:b,caregiver:_,family:B,premium:M},C={free:"border-muted",personal:"border-primary/40",caregiver:"border-primary",family:"border-primary ring-2 ring-primary/20",premium:"border-primary ring-2 ring-primary/30"};function $e({onBack:f}){const{user:j}=E(),{tier:l,subscribed:y,loading:H,refreshSubscription:N}=R(),[t,g]=d.useState(!1),[a,m]=d.useState(null),w=async e=>{if(!j){p.error("Please sign in to subscribe.");return}m(e.tier);try{const s=t?e.annualPriceId:e.monthlyPriceId,{data:i,error:o}=await u.functions.invoke("create-checkout",{body:{priceId:s}});if(o)throw o;i!=null&&i.url&&window.open(i.url,"_blank")}catch(s){console.error("Checkout error:",s),p.error("Failed to start checkout. Please try again.")}finally{m(null)}},v=async()=>{m("manage");try{const{data:e,error:s}=await u.functions.invoke("customer-portal");if(s)throw s;e!=null&&e.url&&window.open(e.url,"_blank")}catch(e){console.error("Portal error:",e),p.error("Failed to open subscription management.")}finally{m(null)}},k=[F.free,...L];return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsxs("div",{className:"sticky top-0 z-10 bg-background/95 backdrop-blur-sm border-b px-4 py-3 flex items-center gap-3",children:[r.jsx(n,{variant:"ghost",size:"icon",onClick:f,children:r.jsx($,{className:"h-5 w-5"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-bold",children:"Subscription Plans"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose the plan that fits your needs"})]})]}),r.jsxs("div",{className:"px-4 py-4 space-y-4 pb-24",children:[r.jsxs("div",{className:"flex items-center justify-center gap-3 py-2",children:[r.jsx("span",{className:`text-sm font-medium ${t?"text-muted-foreground":"text-foreground"}`,children:"Monthly"}),r.jsx(A,{checked:t,onCheckedChange:g}),r.jsx("span",{className:`text-sm font-medium ${t?"text-foreground":"text-muted-foreground"}`,children:"Annual"}),t&&r.jsx(x,{variant:"secondary",className:"text-xs bg-green-100 text-green-800 border-green-200",children:"Save 25%"})]}),k.map(e=>{const s=O[e.tier],i=e.tier===l,o=e.tier==="free",S=t?e.annualPrice:e.monthlyPrice,c=t&&e.annualPrice>0?(e.annualPrice/12).toFixed(2):null;return r.jsxs(T,{className:`p-4 relative ${C[e.tier]} ${i?"bg-primary/5":""}`,children:[i&&r.jsx(x,{className:"absolute -top-2 right-4 bg-primary text-primary-foreground text-xs",children:"Your Plan"}),r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"p-2 rounded-lg bg-primary/10 shrink-0",children:r.jsx(s,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"font-bold text-base",children:e.name}),r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.description}),r.jsx("div",{className:"mt-2",children:o?r.jsx("span",{className:"text-2xl font-bold",children:"Free"}):r.jsxs("div",{children:[r.jsxs("span",{className:"text-2xl font-bold",children:["$",S.toFixed(2)]}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["/",t?"year":"month"]}),c&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["($",c,"/mo)"]})]})}),r.jsx("ul",{className:"mt-3 space-y-1.5",children:e.features.map((P,I)=>r.jsxs("li",{className:"flex items-start gap-2 text-xs",children:[r.jsx(z,{className:"h-3.5 w-3.5 text-primary shrink-0 mt-0.5"}),r.jsx("span",{children:P})]},I))}),r.jsx("div",{className:"mt-3",children:i?y?r.jsxs(n,{variant:"outline",size:"sm",className:"w-full",onClick:v,disabled:a==="manage",children:[a==="manage"?r.jsx(h,{className:"h-4 w-4 animate-spin mr-2"}):null,"Manage Subscription"]}):r.jsx(n,{variant:"outline",size:"sm",className:"w-full",disabled:!0,children:"Current Plan"}):o?null:r.jsxs(n,{size:"sm",className:"w-full",onClick:()=>w(e),disabled:a===e.tier,children:[a===e.tier?r.jsx(h,{className:"h-4 w-4 animate-spin mr-2"}):null,l!=="free"&&!o?"Switch Plan":"Get Started"]})})]})]})]},e.tier)}),r.jsxs("p",{className:"text-center text-xs text-muted-foreground pt-2",children:["After subscribing, your plan updates automatically within a minute.",r.jsx("button",{onClick:N,className:"text-primary ml-1 underline",children:"Refresh n
1ow"})]})]})]})}export{$e as default};
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.