import{i as o,j as F,c as u,o as s,f as n,e as j,d as i,u as f,b as N,F as L,h as R,t as x}from"./vue.esm-bundler-DZdE0M9V.js";import{R as w}from"./Rest-DEQMhckH.js";import{t as r}from"./Translator-Bios5QX5.js";import{d as A,b as m}from"./CopyToClipboard-HDOjVK6m.js";import"./Arr-MwYQQ3qa.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./Badge-CAEsoWyQ.js";import"./Str-Ckn63bs5.js";import"./DynamicIcon-D-LZibaK.js";import"./Notify-D1wJq1es.js";import"./index-D0R5Hqh1.js";const I={class:"fct-global-address-component"},P={class:"setting-fields-inner country"},Z={key:0},$={class:"grid lg:grid-cols-2"},z={class:"setting-fields-inner city"},D={class:"setting-fields-inner postcode"},K={key:1},ee={__name:"AddressComponent",props:{name:{type:String,required:!0},field:{type:Object},fieldKey:{type:String},value:{required:!0},variant:{type:String},nesting:{type:Boolean,default:!1},statePath:{type:String},form:{type:Object,required:!0},callback:{type:Function,required:!0},label:{type:String},attribute:{required:!0}},setup(l){const V=l,g=o([]),E=()=>{w.get("address-info/countries").then(t=>{g.value=t.data}).catch(t=>{}).finally(()=>{})},v=o({}),d=o(!1),S=o(!0),k=o(!0),h=o(r("Zip Code")),c=o(r("State")),U=t=>{if(d.value=!0,!t){d.value=!1;return}if(v.value[t]){O(v.value[t]),d.value=!1;return}w.get("address-info/get-country-info",{country_code:t}).then(e=>{v.value[t]=e,O(e)}).catch(e=>{console.log(e,"errors")}).finally(()=>{d.value=!1})},b=o([]),O=t=>{var e,a,y,q,B,C;b.value=(t==null?void 0:t.states)||[],k.value=((a=(e=t==null?void 0:t.address_locale)==null?void 0:e.state)==null?void 0:a.hidden)!==!0,S.value=b.value.length>1,h.value=((q=(y=t==null?void 0:t.address_locale)==null?void 0:y.postcode)==null?void 0:q.label)||r("Zip Code"),c.value=((C=(B=t==null?void 0:t.address_locale)==null?void 0:B.state)==null?void 0:C.label)||r("State")};return F(()=>{E(),V.form.data.values.store_country&&U(V.form.data.values.store_country)}),(t,e)=>(s(),u("div",I,[n("div",P,[i(A,{modelValue:l.form.data.values.store_country,"onUpdate:modelValue":e[0]||(e[0]=a=>l.form.data.values.store_country=a),label:f(r)("Select Country"),filterable:"",options:g.value,onOnChange:e[1]||(e[1]=a=>{l.form.data.values.store_state="",U(a)})},null,8,["modelValue","label","options"])]),!d.value&&k.value?(s(),u("div",Z,[S.value?(s(),N(A,{key:0,modelValue:l.form.data.values.store_state,"onUpdate:modelValue":e[2]||(e[2]=a=>l.form.data.values.store_state=a),label:c.value,filterable:"",options:b.value},null,8,["modelValue","label","options"])):(s(),N(m,{key:1,id:"store_state",modelValue:l.form.data.values.store_state,"onUpdate:modelValue":e[3]||(e[3]=a=>l.form.data.values.store_state=a),label:c.value},null,8,["modelValue","label"]))])):j("",!0),i(m,{modelValue:l.form.data.values.store_address1,"onUpdate:modelValue":e[4]||(e[4]=a=>l.form.data.values.store_address1=a),label:f(r)("Street address")},null,8,["modelValue","label"]),i(m,{modelValue:l.form.data.values.store_address2,"onUpdate:modelValue":e[5]||(e[5]=a=>l.form.data.values.store_address2=a),label:f(r)("Apt, suite, unit")},null,8,["modelValue","label"]),n("div",$,[n("div",z,[i(m,{modelValue:l.form.data.values.store_city,"onUpdate:modelValue":e[6]||(e[6]=a=>l.form.data.values.store_city=a),label:f(r)("City/Town")},null,8,["modelValue","label"])]),n("div",D,[i(m,{modelValue:l.form.data.values.store_postcode,"onUpdate:modelValue":e[7]||(e[7]=a=>l.form.data.values.store_postcode=a),label:h.value},null,8,["modelValue","label"])])]),l.form.data.validationErrors.hasOwnProperty("store_country")?(s(),u("div",K,[(s(!0),u(L,null,R(l.form.data.validationErrors,(a,y)=>(s(),u("span",{class:"fluent-cart-admin-validation-error",key:a},[n("span",null,x(Object.values(a)[0]),1)]))),128))])):j("",!0)]))}};export{ee as default};
