1import{j as e,u}from"./vendor-query-D4uPiuyR.js";import{N,L as g}from"./vendor-react-BRGhWmg7.js";import{i as m,R as x,gr as _,t as b,v as w,w as l,x as o,a8 as p,av as h,ah as f,E as j,h as n,l as c,cu as d,B as v,aR as R,c as y,d as E,fg as M,gx as S,ar as C}from"./index-DkeiDCNA.js";import{S as D}from"./SEO-D_UhwQfH.js";import"./vendor-stripe-BHvYnncw.js";import{R as L}from"./RedeemCodeForm-C8sZ3IIW.js";import{S as q}from"./SettingsLayout-ybZFFySq.js";import"./AnswerEngineEditor-C65Bxl-z.js";import"./vendor-ui-D3k8NXhB.js";import"./vendor-supabase-BlYwxiTD.js";import"./vendor-charts-LoX2Ulxq.js";import"./vendor-editor-DbblO3Sp.js";import"./useSettingsEditors-1wS1bBLp.js";import"./builder-CGHwO2gV.js";const F={active:"default",past_due:"destructive",canceled:"secondary",expired:"outline",inactive:"outline"};function ee(){return!m("preferences")||!m("membership")?e.jsx(N,{to:x.HOME,replace:!0}):e.jsxs(_,{children:[e.jsx(D,{title:"Your access",description:"View your subscriptions, redeemed codes, and orders in one place."}),e.jsx(q,{title:"Access",children:e.jsx(k,{})})]})}function k(){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Everything you have access to â from paid subscriptions to redeemed gift codes â in one place."}),e.jsxs(b,{defaultValue:"subscriptions",className:"w-full",children:[e.jsxs(w,{children:[e.jsx(l,{value:"subscriptions",children:"Subscriptions"}),e.jsx(l,{value:"codes",children:"Redeemed Codes"}),e.jsx(l,{value:"orders",children:"Orders"})]}),e.jsx(o,{value:"subscriptions",className:"mt-4",children:e.jsx(O,{})}),e.jsxs(o,{value:"codes",className:"mt-4 space-y-6",children:[e.jsx(T,{}),e.jsxs("div",{className:"border-t pt-4 space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Have a new code?"}),e.jsx(L,{})]})]}),e.jsx(o,{value:"orders",className:"mt-4",children:e.jsx(A,{})})]})]})}function O(){const{user:s}=p(),{data:t,isLoading:a}=u({queryKey:["my-subscriptions",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return[];const{data:r,error:i}=await h.from("user_subscriptions").select("id, product_slug, status, source, current_period_start, current_period_end, canceled_at, created_at").eq("user_id",s.id).order("created_at",{ascending:!1});if(i)throw i;return r??[]},enabled:!!(s!=null&&s.id)});return a?e.jsx(f,{variant:"spinner"}):t!=null&&t.length?e.jsx("div",{className:"space-y-3",children:t.map(r=>e.jsx(n,{children:e.jsxs(c,{className:"p-4 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium capitalize",children:r.product_slug.replace(/-/g," ")}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Started ",d(new Date(r.created_at),"MMM d, yyyy"),r.current_period_end&&e.jsxs(e.Fragment,{children:[" · Renews ",d(new Date(r.current_period_end),"MMM d, yyyy")]}),r.canceled_at&&e.jsxs(e.Fragment,{children:[" · Canceled ",d(new Date(r.canceled_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground capitalize",children:["Source: ",r.source]})]}),e.jsx(v,{variant:F[r.status]??"outline",className:"capitalize",children:r.status.replace(/_/g," ")})]})},r.id))}):e.jsx(j,{title:"No subscriptions yet",description:"When you subscribe to a product, it will appear here."})}function T(){const{user:s}=p(),{data:t,isLoading:a}=u({queryKey:["my-redeemed-codes",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return[];const{data:r,error:i}=await h.from("redemption_codes").select("id, code, redeemed_at, product_id, products(name, slug)").eq("redeemed_by_user_id",s.id).order("redeemed_at",{ascending:!1});if(i)throw i;return r??[]},enabled:!!(s!=null&&s.id)});return a?e.jsx(f,{variant:"spinner"}):t!=null&&t.length?e.jsx("div",{className:"space-y-3",children:t.map(r=>{var i;return e.jsx(n,{children:e.jsxs(c,{className:"p-4 flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium",children:((i=r.products)==null?void 0:i.name)??r.code}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:r.code}),r.redeemed_at&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Redeemed ",d(new Date(r.redeemed_at),"MMM d, yyyy")]})]}),e.jsx(v,{variant:"secondary",children:"Redeemed"})]})},r.id)})}):e.jsx(j,{title:"No codes redeemed",description:"Codes you redeem will appear here."})}function A(){return m("membership.fulfillment")?e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{}),e.jsx(g,{to:x.PREFERENCES.ORDERS,className:"block",children:e.jsx(n,{className:"hover:bg-muted/40 transition-colors",children:e.jsxs(c,{className:"p-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Full order history"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Track shipments, view tracking numbers, manage all orders."})]})]}),e.jsxs(y,{variant:"ghost",size:"sm",className:"gap-1.5",children:["View ",e.jsx(E,{className:"h-4 w-4"})]})]})})})]}):e.jsx(j,{title:"No orders",description:"Physical product orders are not enabled."})}function P(){const{user:s}=p(),{data:t,isLoading:a}=u({queryKey:["my-digital-orders",s==null?void 0:s.id],queryFn:async()=>
1{if(!(s!=null&&s.id))return[];const{data:r,error:i}=await h.from("fulfillment_orders").select("id, product_slug, created_at, products!inner(name, slug, fulfillment_provider)").eq("user_id",s.id).eq("products.fulfillment_provider","digital_email").is("deleted_at",null).order("created_at",{ascending:!1}).limit(10);if(i)throw i;return r??[]},enabled:!!(s!=null&&s.id)});return a?e.jsx(f,{variant:"spinner"}):t!=null&&t.length?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Digital downloads"}),t.map(r=>{var i;return e.jsx(n,{children:e.jsxs(c,{className:"p-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:((i=r.products)==null?void 0:i.name)??r.product_slug}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Ordered ",d(new Date(r.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(z,{orderId:r.id}),e.jsx(y,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:M(x.PREFERENCES.ORDER_DETAIL,{id:r.id}),children:"Details"})})]})]})},r.id)})]}):null}function z({orderId:s}){const t=S();return e.jsxs(y,{variant:"outline",size:"sm",disabled:t.isPending,onClick:()=>t.mutate(s),children:[e.jsx(C,{className:"h-4 w-4 mr-1"}),t.isPending?"Sendingâ¦":"Resend link"]})}export{ee 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.