1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BnzKVNWm.js","./CJOrt7RF.js","./DzEf6c3d.js","./dist.bNMobKjw.css"])))=>i.map(i=>d[i]); 2import{o as e,s as t}from"./VALu4SJC.js";import{Ht as n,L as r,ct as i,g as a,tt as o,vn as s}from"./CJOrt7RF.js";import{d as c,p as l}from"./DHNRalsD.js";import{A as u,q as d,t as f}from"./B-8rjqvJ.js";import{t as p}from"./HclGiUj8.js";import{i as m,n as h,s as g,t as _}from"./Bm62HHlj.js";import{t as v}from"./DAIwsz81.js";import{t as y}from"./C4CyR1sm.js";var b;function x(){return r()?.appContext?.app?.config?.globalProperties?.$gtm??b}var S=()=>{let e=x(),t=()=>!!e?.enabled()&&typeof window<`u`&&!!window.dataLayer;return{track:e=>{t()&&window.dataLayer.push(e)},isEnabled:t}},C={FZ:30,RL:1864,DL:2133},w=[`diensten`,`dienst`,`coupondienst`,`betaaldienst`,`bestandsdienst`,`discountdienst`,`verzenddienst`],T={NORMAL:1,MORNING:2,EVENING:3,DHL_POINT:4,PICKUP:6},E={DASHBOARD:1034,ORDERS:1035,FILES:1036,INVOICES:1037,QUOTATIONS:1038,CARTS:1039,FAVORITES:1040,DESIGNS:1041,COMPLAINTS:1042,INFORMATION:1043,ADDRESSES:1044,ORDER_DETAIL:1045,QUOTATION_DETAIL:1046,COMPLAINT_DETAIL:1047},D=[{key:`dashboard`,name:`account.menu.dashboard`,icon:`dashboard`,route:`account`},{key:`orders`,name:`account.menu.orders`,icon:`orders`,route:`account-orders`},{key:`files`,name:`account.menu.files`,icon:`upload`,route:`account-files`},{key:`open`,name:`account.menu.open`,icon:`invoice`,route:`account-open`},{key:`quotes`,name:`account.menu.quotes`,icon:`quote`,route:`account-quotations`},{key:`favorites`,name:`account.menu.favorites`,icon:`heart`,route:`account-favorites`},{key:`designs`,name:`account.menu.designs`,icon:`saved`,route:`account-designs`},{key:`complaints`,name:`account.menu.complaints`,icon:`warning`,route:`account-complaints`},{key:`info`,name:`account.menu.info`,icon:`account`,route:`account-information`},{key:`addresses`,name:`account.menu.addresses`,icon:`location`,route:`account-addresses`}],O=5e3,k=[`pagina's`,`pages`,`tabs`,`onglets`],A=[`gelijmde-magazines`,`gelijmde-brochures`,`softcover-boeken`,`hardcover-boeken`,`softcover-fotoboeken`,`hardcover-fotoboeken`,`livres-couverture-souple`,`livres-couverture-rigide`,`albums-photo-couverture-souple`,`albums-photo-couverture-rigide`,`brochures-avec-dos-carre-colle`,`brochures-a-dos-carre-colle`],j=`15:00:00`,M=[`25-12-2025`,`26-12-2025`,`1-1-2026`,`2-1-2026`,`6-4-2026`,`27-4-2026`,`5-5-2026`,`14-5-2026`,`24-5-2026`,`25-5-2026`,`25-12-2026`],N={FEMALE:[`XS`,`S`,`M`,`L`,`XL`],KIDS:[`104`,`116`,`128`,`140`,`152`],BABY_BASIC:[`50/56`,`62/68`,`74/80`,`86/92`],BABY_PREMIUM:[`62/68`,`74/80`,`86/92`],DEFAULT:[`S`,`M`,`L`,`XL`,`XXL`]},P=64;function F(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}function I(e){let t=[];e.category&&t.push(e.category.split(`-`).map(e=>e.slice(0,2)).join(`_`)),e.product_id&&t.push(e.product_id),e.qty&&t.push(e.qty),e.width&&t.push(e.width),e.height&&t.push(e.height),e.delivery_speed&&t.push(e.delivery_speed.slice(0,1));let n=e.decorations;n?.length&&t.push(n.map(e=>e.answer).sort().join(`_`));let r=e.properties?.sizes;r&&t.push(Object.keys(r).sort().map(e=>e+r[e]).join(`_`));let i=t.join(`_`);if(i.length<=P)return i;let a=F(i);return`${i.slice(0,P-a.length-1)}_${a}`}function L(){try{let{$i18n:t}=e();return`~~${t.t(`common.design`)}`}catch{return`~~Design`}}function R(e){let t={id:e.id||null,product_id:e.product_id||0,ref:e.ref||L(),description:e.description||``,category:e.category||``,price:e.price||null,width:e.width||null,height:e.height||null,files:e.files||[{path:null}],qty:e.qty||0,delivery_speed:e.delivery_speed||`normal`,decorations:e.decorations||[],tax_id:e.tax_id||3,properties:e.properties||null,has_file_requirement:e.has_file_requirement,group_id:e.group_id||``};return t.group_id||=I(t),t}function z(e,t,n,r=new WeakSet){if(!n)return null;if(typeof n==`object`){if(r.has(n))return null;r.add(n)}if(Array.isArray(n)){for(let i of n){let n=z(e,t,i,r);if(n)return n}return null}return n[e]===t?n:n.children&&Array.isArray(n.children)&&n.children.length>0?z(e,t,n.children,r):null}function ee(e,t=20,n=500){return e()?Promise.resolve():new Promise((r,i)=>{let a=0,o=y(()=>{e()?(clearInterval(o),r()):(a++,a>=t&&(clearInterval(o),i(Error(`Timeout waiting for condition`))))},n)})}var B=s(0),te=s(0),V=s([]),H=s(null),U=()=>{let e=e=>{B.value=e,te.value++},t=(e,t)=>{V.value[e]=t};
2return{openSignalIdx:B,openSignalVersion:te,skippedQuestions:V,resetSignalIdx:H,signalOpen:e,setSkipped:t,signalReset:e=>{H.value=e},clearResetSignal:()=>{H.value=null},openNextLogicalQuestion:n=>{let{questions:r,filters:i}=W();for(let a=n;a<r.length;a++){if(!(r[a].key in i)){e(a);return}let n=!1;for(let e=0;e<a;e++)r[e].key in i||(t(e,!0),n=!0);if(n)return}}}},ne=(e,t,r)=>{let c=l(),{language:u}=v(),d=U(),{skippedQuestions:f,openSignalIdx:p,openSignalVersion:m,resetSignalIdx:h}=d,_=W(),{filters:y,questions:b,isLoading:x,filtersPerQuestion:S,filteredQuestions:C,availableAnswers:w,isResetting:T}=g(_),E=s(!1),D=s([]),O=s(!1),k=s(!1),A=a(()=>y.value[e.value.key]),j=a(()=>e.value?.values.buckets),M=()=>{_.loadQuestions({category:c.params.product,loading:!!c.query.product})},N=(e=!1)=>{if(t.value===0)return!1;let n=!1;for(let r=t.value-1;r>=0;r--)b.value[r].key in y.value||(n=!0,e&&!k.value&&d.setSkipped(r,!0));return n},P=()=>{if(t.value===b.value.length-1)return!1;for(let e=t.value+1;e<=b.value.length-1;e++)if(b.value[e].key in y.value)return!0;return!1},F=(n,i)=>{i?.target?.closest(`#icon`)||A.value===n||x.value||(i&&r(`answer-chosen`),_.addFilter({question:e.value.key,answer:n}),M(),E.value=!1,d.setSkipped(t.value,!1),!N(!0)&&d.openNextLogicalQuestion(t.value+1))},I=()=>{w.value?.[t.value]?.length===1&&!y.value[e.value.key]&&!O.value&&(k.value=!0,F(w.value[t.value][0]))},L=async()=>{T.value&&await ee(()=>!T.value);let n=(A.value?S.value[e.value.key]:C.value)?.[t.value]?.values.buckets.map(e=>e.key)??[];if(_.setAvailableAnswers({idx:t.value,answers:n}),!N())try{I()}catch(e){console.error(e)}O.value=!1,D.value=j.value.filter(e=>!n.includes(e.key)).map(e=>e.key)},R=n=>{A.value&&(O.value=!0,_.resetQuestion({question:e.value.key,category:c.params.product}),E.value=!0,P()&&d.setSkipped(t.value,!0),document.getElementById(`question-${n}`)?.scrollIntoView({behavior:`smooth`}))},z=()=>{let t=y.value[e.value.key],n=e.value.values.buckets.find(e=>e.key===t);if(!n)return t;let r=(n.value.hits.hits[0]._source[`answer_${u.value}`]?.replace(/<br>/g,` `)||``).toString();return r[0]?.toUpperCase()+r.substring(1)||``},B=()=>{let t=c.query.filter;if(!t)return null;let n=e.value.values.buckets.find(e=>{let n=e.value.hits.hits[0]._source[`answer_${u.value}`];return n===t||n.replace(`+ `,``)===t});return n&&setTimeout(()=>F(n.key),100),n};return n(C,()=>L()),n(m,()=>{p.value===t.value&&(y.value[e.value.key]||(E.value=!0,I()))}),n(h,e=>{e===t.value&&(R(e),d.clearResetSignal())}),i(()=>{let e=B();t.value===0&&!e&&!c.query.product&&(E.value=!0),o(()=>L())}),{showAnswers:E,disabledAnswers:D,filters:y,questions:b,isLoading:x,availableAnswers:w,skippedQuestions:f,selectedAnswer:A,answerArray:j,handleInput:F,resetQuestion:R,getAnswer:z}},W=m(`product`,{state:()=>({categories:[],horizontalCategories:[],questions:[],options:[],selectedOptions:[],filters:{},product:null,products:[],customSize:{width:null,height:null},sizeErrors:[],customPrice:null,clothingSizes:{},designs:1,filteredQuestions:[],selectedQtySpeed:null,isLoading:!0,filtersPerQuestion:{},lastAddedFilter:null,lastCategory:null,availableAnswers:[],quoteMode:!1,isResetting:!1}),getters:{hasFileRequirement(e){return!e.products[0]?.description.includes(`geen bedrukking`)&&e.products[0]?.type!==4},fixedWidth(e){return Number(e.products[0]?.width)/(e.products[0]?.type===3?10:1)||0},fixedHeight(e){return Number(e.products[0]?.height)/(e.products[0]?.type===3?10:1)||0},showOptions(e){return e.product?!!e.product.options.length:!!e.products[0]?.options?.length}},actions:{setCategories(e){if(!e){this.categories=[],this.horizontalCategories=[];return}if($().config.storeCode===`RL`){let t=_(e),n=e=>e.map(e=>(delete e.horizontal_bar,e));this.categories=n(t),this.horizontalCategories=e.filter(e=>e.id!==136).map(e=>({id:e.id,title:e.title,slug:e.slug,menu:e.horizontal_bar||[],fetched:!!e.horizontal_bar?.length}))}else this.categories=e},async fetchHorizontalCategories(){let e=Z(),t=$(),n=this.horizontalCategories.map(async(n,r)=>{if(n.fetched)return;let i;try{i=await d(`${t.config.baseUrl}/data/${t.languageCode}/products/${n.slug}.json`)}catch{}if(!i)try{i=await e(`/catalog/pages/${n.id}/content/`)}catch(e){console.error(e)}this.horizontalCategories[r].menu=i?.horizontal_bar||[],this.horizontalCategories[r].fetched=!0});await Promise.all(n)},async fetchFilteredProducts({category:e,filters:t,identifier:n}){return await Z()(`/filter`,{method:`POST`,body:{category:e,filters:t},headers:n?{"X-Request-Source":n}:{},credentials:`include`})},async loadQuestions({category:e,loadId:t,loading:n}){this.isLoading=!0;try{$().config.countryCode!==`NL`&&(e=this.getProduct(`slug`,e)?.slug_source||e);let r=await this.fetchFilteredProducts({category:e,filters:this.filters,identifier:`initial-load`}),i=r?.hits.hits.map(e=>e._source);if(this.products=i,this.products[0]?.display!==`calc_view`&&(this.customSize={width:null,height:null},(this.customPrice?.width||this.customPrice?.height)&&(this.customPrice=null)),!this.products.length&&this.lastAddedFilter&&!this.isResetting){this.resetProduct(e,!1,!0);return}if(r?.hits.total.value<=2&&r?.hits.total.value>0){let e=t||null;
2this.selectProduct({id:e,loading:n})}else n||(this.product=null,this.options=[]);this.questions.length<1&&!Object.keys(this.filters).length?this.questions=r?.aggregations.questions_nest.questions_agg.buckets:this.replaceIcons(r?.aggregations.questions_nest.questions_agg.buckets),this.lastCategory=e;let a=Object.keys(this.filters).map(async t=>{let n={...this.filters};if(delete n[t],Object.keys(n).length===0&&this.questions.length>0)return{filter:t,data:this.questions};try{return{filter:t,data:(await this.fetchFilteredProducts({category:e,filters:n,identifier:`filter-calc-${t}`}))?.aggregations.questions_nest.questions_agg.buckets}}catch(e){return console.error(e),null}});(await Promise.all(a)).forEach(e=>{e&&(this.filtersPerQuestion[e.filter]=e.data)}),(r?.aggregations.questions_nest.questions_agg.buckets)?.forEach((e,t)=>{if(e.values.buckets[0]?.value.hits.hits[0]?._source.hidedisabled)if(this.filters[e.key]){let n=this.filtersPerQuestion[e.key]?.find(t=>t.key===e.key);n&&(this.questions[t]=n)}else this.questions[t]=e}),r?.hits.total.value>0&&(this.filteredQuestions=r?.aggregations.questions_nest.questions_agg.buckets)}catch(e){console.error(e)}this.isLoading=!1},replaceIcons(e){this.questions.forEach((t,n)=>{t.values.buckets.forEach((t,r)=>{e[n]?.values.buckets.forEach(e=>{e.key===t.key&&(this.questions[n].values.buckets[r].value.hits.hits[0]._source.icon=e.value.hits.hits[0]._source.icon)})})})},addFilter(e){e&&(this.filters={...this.filters,[e.question]:e.answer},this.lastAddedFilter=e)},removeFilter(e){let{[e]:t,...n}=this.filters;this.filters=n},setSelectedQtySpeed(e){this.selectedQtySpeed=e},setDesigns(e){this.designs=e},setSelectedOptions(e){this.selectedOptions=e},setCustomSize({size:e,dimension:t}){this.customSize[t]=e},setCustomPrice(e){this.customPrice=e},resetCustomPrice(){this.customPrice=null},setClothingSizes(e){this.clothingSizes=e},setQuoteMode(e){this.quoteMode=e},setAvailableAnswers({idx:e,answers:t}){this.availableAnswers[e]=t},getProduct(e,t){return z(e,t,this.categories)},selectProduct({id:e,loading:t}){if(this.selectedQtySpeed){let t=Number(this.selectedQtySpeed.split(`-`)[0]),n=this.selectedQtySpeed.split(`-`)[1];if(e==null){let e=this.products.filter(e=>e.qtys?.filter(e=>Number(e.qty)===t&&e.speed===n?e:null)?.length>=1?e:null),r=e[0]||this.products[0];this.product=r,e.length===0&&!this.quoteMode&&(this.selectedQtySpeed=null)}else{let t=this.products.find(t=>t.id===String(e));t&&(this.product=t)}this.sortOptionsByQuestion(),this.resetOptions()}else t||(this.product=null)},resetOptions(){if(!this.product?.options){this.selectedOptions=[];return}let e=new Set(this.product.options.map(e=>e.id));this.selectedOptions=this.selectedOptions.filter(t=>e.has(t.id))},async resetProduct(e,t=!1,n=!1){let r=_(this.filters);t&&(this.questions=[]),this.filteredQuestions=[],this.availableAnswers=[],this.options=[],this.designs=1,this.selectedOptions=[],this.filters={},this.filtersPerQuestion={},this.selectedQtySpeed=null,this.quoteMode=!1,this.customSize={width:null,height:null},e&&(t&&await this.loadQuestions({category:e}),n&&await this.reapplyFiltersAfterReset(e,r))},async reapplyFiltersAfterReset(e,t){this.isResetting=!0;let n=this.lastAddedFilter;this.lastAddedFilter=null,this.addFilter(n),await this.loadQuestions({category:e});let r=null;for(let i in t){if(i===n?.question)continue;let a=this.questions.findIndex(e=>e.key===i);this.questions[a]?.values.buckets[0].value.hits.hits[0]._source.hidedisabled||this.filteredQuestions?.[a]?.values.buckets.some(e=>e.key===t[i])&&((r==null||a>r)&&(r=a),this.addFilter({question:i,answer:t[i]}),await this.loadQuestions({category:e}))}this.isResetting=!1,this.products.length===0&&(this.lastAddedFilter=null),r!==null&&U().openNextLogicalQuestion(r+1)},resetQuestion({question:e,category:t}){this.removeFilter(e),this.selectedQtySpeed=null,this.loadQuestions({category:t})},sortOptionsByQuestion(){let e=this.product?.options?.reduce((e,t)=>(Object.keys(e).includes(t.question)||(e[t.question]=this.product.options.filter(e=>e.question===t.question)),e),{})??{};this.options=e},addSelectedOption({name:e,answer:t}){let n=this.selectedOptions.findIndex(n=>t.inputtype===`checkbox`?n.id===t.id:n.question===e);if(n===-1)this.selectedOptions=[...this.selectedOptions,t];else{let e=[...this.selectedOptions];e[n]=t,this.selectedOptions=e}},removeSelectedOption(e,t){this.selectedOptions=t?this.selectedOptions.filter(e=>e.id!==t):this.selectedOptions.filter(t=>t.question!==e)},async loadProductFromId(e){if(!e)return;let t=Z();this.isLoading=!0;try{let n=await t(`/product/`+e);
2return n._source.questions.forEach(e=>{this.addFilter({question:e.question,answer:e.answer})}),this.product=n._source,n}catch(e){console.error(e)}finally{this.isLoading=!1}}}}),re,ie=async()=>re??=await(async()=>{let{createToastInterface:e}=await p(async()=>{let{createToastInterface:e}=await import(`./BnzKVNWm.js`);return{createToastInterface:e}},__vite__mapDeps([0,1,2]),import.meta.url);return await p(()=>Promise.resolve({}),__vite__mapDeps([3]),import.meta.url),e()})();function G(){return new Proxy({},{get:(e,t)=>(...e)=>ie().then(n=>n[t](...e))})}var K=null,q=e=>{for(let t=e.length-1;t>=0;t--)e[t].items.length===0&&e.splice(t,1);return e},J=m(`cart`,{state:()=>({id:null,mergeAlert:null,cartAlert:null,cartItems:[],packages:[],fileCheck:`normal`,paymentMethod:null,paymentIssuer:null,orderReference:null,coupon:null,deliveryType:`delivery`,shippingType:`neutral`,addresses:{delivery:null,servicePoint:null,invoice:null,shipping:null},invoiceCc:null,cartProductsInfo:[],showDhlPickupNameError:!1,receiveNewsletter:!1,totalEx:0,totalIn:0,isLoading:!1}),persist:{pick:[`id`,`cartItems`,`fileCheck`,`orderReference`,`deliveryType`,`invoiceCc`,`cartProductsInfo`]},getters:{getNumCartItems(){return this.cartItems.filter(e=>!w.includes(e.category)).length},getCartItemDescription:e=>t=>e.cartItems[t]?.description||``,getCartItemIdx:e=>t=>e.cartItems.findIndex(e=>String(e.id)===String(t)),getGroupId:e=>t=>e.cartItems.find(e=>String(e.id)===String(t))?.group_id,getCartItemById:e=>t=>e.cartItems.find(e=>String(e.id)===String(t)),getProductInfo:e=>t=>e.cartProductsInfo.find(e=>String(e.id)===String(t))},actions:{normalizeItems(e){return e.map(e=>R({...e}))},addCartItem(e){this.cartItems.push(e),this.syncCartItems()},addCartItems(e){this.cartItems.push(...e),this.syncCartItems()},addDesign({groupId:e,numToAdd:t}){let n=this.cartItems.find(t=>t.group_id===e),r=[];for(let e=0;e<t;e++){let e=R({..._(n),id:null,ref:void 0,files:null});r.push(e)}this.addCartItems(r)},editItem({itemId:e,qty:t,properties:n}){let r=this.cartItems.findIndex(t=>String(t.id)===String(e));if(r===-1)return;let i=this.cartItems[r],a=R({..._(i),qty:t,properties:n,group_id:null});this.cartItems[r]=a;let o=!1;this.packages.forEach((e,n)=>{let r=e.items.findIndex(e=>String(e.order_item_id)===String(i.id));r!==-1&&(this.packages[n].items[r].qty=t,o=!0)}),this.syncCartItems(),o&&this.queuePackagesSync()},createPackages(){let e=[];
2if(this.packages.length===0){let t={shipping_option_id:T.NORMAL,parcel_point_id:null,parcel_point_name:null,by_customer:!1,delivery_address:null,shipping_address:null,shipping_as:this.shippingType,items:[]};this.cartItems.filter(e=>!w.includes(e.category)).forEach(e=>t.items.push({order_item_id:e.id,qty:e.qty})),t.items.length>0&&e.push(t)}else{e=_(this.packages),e.forEach(e=>{e.items=e.items.map(e=>{let t=this.cartItems.find(t=>String(t.id)===String(e.order_item_id));return t?{...e,qty:t.qty}:null}).filter(Boolean)});let t=this.cartItems.filter(t=>e.every(e=>e.items.every(e=>String(e.order_item_id)!==String(t.id)))&&!w.includes(t.category));t.length>0&&t.forEach(t=>{e[0].items.push({order_item_id:t.id,qty:t.qty})}),e=q(e)}this.updatePackages(e)},updatePackages(e,t=!0){let n=JSON.stringify(this.packages)!==JSON.stringify(e);this.packages=e,!(!t||!n)&&this.queuePackagesSync()},changeDeliveryType(e){this.setDeliveryType(e),this.packages.length||this.createPackages();let t=_(this.packages);if(t.length!==0){if(e===`delivery`){let e=[T.NORMAL,T.MORNING,T.EVENING];t.forEach(t=>{t.delivery_address=this.addresses.delivery,t.parcel_point_id=null,e.includes(t.shipping_option_id)||(t.shipping_option_id=T.NORMAL)})}else{let n=t[0]?.shipping_address;t=[{id:t[0]?.id,parcel_point_id:e===`dhl`?this.addresses.servicePoint?.id:null,parcel_point_name:null,shipping_option_id:T[e===`dhl`?`DHL_POINT`:`PICKUP`],by_customer:!1,delivery_address:null,shipping_address:n,shipping_as:this.shippingType,items:[]}],this.cartItems.filter(e=>!w.includes(e.category)).forEach(e=>t[0].items.push({order_item_id:e.id,qty:e.qty}))}t=q(t),this.updatePackages(t,e!==`dhl`)}},setDeliveryType(e){this.deliveryType=e},changeDhlPickupName(e,t=!0){let n=_(this.packages);n.forEach(t=>{t.parcel_point_name=e}),this.updatePackages(n,t)},changeDeliveryMoment(e){let t=e===`normal`?T.NORMAL:e===`morning`?T.MORNING:T.EVENING;this.packages.length||this.createPackages();let n=_(this.packages);n.length>0&&(n[0].shipping_option_id=t,this.updatePackages(n))},async syncCartItems(){this.isLoading=!0;try{let e=await Z()(`/cart/${$().userToken}`,{method:`PUT`,body:{items:_(this.cartItems)},credentials:`include`});this.processCartData(e)}catch(e){console.error(e)}finally{this.isLoading=!1}},async getCartItems(){try{let e=await Z()(`/cart/${$().userToken}`,{credentials:`include`});this.processCartData(e)}catch(e){console.error(e)}},processCartData(e){let t=this.normalizeItems(e.resource.items);this.setOrderId(e.resource.order.id),this.setTotals(e.resource.order.sub_total_amount,e.resource.order.total_amount),this.updateCartItems(t),e.resource.packages&&K===null&&this.updateSyncedPackages(e.resource.packages)},async syncInvoiceAddress(){this.isLoading=!0;try{let e=await Z()(`/cart/${$().userToken}`,{method:`PUT`,body:{invoice_address:this.addresses.invoice},credentials:`include`});this.processCartData(e)}catch(e){console.error(e)}finally{this.isLoading=!1}},async syncOrderReference(){this.isLoading=!0;try{await Z()(`/cart/${$().userToken}`,{method:`PUT`,body:{order:{reference:this.orderReference}},credentials:`include`})}catch(e){console.error(e)}finally{this.isLoading=!1}},async syncCoupon(n){try{let r=Z(),{$i18n:i}=e(),{countryCode:a}=t().public,{intlLocale:o}=v(),s=$(),c=W(),l=G(),u=await r(`/cart/${s.userToken}/apply-coupon`,{method:`POST`,body:{coupon:n},credentials:`include`});if(this.getCartItems(),u.applied){this.coupon=u.coupon;let e=u.coupon?.slugs||[];if(!e.length)l.success(i.t(`checkout.coupon_applied`,{coupon:n}));else{let t=new Set(this.cartItems.map(e=>e.category)),r=e.map(e=>{let n=(a===`NL`?null:c.getProduct(`slug_source`,e))||c.getProduct(`slug`,e);return{inCart:t.has(n?.slug||e),title:(n?.title||e.replace(/-/g,` `)).toLowerCase()}}),s=r.filter(e=>e.inCart),u=new Intl.ListFormat(o.value).format((s.length?s:r).map(e=>e.title));l.success(i.t(s.length?`checkout.coupon_applied_slugs`:`checkout.coupon_applied_no_match`,{coupon:n,products:u}))}}else this.coupon=null;return u}catch(e){console.error(e)}},async syncNewsletter(){this.isLoading=!0;try{await Z()(`/cart/${$().userToken}`,{method:`PUT`,body:{newsletter:this.receiveNewsletter},credentials:`include`})}catch(e){console.error(e)}finally{this.isLoading=!1}},async syncFileCheck(){this.isLoading=!0;try{let e=await Z()(`/cart/${$().userToken}`,{method:`PUT`,body:{order:{selected_file_validation:this.fileCheck}},credentials:`include`});this.processCartData(e)}catch(e){console.error(e)}finally{this.isLoading=!1}},async syncInvoiceCc(){this.isLoading=!0;try{let e=await Z()(`/cart/${$().userToken}`,{method:`PUT`,body:{order:{invoice_cc_email:this.invoiceCc}},credentials:`include`});this.processCartData(e)}catch(e){console.error(e)}finally{this.isLoading=!1}},queuePackagesSync(){this.isLoading=!0,clearTimeout(K),K=setTimeout(()=>{K=null,this.commitPackagesSync()},300)},async commitPackagesSync(){try{let e=await Z()(`/cart/${$().userToken}`,{method:`PUT`,body:{packages:_(this.packages)},credentials:`include`});this.processCartData(e);let t=e.resource.packages[0];!t?.delivery_address&&!t?.parcel_point_id&&t?.shipping_option_id!==T.PICKUP&&this.setDeliveryType(null)}catch(e){console.error(e)}finally{K===null&&(this.isLoading=!1)}},async addCartProductInfo(e){if(!this.cartProductsInfo.some(t=>String(t.id)===String(e.id))){let t={...e},n=await this.getTemplate(e.template);
2n&&(n=h(n),t.templateWidth=n.template[0].width,t.templateHeight=n.template[0].height),this.cartProductsInfo.push(t)}},async getTemplate(e){try{return await Z()(`/template/${e}`,{credentials:`include`})}catch(e){console.error(e)}},removeCartItem(e){let t=this.packages.findIndex(t=>t.items.some(t=>String(t.order_item_id)===String(e))),n=!1;if(t!==-1){let r=this.packages[t].items.filter(t=>String(t.order_item_id)!==String(e));this.packages[t].items=r,this.packages=q(this.packages),n=!0}let r=this.cartItems.findIndex(t=>String(t.id)===String(e));r!==-1&&this.cartItems.splice(r,1),this.syncCartItems(),n&&this.queuePackagesSync()},removeCartProductInfo(e){if(!this.cartItems.some(t=>String(t.product_id)===String(e))){let t=this.cartProductsInfo.findIndex(t=>String(t.id)===String(e));t!==-1&&this.cartProductsInfo.splice(t,1)}},updateCartItems(e){this.cartItems=e},updateCartItem({cartItem:e,resetDesign:t}){this.cartItems.forEach((n,r)=>{if(n.group_id===e.group_id){let i=_(e);i=R({...i,id:n.id,files:n.files,ref:n.ref}),t&&i.files.forEach(e=>{e.path=null}),this.cartItems[r]=i}}),this.syncCartItems()},updateSyncedPackages(e){this.packages=q(_(e))},changeOrderReference(e){this.orderReference=e},changeCoupon(e){this.coupon=e},changeNewsletter(e){this.receiveNewsletter=e},changeItemReference({groupId:e,reference:t}){this.cartItems.forEach(n=>{if(n.group_id===e){let e=n.ref.split(`~~`);n.ref=t+`~~`+e[1]}}),this.syncCartItems()},changeFileCheck(e){this.fileCheck=e},changePaymentMethod(e){this.paymentMethod=e},changePaymentIssuer(e){this.paymentIssuer=e},changeAddress({type:e,address:t},n=!0){if(t&&Object.prototype.hasOwnProperty.call(t,`is_primary_delivery`)&&(t.user_address_id=t.id,delete t.id,delete t.is_primary_delivery,delete t.is_primary_invoice,delete t.is_primary_shipping),this.addresses[e]=t,e!==`invoice`){if(this.packages.length||this.createPackages(),this.packages.forEach((n,r)=>{this.packages[r][e+`_address`]=t}),!n||!this.packages.length)return;this.queuePackagesSync()}else n&&this.syncInvoiceAddress()},changeServicePointAddress(e){this.addresses.servicePoint=e},changeInvoiceCc(e){this.invoiceCc=e},changeShippingType(e,t=!0){this.shippingType=e;let n=_(this.packages);n.forEach(t=>{t.shipping_as=e}),t&&this.updatePackages(n)},submitFile({file:e,cartItemIdx:t,encodedString:n,type:r=`content`,service:i=`upload`}){let a=this.cartItems[t].files.findIndex(e=>e.description_type===r),o={path:e,description_type:r,service:i,customer_acceptance:n||null};a===-1?this.cartItems[t].files.push(o):this.cartItems[t].files[a]=o,this.syncCartItems()},setMergeAlert(e){this.mergeAlert=e},setCartAlert(e){this.cartAlert=e},resetCartState(){this.$reset()},removeAllCartItems(){this.cartItems=[],this.cartProductsInfo=[],this.packages=[],this.syncCartItems(),this.queuePackagesSync()},setOrderId(e){this.id=e},setDhlPickupNameError(e){this.showDhlPickupNameError=e},setTotals(e,t){this.totalEx=e,this.totalIn=t},setPackages(e){this.packages=q(_(e))}}}),ae={products:{endpoint:`menus/drukken`,slug:`products`,remove:[`image`,{field:`icon`,keepFirstChildren:!0}]},service:{endpoint:`menus/klantenservice`,slug:`service`,remove:[`canonical_id`,`is_new`]},themes:{endpoint:`menus/themas`,slug:`themes`,overviewId:95,remove:[`icon`,`is_popular`,`is_new`]},pages:{endpoint:`menus/paginas`,slug:`page`,remove:[`image`,`icon`,`intro`,`canonical_id`,`is_popular`,`is_new`]},guide:{endpoint:`menus/keuzehulp`,slug:`guide`,stores:[`RL`],nested:!0,overviewId:2193,remove:[`is_popular`,`is_new`]},store:{endpoint:`store`},header:{endpoint:`catalog/pages/133/content`},footer:{endpoint:`catalog/pages/135/content`},notifications:{endpoint:`catalog/pages/1677/content`},reviews:{endpoint:`places/reviews`}},oe=(e,t)=>!e.stores||e.stores.includes(t),se=e=>Object.fromEntries(Object.entries(ae).filter(([,t])=>oe(t,e))),Y={},ce=()=>{let e=t().public;return{getTree:async(t,n)=>{let r=`${n}-${t}`;if(Y[r])return Y[r];let i;return i=(await d(`${e.baseUrl}/data/${n}/main.json`))?.[t],Y[r]=i?.data.resource.children||[],Y[r]}}},le=()=>{let t=J(),{getTree:n}=ce(),{intlLocale:r}=v(),{$i18n:i}=e(),a=async(e,t)=>{for(let r of t){let t=z(`slug`,e,await n(`products`,r));if(t?.id)return t}return null};return{localizeCartItems:async(e,o)=>{let s=i.locales.value.map(e=>e.code??e);if(s.length<2||!t.cartItems.length)return;
2let c=[...new Set([o,e,...s].filter(Boolean))],l=await n(`products`,e),u=[],d=[],f=!1;for(let n of t.cartItems){let r=await a(n.category,c),i=r?z(`id`,r.id,l):null;if(!i){r?(d.push({item:n,title:r.title}),f=!0):u.push(n);continue}let o=t.getProductInfo(n.product_id)?.[`description_${e}`]||n.description.split(` 3`).slice(1).join(` 4`),s=`${i.title}\n${o}`.trim();if(i.slug===n.category&&s===n.description){u.push(n);continue}f=!0,u.push(R({...n,category:i.slug,description:s,group_id:i.slug===n.category?n.group_id:null}))}if(f){if(d.length){let e=new Set(d.map(({item:e})=>String(e.id)));t.setPackages(t.packages.map(t=>({...t,items:t.items.filter(t=>!e.has(String(t.order_item_id)))})))}t.updateCartItems(u),t.syncCartItems(),d.length&&(t.queuePackagesSync(),d.forEach(({item:e})=>t.removeCartProductInfo(e.product_id)),G().warning(i.t(`cart.alert.unavailable_in_language`,{products:new Intl.ListFormat(r.value).format(d.map(({title:e})=>e))})))}}}};function ue(e,t,n=86400){let r={value:t,ttl:Date.now()+n*1e3};localStorage?.setItem(e,JSON.stringify(r))}function de(e){let t=localStorage?.getItem(e);if(!t)return null;let n=JSON.parse(t);return Date.now()>n.ttl?(localStorage.removeItem(e),null):n.value}var fe=()=>{let e=Z(),t=async t=>{if(!t)return null;let n=de(t);if(n)return n;try{let n=await e(`/product/${t}`),r=n?._source||n;return r&&ue(t,r,86400),r}catch(e){if(e?.status===500)throw e;return console.error(`Failed to fetch product info for ${t}:`,e),null}};return{fetchProduct:t,fetchProductsForItems:async(e,n=`product_id`,r=`product`)=>{if(!e||!e.length)return;let i=[...new Set(e.map(e=>e[n]).filter(Boolean))].map(async e=>{try{return{id:e,product:await t(e)}}catch{return{id:e,product:null}}}),a=await Promise.all(i),o=new Map(a.map(e=>[String(e.id),e.product]));e.forEach(e=>{let t=e[n];if(t&&o.has(String(t))){let n=o.get(String(t));n&&(e[r]=n)}})},fetchCustomPrice:async(t,n,r,i)=>{let a=Array.isArray(t)?t.join(`_`):t;try{return await e(`/product/${a}/${n}/${r}/${i}`)}catch(e){return console.error(`Failed to fetch custom price for ${a}:`,e),null}},extractPriceObject:(e,t=null)=>{if(!e||!Array.isArray(e))return null;if(e.some(e=>e.errors&&e.errors.length===0)){let n=e.filter(e=>e.errors&&e.errors.length===0),r=null;return t&&(r=n.find(e=>String(e.product_id)===String(t))),r||=n.reduce((e,t)=>t.normalpricetotal<e.normalpricetotal?t:e),{id:r.product_id,qty:r.qty,normal:r.normalpricetotal,express:r.expresspricetotal,overnight:r.overnightpricetotal,width:r.width,height:r.height}}return null}}},X=()=>{let e=J(),n=$(),{public:r}=t(),i=Q(),a=f(),{language:o}=v(),{localizeCartItems:s}=le(),c=async e=>{try{return await d(`https://api-gw.dhlparcel.nl/parcel-shop-locations/${r.countryCode}/${e}`)}catch(e){return console.error(`Failed to fetch DHL point:`,e),null}},l=async t=>{let n=t?.filter(e=>e.items?.length>0)??[];if(!n.length)return;e.setPackages(n);let{delivery_address:r,shipping_option_id:i,parcel_point_id:a,parcel_point_name:o,shipping_address:s,shipping_as:l}=n[0];if(i!==T.PICKUP&&s&&(e.changeAddress({type:`shipping`,address:s},!1),e.changeShippingType(l||`neutral`,!1)),i===T.NORMAL&&e.setDeliveryType(`delivery`),r&&e.changeAddress({type:`delivery`,address:r},!1),i===T.DHL_POINT&&a){o&&e.changeDhlPickupName(o,!1);let t=await c(a);t&&(e.changeServicePointAddress(t),e.setDeliveryType(`dhl`))}else i===T.PICKUP&&e.setDeliveryType(`pickup`)},u=t=>{e.setTotals(t.order.sub_total_amount,t.order.total_amount),t.order.reference&&e.changeOrderReference(t.order.reference),t.order.selected_file_validation&&e.changeFileCheck(t.order.selected_file_validation),t.order.invoice_cc_email&&e.changeInvoiceCc(t.order.invoice_cc_email),Array.isArray(t.invoice_address)||e.changeAddress({type:`invoice`,address:t.invoice_address},!1),t.coupon&&e.changeCoupon(t.coupon),t.order.payment_method&&e.changePaymentMethod(t.order.payment_method)},p=async t=>{let{fetchProduct:n}=fe(),r=t.filter(t=>t.product_id&&!e.cartProductsInfo.some(e=>e.id==t.product_id));if(!r.length)return;let i=[...new Set(r.map(e=>e.product_id))].map(async r=>{try{let t=await n(r);t&&await e.addCartProductInfo(t)}catch{t.filter(e=>
4String(e.product_id)===String(r)).forEach(t=>e.removeCartItem(t.id))}});await Promise.all(i)};return{syncCart:async(t=!1)=>{let r=e.cartItems.length;try{let{resource:c}=await Z()(`/cart/${n.userToken}`,{credentials:`include`});e.updateCartItems(e.normalizeItems(c.items)),c?.items.length>0&&(e.setOrderId(c.order.id),await l(c.packages),u(c),p(c.items).then(()=>s(o.value)),t&&r&&r!==c.items.length&&(e.setMergeAlert(`previous`),i.setRedirectUrl(a({name:`checkout-cart`}))))}catch(e){console.error(`Error syncing cart:`,e)}}}},Z=()=>{let{public:n}=t(),{$i18n:r}=e(),i=Q(),{syncCart:a}=X();return async(e,t={})=>{let o=()=>d(e,{baseURL:n.apiUrl,...t,query:{lang:r.locale.value.toUpperCase(),...t.query},onRequest({options:e}){let t=new Headers(e.headers);t.set(`Accept`,`application/json`),t.set(`X-XSRF-TOKEN`,u(`XSRF-TOKEN`).value||``),e.headers=t},async onResponse({request:e,response:n}){let r=new URL(String(e));if(n.ok&&r.pathname.endsWith(`/login`)&&(await a(!0),await i.getUser(),!t.skipAuthRedirect)){let e=i.redirectUrl;e===`/`&&(e=localStorage?.getItem(`redirect`)||`/`),localStorage?.removeItem(`redirect`),c(e)}}});try{return await o()}catch(e){let r=e?.response?.status??e?.statusCode;if(r===419&&!t._retry)return t._retry=!0,await d(`${n.apiUrl}/sanctum/csrf-cookie`,{credentials:`include`}),await o();r===401&&!t.skipLogout&&i.logout(!1);let a=e?.response?._data??e?.data;throw a&&typeof a==`object`&&!(`status`in a)&&(a.status=r),a??e}}},pe=m(`account`,()=>{let e=s({});async function t(e=!1){if(!Q().isLoggedIn)return;let t=Z();try{n(await t(`/stats`+(e?`?force=true`:``),{credentials:`include`}))}catch(e){console.error(e)}}function n(t){e.value=t}return{stats:e,getStats:t,updateStats:n}}),Q=m(`auth`,()=>{let e=f(),t=s(null),n=s(`/`);return{user:t,redirectUrl:n,isLoggedIn:a(()=>!!t.value),getUser:async()=>{try{let e=Z(),{track:n}=S();if(!(await e(`/authenticated`,{credentials:`include`}))?.authenticated)return;let r=await e(`/user`,{credentials:`include`});t.value=r?.data,n({user_id:t.value.id}),pe().getStats()}catch(e){console.error(e,`Failed to get user.`)}},logout:async(n=!0)=>{try{let r=Z(),{track:i}=S();await r(`/logout`,{method:`POST`,body:{},credentials:`include`,skipLogout:!0}),t.value=null,n&&await c(e(`/`)),i({user_id:null})}catch(e){console.error(e)}},setRedirectUrl:(e,t=!1)=>{n.value=e,t&&localStorage&&localStorage.setItem(`redirect`,e)}}}),me=m(`pages`,()=>{let e=s([]),t=s([]),n=s([]),r=s([]);return{service:e,themes:t,pages:n,guides:r,getTheme:a(()=>(e,n)=>t.value?.[0]?.children?.find(t=>t[e]===n)),setServicePages:t=>{e.value=t},setThemePages:e=>{t.value=e},setGuidePages:e=>{r.value=e},setPages:e=>{n.value=e},getPage:(t,n,r=e.value)=>z(t,n,r),reset:()=>{e.value=[],t.value=[],n.value=[],r.value=[]}}}),$=m(`root`,()=>{let n=Q(),{$i18n:r}=e(),i=s(t().public),o=s(null),c=s([]),l=s(!1),u=s(null),f=s(0),p=s(null),m=s({rating:0,reviews:[],total:0}),h=s(null),g=s(null),_=s([]),v=s(i.value.storeCode===`RL`?`shopping-bag`:`cart`),y=a(()=>n.isLoggedIn?n.user.id:u.value),b=a(()=>e=>{let t=p.value?.vat.high.multiplier??1.21;return l.value?e*t:e}),x=a(()=>r.locale.value),S=a(()=>{let e=W();return c.value.map(t=>(e.getProduct(`slug_source`,t)||e.getProduct(`slug`,t))?.slug).filter(
4Boolean)});async function C(){await M()}function w(){M(),u.value||j()}function T(e){if(typeof e==`boolean`){l.value=e;return}l.value=!l.value}function E(e){let t=W().getProduct(`slug`,e);if(!t||!t.is_visible)return;let n=t.slug_source||e,r=c.value.indexOf(n);r>-1&&c.value.splice(r,1),c.value.unshift(n),c.value.length>6&&c.value.pop()}function D(e){let t=W().getProduct(`slug`,e)?.slug_source||e;c.value=c.value.filter(n=>n!==t&&n!==e)}function O(){c.value=[]}function k(){p.value=null,g.value=null,h.value=null,_.value=[],m.value={rating:0,reviews:[],total:0},o.value=null}function A(){f.value++}function j(){u.value=crypto.randomUUID()}async function M(){let e=W(),t=me(),n=se(i.value.storeCode),r=x.value,a={};if(o.value===r&&p.value&&e.categories?.length&&t.pages?.length&&t.service?.length&&t.themes?.length)return;try{try{a=await d(`${i.value.baseUrl}/data/${r}/main.json`)}catch{}}catch(e){console.error(`[RootStore] Error fetching main.json`,e)}let s={},c=Object.keys(n).map(async e=>{try{if(a&&a[e]){s[e]=a[e];return}let t=`?store=${i.value.storeCode}&country=${i.value.countryCode}&lang=${r.toUpperCase()}`;s[e]=await d(`${i.value.apiUrl}/${n[e].endpoint}${t}`)}catch(t){console.error(`[RootStore] Failed to fetch data for ${e}`,t)}});await Promise.all(c),e.setCategories(s.products?.data.resource.children),t.setServicePages(s.service?.data.resource.children),t.setThemePages(s.themes?.data.resource.children),t.setPages(s.pages?.data.resource.children),t.setGuidePages(s.guide?.data.resource.children),p.value=s.store?.data,g.value=s.header,h.value=s.footer,_.value=s.notifications?.notifications.filter(e=>{let t=new Date,n=new Date(e.active_from),r=new Date(e.active_until);return e.is_active&&(!e.active_until||t<r)&&(!e.active_from||t>=n)})||[],s.reviews?.result&&(m.value=s.reviews.result),o.value=r}return{config:i,loadedLanguage:o,recentlyViewed:c,showVat:l,userToken:u,cacheKey:f,store:p,aggregateRating:m,footer:h,header:g,notifications:_,cartIcon:v,getPath:y,getVatPrice:b,languageCode:x,recentlyViewedSlugs:S,serverInit:C,clientInit:w,setShowVat:T,addRecentlyViewed:E,removeRecentlyViewed:D,clearRecentlyViewed:O,resetContent:k,refreshImageCache:A,refreshUserToken:j,getData:M}},{persist:{pick:[`recentlyViewed`,`showVat`,`userToken`]}});export{O as C,T as D,w as E,S as O,C as S,A as T,D as _,Z as a,N as b,le as c,G as d,W as f,R as g,ee as h,pe as i,ae as l,U as m,me as n,X as o,ne as p,Q as r,fe as s,$ as t,J as u,E as v,k as w,j as x,M as y};
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.