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

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

// 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);
// EXTERNAL MODULE: ./components/landing/header.tsx + 2 modules
var header = __webpack_require__(113680);
// 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/auth/in-place-sign-in-or-up.tsx
var in_place_sign_in_or_up = __webpack_require__(886796);
// EXTERNAL MODULE: ./components/misc/anonymous.tsx
var anonymous = __webpack_require__(461124);
// EXTERNAL MODULE: ./components/share/loading.tsx
var share_loading = __webpack_require__(598278);
// EXTERNAL MODULE: ./lib/hooks/profile.ts
var hooks_profile = __webpack_require__(999005);
// EXTERNAL MODULE: external "next/router"
var router_ = __webpack_require__(371853);
// EXTERNAL MODULE: external "react"
var external_react_ = __webpack_require__(616689);
// EXTERNAL MODULE: ./lib/hooks/api.ts
var api = __webpack_require__(811185);
// EXTERNAL MODULE: ./components/licenses/license.tsx
var licenses_license = __webpack_require__(66717);
// EXTERNAL MODULE: ../util/dist/misc.js
var misc = __webpack_require__(477389);
;// CONCATENATED MODULE: ./components/licenses/select-license.tsx





const { Option  } = external_antd_.Select;

function SelectLicense({ onSelect , license , style , disabled  }) {
    let { result , error  } = (0,api/* default */.Z)("licenses/get-managed");
    if (error) {
        return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
            type: "error",
            message: error
        });
    }
    if (!result) {
        return /*#__PURE__*/ jsx_runtime_.jsx(share_loading/* default */.Z, {
            style: {
                fontSize: "16pt",
                margin: "auto"
            }
        });
    }
    const v = [];
    for (const x of result){
        v.push(/*#__PURE__*/ (0,jsx_runtime_.jsxs)(Option, {
            value: x.id,
            search: `${x.id} ${x.title} ${x.description} ${JSON.stringify(x.quota)}`.toLowerCase(),
            children: [
                x.title?.trim() ? `${x.title} - ` : "",
                /*#__PURE__*/ jsx_runtime_.jsx("span", {
                    style: {
                        fontFamily: "monospace"
                    },
                    children: x.id
                }),
                /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                /*#__PURE__*/ jsx_runtime_.jsx(licenses_license/* Quota */.cF, {
                    quota: x.quota
                })
            ]
        }, x.id));
    }
    return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Select, {
        style: style,
        disabled: disabled,
        showSearch: true,
        allowClear: true,
        placeholder: "Select a license",
        optionFilterProp: "children",
        value: license ? license : undefined /* no empty string so placeholder works */ ,
        onChange: onSelect,
        filterOption: (input, option)=>{
            if (!input.trim()) return true;
            return (0,misc.search_match)(option?.search ?? "", (0,misc.search_split)(input));
        },
        children: v
    });
};

// EXTERNAL MODULE: ./components/account/avatar.tsx
var avatar = __webpack_require__(23861);
// EXTERNAL MODULE: ./components/misc/A.tsx
var A = __webpack_require__(617637);
// EXTERNAL MODULE: ./lib/api/post.ts
var post = __webpack_require__(456658);
// EXTERNAL MODULE: ./lib/share/edit-url.ts
var edit_url = __webpack_require__(682620);
// EXTERNAL MODULE: ../frontend/dist/components/icon.js
var icon = __webpack_require__(807772);
// EXTERNAL MODULE: ./lib/share/util.ts
var util = __webpack_require__(262898);
;// CONCATENATED MODULE: ./components/account/name.tsx



function Name({ account_id , style  }) {
    const profile = (0,hooks_profile/* default */.Z)({
        account_id
    });
    if (profile == null) {
        return /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {});
    }
    const { first_name , last_name  } = profile;
    return /*#__PURE__*/ jsx_runtime_.jsx("span", {
        style: style,
        children: (0,util/* trunc */.RF)(`${first_name} ${last_name}`, 50)
    });
};

;// CONCATENATED MODULE: external "lodash/debounce"
const debounce_namespaceObject = require("lodash/debounce");
var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce_namespaceObject);
// EXTERNAL MODULE: ./components/misc/timestamp.tsx
var timestamp = __webpack_require__(794265);
;// CONCATENATED MODULE: ./components/account/select-users.tsx

/*
SelectUsers of this Cocalc server.

Inspired by https://ant.design/components/select/#components-select-demo-select-users
*/ 






function SelectUsers({ autoFocus , exclude , onChange  }) {
    const { 0: value , 1: setValue  } = (0,external_react_.useState)([]);
    return /*#__PURE__*/ jsx_runtime_.jsx(DebounceSelect, {
        autoFocus: autoFocus,
        exclude: new Set(exclude),
        mode: "multiple",
        value: value,
        placeholder: "Email address, name or @username",
        fetchOptions: fetchUserList,
        onChange: (newValue)=>{
            setValue(newValue);
            onChange?.(newValue.map((x)=>x.value
            ));
        },
        style: {
            width: "100%"
        }
    });
};
function DebounceSelect({ exclude , fetchOptions , debounceTimeout =800 , ...props }) {
    const { 0: fetching , 1: setFetching  } = (0,external_react_.useState)(false);
    const { 0: error , 1: setError  } = (0,external_react_.useState)("");
    const { 0: options , 1: setOptions  } = (0,external_react_.useState)([]);
    const fetchRef = (0,external_react_.useRef)(0);
    const debounceFetcher = (0,external_react_.useMemo)(()=>{
        const loadOptions = async (value)=>{
            fetchRef.current += 1;
            const fetchId = fetchRef.current;
            setError("");
            setFetching(true);
            try {
                const newOptions = await fetchOptions(value, exclude);
                if (fetchId == fetchRef.current) {
                    setOptions(newOptions);
                }
            } catch (err) {
                setError(err.message);
            } finally{
                setFetching(false);
            }
        };
        return debounce_default()(loadOptions, debounceTimeout);
    }, [
        fetchOptions,
        debounceTimeout
    ]);
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
        children: [
            error && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                type: "error",
                message: error,
                style: {
                    marginBottom: "15px"
                }
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Select, {
                labelInValue: true,
                filterOption: false,
                onSearch: debounceFetcher,
                notFoundContent: fetching ? /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Spin, {
                    size: "small"
                }) : null,
                ...props,
                options: options
            })
        ]
    });
}
async function fetchUserList(query, exclude) {
    const v = await (0,post/* default */.Z)("/accounts/search", {
        query
    });
    const list = [];
    for (const user of v){
        if (exclude?.has(user.account_id)) continue;
        list.push({
            label: /*#__PURE__*/ jsx_runtime_.jsx(Label, {
                ...user
            }),
            value: user.account_id
        });
    }
    return list;
}
function Label({ account_id , first_name , last_name , last_active , created , name , email_address_verified  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        style: {
            borderBottom: "1px solid lightgrey",
            paddingBottom: "5px"
        },
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx(avatar/* default */.Z, {
                account_id: account_id,
                size: 18,
                style: {
                    marginRight: "5px"
                },
                zIndex: 10000
            }),
            first_name,
            " ",
            last_name,
            name ? ` (@${name})` : "",
            last_active && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                children: [
                    "Last Active: ",
                    /*#__PURE__*/ jsx_runtime_.jsx(timestamp/* default */.Z, {
                        epoch: last_active,
                        dateOnly: true
                    })
                ]
            }),
            created && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                children: [
                    "Created: ",
                    /*#__PURE__*/ jsx_runtime_.jsx(timestamp/* default */.Z, {
                        epoch: created,
                        dateOnly: true
                    })
                ]
            }),
            email_address_verified && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                        name: "check",
                        style: {
                            color: "darkgreen"
                        }
                    }),
                    " Email address is verified"
                ]
            })
        ]
    });
}

// EXTERNAL MODULE: ./lib/use-customize.ts
var use_customize = __webpack_require__(1198);
// EXTERNAL MODULE: ./components/licenses/editable-license.tsx
var editable_license = __webpack_require__(537894);
;// CONCATENATED MODULE: ./components/licenses/managed.tsx

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














const renderTimestamp = (epoch)=>/*#__PURE__*/ jsx_runtime_.jsx(timestamp/* default */.Z, {
        epoch: epoch
    })
;
const quotaColumn = {
    title: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Popover, {
        title: "Quota",
        content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
            style: {
                maxWidth: "75ex"
            },
            children: "This is the license quota. If the license is active on a project, its quotas will be set to at least the values listed here."
        }),
        children: [
            "Quota",
            " "
        ]
    }),
    width: "35%",
    responsive: [
        "sm"
    ],
    render: (_, license)=>/*#__PURE__*/ jsx_runtime_.jsx(Quota, {
            ...license
        })
};
function Quota({ quota , state , upgrades  }) {
    return state != null && state != "running" ? /*#__PURE__*/ jsx_runtime_.jsx("span", {
        children: "\u2014"
    }) : /*#__PURE__*/ (0,jsx_runtime_.jsxs)("span", {
        style: {
            wordWrap: "break-word",
            wordBreak: "break-word"
        },
        children: [
            quota && /*#__PURE__*/ jsx_runtime_.jsx(licenses_license/* Quota */.cF, {
                quota: quota
            }),
            upgrades && /*#__PURE__*/ jsx_runtime_.jsx("pre", {
                children: JSON.stringify(upgrades)
            })
        ]
    });
}
function TitleDescId({ title , description , id , onChange  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        style: {
            wordWrap: "break-word",
            wordBreak: "break-word",
            color: "#333"
        },
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    fontFamily: "monospace",
                    fontSize: "9pt"
                },
                children: /*#__PURE__*/ jsx_runtime_.jsx(licenses_license/* default */.ZP, {
                    license_id: id
                })
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(editable_license/* EditableTitle */.M, {
                license_id: id,
                title: title,
                onChange: onChange
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(editable_license/* EditableDescription */.q, {
                license_id: id,
                description: description,
                onChange: onChange
            })
        ]
    });
}
function Managers({ managers , id , onChange  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    maxHeight: "65px",
                    overflowY: "auto"
                },
                children: managers.map((account_id)=>/*#__PURE__*/ jsx_runtime_.jsx(avatar/* default */.Z, {
                        style: {
                            margin: "0 5px 5px 0"
                        },
                        account_id: account_id,
                        size: 24,
                        extra: /*#__PURE__*/ jsx_runtime_.jsx(RemoveManager, {
                            license_id: id,
                            managers: managers,
                            account_id: account_id,
                            onChange: onChange
                        })
                    }, account_id)
                )
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(AddManagers, {
                license_id: id,
                managers: managers,
                onChange: onChange
            })
        ]
    });
}
function RunLimit({ run_limit  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {
        children: run_limit
    });
}
function LastUsed({ last_used  }) {
    return renderTimestamp(last_used);
}
function Created({ created  }) {
    return renderTimestamp(created);
}
function columns(onChange) {
    return [
        {
            responsive: [
                "xs"
            ],
            title: "Managed Licenses",
            render: (_, license)=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                    children: [
                        /*#__PURE__*/ jsx_runtime_.jsx(TitleDescId, {
                            ...license,
                            onChange: onChange
                        }),
                        /*#__PURE__*/ jsx_runtime_.jsx("div", {
                            children: /*#__PURE__*/ jsx_runtime_.jsx(licenses_license/* DateRange */.C0, {
                                ...license
                            })
                        }),
                        " ",
                        "Run Limit: ",
                        /*#__PURE__*/ jsx_runtime_.jsx(RunLimit, {
                            ...license
                        }),
                        /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                            children: [
                                "Quota: ",
                                /*#__PURE__*/ jsx_runtime_.jsx(Quota, {
                                    ...license
                                })
                            ]
                        }),
                        "Last Used: ",
                        /*#__PURE__*/ jsx_runtime_.jsx(LastUsed, {
                            ...license
                        }),
                        /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                        "Created: ",
                        /*#__PURE__*/ jsx_runtime_.jsx(Created, {
                            ...license
                        }),
                        /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                            style: {
                                border: "1px solid lightgrey",
                                padding: "5px 15px"
                            },
                            children: [
                                "Managers ",
                                /*#__PURE__*/ jsx_runtime_.jsx(Managers, {
                                    ...license,
                                    onChange: onChange
                                })
                            ]
                        })
                    ]
                })
        },
        {
            responsive: [
                "sm"
            ],
            title: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Popover, {
                placement: "top",
                title: "Id, Title and Description of the License",
                content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                    style: {
                        maxWidth: "75ex"
                    },
                    children: "The first line is the id of the license, which anybody can enter in various places to upgrade projects or courses. The title and description of the license help you keep track of what the license is for, and you can edit both fields here as well by clicking on them."
                }),
                children: "License"
            }),
            key: "title",
            width: "40%",
            sorter: {
                compare: (a, b)=>(0,misc.cmp)(a.title, b.title)
            },
            render: (_, license)=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                    children: [
                        /*#__PURE__*/ jsx_runtime_.jsx(TitleDescId, {
                            ...license,
                            onChange: onChange
                        }),
                        /*#__PURE__*/ jsx_runtime_.jsx("div", {
                            children: /*#__PURE__*/ jsx_runtime_.jsx(licenses_license/* DateRange */.C0, {
                                ...license
                            })
                        })
                    ]
                })
        },
        {
            responsive: [
                "sm"
            ],
            width: "15%",
            title: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Popover, {
                title: "Managers",
                content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                    style: {
                        maxWidth: "75ex"
                    },
                    children: "These are the managers of this license. They can see extra information about the license, the license is included in any dropdown where they can select a license, and they can add or remove other license managers. You are a manager of all licenses listed here."
                }),
                children: "Managers"
            }),
            key: "managers",
            render: (_, license)=>/*#__PURE__*/ jsx_runtime_.jsx(Managers, {
                    ...license,
                    onChange: onChange
                })
        },
        {
            responsive: [
                "sm"
            ],
            title: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Popover, {
                placement: "top",
                title: "Run Limit",
                content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                    style: {
                        maxWidth: "75ex"
                    },
                    children: "The maximum number of simultaneous running projects that this license can upgrade. You can apply the license to any number of projects, but it only impacts this many projects at once."
                }),
                children: "Run Limit"
            }),
            align: "center",
            render: (_, license)=>/*#__PURE__*/ jsx_runtime_.jsx(RunLimit, {
                    ...license
                })
            ,
            sorter: {
                compare: (a, b)=>(0,misc.cmp)(a.run_limit, b.run_limit)
            }
        },
        quotaColumn,
        {
            responsive: [
                "sm"
            ],
            title: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Popover, {
                placement: "top",
                title: "When License was Last Used",
                content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                    style: {
                        maxWidth: "75ex"
                    },
                    children: "This is when this license was last used to upgrade a project when the project was starting. It's the point in time when the project started."
                }),
                children: [
                    "Last Used",
                    " "
                ]
            }),
            render: (_, license)=>/*#__PURE__*/ jsx_runtime_.jsx(LastUsed, {
                    ...license
                })
            ,
            sorter: {
                compare: (a, b)=>(0,misc.cmp)(a.last_used, b.last_used)
            }
        },
        /*   {
      responsive: ["sm"],
      title: (
        <Popover
          placement="top"
          title="When License Becomes Activate"
          content={
            <div style={{ maxWidth: "75ex" }}>
              This is when the license becomes active. In can be in the future,
              in which case the license will be valid and useful in the future,
              but not right now.
            </div>
          }
        >
          Activates{" "}
        </Popover>
      ),
      render: (_, license) => <Activates {...license} />,
      sorter: { compare: (a, b) => cmp(a.activates, b.activates) },
    },
    {
      responsive: ["sm"],
      title: (
        <Popover
          placement="top"
          title="When License Expires"
          content={
            <div style={{ maxWidth: "75ex" }}>
              This is when the license expires. Unless there is a subscription
              that renews it, after this point in time the license will stop
              upgrading projects.
            </div>
          }
        >
          Expires{" "}
        </Popover>
      ),
      render: (_, license) => <Expires {...license} />,
      sorter: { compare: (a, b) => cmp(a.expires, b.expires) },
    },*/ {
            responsive: [
                "sm"
            ],
            title: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Popover, {
                placement: "top",
                title: "When License was Created",
                content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                    style: {
                        maxWidth: "75ex"
                    },
                    children: "This is when the license was created."
                }),
                children: [
                    "Created",
                    " "
                ]
            }),
            render: (_, license)=>/*#__PURE__*/ jsx_runtime_.jsx(Created, {
                    ...license
                })
            ,
            sorter: {
                compare: (a, b)=>(0,misc.cmp)(a.created, b.created)
            }
        }, 
    ];
}
function ManagedLicenses() {
    let { result , error , call  } = (0,api/* default */.Z)("licenses/get-managed");
    const { 0: search , 1: setSearch  } = (0,external_react_.useState)("");
    const { 0: showExpired , 1: setShowExpired  } = (0,external_react_.useState)(false);
    const numExpired = (0,external_react_.useMemo)(()=>{
        if (!result) return 0;
        let n = 0;
        const t = new Date().valueOf();
        for (const x of result){
            if (x.expires && x.expires <= t) {
                n += 1;
            }
        }
        return n;
    }, [
        result
    ]);
    if (error) {
        return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
            type: "error",
            message: error
        });
    }
    if (!result) {
        return /*#__PURE__*/ jsx_runtime_.jsx(share_loading/* default */.Z, {
            style: {
                fontSize: "16pt",
                margin: "auto"
            }
        });
    }
    if (search) {
        result = doSearch(result, search);
    }
    if (!showExpired) {
        // filter out anything that is expired
        result = removeExpired(result);
    }
    function onChange() {
        call();
    }
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        style: {
            width: "100%",
            overflowX: "auto",
            minHeight: "50vh"
        },
        children: [
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("h3", {
                children: [
                    "Licenses that you Manage (",
                    result.length,
                    ")"
                ]
            }),
            "These are the licenses that you have purchased or been added to manage. You can add other people as managers of any of these licenses, if they need to be able to use these licenses to upgrade projects. You can also",
            " ",
            /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                href: "/billing/subscriptions",
                children: "manage your purchased subscriptions"
            }),
            " ",
            "and browse ",
            /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                href: "/billing/receipts",
                children: "your receipts and invoices"
            }),
            ".",
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                style: {
                    margin: "15px 0"
                },
                children: [
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Checkbox, {
                        disabled: numExpired == 0,
                        style: {
                            float: "right"
                        },
                        checked: showExpired,
                        onChange: (e)=>setShowExpired(e.target.checked)
                        ,
                        children: [
                            "Show Expired (",
                            numExpired,
                            ")"
                        ]
                    }),
                    /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Input.Search, {
                        placeholder: "Search...",
                        allowClear: true,
                        onChange: (e)=>setSearch(e.target.value)
                        ,
                        style: {
                            width: "50ex",
                            maxWidth: "100%"
                        }
                    })
                ]
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Table, {
                columns: columns(onChange),
                dataSource: result,
                rowKey: "id",
                style: {
                    marginTop: "15px"
                },
                pagination: {
                    hideOnSinglePage: true,
                    pageSize: 100
                }
            })
        ]
    });
};
function doSearch(data, search) {
    const v = (0,misc.search_split)(search.toLowerCase().trim());
    const w = [];
    for (const x of data){
        if (x["search"] == null) {
            x["search"] = `${x["title"] ?? ""} ${x["description"] ?? ""} ${x["id"]} ${x["info"]?.purchased?.subscription}`.toLowerCase();
        }
        if ((0,misc.search_match)(x["search"], v)) {
            w.push(x);
        }
    }
    return w;
}
function removeExpired(data) {
    const data1 = [];
    const now = new Date().valueOf();
    for (const x of data){
        if (!(x.expires != null && x.expires <= now)) {
            data1.push(x);
        }
    }
    return data1;
}
function AddManagers({ license_id , managers , onChange  }) {
    const { 0: adding , 1: setAdding  } = (0,external_react_.useState)(false);
    const { 0: accountIds , 1: setAccountIds  } = (0,external_react_.useState)([]);
    const { 0: error , 1: setError  } = (0,external_react_.useState)("");
    const { account  } = (0,use_customize/* default */.Z)();
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        children: [
            adding && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Button, {
                size: "small",
                style: {
                    float: "right"
                },
                onClick: ()=>{
                    setAdding(false);
                    setError("");
                    setAccountIds([]);
                },
                children: "Cancel"
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Button, {
                disabled: adding,
                style: {
                    marginTop: "5px"
                },
                size: "small",
                onClick: ()=>{
                    setAdding(true);
                    setAccountIds([]);
                    setError("");
                },
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                        name: "plus-circle"
                    }),
                    " Add"
                ]
            }),
            adding && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                style: {
                    width: "300px",
                    marginTop: "5px"
                },
                children: [
                    error && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                        type: "error",
                        message: error
                    }),
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Button, {
                        disabled: accountIds.length == 0,
                        onClick: async ()=>{
                            setError("");
                            const query = {
                                manager_site_licenses: {
                                    id: license_id,
                                    managers: managers.concat(accountIds)
                                }
                            };
                            try {
                                await (0,post/* default */.Z)("/user-query", {
                                    query
                                });
                                setAdding(false);
                                onChange?.();
                            } catch (err) {
                                setError(err.message);
                            }
                        },
                        style: {
                            marginBottom: "5px",
                            width: "100%"
                        },
                        type: "primary",
                        children: [
                            /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                                name: "check"
                            }),
                            " Add ",
                            accountIds.length,
                            " ",
                            (0,misc.plural)(accountIds.length, "selected user")
                        ]
                    }),
                    /*#__PURE__*/ jsx_runtime_.jsx(SelectUsers, {
                        autoFocus: true,
                        onChange: setAccountIds,
                        exclude: managers.concat(account?.account_id ? [
                            account.account_id
                        ] : [])
                    })
                ]
            })
        ]
    });
}
function RemoveManager({ license_id , managers , account_id , onChange  }) {
    const { 0: error , 1: setError  } = (0,external_react_.useState)("");
    const { account  } = (0,use_customize/* default */.Z)();
    return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Popconfirm, {
        zIndex: 20000 /* compare with user search */ ,
        title: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
            children: [
                account?.account_id == account_id ? /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
                    children: [
                        "Remove ",
                        /*#__PURE__*/ jsx_runtime_.jsx("b", {
                            children: "yourself"
                        }),
                        " as a manager of this license?"
                    ]
                }) : /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
                    children: [
                        "Remove manager",
                        " ",
                        /*#__PURE__*/ (0,jsx_runtime_.jsxs)("b", {
                            children: [
                                /*#__PURE__*/ jsx_runtime_.jsx(Name, {
                                    account_id: account_id
                                }),
                                "?"
                            ]
                        }),
                        /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                        /*#__PURE__*/ jsx_runtime_.jsx(Name, {
                            account_id: account_id
                        }),
                        " will no longer see this license listed under licenses they manage."
                    ]
                }),
                /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                " The license will ",
                /*#__PURE__*/ jsx_runtime_.jsx("i", {
                    children: "not"
                }),
                " be automatically removed from any projects."
            ]
        }),
        onConfirm: async ()=>{
            setError("");
            const query = {
                manager_site_licenses: {
                    id: license_id,
                    managers: managers.filter((x)=>x != account_id
                    )
                }
            };
            try {
                await (0,post/* default */.Z)("/user-query", {
                    query
                });
                onChange?.();
            } catch (err) {
                setError(err.message);
            }
        },
        okText: "Remove",
        cancelText: "Cancel",
        children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
            children: [
                /*#__PURE__*/ jsx_runtime_.jsx("a", {
                    children: "Remove as Manager..."
                }),
                error && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                    type: "error",
                    message: "Error Removing Manager",
                    description: error
                })
            ]
        })
    });
}

// EXTERNAL MODULE: ./components/misc/copyable.tsx
var copyable = __webpack_require__(667105);
// EXTERNAL MODULE: ../frontend/dist/components/r_join.js
var r_join = __webpack_require__(115108);
;// CONCATENATED MODULE: ./components/licenses/licensed-projects.tsx













function Title({ title , project_id  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx("span", {
        style: {
            wordWrap: "break-word",
            wordBreak: "break-word"
        },
        children: /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
            href: (0,edit_url/* default */.Z)({
                project_id,
                type: "collaborator"
            }),
            external: true,
            children: title
        })
    });
}
function Licenses({ site_license , project_id  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx("div", {
        style: {
            wordWrap: "break-word",
            wordBreak: "break-word"
        },
        children: (0,r_join.r_join)((0,misc.keys)(site_license).map((license_id)=>/*#__PURE__*/ jsx_runtime_.jsx(licenses_license/* default */.ZP, {
                license_id: license_id,
                contrib: {
                    [project_id]: site_license[license_id]
                }
            }, license_id)
        ), /*#__PURE__*/ jsx_runtime_.jsx("br", {}))
    });
}
function LastEdited({ last_edited  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx(timestamp/* default */.Z, {
        epoch: last_edited
    });
}
function IsHidden({ hidden  }) {
    if (hidden) {
        return /*#__PURE__*/ jsx_runtime_.jsx("div", {
            style: {
                textAlign: "center"
            },
            children: /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                name: "check"
            })
        });
    } else {
        return null;
    }
}
const licensed_projects_columns = [
    {
        responsive: [
            "xs"
        ],
        title: "Invoices and Receipts",
        render: (_, project)=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                children: [
                    "Project: ",
                    /*#__PURE__*/ jsx_runtime_.jsx(Title, {
                        ...project
                    }),
                    /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                        children: [
                            "Last Edited: ",
                            /*#__PURE__*/ jsx_runtime_.jsx(LastEdited, {
                                ...project
                            })
                        ]
                    }),
                    "Licenses:",
                    /*#__PURE__*/ jsx_runtime_.jsx("div", {
                        style: {
                            margin: "5px 0 0 30px",
                            border: "1px solid #eee",
                            padding: "5px",
                            borderRadius: "5px"
                        },
                        children: /*#__PURE__*/ jsx_runtime_.jsx(Licenses, {
                            ...project
                        })
                    })
                ]
            })
    },
    {
        responsive: [
            "sm"
        ],
        title: "Project",
        width: "30%",
        render: (_, project)=>/*#__PURE__*/ jsx_runtime_.jsx(Title, {
                ...project
            })
        ,
        sorter: {
            compare: (a, b)=>(0,misc.cmp)(a.title, b.title)
        }
    },
    {
        responsive: [
            "sm"
        ],
        title: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Popover, {
            placement: "bottom",
            title: "Licenses",
            content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    maxWidth: "75ex"
                },
                children: "These licenses are all applied to the project. They may or may not contribute any upgrades, depending on how the license is being used across all projects."
            }),
            children: "Licenses"
        }),
        render: (_, project)=>/*#__PURE__*/ jsx_runtime_.jsx(Licenses, {
                ...project
            })
        ,
        sorter: {
            compare: (a, b)=>(0,misc.cmp)(`${(0,misc.keys)(a.site_licenses)}`, `${(0,misc.keys)(b.site_licenses)}`)
        }
    },
    {
        responsive: [
            "sm"
        ],
        title: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Popover, {
            placement: "bottom",
            title: "Last Edited",
            content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    maxWidth: "75ex"
                },
                children: "When the project was last edited."
            }),
            children: "Project Last Edited"
        }),
        render: (_, project)=>/*#__PURE__*/ jsx_runtime_.jsx(LastEdited, {
                ...project
            })
        ,
        sorter: {
            compare: (a, b)=>(0,misc.cmp)(a.last_edited, b.last_edited)
        }
    },
    {
        responsive: [
            "sm"
        ],
        title: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Popover, {
            placement: "bottom",
            title: "Project Hidden",
            content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    maxWidth: "75ex"
                },
                children: 'Whether or not the project is "hidden" from you, so it doesn\'t appear in your default list of projects. Typically all student projects in a course you teach are hidden. There is a checkmark below for hidden projects.'
            }),
            children: "Project Hidden"
        }),
        width: "10%",
        render: (_, project)=>/*#__PURE__*/ jsx_runtime_.jsx(IsHidden, {
                ...project
            })
        ,
        sorter: {
            compare: (a, b)=>(0,misc.cmp)(a.hidden, b.hidden)
        }
    }, 
];
function LicensedProjects() {
    const { 0: search , 1: setSearch  } = (0,external_react_.useState)("");
    let { result , error  } = (0,api/* default */.Z)("licenses/get-projects");
    if (error) {
        return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
            type: "error",
            message: error
        });
    }
    if (!result) {
        return /*#__PURE__*/ jsx_runtime_.jsx(share_loading/* default */.Z, {});
    }
    if (search) {
        result = licensed_projects_doSearch(result, search);
    }
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("h3", {
                children: [
                    "Your Licensed Projects (",
                    result.length,
                    ")"
                ]
            }),
            "These are the licensed projects that you are a collaborator on. You might not be a manager of some of the licenses listed below. If you're teaching a course, the student projects are likely hidden from your normal project list, but are included below.",
            /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    margin: "15px 0"
                },
                children: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Input.Search, {
                    placeholder: "Search...",
                    allowClear: true,
                    onChange: (e)=>setSearch(e.target.value)
                    ,
                    style: {
                        width: "40ex"
                    }
                })
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Table, {
                columns: licensed_projects_columns,
                dataSource: result,
                rowKey: "project_id",
                pagination: {
                    hideOnSinglePage: true,
                    pageSize: 100
                }
            })
        ]
    });
};
function licensed_projects_doSearch(data, search) {
    const v = (0,misc.search_split)(search.toLowerCase().trim());
    const w = [];
    for (const x of data){
        if (x["search"] == null) {
            x["search"] = `${x["title"]}${JSON.stringify((0,misc.keys)(x["site_license"]))}`.toLowerCase();
        }
        if ((0,misc.search_match)(x["search"], v)) {
            w.push(x);
        }
    }
    return w;
}

;// CONCATENATED MODULE: ./components/licenses/how-used.tsx
















function TitleId({ title , project_id , collaborators , account_id , label  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        style: {
            wordWrap: "break-word",
            wordBreak: "break-word"
        },
        children: [
            collaborators.includes(account_id) ? /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                href: (0,edit_url/* default */.Z)({
                    project_id,
                    type: "collaborator"
                }),
                external: true,
                children: title
            }) : title,
            label && /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
                children: [
                    /*#__PURE__*/ jsx_runtime_.jsx("br", {}),
                    "Project Id:"
                ]
            }),
            /*#__PURE__*/ jsx_runtime_.jsx(copyable/* default */.Z, {
                value: project_id,
                size: "small"
            })
        ]
    });
}
function Collaborators({ collaborators  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {
        children: collaborators.map((account_id)=>/*#__PURE__*/ jsx_runtime_.jsx(avatar/* default */.Z, {
                account_id: account_id,
                size: 24,
                style: {
                    marginRight: "2.5px"
                }
            }, account_id)
        )
    });
}
function State({ state  }) {
    return /*#__PURE__*/ jsx_runtime_.jsx(jsx_runtime_.Fragment, {
        children: (0,misc.capitalize)(state)
    });
}
function HowLicenseUsed({ account_id  }) {
    const router = (0,router_.useRouter)();
    const { 0: license , 1: setLicense  } = (0,external_react_.useState)(`${router.query.license_id ?? ""}`);
    const { 0: search , 1: setSearch  } = (0,external_react_.useState)("");
    const { 0: error , 1: setError  } = (0,external_react_.useState)("");
    let { 0: projects , 1: setProjects  } = (0,external_react_.useState)([]);
    const { 0: loading , 1: setLoading  } = (0,external_react_.useState)(false);
    const { 0: excludeMe , 1: setExcludeMe  } = (0,external_react_.useState)(false);
    const columns = (0,external_react_.useMemo)(()=>{
        return [
            {
                responsive: [
                    "xs"
                ],
                render: (_, project)=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                        children: [
                            /*#__PURE__*/ jsx_runtime_.jsx(TitleId, {
                                ...project,
                                account_id: account_id,
                                label: true
                            }),
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                                children: [
                                    "Last Edited: ",
                                    /*#__PURE__*/ jsx_runtime_.jsx(LastEdited, {
                                        ...project
                                    })
                                ]
                            }),
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                                children: [
                                    "State: ",
                                    /*#__PURE__*/ jsx_runtime_.jsx(State, {
                                        ...project
                                    })
                                ]
                            }),
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                                children: [
                                    "Collaborators: ",
                                    /*#__PURE__*/ jsx_runtime_.jsx(Collaborators, {
                                        ...project
                                    })
                                ]
                            }),
                            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                                children: [
                                    "Quota in use: ",
                                    /*#__PURE__*/ jsx_runtime_.jsx(Quota, {
                                        ...project
                                    })
                                ]
                            })
                        ]
                    })
            },
            {
                responsive: [
                    "sm"
                ],
                title: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Popover, {
                    placement: "bottom",
                    title: "Project",
                    content: /*#__PURE__*/ jsx_runtime_.jsx("div", {
                        style: {
                            maxWidth: "75ex"
                        },
                        children: "This is the title and id of the project. If you are a collaborator on this project, then you can click the title to open the project."
                    }),
                    children: "Project"
                }),
                width: "30%",
                render: (_, project)=>/*#__PURE__*/ jsx_runtime_.jsx(TitleId, {
                        ...project,
                        account_id: account_id
                    })
                ,
                sorter: {
                    compare: (a, b)=>(0,misc.cmp)(a.title, b.title)
                }
            },
            {
                responsive: [
                    "sm"
                ],
                title: "Last Edited",
                render: (_, project)=>/*#__PURE__*/ jsx_runtime_.jsx(LastEdited, {
                        ...project
                    })
                ,
                sorter: {
                    compare: (a, b)=>(0,misc.cmp)(a.last_edited, b.last_edited)
                }
            },
            {
                responsive: [
                    "sm"
                ],
                title: /*#__PURE__*/ (0,jsx_runtime_.jsxs)(external_antd_.Popover, {
                    title: "Collaborators",
                    content: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
                        style: {
                            maxWidth: "75ex"
                        },
                        children: [
                            'These are the collaborators on this project. You are not necessarily included in this list, since this license can be applied to any project by somebody who knows the license code. Click the "Exclude me" checkbox to see only projects that you are ',
                            /*#__PURE__*/ jsx_runtime_.jsx("b", {
                                children: "not"
                            }),
                            " a collaborator on."
                        ]
                    }),
                    children: [
                        "Collaborators",
                        /*#__PURE__*/ jsx_runtime_.jsx("div", {
                            style: {
                                fontWeight: 300
                            },
                            children: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Checkbox, {
                                onChange: (e)=>setExcludeMe(e.target.checked)
                                ,
                                checked: excludeMe,
                                children: "Exclude me"
                            })
                        })
                    ]
                }),
                render: (_, project)=>/*#__PURE__*/ jsx_runtime_.jsx(Collaborators, {
                        ...project
                    })
            },
            {
                responsive: [
                    "sm"
                ],
                title: "State",
                dataIndex: "state",
                key: "state",
                sorter: {
                    compare: (a, b)=>(0,misc.cmp)(a.state, b.state)
                },
                render: (_, project)=>/*#__PURE__*/ jsx_runtime_.jsx(State, {
                        ...project
                    })
            },
            quotaColumn, 
        ];
    }, [
        account_id,
        excludeMe
    ]);
    async function load(license_id) {
        setLicense(license_id);
        setError("");
        if (license_id) {
            setLoading(true);
            setProjects([]);
            try {
                setProjects(await (0,post/* default */.Z)("/licenses/get-projects-with-license", {
                    license_id
                }));
            } catch (err) {
                setError(err.message);
            } finally{
                setLoading(false);
            }
        }
    }
    (0,external_react_.useEffect)(()=>{
        // initial license load (e.g., from query param)
        if (license) {
            load(license);
        }
    }, []);
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        style: {
            width: "100%",
            overflowX: "auto",
            minHeight: "50vh"
        },
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx("h3", {
                children: "How a License You Manage is Being Used"
            }),
            "Select a license you manage to see how it is being used. You can see",
            " ",
            /*#__PURE__*/ jsx_runtime_.jsx("i", {
                children: "all"
            }),
            " projects that have this license applied to them (even if you are not a collaborator on them!), remove licenses from projects, and view analytics about how the license has been used over time to better inform your decision making.",
            /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    margin: "15px 0",
                    width: "100%",
                    textAlign: "center"
                },
                children: /*#__PURE__*/ jsx_runtime_.jsx(SelectLicense, {
                    disabled: loading,
                    onSelect: (license_id)=>{
                        router.push({
                            pathname: router.asPath.split("?")[0],
                            query: {
                                license_id
                            }
                        });
                        load(license_id);
                    },
                    license: license,
                    style: {
                        width: "100%",
                        maxWidth: "90ex"
                    }
                })
            }),
            license && error && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Alert, {
                type: "error",
                message: error
            }),
            license && loading && /*#__PURE__*/ jsx_runtime_.jsx(share_loading/* default */.Z, {
                style: {
                    fontSize: "16pt",
                    margin: "auto"
                }
            }),
            /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    border: "1px solid lightgrey",
                    borderRadius: "5px",
                    padding: "15px",
                    backgroundColor: "#fafafa",
                    width: "100%",
                    maxWidth: "90ex",
                    margin: "auto"
                },
                children: license ? /*#__PURE__*/ jsx_runtime_.jsx(licenses_license/* Details */.PO, {
                    license_id: license
                }) : /*#__PURE__*/ jsx_runtime_.jsx("div", {
                    style: {
                        textAlign: "center",
                        fontSize: "13pt"
                    },
                    children: "Select a license above."
                })
            }),
            license && !loading && projects.length > 1 && /*#__PURE__*/ jsx_runtime_.jsx("div", {
                style: {
                    margin: "15px 0",
                    maxWidth: "50ex"
                },
                children: /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Input.Search, {
                    placeholder: "Search project titles...",
                    allowClear: true,
                    onChange: (e)=>setSearch(e.target.value)
                    ,
                    style: {
                        width: "100%"
                    }
                })
            }),
            license && !loading && /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Table, {
                columns: columns,
                dataSource: how_used_doSearch(projects, search, excludeMe, account_id),
                rowKey: "project_id",
                style: {
                    marginTop: "15px"
                },
                pagination: {
                    hideOnSinglePage: true,
                    pageSize: 100
                }
            })
        ]
    });
};
function how_used_doSearch(data, search, excludeMe, account_id) {
    const v = (0,misc.search_split)(search.toLowerCase().trim());
    const w = [];
    for (const x of data){
        if (excludeMe && x["collaborators"]?.includes(account_id)) continue;
        if (x["search"] == null) {
            x["search"] = `${x["title"] ?? ""} ${x["id"]}`.toLowerCase();
        }
        if ((0,misc.search_match)(x["search"], v)) {
            w.push(x);
        }
    }
    return w;
}

;// CONCATENATED MODULE: ./components/licenses/menu.tsx




function ConfigMenu({ main  }) {
    const router = (0,router_.useRouter)();
    const items = [
        {
            label: /*#__PURE__*/ jsx_runtime_.jsx("b", {
                style: {
                    color: "#666"
                },
                children: "Licenses"
            }),
            key: ""
        },
        {
            label: "Manage",
            key: "managed",
            icon: /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                name: "key"
            })
        },
        {
            label: "Projects",
            key: "projects",
            icon: /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                name: "edit"
            })
        },
        {
            label: "How Used",
            key: "how-used",
            icon: /*#__PURE__*/ jsx_runtime_.jsx(icon.Icon, {
                name: "key"
            })
        }, 
    ];
    return /*#__PURE__*/ jsx_runtime_.jsx(external_antd_.Menu, {
        mode: "horizontal",
        selectedKeys: [
            main
        ],
        style: {
            height: "100%"
        },
        onSelect: (e)=>{
            router.push(`/licenses/${e.keyPath[0]}`, undefined, {
                scroll: false
            });
        },
        items: items
    });
};

;// CONCATENATED MODULE: ./components/licenses/overview.tsx



function Overview() {
    const { isCommercial  } = (0,use_customize/* default */.Z)();
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("p", {
                children: [
                    "You can",
                    " ",
                    isCommercial && /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
                        children: [
                            /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                                href: "/store/site-license",
                                children: "buy a site license"
                            }),
                            ","
                        ]
                    }),
                    " ",
                    "see the ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/licenses/managed",
                        children: "licenses you manage"
                    }),
                    ", browse the",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/licenses/projects",
                        children: "licensed projects you collaborate on"
                    }),
                    ", and see how",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/licenses/how-used",
                        children: "a specific site licenses is being used"
                    }),
                    ".",
                    " "
                ]
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("p", {
                children: [
                    "You can also",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/billing/subscriptions",
                        children: "manage your purchased subscriptions"
                    }),
                    " ",
                    "and browse ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "/billing/receipts",
                        children: "your receipts and invoices"
                    }),
                    "."
                ]
            }),
            /*#__PURE__*/ (0,jsx_runtime_.jsxs)("p", {
                children: [
                    "Read",
                    " ",
                    /*#__PURE__*/ jsx_runtime_.jsx(A/* default */.Z, {
                        href: "https://doc.cocalc.com/licenses.html",
                        children: "the license documentation"
                    }),
                    "."
                ]
            })
        ]
    });
};

;// CONCATENATED MODULE: ./components/licenses/layout.tsx












const { Content  } = external_antd_.Layout;
function ConfigLayout({ page  }) {
    const router = (0,router_.useRouter)();
    const profile = (0,hooks_profile/* default */.Z)({
        noCache: true
    });
    if (!profile) {
        return /*#__PURE__*/ jsx_runtime_.jsx(share_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, {});
    }
    const [main] = page;
    function body() {
        switch(main){
            case "projects":
                return /*#__PURE__*/ jsx_runtime_.jsx(LicensedProjects, {});
            case "managed":
                return /*#__PURE__*/ jsx_runtime_.jsx(ManagedLicenses, {});
            case "how-used":
                return /*#__PURE__*/ jsx_runtime_.jsx(HowLicenseUsed, {
                    account_id: account_id
                });
        }
        return /*#__PURE__*/ jsx_runtime_.jsx(Overview, {});
    }
    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()
            })
        ]
    });
};

// 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/licenses/[[...page]].tsx








function Preferences({ customize , page  }) {
    return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(lib_customize/* Customize */.l, {
        value: customize,
        children: [
            /*#__PURE__*/ jsx_runtime_.jsx(head/* default */.Z, {
                title: "Licenses"
            }),
            /*#__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) {
    let { page  } = context.params;
    if (page == null) {
        page = [];
    }
    return await (0,with_customize/* default */.Z)({
        context,
        props: {
            page
        }
    });
}


/***/ }),

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

module.exports = require("antd");

/***/ }),

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

module.exports = require("awaiting");

/***/ }),

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

module.exports = require("cookies");

/***/ }),

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

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

/***/ }),

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

/***/ }),

/***/ 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,9505,1746,1664,7545,3734,7845,9715,2448,1107,7637,9521,5114,8278,3009,2353,81,3144,6796,2620,2058,1839], () => (__webpack_exec__(435053)));
module.exports = __webpack_exports__;

})();