1import{f as I,c as z,b as D,r as x,j as e,H as F,L}from"./edge-BOITG1XR.js";const W=[["","Select countryâ¦"],["US","United States"],["GB","United Kingdom"],["DE","Germany"],["FR","France"],["NL","Netherlands"],["CA","Canada"],["AU","Australia"],["IN","India"],["AE","United Arab Emirates"],["SG","Singapore"],["IT","Italy"],["ES","Spain"],["BR","Brazil"],["JP","Japan"],["KR","South Korea"],["MX","Mexico"],["ZA","South Africa"],["CH","Switzerland"],["SE","Sweden"],["NO","Norway"],["DK","Denmark"],["BE","Belgium"],["IE","Ireland"],["PT","Portugal"],["PL","Poland"],["CZ","Czechia"],["AT","Austria"],["FI","Finland"],["NZ","New Zealand"],["HK","Hong Kong"],["MY","Malaysia"],["ID","Indonesia"],["TR","Turkey"],["SA","Saudi Arabia"],["EG","Egypt"],["NG","Nigeria"],["CL","Chile"],["CO","Colombia"],["AR","Argentina"]],U=["UTC","Europe/London","Europe/Berlin","Europe/Paris","Asia/Dubai","Asia/Kolkata","Asia/Bangkok","Asia/Singapore","Asia/Tokyo","Asia/Hong_Kong","Australia/Sydney","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Sao_Paulo"];function K(){const n=I(),[l,u]=z(),{notify:d,confirm:S}=D(),[a,j]=x.useState(null),A=["personal","address","notifications","security"].includes(l.get("tab"))?l.get("tab"):"personal",[p,k]=x.useState(A),T=t=>{k(t),u({tab:t},{replace:!0})},[h,m]=x.useState(!1),[c,y]=x.useState({current_password:"",new_password:"",new_password_confirmation:""});x.useEffect(()=>{const t=localStorage.getItem("token");if(!t){n("/auth/login?next=/profile");return}fetch("/api/my/profile",{headers:{Authorization:`Bearer ${t}`}}).then(o=>o.status===401?(n("/auth/login?next=/profile"),null):o.json()).then(o=>o&&j(o.profile))},[n]);function s(t,o){j({...a,[t]:o})}async function _(t){m(!0);const o=localStorage.getItem("token"),g=await fetch("/api/my/profile",{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(t)});m(!1);const f=await g.json();g.ok?(j(f.profile),d({title:"Saved",tone:"success"})):d({title:"Save failed",body:Object.values(f.errors||{})[0]?.[0]||"Try again.",tone:"error"})}async function N(){_({first_name:a.first_name,last_name:a.last_name,email:a.email,phone:a.phone,company_name:a.company_name,tax_id:a.tax_id})}async function P(){_({address_line1:a.address_line1,address_line2:a.address_line2,city:a.city,state:a.state,postcode:a.postcode,country:a.country,timezone:a.timezone})}async function B(){_({notify_invoices:a.notify_invoices,notify_tickets:a.notify_tickets,notify_services:a.notify_services,notify_marketing:a.notify_marketing})}async function E(t){if(t.preventDefault(),c.new_password!==c.new_password_confirmation){d({title:"Passwords do not match",tone:"error"});return}m(!0);const o=localStorage.getItem("token"),g=await fetch("/api/my/password",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(c)});m(!1);const f=await g.json();g.ok?(d({title:"Password changed",tone:"success"}),y({current_password:"",new_password:"",new_password_confirmation:""})):d({title:"Change failed",body:f.error||"Try again.",tone:"error"})}return a?e.jsxs(e.Fragment,{children:[e.jsxs(F,{children:[e.jsx("title",{children:"My profile | SendUnlimitedEmail"}),e.jsx("meta",{name:"robots",content:"noindex"})]}),e.jsx("section",{style:{padding:"32px 0 16px",background:"linear-gradient(180deg, #F8FAFC 0%, white 100%)",borderBottom:"1px solid var(--sue-border)"},children:e.jsxs("div",{className:"sue-container",children:[e.jsx(L,{to:"/dashboard",style:{fontSize:13,color:"var(--sue-blue-600)",textDecoration:"none",fontWeight:600},children:"â Back to dashboard"}),e.jsxs("div",{style:{display:"flex",gap:16,alignItems:"center",marginTop:12,flexWrap:"wrap"},children:[e.jsx(q,{name:a.name||a.email,size:56}),e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"clamp(22px, 3vw, 28px)",fontWeight:800,margin:0,letterSpacing:"-0.02em"},children:a.name||a.email}),e.jsxs("div",{style:{fontSize:13,color:"var(--sue-text-muted)",marginTop:4},children:[a.email," · joined ",new Date(a.created_at).toLocaleDateString(),parseFloat(a.credit_balance)>0&&e.jsxs("span",{style:{marginLeft:12,color:"#16A34A",fontWeight:700},children:["· $",parseFloat(a.credit_balance).toFixed(2)," credit"]})]})]})]})]})}),e.jsx("section",{style:{padding:"24px 0 64px"},children:e.jsxs("div",{className:"sue-container",style:{maxWidth:880},children:[e.jsx("div",{style:{display:"flex",gap:4,marginBottom:20,borderBottom:"1px solid var(--sue-border)",overflowX:"auto"},children:[["personal","Personal info"],["address","Billing address"],["notifications","Email preferences"],["security","Security"]].map(([t,o])=>e.jsx("button",{type:"button",onClick:()=>T(t),style:{padding:"10px 18px",fontSize:13.5,fontWeight:600,background:"transparent",color:p===t?"var(--sue-blue-600)":"var(--sue-text-muted)",border:"none",borderBottom:`2px solid ${p===t?"var(--sue-blue-600)":"transparent"}`,cursor:"pointer",whiteSpace:"nowrap"},children:o},t))}),p==="personal"&&e.jsxs(v,{children:[e.jsxs(C,{children:[e.jsx(i,{label:"First name",required:!0,children:e.jsx("input",{required:!0,value:a.first_name||"",onChange:t=>s("first_name",t.target.value),style:r})}),e.jsx(i,{label:"Last name (optional)",children:e.jsx("input",{value:a.last_name||"",onChange:t=>s("last_name",t.target.value),style:r,placeholder:"Leave blank to use your first name"})}),e.jsx(i,{label:"Email",full:!0,required:!0,children:e.jsx("input",{type:"email",required:!0,value:a.email||"",onChange:t=>s("email",t.target.value),style:r})}
1),e.jsx(i,{label:"Phone",children:e.jsx("input",{value:a.phone||"",onChange:t=>s("phone",t.target.value),style:r,placeholder:"+1 555 1234"})}),e.jsx(i,{label:"Tax ID / VAT",children:e.jsx("input",{value:a.tax_id||"",onChange:t=>s("tax_id",t.target.value),style:r})}),e.jsx(i,{label:"Company name",full:!0,children:e.jsx("input",{value:a.company_name||"",onChange:t=>s("company_name",t.target.value),style:r})})]}),e.jsx(w,{busy:h,onSave:N})]}),p==="address"&&e.jsxs(v,{children:[e.jsxs(C,{children:[e.jsx(i,{label:"Address line 1",full:!0,children:e.jsx("input",{value:a.address_line1||"",onChange:t=>s("address_line1",t.target.value),style:r})}),e.jsx(i,{label:"Address line 2",full:!0,children:e.jsx("input",{value:a.address_line2||"",onChange:t=>s("address_line2",t.target.value),style:r})}),e.jsx(i,{label:"City",children:e.jsx("input",{value:a.city||"",onChange:t=>s("city",t.target.value),style:r})}),e.jsx(i,{label:"State / Region",children:e.jsx("input",{value:a.state||"",onChange:t=>s("state",t.target.value),style:r})}),e.jsx(i,{label:"Postal code",children:e.jsx("input",{value:a.postcode||"",onChange:t=>s("postcode",t.target.value),style:r})}),e.jsx(i,{label:"Country",children:e.jsx("select",{value:a.country||"",onChange:t=>s("country",t.target.value),style:r,children:W.map(([t,o])=>e.jsx("option",{value:t,children:o},t))})}),e.jsx(i,{label:"Timezone",full:!0,children:e.jsx("select",{value:a.timezone||"UTC",onChange:t=>s("timezone",t.target.value),style:r,children:U.map(t=>e.jsx("option",{value:t,children:t},t))})})]}),e.jsx(w,{busy:h,onSave:P})]}),p==="notifications"&&e.jsxs(v,{children:[e.jsxs("div",{style:{padding:20,display:"flex",flexDirection:"column",gap:14},children:[e.jsx(b,{label:"Invoice notifications",sub:"Issued, paid, reminders, overdue",value:a.notify_invoices,onChange:t=>s("notify_invoices",t)}),e.jsx(b,{label:"Service notifications",sub:"Provisioning, activated, suspended, cancelled",value:a.notify_services,onChange:t=>s("notify_services",t)}),e.jsx(b,{label:"Support ticket replies",sub:"When staff replies or your ticket is closed",value:a.notify_tickets,onChange:t=>s("notify_tickets",t)}),e.jsx(b,{label:"Marketing & announcements",sub:"New features, price changes, blog posts",value:a.notify_marketing,onChange:t=>s("notify_marketing",t)})]}),e.jsx(w,{busy:h,onSave:B})]}),p==="security"&&e.jsxs(v,{children:[e.jsxs("form",{onSubmit:E,style:{padding:20,display:"flex",flexDirection:"column",gap:12,maxWidth:420},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,marginBottom:4},children:"Change password"}),e.jsx(i,{label:"Current password",required:!0,children:e.jsx("input",{type:"password",value:c.current_password,onChange:t=>y({...c,current_password:t.target.value}),required:!0,style:r})}),e.jsx(i,{label:"New password",required:!0,children:e.jsx("input",{type:"password",value:c.new_password,onChange:t=>y({...c,new_password:t.target.value}),required:!0,minLength:8,style:r})}),e.jsx(i,{label:"Confirm new password",required:!0,children:e.jsx("input",{type:"password",value:c.new_password_confirmation,onChange:t=>y({...c,new_password_confirmation:t.target.value}),required:!0,style:r})}),e.jsx("button",{disabled:h,type:"submit",className:"sue-btn sue-btn-primary",style:{alignSelf:"flex-start"},children:h?"Savingâ¦":"Update password"})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--sue-border)",padding:20,fontSize:13.5},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:4},children:"Two-factor authentication"}),e.jsx("div",{style:{color:"var(--sue-text-muted)",marginBottom:8},children:a.two_factor_enabled?"Enabled â app code required at login.":"Not enabled â protect your account with an authenticator app."}),e.jsx("button",{type:"button",disabled:!0,className:"sue-btn sue-btn-outline sue-btn-sm",children:"Coming soon"})]})]})]})})]}):e.jsx(R,{children:"Loading profileâ¦"})}function q({name:n,size:l}){const u=(n||"?").trim().charAt(0).toUpperCase();return e.jsx("div",{style:{width:l,height:l,borderRadius:"50%",background:"linear-gradient(135deg, var(--sue-blue-600), var(--sue-teal-600))",color:"white",display:"grid",placeItems:"center",fontWeight:800,fontSize:l*.45},children:u})}function v({children:n}){return e.jsx("div",{style:{background:"white",border:"1px solid var(--sue-border)",borderRadius:12,overflow:"hidden"},children:n})}function C({children:n}){return e.jsx("div",{style:{padding:20,display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:n})}function i({label:n,full:l,required:u,children:d}){return e.jsxs("div",{style:{gridColumn:l?"1 / -1":"auto"},children:[e.jsxs("label",{style:{fontSize:11,fontWeight:600,color:"var(--sue-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em",display:"block",marginBottom:6},children:[n," ",u&&e.jsx("span",{style:{color:"#DC2626"},children:"*"})]}),d]})}function b({label:n,sub:l,value:u,onChange:d}){return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",ga
1p:12,cursor:"pointer",padding:"8px 0"},children:[e.jsx("input",{type:"checkbox",checked:!!u,onChange:S=>d(S.target.checked),style:{marginTop:3,width:18,height:18,accentColor:"var(--sue-blue-600)"}}),e.jsxs("span",{children:[e.jsx("div",{style:{fontWeight:700,fontSize:14},children:n}),e.jsx("div",{style:{fontSize:12.5,color:"var(--sue-text-muted)"},children:l})]})]})}function w({busy:n,onSave:l}){return e.jsx("div",{style:{borderTop:"1px solid var(--sue-border)",padding:"14px 20px",textAlign:"right"},children:e.jsx("button",{type:"button",disabled:n,onClick:l,className:"sue-btn sue-btn-primary",children:n?"Savingâ¦":"Save changes"})})}function R({children:n}){return e.jsx("section",{style:{minHeight:"60vh",display:"grid",placeItems:"center"},children:e.jsx("div",{style:{color:"var(--sue-text-muted)"},children:n})})}const r={width:"100%",padding:"8px 12px",fontSize:14,border:"1px solid var(--sue-border)",borderRadius:6};export{K 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.