<!DOCTYPE html>
<html>

<head>
	<title>CodeStream</title>
	<link rel="dns-prefetch" href="https://images.codestream.com">
	{{> partial_html_head partial_html_head_model}}
	<script type="text/javascript">
		!function () {
			var analytics = window.analytics = window.analytics || []; if (!analytics.initialize) if (analytics.invoked) window.console && console.error && console.error("Segment snippet included twice."); else {
				analytics.invoked = !0; analytics.methods = ["trackSubmit", "trackClick", "trackLink", "trackForm", "pageview", "identify", "reset", "group", "track", "ready", "alias", "debug", "page", "once", "off", "on"]; analytics.factory = function (t) { return function () { var e = Array.prototype.slice.call(arguments); e.unshift(t); analytics.push(e); return analytics } }; for (var t = 0; t < analytics.methods.length; t++) { var e = analytics.methods[t]; analytics[e] = analytics.factory(e) } analytics.load = function (t, e) { var n = document.createElement("script"); n.type = "text/javascript"; n.async = !0; n.src = "https://cdn.segment.com/analytics.js/v1/" + t + "/analytics.min.js"; var a = document.getElementsByTagName("script")[0]; a.parentNode.insertBefore(n, a); analytics._loadOptions = e }; analytics.SNIPPET_VERSION = "4.1.0";
				analytics.load("{{segmentKey}}");
			}
		}();
	</script>
	<script>
		var setError = function(error) {
			const errorElem = document.getElementById("error");
			const maxFreeSeats = {{minPaidSeats}} - 1;
			let message = {
				number: "Must be a positive number.",
				free: `{{minPaidSeats}}-seat minimum. CodeStream is free for companies of ${maxFreeSeats} or less.`,
				tooFewSeats: "Your company currently has {{memberCount}} users. If you’d like to subscribe with less you will need to remove some."
			}[error];
			if (!message) message = "Unknown error.";
			errorElem.style.display = "block";
			errorElem.innerHTML = message;
		};

		var checkout = function() {
			const seatsElem = document.getElementById("seats");
			const seats = seatsElem.value;
			const numSeats = parseInt(seats, 10);
			const payMonthly = document.getElementById("pay-monthly").checked;
			const frequency = payMonthly ? "Monthly" : "Annual";
			let error;
			if (numSeats == NaN || numSeats < 1 || numSeats.toString() !== seats.trim()) {
				setError("number");
				return false;
			} else if (numSeats < {{ memberCount }}) {
				setError("tooFewSeats");
				window.analytics.track("Payment Seats Validation", { Validation: "Less than registered seats" });
				return false;
			} else if (numSeats < {{minPaidSeats}}) {
				setError("free");
				window.analytics.track("Payment Seats Validation", { Validation: "Less than {{minPaidSeats}}" });
				return false;
			} else {
				const couponCtrl = document.getElementById("coupon");
				const buyNowCoupon = {{buyNowDiscount}} ? "{{buyNowCouponCode}}": "";
				const coupon = couponCtrl ? couponCtrl.value : buyNowCoupon;
				window.analytics.track("Checkout", {
					"Company ID": "{{companyId}}",
					"Seats": numSeats,
					"Plan Purchased": "BUSINESS",
					"Frequency": frequency,
					"Coupon": coupon
				}, () => {
					const params = {
						companyId: "{{companyId}}",
						seats: numSeats,
						"pay-type": payMonthly ? "monthly" : "annual",
						coupon
					};
					document.location = "/web/subscription/checkout?" + Object.keys(params).map(key => {
						return `${key}=${params[key]}`;
					}).join('&');
				});
				return false;
			}
		};

		window.onload = function() {
			if ("{{error}}") {
				setError("{{error}}");
			}
			window.analytics.track('Page Viewed', { 'Page Name': 'Payment' });
		};

	</script>
</head>
<body>
	{{{identifyScript}}}
	{{> partial_menu partial_menu_model}}

	<div class="container-fluid" id="root">
		<div class="row">
			<div class="col-sm-6 offset-sm-3">
				<div class="box-content box-border box-content-subscription-upgrade">
					<h1>Upgrade {{companyName}} to CodeStream Business</h1>
					<br />
					<p>CodeStream is free for teams of any size and offers unlimited comments, pull requests, code reviews, and integrations, as well as lifetime knowledge retention.</p>
					<br />
					<p>Upgrade to CodeStream Business for priority support, on prem deployment, and additional management reporting.</p>
					<br />
					<p>For more information please see <a href="https://codestream.com/pricing" target="_blank">CodeStream Business and Enterprise Pricing</a>.</p>

					<div class="form-wrapper">
						<form method="get" onsubmit="return checkout();">
							<div class="form-group">
								<input type="hidden" name="companyId" value="{{companyId}}" />
							</div>
							<div class="form-group row">
								<label class="label col-form-label col-sm-4">Number of seats:&nbsp;&nbsp;</label>
								<div class="col-sm-6">
									<input class="form-control bg-dark" id="seats" name="seats" autocomplete="off" type="number" value="{{memberCount}}" autofocus />
								</div>
							</div>
							{{#if offerCoupon}}
							<div class="form-group row">
								<label class="label col-form-label col-sm-4">Referral code:&nbsp;&nbsp;</label>
								<div class="col-sm-6">
									<input class="form-control bg-dark" id="coupon" name="coupon" autocomplete="off" />
								</div>
							</div>
							<div class="form-group row">
								<div class="col-sm-4">&nbsp;</div>
								<div class="col-sm-8" style="margin-top:-10px">
									Discounted pricing will be reflected on the checkout page.
								</div>
							</div>
							{{/if}}
							<p id="error" class="error" style="display:none;">error</p>
							<div class="radio-group">
								<input type="radio" class="radio" id="pay-annually" name="pay-type" value="annual" checked>
								{{#if buyNowDiscount}}
								<label for="pay-annual">Pay Annually</label>
								<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Only $5.00 per seat with discount. Regularly $8.33/month.</p>
								{{else}}
								<label for="pay-annual">Pay Annually</label>
								<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get 12 months for the price of 10. Just $8.33/month per seat.</p>
								{{/if}}
								<input type="radio" class="radio" id="pay-monthly" name="pay-type" value="month">
								{{#if buyNowDiscount}}
								<label for="pay-monthly">Pay Monthly</label>
								<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Only $6.00 per seat with discount. Regularly $10.00/month.</p>
								{{else}}
								<label for="pay-monthly">Pay Monthly</label>
								<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$10/month per seat.</p>
								{{/if}}
							</div>
							<br />
							<div class="form-group">
								<input type="submit" value="Checkout" class="btn" />
							</div>
						</form>
					</div>

				</div>
			</div>
		</div>
	</div>
</body>
</html>
