1import{p as f}from"./index-hdnIDsqN.js";import{$ as p}from"./l10n-CGGNtq87.js";import{M as q}from"./Modal-5JEvAa1x.js";import{a as m,o as c,d as i,b as h,i as x,j as g,e as y,w as _,F as b,r as C,k as w,l as S,T as V}from"./runtime-core.esm-bundler-qir4qudY.js";import{t as u,n as B}from"./reactivity.esm-bundler-BFx7IUI5.js";import{w as N,f as M,T as A}from"./runtime-dom.esm-bundler-Bm0-6-7k.js";import{_ as E}from"./_plugin-vue_export-helper-DlAUqK2U.js";const j={class:"text-area"},O={class:"d-flex justify-content-between"},P={key:0,class:"text-area__label"},I=["rows","placeholder","required","value"],U={__name:"TextArea",props:{emoji:{default:!1,type:Boolean},label:{default:"",type:String},limit:{default:250,type:Number},modelValue:{type:String,default:""},placeholder:{default:"",type:String},required:{default:!1,type:Boolean},rows:{default:2,type:Number}},emits:["update:model-value"],setup(t,{emit:e}){const r=e,a=t;function l(d){const n=l.text;let s=d.target.value;if(a.emoji||(s=o(s)),s.length>a.limit){if(n&&n.length===a.limit&&s.length-a.limit===1){d.target.value=n,r("update:model-value",n);return}s=s.slice(0,a.limit)}d.target.value=s,r("update:model-value",s),l.text=s}function o(d){const n=["\uD83C[\uDF00-\uDFFF]","\uD83D[\uDC00-\uDE4F]","\uD83D[\uDE80-\uDEFF]"];return d.replace(new RegExp(n.join("|"),"g"),"")}return(d,n)=>(c(),m("label",j,[i("span",O,[t.label?(c(),m("span",P,u(t.label),1)):h("",!0),i("span",{class:B(["text-area__limit",{"text-warning":t.modelValue.length===t.limit}])},u(t.modelValue.length)+" / "+u(t.limit),3)]),i("textarea",{class:"form-field form-field_outline form-field_textarea",rows:t.rows,placeholder:t.placeholder,required:t.required,value:t.modelValue,onInput:n[0]||(n[0]=s=>l(s))},null,40,I)]))}},D={name:"ModalPostcard",components:{Modal:q,TextArea:U},props:{free:{default:!1,type:Boolean},open:{default:!1,type:Boolean},parentId:{type:Number},products:{default(){return[]},type:Array},text:{default:"",type:String}},emits:["add","add-paid","close"],data(){return{limit:250,modal_open:this.open,modal_text:"",products_id:[]}},computed:{products_to_select(){return this.products.filter(t=>!t.is_additional&&!t.postcards.length)}},watch:{modal_open(t){var e;t?(this.modal_text=this.text,this.products_id.push(this.parentId||((e=this.products_to_select[0])==null?void 0:e.id))):(this.products_id=[],this.modal_text="")},open(t){this.modal_open=t}},methods:{$translate:p,add(){const t=this.modal_text.trim();if(this.free&&!t){this.$refs.textarea.focus();return}if(t&&t===this.text){this.close();return}this.free?this.$emit("add",{products:this.products_id,text:this.modal_text}):this.$emit("add-paid",{text:this.modal_text}),this.close()},close(){this.modal_open=!1,this.$emit("close")}}},J={class:"h2 mb-3"},$={class:"mp-products-list mb-4"},z=["src","alt"],L={class:"flex-grow-1 pr-4"},F={key:0,class:"text-danger"},R={class:"form-check form-radio"},G=["value"],H=["disabled"];function K(t,e,r,a,l,o){const d=x("TextArea"),n=x("Modal");return c(),g(V,{to:"body"},[y(A,{name:"modal"},{default:_(()=>[l.modal_open?(c(),g(n,{key:0,onClose:o.close},{title:_(()=>[w(u(o.$translate("common.postcard")),1)]),default:_(()=>[i("form",{onSubmit:e[2]||(e[2]=N(s=>o.add(),["prevent"]))},[y(d,{class:"mb-4",label:o.$translate("common.postcard_text"),required:r.free,rows:6,modelValue:l.modal_text,"onUpdate:modelValue":e[0]||(e[0]=s=>l.modal_text=s)},null,8,["label","required","modelValue"]),r.free&&o.products_to_select.length>1?(c(),m(b,{key:0},[i("div",J,u(o.$translate("cart.to_which_product")),1),i("div",$,[(c(!0),m(b,null,C(o.products_to_select,s=>(c(),m("label",{key:s.id,class:"mp-product"},[i("img",{class:"mp-product__img",src:s.photos.length?s.photos[0].small_image:"/img/empty.svg",width:"50",height:"50",alt:s.name},null,8,z),i("div",L,[w(u(s.name)+" ",1),s.customization?(c(),m("span",F,u(s.customized_product_data.name),1)):h("",!0)]),i("div",R,[S(i("input",{type:"checkbox",class:"form-check-input","onUpdate:modelValue":e[1]||(e[1]=T=>l.products_id=T),value:s.id},null,8,G),[[M,l.products_id]]),e[3]||(e[3]=i("span",{class:"form-check-label"},null,-1))])]))),128))])],64)):h("",!0),i("button",{class:"btn btn-danger btn-lg btn-block",disabled:!l.products_id.length},u(o.$translate("common.add")),9,H)],32)],void 0,!0),_:1},8,["onClose"])):h("",!0)],void 0),_:1})])}const Q=E(D,[["render",K]]);let k=!1;
1function W(){k||(k=!0,data_layer.push_event("add_postcard_to_cart"))}const v={data:null,open:!1,order:{},parent_id:0,text:""},ot={components:{ModalPostcard:Q},data(){return{cart:null,modals:{postcard:JSON.parse(JSON.stringify(v))}}},computed:{_freePostcardInGroups(){var e;const t={};return(e=this.cart)==null||e.checkout_orders.forEach(r=>{t[r.key]=r.items.some(a=>{if(!a.is_additional)return a.postcards.length<1})}),t}},methods:{close_modal_postcard(){const t=this.modals.postcard.data;this.modals.postcard=JSON.parse(JSON.stringify(v)),this.modals.postcard.data=t},del_postcard(t,e=this.modals.postcard.data){swal.fire({text:p("common.delete"),icon:"question",showCancelButton:!0,confirmButtonText:p("dialogs.answer.yes_comma_action",{action:p("common.delete").toLowerCase()}),cancelButtonText:p("common.cancel"),focusConfirm:!1}).then(r=>{r.value&&(swal.blockUI(),f(t.id,{postcards:[]}).then(a=>{this.cart=a,e.quantity=0}).catch(handling_error).finally(swal.close))})},show_modal_postcard(t=null,e="",r=0,a={}){this.modals.postcard.data=t,this.modals.postcard.open=!0,this.modals.postcard.order=a,this.modals.postcard.parent_id=r,this.modals.postcard.text=e},save_postcard(t,e=this.modals.postcard.data){swal.blockUI();let r=0;t.products.forEach(a=>{f(a,{postcards:[{text:t.text}]}).then(l=>{this.cart=this.cart||l,l.checkout_orders.forEach((o,d)=>this.cart.checkout_orders[d].items=o.items),l.checkout_orders.some(o=>o.items.some(d=>{if(d.id===a)return e.quantity=1}))}).catch(handling_error).finally(()=>{++r,!(r<t.products.length)&&(W(),swal.close())})})},save_partner_postcard(t,e=this.modals.postcard.data.id,r=this.modals.postcard.data){swal.blockUI(),f(e,{postcards:[{text:t.text}]}).then(a=>{this.cart=this.cart||a,a.checkout_orders.forEach((o,d)=>this.cart.checkout_orders[d].items=o.items);const l=a.checkout_orders.map(o=>o.items.find(d=>d.id===e)).filter(o=>o)[0];l&&(r.quantity=l.quantity)}).catch(handling_error).finally(()=>swal.close())}}};export{Q as M,ot as a,W as p};
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.