1import{x as A,r as s,D as p,y as $}from"./6bISWLsM.js";import{u as y}from"./CYe543ep.js";const L=A("myCartStore",()=>{const u=$(),o=y("auth-token"),w=s(),n=s(),l=s(),c=s({total_products_quantity:0,total_products_price:0,total_products_price_with_discount:0,client_profile_id:0,products:[]}),a=s(!1),P=async(r,i=1)=>{o.value?await $fetch(u.public.API_URL+"/cart/store_product",{method:"POST",body:{product_id:r.id,quantity:i},headers:{Authorization:`Bearer ${o.value}`}}).then(()=>{d()}):$fetch(u.public.API_URL+`/cart_no_reg/store_product?product_id=${r.id}&quantity=1`,{method:"POST",credentials:"include"}).then(()=>{d()})},d=async()=>{a.value=!0,o.value?await $fetch(u.public.API_URL+"/cart/show",{onResponse({request:r,response:i,options:_}){c.value=i._data,a.value=!1},headers:{Authorization:`Bearer ${o.value}`}}):$fetch(u.public.API_URL+"/cart_no_reg/show",{credentials:"include"}).then(r=>{c.value=r,a.value=!1})};return{cart:c,showCart:d,addToCart:P,loading:a,thanksData:w,removeFormCart:async r=>{o.value?(a.value=!0,await $fetch(u.public.API_URL+"/cart/delete_product",{method:"delete",body:{product_id:r},headers:{Authorization:`Bearer ${o.value}`}}).then(()=>{a.value=!1,d()})):await $fetch(u.public.API_URL+"/cart_no_reg/delete_product",{method:"delete",body:{product_id:r},credentials:"include",headers:{Authorization:`Bearer ${o.value}`}}).then(()=>{a.value=!1,d()})},editProductCount:async(r,i)=>{a.value=!0,o.value?await $fetch(u.public.API_URL+"/cart/update_product?_method=PATCH",{method:"POST",body:{product_id:r,quantity:i},headers:{Authorization:`Bearer ${o.value}`}}).then(()=>{d().then(()=>{a.value=!1})}):await $fetch(u.public.API_URL+"/cart_no_reg/update_product?_method=PATCH",{method:"POST",credentials:"include",body:{product_id:r,quantity:i},headers:{Authorization:`Bearer ${o.value}`}}).then(()=>{d().then(()=>{a.value=!1})})},createOrder:async(r,i,_)=>{var h,f;console.log(i,_);const v=async t=>((t==null?void 0:t.status)=="success"&&c.value.products.length>0&&(c.value.id||t!=null&&t.order_num)&&(window.dataLayer.push({ecommerce:{currencyCode:"BYN",purchase:{actionField:{id:(t==null?void 0:t.order_num)??c.value.id,revenue:r.total_products_price_with_discount},products:c.value.products.map(e=>{var m;return{id:e.vendor_code,name:e.title+" "+e.vendor_code,variant:((m=e==null?void 0:e.colors)==null?void 0:m.length)>0?e.colors[0].title:"",price:parseFloat(e.discounted_price?e.discounted_price:e.price),brand:"Makey",quantity:1}})}}}),window.fbq&&window.fbq("track","Purchase",{content_ids:c.value.products.map(e=>String(e.id)),content_type:"product",currency:"BYN",value:r.total_products_price_with_discount,num_items:r.total_products_quantity,contents:c.value.products.map(e=>({id:e.id,name:e.title,price:e.discounted_price?e.discounted_price:e.price,brand:"Makey",quantity:1}))},{eventID:(t==null?void 0:t.order_num)??c.value.id})),a.value=!0,await new Promise(e=>setTimeout(e,1500)),a.value=!1,t);if(a.value=!0,o.value)try{const t=await $fetch(u.public.API_URL+"/new-order/store",{method:"POST",body:r,headers:{Authorization:`Bearer ${o.value}`}}),e=t._data||t;l.value=e,a.value=!1,e.status!="error"&&await v(e),i==1&&e.status!="error"?(await p(e.data.redirectUrl,{external:!0}),l.value=e,n.value=e):(n.value=e,a.value=!1,l.value=e)}catch(t){const e=((h=t.response)==null?void 0:h._data)||t.response||t;l.value=e,n.value=e,a.value=!1}else try{const t=await $fetch(u.public.API_URL+"/new-order/store-not-reg",{method:"POST",body:r}),e=t._data||t;l.value=e,a.value=!1,e.status!="error"&&await v(e),i==1&&e.status!="error"?(await p(e.data.redirectUrl,{external:!0}),l.value=e,n.value=e):(n.value=e,a.value=!1,l.value=e)}catch(t){const e=((f=t.response)==null?void 0:f._data)||t.response||t;l.value=e,n.value=e,a.value=!1}},checkoutErrors:n,checkoutResponce:l}});export{L as c};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.