<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<%@ include file="/mini_cart/init.jsp" %>

<c:choose>
	<c:when test="<%= commerceChannelId == 0 %>">
		<div class="alert alert-info mx-auto">
			<liferay-ui:message key="this-site-does-not-have-a-channel" />
		</div>
	</c:when>
	<c:otherwise>
		<div class="cart-root" id="<%= miniCartId %>"></div>

		<aui:script require="commerce-frontend-js/components/mini_cart/entry as Cart">
			var initialProps = {
				cartActionURLs: {
					checkoutURL: '<%= HtmlUtil.escapeJS(checkoutURL) %>',
					orderDetailURL: '<%= HtmlUtil.escapeJS(orderDetailURL) %>',
					productURLSeparator: '<%= HtmlUtil.escapeJS(productURLSeparator) %>',
					siteDefaultURL: '<%= HtmlUtil.escapeJS(siteDefaultURL) %>',
				},
				channel: {
					currencyCode: '<%= commerceCurrencyCode %>',
					groupId: <%= commerceChannelGroupId %>,
					id: <%= commerceChannelId %>,
				},
				displayDiscountLevels: <%= displayDiscountLevels %>,
				displayTotalItemsQuantity: <%= displayTotalItemsQuantity %>,
				itemsQuantity: <%= itemsQuantity %>,
				orderId: <%= orderId %>,
				toggleable: <%= toggleable %>,
			};

			<%
			if (!cartViews.isEmpty()) {
			%>

				initialProps.cartViews = {};

				<%
				for (Map.Entry<String, String> cartView : cartViews.entrySet()) {
				%>

					initialProps.cartViews['<%= cartView.getKey() %>'] = {
						contentRendererModuleUrl: '<%= cartView.getValue() %>',
					};

				<%
					}
				}

				if (!labels.isEmpty()) {
				%>

				initialProps.labels = {};

				<%
				for (Map.Entry<String, String> label : labels.entrySet()) {
				%>

					initialProps.labels['<%= label.getKey() %>'] = '<%= label.getValue() %>';

			<%
				}
			}
			%>

			Cart.default('<%= miniCartId %>', '<%= miniCartId %>', initialProps);
		</aui:script>
	</c:otherwise>
</c:choose>