1import{d as E,B as I,K as O,P as Y,p as T,c as i,a as t,t as s,f as e,g as p,F as x,q,w as B,b as g,h as Z,v as G,T as Q,k as W,i as X,j as C,r as u,y as L,o as a,_ as ee,e as K,s as te}from"./C0XbLphV.js";import{_ as se}from"./BVEjrhUu.js";import{u as oe}from"./BQamZ7yO.js";const ne={class:"space-y-6"},ae={class:"grid gap-6 lg:grid-cols-2"},re={class:"rounded-2xl border bg-card p-6 shadow-sm"},ie={class:"flex items-start justify-between gap-3"},le={class:"text-lg font-semibold"},ce={key:0,class:"inline-flex rounded-full bg-amber-400 px-3 py-1 text-xs font-semibold text-white"},de={key:1,class:"inline-flex rounded-full bg-green-500 px-3 py-1 text-xs font-semibold text-white"},ue={key:0,class:"mt-4 h-24 animate-pulse rounded-xl bg-muted"},pe={key:0,class:"mt-4 text-2xl font-bold text-primary"},me={key:1,class:"mt-1 text-sm text-muted-foreground"},_e={key:2,class:"mt-4 text-sm text-muted-foreground"},be={key:3,class:"mt-4 text-sm text-muted-foreground"},fe={class:"mt-4 flex items-center gap-2 text-destructive"},xe={class:"text-xl font-semibold"},ge={class:"rounded-2xl border bg-card p-6 shadow-sm"},ye={class:"text-lg font-semibold"},he=["placeholder","onKeydown"],ve=["disabled"],ke={key:0,class:"mt-2 text-xs text-green-600 dark:text-green-400"},we={key:1,class:"mt-2 text-xs text-destructive"},$e={class:"rounded-2xl border bg-card p-6 shadow-sm"},De={class:"text-lg font-semibold"},Me={key:0,class:"mt-5 space-y-3"},Se={key:1,class:"mt-5 text-sm text-muted-foreground"},Ne={key:2,class:"mt-5 overflow-x-auto"},Ce={class:"w-full min-w-[560px] text-left text-sm"},Le={class:"border-b text-muted-foreground"},je={class:"pb-3 pr-4 font-normal"},ze={class:"pb-3 pr-4 font-normal"},Pe={class:"pb-3 pr-4 font-normal"},Fe={class:"pb-3 font-normal"},Te={class:"py-4 pr-4"},Be={class:"py-4 pr-4"},Ke={class:"py-4 pr-4"},Ve={class:"py-4"},Ae={key:0,class:"inline-flex rounded-md bg-green-100 px-2.5 py-1 text-xs font-medium text-green-700 dark:bg-green-500/15 dark:text-green-400"},He={key:1,class:"inline-flex rounded-md bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground"},Je={key:2,class:"inline-flex rounded-md bg-red-100 px-2.5 py-1 text-xs font-medium text-red-600 dark:bg-red-500/15 dark:text-red-400"},Re={key:3,class:"mt-6 flex items-center justify-center gap-1"},Ue=["disabled"],Ee=["onClick"],Ie=["disabled"],Ge=E({__name:"subscription",setup(Oe){const{$t:o}=I(),{locale:j}=O(),D=oe();Y({title:o("profile_nav.subscription"),meta:[{name:"robots",content:"noindex, nofollow"}]});const c=u(null),y=u(!0);T(async()=>{try{c.value=(await D.me()).data}catch{c.value=null}finally{y.value=!1}});const M=L(()=>{if(!c.value?.valid_until)return null;const n=new Date(c.value.valid_until).getTime()-Date.now();return n>0?Math.ceil(n/864e5):0}),V=L(()=>c.value?.active===!0&&M.value!==null&&M.value<=7),A=L(()=>c.value?.source!=="school"&&c.value?.source!=="corporate"),h=u([]),v=u(!0),m=u(1),_=u(1);async function S(n=1){v.value=!0;try{const r=await D.payments(n);h.value=r.data,m.value=r.meta?.current_page??n,_.value=r.meta?.last_page??1}catch{h.value=[],_.value=1}finally{v.value=!1}}T(()=>S(1));function N(n){n<1||n>_.value||n===m.value||S(n)}const b=u(""),k=u(!1),w=u(null),$=u(null);async function z(){const n=b.value.trim();if(!(!n||k.value)){k.value=!0,w.value=null,$.value=null;try{c.value=(await D.redeemPromocode(n)).data,$.value=o("subscription.promocode_applied"),b.value="",await S()}catch(r){w.value=r.message??o("subscription.promocode_invalid")}finally{k.value=!1}}}const P={kk:["ÒаңÑаÑ","аÒпан","наÑÑÑз","ÑÓÑÑÑ","мамÑÑ","маÑÑÑм","ÑÑлде","ÑамÑз","ÒÑÑкүйек","Òазан","ÒаÑаÑа","желÑоÒÑан"],ru:["ÑнваÑÑ","ÑевÑалÑ","маÑÑа","апÑелÑ","маÑ","иÑнÑ","иÑлÑ","авгÑÑÑа","ÑенÑÑбÑÑ","окÑÑбÑÑ","ноÑбÑÑ","декабÑÑ"],en:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]};function H(n){return n?new Date(n).toLocaleDateString("ru-RU"):""}function J(n){if(!n)return"â";const r=new Date(n),d=F=>String(F).padStart(2,"0"),f=P[j.value]??P.ru,l=`${d(r.getHours())}:${d(r.getMinutes())}`;return j.value==="en"?`${f[r.getMonth()]} ${r.getDate()}, ${r.getFullYear()}, ${l}`:`${r.getDate()} ${f[r.getMonth()]} ${r.getFullYear()}, ${l}`}function R(n){return n?o("subscription_page.period_months",{n:Math.max(1,Math.round(n/30))}):"â"}function U(n,r){const d=new Intl.NumberFormat("ru-RU",{maximumFractionDigits:0}).format(Number(n));return r==="KZT"?`${d} â¸`:`${d} ${r}`}return(n,r)=>{const d=ee,f=se;return a(),i("div",ne,[t("div",ae,[t("section",re,[t("div",ie,[t("h2",le,s(e(o)("profile_nav.subscription")),1),!e(y)&&e(V)?(a(),i("span",ce,s(e(o)("subscription_page.days_left",{n:e(M)??0})),1)):!e(y)&&e(c)?.active?(a(),i("span",de,s(e(o)("subscription.active")),1)):p("",!0)]),e(y)?(a(),i("div",ue)):e(c)?.active?(a(),i(x,{key:1},[e(c).plan?.name?(a(),i("p",pe,s(e(c).plan.name),1)):p("",!0),e(c).val
1id_until?(a(),i("p",me,s(e(o)("subscription.expires_at",{date:H(e(c).valid_until)})),1)):p("",!0),e(c)?.source==="school"?(a(),i("p",_e,s(e(o)("subscription.school_access")),1)):e(c)?.source==="corporate"?(a(),i("p",be,s(e(o)("subscription.corporate_access")),1)):p("",!0),e(A)?(a(),q(f,{key:4,to:"/subscription",class:"mt-5 flex w-full items-center justify-center gap-2 rounded-xl bg-primary py-3 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90"},{default:B(()=>[g(d,{name:"lucide:book-open",class:"size-4"}),K(" "+s(e(o)("subscription_page.renew")),1)]),_:1})):p("",!0)],64)):(a(),i(x,{key:2},[t("div",fe,[g(d,{name:"lucide:ban",class:"size-6"}),t("span",xe,s(e(o)("subscription_page.none")),1)]),g(f,{to:"/subscription",class:"mt-5 flex w-full items-center justify-center rounded-xl bg-primary py-3 text-sm font-semibold text-primary-foreground transition-colors hover:bg-primary/90"},{default:B(()=>[K(s(e(o)("subscription_page.subscribe")),1)]),_:1})],64))]),t("section",ge,[t("h2",ye,s(e(o)("subscription.promocode_label")),1),Z(t("input",{"onUpdate:modelValue":r[0]||(r[0]=l=>X(b)?b.value=l:null),type:"text",placeholder:e(o)("subscription.promocode_placeholder"),class:"mt-4 w-full rounded-xl border bg-background px-4 py-3 text-sm outline-none focus:border-primary",onKeydown:Q(W(z,["prevent"]),["enter"])},null,40,he),[[G,e(b)]]),t("button",{type:"button",disabled:e(k)||!e(b).trim(),class:"mt-3 w-full rounded-xl bg-primary/10 py-3 text-sm font-semibold text-primary transition-colors hover:bg-primary/20 disabled:opacity-50",onClick:z},s(e(o)("subscription.promocode_apply")),9,ve),e($)?(a(),i("p",ke,s(e($)),1)):p("",!0),e(w)?(a(),i("p",we,s(e(w)),1)):p("",!0)])]),t("section",$e,[t("h2",De,s(e(o)("subscription_page.history_title")),1),e(v)?(a(),i("div",Me,[(a(),i(x,null,C(3,l=>t("div",{key:l,class:"h-10 animate-pulse rounded-lg bg-muted"})),64))])):e(h).length?(a(),i("div",Ne,[t("table",Ce,[t("thead",null,[t("tr",Le,[t("th",je,s(e(o)("subscription_page.col_date")),1),t("th",ze,s(e(o)("subscription_page.col_plan")),1),t("th",Pe,s(e(o)("subscription_page.col_amount")),1),t("th",Fe,s(e(o)("subscription_page.col_status")),1)])]),t("tbody",null,[(a(!0),i(x,null,C(e(h),l=>(a(),i("tr",{key:l.id,class:"border-b last:border-0"},[t("td",Te,s(J(l.paid_at)),1),t("td",Be,s(l.kind==="book"?e(o)("subscription_page.book_purchase",{name:l.book?.name??""}):R(l.period_days)),1),t("td",Ke,s(U(l.amount,l.currency)),1),t("td",Ve,[l.status==="paid"?(a(),i("span",Ae,s(e(o)("subscription_page.status_paid")),1)):l.status==="refunded"?(a(),i("span",He,s(e(o)("subscription_page.status_refunded")),1)):(a(),i("span",Je,s(e(o)("subscription_page.status_failed")),1))])]))),128))])])])):(a(),i("p",Se,s(e(o)("subscription_page.history_empty")),1)),!e(v)&&e(_)>1?(a(),i("div",Re,[t("button",{type:"button",disabled:e(m)<=1,class:"flex size-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40","aria-label":"prev",onClick:r[1]||(r[1]=l=>N(e(m)-1))},[g(d,{name:"lucide:chevron-left",class:"size-4"})],8,Ue),(a(!0),i(x,null,C(e(_),l=>(a(),i("button",{key:l,type:"button",class:te(["flex size-9 items-center justify-center rounded-lg border text-sm font-medium transition-colors",l===e(m)?"border-primary bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"]),onClick:F=>N(l)},s(l),11,Ee))),128)),t("button",{type:"button",disabled:e(m)>=e(_),class:"flex size-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40","aria-label":"next",onClick:r[2]||(r[2]=l=>N(e(m)+1))},[g(d,{name:"lucide:chevron-right",class:"size-4"})],8,Ie)])):p("",!0)])])}}});export{Ge 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.