"use strict";
(() => {
var exports = {};
exports.id = 9511;
exports.ids = [9511,2438,7206];
exports.modules = {

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

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ getProjectId)
/* harmony export */ });
/* harmony import */ var _cocalc_database_pool__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(17763);
/* harmony import */ var _cocalc_database_pool__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_cocalc_database_pool__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _owner__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(938450);
/*
Get basic information about a user or organization
from the database.  This should be enough to render
a nice "homepage" for that user or organization.

*/ 

// Throws an exception if there is no project with this name.
// TODO: take into account redirects for when name is changed.
async function getProjectId(owner, project) {
    const { owner_id  } = await (0,_owner__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)(owner);
    const pool = _cocalc_database_pool__WEBPACK_IMPORTED_MODULE_0___default()("long"); // map from owner/project --> project_id unlikely to change and when it does, stale data is ok.
    // NOTE: it's not enough that owner is a collab on the project -- they have to be the owner.
    // We do users ? $2 also, since it's fast/indexed, then dig in to the JSON...
    // Note that we have put owner_id in the query string explicitly (as far as I know),
    // though it is NOT user supplied so that's safe.
    const result = await pool.query(`SELECT project_id FROM projects WHERE LOWER(name)=$1 AND users ? $2 AND users#>>'{${owner_id},group}' = 'owner'`, [
        project.toLowerCase(),
        owner_id
    ]);
    if (result.rows.length > 0) {
        return result.rows[0].project_id;
    }
    throw Error(`no project ${owner}/${project}`);
};


/***/ }),

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

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__),
/* harmony export */   "getServerSideProps": () => (/* binding */ getServerSideProps)
/* harmony export */ });
/* harmony import */ var lib_names_project__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(270263);
/* harmony import */ var lib_with_customize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(422638);
/* harmony import */ var lib_project_info__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(336284);
/* harmony import */ var lib_share_get_project__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(123925);
/* harmony import */ var components_project_project__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(166455);
/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ // Page for a project that is owned by a named account
// or organization.





/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (components_project_project__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z);
async function getServerSideProps(context) {
    const { owner , project  } = context.params;
    try {
        const project_id = await (0,lib_names_project__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z)(owner, project);
        const props = {
            project_id,
            ...await (0,lib_project_info__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z)(project_id, context.req),
            ...await (0,lib_share_get_project__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)(project_id)
        };
        return (0,lib_with_customize__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)({
            context,
            props
        });
    } catch (_err) {
        return {
            notFound: true
        };
    }
}


/***/ }),

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

module.exports = require("antd");

/***/ }),

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

module.exports = require("cookies");

/***/ }),

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

module.exports = require("lodash");

/***/ }),

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

module.exports = require("lru-cache");

/***/ }),

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

module.exports = require("next/dist/shared/lib/head-manager-context.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/head.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/i18n/detect-domain-locale.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/i18n/normalize-locale-path.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/image-config-context.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/image-config.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/is-plain-object.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/mitt.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/page-path/denormalize-page-path.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router-context.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/format-url.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/get-asset-path-from-route.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/get-middleware-regex.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/is-dynamic.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/parse-relative-url.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/querystring.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/resolve-rewrites.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/route-matcher.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/route-regex.js");

/***/ }),

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

module.exports = require("next/dist/shared/lib/utils.js");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

module.exports = require("react");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

module.exports = require("assert");

/***/ }),

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

module.exports = require("buffer");

/***/ }),

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

module.exports = require("crypto");

/***/ }),

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

module.exports = require("dns");

/***/ }),

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

module.exports = require("events");

/***/ }),

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

module.exports = require("fs");

/***/ }),

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

module.exports = require("net");

/***/ }),

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

module.exports = require("os");

/***/ }),

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

module.exports = require("path");

/***/ }),

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

module.exports = require("process");

/***/ }),

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

module.exports = require("punycode");

/***/ }),

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

module.exports = require("stream");

/***/ }),

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

module.exports = require("string_decoder");

/***/ }),

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

module.exports = require("tls");

/***/ }),

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

module.exports = require("tty");

/***/ }),

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

module.exports = require("url");

/***/ }),

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

module.exports = require("util");

/***/ })

};
;

// 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, [549,6918,3429,1746,9505,1748,3734,2208,5654,5887,9715,2448,1107,9521,5114,722,3624,9924,5379,8278,2712,4258,6349,2620,2983,4831,8450], () => (__webpack_exec__(227439)));
module.exports = __webpack_exports__;

})();