import{r as s,h as a}from"./p-b891c2f1.js";import{_ as t}from"./p-684c85b4.js";import"./p-aafd8ea4.js";import{a as e}from"./p-6fd3642a.js";import"./p-112455b1.js";import"./p-1c2e2695.js";const i=class{constructor(a){s(this,a)}renderEmpty(){return a("slot",{name:"empty"},t("User not found.","surecart"))}async handleSubmit(s){this.loading=!0;try{const{email:a,first_name:t,last_name:i,name:r}=await s.target.getFormJson();await e({path:"wp/v2/users/me",method:"PATCH",data:{first_name:t,last_name:i,email:a,name:r}}),this.successUrl?window.location.assign(this.successUrl):this.loading=!1}catch(s){this.error=(null==s?void 0:s.message)||t("Something went wrong","surecart"),this.loading=!1}}render(){var s,e,i,r;return a("sc-dashboard-module",{class:"account-details",error:this.error},a("span",{slot:"heading"},this.heading||t("Account Details","surecart")," "),a("sc-card",null,a("sc-form",{onScFormSubmit:s=>this.handleSubmit(s)},a("sc-input",{label:t("Billing Email","surecart"),name:"email",value:null===(s=this.user)||void 0===s?void 0:s.email,required:!0}),a("sc-columns",{style:{"--sc-column-spacing":"var(--sc-spacing-medium)"}},a("sc-column",null,a("sc-input",{label:t("First Name","surecart"),name:"first_name",value:null===(e=this.user)||void 0===e?void 0:e.first_name})),a("sc-column",null,a("sc-input",{label:t("Last Name","surecart"),name:"last_name",value:null===(i=this.user)||void 0===i?void 0:i.last_name}))),a("sc-input",{label:t("Display Name","surecart"),name:"name",value:null===(r=this.user)||void 0===r?void 0:r.display_name}),a("div",null,a("sc-button",{type:"primary",full:!0,submit:!0},t("Save","surecart"))))),this.loading&&a("sc-block-ui",{spinner:!0}))}};i.style=":host{display:block;position:relative}.customer-details{display:grid;gap:0.75em}";export{i as sc_wordpress_user_edit}