"use strict";
/*
 * ATTENTION: An "eval-source-map" devtool has been used.
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
self["webpackHotUpdate_N_E"]("app/page",{

/***/ "(app-pages-browser)/./src/app/page.tsx":
/*!**************************!*\
  !*** ./src/app/page.tsx ***!
  \**************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {

eval(__webpack_require__.ts("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   \"default\": function() { return /* binding */ Home; }\n/* harmony export */ });\n/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ \"(app-pages-browser)/./node_modules/next/dist/compiled/react/jsx-dev-runtime.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"(app-pages-browser)/./node_modules/next/dist/compiled/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _supabase_auth_helpers_nextjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @supabase/auth-helpers-nextjs */ \"(app-pages-browser)/./node_modules/@supabase/auth-helpers-nextjs/dist/index.js\");\n/* harmony import */ var _supabase_auth_helpers_nextjs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_supabase_auth_helpers_nextjs__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _components_CameraCapture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/components/CameraCapture */ \"(app-pages-browser)/./src/components/CameraCapture.tsx\");\n/* harmony import */ var _components_BottleGrid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/BottleGrid */ \"(app-pages-browser)/./src/components/BottleGrid.tsx\");\n/* harmony import */ var _components_AuthForm__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/components/AuthForm */ \"(app-pages-browser)/./src/components/AuthForm.tsx\");\n/* __next_internal_client_entry_do_not_use__ default auto */ \nvar _s = $RefreshSig$();\n\n\n\n\n\nfunction Home() {\n    _s();\n    const supabase = (0,_supabase_auth_helpers_nextjs__WEBPACK_IMPORTED_MODULE_2__.createClientComponentClient)();\n    const [bottles, setBottles] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)([]);\n    const [isLoading, setIsLoading] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(true);\n    const [user, setUser] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null); // Added user state\n    (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{\n        // Check session\n        const checkUser = async ()=>{\n            const { data: { session } } = await supabase.auth.getSession();\n            var _session_user;\n            setUser((_session_user = session === null || session === void 0 ? void 0 : session.user) !== null && _session_user !== void 0 ? _session_user : null);\n            if (session === null || session === void 0 ? void 0 : session.user) {\n                fetchCollection();\n            } else {\n                setIsLoading(false);\n            }\n        };\n        checkUser();\n        // Listen for auth changes\n        const { data: { subscription } } = supabase.auth.onAuthStateChange((_event, session)=>{\n            var _session_user;\n            setUser((_session_user = session === null || session === void 0 ? void 0 : session.user) !== null && _session_user !== void 0 ? _session_user : null);\n            if (session === null || session === void 0 ? void 0 : session.user) {\n                fetchCollection();\n            } else {\n                setBottles([]);\n            }\n        });\n        return ()=>subscription.unsubscribe();\n    }, []);\n    const fetchCollection = async ()=>{\n        setIsLoading(true);\n        try {\n            // Fetch bottles with their latest tasting date\n            const { data, error } = await supabase.from(\"bottles\").select(\"\\n          *,\\n          tastings (\\n            created_at\\n          )\\n        \").order(\"created_at\", {\n                ascending: false\n            });\n            if (error) throw error;\n            // Process data to get the absolute latest tasting date for each bottle\n            const processedBottles = (data || []).map((bottle)=>{\n                const lastTasted = bottle.tastings && bottle.tastings.length > 0 ? bottle.tastings.reduce((latest, current)=>new Date(current.created_at) > new Date(latest) ? current.created_at : latest, bottle.tastings[0].created_at) : null;\n                return {\n                    ...bottle,\n                    last_tasted: lastTasted\n                };\n            });\n            setBottles(processedBottles);\n        } catch (err) {\n            console.error(\"Error fetching collection:\", err);\n        } finally{\n            setIsLoading(false);\n        }\n    };\n    const handleLogout = async ()=>{\n        await supabase.auth.signOut();\n    };\n    if (!user) {\n        return /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"main\", {\n            className: \"flex min-h-screen flex-col items-center justify-center p-6 bg-zinc-50 dark:bg-black\",\n            children: [\n                /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                    className: \"mb-12 text-center\",\n                    children: [\n                        /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"h1\", {\n                            className: \"text-5xl font-black text-zinc-900 dark:text-white tracking-tighter mb-4\",\n                            children: [\n                                \"WHISKY\",\n                                /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"span\", {\n                                    className: \"text-amber-600\",\n                                    children: \"VAULT\"\n                                }, void 0, false, {\n                                    fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                                    lineNumber: 90,\n                                    columnNumber: 31\n                                }, this)\n                            ]\n                        }, void 0, true, {\n                            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                            lineNumber: 89,\n                            columnNumber: 21\n                        }, this),\n                        /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"p\", {\n                            className: \"text-zinc-500 max-w-sm mx-auto\",\n                            children: \"Scanne deine Flaschen, tracke deine Tastings und verwalte deinen Keller.\"\n                        }, void 0, false, {\n                            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                            lineNumber: 92,\n                            columnNumber: 21\n                        }, this)\n                    ]\n                }, void 0, true, {\n                    fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                    lineNumber: 88,\n                    columnNumber: 17\n                }, this),\n                /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(_components_AuthForm__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {}, void 0, false, {\n                    fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                    lineNumber: 94,\n                    columnNumber: 17\n                }, this)\n            ]\n        }, void 0, true, {\n            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n            lineNumber: 87,\n            columnNumber: 13\n        }, this);\n    }\n    return /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"main\", {\n        className: \"flex min-h-screen flex-col items-center gap-12 p-6 md:p-24 bg-zinc-50 dark:bg-black\",\n        children: /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n            className: \"z-10 max-w-5xl w-full flex flex-col items-center gap-8\",\n            children: [\n                /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"header\", {\n                    className: \"w-full flex justify-between items-center\",\n                    children: [\n                        /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"h1\", {\n                            className: \"text-4xl font-black text-zinc-900 dark:text-white tracking-tighter\",\n                            children: [\n                                \"WHISKY\",\n                                /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"span\", {\n                                    className: \"text-amber-600\",\n                                    children: \"VAULT\"\n                                }, void 0, false, {\n                                    fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                                    lineNumber: 104,\n                                    columnNumber: 31\n                                }, this)\n                            ]\n                        }, void 0, true, {\n                            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                            lineNumber: 103,\n                            columnNumber: 21\n                        }, this),\n                        /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"button\", {\n                            onClick: handleLogout,\n                            className: \"text-sm font-medium text-zinc-500 hover:text-zinc-800 dark:hover:text-zinc-300 transition-colors\",\n                            children: \"Abmelden\"\n                        }, void 0, false, {\n                            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                            lineNumber: 106,\n                            columnNumber: 21\n                        }, this)\n                    ]\n                }, void 0, true, {\n                    fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                    lineNumber: 102,\n                    columnNumber: 17\n                }, this),\n                /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(_components_CameraCapture__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n                    onSaveComplete: fetchCollection\n                }, void 0, false, {\n                    fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                    lineNumber: 114,\n                    columnNumber: 17\n                }, this),\n                /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                    className: \"w-full mt-12\",\n                    children: [\n                        /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"h2\", {\n                            className: \"text-2xl font-bold mb-6 text-zinc-800 dark:text-zinc-100 flex items-center gap-3\",\n                            children: [\n                                \"Deine Sammlung\",\n                                /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"span\", {\n                                    className: \"text-sm font-normal text-zinc-500 bg-zinc-100 dark:bg-zinc-800 px-3 py-1 rounded-full\",\n                                    children: bottles.length\n                                }, void 0, false, {\n                                    fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                                    lineNumber: 119,\n                                    columnNumber: 25\n                                }, this)\n                            ]\n                        }, void 0, true, {\n                            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                            lineNumber: 117,\n                            columnNumber: 21\n                        }, this),\n                        isLoading ? /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                            className: \"flex justify-center py-12\",\n                            children: /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                                className: \"animate-spin rounded-full h-8 w-8 border-b-2 border-amber-600\"\n                            }, void 0, false, {\n                                fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                                lineNumber: 126,\n                                columnNumber: 29\n                            }, this)\n                        }, void 0, false, {\n                            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                            lineNumber: 125,\n                            columnNumber: 25\n                        }, this) : /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(_components_BottleGrid__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n                            bottles: bottles\n                        }, void 0, false, {\n                            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                            lineNumber: 129,\n                            columnNumber: 25\n                        }, this)\n                    ]\n                }, void 0, true, {\n                    fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n                    lineNumber: 116,\n                    columnNumber: 17\n                }, this)\n            ]\n        }, void 0, true, {\n            fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n            lineNumber: 101,\n            columnNumber: 13\n        }, this)\n    }, void 0, false, {\n        fileName: \"/home/robin/AI/Coding/Whisky/src/app/page.tsx\",\n        lineNumber: 100,\n        columnNumber: 9\n    }, this);\n}\n_s(Home, \"jCmmO1rftSgHIdr74tj8GiYQJYE=\");\n_c = Home;\nvar _c;\n$RefreshReg$(_c, \"Home\");\n\n\n;\n    // Wrapped in an IIFE to avoid polluting the global scope\n    ;\n    (function () {\n        var _a, _b;\n        // Legacy CSS implementations will `eval` browser code in a Node.js context\n        // to extract CSS. For backwards compatibility, we need to check we're in a\n        // browser context before continuing.\n        if (typeof self !== 'undefined' &&\n            // AMP / No-JS mode does not inject these helpers:\n            '$RefreshHelpers$' in self) {\n            // @ts-ignore __webpack_module__ is global\n            var currentExports = module.exports;\n            // @ts-ignore __webpack_module__ is global\n            var prevSignature = (_b = (_a = module.hot.data) === null || _a === void 0 ? void 0 : _a.prevSignature) !== null && _b !== void 0 ? _b : null;\n            // This cannot happen in MainTemplate because the exports mismatch between\n            // templating and execution.\n            self.$RefreshHelpers$.registerExportsForReactRefresh(currentExports, module.id);\n            // A module can be accepted automatically based on its exports, e.g. when\n            // it is a Refresh Boundary.\n            if (self.$RefreshHelpers$.isReactRefreshBoundary(currentExports)) {\n                // Save the previous exports signature on update so we can compare the boundary\n                // signatures. We avoid saving exports themselves since it causes memory leaks (https://github.com/vercel/next.js/pull/53797)\n                module.hot.dispose(function (data) {\n                    data.prevSignature =\n                        self.$RefreshHelpers$.getRefreshBoundarySignature(currentExports);\n                });\n                // Unconditionally accept an update to this module, we'll check if it's\n                // still a Refresh Boundary later.\n                // @ts-ignore importMeta is replaced in the loader\n                module.hot.accept();\n                // This field is set when the previous version of this module was a\n                // Refresh Boundary, letting us know we need to check for invalidation or\n                // enqueue an update.\n                if (prevSignature !== null) {\n                    // A boundary can become ineligible if its exports are incompatible\n                    // with the previous exports.\n                    //\n                    // For example, if you add/remove/change exports, we'll want to\n                    // re-execute the importing modules, and force those components to\n                    // re-render. Similarly, if you convert a class component to a\n                    // function, we want to invalidate the boundary.\n                    if (self.$RefreshHelpers$.shouldInvalidateReactRefreshBoundary(prevSignature, self.$RefreshHelpers$.getRefreshBoundarySignature(currentExports))) {\n                        module.hot.invalidate();\n                    }\n                    else {\n                        self.$RefreshHelpers$.scheduleUpdate();\n                    }\n                }\n            }\n            else {\n                // Since we just executed the code for the module, it's possible that the\n                // new exports made it ineligible for being a boundary.\n                // We only care about the case when we were _previously_ a boundary,\n                // because we already accepted this update (accidental side effect).\n                var isNoLongerABoundary = prevSignature !== null;\n                if (isNoLongerABoundary) {\n                    module.hot.invalidate();\n                }\n            }\n        }\n    })();\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 11112 characters]\n//# sourceURL=webpack-internal:///(app-pages-browser)/./src/app/page.tsx\n"));

/***/ })

});