import{S as c,P as f,M as p,T as a,X as d,W as u,V as C,K as B,r as $,ab as b,ag as M,B as N,aa as y,a7 as x,b as F,U as D}from"./vendor-bSWkQivH.js";import{e as A,y as P,aj as W,h as I,ak as S,al as T,Q as U,g as j,am as E}from"./index-Dqv5IkpS.js";const G={};function K(n,m){const s=c("VcButton"),i=c("VcModal");return p(),f(i,{title:n.$t("common.titles.remove_products"),variant:"danger",icon:"warning"},{actions:a(({close:r})=>[C(s,{class:"mx-auto",onClick:_=>r()},{default:a(()=>[d(u(n.$t("common.buttons.ok")),1)]),_:2},1032,["onClick"])]),default:a(()=>[d(" "+u(n.$t("common.messages.cart_contains_deleted_products")),1)]),_:1},8,["title"])}const O=A(G,[["render",K]]),R={class:"mb-5 text-xs font-normal text-neutral-400"},H=B({__name:"create-quote-from-cart",emits:["lockCart","unlockCart"],setup(n,{emit:m}){const s=m,i=P(),{cart:r,refetch:_}=W(),l=$(!1),{client:g}=b(),V=M(),{openModal:h}=I(),k=N(()=>{var t,e;return(e=(t=r.value)==null?void 0:t.items)==null?void 0:e.some(o=>!o.product)}),{mutate:v}=y(T,{refetchQueries:()=>S(g,[E.Query.GetFullCart])}),{isAuthenticated:q}=U();async function w(){var o;if(k.value){h({component:O});return}l.value=!0,s("lockCart");const t=await v({command:{cartId:r.value.id,comment:""}}),e=(o=t==null?void 0:t.data)==null?void 0:o.createQuoteFromCart;e?await V.push({name:"EditQuote",params:{quoteId:e.id}}):i.error({text:j.i18n.global.t("quotes.errors.creating_quote_error"),duration:15e3,single:!0}),await _(),s("unlockCart"),l.value=!1}return(t,e)=>{const o=c("VcButton"),Q=c("VcWidget");return F(q)?(p(),f(Q,{key:0,title:t.$t("quotes.cart_widget.title"),class:"print:hidden"},{default:a(()=>[D("p",R,u(t.$t("quotes.cart_widget.quote_request_hint")),1),C(o,{loading:l.value,"full-width":"",variant:"outline",onClick:w},{default:a(()=>[d(u(t.$t("quotes.cart_widget.create_quote_button")),1)]),_:1},8,["loading"])]),_:1},8,["title"])):x("",!0)}}});export{H as default};
//# sourceMappingURL=create-quote-from-cart-B6dKaWR9.js.map
