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

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

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ ProxyInput)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* 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__(616689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(545725);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(antd__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var components_misc_A__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(940981);
/* harmony import */ var components_share_site_name__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(535358);
/* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(371853);
/* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(next_router__WEBPACK_IMPORTED_MODULE_5__);
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 





function ProxyInput() {
    const router = (0,next_router__WEBPACK_IMPORTED_MODULE_5__.useRouter)();
    const { 0: error , 1: setError  } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)("");
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
        style: {
            margin: "15px 0"
        },
        children: [
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(components_misc_A__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {
                href: "https://doc.cocalc.com/share.html",
                children: [
                    "Share what you create in ",
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_share_site_name__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {})
                ]
            }),
            " ",
            "or paste a URL from anywhere on the web of a notebook, GitHub repo, or markdown file:",
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_2__.Input.Search, {
                style: {
                    marginTop: "10px"
                },
                size: "large",
                placeholder: "URL to notebook or GitHub username or GitHub username/repo or Gist id",
                allowClear: true,
                enterButton: "Enter",
                onSearch: (url)=>{
                    try {
                        router.push(urlToProxyURL(url));
                    } catch (err) {
                        setError(`Please enter a valid URL -- ${err}`);
                    }
                }
            }),
            error && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_2__.Alert, {
                style: {
                    marginTop: "15px"
                },
                type: "error",
                message: error,
                showIcon: true
            })
        ]
    });
};
// INPUT: a URL to something on the internet
// OUTPUT: a URL on the share serve (without the http, host stuff)
//         that proxies that input URL.
// The cases we treat are:
//     - gist
//     - github user or repo
//     - general URL fallback, if none of the above apply
function urlToProxyURL(url) {
    const { host , pathname  } = new URL(url);
    if (host == new URL(document.URL).host) {
        // URL on this very server - just go to it
        return url;
    } else if (host == "github.com") {
        return `/github${pathname}`;
    } else if (host == "gist.github.com") {
        return `/gist${pathname}`;
    } else {
        return `/url/${host}${pathname}`;
    }
}


/***/ }),

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

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ SiteName)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* 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 lib_use_customize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(117682);


function SiteName({ full  }) {
    const { siteName , siteDescription  } = (0,lib_use_customize__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z)();
    if (full) {
        return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
            children: [
                siteName,
                ": ",
                siteDescription
            ]
        });
    }
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
        children: siteName
    });
};


/***/ }),

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

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

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

// EXTERNAL MODULE: external "react/jsx-runtime"
var jsx_runtime_ = __webpack_require__(920997);
// EXTERNAL MODULE: ./node_modules/next/link.js
var next_link = __webpack_require__(741664);
var link_default = /*#__PURE__*/__webpack_require__.n(next_link);
// EXTERNAL MODULE: ./components/share/site-name.tsx
var site_name = __webpack_require__(535358);
// EXTERNAL MODULE: ../database/dist/pool/index.js
var dist_pool = __webpack_require__(17763);
var pool_default = /*#__PURE__*/__webpack_require__.n(dist_pool);
// EXTERNAL MODULE: ./components/share/public-paths.tsx
var public_paths = __webpack_require__(113419);
// EXTERNAL MODULE: ./components/share/layout.tsx + 1 modules
var layout = __webpack_require__(216284);
// EXTERNAL MODULE: ./lib/with-customize.ts
var with_customize = __webpack_require__(601880);
// EXTERNAL MODULE: ./lib/share/customize.tsx
var share_customize = __webpack_require__(158742);
// EXTERNAL MODULE: external "antd"
var external_antd_ = __webpack_require__(545725);
;// CONCATENATED MODULE: ./components/share/google-search.tsx
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 

function GoogleSearch() {
    return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Input.Search, {
        size: "small",
        placeholder: "Search...",
        allowClear: true,
        enterButton: "Google",
        onSearch: (value)=>{
            const host = window.location.host;
            const url = `https://www.google.com/search?q=site%3A${host}+${value}`;
            // Open url in a new tab.
            const tab = window.open(url, "_blank");
            if (tab != null) {
                tab.opener = null;
            }
        }
    });
};

// EXTERNAL MODULE: ./components/share/proxy-input.tsx
var proxy_input = __webpack_require__(709711);
// EXTERNAL MODULE: ./lib/account/get-account.ts
var get_account = __webpack_require__(661879);
// EXTERNAL MODULE: ./components/misc/A.tsx
var A = __webpack_require__(940981);
;// CONCATENATED MODULE: ./pages/share/public_paths/page/[page].tsx
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ /*
This is simply a list of *all* publicly shared files/directories,
with a simple page.  It is mainly meant to be walked by crawlers
such as Google and for people to browse.
*/ 











const PAGE_SIZE = 100;
function getPage(obj) {
    let { page  } = obj ?? {};
    if (page == null) {
        return 1;
    }
    page = parseInt(page);
    if (isFinite(page)) {
        return Math.max(page, 1);
    }
    return 1;
}
function Pager({ page , publicPaths  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        children: [
            "Page ",
            page,
            "\xa0\xa0",
            page > 1 ? /*#__PURE__*/ jsx_runtime_.jsx((link_default()), {
                href: `/share/public_paths/page/${page - 1}`,
                children: /*#__PURE__*/ jsx_runtime_.jsx("a", {
                    children: "Previous"
                })
            }) : /*#__PURE__*/ jsx_runtime_.jsx("span", {
                style: {
                    color: "#888"
                },
                children: "Previous"
            }),
            "\xa0\xa0",
            publicPaths != null && publicPaths.length >= PAGE_SIZE ? /*#__PURE__*/ jsx_runtime_.jsx((link_default()), {
                href: `/share/public_paths/page/${page + 1}`,
                children: /*#__PURE__*/ jsx_runtime_.jsx("a", {
                    children: "Next"
                })
            }) : /*#__PURE__*/ jsx_runtime_.jsx("span", {
                style: {
                    color: "#888"
                },
                children: "Next"
            })
        ]
    });
}
function All({ page , publicPaths , customize  }) {
    const pager = /*#__PURE__*/ jsx_runtime_.jsx(Pager, {
        page: page,
        publicPaths: publicPaths
    });
    return /*#__PURE__*/ jsx_runtime_.jsx(share_customize/* Customize */.l, {
        value: customize,
        children: /*#__PURE__*/ jsx_runtime_.jsx(layout/* Layout */.A, {
            title: `Page ${page} of public files`,
            children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx("div", {
                        style: {
                            float: "right",
                            width: "250px"
                        },
                        children: /*#__PURE__*/ jsx_runtime_.jsx(GoogleSearch, {})
                    }),
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)("h2", {
                        children: [
                            "Browse Jupyter Notebooks, Computational Whiteboards and much more on ",
                            /*#__PURE__*/ jsx_runtime_.jsx(site_name/* default */.Z, {})
                        ]
                    }),
                    /*#__PURE__*/ jsx_runtime_.jsx(proxy_input/* default */.Z, {}),
                    "Star items to easily ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/stars",
                        children: "find them in your list"
                    }),
                    ".",
                    /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                    /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                    pager,
                    /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                    /*#__PURE__*/ jsx_runtime_.jsx(public_paths/* default */.Z, {
                        publicPaths: publicPaths
                    }),
                    /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                    pager
                ]
            })
        })
    });
};
async function getServerSideProps(context) {
    const isAuthenticated = await (0,get_account/* default */.Z)(context.req) != null;
    const page = getPage(context.params);
    const pool = pool_default()("medium");
    const { rows  } = await pool.query(`SELECT id, path, url, description, ${(0,dist_pool.timeInSeconds)("last_edited")},
    counter::INT,
     (SELECT COUNT(*)::INT FROM public_path_stars WHERE public_path_id=id) AS stars
    FROM public_paths
    WHERE vhost IS NULL AND disabled IS NOT TRUE AND unlisted IS NOT TRUE AND
    ((authenticated IS TRUE AND $1 IS TRUE) OR (authenticated IS NOT TRUE))
    ORDER BY stars DESC, last_edited DESC LIMIT $2 OFFSET $3`, [
        isAuthenticated,
        PAGE_SIZE,
        PAGE_SIZE * (page - 1)
    ]);
    return await (0,with_customize/* default */.Z)({
        context,
        props: {
            page,
            publicPaths: rows
        }
    });
}


/***/ }),

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

module.exports = require("antd");

/***/ }),

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

module.exports = require("cookies");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

/***/ 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");

/***/ }),

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

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

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/add-path-prefix.js");

/***/ }),

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

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

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/format-next-pathname-info.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");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/path-has-prefix.js");

/***/ }),

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

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

/***/ }),

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

module.exports = require("next/dist/shared/lib/router/utils/remove-trailing-slash.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,2952,1746,1664,7545,3734,2208,5654,9925,9715,2448,9066,981,5997,5409,722,3624,9924,5379,8742,686], () => (__webpack_exec__(409984)));
module.exports = __webpack_exports__;

})();