"use strict";
(() => {
var exports = {};
exports.id = 4656;
exports.ids = [4656];
exports.modules = {

/***/ 629:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ Homepage),
/* harmony export */   "getStaticPaths": () => (/* binding */ getStaticPaths),
/* harmony export */   "getStaticProps": () => (/* binding */ getStaticProps)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _layouts_GeneralLayout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6217);
/* harmony import */ var _components_general_PageHeadTags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4097);
/* harmony import */ var _functions_frontend_clientAuthUser__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9922);
/* harmony import */ var _components_pages_docs_DocsAside__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6000);
/* harmony import */ var _components_pages_docs_DocsGenereicHero__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9350);
/* harmony import */ var _package_shared_functions_backend_dbHandler__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1273);
/* harmony import */ var _package_shared_functions_backend_dbHandler__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_dbHandler__WEBPACK_IMPORTED_MODULE_6__);
// @ts-check
/**
 * ==============================================================================
 * Imports
 * ==============================================================================
 */ 

////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////






/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
 * ==============================================================================
 * Main Component { Functional }
 * ==============================================================================
 * @param {Object} props - Server props
 * @param {any[]} props.pages
 * @param {any} props.targetPage
 */ function Homepage({ pages , targetPage  }) {
    /**
     * Get Contexts
     *
     * @abstract { React.useContext }
     */ if (true) {
        react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
            window.location.href = "https://datasquirel.com/docs/getting-started";
        }, []);
        return null;
    }
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * Javascript Variables
     *
     * @abstract Non hook variables and functions
     */ const pageTitle = `${targetPage.title} | Datasquirel docs`;
    const pageDescription = targetPage.description;
    let head = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
        children: [
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("title", {
                children: pageTitle
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
                name: "description",
                content: pageDescription
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_general_PageHeadTags__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {
                pageTitle: pageTitle,
                pageDescription: pageDescription,
                pagePathname: "/"
            })
        ]
    });
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * React Hooks
     *
     * @abstract { useState, useEffect, useRef, etc ... }
     */ const [user, setUser] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null);
    react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
        (0,_functions_frontend_clientAuthUser__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z)({
            setUser
        });
    }, []);
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * Function Return
     *
     * @abstract Main Function Return
     */ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_layouts_GeneralLayout__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
        head: head,
        user: user,
        children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
            className: "items-stretch w-full gap-0 flex-col-reverse lg:flex-row",
            children: [
                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_pages_docs_DocsAside__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
                    pages: pages
                }),
                /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("main", {
                    children: [
                        /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_pages_docs_DocsGenereicHero__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, {
                            title: targetPage.title,
                            description: targetPage.description
                        }),
                        /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                            className: "RTE-DOCS pl-4 sm:pl-10 pt-4 pb-20 pr-4",
                            dangerouslySetInnerHTML: {
                                __html: targetPage.content
                            }
                        })
                    ]
                })
            ]
        })
    });
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
 * Server Side Props or Static Props
 * @type {import("next").GetStaticProps}
 */ async function getStaticProps({ params  }) {
    /**
     * Data Fetching
     *
     * @description Data Fetching
     */ // const page = params.page;
    const subPage = params?.["sub-page"];
    /** @type {any[] | null} */ // @ts-ignore
    const pages = await _package_shared_functions_backend_dbHandler__WEBPACK_IMPORTED_MODULE_6___default()(`SELECT id, title, slug, level, parent_id FROM docs_pages ORDER BY page_order ASC`);
    const targetRootPage = pages?.filter((page)=>page.slug === params?.page && page.level == 1);
    if (!targetRootPage) {
        return {
            redirect: {
                destination: "/docs",
                permanent: false
            }
        };
    }
    /** @type {any[] | null} */ // @ts-ignore
    const targetPage = await _package_shared_functions_backend_dbHandler__WEBPACK_IMPORTED_MODULE_6___default()(`SELECT title, slug, description, content FROM docs_pages WHERE slug = ? AND level = ? AND parent_id = ?`, [
        subPage,
        2,
        targetRootPage[0]?.id
    ]);
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * Server props return
     *
     * @description Return data fetched on the server side
     */ return {
        props: {
            user: null,
            pages,
            targetPage: targetPage?.[0] ? targetPage[0] : {}
        }
    };
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/**
 *
 * Static Props
 * @type {import("next").GetStaticPaths}
 */ async function getStaticPaths() {
    try {
        /**
         * Page/Site Data Data Fetching
         */ /** @type {any[] | null} */ // @ts-ignore
        const entries = await _package_shared_functions_backend_dbHandler__WEBPACK_IMPORTED_MODULE_6___default()(`SELECT id, title, slug, level, parent_id FROM docs_pages`);
        const subEntries = entries?.filter((entry)=>parseInt(entry?.level) == 2);
        /** @type {any[]} */ let paths = [];
        const rootEntries = entries?.filter((entry)=>entry?.level == 1);
        if (!rootEntries?.[0]) {
            return {
                paths: [],
                fallback: false
            };
        }
        rootEntries.forEach((entry)=>{
            const rootSubEntries = subEntries?.filter((subEntry)=>subEntry.parent_id == entry?.id);
            rootSubEntries?.forEach((rootSubEntry)=>{
                paths.push({
                    params: {
                        page: entry.slug,
                        "sub-page": rootSubEntry.slug
                    }
                });
            });
        });
        // console.log(JSON.stringify(paths, null, 4));
        /**
         * Server props return
         *
         * @description Return data fetched on the server side
         */ return {
            paths: paths,
            fallback: false
        };
    } catch (/** @type {any} */ error) {
        /**
         * Error Response
         *
         * @description Return data fetched on the server side
         */ console.log("Error =>", error.message);
        return {
            paths: [],
            fallback: false
        };
    }
}


/***/ }),

/***/ 386:
/***/ ((module) => {

module.exports = require("@mui/icons-material/CottageTwoTone");

/***/ }),

/***/ 5557:
/***/ ((module) => {

module.exports = require("@mui/icons-material/MenuBookTwoTone");

/***/ }),

/***/ 2423:
/***/ ((module) => {

module.exports = require("lucide-react");

/***/ }),

/***/ 968:
/***/ ((module) => {

module.exports = require("next/head");

/***/ }),

/***/ 6689:
/***/ ((module) => {

module.exports = require("react");

/***/ }),

/***/ 997:
/***/ ((module) => {

module.exports = require("react/jsx-runtime");

/***/ }),

/***/ 2261:
/***/ ((module) => {

module.exports = require("serverless-mysql");

/***/ }),

/***/ 7147:
/***/ ((module) => {

module.exports = require("fs");

/***/ })

};
;

// load runtime
var __webpack_require__ = require("../../../webpack-runtime.js");
__webpack_require__.C(exports);
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
var __webpack_exports__ = __webpack_require__.X(0, [4017,8313,5264,6729,5449,913,9360,6217,4097,7023,9922,6000,2896], () => (__webpack_exec__(629)));
module.exports = __webpack_exports__;

})();