https://chefito.de/app/_expo/static/js/web/habits-section-070fc0e0…?chefito-release=4acfbdc30b7897e4
1__d(function(g,r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return D}});var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),p=r(d[10]),y=r(d[11]),x=r(d[12]),_=r(d[13]),j=r(d[14]),b=r(d[15]),w=r(d[16]),v=r(d[17]),S=r(d[18]),C=r(d[19]),F=r(d[20]),k=r(d[21]),T=r(d[22]);const B={shopping_behavior:{titleKey:'shopping_stats_title',fallback:'Shopping behavior',icon:h.Receipt},sustainability:{titleKey:'hidden_cost_insight',fallback:'Sustainability and hidden cost',icon:h.DollarSign},taste_profile:{titleKey:'habits_section_profile_title',fallback:'Taste profile',icon:h.PieChart},recipe_intelligence:{titleKey:'insight_recipe_intelligence_title',fallback:'Recipe intelligence',icon:h.FolderHeart}};function D(){const{id:e}=(0,c.useLocalSearchParams)(),{theme:s}=(0,f.useTheme)(),{t:D,language:$}=(0,p.useTranslation)(),A=(0,c.useRouter)(),{colors:N}=s,{currentKitchen:V}=(0,j.useKitchen)(),{trips:I}=(0,y.useShoppingHistory)(),{fetchTrips:P}=(0,y.useShoppingHistoryDispatch)(),{cookedRecipesLog:K,itemConsumptionsLog:W,wealthHistory:O}=(0,x.useAnalyticsLog)(),{ensureListenersActive:U,fetchWealthHistory:q}=(0,x.useAnalyticsLogDispatch)(),{savedRecipes:G}=(0,b.useMealPlanner)(),{cookedRecipesLog:J}=(0,_.useInsightMealHistory)(K,G),Y=e||'shopping_behavior',Q=B[Y],X=Q.icon,Z={EUR:'\u20ac',USD:'$',GBP:'\xa3',JPY:'\xa5'}[V?.currency||'EUR']||'\u20ac',ee='de'===$?'de-DE':'es'===$?'es-ES':'en-US';(0,t.useEffect)(()=>{P(),U(),q(6)},[U,P,q]);const te=(0,t.useMemo)(()=>{const e=I.filter(e=>(0,u.isValid)(new Date(e.timestamp))).map(e=>{const t=(e.items||[]).reduce((e,t)=>e+(0,F.resolveReceiptLineTotal)({price:t.price??void 0,quantity:t.quantity,lineTotal:t.lineTotal??void 0}),0);return{...e,displayTotal:t>0?t:Math.max(0,e.totalCost||0)}}).sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),t=e.filter(e=>e.displayTotal>0),o=new Map,s=new Map;e.forEach(e=>{const t=(0,u.format)(new Date(e.timestamp),'yyyy-MM');o.set(t,(o.get(t)||0)+e.displayTotal),e.store?.trim()&&s.set(e.store.trim(),(s.get(e.store.trim())||0)+1)});const l=Array.from(o.entries()).sort(([e],[t])=>e.localeCompare(t)).slice(-6),n=l.length>0?l.reduce((e,[,t])=>e+t,0)/l.length:0,a=t.slice().sort((e,t)=>t.displayTotal-e.displayTotal);return{trips:e.slice(0,12),monthSeries:l,monthlyAverage:n,mostExpensive:a[0],leastExpensive:a[a.length-1],biggestHaul:e.slice().sort((e,t)=>t.itemCount-e.itemCount)[0],topStores:Array.from(s.entries()).sort((e,t)=>t[1]-e[1]).slice(0,6),commonPurchases:(0,k.aggregateCommonShoppingPurchases)(e).slice(0,6)}},[I]),oe=(0,t.useMemo)(()=>{const e=(0,u.startOfMonth)(new Date),t=(0,u.endOfMonth)(new Date);let o=0,s=0;for(const l of W){const n=new Date(l.date);if(!(0,u.isValid)(n)||n<e||n>t)continue;const a=Number.isFinite(l.value)?Math.max(0,l.value||0):0;l.wasWasted&&(s+=a),l.wasConsumed&&!l.isExpired&&(o+=a)}const l=o+s;return{saved:o,wasted:s,efficiency:l>0?o/l*100:null,months:O.slice().sort((e,t)=>e.monthKey-t.monthKey).slice(-6)}},[W,O]),ie=(0,t.useMemo)(()=>{const e=new Map,t=new Map,o=(0,v.countCookedRecipesById)(J),s=J.length>0,l=G.map(e=>({label:e.recipeName||D('recipe'),value:s?o.get(e.id)||0:e.cookedCount||0})).filter(e=>e.value>0).sort((e,t)=>t.value-e.value).slice(0,6);return G.forEach(l=>{const n=Array.from(new Set(l.tags||[])).filter(Boolean),a=s?o.get(l.id)||0:Math.max(l.cookedCount||0,1);if(0!==a){n.forEach(t=>e.set(t,(e.get(t)||0)+a));for(let e=0;e<n.length;e+=1)for(let o=e+1;o<n.length;o+=1){const s=[n[e],n[o]].sort().join(' + ');t.set(s,(t.get(s)||0)+a)}}}),{tags:Array.from(e.entries()).sort((e,t)=>t[1]-e[1]).slice(0,10),pairs:Array.from(t.entries()).sort((e,t)=>t[1]-e[1]).slice(0,10),cookedRecipes:l}},[J,G,D]),re=e=>{const t=D(e);return t===e?e:t};return(0,T.jsxs)(a.SafeAreaView,{style:[L.container,{backgroundColor:N.background}],edges:['top','bottom'],children:[(0,T.jsx)(c.Stack.Screen,{options:{headerShown:!1}}),(0,T.jsxs)(n.default,{style:[L.header,{borderBottomColor:N.border,backgroundColor:N.background}],children:[(0,T.jsx)(S.BackButton,{onPress:()=>(0,w.safeBack)(A)}),(0,T.jsx)(X,{size:20,color:N.primary,strokeWidth:2.5}),(0,T.jsx)(l.default,{style:[L.headerTitle,{color:N.foreground}],numberOfLines:1,children:D(Q.titleKey)||Q.fallback})]}),(0,T.jsxs)(o.default,{contentContainerStyle:L.content,showsVerticalScrollIndicator:!1,children:['shopping_behavior'===Y&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsxs)(n.default,{style:L.metricBand,children:[(0,T.jsx)(R,{value:`${Z}${te.monthlyAverage.toFixed(2)}`,label:D('monthly_spending_average'),color:N.primary}),(0,T.jsx)(R,{value:te.mostExpensive?`${Z}${te.mostExpensive.displayTotal.toFixed(2)}`:'\u2014',label:D('most_expensive_trip'),color:N.citrus}),(0,T.jsx)(R,{value:te.biggestHaul?String(te.biggestHaul.itemCount):'\u2014',label:D('insights_data_biggest_haul'),color:N.basil})]}
1),(0,T.jsx)(M,{title:D('insights_data_spending_by_month'),colors:N}),(0,T.jsx)(C.MiniBars,{values:te.monthSeries.map(([,e])=>e),color:N.primary,height:90}),(0,T.jsx)(n.default,{style:L.axisLabels,children:te.monthSeries.map(([e])=>(0,T.jsx)(l.default,{style:[L.axisLabel,{color:N.mutedForeground}],children:new Intl.DateTimeFormat(ee,{month:'short'}).format(new Date(`${e}-01T12:00:00`))},e))})]})}),(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsx)(M,{title:D('insights_data_store_share'),subtitle:D('insights_data_trip_frequency'),colors:N}),(0,T.jsx)(E,{rows:te.topStores.map(([e,t])=>({label:e,value:t})),accent:N.secondary,foreground:N.foreground,muted:N.mutedForeground,valueSuffix:` ${D('insights_data_trips')}`})]})}),(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsx)(M,{title:D('insights_data_recent_shopping'),subtitle:D('insights_data_history_restored'),colors:N}),te.trips.map((e,t)=>(0,T.jsxs)(n.default,{style:[L.historyRow,t>0&&L.rowDivider],children:[(0,T.jsx)(n.default,{style:[L.historyIcon,{backgroundColor:N.primary+'12'}],children:(0,T.jsx)(h.ShoppingBasket,{size:17,color:N.primary})}),(0,T.jsxs)(n.default,{style:{flex:1},children:[(0,T.jsx)(l.default,{style:[L.rowTitle,{color:N.foreground}],numberOfLines:1,children:e.store||D('shopping_trip')}),(0,T.jsxs)(l.default,{style:[L.rowMeta,{color:N.mutedForeground}],children:[new Intl.DateTimeFormat(ee,{day:'2-digit',month:'short',year:'numeric'}).format(new Date(e.timestamp)),' \xb7 ',D('shopping_trip_products_and_units',{products:e.items.length,units:(0,k.getShoppingTripUnitCount)(e)})]})]}),(0,T.jsx)(l.default,{style:[L.historyAmount,{color:N.foreground}],children:e.displayTotal>0?`${Z}${e.displayTotal.toFixed(2)}`:'\u2014'})]},e.id)),0===te.trips.length?(0,T.jsx)(H,{text:D('no_shopping_trips'),color:N.mutedForeground}):null,(0,T.jsx)(S.ScalePressable,{style:[L.primaryButton,{backgroundColor:N.primary}],onPress:()=>A.push('/shopping-trips'),children:(0,T.jsx)(l.default,{style:[L.primaryButtonText,{color:N.primaryForeground}],children:D('manage_shopping_trips_title')})})]})}),te.commonPurchases.length>0?(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsx)(M,{title:D('most_common_purchase'),subtitle:D('shopping_trip_frequency_explainer'),colors:N}),(0,T.jsx)(E,{rows:te.commonPurchases.map(([e,t])=>({label:e,value:t})),accent:N.basil,foreground:N.foreground,muted:N.mutedForeground,valueSuffix:` ${D('shopping_trip_units_short')}`})]})}):null]}),'sustainability'===Y&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsxs)(n.default,{style:L.metricBand,children:[(0,T.jsx)(R,{value:`${Z}${oe.saved.toFixed(2)}`,label:D('wealth_saved'),color:N.success}),(0,T.jsx)(R,{value:`${Z}${oe.wasted.toFixed(2)}`,label:D('wealth_wasted'),color:N.destructive}
1),(0,T.jsx)(R,{value:null!=oe.efficiency?`${oe.efficiency.toFixed(0)}%`:'\u2014',label:D('food_efficiency'),color:N.basil})]}),(0,T.jsx)(C.SplitBar,{primaryValue:oe.saved,secondaryValue:oe.wasted,primaryColor:N.success,secondaryColor:N.destructive}),(0,T.jsxs)(n.default,{style:L.legendRow,children:[(0,T.jsx)(z,{color:N.success,label:D('wealth_saved')}),(0,T.jsx)(z,{color:N.destructive,label:D('wealth_wasted')})]})]})}),(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsx)(M,{title:D('insights_data_six_month_balance'),subtitle:D('habits_section_sustainability_desc'),colors:N}),(0,T.jsx)(C.MiniBars,{values:oe.months.map(e=>e.savedValue),secondaryValues:oe.months.map(e=>e.wastedValue),color:N.success,secondaryColor:N.destructive,height:110}),(0,T.jsx)(n.default,{style:L.axisLabels,children:oe.months.map(e=>(0,T.jsx)(l.default,{style:[L.axisLabel,{color:N.mutedForeground}],children:new Intl.DateTimeFormat(ee,{month:'short'}).format(new Date(e.year,e.month-1,1))},e.monthKey))}),oe.months.map(e=>(0,T.jsxs)(n.default,{style:L.monthRow,children:[(0,T.jsx)(l.default,{style:[L.rowTitle,{color:N.foreground}],children:new Intl.DateTimeFormat(ee,{month:'long',year:'numeric'}).format(new Date(e.year,e.month-1,1))}),(0,T.jsxs)(l.default,{style:[L.monthSaved,{color:N.success}],children:["+",Z,e.savedValue.toFixed(2)]}),(0,T.jsxs)(l.default,{style:[L.monthWasted,{color:N.destructive}],children:["\u2212",Z,e.wastedValue.toFixed(2)]})]},`row-${e.monthKey}`))]})})]}),'taste_profile'===Y&&(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsxs)(n.default,{style:L.metricBand,children:[(0,T.jsx)(R,{value:ie.tags[0]?re(ie.tags[0][0]):'\u2014',label:D('insights_data_signature_taste'),color:N.berry}),(0,T.jsx)(R,{value:String(ie.tags.length),label:D('insights_data_active_tastes'),color:N.primary})]}),(0,T.jsx)(M,{title:D('insights_data_taste_ranking'),subtitle:D('insights_data_weighted_by_cooking'),colors:N}),(0,T.jsx)(E,{rows:ie.tags.map(([e,t])=>({label:re(e),value:t})),accent:N.berry,foreground:N.foreground,muted:N.mutedForeground,valueSuffix:` ${D('count_times',{count:''}).trim()}`})]})}),'recipe_intelligence'===Y&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsx)(M,{title:D('insights_data_signature_pairs'),subtitle:D('habits_section_intelligence_desc'),colors:N}),(0,T.jsx)(E,{rows:ie.pairs.map(([e,t])=>({label:e.split(' + ').map(re).join(' + '),value:t})),accent:N.citrus,foreground:N.foreground,muted:N.mutedForeground}),0===ie.pairs.length?(0,T.jsx)(H,{text:D('no_data_for_chart'),color:N.mutedForeground}):null]})}),ie.cookedRecipes.length>0?(0,T.jsx)(S.Card,{style:L.card,children:(0,T.jsxs)(n.default,{style:L.cardContent,children:[(0,T.jsx)(M,{title:D('insights_data_repeat_recipes'),subtitle:D('insights_data_actual_cooked_counts'),colors:N}),(0,T.jsx)(E,{rows:ie.cookedRecipes,accent:N.basil,foreground:N.foreground,muted:N.mutedForeground})]})}):null]})]})]})}function R({value:e,label:t,color:o}){const{theme:s}=(0,f.useTheme)();return(0,T.jsxs)(n.default,{style:L.metric,children:[(0,T.jsx)(l.default,{style:[L.metricValue,{color:o}],numberOfLines:1,adjustsFontSizeToFit:!0,children:e}),(0,T.jsx)(l.default,{style:[L.metricLabel,{color:s.colors.mutedForeground}],numberOfLines:2,children:t})]})}function M({title:e,subtitle:t,colors:o}){return(0,T.jsxs)(n.default,{style:L.sectionHeading,children:[(0,T.jsx)(l.default,{style:[L.sectionTitle,{color:o.foreground}],children:e}),t?(0,T.jsx)(l.default,{style:[L.sectionSubtitle,{color:o.mutedForeground}],children:t}):null]})}function E({rows:e,accent:t,foreground:o,muted:s,valueSuffix:a=""}){const c=Math.max(...e.map(e=>e.value),1);return(0,T.jsx)(n.default,{style:{gap:13},children:e.slice(0,10).map((e,u)=>(0,T.jsxs)(n.default,{style:L.rankedRow,children:[(0,T.jsx)(l.default,{style:[L.rank,{color:s}],children:u+1}),(0,T.jsxs)(n.default,{style:{flex:1,gap:5},children:[(0,T.jsxs)(n.default,{style:L.rankedCopy,children:[(0,T.jsx)(l.default,{style:[L.rowTitle,{color:o}],numberOfLines:2,children:e.label}),(0,T.jsxs)(l.default,{style:[L.rankValue,{color:t}],children:[e.value,a]})]}),(0,T.jsx)(n.default,{style:L.track,children:(0,T.jsx)(n.default,{style:[L.fill,{width:`${Math.max(4,e.value/c*100)}%`,backgroundColor:t}]})})]})]},`${e.label}-${u}`))})}function z({color:e,label:t}){const{theme:o}=(0,f.useTheme)();return(0,T.jsxs)(n.default,{style:L.legend,children:[(0,T.jsx)(n.default,{style:[L.legendDot,{backgroundColor:e}]}),(0,T.jsx)(l.default,{style:[L.legendText,{color:o.colors.mutedForeground}],children:t})]})}function H({text:e,color:t}){return(0,T.jsx)(l.default,{style:[L.empty,{color:t}],children:e})}const L=s.default.create({container:{flex:1},header:{minHeight:66,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,flexDirection:'row',alignItems:'center',gap:9},headerTitle:{flex:1,fontSize:18,fontFamily:'Nunito_800ExtraBold'},content:{padding:12,gap:12,paddingBottom:40},card:{borderRadius:20},cardContent:{padding:16,gap:16},metricBand:{flexDirection:'row',gap:8},metric:{flex:1,minWidth:0,gap:2},metricValue:{fontSize:21,lineHeight:25,fontFamily:'Nunito_800ExtraBold'},metricLabel:{fontSize:10,lineHeight:13,fontFamily:'Nunito_600SemiBold'},sectionHeading:{gap:2},sectionTitle:{fontSize:15,lineHeight:19,fontFamily:'Nunito_800ExtraBold'},sectionSubtitle:{fontSize:11,lineHeight:15,fontFamily:'Nunito_400Regular'},axisLabels:{flexDirection:'row',gap:4},axisLabel:{flex:1,textAlign:'center',fontSize:9,fontFamily:'Nunito_600SemiBold'},rankedRow:{flexDirection:'row',alignItems:'center',gap:10},rank:{width:18,textAlign:'center',fontSize:11,fontFamily:'Nunito_800ExtraBold'},rankedCopy:{flexDirection:'row',alignItems:'flex-start',justifyContent:'space-between',gap:8},rowTitle:{flex:1,fontSize:13,lineHeight:17,fontFamily:'Nunito_700Bold'},rowMeta:{fontSize:11,lineHeight:14,fontFamily:'Nunito_400Regular'},rankValue:{fontSize:11,fontFamily:'Nunito_800ExtraBold'}
1,track:{height:7,borderRadius:4,overflow:'hidden',backgroundColor:'rgba(0,0,0,0.08)'},fill:{height:'100%',borderRadius:4},historyRow:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:9},rowDivider:{borderTopWidth:s.default.hairlineWidth,borderTopColor:'rgba(0,0,0,0.12)'},historyIcon:{width:34,height:34,borderRadius:11,alignItems:'center',justifyContent:'center'},historyAmount:{fontSize:13,fontFamily:'Nunito_800ExtraBold'},primaryButton:{minHeight:44,borderRadius:14,alignItems:'center',justifyContent:'center',paddingHorizontal:14},primaryButtonText:{fontSize:13,fontFamily:'Nunito_800ExtraBold'},legendRow:{flexDirection:'row',gap:16},legend:{flexDirection:'row',alignItems:'center',gap:5},legendDot:{width:8,height:8,borderRadius:4},legendText:{fontSize:10,fontFamily:'Nunito_600SemiBold'},monthRow:{flexDirection:'row',alignItems:'center',gap:8},monthSaved:{minWidth:66,textAlign:'right',fontSize:11,fontFamily:'Nunito_800ExtraBold'},monthWasted:{minWidth:66,textAlign:'right',fontSize:11,fontFamily:'Nunito_800ExtraBold'},empty:{paddingVertical:28,textAlign:'center',fontSize:12,fontFamily:'Nunito_600SemiBold'}})},5436,[39,197,101,246,174,5663,82,3640,5701,781,2481,5180,4938,5173,4696,4926,3346,5174,3000,5178,4892,5437,2]);
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.