import{Q as _}from"./QBtn-Bl8V3g1s.js";import{Q as O}from"./QSeparator-D1JYPgu2.js";import{Q as j,a as F,b as x,c as I,A as E}from"./AddressModal-33esE-yw.js";import{Q as G}from"./QFile-DVWif_Vn.js";import{Q as J,a as K,_ as L}from"./IndexPage-CTPnu3LT.js";import{u as X}from"./taxstore-B0e8PHMB.js";import{I as H,G as W,r as N,a as d,o as Y,e as Z,J as $,M as u,K as c,N as r,O as i,Q as m,U as o,R as y,P as ee}from"./index-BFHpqQMc.js";import{u as ae}from"./vue-i18n.runtime-CGMLV8bE.js";import"./use-router-link-niyq3CDa.js";import"./QList-CPm2VhlR.js";import"./LocalStorage-Bg7wwOV9.js";const te={class:"row items-center"},se={class:"col"},re={class:"text-h5"},le={class:"col-auto"},oe={key:0,class:"q-mt-sm"},ie={key:1},de={class:"row items-center q-gutter-sm q-mb-sm"},ne={class:"col-auto"},pe={class:"col"},ue={class:"text-caption"},ce={class:"q-pa-sm bg-grey-2 q-mb-sm"},me={key:0,class:"text-negative"},ve={key:1},fe=H({__name:"TaxpayerStep",props:{step:{}},emits:["next","prev"],setup(U,{emit:B}){const q=U,D=B,h=q.step,n=X(),e=W({}),{t:l}=ae(),b=N(null),p=N(!1),g=N(null),A=d(()=>[e.address||"",e.zip||"",e.city||""].join("	")),P=(s="Required")=>{const a=l("validation.required");return a&&a!=="validation.required"?a:s},v=s=>a=>{const t=s||P();return a==null?t:typeof a=="string"?a.trim()!==""||t:Array.isArray(a)?a.length>0||t:!0},f=d(()=>!!e.prevPreparedByUs),Q=d(()=>f.value?[v()]:[]),k=d(()=>f.value?[]:[v()]),T=d(()=>f.value?[]:[v()]),z=d(()=>f.value?[]:[v()]);Y(async()=>{const s=n.getTaxpayer()||{};Object.assign(e,s),await Z(),b.value?.resetValidation?.()});const V={prevPreparedByUs:!1,prevDeclaration:null,firstName:"",lastName:"",birthDate:"",address:"",zip:"",city:""};Object.keys(V).forEach(s=>{const a=s;e[a]===void 0&&(e[a]=V[a])});async function R(){try{if(await(b.value?.validate?.()??!0)===!1)return}catch{return}e.prevPreparedByUs?n.setTaxpayer({prevPreparedByUs:!0,prevDeclaration:e.prevDeclaration,firstName:"",lastName:"",birthDate:"",address:"",zip:"",city:""}):n.setTaxpayer({prevPreparedByUs:!1,prevDeclaration:e.prevDeclaration,firstName:e.firstName,lastName:e.lastName,birthDate:e.birthDate,address:e.address,zip:e.zip,city:e.city}),D("next",h.next)}function w(){e.prevPreparedByUs?n.setTaxpayer({prevPreparedByUs:!0,prevDeclaration:e.prevDeclaration,firstName:"",lastName:"",birthDate:"",address:"",zip:"",city:""}):n.setTaxpayer({prevPreparedByUs:!1,prevDeclaration:e.prevDeclaration,firstName:e.firstName,lastName:e.lastName,birthDate:e.birthDate,address:e.address,zip:e.zip,city:e.city}),D("prev",h.prev)}function C(){g.value={street:e.address||"",zip:e.zip||"",city:e.city||"",country:null,foreign:!0},p.value=!0}function S(){p.value=!1}function M(s){e.address=s.street||"",e.zip=s.zip||"",e.city=s.city||"",p.value=!1}return(s,a)=>(u(),$(K,{flat:"",class:"full-width q-pa-none"},{default:c(()=>[r(J,{class:"full-width"},{default:c(()=>[i("div",te,[i("div",se,[i("div",re,m(o(l)("TAX")),1)]),i("div",le,[r(_,{flat:"",color:"secondary",label:o(l)("button.prev"),onClick:w,class:"q-mr-sm"},null,8,["label"]),r(_,{color:"primary",label:o(l)("button.next"),onClick:R},null,8,["label"])])]),r(O,{class:"q-my-sm"}),r(j,{ref_key:"formRef",ref:b,class:"q-gutter-md q-mt-md"},{default:c(()=>[r(F,{modelValue:e.prevPreparedByUs,"onUpdate:modelValue":a[0]||(a[0]=t=>e.prevPreparedByUs=t),label:o(l)("taxpayer.prevPreparedByUs")},null,8,["modelValue","label"]),e.prevPreparedByUs?(u(),y("div",oe,[r(G,{modelValue:e.prevDeclaration,"onUpdate:modelValue":a[1]||(a[1]=t=>e.prevDeclaration=t),label:o(l)("taxpayer.prevDeclaration"),multiple:"","use-chips":"",accept:"application/pdf,image/*","hide-upload-btn":"",rules:Q.value},null,8,["modelValue","label","rules"])])):(u(),y("div",ie,[r(x,{modelValue:e.firstName,"onUpdate:modelValue":a[2]||(a[2]=t=>e.firstName=t),label:o(l)("taxpayer.firstName"),rules:k.value},null,8,["modelValue","label","rules"]),r(x,{modelValue:e.lastName,"onUpdate:modelValue":a[3]||(a[3]=t=>e.lastName=t),label:o(l)("taxpayer.lastName"),rules:T.value},null,8,["modelValue","label","rules"]),r(x,{modelValue:e.birthDate,"onUpdate:modelValue":a[4]||(a[4]=t=>e.birthDate=t),type:"date",label:o(l)("taxpayer.birthDate"),rules:z.value},null,8,["modelValue","label","rules"]),i("div",de,[i("div",ne,[r(_,{dense:"",flat:"",round:"",icon:"edit",onClick:C},{default:c(()=>[r(I,{class:"bg-primary text-white"},{default:c(()=>[ee(m(o(l)("children.editAddress")),1)]),_:1})]),_:1})]),i("div",pe,[i("div",ue,m(o(l)("taxpayer.address")),1)])]),i("div",ce,[e.address?(u(),y("div",ve,m(A.value),1)):(u(),y("div",me,m(o(l)("validation.insertAddress")),1))]),r(E,{modelValue:p.value,"onUpdate:modelValue":a[5]||(a[5]=t=>p.value=t),modelAddress:g.value,allowForeign:!1,onSave:M,onCancel:S},null,8,["modelValue","modelAddress"])]))]),_:1},512)]),_:1})]),_:1}))}}),qe=L(fe,[["__scopeId","data-v-00648f3a"]]);export{qe as default};
