1"use strict";(self.webpackChunkWPRecipeMakerPublicSplit=self.webpackChunkWPRecipeMakerPublicSplit||[]).push([[10],{7743:(e,t,i)=>{i.r(t),i.d(t,{default:()=>p});var o=i(4181);i(942);const n={checkTemp:e=>{const t=localStorage.getItem("wprm-recipe-collection");if(t){const i=JSON.parse(t);if(i.hasOwnProperty("temp")&&i.temp.items.hasOwnProperty("0-0")){i.temp.items["0-0"].filter((t=>t.recipeId===e)).length>0&&n.updateButtons(e)}}},updateButtons:(e,t="add")=>{const i=document.querySelectorAll(".wprm-recipe-add-to-shopping-list");for(let o of i)e===parseInt(o.dataset.recipeId)&&(o.classList.contains("wprm-recipe-not-in-shopping-list")?o.style.display="add"===t?"none":"":o.classList.contains("wprm-recipe-in-shopping-list")&&(o.style.display="add"===t?"":"none"))}},p=n;var s;window.WPRecipeMaker=void 0===window.WPRecipeMaker?{}:window.WPRecipeMaker,window.WPRecipeMaker.shoppingList={init(){if(0===parseInt(wprmp_public.user)){const e=document.querySelectorAll(".wprm-recipe-add-to-shopping-list.wprm-recipe-not-in-shopping-list");for(let t of e){const e=parseInt(t.dataset.recipeId);n.checkTemp(e)}}if(document.addEventListener("click",(function(e){const t=!!e.target.closest&&e.target.closest(".wprm-recipe-add-to-shopping-list.wprm-recipe-not-in-shopping-list, .wprm-recipe-add-to-shopping-list.wprm-recipe-remove-from-shopping-list");t&&window.WPRecipeMaker.shoppingList.onClick(t,e)}),!1),"logged_in"===wprmp_public.quick_access_shopping_list.access&&0===parseInt(wprmp_public.user)&&wprmp_public.add_to_collection.not_logged_in_tooltip){const e=document.querySelectorAll(".wprm-recipe-add-to-shopping-list");for(let t of e)(0,o.Ay)(t,{theme:"wprm",content:wprmp_public.add_to_collection.not_logged_in_tooltip})}},onClick(e,t){if(t.preventDefault(),"logged_in"===wprmp_public.quick_access_shopping_list.access&&0===parseInt(wprmp_public.user)){if("redirect"===wprmp_public.add_to_collection.not_logged_in){const t=wprmp_public.add_to_collection.not_logged_in_redirect;if(t){const i=parseInt(e.dataset.recipeId),o=WPRecipeMaker.shoppingList.getRecipeServings(i);window.WPRecipeMaker.manager.getRecipe(i).then((e=>{if(e){let t={timestamp:Date.now(),recipe:e.data.collection,servings:o,collection:"temp"};localStorage.setItem("wprm-added-to-collection-before-login",JSON.stringify(t))}window.location=t}))}}}else e.classList.contains("wprm-recipe-remove-from-shopping-list")?WPRecipeMaker.shoppingList.onClickRecipeRemove(e):WPRecipeMaker.shoppingList.onClickRecipe(e)},onClickRecipe(e){const t=parseInt(e.dataset.recipeId),i=[{id:t,servings:WPRecipeMaker.shoppingList.getRecipeServings(t)}];WPRecipeMaker.shoppingList.addRecipesToShoppingList(e,i)},getRecipeServings(e){const t=document.querySelectorAll(".wprm-recipe-servings-"+e);let i=0<t.length&&t[0].dataset.servings;return isNaN(i)&&(i=!1),i},addRecipesToShoppingList(e,t){const i=localStorage.getItem("wprm-recipe-collection");let o=!1;i&&(o=JSON.parse(i));const p=e.innerHTML;e.style.width=`${e.offsetWidth}px`,e.style.height=`${e.offsetHeight}px`,"inline"===getComputedStyle(e).display&&(e.style.display="inline-block"),e.style.opacity="0.5",e.innerHTML="...";let s={Accept:"application/json","Content-Type":"application/json"};0<parseInt(wprmp_public.user)&&(s["X-WP-Nonce"]=wprm_public.api_nonce),fetch(`${wprmp_public.endpoints.collections_helper}/add`,{method:"POST",headers:s,credentials:"same-origin",body:JSON.stringify({localCollections:o,recipes:t,collection:{id:"temp"}})}).then((function(i){i.ok?i.json().then((i=>{if(!1===i)alert("Something went wrong. Please try again later.");else if(!0!==i){const e=!!i.hasOwnProperty("collections")&&i.collections;e&&localStorage.setItem("wprm-recipe-collection",JSON.stringify(e))}e.innerHTML=p,e.style.width="",e.style.height="",e.style.display="",e.style.opacity="";for(let e of t)n.updateButtons(e.id,"add")})):alert("Something went wrong. Please try again later.")}))},onClickRecipeRemove(e){const t=[parseInt(e.dataset.recipeId)];WPRecipeMaker.shoppingList.removeRecipesFromShoppingList(e,t)},removeRecipesFromShoppingList(e,t){const i=localStorage.getItem("wprm-recipe-collection");let o=!1;i&&(o=JSON.parse(i));const p=e.innerHTML;e.style.width=`${e.offsetWidth}px`,e.style.height=`${e.offsetHeight}px`,"inline"===getComputedStyle(e).display&&(e.style.display="inline-block"),e.style.opacity="0.5",e.innerHTML="...";let s={Accept:"application/json","Content-Type":"application/json"};0<parseInt(wprmp_public.user)&&(s["X-WP-Nonce"]=wprm_public.api_nonce),fetch(`${wprmp_public.endpoints.collections_helper}/remove`,{method:"POST",headers:s,credentials:"same-origin",body:JSON.stringify({localCollections:o,recipes:t,collection:{id:"temp"}})}).then((function(i){i.ok?i.json().then((i=>{if(!1===i)alert("Something went wrong. Please try again later.");else if(!0!==i){const e=!!i.hasOwnProperty("collections")&&i.collections;e&&localStorage.setItem("wprm-recipe-collection",JSON.stringify(e))}e.innerHTML=p,e.style.width="",e.style.height="",e.style.display="",e.style.opacity="";for(let e of t)n.updateButtons(e,"remove")})):alert("Something went wrong. Please try again later.")}))}},s=()=>
1{window.WPRecipeMaker.shoppingList.init()},"loading"!=document.readyState?s():document.addEventListener("DOMContentLoaded",s)}}]);
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.