1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="139bb797-7eb4-9448-490f-6d949786c6d0")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,449463,595141,926466,e=>{"use strict";var t,r=e.i(75907),n=e.i(191788),s=e.i(314696),i=e.i(648827),a=e.i(649893),o=e.i(411303),u=e.i(239719),l=function(e){function t(t,r){var n;return(n=e.call(this)||this).client=t,n.setOptions(r),n.bindMethods(),n.updateResult(),n}(0,a.default)(t,e);var n=t.prototype;return n.bindMethods=function(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)},n.setOptions=function(e){this.options=this.client.defaultMutationOptions(e)},n.onUnsubscribe=function(){if(!this.listeners.length){var e;null==(e=this.currentMutation)||e.removeObserver(this)}},n.onMutationUpdate=function(e){this.updateResult();var t={listeners:!0};"success"===e.type?t.onSuccess=!0:"error"===e.type&&(t.onError=!0),this.notify(t)},n.getCurrentResult=function(){return this.currentResult},n.reset=function(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})},n.mutate=function(e,t){return this.mutateOptions=t,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,(0,r.default)({},this.options,{variables:void 0!==e?e:this.options.variables})),this.currentMutation.addObserver(this),this.currentMutation.execute()},n.updateResult=function(){var e=this.currentMutation?this.currentMutation.state:(0,o.getDefaultState)(),t=(0,r.default)({},e,{isLoading:"loading"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset});this.currentResult=t},n.notify=function(e){var t=this;s.notifyManager.batch(function(){t.mutateOptions&&(e.onSuccess?(null==t.mutateOptions.onSuccess||t.mutateOptions.onSuccess(t.currentResult.data,t.currentResult.variables,t.currentResult.context),null==t.mutateOptions.onSettled||t.mutateOptions.onSettled(t.currentResult.data,null,t.currentResult.variables,t.currentResult.context)):e.onError&&(null==t.mutateOptions.onError||t.mutateOptions.onError(t.currentResult.error,t.currentResult.variables,t.currentResult.context),null==t.mutateOptions.onSettled||t.mutateOptions.onSettled(void 0,t.currentResult.error,t.currentResult.variables,t.currentResult.context))),e.listeners&&t.listeners.forEach(function(e){e(t.currentResult)})})},t}(u.Subscribable),c=e.i(122329);function d(e,t,r){return"function"==typeof t?t.apply(void 0,r):"boolean"==typeof t?t:!!e}e.s(["useMutation",0,function(e,t,a){var o=n.default.useRef(!1),u=n.default.useState(0)[1],p=(0,i.parseMutationArgs)(e,t,a),h=(0,c.useQueryClient)(),f=n.default.useRef();f.current?f.current.setOptions(p):f.current=new l(h,p);var y=f.current.getCurrentResult();n.default.useEffect(function(){o.current=!0;var e=f.current.subscribe(s.notifyManager.batchCalls(function(){o.current&&u(function(e){return e+1})}));return function(){o.current=!1,e()}},[]);var g=n.default.useCallback(function(e,t){f.current.mutate(e,t).catch(i.noop)},[]);if(y.error&&d(void 0,f.current.options.useErrorBoundary,[y.error]))throw y.error;return(0,r.default)({},y,{mutate:g,mutateAsync:y.mutate})}],449463);var p=e.i(555087),h=e.i(924881),f=e.i(580657),y=function(e){function t(t,r){var n;return(n=e.call(this)||this).client=t,n.options=r,n.trackedProps=[],n.selectError=null,n.bindMethods(),n.setOptions(r),n}(0,a.default)(t,e);var n=t.prototype;return n.bindMethods=function(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)},n.onSubscribe=function(){1===this.listeners.length&&(this.currentQuery.addObserver(this),g(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())},n.onUnsubscribe=function(){this.listeners.length||this.destroy()},n.shouldFetchOnReconnect=function(){return m(this.currentQuery,this.options,this.options.refetchOnReconnect)},n.shouldFetchOnWindowFocus=function(){return m(this.currentQuery,this.options,this.options.refetchOnWindowFocus)},n.destroy=function(){this.listeners=[],this.clearTimers(),this.currentQuery.removeObserver(this)},n.setOptions=function(e,t){var r=this.options,n=this.currentQuery;if(this.options=this.client.defaultQueryObserverOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled)throw Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),this.updateQuery();var s=this.hasListeners();s&&v(this.currentQuery,n,this.options,r)&&this.executeFetch(),this.updateResult(t),s&&(this.currentQuery!==n||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&this.updateStaleTimeout();var i=this.computeRefetchInterval();s&&(this.currentQuery!==n||this.options.enabled!==r.enabled||i!==this.currentRefetchInterval)&&this.updateRefetchInterval(i)},n.getOptimisticResult=function(e){var t=this.client.defaultQueryObserverOptions(e),r=this.client.getQueryCache().build(this.client,t);return this.createResult(r,t)},n.getCurrentResult=function(){return this.currentResult},n.trackResult=function(e,t){var r=this,n={},s=function(e){r.trackedProps.includes(e)||r.trackedProps.push(e)};return Object.keys(e).forEach(function(t){Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:function(){return s(t),e[t]}})}),(t.useErrorBoundary||t.suspense)&&s("error"),n},n.getNextResult=function(e){var t=this;return new Promise(function(r,n){var s=t.subscribe(function(t){t.isFetching||(s(),t.isError&&(null==e?void 0:e.throwOnError)?n(t.error):r(t))})})},n.getCurrentQuery=function(){return this.currentQuery},n.remove=function(){this.client.getQueryCache().remove(this.currentQuery)},n.refetch=function(e){return this.fetch((0,r.default)({},e,{meta:{refetchPage:null==e?void 0:e.refetchPage}}))},n.fetchOptimistic=function(e){var t=this,r=this.client.defaultQueryObserverOptions(e),n=this.client.getQueryCache().build(this.client,r);return n.fetch().then(function(){return t.createResult(n,r)})},n.fetch=function(e){var t=this;return this.executeFetch(e).then(function(){return t.updateResult(),t.currentResult})},n.executeFetch=function(e){this.updateQuery();var t=this.currentQuery.fetch(this.options,e);return(null==e?void 0:e.throwOnError)||(t=t.catch(i.noop)),t},n.updateStaleTimeout=function(){var e=this;if(this.clearStaleTimeout(),!i.isServer&&!this.currentResult.isStale&&(0,i.isValidTimeout)(this.options.staleTime)){var t=(0,i.timeUntilStale)(this.currentResult.dataUpdatedAt,this.options.staleTime);this.staleTimeoutId=setTimeout(function(){e.currentResult.isStale||e.updateResult()},t+1)}},n.computeRefetchInterval=function(){var e;return"function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.currentResult.data,this.currentQuery):null!=(e=this.options.refetchInterval)&&e},n.updateRefetchInterval=function(e){var t=this;this.clearRefetchInterval(),this.currentRefetchInterval=e,!i.isServer&&!1!==this.options.enabled&&(0,i.isValidTimeout)(this.currentRefetchInterval)&&0!==this.currentRefetchInterval&&(this.refetchIntervalId=setInterval(function(){(t.options.refetchIntervalInBackgroun
2d||p.focusManager.isFocused())&&t.executeFetch()},this.currentRefetchInterval))},n.updateTimers=function(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())},n.clearTimers=function(){this.clearStaleTimeout(),this.clearRefetchInterval()},n.clearStaleTimeout=function(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)},n.clearRefetchInterval=function(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)},n.createResult=function(e,t){var r,n,s=this.currentQuery,a=this.options,o=this.currentResult,u=this.currentResultState,l=this.currentResultOptions,c=e!==s,d=c?e.state:this.currentQueryInitialState,p=c?this.currentResult:this.previousQueryResult,f=e.state,y=f.dataUpdatedAt,m=f.error,b=f.errorUpdatedAt,R=f.isFetching,E=f.status,O=!1,M=!1;if(t.optimisticResults){var k=this.hasListeners(),w=!k&&g(e,t),C=k&&v(e,s,t,a);(w||C)&&(R=!0,y||(E="loading"))}if(t.keepPreviousData&&!f.dataUpdateCount&&(null==p?void 0:p.isSuccess)&&"error"!==E)r=p.data,y=p.dataUpdatedAt,E=p.status,O=!0;else if(t.select&&void 0!==f.data)if(o&&f.data===(null==u?void 0:u.data)&&t.select===this.selectFn)r=this.selectResult;else try{this.selectFn=t.select,r=t.select(f.data),!1!==t.structuralSharing&&(r=(0,i.replaceEqualDeep)(null==o?void 0:o.data,r)),this.selectResult=r,this.selectError=null}catch(e){(0,h.getLogger)().error(e),this.selectError=e}else r=f.data;if(void 0!==t.placeholderData&&void 0===r&&("loading"===E||"idle"===E)){if((null==o?void 0:o.isPlaceholderData)&&t.placeholderData===(null==l?void 0:l.placeholderData))n=o.data;else if(n="function"==typeof t.placeholderData?t.placeholderData():t.placeholderData,t.select&&void 0!==n)try{n=t.select(n),!1!==t.structuralSharing&&(n=(0,i.replaceEqualDeep)(null==o?void 0:o.data,n)),this.selectError=null}catch(e){(0,h.getLogger)().error(e),this.selectError=e}void 0!==n&&(E="success",r=n,M=!0)}return this.selectError&&(m=this.selectError,r=this.selectResult,b=Date.now(),E="error"),{status:E,isLoading:"loading"===E,isSuccess:"success"===E,isError:"error"===E,isIdle:"idle"===E,data:r,dataUpdatedAt:y,error:m,errorUpdatedAt:b,failureCount:f.fetchFailureCount,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:R,isRefetching:R&&"loading"!==E,isLoadingError:"error"===E&&0===f.dataUpdatedAt,isPlaceholderData:M,isPreviousData:O,isRefetchError:"error"===E&&0!==f.dataUpdatedAt,isStale:S(e,t),refetch:this.refetch,remove:this.remove}},n.shouldNotifyListeners=function(e,t){if(!t)return!0;var r=this.options,n=r.notifyOnChangeProps,s=r.notifyOnChangePropsExclusions;if(!n&&!s||"tracked"===n&&!this.trackedProps.length)return!0;var i="tracked"===n?this.trackedProps:n;return Object.keys(e).some(function(r){var n=e[r]!==t[r],a=null==i?void 0:i.some(function(e){return e===r}),o=null==s?void 0:s.some(function(e){return e===r});return n&&!o&&(!i||a)})},n.updateResult=function(e){var t=this.currentResult;if(this.currentResult=this.createResult(this.currentQuery,this.options),this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,!(0,i.shallowEqualObjects)(this.currentResult,t)){var n={cache:!0};(null==e?void 0:e.listeners)!==!1&&this.shouldNotifyListeners(this.currentResult,t)&&(n.listeners=!0),this.notify((0,r.default)({},n,e))}},n.updateQuery=function(){var e=this.client.getQueryCache().build(this.client,this.options);if(e!==this.currentQuery){var t=this.currentQuery;this.currentQuery=e,this.currentQueryInitialState=e.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(null==t||t.removeObserver(this),e.addObserver(this))}},n.onQueryUpdate=function(e){var t={};"success"===e.type?t.onSuccess=!0:"error"!==e.type||(0,f.isCancelledError)(e.error)||(t.onError=!0),this.updateResult(t),this.hasListeners()&&this.updateTimers()},n.notify=function(e){var t=this;s.notifyManager.batch(function(){e.onSuccess?(null==t.options.onSuccess||t.options.onSuccess(t.currentResult.data),null==t.options.onSettled||t.options.onSettled(t.currentResult.data,null)):e.onError&&(null==t.options.onError||t.options.onError(t.currentResult.error),null==t.options.onSettled||t.options.onSettled(void 0,t.currentResult.error)),e.listeners&&t.listeners.forEac
2h(function(e){e(t.currentResult)}),e.cache&&t.client.getQueryCache().notify({query:t.currentQuery,type:"observerResultsUpdated"})})},t}(u.Subscribable);function g(e,t){return!1!==t.enabled&&!e.state.dataUpdatedAt&&("error"!==e.state.status||!1!==t.retryOnMount)||e.state.dataUpdatedAt>0&&m(e,t,t.refetchOnMount)}function m(e,t,r){if(!1!==t.enabled){var n="function"==typeof r?r(e):r;return"always"===n||!1!==n&&S(e,t)}return!1}function v(e,t,r,n){return!1!==r.enabled&&(e!==t||!1===n.enabled)&&(!r.suspense||"error"!==e.state.status)&&S(e,r)}function S(e,t){return e.isStaleByTime(t.staleTime)}e.s(["QueryObserver",0,y],595141);var b=n.default.createContext((t=!1,{clearReset:function(){t=!1},reset:function(){t=!0},isReset:function(){return t}}));e.s(["useQuery",0,function(e,t,r){return function(e,t){var r=n.default.useRef(!1),i=n.default.useState(0)[1],a=(0,c.useQueryClient)(),o=n.default.useContext(b),u=a.defaultQueryObserverOptions(e);u.optimisticResults=!0,u.onError&&(u.onError=s.notifyManager.batchCalls(u.onError)),u.onSuccess&&(u.onSuccess=s.notifyManager.batchCalls(u.onSuccess)),u.onSettled&&(u.onSettled=s.notifyManager.batchCalls(u.onSettled)),u.suspense&&("number"!=typeof u.staleTime&&(u.staleTime=1e3),0===u.cacheTime&&(u.cacheTime=1)),(u.suspense||u.useErrorBoundary)&&!o.isReset()&&(u.retryOnMount=!1);var l=n.default.useState(function(){return new t(a,u)})[0],p=l.getOptimisticResult(u);if(n.default.useEffect(function(){r.current=!0,o.clearReset();var e=l.subscribe(s.notifyManager.batchCalls(function(){r.current&&i(function(e){return e+1})}));return l.updateResult(),function(){r.current=!1,e()}},[o,l]),n.default.useEffect(function(){l.setOptions(u,{listeners:!1})},[u,l]),u.suspense&&p.isLoading)throw l.fetchOptimistic(u).then(function(e){var t=e.data;null==u.onSuccess||u.onSuccess(t),null==u.onSettled||u.onSettled(t,null)}).catch(function(e){o.clearReset(),null==u.onError||u.onError(e),null==u.onSettled||u.onSettled(void 0,e)});if(p.isError&&!o.isReset()&&!p.isFetching&&d(u.suspense,u.useErrorBoundary,[p.error,l.getCurrentQuery()]))throw p.error;return"tracked"===u.notifyOnChangeProps&&(p=l.trackResult(p,u)),p}((0,i.parseQueryArgs)(e,t,r),y)}],926466)},551207,(e,t,r)=>{t.exports=function(e){if("function"!=typeof e)throw TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}},111368,(e,t,r)=>{var n=e.r(305792),s=e.r(551207),i=e.r(838477);t.exports=function(e,t){return i(e,s(n(t)))}},518219,(e,t,r)=>{t.exports=function(e,t,r,n){for(var s=e.length,i=r+(n?1:-1);n?i--:++i<s;)if(t(e[i],i,e))return i;return -1}},285208,(e,t,r)=>{t.exports=function(e){return e!=e}},739960,(e,t,r)=>{t.exports=function(e,t,r){for(var n=r-1,s=e.length;++n<s;)if(e[n]===t)return n;return -1}},291037,(e,t,r)=>{var n=e.r(518219),s=e.r(285208),i=e.r(739960);t.exports=function(e,t,r){return t==t?i(e,t,r):n(e,s,r)}},679617,(e,t,r)=>{var n=e.r(291037);t.exports=function(e,t){return!!(null==e?0:e.length)&&n(e,t,0)>-1}},734403,(e,t,r)=>{t.exports=function(e,t,r){for(var n=-1,s=null==e?0:e.length;++n<s;)if(r(t,e[n]))return!0;return!1}},687378,(e,t,r)=>{t.exports=function(){}},464163,(e,t,r)=>{var n=e.r(340682),s=e.r(687378),i=e.r(231853);t.exports=n&&1/i(new n([,-0]))[1]==1/0?function(e){return new n(e)}:s},681708,(e,t,r)=>{var n=e.r(650119),s=e.r(679617),i=e.r(734403),a=e.r(33483),o=e.r(464163),u=e.r(231853);t.exports=function(e,t,r){var l=-1,c=s,d=e.length,p=!0,h=[],f=h;if(r)p=!1,c=i;else if(d>=200){var y=t?null:o(e);if(y)return u(y);p=!1,c=a,f=new n}else f=t?[]:h;e:for(;++l<d;){var g=e[l],m=t?t(g):g;if(g=r||0!==g?g:0,p&&m==m){for(var v=f.length;v--;)if(f[v]===m)continue e;t&&f.push(m),h.push(g)}else c(f,m,r)||(f!==h&&f.push(m),h.push(g))}return h}},407055,(e,t,r)=>{var n=e.r(681708);t.exports=function(e){return e&&e.length?n(e):[]}},73034,e=>{"use strict";var t=e.i(745994);e.s(["resolveCanonicalRecipe",0,function({meal:e,generatedRecipesById:r,resolveUserRecipe:n}){if(!e)return;if(e.userRecipeId)return n(e.userRecipeId);let s=r[e.id];if(s&&(0,t.normalizeMealName)(s.name)===(0,t.normalizeMealName)(e.name))return s}])},757965,(e,t,r)=>{"use strict";var n=function(e){var t,r,n;return!!(t=e)&&"object"==typeof t&&(r=e,"[object RegExp]"!==(n=Object.prototype.toString.call(r))&&"[object Date]"!==n&&r.$$typeof!==s)},s="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(e,t){return!1!==t.clone&&t.isMergeableObject(e)?l(Array.isArray(e)?[]:{},e,t):e}function a(e,t,r){return e.concat(t).map(function(e){return i(e,r)})}function o(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function u(e,t){try{return t in e}catch(e){return!1}}function l(e,t,r){(r=r||{}).arrayMerge=r.arrayMerge||a,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=i;var s,c,d=Array.isArray(t);return d!==Array.isArray(e)?i(t,r):d?r.arrayMerge(e,t,r):(c={},(s=r).isMergeableObject(e)&&o(e).forEach(function(t){c[t]=i(e[t],s)}),o(t).forEach(function(r){u(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))||(u(e,r)&&s.isMergeableObject(t[r])?c[r]=(function(e,t){if(!t.customMerge)return l;var r=t.customMerge(e);return"function"==typeof r?r:l})(r,s)(e[r],t[r],s):c[r]=i(t[r],s))}),c)}l.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,r){return l(e,r,t)},{})},t.exports=l},400805,765525,143556,e=>{"use strict";var t=e.i(667108),r=e.i(745994),n=e.i(73034);let s={vegetables:"produce",fruits:"produce",dairy:"dairy",beverages:"beverages",spices:"spices",grains:"grains","breakfast-cereals":"grains",beef:"meat",pork:"meat",poultry:"meat",sausages:"meat",lamb:"meat",f
2ish:"fish",fats:"condiments","baked-goods":"bakery",soups:"pantry",legumes:"pantry",nuts:"pantry",sweets:"pantry",snacks:"pantry","baby-food":"unknown","fast-food":"unknown","mixed-dishes":"unknown","native-foods":"unknown",restaurant:"unknown",unknown:"unknown"};e.s(["deriveShoppingList",0,function({plan:e,generatedRecipesById:i,userRecipesById:a,householdSize:o}){let u=new Map;for(let l of Object.values(e))for(let e of Object.values(l)){if(!e.name||e.isSkipped)continue;let l=(0,n.resolveCanonicalRecipe)({meal:e,generatedRecipesById:i,resolveUserRecipe:e=>a[e]});if(l)for(let n of l.ingredients){let i=n.resolved?.canonicalName??n.name.trim(),a=n.resolved?.aggregationKey??i.trim().toLowerCase(),c=u.get(a),d=function(e){let{ingredient:r,slotId:n,householdSize:s,mealServings:i,recipeServings:a}=e,o=a&&a>0?(i??s)/a:1;if(r.resolved?.isSeasoning)return{slotId:n,requiredQuantity:null,unit:null,buyQuantity:null};if(null===r.quantity)return{slotId:n,requiredQuantity:null,unit:r.unit,buyQuantity:null};if(r.isCountable&&void 0!==r.gramsPerUnit&&(0,t.isCountableUnit)(r.unit)){let e=r.quantity*r.gramsPerUnit*o;return{slotId:n,requiredQuantity:e,unit:"g",buyQuantity:e}}let u=r.quantity*o;return{slotId:n,requiredQuantity:u,unit:r.unit,buyQuantity:u}}({ingredient:n,slotId:e.id,householdSize:o,mealServings:e.servings,recipeServings:l.servings}),p=`${d.slotId}:${d.unit??"null"}`;if(!c){u.set(a,{canonicalName:i,displayName:(0,r.replaceSpecialCharacters)(n.name.trim()),shoppingCategory:n.resolved?s[n.resolved.nutritionCategory]:"unknown",resolved:n.resolved??null,usagesByRecipeAndUnit:new Map([[p,d]])});continue}let h=c.usagesByRecipeAndUnit.get(p);h?c.usagesByRecipeAndUnit.set(p,{...h,requiredQuantity:null===h.requiredQuantity||null===d.requiredQuantity?null:h.requiredQuantity+d.requiredQuantity,buyQuantity:null===h.buyQuantity||null===d.buyQuantity?null:h.buyQuantity+d.buyQuantity}):c.usagesByRecipeAndUnit.set(p,d),!c.resolved&&n.resolved&&(c.resolved=n.resolved,c.shoppingCategory=s[n.resolved.nutritionCategory])}}return Array.from(u.values()).map(e=>{let t,r=Array.from(e.usagesByRecipeAndUnit.values()),n=!!e.resolved?.isSeasoning,s=n||0===(t=r.filter(e=>null!==e.requiredQuantity&&null!==e.buyQuantity)).length||new Set(t.map(e=>e.unit)).size>1?{requiredQuantity:null,buyQuantity:null,unit:null}:{requiredQuantity:t.reduce((e,t)=>e+t.requiredQuantity,0),buyQuantity:t.reduce((e,t)=>e+t.buyQuantity,0),unit:t[0]?.unit??null};return{canonicalName:e.canonicalName,displayName:e.displayName,shoppingCategory:e.shoppingCategory,resolved:e.resolved,usages:r,requiredQuantity:s.requiredQuantity,buyQuantity:s.buyQuantity,unit:s.unit,needsSortFallback:"unknown"===e.shoppingCategory,isSeasoning:n}}).sort((e,t)=>e.canonicalName.localeCompare(t.canonicalName))},"shoppingCategoryByNutritionCategory",0,s],400805);var i=e.i(757965),a=e.i(303783);e.i(823400);var o=e.i(786904),u=e.i(159751),l=e.i(825611),c=e.i(690863);let d=new Set(a.mealTimes),p=e=>{if(d.has(e))return(e,t)=>{if(e.isLocked)return e;let n=!!e.userRecipeId&&(0,r.normalizeMealName)(e.name)===(0,r.normalizeMealName)(t?.name);return{...t,isLocked:e.isLocked,isSkipped:e.isSkipped,...n?{userRecipeId:e.userRecipeId,source:e.source??"user"}:{}}}};e.s(["applyPlanSnapshot",0,function(e,{lockAndSkipMask:t,userRecipes:r,preservedGeneratedRecipesById:n}){let s=(0,i.default)(t,function(e){if(!e.allergyGuardStatusBySlot)return e.plan;let t=structuredClone(e.plan);return(0,u.forEachMeal)(t,(r,n,s)=>{let i=e.allergyGuardStatusBySlot?.[n]?.[s];i&&(t[n][s]={...r,allergyGuardStatus:i})}),t}(e),{customMerge:e=>p(e)}),{plan:a}=(0,c.linkUserRecipesByName)(s,r);return{plan:(0,l.replaceSpecialCharsInMealPlan)(a),generatedRecipesById:{...n,...e.generatedRecipesById}}},"createSnapshotFrameParser",0,function(){let e="",t=e=>o.planStreamSnapshotSchema.parse(JSON.parse(e));return{push(r){e+=r;let n=[];for(;;){let r=e.indexOf("\n");if(-1===r)break;let s=e.slice(0,r).trim();e=e.slice(r+1),s&&n.push(t(s))}return n},flush(){let r=e.trim();return e="",r?t(r):null}}},"getLockAndSkipMask",0,e=>(0,i.default)(e,(0,a.getEmptyPlan)((0,a.getPlanMealTimes)(e)),{customMerge:e=>p(e)}),"getPreservedGeneratedRecipesById",0,function(e,t){let r=new Set;return(0,u.forEachMeal)(e,e=>{e.isLocked&&"ai"===e.source&&t[e.id]&&r.add(e.id)}),Object.fromEntries(Object.entries(t).filter(([e])=>r.has(e)))}],765525),e.s(["createConcurrencyLimit",0,e=>{let t=0,r=[];return async n=>{t>=e&&await new Promise(e=>r.push(e)),t++;try{return await n()}finally{t--,r.shift()?.()}}}],143556)},86517,e=>{"use strict";e.s(["allergyGuardMessage",0,(e,t)=>e("unsafe"===t?"Nessun pasto sicuro per le tue allergie":"Impossibile verificare il pasto per le tue allergie"),"isAllergyGuardStatus",0,e=>"unsafe"===e||"unchecked"===e])},249493,e=>{"use strict";e.i(719830);var t=e.i(449463),r=e.i(926466);e.i(664157);var n=e.i(271179),s=e.i(111368),i=e.i(407055),a=e.i(190077),o=e.i(191788),u=e.i(543929),l=e.i(433736);e.i(823400);var c=e.i(15951),d=e.i(849150),p=e.i(159751),h=e.i(745994),f=e.i(400805),y=e.i(765525),g=e.i(303783),m=e.i(482303),v=e.i(825611),S=e.i(143556),b=e.i(53399),R=e.i(838334),E=e.i(86517),O=e.i(147317),M=e.i(2463),k=e.i(883655);
2class w extends Error{constructor(){super("The plan has meals but none of them resolved to a recipe"),this.name="EmptyShoppingListError"}}function C(e){u.toaster.error({title:e("Generazione già in corso"),description:e("Aspetta che finisca prima di riprovare"),closable:!0,duration:4e3}),window.umami?.track?.("generation_concurrent_blocked")}function I(e){if(!e)return!1;let t=1e3*e.seconds+e.nanoseconds/1e6;return Date.now()-t<4e4}let Q=e=>e.trim().toLowerCase(),P=(0,S.createConcurrencyLimit)(4),T=({onSuccess:e}={})=>{let{t:r}=(0,n.useTranslation)();return(0,t.useMutation)(async e=>{let t=l.useSettingsStore.getState(),r=t.user,n=e?.shoppingList?.items??t.shoppingList.items;if(!r||0===Object.keys(n).length)return;let s=Object.entries(n).sort(([,e],[,t])=>e.order-t.order).map(([e])=>e);await k.clientNetworking.sortShoppingList(r.currentHomeId,s,r.locale)},{mutationKey:"sortShoppingList",onSuccess:()=>{e?.()},onError:e=>{console.error("Error sorting shopping list:",e),u.toaster.error({title:r("Errore durante il riordinamento della lista"),description:r("Ti preghiamo di riprovare"),closable:!0,duration:4500})}})},A=(e,t,n)=>(0,r.useQuery)([e,t],()=>k.clientNetworking.fetchSubscription(t),{enabled:!!t&&!1!==n,staleTime:1/0,cacheTime:86400});e.s(["useGenerateImage",0,()=>{let{i18n:e}=(0,n.useTranslation)();return(0,t.useMutation)(async({name:t,type:r,category:n,isShared:s})=>{await k.clientNetworking.auth.authStateReady();let i=await k.clientNetworking.getValidUserToken(),a=l.useSettingsStore.getState().user?.locale??e.language??"en-US",o=new URLSearchParams({name:t.toLowerCase().trim(),type:r,locale:a});s&&o.set("shared","true"),n&&o.set("category",n);let u=!i,c=u?"/api/public/generate-image":"/api/generate-image";if(u&&"meal"!==r)throw Error("Image generation for non-meal types requires authentication");return P(async()=>{let e=await (0,M.authedFetch)(`${c}?${o.toString()}`,{method:"GET",auth:"optional"}),t=await e.json().catch(()=>null);if(!e.ok||!t)throw Error(t?.error??"Unable to generate image");return t})})},"useHomeSubscription",0,(e,{enabled:t=!0}={})=>A("homeSubscription",e,t),"useMutateRecipe",0,()=>{let{t:e}=(0,n.useTranslation)(),r=(0,l.useSettingsStore)(e=>e.user?.locale),s=(0,b.useUnitSystem)();return(0,t.useMutation)(async({recipeName:e,ingredients:t})=>{let{recipe:n}=await (0,M.authedPostJson)("/api/recipe",{locale:r,unitSystem:s,ingredients:t,recipeName:e});return{recipeName:e,instructions:c.recipeInstructionsSchema.parse(JSON.parse(n))}},{mutationKey:"createRecipe",onError:t=>{console.error("Error generating recipe",t),u.toaster.error({title:e("Errore durante la generazione della ricetta"),duration:3e3})}})},"useMutateShoppingList",0,({onSuccess:e}={})=>{let{t:r}=(0,n.useTranslation)(),i=(0,l.useSettingsStore)(e=>e.setShoppingList),a=(0,l.useSettingsStore)(e=>e.setIngredientMacros),o=(0,l.useSettingsStore)(e=>e.currentHome?.uid),c=(0,l.useSettingsStore)(e=>e.currentHome?.householdSize||e.currentHome?.members?.length||1),{mutate:h}=T();return(0,t.useMutation)(async()=>{if(I(l.useSettingsStore.getState().currentHome?.generationStartedAt))return void C(r);if(!o)return;await Promise.allSettled(l.useSettingsStore.getState().pendingMealEnrichments);let e=l.useSettingsStore.getState(),t=Object.fromEntries(e.userRecipes.map(e=>[e.id,e])),n=function(e){let{plan:t,householdSize:r,generatedRecipesById:n,userRecipesById:s}=e,i=(0,f.deriveShoppingList)({plan:t,generatedRecipesById:n,userRecipesById:s,householdSize:r}),a={},o={};return i.forEach((e,n)=>{a[e.displayName]={usages:e.usages.map(e=>{let n=Object.values(t).flatMap(e=>Object.values(e)).find(t=>t.id===e.slotId),s=n?.servings??r;return{recipeId:e.slotId,requiredQuantity:e.requiredQuantity,buyQuantity:e.buyQuantity,unit:e.unit,...void 0!==s?{baseServings:s}:{}}}),isTaken:!1,order:n,canonicalName:e.canonicalName,...e.resolved&&"unknown"!==e.shoppingCategory?{englishCanonicalName:e.resolved.canonicalName}:{},displayName:e.displayName,shoppingCategory:e.shoppingCategory,...e.isSeasoning?{isSeasoning:!0}:{},...e.resolved?.teaspoonGrams?{teaspoonGrams:e.resolved.teaspoonGrams}:{},...e.resolved?.brandedName?{refinedProduct:{name:e.resolved.brandedName,foodId:e.resolved.foodId,macrosPer100g:e.resolved.macrosPer100g}}:{}},o[e.displayName.toLowerCase().trim()]=e.resolved?{macros:e.resolved.macrosPer100g,matchScore:e.resolved.matchScore,foodId:e.resolved.foodId}:null}),{shoppingList:{items:a},ingredientMacros:o}}({plan:e.mostRecentPlan,householdSize:c,generatedRecipesById:e.generatedRecipesById,userRecipesById:t});if((0,p.someMeal)(e.mostRecentPlan,e=>!!e.name&&!e.isSkipped)&&0===Object.keys(n.shoppingList.items).length)throw new w;return n},{mutationKey:"createShoppingList",onSuccess:async t=>{if(!t)return;a(t.ingredientMacros);let r={items:(0,s.default)(t.shoppingList.items,e=>e.usages.some(e=>"all"===e.recipeId))};(0,d.isShoppingList)(r)&&(i(r),(0,R.pruneImageIdCache)("shopping",Object.keys(r.items)),e?.(),h({shoppingList:r}))},onError:e=>{e instanceof w?u.toaster.error({title:r("Nessun ingrediente trovato"),description:r("Le ricette del piano non sono ancora pronte, riprova tra poco"),closable:!0,duration:4500}):(console.error("Error generating shopping list",e),u.toaster.error({title:r("Errore durante la generazione lista"),description:r("Ti preghiamo di riprovare"),closable:!0,duration:4500}))}})},"usePersonalSubscription",0,(e,{enabled:t=!0}={})=>A("personalSubscription",e,t),"useRerollMeal",0,()=>{let{t:e}=(0,n.useTranslation)(),r=(0,l.useSettingsStore)(e=>e.setDraftPlan),s=(0,l.useSettingsStore)(e=>e.addRejectedMealName),[d,h]=(0,o.useState)(new Set),f=(0,o.useCallback)(e=>{h(t=>new Set(t).add(e))},[]),y=(0,o.useCallback)(e=>{h(t=>{let r=new Set(t);return r.delete(e),r})},[]);return{rerollMeal:(0,t.useMutation)(async({day:e,mealTime:t})=>{if(l.useSettingsStore.getState().isStreamingPlan)return;let n=`${e}-${t}`;f(n);try{let o=l.useSettingsStore.getState(),u=o.draftPlan,d=u[e][t];if(!d)return;let h={...u,[e]:{...u[e],[t]:{...d,name:"",isSkipped:!1,macros:(0,g.getEmptyMacros)()}}},f=d.name,y={day:e,mealTime:t,...f?{previousName:f}:{}},m=o.rejectedMealNamesBySlot[n]??[],S=(0,i.default)(f?[...m,f]:m),b=async()=>{let{plan:r}=await (0,M.authedPostJson)("/api/meal-reroll",{locale:o.user?.locale,constraints:o.constraints.map(e=>e.value),presetConstraints:o.presetConstraints,planSettings:o.planSettings,planToBeFilled:(0,p.appPlanToPlanAPIPayload)(h),recipesUserDidntLike:S,userRecipeNames:o.userRecipes.filter(e=>g.recipeMealTypesForSlot[t].includes(e.categories?.mealType??"")).map(e=>e.name),targetSlots:[y]});return c.planPatchSchema.parse(r)[e]?.[t]},R=e=>!e?.name||!!f&&Q(e.name)===Q(f),E=await b();if(R(E)&&(E?.name&&S.push(E.name),E=await b()),R(E))throw Error("Reroll did not return a usable replacement meal");if(E){f&&s(e,t,f);let n=l.useSettingsStore.getState().draftPlan,i={...n,[e]:{...n[e],[t]:{...n[e][t],name:E.name??n[e][t]?.name??"",id:(0,a.v4)(),source:void 0,userRecipeId:void 0,macros:void 0,servings:void 0,allergyGuardStatus:void 0,isSkipped:!1,isLocked:!1}}};r((0,v.replaceSpecialCharsInMealPlan)(i));let{homeSubscription:o,retryMealEnrichment:u}=l.useSettingsStore.getState();(0,O.hasPremiumAccess)(o)&&u(e,t,{isDraft:!0})}}finally{y(n)}},{mutationKey:"rerollMeal",onError:t=>{console.error("Error in rerollMeal",t);let r=t instanceof M.ApiResponseError?t.body?.allergyGuardStatus:void 0;u.toaster.error({title:(0,E.isAllergyGuardStatus)(r)?(0,E.allergyGuardMessage)(e,r):e("Errore durante la generazione del pasto"),description:e("Ti preghiamo di riprovare"),closable:!0,duration:4500})}}).mutate,rerollingSlots:d}},"useSortShoppingList",0,T,"useStreamPlan",0,()=>{let{t:e}=(0,n.useTranslation)(),[t,r]=(0,o.useState)(void 0),s=(0,o.useRef)(!1),a=(0,o.useRef)(null),c=(0,o.useRef)(!1),d=(0,o.useRef)({}),f=(0,l.useSettingsStore)(e=>e.setDraftPlan),v=(0,l.useSettingsStore)(e=>e.setDraftGeneratedRecipesById),S=(0,l.useSettingsStore)(e=>e.setIsStreamingPlan),b=(0,l.useSettingsStore)(e=>e.mirrorPlanMutation),E=(0,l.useSettingsStore)(e=>e.setGeneratedRecipesById),O=(0,l.useSettingsStore)(e=>e.setGenerationStartedAt),k=(0,o.useRef)((0,y.getLockAndSkipMask)(l.useSettingsStore.getState().draftPlan)),w=(0,o.useRef)(null),Q=(0,o.useRef)(!1),P=(0,o.useRef)(void 0),T=()=>{P.current&&(u.toaster.dismiss(P.current),P.current=void 0)},A=(0,o.useCallback)(()=>{S(!1),O(null),T(),s.current&&l.useSettingsStore.getState().flushPlanWrite();let e=l.useSettingsStore.getState().draftPlan,t=[];(0,p.forEachMeal)(e,e=>{t.push(e.name)}),(0,R.pruneImageIdCache)("meal",t)},[O,S]),L=(0,o.useCallback)(t=>(S(!1),O(null),r(t instanceof Error?t:Error("Plan stream failed")),console.error("Error streaming plan",t),!Q.current&&w.current)?(Q.current=!0,P.current=u.toaster.create({title:e("Ancora un po' di pazienza"),description:e("Ci sta volendo più tempo del solito..."),type:"loading",closable:!1}),S(!0),O({seconds:Math.floor(Date.now()/1e3),nanoseconds:0}),!0):(T(),u.toaster.error({title:e("Ops"),description:e("Qualcosa è andato storto")}),!1),[O,S,e]),U=(0,o.useCallback)(e=>{let{plan:t,generatedRecipesById:r}=(0,y.applyPlanSnapshot)(e,{lockAndSkipMask:k.current,userRecipes:l.useSettingsStore.getState().userRecipes,preservedGeneratedRecipesById:d.current});f(t),v(r),s.current&&b({plan:t,generatedRecipesById:r})},[v,f,b]),N=(0,o.useCallback)(async e=>{let t=new AbortController;a.current=t,c.current=!1;let r=await (0,M.authedFetch)("/api/plan-stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t.signal});if(!r.ok||!r.body)throw Error(`Plan stream failed: ${r.status}`);let n=r.body.getReader(),s=new TextDecoder,i=(0,y.createSnapshotFrameParser)();for(;;){let{value:e,done:t}=await n.read();if(t)break;for(let t of i.push(s.decode(e,{stream:!0})))U(t)}let o=i.flush();o&&U(o)},[U]),j=(0,o.useCallback)(async e=>{try{await N(e),A()}catch(e){if(c.current||e instanceof DOMException&&"AbortError"===e.name)return void T();L(e)&&w.current&&j(w.current)}finally{a.current=null}},[A,L,N]);return{cancel:(0,o.useCallback)(()=>{c.current=!0,a.current?.abort(),S(!1),O(null)},[O,S]),error:t,isError:!!t,start:(0,o.useCallback)((t,n=!1)=>{let a=l.useSettingsStore.getState();if(I(a.currentHome?.generationStartedAt))return void C(e);(0,m.trackEvent)("app_plan-generate",{origin:t}),S(!0),O({seconds:Math.floor(Date.now()/1e3),nanoseconds:0}),a.clearRejectedMealNames(),s.current=n;let o=(0,g.getEnabledMeals)(a.planSettings),u=new Set(o.flatMap(e=>g.recipeMealTypesForSlot[e])),c=(0,g.alignPlanToEnabledMeals)(a.draftPlan,o);k.current=(0,y.getLockAndSkipMask)(c),d.current=(0,y.getPreservedGeneratedRecipesById)(c,a.draftGeneratedRecipesById),f(c),v(d.current),s.current&&E(d.current);let b=[],R=(0,p.isPlanEmpty)(c)?(0,g.getEmptyPlan)(o):(0,h.mapOverMeals)(c,e=>e.isLocked||e.isSkipped?e:(b.push(e.name),{id:e.id,name:"",isSkipped:!1})),M={locale:a.user?.locale,constraints:a.constraints.map(e=>e.value),presetConstraints:a.presetConstraints,planSettings:a.planSettings,planToBeFilled:(0,p.appPlanToPlanAPIPayload)(R),recipesUserDidntLike:(0,i.default)(b),userRecipeNames:a.userRecipes.filter(e=>u.has(e.categories?.mealType??"")).map(e=>e.name),householdSize:a.currentHome?.householdSize||a.currentHome?.members?.length||1};Q.current=!1,w.current=M,r(void 0),j(M)},[v,f,E,O,S,j,e])}},"useStripePrices",0,({onError:e}={})=>(0,r.useQuery)(["stripePrices"],async()=>{let e=await fetch("/api/stripe/prices");return(await e.json()).prices||[]},{staleTime:3e5,onError:e})])}]); 3 4//# debugId=139bb797-7eb4-9448-490f-6d949786c6d0
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.