(() => {
var exports = {};
exports.id = 159;
exports.ids = [159,7206];
exports.modules = {

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

"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "E": () => (/* binding */ LOGIN_STYLE)
/* harmony export */ });
const LOGIN_STYLE = {
    maxWidth: "400px",
    margin: "auto",
    border: "1px solid lightgrey",
    borderRadius: "5px",
    padding: "10px 20px 20px 20px",
    backgroundColor: "#fafafa",
    fontSize: "12pt",
    color: "#606060"
};


/***/ }),

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

"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ Head)
/* 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 next_head__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(40968);
/* harmony import */ var next_head__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(next_head__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var lib_customize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(481617);
/* harmony import */ var lib_base_path__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(621923);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(371017);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);




const FAVICON = "/webapp/favicon-32x32.png";

function Head({ title  }) {
    const { siteName  } = (0,lib_customize__WEBPACK_IMPORTED_MODULE_2__/* .useCustomize */ .i)();
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((next_head__WEBPACK_IMPORTED_MODULE_1___default()), {
        children: [
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("title", {
                children: [
                    siteName,
                    " ",
                    siteName ? "\u2013" : "",
                    " ",
                    title
                ]
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
                name: "description",
                content: "CoCalc landing pages and documentation"
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("link", {
                rel: "icon",
                href: (0,path__WEBPACK_IMPORTED_MODULE_3__.join)(lib_base_path__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z ?? "", FAVICON)
            })
        ]
    });
};


/***/ }),

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

"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

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

// EXTERNAL MODULE: external "react/jsx-runtime"
var jsx_runtime_ = __webpack_require__(920997);
// EXTERNAL MODULE: external "antd"
var external_antd_ = __webpack_require__(545725);
// EXTERNAL MODULE: external "react"
var external_react_ = __webpack_require__(616689);
// EXTERNAL MODULE: ./components/logo-square.tsx
var logo_square = __webpack_require__(973846);
// EXTERNAL MODULE: ./lib/use-customize.ts
var use_customize = __webpack_require__(1198);
// EXTERNAL MODULE: ./components/misc/A.tsx
var A = __webpack_require__(617637);
// EXTERNAL MODULE: ./components/auth/shared.ts
var shared = __webpack_require__(579851);
// EXTERNAL MODULE: ./lib/api/post.ts
var post = __webpack_require__(456658);
// EXTERNAL MODULE: ../frontend/dist/components/icon.js
var icon = __webpack_require__(807772);
// EXTERNAL MODULE: ./components/landing/contact.tsx
var contact = __webpack_require__(745743);
// EXTERNAL MODULE: external "next/router"
var router_ = __webpack_require__(371853);
;// CONCATENATED MODULE: ./components/auth/redeem-password-reset.tsx











function PasswordReset({ passwordResetId  }) {
    const { account , siteName  } = (0,use_customize/* default */.Z)();
    const { 0: password , 1: setPassword  } = (0,external_react_.useState)("");
    const { 0: resetting , 1: setResetting  } = (0,external_react_.useState)(false);
    const { 0: error , 1: setError  } = (0,external_react_.useState)("");
    const { 0: success , 1: setSuccess  } = (0,external_react_.useState)("");
    const router = (0,router_.useRouter)();
    async function resetPassword() {
        if (resetting) return;
        try {
            setError("");
            setSuccess("");
            setResetting(true);
            await (0,post/* default */.Z)("/auth/redeem-password-reset", {
                password,
                passwordResetId
            });
            // if no error got signed in, so do a page refresh to see this
            router.reload();
        } catch (err) {
            setError(`${err}`);
        } finally{
            setResetting(false);
        }
    }
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        style: {
            padding: "15px"
        },
        children: [
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                style: {
                    textAlign: "center",
                    marginBottom: "15px"
                },
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(logo_square/* default */.Z, {
                        style: {
                            width: "100px",
                            height: "100px"
                        }
                    }),
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)("h1", {
                        children: [
                            account ? "Successfully " : "",
                            "Reset Your ",
                            siteName,
                            " Password"
                        ]
                    })
                ]
            }),
            account && /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: shared/* LOGIN_STYLE */.E,
                children: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                    style: {
                        marginTop: "20px"
                    },
                    message: /*#__PURE__*/ jsx_runtime_.jsx("b", {
                        children: "Success"
                    }),
                    description: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                        style: {
                            fontSize: "12pt"
                        },
                        children: "Password successfully set. You are now signed in using your new password."
                    }),
                    type: "success",
                    showIcon: true
                })
            }),
            !account && /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
                children: [
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                        style: shared/* LOGIN_STYLE */.E,
                        children: [
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                                style: {
                                    margin: "10px 0"
                                },
                                children: [
                                    "Choose a new ",
                                    siteName,
                                    " password:"
                                ]
                            }),
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("form", {
                                children: [
                                    /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Input.Password, {
                                        style: {
                                            fontSize: "13pt"
                                        },
                                        autoFocus: true,
                                        placeholder: "New Password",
                                        autoComplete: "username",
                                        value: password,
                                        onChange: (e)=>{
                                            setPassword(e.target.value);
                                            setError("");
                                            setSuccess("");
                                        },
                                        onPressEnter: (e)=>{
                                            e.preventDefault();
                                            if (resetting || !isValidPassword(password)) return;
                                            resetPassword();
                                        }
                                    }),
                                    password && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Button, {
                                        disabled: resetting || !isValidPassword(password),
                                        shape: "round",
                                        size: "large",
                                        type: "primary",
                                        style: {
                                            width: "100%",
                                            marginTop: "20px"
                                        },
                                        onClick: resetPassword,
                                        children: resetting ? /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
                                            children: [
                                                /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                                                    name: "spinner",
                                                    spin: true
                                                }),
                                                " Changing password..."
                                            ]
                                        }) : !isValidPassword(password) ? "Enter password (at least 6 characters)." : "Change Password"
                                    })
                                ]
                            }),
                            error && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                                style: {
                                    marginTop: "20px"
                                },
                                message: "Error",
                                description: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                                    style: {
                                        fontSize: "12pt"
                                    },
                                    children: [
                                        /*#__PURE__*/ jsx_runtime_.jsx("b", {
                                            children: error
                                        }),
                                        /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                                        " If you are stuck ",
                                        /*#__PURE__*/ jsx_runtime_.jsx(contact/* default */.Z, {
                                            lower: true
                                        }),
                                        "."
                                    ]
                                }),
                                type: "error",
                                showIcon: true
                            }),
                            success && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                                style: {
                                    marginTop: "20px"
                                },
                                message: /*#__PURE__*/ jsx_runtime_.jsx("b", {
                                    children: "Success"
                                }),
                                description: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                                    style: {
                                        fontSize: "12pt"
                                    },
                                    children: success
                                }),
                                type: "success",
                                showIcon: true
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                        style: {
                            ...shared/* LOGIN_STYLE */.E,
                            backgroundColor: "white",
                            marginTop: "30px",
                            marginBottom: "30px",
                            paddingTop: "15px"
                        },
                        children: [
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("p", {
                                children: [
                                    "Remember your password? ",
                                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                                        href: "/auth/sign-in",
                                        children: "Sign In"
                                    })
                                ]
                            }),
                            "You can also",
                            " ",
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)(A/* default */.Z, {
                                href: "/auth/try",
                                children: [
                                    "use ",
                                    siteName,
                                    " without creating an account"
                                ]
                            })
                        ]
                    })
                ]
            })
        ]
    });
};
function isValidPassword(password) {
    return password.length >= 6;
}

// EXTERNAL MODULE: ./components/landing/footer.tsx + 1 modules
var footer = __webpack_require__(920691);
// EXTERNAL MODULE: ./components/landing/head.tsx
var head = __webpack_require__(422004);
// EXTERNAL MODULE: ./components/landing/header.tsx + 2 modules
var header = __webpack_require__(113680);
// EXTERNAL MODULE: ./lib/customize.ts
var lib_customize = __webpack_require__(481617);
// EXTERNAL MODULE: ./lib/with-customize.ts
var with_customize = __webpack_require__(422638);
;// CONCATENATED MODULE: ./pages/auth/password-reset/[id].tsx

/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ // Password reset page







function _id_PasswordReset({ passwordResetId , customize  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(lib_customize/* Customize */.l, {
        value: customize,
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx(head/* default */.Z, {
                title: "Password Reset"
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Layout, {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(header/* default */.Z, {
                        page: "sign-in",
                        subPage: "password-reset"
                    }),
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Layout.Content, {
                        style: {
                            backgroundColor: "white"
                        },
                        children: [
                            /*#__PURE__*/ jsx_runtime_.jsx(PasswordReset, {
                                passwordResetId: passwordResetId
                            }),
                            /*#__PURE__*/ jsx_runtime_.jsx(footer/* default */.Z, {})
                        ]
                    })
                ]
            })
        ]
    });
};
async function getServerSideProps(context) {
    const { id  } = context.params;
    return await (0,with_customize/* default */.Z)({
        context,
        props: {
            passwordResetId: id
        }
    });
}


/***/ }),

/***/ 689685:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {

var crypto = __webpack_require__(706113);

var rn = function(max) {
  var rnBytes = crypto.randomBytes(2);
  var randomNum = rnBytes.readUInt8(0) * 256 + rnBytes.readUInt8(1);
  return randomNum % max;
}

var digits = '0123456789'
var base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'
var base30 = '0123456789ABCDFHKLMNPQRSTUVWXYZ'  // 1-9, A-Z exclude(E, G, I, J, O) for human read

exports.generate = function(len, chars) {
  len = len || 16;
  chars = chars || base62;
  var key = '';
  var charsLen = chars.length;
  for (var i=0; i<len; i++) {
    key += chars[rn(charsLen)];
  }
  return key;
};

exports.generateDigits = function(len) {
  len = len || 16;
  return exports.generate(len, digits)
};

exports.generateBase30 = function(len) {
  len = len || 16;
  return exports.generate(len, base30)
}


/***/ }),

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

"use strict";
module.exports = require("antd");

/***/ }),

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

"use strict";
module.exports = require("cookies");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

"use strict";
module.exports = require("react");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

"use strict";
module.exports = require("assert");

/***/ }),

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

"use strict";
module.exports = require("buffer");

/***/ }),

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

"use strict";
module.exports = require("crypto");

/***/ }),

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

"use strict";
module.exports = require("dns");

/***/ }),

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

"use strict";
module.exports = require("events");

/***/ }),

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

"use strict";
module.exports = require("fs");

/***/ }),

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

"use strict";
module.exports = require("net");

/***/ }),

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

"use strict";
module.exports = require("os");

/***/ }),

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

"use strict";
module.exports = require("path");

/***/ }),

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

"use strict";
module.exports = require("process");

/***/ }),

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

"use strict";
module.exports = require("stream");

/***/ }),

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

"use strict";
module.exports = require("string_decoder");

/***/ }),

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

"use strict";
module.exports = require("tls");

/***/ }),

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

"use strict";
module.exports = require("tty");

/***/ }),

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

"use strict";
module.exports = require("url");

/***/ }),

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

"use strict";
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,9715,2448,1107,9521,5114], () => (__webpack_exec__(680594)));
module.exports = __webpack_exports__;

})();