import{h as o,i as F,e as u,o as d,d as n,b as N,a as i,u as f,c as j,F as L,g as R,t as x}from"./vue.esm-bundler.js?ver=1.5.2";import{R as w}from"./Rest.js?ver=1.5.2";import{t as s}from"./Translator.js?ver=1.5.2";import{b as A,_ as m}from"./AddressComponent2.js?ver=1.5.2";import"./Arr.js?ver=1.5.2";import"./Animation.js?ver=1.5.2";import"./_plugin-vue_export-helper.js?ver=1.5.2";import"./TransitionAccordion.js?ver=1.5.2";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},Y={__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({}),r=o(!1),S=o(!0),k=o(!0),h=o(s("Zip Code")),c=o(s("State")),U=t=>{if(r.value=!0,!t){r.value=!1;return}if(v.value[t]){O(v.value[t]),r.value=!1;return}w.get("address-info/get-country-info",{country_code:t}).then(e=>{v.value[t]=e,O(e)}).catch(e=>{}).finally(()=>{r.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)||s("Zip Code"),c.value=((C=(B=t==null?void 0:t.address_locale)==null?void 0:B.state)==null?void 0:C.label)||s("State")};return F(()=>{E(),V.form.data.values.store_country&&U(V.form.data.values.store_country)}),(t,e)=>(d(),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(s)("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"])]),!r.value&&k.value?(d(),u("div",Z,[S.value?(d(),j(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"])):(d(),j(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"]))])):N("",!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(s)("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(s)("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(s)("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")?(d(),u("div",K,[(d(!0),u(L,null,R(l.form.data.validationErrors,(a,y)=>(d(),u("span",{class:"fluent-cart-admin-validation-error",key:a},[n("span",null,x(Object.values(a)[0]),1)]))),128))])):N("",!0)]))}};export{Y as default};
