"use strict";
(() => {
var exports = {};
exports.id = 4504;
exports.ids = [4504,8105,3316,133,4135];
exports.modules = {

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

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ updateTableAfterFieldsUpdateFunctionExt)
/* harmony export */ });
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6517);
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _fetchApi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6729);
// @ts-check
/**
 * ==============================================================================
 * Imports
 * ==============================================================================
 */ 

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/**
 * ==============================================================================
 * Auth user on client side
 * ==============================================================================
 * @param {object} params - Single object parameters
 * @param {{delegated: boolean}} [params.query] - Query object
 * @param {import("@/package-shared/types").DSQL_TableSchemaType} params.table - Target table object
 * @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type} params.database - Target MYSQL database record object
 * @param {import("@/package-shared/types").DSQL_DatabaseSchemaType[]} params.dbSchemaData - DSQL db schema
 * @param {import("@/package-shared/types").DSQL_FieldSchemaType[]} [params.tableFields] - Table Fields
 * @param {import("@/package-shared/types").DSQL_IndexSchemaType[]} [params.tableIndexes] - Table INdexes
 * @param {React.Dispatch<React.SetStateAction<boolean>>} [params.setLoading]
 */ function updateTableAfterFieldsUpdateFunctionExt({ query , table , database , dbSchemaData , tableFields , tableIndexes , setLoading ,  }) {
    /**
     * @description Initialize
     */ let newDbSchemaData = [
        ...dbSchemaData
    ];
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    try {
        const dbIndex = newDbSchemaData.findIndex((db)=>db.dbFullName === database.db_full_name);
        const targetDb = newDbSchemaData[dbIndex];
        const targetTableIndex = targetDb.tables.findIndex((_table)=>_table.tableName === table.tableName);
        newDbSchemaData[dbIndex].tables[targetTableIndex].fields = tableFields ? lodash__WEBPACK_IMPORTED_MODULE_0__.cloneDeep(tableFields) : [];
        newDbSchemaData[dbIndex].tables[targetTableIndex].indexes = tableIndexes ? lodash__WEBPACK_IMPORTED_MODULE_0__.cloneDeep(tableIndexes) : [];
        const tempField = newDbSchemaData[dbIndex].tables[targetTableIndex].fields.find((fld)=>fld.newTempField);
        if (tempField) {
            window.alert("Please resolve all open fields before you save");
            setTimeout(()=>{
                setLoading?.(false);
            }, 1000);
            return;
        }
        (0,_fetchApi__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)("/api/updateDbSchemaDataForUser", {
            method: "post",
            body: {
                schema: newDbSchemaData,
                database: database.db_slug,
                table: table,
                delegated: query?.delegated
            }
        }, true).then((res)=>{
            if (res.success) {
                window.location.reload();
            } else {
                window.alert(res.msg || "Operation Failed. Please check permissions.");
            }
        }).finally(()=>{
            if (setLoading) {
                setTimeout(()=>{
                    setLoading(false);
                }, 1000);
            }
        });
    } catch (/** @type {any} */ error) {
        window.alert(error.message);
        setTimeout(()=>{
            setLoading?.(false);
        }, 1000);
        return;
    }
} ////////////////////////////////////////
 ////////////////////////////////////////
 ////////////////////////////////////////


/***/ }),

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

// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "EditTableContext": () => (/* binding */ EditTableContext),
  "default": () => (/* binding */ EditTable),
  "getServerSideProps": () => (/* binding */ getServerSideProps)
});

// EXTERNAL MODULE: external "react/jsx-runtime"
var jsx_runtime_ = __webpack_require__(997);
// EXTERNAL MODULE: external "react"
var external_react_ = __webpack_require__(6689);
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
// EXTERNAL MODULE: ./layouts/AdminLayout.jsx + 2 modules
var AdminLayout = __webpack_require__(4858);
// EXTERNAL MODULE: ./functions/backend/userAuth.js
var userAuth = __webpack_require__(370);
var userAuth_default = /*#__PURE__*/__webpack_require__.n(userAuth);
// EXTERNAL MODULE: ./components/general/ExtraContentDatabase.jsx
var ExtraContentDatabase = __webpack_require__(4941);
// EXTERNAL MODULE: ./components/general/BackButton.jsx
var BackButton = __webpack_require__(1781);
// EXTERNAL MODULE: ./components/general/Breadcrumbs.jsx
var Breadcrumbs = __webpack_require__(424);
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
var LoadingBlock = __webpack_require__(5264);
// EXTERNAL MODULE: ./functions/frontend/checkUniqueField.js
var checkUniqueField = __webpack_require__(4105);
// EXTERNAL MODULE: ./components/admin/databases/TableFields.jsx + 7 modules
var TableFields = __webpack_require__(4893);
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
var fetchApi = __webpack_require__(6729);
// EXTERNAL MODULE: ./components/general/FormAlertBlock.jsx
var FormAlertBlock = __webpack_require__(7037);
;// CONCATENATED MODULE: ./components/admin/databases/EditTableForm.jsx
// @ts-check
/**
 * ==============================================================================
 * Imports
 * ==============================================================================
 */ 







/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** @type {any} */ let timeout;
/** ****************************************************************************** */ /**
 * ==============================================================================
 * Main Component { Functional }
 * ==============================================================================
 * @param {Object} props - Server props
 */ function EditTableForm(props) {
    /**
     * Get Contexts
     *
     * @abstract { React.useContext }
     */ const { user , table , tableFields , database , query , confirmedDelegetedUser ,  } = external_react_default().useContext(EditTableContext);
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * ## Check Duplicate Slug Function
     * @param {string} value
     */ async function checkDuplicateSlug(value) {
        const duplicate = await (0,checkUniqueField/* default */.Z)({
            tableName: "user_database_tables",
            columnName: "table_slug",
            value: value,
            userId: user.id
        });
        return duplicate;
    }
    const isDelegated = confirmedDelegetedUser?.delegated;
    const isTableEditable = confirmedDelegetedUser?.priviledges?.match(/Edit Tables/i);
    const isTableDeletable = confirmedDelegetedUser?.priviledges?.match(/Delete Tables/i);
    const isTableCreatable = confirmedDelegetedUser?.priviledges?.match(/Create Tables/i);
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * React Hooks
     *
     * @abstract { useState, useEffect, useRef, etc ... }
     */ /** @type {any} */ const alertState = external_react_default().useState(null);
    /** @type {[ alert: string | null, setAlert: React.Dispatch<React.SetStateAction<string | null>> ]} */ const [alert, setAlert] = alertState;
    const [loading, setLoading] = external_react_default().useState(false);
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * Function Return
     *
     * @abstract Main Function Return
     */ return /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {
        children: (!isDelegated || isDelegated && isTableEditable) && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("section", {
            className: "paper",
            children: [
                /*#__PURE__*/ jsx_runtime_.jsx("h2", {
                    className: "text-xl m-0 text-left w-full",
                    children: "Update Table Information"
                }),
                loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {}),
                /*#__PURE__*/ (0,jsx_runtime_.jsxs)("form", {
                    className: "w-full flex flex-col items-start gap-4 relative",
                    onSubmit: (e)=>{
                        e.preventDefault();
                        setLoading(true);
                        /** @type {HTMLFormElement} */ // @ts-ignore
                        const formEl = e.target;
                        const table_name_full = formEl["table_name"].value;
                        const table_name = formEl["table_slug"].value;
                        const table_description = formEl["table_description"].value;
                        const tableObject = {
                            tableName: table_name,
                            tableFullName: table_name_full,
                            tableDescription: table_description
                        };
                        // submitNewDatabaseForm({ e, setLoading })
                        (0,fetchApi/* default */.Z)("/api/updateUserTable", {
                            method: "post",
                            body: {
                                dbFullName: database.db_full_name,
                                dbSlug: database.db_slug,
                                dbId: database.id,
                                tableNameOld: table.tableName,
                                payload: tableObject,
                                delegated: query?.delegated
                            }
                        }, true).then((res)=>{
                            if (res.success) {
                                window.location.pathname = `/admin/${user?.id}/databases/${database.db_slug}/tables` + window.location.search;
                            } else {
                                window.alert("Failed to update Table! Please Try again.");
                                window.location.reload();
                            }
                        });
                    },
                    children: [
                        alert && /*#__PURE__*/ jsx_runtime_.jsx(FormAlertBlock/* default */.Z, {
                            message: alert
                        }),
                        /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                            className: "flex flex-col items-start gap-0.5 w-full",
                            children: [
                                /*#__PURE__*/ jsx_runtime_.jsx("label", {
                                    htmlFor: "table_name",
                                    children: "Name"
                                }),
                                /*#__PURE__*/ jsx_runtime_.jsx("input", {
                                    type: "text",
                                    name: "table_name",
                                    id: "table_name",
                                    placeholder: "Table Name",
                                    onInput: async (e)=>{
                                        /** @type {HTMLInputElement} */ // @ts-ignore
                                        const inputEl = e.target;
                                        /** @type {HTMLFormElement} */ // @ts-ignore
                                        const form = inputEl.closest("form");
                                        if (inputEl.value.match(/./)) {
                                            inputEl.classList.remove("warning");
                                            setAlert(null);
                                        } else {
                                            inputEl.classList.add("warning");
                                        }
                                        form["table_slug"].value = inputEl.value.toLowerCase().replace(/ /g, "_").replace(/[^a-zA-Z0-9-_]/g, "");
                                        let slugValue = form["table_slug"].value;
                                        window.clearTimeout(timeout);
                                        timeout = setTimeout(()=>{
                                            checkDuplicateSlug(slugValue).then((res)=>{
                                                if (res.result && slugValue !== table.tableName) {
                                                    form["table_slug"].classList.add("warning");
                                                    setAlert("Duplicate Table Name");
                                                } else {
                                                    form["table_slug"].classList.remove("warning");
                                                    setAlert(null);
                                                }
                                            });
                                        }, 300);
                                    },
                                    required: true,
                                    defaultValue: table.tableFullName
                                })
                            ]
                        }),
                        /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                            className: "flex flex-col items-start gap-0.5 w-full",
                            children: [
                                /*#__PURE__*/ jsx_runtime_.jsx("label", {
                                    htmlFor: "table_slug",
                                    children: "Slug"
                                }),
                                /*#__PURE__*/ jsx_runtime_.jsx("input", {
                                    type: "text",
                                    name: "table_slug",
                                    id: "table_slug",
                                    placeholder: "Table Slug",
                                    onInput: (e)=>{
                                        /** @type {HTMLInputElement} */ // @ts-ignore
                                        const inputEl = e.target;
                                        /** @type {HTMLFormElement} */ // @ts-ignore
                                        const form = inputEl.closest("form");
                                        if (inputEl.value.match(/./)) {
                                            inputEl.classList.remove("warning");
                                            setAlert(null);
                                        } else {
                                            inputEl.classList.add("warning");
                                        }
                                        window.clearTimeout(timeout);
                                        timeout = setTimeout(()=>{
                                            checkDuplicateSlug(inputEl.value).then((res)=>{
                                                if (res.result) {
                                                    inputEl.classList.add("warning");
                                                    setAlert("Duplicate Table Slug");
                                                } else {
                                                    inputEl.classList.remove("warning");
                                                    setAlert(null);
                                                }
                                            });
                                        }, 300);
                                    },
                                    required: true,
                                    defaultValue: table.tableName
                                })
                            ]
                        }),
                        /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                            className: "flex flex-col items-start gap-0.5 w-full",
                            children: [
                                /*#__PURE__*/ jsx_runtime_.jsx("label", {
                                    htmlFor: "table_description",
                                    children: "Description (optional)"
                                }),
                                /*#__PURE__*/ jsx_runtime_.jsx("textarea", {
                                    name: "table_description",
                                    id: "table_description",
                                    placeholder: "Short Description of Table",
                                    defaultValue: table.tableDescription
                                })
                            ]
                        }),
                        /*#__PURE__*/ jsx_runtime_.jsx("button", {
                            type: "submit",
                            className: "w-full" + (loading ? " pointer-events-none opacity-40" : ""),
                            id: "create-new-table-form-submit-button",
                            children: "Update Table Info"
                        })
                    ]
                })
            ]
        })
    });
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */  /** ****************************************************************************** */  /** ****************************************************************************** */  /** ****************************************************************************** */  /** ****************************************************************************** */  /** ****************************************************************************** */ 

// EXTERNAL MODULE: ./functions/frontend/updateTableAfterFieldsUpdateFunctionExt.js
var updateTableAfterFieldsUpdateFunctionExt = __webpack_require__(8382);
// EXTERNAL MODULE: ./components/general/ActiveCloneDbBanner.jsx
var ActiveCloneDbBanner = __webpack_require__(4986);
// EXTERNAL MODULE: ./components/general/ActiveCloneTableBanner.jsx
var ActiveCloneTableBanner = __webpack_require__(8515);
// EXTERNAL MODULE: ./components/admin/databases/DatabasesTablesList.jsx
var DatabasesTablesList = __webpack_require__(8264);
;// CONCATENATED MODULE: ./components/admin/databases/EditTableContent.jsx
// @ts-check
/**
 * ==============================================================================
 * Imports
 * ==============================================================================
 */ 











/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
 * ==============================================================================
 * Main Component { Functional }
 * ==============================================================================
 * @param {Object} props - Server props
 */ function EditTableContent(props) {
    /**
     * Get Contexts
     *
     * @abstract { React.useContext }
     */ const { user , database , table , tableFields , setTableFields , setTargetField , refreshFieldsListRef , dbSchemaData , query , confirmedDelegetedUser ,  } = external_react_default().useContext(EditTableContext);
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * Javascript Variables
     *
     * @abstract Non hook variables and functions
     */ const isDelegated = confirmedDelegetedUser?.delegated;
    const isTableEditable = confirmedDelegetedUser?.priviledges?.match(/Edit Tables/i);
    const isTableDeletable = confirmedDelegetedUser?.priviledges?.match(/Delete Tables/i);
    const isTableCreatable = confirmedDelegetedUser?.priviledges?.match(/Create Tables/i);
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * React Hooks
     *
     * @abstract { useState, useEffect, useRef, etc ... }
     */ function updateTableAfterFieldsUpdateFunction() {
        (0,updateTableAfterFieldsUpdateFunctionExt/* default */.Z)({
            query,
            table,
            database,
            dbSchemaData,
            tableFields,
            tableIndexes: table.indexes
        });
    }
    ////////////////////////////////////////
    /**
     * Function Return
     *
     * @abstract Main Function Return
     */ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
        children: [
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                className: "flex-col items-start gap-0 w-full",
                children: [
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                        className: "",
                        children: [
                            /*#__PURE__*/ jsx_runtime_.jsx(BackButton/* default */.Z, {}),
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("h1", {
                                className: "text-3xl m-0",
                                children: [
                                    /*#__PURE__*/ jsx_runtime_.jsx("span", {
                                        children: "Edit"
                                    }),
                                    /*#__PURE__*/ jsx_runtime_.jsx("a", {
                                        href: `/admin/${user?.id}/databases/${database.db_slug}/tables/${table.tableName}`,
                                        className: "p-2 bg-white dark:bg-slate-800 rounded border border-solid border-slate-200 dark:border-slate-600 ml-2 text-primary hover:text-primary_dark",
                                        children: table.tableFullName
                                    }),
                                    /*#__PURE__*/ jsx_runtime_.jsx("span", {
                                        className: "ml-2",
                                        children: "Table"
                                    })
                                ]
                            })
                        ]
                    }),
                    /*#__PURE__*/ jsx_runtime_.jsx(Breadcrumbs/* default */.Z, {
                        confirmedDelegetedUser: query?.delegated,
                        user: user
                    })
                ]
            }),
            database.active_clone ? /*#__PURE__*/ jsx_runtime_.jsx(ActiveCloneDbBanner/* default */.Z, {
                database: database,
                user: user
            }) : /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {}),
            database.remote_connected ? /*#__PURE__*/ jsx_runtime_.jsx(DatabasesTablesList/* ConnectedDatabaseBanner */.w, {
                database: database
            }) : /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {}),
            /*#__PURE__*/ jsx_runtime_.jsx(ActiveCloneTableBanner/* default */.Z, {
                table: table,
                database: database,
                user: user
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                className: "w-full flex-col",
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(EditTableForm, {}),
                    /*#__PURE__*/ jsx_runtime_.jsx(TableFields/* default */.Z, {
                        user: user,
                        tableFields: tableFields,
                        setTableFields: setTableFields,
                        setTargetField: setTargetField,
                        refreshFieldsListRef: refreshFieldsListRef,
                        updateTable: true,
                        database: database,
                        updateTableAfterFieldsUpdateFunction: updateTableAfterFieldsUpdateFunction,
                        confirmedDelegetedUser: confirmedDelegetedUser,
                        query: query,
                        table: table
                    })
                ]
            })
        ]
    });
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */  /** ****************************************************************************** */  /** ****************************************************************************** */  /** ****************************************************************************** */  /** ****************************************************************************** */  /** ****************************************************************************** */ 

// EXTERNAL MODULE: ./functions/backend/grabDelegatedUserFromCookie.js
var grabDelegatedUserFromCookie = __webpack_require__(5116);
var grabDelegatedUserFromCookie_default = /*#__PURE__*/__webpack_require__.n(grabDelegatedUserFromCookie);
// EXTERNAL MODULE: ./package-shared/utils/backend/global-db/DB_HANDLER.js
var DB_HANDLER = __webpack_require__(9395);
var DB_HANDLER_default = /*#__PURE__*/__webpack_require__.n(DB_HANDLER);
// EXTERNAL MODULE: ./functions/backend/grabUserSchemaData.js
var grabUserSchemaData = __webpack_require__(2527);
;// CONCATENATED MODULE: ./pages/admin/[user_id]/databases/[single]/tables/[single_table]/edit-table.jsx
// @ts-check
/**
 * ==============================================================================
 * Imports
 * ==============================================================================
 */ 

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







/** ****************************************************************************** */ /** @type {import("@/package-shared/types").EditTableContextType} */ // @ts-ignore
const init = {};
const EditTableContext = /*#__PURE__*/ external_react_default().createContext(init);
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
 * ==============================================================================
 * Main Component { Functional }
 * ==============================================================================
 * @param {Object} props - Server props
 * @param {import("@/package-shared/types").UserType} props.user
 * @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type} props.database
 * @param {import("@/package-shared/types").DSQL_TableSchemaType} props.table
 * @param {import("@/package-shared/types").DSQL_DatabaseSchemaType[]} props.dbSchemaData
 * @param {any} props.query
 * @param {any} props.confirmedDelegetedUser
 */ function EditTable({ user , database , table , dbSchemaData , query , confirmedDelegetedUser ,  }) {
    /**
     * Get Contexts
     *
     * @abstract { React.useContext }
     */ ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * Javascript Variables
     *
     * @abstract Non hook variables and functions
     */ const pageTitle = `Edit Table | Datasquirel`;
    const pageDescription = "Edit Table";
    let head = /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx("title", {
                children: pageTitle
            }),
            /*#__PURE__*/ jsx_runtime_.jsx("meta", {
                name: "description",
                content: pageDescription
            })
        ]
    });
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * React Hooks
     *
     * @abstract { useState, useEffect, useRef, etc ... }
     */ const [tableFields, setTableFields] = external_react_default().useState(table.fields);
    /** @type {[ targetField: import("@/package-shared/types").DSQL_FieldSchemaType | null, setTargetField: React.Dispatch<React.SetStateAction<import("@/package-shared/types").DSQL_FieldSchemaType | null>> ]} */ // @ts-ignore
    const [targetField, setTargetField] = external_react_default().useState(null);
    const [pageRefresh, setPageRefresh] = external_react_default().useState(0);
    const refreshFieldsListRef = external_react_default().useRef();
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    /**
     * Function Return
     *
     * @abstract Main Function Return
     */ return /*#__PURE__*/ jsx_runtime_.jsx(AdminLayout/* default */.Z, {
        head: head,
        user: user,
        extraHeaderContent: /*#__PURE__*/ jsx_runtime_.jsx(ExtraContentDatabase/* default */.Z, {
            database: database,
            query: query,
            confirmedDelegetedUser: confirmedDelegetedUser,
            user: user
        }),
        children: /*#__PURE__*/ jsx_runtime_.jsx(EditTableContext.Provider, {
            value: {
                user,
                database,
                table,
                tableFields,
                setTableFields,
                targetField,
                setTargetField,
                pageRefresh,
                setPageRefresh,
                refreshFieldsListRef,
                dbSchemaData,
                query,
                confirmedDelegetedUser
            },
            children: /*#__PURE__*/ jsx_runtime_.jsx(EditTableContent, {})
        })
    });
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
 * ==============================================================================
 * Server Side Props or Static Props
 * ==============================================================================
 * @type {import("next").GetServerSideProps}
 */ async function getServerSideProps({ req , res , query  }) {
    try {
        /**
         * User Auth
         *
         * @description User Auth
         */ const user = await userAuth_default()(req, res);
        if (!user?.logged_in_status) {
            return {
                redirect: {
                    destination: "/login",
                    permanent: false
                }
            };
        }
        /**
         * Check delegated user token
         *
         * @description Check delegated user token
         */ const dbUserData = await grabDelegatedUserFromCookie_default()({
            request: req,
            user: user,
            // @ts-ignore
            databaseSlug: query.single,
            query
        });
        const dbUserDataObj = dbUserData;
        if (!dbUserDataObj) {
            throw new Error("No Db Object Found!");
        }
        const { dbUserId , rootUserId  } = dbUserDataObj;
        /**
         * Page/Site Data Data Fetching
         *
         * @description Fetch data on the server before returning
         */ const database = await DB_HANDLER_default()(`SELECT * FROM user_databases WHERE user_id='${dbUserId}' AND db_slug='${query.single}'`);
        if (!database || !database[0]) {
            return {
                redirect: {
                    destination: `/admin/${user?.id}/databases`,
                    permanent: false
                }
            };
        }
        ////////////////////////////////////////
        ////////////////////////////////////////
        ////////////////////////////////////////
        /**
         * Confirm delegated User
         *
         * @description Confirm delegated User
         */ let confirmedDelegetedUser = dbUserData;
        const dbSchemaData = (0,grabUserSchemaData/* default */.Z)({
            userId: dbUserId
        });
        if (!dbSchemaData) throw new Error("User schema data not found!");
        /** @type {import("@/package-shared/types").DSQL_TableSchemaType[] | undefined} */ const tables = dbSchemaData.filter((db)=>db.dbFullName === database[0].db_full_name)?.[0]?.tables;
        const targetTable = tables?.filter((table)=>table.tableName === query.single_table)[0];
        if (!tables || !targetTable) {
            return {
                redirect: {
                    destination: `/admin/${user?.id}/databases`,
                    permanent: false
                }
            };
        }
        ////////////////////////////////////////
        ////////////////////////////////////////
        ////////////////////////////////////////
        /**
         * Server props return
         *
         * @description Return data fetched on the server side
         */ return {
            props: {
                user: user,
                database: database[0],
                dbSchemaData: dbSchemaData,
                table: targetTable,
                query,
                confirmedDelegetedUser
            }
        };
    ////////////////////////////////////////
    ////////////////////////////////////////
    ////////////////////////////////////////
    } catch (error) {
        return {
            redirect: {
                destination: "/",
                permanent: false
            }
        };
    }
}


/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

module.exports = require("gsap");

/***/ }),

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

module.exports = require("gsap/Flip");

/***/ }),

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

module.exports = require("lodash");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

module.exports = require("react");

/***/ }),

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

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

/***/ }),

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

module.exports = require("react-dom/client");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

module.exports = require("buffer");

/***/ }),

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

module.exports = require("crypto");

/***/ }),

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

module.exports = require("fs");

/***/ }),

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

module.exports = require("http");

/***/ }),

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

module.exports = require("path");

/***/ })

};
;

// 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,4480,370,424,4858,5472,1781,4941,7901,2317,5116,8345,4986,9594,8264,9471,7037,9967,464,8515,4105,3314,4893], () => (__webpack_exec__(8239)));
module.exports = __webpack_exports__;

})();