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

/***/ 762064:
/***/ ((__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 */ Preferences),
  "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);
;// CONCATENATED MODULE: external "next/error"
const error_namespaceObject = require("next/error");
var error_default = /*#__PURE__*/__webpack_require__.n(error_namespaceObject);
// EXTERNAL MODULE: ./components/landing/header.tsx + 2 modules
var header = __webpack_require__(131498);
// EXTERNAL MODULE: ./components/landing/footer.tsx + 1 modules
var footer = __webpack_require__(831910);
// EXTERNAL MODULE: ./components/landing/head.tsx
var head = __webpack_require__(373306);
// EXTERNAL MODULE: ../util/dist/misc.js
var misc = __webpack_require__(477389);
// EXTERNAL MODULE: ./components/auth/in-place-sign-in-or-up.tsx
var in_place_sign_in_or_up = __webpack_require__(438572);
// EXTERNAL MODULE: ./components/misc/anonymous.tsx
var anonymous = __webpack_require__(688642);
// EXTERNAL MODULE: ./components/share/loading.tsx
var loading = __webpack_require__(976087);
// EXTERNAL MODULE: ./lib/hooks/profile.ts
var hooks_profile = __webpack_require__(148881);
// EXTERNAL MODULE: ./lib/use-customize.ts
var use_customize = __webpack_require__(117682);
// EXTERNAL MODULE: external "next/router"
var router_ = __webpack_require__(371853);
// EXTERNAL MODULE: ./lib/hooks/api.ts
var api = __webpack_require__(375698);
// EXTERNAL MODULE: ./components/licenses/license.tsx
var license = __webpack_require__(776527);
// EXTERNAL MODULE: ./components/misc/A.tsx
var A = __webpack_require__(940981);
// EXTERNAL MODULE: ../frontend/dist/components/icon.js
var icon = __webpack_require__(807772);
// EXTERNAL MODULE: ./components/misc/timestamp.tsx
var timestamp = __webpack_require__(749414);
;// CONCATENATED MODULE: ./components/billing/invoices-and-receipts.tsx
/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 








function Description({ hosted_invoice_url , lines , metadata  }) {
    const license_id = metadata?.license_id ?? lines.data[0].metadata?.license_id;
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        style: {
            wordWrap: "break-word",
            wordBreak: "break-word"
        },
        children: [
            lines.data[0].description,
            (lines?.total_count ?? 1) > 1 && ", etc.",
            hosted_invoice_url && /*#__PURE__*/ jsx_runtime_.jsx("div", {
                children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(A/* default */.Z, {
                    href: hosted_invoice_url,
                    children: [
                        /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                            name: "external-link"
                        }),
                        " Invoice"
                    ]
                })
            }),
            license_id && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                children: [
                    "License: ",
                    /*#__PURE__*/ jsx_runtime_.jsx(license/* default */.ZP, {
                        license_id: license_id
                    })
                ]
            })
        ]
    });
}
function Status({ status , due_date , hosted_invoice_url  }) {
    if (status == "paid") {
        return /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {
            children: "Paid"
        });
    }
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(A/* default */.Z, {
        style: {
            color: "red"
        },
        href: hosted_invoice_url,
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                name: "external-link"
            }),
            " Due",
            " ",
            /*#__PURE__*/ jsx_runtime_.jsx(timestamp/* default */.Z, {
                epoch: 1000 * due_date,
                dateOnly: true
            })
        ]
    });
}
function Created({ created  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx(timestamp/* default */.Z, {
        epoch: 1000 * created,
        dateOnly: true
    });
}
function Amount({ total , currency  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {
        children: (0,misc.stripeAmount)(total, currency)
    });
}
const columns = [
    {
        responsive: [
            "xs"
        ],
        title: "Invoices and Receipts",
        render: (_, invoice)=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(Description, {
                        ...invoice
                    }),
                    "Created: ",
                    /*#__PURE__*/ jsx_runtime_.jsx(Created, {
                        ...invoice
                    }),
                    /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                    /*#__PURE__*/ jsx_runtime_.jsx(Amount, {
                        ...invoice
                    }),
                    /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                    /*#__PURE__*/ jsx_runtime_.jsx(Status, {
                        ...invoice
                    })
                ]
            })
    },
    {
        responsive: [
            "sm"
        ],
        title: "Description",
        width: "50%",
        render: (_, invoice)=>/*#__PURE__*/ jsx_runtime_.jsx(Description, {
                ...invoice
            })
    },
    {
        responsive: [
            "sm"
        ],
        title: "Status",
        align: "center",
        render: (_, invoice)=>/*#__PURE__*/ jsx_runtime_.jsx(Status, {
                ...invoice
            }),
        sorter: {
            compare: (a, b)=>(0,misc.cmp)(a.status, b.status)
        }
    },
    {
        responsive: [
            "sm"
        ],
        title: "Created",
        align: "center",
        render: (_, invoice)=>/*#__PURE__*/ jsx_runtime_.jsx(Created, {
                ...invoice
            }),
        sorter: {
            compare: (a, b)=>-(0,misc.cmp)(a.created, b.created)
        }
    },
    {
        responsive: [
            "sm"
        ],
        title: "Amount",
        align: "right",
        render: (_, invoice)=>/*#__PURE__*/ jsx_runtime_.jsx(Amount, {
                ...invoice
            }),
        sorter: {
            compare: (a, b)=>(0,misc.cmp)(a.amount_paid ?? 0, b.amount_paid ?? 0)
        }
    }, 
];
function InvoicesAndReceipts() {
    const { result , error  } = (0,api/* default */.Z)("billing/get-invoices-and-receipts");
    if (error) {
        return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
            type: "error",
            message: error
        });
    }
    if (!result) {
        return /*#__PURE__*/ jsx_runtime_.jsx(loading/* default */.Z, {});
    }
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx("h3", {
                children: "Invoices and Receipts"
            }),
            'Your invoices and receipts are listed below. Click on the "Invoice" link to get a printable invoice or receipt version.',
            /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Table, {
                columns: columns,
                dataSource: result.data ?? [],
                rowKey: "id",
                style: {
                    marginTop: "15px"
                },
                pagination: {
                    hideOnSinglePage: true,
                    pageSize: 100
                }
            })
        ]
    });
};

;// CONCATENATED MODULE: ./components/billing/menu.tsx
/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 



function ConfigMenu({ main  }) {
    const router = (0,router_.useRouter)();
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Menu, {
        mode: "horizontal",
        selectedKeys: [
            main
        ],
        style: {
            height: "100%"
        },
        onSelect: (e)=>{
            router.push(`/billing/${e.keyPath[0]}`, undefined, {
                scroll: false
            });
        },
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Menu.Item, {
                children: /*#__PURE__*/ jsx_runtime_.jsx("b", {
                    style: {
                        color: "#666"
                    },
                    children: "Billing"
                })
            }, ""),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Menu.Item, {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                        name: "credit-card",
                        style: {
                            marginRight: "5px"
                        }
                    }),
                    " Credit Cards"
                ]
            }, "cards"),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Menu.Item, {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                        name: "calendar",
                        style: {
                            marginRight: "5px"
                        }
                    }),
                    " Subscriptions"
                ]
            }, "subscriptions"),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Menu.Item, {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                        name: "list",
                        style: {
                            marginRight: "5px"
                        }
                    }),
                    " Invoices and Receipts"
                ]
            }, "receipts")
        ]
    });
};

;// CONCATENATED MODULE: ./components/billing/overview.tsx
/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 

function Overview() {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("p", {
                children: [
                    "You can see and edit your",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/billing/cards",
                        children: "your payment methods"
                    }),
                    ", view or cancel",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/billing/subscriptions",
                        children: "your subscriptions"
                    }),
                    ", and see",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/billing/receipts",
                        children: "your invoices and receipts"
                    }),
                    "."
                ]
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("p", {
                children: [
                    "You can also ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/store/site-license",
                        children: "buy a license"
                    }),
                    " at",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/store",
                        children: "the store"
                    }),
                    " and",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/licenses/managed",
                        children: "browse your existing licenses"
                    }),
                    "."
                ]
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("p", {
                children: [
                    "You can also read",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "https://doc.cocalc.com/account/purchases.html#subscription-list",
                        children: "the billing documentation"
                    }),
                    "."
                ]
            })
        ]
    });
};

// EXTERNAL MODULE: ./components/billing/payment-methods.tsx
var payment_methods = __webpack_require__(383668);
// EXTERNAL MODULE: external "react"
var external_react_ = __webpack_require__(616689);
// EXTERNAL MODULE: ./components/misc/help-email.tsx
var help_email = __webpack_require__(500590);
// EXTERNAL MODULE: ./lib/hooks/mounted.ts
var mounted = __webpack_require__(900686);
// EXTERNAL MODULE: ./lib/api/post.ts
var post = __webpack_require__(194184);
;// CONCATENATED MODULE: ./components/billing/subscriptions.tsx
/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 












function subscriptions_Description({ latest_invoice , metadata , invoices  }) {
    for (const invoice of invoices.data){
        if (latest_invoice != invoice.id) continue;
        const cnt = invoice.lines?.total_count ?? 1;
        const url = invoice.hosted_invoice_url;
        return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
            style: {
                wordWrap: "break-word",
                wordBreak: "break-word"
            },
            children: [
                invoice.lines.data[0].description,
                cnt > 1 && ", etc.",
                url && /*#__PURE__*/ jsx_runtime_.jsx("div", {
                    children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(A/* default */.Z, {
                        href: url,
                        children: [
                            /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                                name: "external-link"
                            }),
                            " Invoice"
                        ]
                    })
                }),
                metadata?.license_id && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                    children: [
                        "License: ",
                        /*#__PURE__*/ jsx_runtime_.jsx(license/* default */.ZP, {
                            license_id: metadata?.license_id
                        })
                    ]
                })
            ]
        });
    }
    return null;
}
function Period({ current_period_start , current_period_end , cancel_at_period_end ,  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx(timestamp/* default */.Z, {
                epoch: 1000 * current_period_start,
                dateOnly: true,
                absolute: true
            }),
            " –",
            " ",
            /*#__PURE__*/ jsx_runtime_.jsx(timestamp/* default */.Z, {
                epoch: 1000 * current_period_end,
                dateOnly: true,
                absolute: true
            }),
            cancel_at_period_end && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("span", {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                    "(will cancel at period end)"
                ]
            })
        ]
    });
}
function subscriptions_Status({ status  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {
        children: (0,misc.capitalize)(status)
    });
}
function Cost({ plan  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
        children: [
            (0,misc.stripeAmount)(plan.amount, plan.currency),
            " for",
            " ",
            (0,misc.planInterval)(plan.interval, plan.interval_count)
        ]
    });
}
function Cancel({ cancel_at_period_end , cancel_at , id , onChange  }) {
    const { 0: error , 1: setError  } = (0,external_react_.useState)("");
    const { 0: cancelling , 1: setCancelling  } = (0,external_react_.useState)(false);
    const isMounted = (0,mounted/* default */.Z)();
    const isCancelled = cancel_at_period_end || cancel_at != null;
    return /*#__PURE__*/ jsx_runtime_.jsx("div", {
        children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Popconfirm, {
            placement: "bottomLeft",
            title: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                style: {
                    maxWidth: "500px"
                },
                children: [
                    "Cancel? Are you sure you want to",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx("b", {
                        children: "cancel this subscription at period end"
                    }),
                    "? If you cancel your subscription, it will run to the end of the subscription period, but will not be renewed when the current (already paid for) period ends. If you need further clarification or need a refund,",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(help_email/* default */.Z, {
                        lower: true
                    }),
                    "."
                ]
            }),
            onConfirm: async ()=>{
                setCancelling(true);
                setError("");
                try {
                    await (0,post/* default */.Z)("billing/cancel-subscription", {
                        id
                    });
                } catch (err) {
                    if (!isMounted.current) return;
                    setError(err.message);
                } finally{
                    if (!isMounted.current) return;
                    setCancelling(false);
                    onChange();
                }
            },
            okText: "Yes, cancel at period end (do not auto-renew)",
            cancelText: "Make no change",
            children: [
                /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Button, {
                    disabled: isCancelled || cancelling,
                    type: "dashed",
                    children: cancelling ? /*#__PURE__*/ jsx_runtime_.jsx(loading/* default */.Z, {
                        delay: 0,
                        children: "Cancelling..."
                    }) : `Cancel${isCancelled ? "led" : ""}`
                }),
                error && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                    style: {
                        marginTop: "15px"
                    },
                    type: "error",
                    message: `Error: ${error}`
                })
            ]
        })
    });
}
function subscriptions_columns(invoices, onChange) {
    return [
        {
            responsive: [
                "xs"
            ],
            title: "Subscriptions",
            render: (_, sub)=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                    children: [
                        /*#__PURE__*/ jsx_runtime_.jsx(subscriptions_Description, {
                            ...sub,
                            invoices: invoices
                        }),
                        "Status: ",
                        /*#__PURE__*/ jsx_runtime_.jsx(subscriptions_Status, {
                            ...sub
                        }),
                        /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                        "Period: ",
                        /*#__PURE__*/ jsx_runtime_.jsx(Period, {
                            ...sub
                        }),
                        /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                        "Cost: ",
                        /*#__PURE__*/ jsx_runtime_.jsx(Cost, {
                            ...sub
                        }),
                        /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                        /*#__PURE__*/ jsx_runtime_.jsx(Cancel, {
                            ...sub,
                            onChange: onChange
                        })
                    ]
                })
        },
        {
            responsive: [
                "sm"
            ],
            title: "Description",
            width: "50%",
            render: (_, sub)=>/*#__PURE__*/ jsx_runtime_.jsx(subscriptions_Description, {
                    ...sub,
                    invoices: invoices
                })
        },
        {
            responsive: [
                "sm"
            ],
            title: "Status",
            align: "center",
            render: (_, sub)=>/*#__PURE__*/ jsx_runtime_.jsx(subscriptions_Status, {
                    ...sub
                }),
            sorter: {
                compare: (a, b)=>(0,misc.cmp)(a.status, b.status)
            }
        },
        {
            responsive: [
                "sm"
            ],
            title: "Period",
            align: "center",
            render: (_, sub)=>/*#__PURE__*/ jsx_runtime_.jsx(Period, {
                    ...sub
                })
        },
        {
            responsive: [
                "sm"
            ],
            title: "Cost",
            sorter: {
                compare: (a, b)=>(0,misc.cmp)(a.plan.amount, b.plan.amount)
            },
            render: (_, sub)=>/*#__PURE__*/ jsx_runtime_.jsx(Cost, {
                    ...sub
                })
        },
        {
            responsive: [
                "sm"
            ],
            title: "Cancel",
            align: "center",
            render: (_, sub)=>/*#__PURE__*/ jsx_runtime_.jsx(Cancel, {
                    ...sub,
                    onChange: onChange
                })
        }, 
    ];
}
function Subscriptions() {
    const subscriptions = (0,api/* default */.Z)("billing/get-subscriptions");
    const invoices = (0,api/* default */.Z)("billing/get-invoices-and-receipts");
    if (subscriptions.error) {
        return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
            type: "error",
            message: subscriptions.error
        });
    }
    if (!subscriptions.result) {
        return /*#__PURE__*/ jsx_runtime_.jsx(loading/* default */.Z, {});
    }
    if (invoices.error) {
        return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
            type: "error",
            message: invoices.error
        });
    }
    if (!invoices.result) {
        return /*#__PURE__*/ jsx_runtime_.jsx(loading/* default */.Z, {});
    }
    function onChange() {
        subscriptions.call();
        invoices.call();
    }
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("h3", {
                children: [
                    "Your Subscriptions (",
                    subscriptions.result?.data?.length ?? 0,
                    ")"
                ]
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                style: {
                    maxWidth: "800px",
                    margin: "15px 0"
                },
                children: [
                    "Your subscriptions are listed below. You can view invoices, get information about the license or plan corresponding to a subscription, and cancel a subscription at period end. You can also",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/store/site-license",
                        children: "create a new site license subscription"
                    }),
                    ". If you have any questions ",
                    /*#__PURE__*/ jsx_runtime_.jsx(help_email/* default */.Z, {
                        lower: true
                    }),
                    "."
                ]
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Table, {
                columns: subscriptions_columns(invoices.result, onChange),
                dataSource: subscriptions.result?.data ?? [],
                rowKey: "id",
                pagination: {
                    hideOnSinglePage: true,
                    pageSize: 100
                },
                style: {
                    overflowX: "auto"
                }
            }),
            subscriptions.result?.has_more && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                style: {
                    margin: "15px"
                },
                type: "warning",
                showIcon: true,
                message: "WARNING: Some of your subscriptions are not displayed above, since there are so many."
            })
        ]
    });
};

;// CONCATENATED MODULE: ./components/billing/layout.tsx
/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 













const { Content  } = external_antd_.Layout;
function ConfigLayout({ page  }) {
    const { isCommercial  } = (0,use_customize/* default */.Z)();
    const router = (0,router_.useRouter)();
    const profile = (0,hooks_profile/* default */.Z)({
        noCache: true
    });
    if (!isCommercial) {
        return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
            showIcon: true,
            style: {
                margin: "30px auto",
                maxWidth: "400px",
                fontSize: "12pt",
                padding: "15px 30px"
            },
            type: "warning",
            message: "Billing is not enabled for this server."
        });
    }
    if (!profile) {
        return /*#__PURE__*/ jsx_runtime_.jsx(loading/* default */.Z, {
            large: true,
            center: true
        });
    }
    const { account_id , is_anonymous  } = profile;
    if (!account_id) {
        return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
            style: {
                margin: "15px auto"
            },
            type: "warning",
            message: /*#__PURE__*/ jsx_runtime_.jsx(in_place_sign_in_or_up/* default */.Z, {
                title: "Account Configuration",
                why: "to see information about your licenses",
                onSuccess: ()=>{
                    router.reload();
                }
            })
        });
    }
    if (is_anonymous) {
        return /*#__PURE__*/ jsx_runtime_.jsx(anonymous/* default */.Z, {});
    }
    // page could be an empty array, then main is undefined → overview page
    const [main] = page;
    function body() {
        // main must be in MainPages defined in [[..page]].tsx
        if (main == null) return /*#__PURE__*/ jsx_runtime_.jsx(Overview, {});
        switch(main){
            case "cards":
                return /*#__PURE__*/ jsx_runtime_.jsx(payment_methods/* default */.Z, {});
            case "subscriptions":
                return /*#__PURE__*/ jsx_runtime_.jsx(Subscriptions, {});
            case "receipts":
                return /*#__PURE__*/ jsx_runtime_.jsx(InvoicesAndReceipts, {});
            default:
                (0,misc.unreachable)(main);
        }
    }
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Layout, {
        style: {
            padding: "0 24px 24px",
            backgroundColor: "white",
            color: "#555"
        },
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx(ConfigMenu, {
                main: main
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(Content, {
                style: {
                    padding: 24,
                    margin: 0,
                    minHeight: 280
                },
                children: body()
            })
        ]
    });
};

;// CONCATENATED MODULE: ./components/billing/consts.ts
/*
 *  This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ const MainPages = [
    "cards",
    "subscriptions",
    "receipts"
];

// EXTERNAL MODULE: ./lib/customize.ts
var lib_customize = __webpack_require__(400054);
// EXTERNAL MODULE: ./lib/with-customize.ts
var with_customize = __webpack_require__(601880);
;// CONCATENATED MODULE: ./pages/billing/[[...page]].tsx
/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 









function Preferences({ customize , pageNotFound , page  }) {
    if (pageNotFound) {
        return /*#__PURE__*/ jsx_runtime_.jsx((error_default()), {
            statusCode: 404
        });
    }
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(lib_customize/* Customize */.l, {
        value: customize,
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx(head/* default */.Z, {
                title: "Billing"
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Layout, {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(header/* default */.Z, {}),
                    /*#__PURE__*/ jsx_runtime_.jsx(ConfigLayout, {
                        page: page
                    }),
                    /*#__PURE__*/ jsx_runtime_.jsx(footer/* default */.Z, {})
                ]
            })
        ]
    });
};
async function getServerSideProps(context) {
    const { params , res  } = context;
    const { page =[]  } = params;
    // deprecated – https://github.com/sagemathinc/cocalc/issues/5739
    // see billing/layout.tsx for possible pages
    const [main] = page;
    switch(main){
        // 307: temp redirect
        case "payment-methods":
            return res.redirect(307, "./cards");
        case "invoices-and-receipts":
            return res.redirect(307, "./receipts");
    }
    if (main != null && !MainPages.includes(main)) {
        return (0,with_customize/* default */.Z)({
            context,
            props: {
                pageNotFound: true
            }
        });
    }
    return await (0,with_customize/* default */.Z)({
        context,
        props: {
            page
        }
    });
}


/***/ }),

/***/ 304298:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

module.exports = __webpack_require__(920699)


/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

"use strict";
module.exports = require("next/dist/shared/lib/router/utils/remove-trailing-slash.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");

/***/ }),

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

"use strict";
module.exports = require("react-google-recaptcha-v3");

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

/***/ 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,2952,1746,1664,7545,3734,7845,9715,2448,9066,981,5997,5409,6087,3009,5490,6952,5863,8572,5773,6879,3668], () => (__webpack_exec__(762064)));
module.exports = __webpack_exports__;

})();