import{r as e,h as s}from"./p-9add63ef.js";import"./p-445fd8b4.js";import{a}from"./p-259c3935.js";import"./p-401e165e.js";import"./p-d3366af3.js";const t=":host{display:block;position:relative}";const d=t;const r=class{constructor(s){e(this,s);this.heading=undefined;this.successUrl=undefined;this.user=undefined;this.loading=undefined;this.error=undefined;this.enableValidation=true}renderEmpty(){return s("slot",{name:"empty"},wp.i18n.__("User not found.","surecart"))}validatePassword(e){const s=new RegExp("^(?=.*?[#?!@$%^&*-]).{6,}$");if(s.test(e))return true;return false}async handleSubmit(e){this.loading=true;this.error="";try{const{password:s}=await e.target.getFormJson();await a({path:`wp/v2/users/me`,method:"PATCH",data:{password:s,meta:{default_password_nag:false}}});if(this.successUrl){window.location.assign(this.successUrl)}else{this.loading=false}}catch(e){this.error=(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong","surecart");this.loading=false}}render(){return s("sc-dashboard-module",{key:"feddccbc9dd30c4f3a70c24d6e25ad69d8ac47fd",class:"customer-details",error:this.error},s("span",{key:"c783193ecf26bf812f46a17aa5d49f4647f24985",slot:"heading"},this.heading||wp.i18n.__("Update Password","surecart")," "),s("slot",{key:"85613aff2a44140892c3b2d3ea1e7e6fd76cb69e",name:"end",slot:"end"}),s("sc-card",{key:"d3f20009f4d1f3f2c588b6372da95965a1e6bbb8"},s("sc-form",{key:"51bfc24a84809d1b95a593e5c26ab7bc73dd464f",onScFormSubmit:e=>this.handleSubmit(e)},s("sc-password",{key:"e106ef9551824fa86ddbe2e8a738cd5f630230a6",enableValidation:this.enableValidation,label:wp.i18n.__("New Password","surecart"),name:"password",confirmation:true,required:true}),s("div",{key:"86e8eb9cb1269515ff05ae9c82823847a1953919"},s("sc-button",{key:"f533e96120143bf8d79c2e7dd5cf3788befe6c5a",type:"primary",full:true,submit:true},wp.i18n.__("Update Password","surecart"))))),this.loading&&s("sc-block-ui",{key:"acca448a76b4c6ded2ff7ba90395adaa182e834a",spinner:true}))}};r.style=d;export{r as sc_wordpress_password_edit};
//# sourceMappingURL=p-ea538aa4.entry.js.map