import{ref as a}from"vue";import{defineStore as $}from"pinia";import{k,b as F}from"../server.mjs";import"klona";import"defu";import"#internal/nuxt/paths";const J=$("car",()=>{const{$axios:i}=k(),w=a({}),{locale:I,t:l}=F(),c=a(),d=a(),o=a([]),f=a([]),r=a(!0),p=a(!0),u=a(!1),n=a(!0),h=a(!1);let m=a(),C=a(1),v=a(),g=a();async function x(e){const t=await i.get(`car/${e}`);t.status>=200&&(c.value=t.data.data,r.value=!1),setTimeout(()=>{r.value=!0},500)}async function S(e){const t=await i.get(`car/${e}`);t.status>=200&&(c.value=t.data.data,r.value=!1),setTimeout(()=>{r.value=!0},500)}async function A(e,t){u.value=!0;const s=await i.get("car/search",{params:{page:e,model_id:typeof t.model_id=="object"?[...t.model_id]:[t.model_id],brand_id:typeof t.model_id=="object"?[...t.brand_id]:[t.brand_id],car_id:typeof t.model_id=="object"?[...t.car_id]:[t.car_id],min_price:t.min_price,max_price:t.max_price}});s.status>=200&&(s.data.data.length==0?o.value=[]:o.value=[...o.value,...s.data.data],p.value=!1,u.value=!1,m.value=s.data.meta.total,v.value=s.data.meta.per_page,g.value=s.data.meta.to)}async function L(e,t,s=!1,y=""){if((await i.post("add-favorite-withoutauth",{car_id:e,device_ip:y})).status>=200){const B=await import("mosha-vue-toastify"),{createToast:P}=B;P(l(t?"wishlist1":"wishlist2"),{toastBackgroundColor:"#00A0B4",position:"top-right",type:"success",transition:"bounce",showIcon:"true",timeout:3e3}),s&&_(y)}}async function _(e){const t=await i.get("user/car",{params:{device_ip:e}});t.status>=200&&(n.value=!1,f.value=t.data.data)}async function T(){const e=await i.get("prices");e.status>=200&&(n.value=!1,d.value=e.data)}return{errors:w,getCar:x,getCarBySlug:S,getSearchCars:A,filteredCar:o,isLoading:r,pendingState:h,isLoading2:p,isLoading3:u,gePrices:T,prices:d,itemsPerPage:g,isLoading4:n,AddFav:L,page:C,per_page:v,total:m,car:c,getFav:_,favsArr:f}});export{J as u};
