1import{n as ie,r as i,j as e,L as g}from"./react-vendor-BDHNqS4B.js";import{u as re,A as le}from"./AccountHomeShell-BmqDkQJS.js";import{A as K}from"./AppDownloadCTA-DAEixTy3.js";import{U as ue}from"./UserReviewList-BdFHL_bd.js";import{u as de,e as me,h as he,B as u,D as L,j as S,k,l as D,m as q,L as d,I as m,o as pe,n as xe,b as je,b0 as h,aC as fe}from"./main-m_sUF2N4.js";import{u as ge}from"./useSEO-CoArDrdl.js";import{G as ve,M as Pe,J as Ne,v,N as ye,O as z,P as we,Q as _e,T as Ce}from"./Header-BkbupWq-.js";import{P as Ae}from"./plus-D0NAkfqS.js";import{C as be}from"./camera-DiII9OQn.js";import"./amplify-DYDcjoow.js";import"./Footer-CtylQEAH.js";import"./textarea-D7qsgB_p.js";import"./reportService-tEzofQZ6.js";import"./phone-B2rvvDkK.js";import"./type-CVgQCqWZ.js";import"./query-7-WHkg5t.js";import"./userReviewApi-BPRYI5-q.js";import"./priceReviewApi-BFijUeFQ.js";import"./chevron-right-CpkQxGj-.js";import"./star-Dim9pf51.js";import"./check-DS0-tR9o.js";import"./tag-D40gy_Nl.js";const Le={dog:"petTag.speciesValues.dog",dogs:"petTag.speciesValues.dogs",cat:"petTag.speciesValues.cat",cats:"petTag.speciesValues.cats"};function Se(a,p){if(!a)return"";const r=new Date(a);if(Number.isNaN(r.getTime()))return"";const c=new Date;let l=(c.getFullYear()-r.getFullYear())*12+(c.getMonth()-r.getMonth());return c.getDate()<r.getDate()&&(l-=1),l<0?"":l<12?p("accountProfile.ageMonths",{count:Math.max(l,0)}):p("accountProfile.ageYears",{count:Math.floor(l/12)})}const $e=()=>{const{t:a}=de(),p=ie(),{isAuthenticated:r,userInfo:c,setIsAuthenticated:l}=me(),{openPanel:F}=he(),P=c==null?void 0:c.userId,{data:s}=ve(),{data:N=[]}=re(),y=Pe(),[J,x]=i.useState(!1),[Q,w]=i.useState(!1),[n,R]=i.useState(null),[_,U]=i.useState(""),[C,O]=i.useState(""),[A,T]=i.useState(""),[E,M]=i.useState(""),[W,B]=i.useState(null),[j,H]=i.useState(null),I=i.useRef(null);ge({title:`${a("accountProfile.title")} | PetWell`,description:a("accountProfile.seoDescription"),canonicalUrl:"https://petwellhk.com/account",noindex:!0}),i.useEffect(()=>{r===!1&&F("LANDING")},[r,F]),i.useEffect(()=>()=>{j&&URL.revokeObjectURL(j)},[j]);const X=Ne(s,c==null?void 0:c.username)||(c==null?void 0:c.email)||"",G=(s==null?void 0:s.email)||(c==null?void 0:c.rawEmail)||(c==null?void 0:c.email)||"",$=v(s==null?void 0:s.profileImage),Z=(X||G||"?").charAt(0).toUpperCase(),b=(s==null?void 0:s.pets)??[],ee=N.slice(0,2),ae=()=>{U((s==null?void 0:s.firstName)||""),O((s==null?void 0:s.lastName)||""),T(_e(s==null?void 0:s.phone)),M((s==null?void 0:s.address)||""),B(null),H(t=>(t&&URL.revokeObjectURL(t),null)),x(!0)},te=t=>{t&&(B(t),H(o=>(o&&URL.revokeObjectURL(o),URL.createObjectURL(t))))},se=async()=>{if(!_.trim()){h({title:a("accountProfile.firstNameRequired"),variant:"destructive"});return}if(!C.trim()){h({title:a("accountProfile.lastNameRequired"),variant:"destructive"});return}if(!Ce(A)){h({title:a("accountProfile.phoneInvalid"),variant:"destructive"});return}try{await y.mutateAsync({firstName:_,lastName:C,phone:A,address:E,avatarFile:W}),x(!1),h({title:a("accountProfile.saveSuccess")})}catch(t){console.error("Failed to update account profile",t),h({title:a("accountProfile.saveFailed"),variant:"destructive"})}},ce=async()=>{try{await fe(),l(!1),p("/")}catch(t){console.error("Logout error:",t)}},ne=t=>{if(!t)return"";const o=Le[t.trim().toLowerCase()];return o?a(o):t},V=t=>{var f;return[(f=t.breed)==null?void 0:f.trim(),ne(t.species),Se(t.birthdate,a),typeof t.weight=="number"&&t.weight>0?a("accountProfile.weightKg",{weight:t.weight}):""].filter(Boolean).join(" · ")},Y=j||$,oe=b.length<ye;return e.jsxs(e.Fragment,{children:[e.jsx(le,{tab:"profile",onEditProfile:ae,children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{className:"account-home-reveal",children:[e.jsx("p",{className:"account-home-kicker",children:a("accountProfile.myPets")}),b.length===0?e.jsxs("div",{className:"account-home-empty",children:[e.jsx("h3",{children:a("accountProfile.noPets")}),e.jsx("p",{children:a("accountProfile.noPetsHint")}),e.jsx("div",{className:"account-home-empty__actions",children:e.jsx(u,{onClick:()=>w(!0),children:a("accountProfile.addPet")})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"account-home-family",children:[b.map(t=>{const o=v(t.profileImage),f=z(t,P);return e.jsxs("button",{type:"button",className:"account-home-pet",onClick:()=>R(t),children:[e.jsxs("span",{className:"account-home-pet__photo",children:[o?e.jsx("img",{src:o,alt:""}):e.jsx("span",{className:"account-home-pet__fallback",children:t.name.charAt(0)}),f?e.jsx("span",{className:"account-home-pet__badge",title:a("accountProfile.sharedBadge")}):null]}),e.jsx("span",{className:"account-home-pet__name",children:t.name})]},t.id)}),oe?e.jsxs("button",{type:"button",className:"account-home-pet account-home-pet--add",onClick:()=>w(!0),children:[e.jsx("span",{className:"account-home-pet__photo",children:e.jsx(Ae,{className:"h-5 w-5"})}),e.jsx("span",{className:"account-home-pet__name",children:a("accountProfile.addPet")})]}):null]}),e.jsx("p",{className:"account-home-hint",children:a("accountProfile.appHint")})]})]}),e.jsxs("section",{className:"account-home-reveal",children:[e.jsxs("div",{className:"account-home-teaser",children:[e.jsx("h2",{children:a("accountProfile.reviewsTeaser")}),N.length>0?e.jsx(g,{to:"/account/reviews",children:a("accountProfile.reviewsTeaserCta")}):null]}),N.length===0?e.jsxs("div",{className:"account-home-empty",children:[e.jsx("p",{children:a("accountProfile.reviewsTeaserEmpty")}),e.jsxs("div",{className:"account-home-empty__actions",children:[e.jsx(u,{variant:"outline",asChild:!0,children:e.jsx(g,{to:"/restaurants",children:a("userReviews.emptyCtaRestaurants")})}),e.jsx(u,{variant:"outline",asChild:!0,children:e.jsx(g,{to:"/clinics",children:a("userReviews.emptyCtaClinics")})})]})]}):e.jsx(ue,{reviews:ee,variant:"journal",showAnonymousBadge:!0})]}),e.jsx("section",{className:"account-home-reveal",children:e.jsxs("div",{className:"account-home-foot",children:[e.jsx("button",{type:"button",onClick:ce,children:a("auth.logout")}),e.jsx(g,{to:"/delete-account",className:"account-home-foot__danger",children:a("accountProfile.deleteAccount")}
1)]})})]})}),e.jsx(L,{open:J,onOpenChange:x,children:e.jsxs(S,{className:"max-h-[90vh] overflow-y-auto",children:[e.jsxs(k,{children:[e.jsx(D,{children:a("accountProfile.editProfile")}),e.jsx(q,{children:a("accountProfile.editProfileDesc")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>{var t;return(t=I.current)==null?void 0:t.click()},className:"relative","aria-label":a("accountProfile.changePhoto"),children:[e.jsx("span",{className:"account-home-portrait__ring account-home-portrait__ring--sm",children:Y?e.jsx("img",{src:Y,alt:""}):e.jsx("span",{"aria-hidden":!0,children:Z})}),e.jsx("span",{className:"absolute -bottom-1 -right-1 flex h-7 w-7 items-center justify-center rounded-full bg-primary text-primary-foreground shadow",children:e.jsx(be,{className:"h-3.5 w-3.5"})})]}),e.jsx("input",{ref:I,type:"file",accept:"image/*",className:"sr-only",onChange:t=>{var o;return te((o=t.target.files)==null?void 0:o[0])}})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"account-first-name",children:a("accountProfile.firstName")}),e.jsx(m,{id:"account-first-name",value:_,onChange:t=>U(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"account-last-name",children:a("accountProfile.lastName")}),e.jsx(m,{id:"account-last-name",value:C,onChange:t=>O(t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"account-email",children:a("accountProfile.email")}),e.jsx(m,{id:"account-email",value:G,disabled:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("accountProfile.emailReadOnly")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"account-phone",children:a("accountProfile.phone")}),e.jsx(m,{id:"account-phone",inputMode:"numeric",value:A,onChange:t=>T(t.target.value.replace(/\D/g,"").slice(0,8))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("accountProfile.phoneHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"account-address",children:a("accountProfile.address")}),e.jsx(m,{id:"account-address",value:E,onChange:t=>M(t.target.value)})]})]}),e.jsxs(pe,{children:[e.jsx(u,{variant:"outline",onClick:()=>x(!1),children:a("accountProfile.cancel")}),e.jsx(u,{onClick:se,disabled:y.isPending,children:y.isPending?e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:je("mr-2 h-4 w-4 animate-spin")}),a("accountProfile.saving")]}):a("accountProfile.save")})]})]})}),e.jsx(L,{open:!!n,onOpenChange:t=>!t&&R(null),children:e.jsx(S,{children:n?e.jsxs(e.Fragment,{children:[e.jsx(k,{children:e.jsx(D,{className:"sr-only",children:n.name})}),e.jsxs("div",{className:"account-home-pet-sheet",children:[e.jsx("div",{className:"account-home-pet-sheet__photo",children:v(n.profileImage)?e.jsx("img",{src:v(n.profileImage),alt:""}):e.jsx("span",{className:"account-home-pet-sheet__fallback",children:n.name.charAt(0)})}),e.jsx("h3",{children:n.name}),V(n)?e.jsx("p",{className:"account-home-pet-sheet__facts",children:V(n)}):null,z(n,P)?e.jsx("p",{className:"account-home-pet-sheet__facts",children:a("accountProfile.sharedBadge")}):null,we(n,P)?e.jsx("p",{className:"account-home-pet-sheet__facts",children:a("accountProfile.sharingBadge")}):null]}),e.jsx(K,{title:a("accountProfile.managePetInApp",{name:n.name}),description:a("accountProfile.appHint")})]}):null})}),e.jsx(L,{open:Q,onOpenChange:w,children:e.jsxs(S,{children:[e.jsxs(k,{children:[e.jsx(D,{children:a("accountProfile.downloadGateTitle")}),e.jsx(q,{children:a("accountProfile.downloadGateBody")})]}),e.jsx(K,{title:a("accountProfile.addPet"),description:a("accountProfile.noPetsHint")})]})})]})};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.