"use strict";
exports.id = 4158;
exports.ids = [4158];
exports.modules = {

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

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "d": () => (/* binding */ MAX_WIDTH),
/* harmony export */   "r": () => (/* binding */ SHARE_MAX_WIDTH)
/* harmony export */ });
/*
Constants and other configuration that impact the overall
look of all of the pages.
*/ const MAX_WIDTH = "900px";
const SHARE_MAX_WIDTH = "1100px";


/***/ }),

/***/ 612134:
/***/ ((__unused_webpack_module, exports) => {


/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LICENSE_MIN_PRICE = exports.ONE_MONTH_MS = exports.AVG_YEAR_DAYS = exports.AVG_MONTH_DAYS = exports.ONE_DAY_MS = void 0;
exports.ONE_DAY_MS = 24 * 60 * 60 * 1000;
exports.AVG_MONTH_DAYS = 30.5;
exports.AVG_YEAR_DAYS = 12 * exports.AVG_MONTH_DAYS;
exports.ONE_MONTH_MS = exports.AVG_MONTH_DAYS * exports.ONE_DAY_MS;
// throughout the UI, we show this price as the minimum (per month)
exports.LICENSE_MIN_PRICE = "less than $4/month";
//# sourceMappingURL=billing.js.map

/***/ }),

/***/ 451349:
/***/ ((__unused_webpack_module, exports) => {


/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isDedicatedDisk = exports.DISK_NAMES = exports.DedicatedDiskSpeedNames = void 0;
exports.DedicatedDiskSpeedNames = ["standard", "balanced", "ssd"];
exports.DISK_NAMES = {
    standard: "slow",
    balanced: "medium",
    ssd: "fast",
};
function isDedicatedDisk(d) {
    return (d != null &&
        typeof d.size_gb === "number" &&
        ["ssd", "standard", "balanced"].includes(d.type));
}
exports.isDedicatedDisk = isDedicatedDisk;
//# sourceMappingURL=dedicated.js.map

/***/ }),

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


/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PRICES = exports.DEFAULT_DEDICATED_VM_MACHINE = exports.getDedicatedDiskKey = exports.DEFAULT_DEDICATED_DISK_SPEED = exports.DEDICATED_DISK_SPEEDS = exports.DEDICATED_DISK_SIZES = exports.DEFAULT_DEDICATED_DISK_SIZE = exports.DEDICATED_DISK_SIZE_INCREMENT = exports.MAX_DEDICATED_DISK_SIZE = exports.MIN_DEDICATED_DISK_SIZE = exports.VMS = void 0;
const billing_1 = __webpack_require__(612134);
const dedicated_1 = __webpack_require__(451349);
// derive price to charge per day from the base monthly price
function rawPrice2Retail(p, discount = false) {
    // factor of 2 and an average month
    // discount factor: for VMs, we pass it on a little bit
    const df = discount ? 90 / 100 : 1;
    return (2 * p * df) / billing_1.AVG_MONTH_DAYS;
}
// the "per core" unit of memory you get for n2 machine families
function deriveMemBase(size) {
    switch (size) {
        case "standard":
            return 4;
        case "highmem":
            return 8;
        default:
            throw new Error(`deriveMemBase size "${size}" unknown`);
    }
}
function deriveVMSpecs(spec) {
    const [family, size, cpu_str] = spec.split("-");
    if (family != "n2")
        throw new Error(`machine families beside "n2" are not supported -- implement it!`);
    const cpu = parseInt(cpu_str);
    if (typeof cpu !== "number" || cpu <= 0)
        throw new Error(`core must be 2, 4, 8, ...`);
    const mem_base = deriveMemBase(size);
    const mem = cpu * mem_base;
    return { family, mem, cpu };
}
// string is like n2-standard-2 or n2-highmem-4
function deriveQuotas({ mem, cpu }) {
    return {
        mem: mem - 2,
        cpu: cpu, // we can safely give all cores to the project
    };
}
// calculate the price proportional to cpu and memory
function getDedicatedVMPrice({ mem, cpu, family }) {
    switch (family) {
        case "n2":
            // https://cloud.google.com/compute/vm-instance-pricing#general-purpose_machine_type_family
            // N2 machine types: us-east1 and monthly on-demand
            // ATTN: that's with 20% usage discount – we factor it out and discount on our own
            const cpu_montly = 18.46 / 0.8;
            const mem_montly = 2.47 / 0.8;
            const gcp_price = cpu * cpu_montly + mem * mem_montly;
            return rawPrice2Retail(gcp_price, true);
        default:
            throw new Error(`family ${family} not supported`);
    }
}
// ATTN: chagnes here have implications for the stripe product ID
// only append values, do not insert them in the middle or the beginning!
const VM_MEM_SIZES = ["standard", "highmem"];
// this is used below to avoid wrong values and easier adjustments
function getSpecAndQuota({ family, memSize, cpus, }) {
    const spec = `${family}-${memSize}-${cpus}`;
    const midx = VM_MEM_SIZES.indexOf(memSize);
    const data = deriveVMSpecs(spec);
    const quotas = deriveQuotas(data);
    return {
        title: `${quotas.cpu} CPU cores, ${quotas.mem}G RAM`,
        price_day: getDedicatedVMPrice(data),
        spec: quotas,
        quota: { dedicated_vm: spec },
        // "d"edicated "VM", family n2, "m"emory [index] and "c"pu cores number
        stripeID: `dVM${family}m${midx}c${cpus}`, // partial stripe product id
    };
}
// generate all dedicated VM specs we want to offer
function* getVMData() {
    const family = "n2";
    for (const memSize of VM_MEM_SIZES) {
        for (const cpus of [2, 4, 8, 16]) {
            yield getSpecAndQuota({ family, memSize, cpus });
        }
    }
}
exports.VMS = {};
for (const vmtype of getVMData()) {
    exports.VMS[vmtype.quota.dedicated_vm] = vmtype;
}
const DISKS = {};
// we add a bit for snapshot storage
const SNAPSHOT_FACTOR = 1.25;
// price numbers are for 1 month and 1024 gb (more significant digits) and zonal storage
const DISK_MONTHLY_1GB = {
    standard: (SNAPSHOT_FACTOR * 40.96) / 1024,
    balanced: (SNAPSHOT_FACTOR * 102.4) / 1024,
    ssd: (SNAPSHOT_FACTOR * 174.08) / 1024,
};
// https://cloud.google.com/compute/docs/disks/performance#performance_by_disk_size
const IOPS = {
    standard: { read: 0.75, write: 1.5 },
    balanced: { read: 6, write: 6 },
    ssd: { read: 30, write: 30 },
};
// sustained throughput
const MBPS = {
    standard: { read: 0.12, write: 0.12 },
    balanced: { read: 0.28, write: 0.28 },
    ssd: { read: 0.48, write: 0.48 },
};
// below, we define all valid dedicated disk configurations
exports.MIN_DEDICATED_DISK_SIZE = 32;
exports.MAX_DEDICATED_DISK_SIZE = 1024;
exports.DEDICATED_DISK_SIZE_INCREMENT = 32;
exports.DEFAULT_DEDICATED_DISK_SIZE = exports.MIN_DEDICATED_DISK_SIZE + exports.DEDICATED_DISK_SIZE_INCREMENT;
// this must be kept in sync with the numerical slider in next/store/dedicated
// we also make it readonly to avoid accidental changes
exports.DEDICATED_DISK_SIZES = (function () {
    const v = [];
    for (let i = exports.MIN_DEDICATED_DISK_SIZE; i <= exports.MAX_DEDICATED_DISK_SIZE; i += exports.DEDICATED_DISK_SIZE_INCREMENT) {
        v.push(i);
    }
    return v;
})();
// ATTN: do not modify/insert/prepend to this list -- only append
// otherwise you distort the stripe ID!
exports.DEDICATED_DISK_SPEEDS = [
    "standard",
    "balanced",
    "ssd",
];
exports.DEFAULT_DEDICATED_DISK_SPEED = "standard";
function getDedicatedDiskKey({ size_gb, speed, }) {
    return `${size_gb}-${speed}`;
}
exports.getDedicatedDiskKey = getDedicatedDiskKey;
for (const size_gb of exports.DEDICATED_DISK_SIZES) {
    for (const speed of exports.DEDICATED_DISK_SPEEDS) {
        const quota = {
            dedicated_disk: { size_gb, speed },
        };
        const tIdx = exports.DEDICATED_DISK_SPEEDS.indexOf(speed);
        const title = `${size_gb}G ${dedicated_1.DISK_NAMES[speed]}`;
        const key = getDedicatedDiskKey({ size_gb, speed });
        DISKS[key] = {
            quota,
            title,
            price_day: rawPrice2Retail(DISK_MONTHLY_1GB[speed] * size_gb),
            iops: `${size_gb * IOPS[speed].read}/${size_gb * IOPS[speed].write}`,
            mbps: `${Math.round(size_gb * MBPS[speed].read)}/` +
                `${Math.round(size_gb * MBPS[speed].write)}`,
            // dedicated "D"isk, "t"ype [number] and "s"ize [number]
            stripeID: `dDt${tIdx}s${size_gb}`,
        };
    }
}
exports.DEFAULT_DEDICATED_VM_MACHINE = getSpecAndQuota({
    family: "n2",
    memSize: "highmem",
    cpus: 2,
}).quota.dedicated_vm;
exports.PRICES = {
    vms: exports.VMS,
    disks: DISKS,
    disks_monthly: DISK_MONTHLY_1GB,
};
//# sourceMappingURL=dedicated.js.map

/***/ })

};
;