1import{_ as M}from"./BodJxGTV.js";import{e as O,h as J,B as Y,m as b,C as H,D as W,E as C,G as K,H as Q,I as X,c as a,a as t,l as u,n as N,b as i,d as g,y as Z,F as B,q as ee,J as te,w as I,t as c,r as D,f as se,p as oe,o as l,g as re}from"./D3mXZbvm.js";import{u as ae}from"./BkGBxuuy.js";import{I as x}from"./CSXwf1OI.js";import{B as E}from"./CbyiM6aK.js";import"./D0HDmefO.js";const le={class:"min-h-screen bg-gray-50 py-8 px-4"},ne={class:"mx-auto max-w-3xl"},ie={class:"border-b border-gray-200 mb-8"},de={class:"-mb-px flex space-x-8","aria-label":"Tabs"},ue={key:0,class:"bg-white shadow-xl rounded-2xl p-6 md:p-8 border border-gray-200"},ce={class:"w-full"},pe={key:0,class:"mb-8 p-4 bg-blue-50 border border-blue-100 rounded-2xl flex items-start gap-3"},me={class:"flex items-center gap-2 py-2"},be={class:"pt-6 border-t border-gray-100"},ye={key:0,class:"mb-6"},ge={class:"flex flex-col sm:flex-row items-center gap-4"},fe={key:0,class:"text-sm text-green-600 font-black uppercase tracking-wide"},xe={key:1,class:"text-sm text-red-600 font-black uppercase tracking-wide"},ve={key:1,class:"bg-white shadow-xl rounded-2xl p-6 md:p-8 border border-gray-200"},we={key:0,class:"overflow-x-auto"},he={class:"w-full text-left border-collapse"},ke={class:"py-4 px-2 text-sm text-gray-600"},_e={class:"py-4 px-2 text-sm text-gray-900 font-medium"},Pe={class:"py-4 px-2 text-sm text-gray-600"},Ce={class:"py-4 px-2 text-sm"},Ne={class:"py-4 px-2 text-right"},Ve={key:0,class:"mt-8 flex justify-center gap-2"},Se=["onClick"],Te={key:1,class:"text-center py-12"},Ue={class:"max-w-sm mx-auto"},Be={class:"w-16 h-16 bg-gray-50 rounded-2xl flex items-center justify-center mx-auto mb-4"},Ie={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-2xl text-sm text-red-600 font-black uppercase tracking-wide flex justify-between items-center"},$e=7,Ge=O({__name:"account",setup(qe){const R=se(),v=H(),d=J(),{request:V}=Y(),{formatShortDate:A}=ae(),y=b("profile"),f=b(!1),w=b(""),p=b(""),h=b(Number(v.query.page)||0),k=b([]),_=b(""),z={finalized:"Completed",refunded:"Refunded"},{data:S,refresh:$}=W("orders",async()=>{if(!d.token)return{items:[],totalCount:0,pageCount:0};try{return(await V(`/api/v3/me/orders?page=${h.value}&itemsPerPage=${$e}`,{method:"GET",headers:{Authorization:`Bearer ${d.token}`}})).data}catch(r){return console.error("Error fetching orders:",r),{items:[],totalCount:0,pageCount:0}}}),q=C(()=>S.value?.items||[]);C(()=>S.value?.totalCount||0);const T=C(()=>S.value?.pageCount||0),L=async(r,e)=>{try{k.value.push(r);const n=await V("/api/v3/me/orders/invoice/download",{method:"POST",headers:{Authorization:`Bearer ${d.token}`},body:JSON.stringify({id:r})});if(n.ok){const U=n.data instanceof Blob?n.data:new Blob([n.data],{type:"application/pdf"}),s=window.URL.createObjectURL(U),m=document.createElement("a");m.href=s,m.download=`invoice-${e}.pdf`,document.body.appendChild(m),m.click(),document.body.removeChild(m),window.URL.revokeObjectURL(s)}else _.value="Failed to download invoice"}catch(n){console.error("Download error:",n)}finally{k.value=k.value.filter(n=>n!==r)}},G=r=>{r>=0&&r<T.value&&(h.value=r,R.push({query:{...v.query,page:r+1}}),$())};K(()=>{v.query.page&&(h.value=Number(v.query.page)-1,$())});const o=Q({name:"",email:"",newPassword:"",retypeNewPassword:"",currentPassword:"",subscribedToNewsletter:!1}),P=C(()=>d.user?.type==="google");function j(){d.user&&(o.name=d.user.name||"",o.email=d.user.email||"",o.subscribedToNewsletter=!!d.user.subscribedToNewsletter)}X(()=>d.user,()=>{j()},{immediate:!0});async function F(){f.value=!0,w.value="",p.value="";try{const r={name:o.name,email:o.email,subscribedToNewsletter:o.subscribedToNewsletter};if(!P.value){if(!o.currentPassword){p.value="Current password is required to save changes.",f.value=!1;return}if(o.newPassword&&o.newPassword!==o.retypeNewPassword){p.value="New passwords do not match.",f.value=!1;return}r.currentPassword=o.currentPassword,o.newPassword&&(r.password=o.newPassword)}const e=await V("/api/v3/me/profile",{method:"PUT",body:JSON.stringify(r)});e.ok?(w.value="Profile updated successfully!",o.currentPassword="",o.newPassword="",o.retypeNewPassword="",await d.fetchProfile()):p.value=e.data?.message||"Failed to update profile."}catch(r){p.value=r?.message||"An unexpected error occurred."}finally{f.value=!1}}return(r,e)=>{const n=oe("font-awesome-icon"),U=M;return l(),a("div",le,[t("div",ne,[e[18]||(e[18]=t("h1",{class:"text-2xl md:text-3xl font-black text-gray-900 mb-6 uppercase tracking-tight"},"Account Settings",-1)),t("div",ie,[t("nav",de,[t("button",{onClick:e[0]||(e[0]=s=>y.value="profile"),class:N([y.value==="profile"?"border-primary text-primary":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700","whitespace-nowrap border-b-2 py-4 px-1 text-sm font-bold uppercase tracking-wide transition-colors"])}," Profile ",2),t("button",{onClick:e[1]||(e[1]=s=>y.value="invoice"),class:N([y.value==="invoice"?"border-primary text-primary":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700","whitespace-nowrap border-b-2 py-4 px-1 text-sm font-bold uppercase tracking-wide transition-colors"])}," Invoice ",2)])]),y.value==="profile"?(l(),a("div",ue,[t("div",ce,[e[12]||(e[12]=t("h2",{class:"text-xl font-black text-gray-900 mb-6 uppercase tracking-tight"},"Profile Information",-1)),P.value?(l(),a("div",pe,[i(n,{icon:"info-circle",class:"text-secondary mt-0.5"}),e[9]||(e[9]=t("p",{class:"text-sm text-blue-800"},[g(" Your account is linked with Google. You can manage your email and password in your "),t("a",{href:"https://myaccount.google.com/",target:"_blank",class:"font-bold underline"},"Google Account"),g(". ")],-1))])):u("",!0),t("form",{onSubmit:Z(F,["prevent"]),class:"space-y-6"},[i(x,{label:"Name",modelValue:o.name,"onUpdate:modelValue":e[2]||(e[2]=s=>o.name=s),placeholder:"Your name",required:!0,"label-class":"text-gray-700 font-semibold"},null,8,["modelValue"]),i(x,{label:"Email",modelValue:o.email,"onUpdate:modelValue":e[3]||(e[3]=s=>o.email=s),type:"email",disabled:!0,hint:"Email cannot be changed.","label-class":"text-gray-700 font-semibold"},null,8,["modelValue"]),P.value?u("",!0):(l(),a(B,{key:0},[i(x,{label:"New Password",modelValue:o.newPassword,"onUpdate:modelValue":e[4]||(e[4]=s=>o.newPassword=s),type:"password",placeholder:"Leave empty if not changing","label-class":"text-gray-700 font-semibold"},null,8,["modelValue"]),i(x,{label:"Retype New Password",modelValue:o.retypeNewPassword,"onUpdate:modelValue":e[5]||(e[5]=s=>o.retypeNewPassword=s),type:"password",placeholder:"Retype your new password","label-class":"text-gray-700 font-semibold"},null,8,["modelValue"])],64)),t("div",me,[ee(t("input",{id:"newsletter",type:"checkbox","onUpdate:modelValue":e[6]||(e[6]=s=>o.subscribedToNewsletter=s),class:"w-4 h-4 rounded border-gray-300 text-primary focus:ring-primary curs
1or-pointer"},null,512),[[te,o.subscribedToNewsletter]]),e[10]||(e[10]=t("label",{for:"newsletter",class:"text-sm font-semibold text-gray-700 cursor-pointer"},"Subscribe to newsletter",-1))]),t("div",be,[P.value?u("",!0):(l(),a("div",ye,[i(x,{label:"Current Password",modelValue:o.currentPassword,"onUpdate:modelValue":e[7]||(e[7]=s=>o.currentPassword=s),type:"password",placeholder:"Enter current password to save changes",required:!0,"label-class":"text-gray-700 font-semibold"},null,8,["modelValue"])])),t("div",ge,[i(E,{type:"submit",variant:"primary",size:"lg",block:"",class:"font-black py-3 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5",loading:f.value},{default:I(()=>[...e[11]||(e[11]=[g(" Save Changes ",-1)])]),_:1},8,["loading"]),w.value?(l(),a("p",fe,c(w.value),1)):u("",!0),p.value?(l(),a("p",xe,c(p.value),1)):u("",!0)])])],32)])])):y.value==="invoice"?(l(),a("div",ve,[q.value.length>0?(l(),a("div",we,[t("table",he,[e[14]||(e[14]=t("thead",null,[t("tr",{class:"border-b border-gray-100"},[t("th",{class:"py-4 px-2 text-sm font-semibold text-gray-900"},"Date"),t("th",{class:"py-4 px-2 text-sm font-semibold text-gray-900"},"Identifier"),t("th",{class:"py-4 px-2 text-sm font-semibold text-gray-900"},"Gross"),t("th",{class:"py-4 px-2 text-sm font-semibold text-gray-900"},"State"),t("th",{class:"py-4 px-2 text-sm font-semibold text-gray-900 text-right"},"Invoice")])],-1)),t("tbody",null,[(l(!0),a(B,null,D(q.value,s=>(l(),a("tr",{key:s.id,class:"border-b border-gray-50 last:border-0 hover:bg-gray-50 transition-colors"},[t("td",ke,c(re(A)(s.date)),1),t("td",_e,c(s.identifier),1),t("td",Pe,"$"+c(s.value),1),t("td",Ce,[t("span",{class:N(["px-2 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",s.state==="finalized"?"bg-green-100 text-green-700":"bg-gray-100 text-gray-600"])},c(z[s.state]||s.state),3)]),t("td",Ne,[i(E,{variant:"secondary",size:"sm",class:"font-black uppercase tracking-wide",onClick:m=>L(s.invoiceId,s.identifier),loading:k.value.includes(s.invoiceId)},{default:I(()=>[...e[13]||(e[13]=[g(" Download ",-1)])]),_:1},8,["onClick","loading"])])]))),128))])]),T.value>1?(l(),a("div",Ve,[(l(!0),a(B,null,D(T.value,s=>(l(),a("button",{key:s,onClick:m=>G(s-1),class:N(["w-8 h-8 rounded-lg text-sm font-black transition-colors",h.value===s-1?"bg-secondary text-white shadow-lg":"bg-white border border-gray-200 text-gray-400 hover:border-secondary hover:text-secondary"])},c(s),11,Se))),128))])):u("",!0)])):(l(),a("div",Te,[t("div",Ue,[t("div",Be,[i(n,{icon:"file-invoice",class:"text-gray-300 text-2xl"})]),e[16]||(e[16]=t("h3",{class:"mt-2 text-lg font-black text-gray-900 uppercase tracking-tight"},"No invoices yet",-1)),e[17]||(e[17]=t("p",{class:"mt-2 text-sm text-gray-500"},"When you make a purchase, your invoices will appear here.",-1)),i(U,{to:"/pricing",class:"mt-6 inline-block text-secondary font-black text-sm uppercase tracking-wide hover:underline"},{default:I(()=>[...e[15]||(e[15]=[g("Check out our pricing page",-1)])]),_:1})])])),_.value?(l(),a("div",Ie,[g(c(_.value)+" ",1),t("button",{onClick:e[8]||(e[8]=s=>_.value=""),class:"ml-2 hover:text-red-800 transition-colors"},[i(n,{icon:"times"})])])):u("",!0)])):u("",!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.