import{r as s,c as t,h as i}from"./p-b891c2f1.js";import{o as h}from"./p-494248b1.js";import{c as e}from"./p-9a3745a6.js";import"./p-6fd3642a.js";import"./p-aafd8ea4.js";import"./p-112455b1.js";import"./p-1c2e2695.js";const a=class{constructor(i){s(this,i),this.scChange=t(this,"scChange",7),this.scClear=t(this,"scClear",7),this.scInput=t(this,"scInput",7),this.scFocus=t(this,"scFocus",7),this.scBlur=t(this,"scBlur",7),this.scUpdateOrderState=t(this,"scUpdateOrderState",7),this.size="medium",this.value="",this.pill=!1,this.showLabel=!0,this.help="",this.disabled=!1,this.readonly=!1,this.required=!1,this.invalid=!1}async handleChange(){var s;this.value=this.input.value,this.scChange.emit();try{const t=await e({id:null===(s=this.order)||void 0===s?void 0:s.id,data:{email:this.input.value}});this.scUpdateOrderState.emit(t)}catch(s){console.error(s)}}handleSessionChange(s){(null==s?void 0:s.email)&&s.email!==this.value&&(this.value=s.email)}async reportValidity(){return this.input.reportValidity()}render(){var s;return i("sc-input",{type:"email",name:"email",ref:s=>this.input=s,value:(null===(s=this.customer)||void 0===s?void 0:s.email)||this.value,label:this.label,help:this.help,autocomplete:"email",placeholder:this.placeholder,disabled:!!this.loggedIn,readonly:this.readonly,required:!0,invalid:this.invalid,autofocus:this.autofocus,hasFocus:this.hasFocus,onScChange:()=>this.handleChange(),onScInput:()=>this.scInput.emit(),onScFocus:()=>this.scFocus.emit(),onScBlur:()=>this.scBlur.emit()})}static get watchers(){return{order:["handleSessionChange"]}}};h(a,["order","customer","loggedIn"],!1),a.style="sc-customer-email{display:block}";export{a as sc_customer_email}