class i{constructor(i,t){this.form=null,this.input=i,this.options={form:i=>{var t,s;return(null===(s=null===(t=this.closestElement("sc-form",i))||void 0===t?void 0:t.shadowRoot)||void 0===s?void 0:s.querySelector("form"))||this.closestElement("form",i)},name:i=>i.name,value:i=>i.value,disabled:i=>i.disabled,...t},this.form=this.options.form(this.input),this.handleFormData=this.handleFormData.bind(this)}closestElement(i,t){return t?t&&t!=document&&t!=window&&t.closest(i)||this.closestElement(i,t.getRootNode().host):null}addFormData(){this.form&&this.form.addEventListener("formdata",this.handleFormData)}removeFormData(){this.form&&this.form.removeEventListener("formdata",this.handleFormData)}handleFormData(i){const t=this.options.name(this.input),s=this.options.value(this.input);"string"==typeof t&&void 0!==s&&(Array.isArray(s)?s.forEach((s=>{s&&i.formData.append(t,s.toString())})):s&&i.formData.append(t,s.toString()))}}const t=i=>{var t;const{email:s,name:n,password:e,shipping_city:a,shipping_country:o,shipping_line_1:r,shipping_line_2:l,shipping_postal_code:_,shipping_state:d,billing_city:h,billing_country:c,billing_line_1:p,billing_line_2:m,billing_postal_code:u,billing_state:b,"tax_identifier.number_type":f,"tax_identifier.number":g,...y}=i,v={...a?{city:a}:{},...o?{country:o}:{},...r?{line_1:r}:{},...l?{line_2:l}:{},..._?{postal_code:_}:{},...d?{state:d}:{}},w={...h?{city:h}:{},...c?{country:c}:{},...p?{line_1:p}:{},...m?{line_2:m}:{},...u?{postal_code:u}:{},...b?{state:b}:{}};return{...n?{name:n}:{},...s?{email:s}:{},...e?{password:e}:{},...Object.keys(v||{}).length?{shipping_address:v}:{},...Object.keys(w||{}).length?{billing_address:w}:{},...f&&g?{tax_identifier:{number:g,number_type:f}}:{},...(null===(t=Object.keys(y))||void 0===t?void 0:t.length)?{metadata:y}:{}}},s=async i=>{const t=[...i.shadowRoot.querySelectorAll("*")].filter((i=>"function"==typeof i.reportValidity));for(const i of t)if(!await i.reportValidity())return!1;return!0};export{i as F,t as p,s as r}