import{r as s,c as i,h as t}from"./p-e97fde0a.js";import{a as e}from"./p-93127aa7.js";import{s as o}from"./p-894c7006.js";import{s as a,o as h}from"./p-f09ee70b.js";import{c as n}from"./p-addaf7a4.js";import"./p-03631502.js";import"./p-9dbc54d6.js";import"./p-d3366af3.js";import"./p-401e165e.js";import"./p-830ab1a3.js";import"./p-ec182234.js";import"./p-3f6362a4.js";import"./p-95325ec5.js";import"./p-88aed607.js";import"./p-d9fa04f9.js";const d=":host{display:block}";const r=d;const l=class{constructor(t){s(this,t);this.scChange=i(this,"scChange",7);this.scUpdateOrderState=i(this,"scUpdateOrderState",7);this.scClear=i(this,"scClear",7);this.scInput=i(this,"scInput",7);this.scFocus=i(this,"scFocus",7);this.scBlur=i(this,"scBlur",7);this.scUpdateCustomer=i(this,"scUpdateCustomer",7);this.loggedIn=undefined;this.size="medium";this.value=e("first_name");this.pill=false;this.label=undefined;this.showLabel=true;this.help="";this.placeholder=undefined;this.disabled=false;this.readonly=false;this.required=false;this.invalid=false;this.autofocus=undefined;this.hasFocus=undefined}async reportValidity(){return this.input.reportValidity()}async handleChange(){this.value=this.input.value;try{a.checkout=await n({id:a.checkout.id,data:{first_name:this.input.value}})}catch(s){console.error(s)}}handleSessionChange(){var s,i,t,h,n,d;if(this.value)return;const r=e("first_name");if(!o.loggedIn&&!!r){this.value=r;return}if(!o.loggedIn){this.value=((i=(s=a===null||a===void 0?void 0:a.checkout)===null||s===void 0?void 0:s.customer)===null||i===void 0?void 0:i.first_name)||((t=a===null||a===void 0?void 0:a.checkout)===null||t===void 0?void 0:t.first_name)}else{this.value=((h=a===null||a===void 0?void 0:a.checkout)===null||h===void 0?void 0:h.first_name)||((d=(n=a===null||a===void 0?void 0:a.checkout)===null||n===void 0?void 0:n.customer)===null||d===void 0?void 0:d.first_name)}}componentWillLoad(){this.handleSessionChange();this.removeCheckoutListener=h("checkout",(()=>this.handleSessionChange()))}disconnectedCallback(){this.removeCheckoutListener()}render(){return t("sc-input",{key:"430e820b69b4750f5e8d51afbafbc3163b53bf8c",type:"text",name:"first_name",ref:s=>this.input=s,value:this.value,label:this.label,help:this.help,autocomplete:"first_name",placeholder:this.placeholder,readonly:this.readonly,required:this.required,invalid:this.invalid,autofocus:this.autofocus,hasFocus:this.hasFocus,onScChange:()=>this.handleChange(),onScInput:()=>this.scInput.emit(),onScFocus:()=>this.scFocus.emit(),onScBlur:()=>this.scBlur.emit(),...this.disabled&&{disabled:true}})}};l.style=r;export{l as sc_customer_firstname};
//# sourceMappingURL=p-9cdf4258.entry.js.map