class i{constructor(i,t){this.form=null,this.input=i,this.options={form:i=>{var t,n;return(null===(n=null===(t=this.closestElement("sc-form",i))||void 0===t?void 0:t.shadowRoot)||void 0===n?void 0:n.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),n=this.options.value(this.input);"string"==typeof t&&void 0!==n&&(Array.isArray(n)?n.forEach((n=>{n&&i.formData.append(t,n.toString())})):n&&i.formData.append(t,n.toString()))}}const t=i=>{var t;const{email:n,name:s,first_name:e,last_name:a,phone:o,password:r,shipping_city:l,shipping_country:_,shipping_line_1:h,shipping_line_2:d,shipping_postal_code:c,shipping_state:p,billing_city:m,billing_country:u,billing_line_1:f,billing_line_2:b,billing_postal_code:g,billing_state:y,"tax_identifier.number_type":v,"tax_identifier.number":w,...x}=i,F={...l?{city:l}:{},..._?{country:_}:{},...h?{line_1:h}:{},...d?{line_2:d}:{},...c?{postal_code:c}:{},...p?{state:p}:{}},j={...m?{city:m}:{},...u?{country:u}:{},...f?{line_1:f}:{},...b?{line_2:b}:{},...g?{postal_code:g}:{},...y?{state:y}:{}};return{...s?{name:s}:{},...n?{email:n}:{},...e?{first_name:e}:{},...a?{last_name:a}:{},...o?{phone:o}:{},...r?{password:r}:{},...Object.keys(F||{}).length?{shipping_address:F}:{},...Object.keys(j||{}).length?{billing_address:j}:{},...v&&w?{tax_identifier:{number:w,number_type:v}}:{},...(null===(t=Object.keys(x))||void 0===t?void 0:t.length)?{metadata:x}:{}}},n=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,n as r}