<?php

	// When mod_rewrite is off, imageanywhere/* is routed here as query_str — serve without tenant mysqli.
	$__storefrontQuery = isset($_REQUEST['query_str']) ? trim((string) $_REQUEST['query_str']) : '';
	if ($__storefrontQuery !== '' && preg_match('#^(?:(\d+)/)?imageanywhere(?:/|$)#', $__storefrontQuery, $__imgRouteM)) {
		if (!empty($__imgRouteM[1])) {
			$_REQUEST['storefront_customer_id'] = (int) $__imgRouteM[1];
		}
		$__imgRel = preg_replace('#^\d+/#', '', $__storefrontQuery);
		$__imgRel = preg_replace('#^imageanywhere/?#', '', $__imgRel);
		if ($__imgRel !== '') {
			$_REQUEST['imgid'] = $__imgRel;
			require __DIR__ . '/index_image.php';
			exit;
		}
	}

	// Affiliate tracked links (Social Management)
	if ($__storefrontQuery !== '' && preg_match('#^(?:(\d+)/)?go/([A-Za-z0-9_-]+)/?$#', $__storefrontQuery, $__goM)) {
		if (!empty($__goM[1])) {
			$_REQUEST['storefront_customer_id'] = (int) $__goM[1];
		}
		$_GET['affiliate_code'] = (string) $__goM[2];
		require __DIR__ . '/go.php';
		exit;
	}

if ($__storefrontQuery !== '' && preg_match('#^(?:(\d+)/)?api/tutorial/?$#', $__storefrontQuery, $__tutApiM)) {
		if (!empty($__tutApiM[1])) {
			$_REQUEST['storefront_customer_id'] = (int) $__tutApiM[1];
		}
		require __DIR__ . '/tutorial_api.php';
		exit;
	}

	if ($__storefrontQuery !== '' && preg_match('#^(?:(\d+)/)?api/site-gate-unlock/?$#', $__storefrontQuery, $__gateApiM)) {
		if (!empty($__gateApiM[1])) {
			$_REQUEST['storefront_customer_id'] = (int) $__gateApiM[1];
		}
		require __DIR__ . '/site_gate_unlock_api.php';
		exit;
	}

	include("__CLIENT.APP/client.config.inc.php");						//print_r($CONFIG);

	require_once __DIR__ . '/__CLIENT.APP/StorefrontPaths.php';
	StorefrontPaths::requireLib('WebsiteSitemapService.php');
	$__seoPath = WebsiteSitemapService::resolveRequestSeoPath($__storefrontQuery);
	if ($__seoPath !== null) {
		$__seoSiteId = (int) ($CONFIG->websiteId ?? 0);
		$__seoPdo = (isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO) ? $CONFIG->pdo : null;
		$__seoBase = rtrim((string) ($CONFIG->siteurlHttps ?? $CONFIG->siteurl ?? ''), '/');
		if ($__seoPdo instanceof PDO && $__seoSiteId > 0 && $__seoBase !== '') {
			WebsiteSitemapService::serveLiveStorefrontSeoIfRequested($__seoPdo, $__seoSiteId, $__seoBase, $__storefrontQuery);
		}
		http_response_code(503);
		header('Content-Type: text/plain; charset=UTF-8');
		echo 'SEO files are not available for this site (database or site id missing).';
		exit;
	}

	if (!isset($CONFIG->dbLink) || !($CONFIG->dbLink instanceof \mysqli)) {
		http_response_code(503);
		header('Content-Type: text/html; charset=utf-8');
		echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Storefront</title></head><body>';
		echo '<p>Customer website database is not configured for this visit.</p>';
		echo '<p>Open the site with your customer id in the URL, for example: ';
		echo '<code>http://localhost/client_store/{customer-id}/</code> (legacy domain-request URLs also work as ';
		echo '<code>http://localhost/client_store/{domain-request-id}/</code>). Optional: set ';
		echo '<code>KISCHIT_CUSTOMER_WEBSITE_DEV_WEB_ID</code> in <code>.env</code> for bare <code>/client_store/</code> without an id segment.</p>';
		echo '<p>Product images are served separately at <code>…/imageanywhere/products/{token}</code> and do not require this bootstrap.</p>';
		echo '</body></html>';
		exit;
	}
	
	if (isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO && (int) ($CONFIG->websiteId ?? 0) > 0) {
		require_once __DIR__ . '/lib/CustomerWebsiteGateStorefrontIntercept.php';
		CustomerWebsiteGateStorefrontIntercept::maybeExit($CONFIG);
	}

	if($CONFIG->pageId == '')
		$page_info = $clientpage->getLandingWebPage(array("PAGE_ID" => $CONFIG->pageId, "WEB_ID" => $CONFIG->websiteId));
	else
		$page_info = $clientpage->getWebPage(array("PAGE_ID" => $CONFIG->pageId, "WEB_ID" => $CONFIG->websiteId));
	
	$web_info 	 	= $page_info["PAGE_INFO"];								//echo "<pre>";print_r($web_info);//print_r($_SESSION);
	$web_content 	= $page_info["PAGE_CONTENT"];
	$header_footer 	= $page_info["HEADER_FOOTER_HTML"];						//echo "<pre>";print_r($header_footer);
	
	$header_logo = $header_footer[1]["header_logo"];
	$footer_logo = $header_footer[1]["footer_logo"];
	$fav_logo = $header_footer[1]["fav_logo"];
	
	$landing_page_link_arr = $clientpage->getLandingPageLink(array("WEB_ID" => $CONFIG->websiteId));
	$landing_page_link = $landing_page_link_arr[1]["page_link_url"];

	require_once __DIR__ . '/__CLIENT.APP/StorefrontPaths.php';
	StorefrontPaths::requireLib('StorefrontPublishedHtml.php');

	$header_logo = $header_logo != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($header_logo) : $header_logo;	//print_r($landing_page_link_arr);
	$footer_logo = $footer_logo != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($footer_logo) : $footer_logo;
	$fav_logo = $fav_logo != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($fav_logo) : $fav_logo;
	
	$page_ext_js_footer = $web_content[1]["page_ext_js_footer"];
	$page_ext_js_head   = $web_content[1]["page_ext_js_head"];
	$page_meta_tags		= $web_content[1]["page_meta_tag"];
	$menu_str			= $header_footer[1]["menu_desktop"];
	$mobile_menu_str	= $header_footer[1]["menu_mobile"];
	$master_html_content= $web_content[1]["page_html"];
	$ns_html			= $header_footer[1]["ns_html"];
	$footer_html		= $header_footer[1]["footer_html"];
	$cp_html			= $header_footer[1]["footer_copyright"];
	$page_title			= $web_content[1]["page_title"];
	
	$page_ext_js_footer = $page_ext_js_footer != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($page_ext_js_footer) : $page_ext_js_footer;
	$page_ext_js_head	= $page_ext_js_head != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($page_ext_js_head) : $page_ext_js_head;
	$page_meta_tags		= $page_meta_tags != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($page_meta_tags) : $page_meta_tags;
	$page_meta_tags     = StorefrontPublishedHtml::normalizePageMetaTagsHtml($page_meta_tags);
	$menu_str			= $menu_str != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($menu_str) : $menu_str;
	$mobile_menu_str 	= $mobile_menu_str != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($mobile_menu_str) : $mobile_menu_str;
	$__themeAssetsBase = (string) ($CONFIG->assetsURL ?? '');
	$menu_str = StorefrontPublishedHtml::normalizeThemeHtmlForLive(
		StorefrontPublishedHtml::sanitizeHeaderMenuHtml($menu_str),
		$__themeAssetsBase
	);
	$mobile_menu_str = StorefrontPublishedHtml::normalizeThemeHtmlForLive(
		StorefrontPublishedHtml::sanitizeHeaderMenuHtml($mobile_menu_str),
		$__themeAssetsBase
	);
	if ($HOST === 'localhost' || $HOST === '127.0.0.1' || str_starts_with((string) $HOST, 'localhost:')) {
		StorefrontPaths::requireLib('StorefrontPublicUrl.php');
		$urlWebSegment = trim((string) ($CONFIG->storefrontUrlWebId ?? $CONFIG->clientId ?? ''));
		if ($urlWebSegment !== '') {
			$legacyWsBase = StorefrontPublicUrl::appBase() . StorefrontPublicUrl::LIVE_PATH_PREFIX . $urlWebSegment . '/';
			$liveBase = rtrim((string) ($CONFIG->siteurl ?? ''), '/') . '/';
			if ($legacyWsBase !== $liveBase) {
				$menu_str = str_replace($legacyWsBase, $liveBase, $menu_str);
				$mobile_menu_str = str_replace($legacyWsBase, $liveBase, $mobile_menu_str);
				$footer_html = str_replace($legacyWsBase, $liveBase, $footer_html);
				$ns_html = str_replace($legacyWsBase, $liveBase, $ns_html);
			}
		}
	}
	$master_html_content= $master_html_content != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($master_html_content) : $master_html_content;
	$ns_html			= $ns_html != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($ns_html) : $ns_html;
	$footer_html		= $footer_html != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($footer_html) : $footer_html;
	$cp_html			= $cp_html != '' ? StorefrontPublishedHtml::decodeLiveStoredBlob($cp_html) : $cp_html;
	$__dynamicImg = trim((string) ($CONFIG->dynamicIMG ?? ''));
	if ($__dynamicImg !== '') {
		$header_logo = StorefrontPublishedHtml::normalizeBrandAssetUrl($header_logo, $__dynamicImg, $HOST);
		$footer_logo = StorefrontPublishedHtml::normalizeBrandAssetUrl($footer_logo, $__dynamicImg, $HOST);
		$fav_logo = StorefrontPublishedHtml::normalizeBrandAssetUrl($fav_logo, $__dynamicImg, $HOST);
		$master_html_content = StorefrontPublishedHtml::expandKwAssetMarkers($master_html_content, $__dynamicImg);
		$ns_html = StorefrontPublishedHtml::expandKwAssetMarkers($ns_html, $__dynamicImg);
		$footer_html = StorefrontPublishedHtml::expandKwAssetMarkers($footer_html, $__dynamicImg);
		$cp_html = StorefrontPublishedHtml::expandKwAssetMarkers($cp_html, $__dynamicImg);
		$menu_str = StorefrontPublishedHtml::expandKwAssetMarkers($menu_str, $__dynamicImg);
		$mobile_menu_str = StorefrontPublishedHtml::expandKwAssetMarkers($mobile_menu_str, $__dynamicImg);
	}
	$master_html_content = StorefrontPublishedHtml::normalizePublishedPageBodyHtml($master_html_content, $__themeAssetsBase);
	$ns_html = StorefrontPublishedHtml::normalizeThemeHtmlForLive($ns_html, $__themeAssetsBase);
	$footer_html = StorefrontPublishedHtml::normalizeThemeHtmlForLive($footer_html, $__themeAssetsBase);

	StorefrontPaths::requireLib('StorefrontPublicUrl.php');
	$__tutorialApiUrlGlobal = StorefrontPublicUrl::safeTutorialApiUrl($CONFIG);
	$master_html_content = StorefrontPublishedHtml::rewriteBadTutorialApiUrls($master_html_content, $__tutorialApiUrlGlobal);
	$page_ext_js_footer = StorefrontPublishedHtml::rewriteBadTutorialApiUrls((string) $page_ext_js_footer, $__tutorialApiUrlGlobal);

	StorefrontPaths::requireLib('EcommerceWebsiteSettingsService.php');
	StorefrontPaths::requireLib('EcommerceStorefrontUrl.php');
	$__ecomChannelRow = EcomRuntime::channelRow();
	if ($__ecomChannelRow !== []) {
		$footer_html = EcommerceWebsiteSettingsService::filterStorefrontFooterHtml($footer_html, $__ecomChannelRow);
		$ns_html = EcommerceWebsiteSettingsService::filterStorefrontFooterHtml($ns_html, $__ecomChannelRow);
		$master_html_content = EcommerceWebsiteSettingsService::filterStorefrontFooterHtml($master_html_content, $__ecomChannelRow);
		$menu_str = EcommerceWebsiteSettingsService::filterStorefrontHeaderNavHtml($menu_str, $__ecomChannelRow);
		$mobile_menu_str = EcommerceWebsiteSettingsService::filterStorefrontHeaderNavHtml($mobile_menu_str, $__ecomChannelRow);
	}
	if (!empty($product_enabled) && isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO && (int) ($CONFIG->websiteId ?? 0) > 0) {
		$__ecomChannelRowFull = EcommerceWebsiteSettingsService::refinedForChannel(
			$CONFIG->pdo,
			(int) $CONFIG->websiteId,
			EcommerceWebsiteSettingsService::CHANNEL_B2C
		);
		if (EcommerceWebsiteSettingsService::shopDisplayFlags($__ecomChannelRowFull)['category_menu']) {
			StorefrontPaths::requireLib('EcommerceStorefrontNavMenus.php');
			$__ecomShopNavHref = EcommerceStorefrontUrl::resolveProductListPageHref(
				$CONFIG->pdo,
				(int) $CONFIG->websiteId,
				rtrim((string) ($CONFIG->siteurlHttps ?? $CONFIG->siteurl ?? ''), '/') . '/'
			);
			$menu_str = EcommerceStorefrontNavMenus::injectProductCategorySubmenuInNav(
				$menu_str,
				$CONFIG->pdo,
				(int) $CONFIG->websiteId,
				EcommerceWebsiteSettingsService::CHANNEL_B2C,
				$__ecomShopNavHref
			);
			$mobile_menu_str = EcommerceStorefrontNavMenus::injectProductCategorySubmenuInNav(
				$mobile_menu_str,
				$CONFIG->pdo,
				(int) $CONFIG->websiteId,
				EcommerceWebsiteSettingsService::CHANNEL_B2C,
				$__ecomShopNavHref,
				'mobile'
			);
		}
	}
	$ecom_storefront_account_enabled = false;
	$ecom_sf_logged_in = false;
	$ecom_sf_display_name = '';
	$__ecomSfAcc = null;
	$ecom_sf_home = rtrim((string) ($CONFIG->siteurlHttps ?? $CONFIG->siteurl ?? ''), '/') . '/';
	if ($__ecomChannelRow !== [] && isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO && (int) ($CONFIG->websiteId ?? 0) > 0) {
		StorefrontPaths::requireLib('EcommerceStorefrontAccountService.php');
		$__ecomSiteAcct = EcommerceWebsiteSettingsService::refinedSiteAccountSettings($CONFIG->pdo, (int) $CONFIG->websiteId);
		$ecom_storefront_account_enabled = EcommerceStorefrontAccountService::accountLoginEnabled($__ecomSiteAcct);
		if ($ecom_storefront_account_enabled) {
			$__ecomSfAcc = EcommerceStorefrontAccountService::currentAccount($CONFIG->pdo, (int) $CONFIG->websiteId);
			if ($__ecomSfAcc !== null) {
				$ecom_sf_logged_in = true;
				$ecom_sf_display_name = trim((string) ($__ecomSfAcc['display_name'] ?? ''));
			}
		}
	}
	$ecom_sf_wishlist_href = EcommerceStorefrontUrl::canonicalHref($ecom_sf_home, EcommerceStorefrontUrl::CANONICAL_WISHLIST);
	if (isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO && (int) ($CONFIG->websiteId ?? 0) > 0) {
		if (!class_exists('EcommerceStorefrontAccountService', false)) {
			StorefrontPaths::requireLib('EcommerceStorefrontAccountService.php');
		}
		$ecom_sf_wishlist_href = EcommerceStorefrontAccountService::headerWishlistHref(
			$ecom_sf_home,
			$ecom_sf_logged_in,
			$ecom_storefront_account_enabled,
			$CONFIG->pdo,
			(int) $CONFIG->websiteId
		);
	}
	$__pageContentType = (string) ($web_info[1]['page_content_type'] ?? '');
	$__isTutorialStorefrontPage = ($__pageContentType === 'Tutorial');
	$__loadTutorialPurchase = $__isTutorialStorefrontPage
		|| str_contains((string) $master_html_content, 'kischit-tutorial-add-cart')
		|| str_contains((string) $master_html_content, 'kischit-tutorial-buy');

	$ecom_sf_auth_from_context = '';
	$__ecomPageSlug = EcommerceStorefrontUrl::normalizeStorefrontPathSegment((string) ($CONFIG->pageId ?? ''));
	if (EcommerceStorefrontUrl::matchesStorefrontRoute($__ecomPageSlug, $__ecomPageSlug, ['cart-style1', 'cart-style2', 'cart'])) {
		$ecom_sf_auth_from_context = 'cart';
	} elseif (EcommerceStorefrontUrl::matchesStorefrontRoute($__ecomPageSlug, $__ecomPageSlug, ['checkout-style1', 'checkout-style2', 'checkout'])) {
		$ecom_sf_auth_from_context = 'checkout';
	}
	StorefrontPaths::requireLib('StorefrontPublicUrl.php');
	$ecom_sf_account_api = StorefrontPublicUrl::ecomStorefrontAccountApiUrl($CONFIG);
	$storefrontBodyClass = 'template-index ' . (string) ($CONFIG->storefrontBodyClass ?? 'index-demo1');
	if (!empty($product_enabled) && isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO && (int) ($CONFIG->websiteId ?? 0) > 0) {
		$ecomProductSlugEarly = EcommerceStorefrontUrl::parseProductSlugFromPath((string) ($_REQUEST['query_str'] ?? ''));
		if ($ecomProductSlugEarly === '' && strtolower((string) ($CONFIG->pageId ?? '')) === 'product') {
			$qsParts = explode('/', trim((string) ($_REQUEST['query_str'] ?? ''), '/'));
			$ecomProductSlugEarly = EcommerceStorefrontUrl::normalizeProductSlug((string) ($qsParts[count($qsParts) - 1] ?? ''));
		}
		if ($ecomProductSlugEarly !== '') {
			$storefrontBodyClass = 'template-product '
				. EcommerceWebsiteSettingsService::productDetailLayoutClass($CONFIG->pdo, (int) $CONFIG->websiteId);
		}
	}
	if ($ecom_sf_auth_from_context === 'checkout') {
		$storefrontBodyClass .= ' checkout-page checkout-style1-page';
	} elseif ($ecom_sf_auth_from_context === 'cart') {
		$storefrontBodyClass .= ' cart-page cart-style1-page';
	}
	$ecom_sf_account_body = '';
	if (EcommerceStorefrontUrl::matchesStorefrontRoute($__ecomPageSlug, $__ecomPageSlug, ['my-account'])) {
		$ecom_sf_account_body = ' account-page my-account-page';
	} elseif (EcommerceStorefrontUrl::matchesStorefrontRoute($__ecomPageSlug, $__ecomPageSlug, ['login'])) {
		$ecom_sf_account_body = ' account-page login-page';
	} elseif (EcommerceStorefrontUrl::matchesStorefrontRoute($__ecomPageSlug, $__ecomPageSlug, ['register'])) {
		$ecom_sf_account_body = ' account-page register-page';
	}
	$storefrontBodyClass .= $ecom_sf_account_body;
?>
<!DOCTYPE html>
<html class="no-js" lang="<?= htmlspecialchars(!empty($ecom_html_lang) ? (string) $ecom_html_lang : 'en', ENT_QUOTES, 'UTF-8') ?>">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php echo $page_meta_tags;?>
    <!-- Title Of Site -->
    <title>
	<?php 
		echo $page_title;
	 ?></title>
    <!-- Favicon -->
    <link rel="shortcut icon" href="<?php echo $fav_logo;?>" />
    <!-- Plugins CSS -->
    <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL.""; ?>assets/css/plugins.css">
    <!-- Photoswipe Gallery CSS -->
    <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL.""; ?>assets/css/vendor/photoswipe.min.css">
    <!-- Main Style CSS -->
    <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL.""; ?>assets/css/style.css">
    <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL.""; ?>assets/css/responsive.css">
    <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL; ?>assets/css/vendor/jquery-ui.css">
    <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL; ?>assets/css/theme-accent.css">
    <?php if ($ecom_sf_auth_from_context === 'checkout' || $ecom_sf_auth_from_context === 'cart' || $ecom_sf_account_body !== ''): ?>
    <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL; ?>assets/css/ecom-storefront-checkout.css?v=20260606b">
    <?php endif; ?>
    <?php if ($__isTutorialStorefrontPage): ?>
    <link rel="stylesheet" href="<?php echo htmlspecialchars((string) $CONFIG->assetsURL, ENT_QUOTES, 'UTF-8'); ?>assets/css/kischit_tutorial.css?v=20260625">
    <link rel="stylesheet" href="<?php echo htmlspecialchars((string) $CONFIG->assetsURL, ENT_QUOTES, 'UTF-8'); ?>assets/css/kischit_video_player.css?v=20260625">
    <?php endif; ?>
    <?php echo $page_ext_js_head;?>
</head>
<body class="<?php echo htmlspecialchars($storefrontBodyClass, ENT_QUOTES, 'UTF-8'); ?>">
	<div class="page-wrapper">
		<?php //--Header-- ?>
        <header class="header d-flex align-items-center header-1 header-fixed">
                <div class="container">        
                    <div class="row">
                        <?php //--Logo-- ?>
                        <div class="logo col-5 col-sm-3 col-md-3 col-lg-2 align-self-center">
                            <a class="logoImg" href="<?php echo $CONFIG->siteurl.$landing_page_link;?>"><img src="<?php echo $header_logo; ?>" alt="<?php echo $title;?>" title="<?php echo $title;?>" width="149" height="39" /></a>
                        </div>
                        <?php //--End Logo-- ?>
                        <?php //--Menu-- ?>
                        <div class="col-1 col-sm-1 col-md-1 col-lg-8 align-self-center d-menu-col">
                            <nav class="navigation" id="AccessibleNav">
                                <ul id="siteNav" class="site-nav medium center">
                               <?php
										
										echo $menu_str;
								?>                                
                                </ul>
                            </nav>
                        </div>
                        <?php //--End Menu-- ?>
                        <?php //--Right Icon-- ?>
                         <button type="button" class="iconset pe-0 menu-icon js-mobile-nav-toggle d-lg-none mobile-nav--open" title="Menu"
                         <?php
						
                         	if(!$product_enabled)
							{
								echo ' style= "right:-130px;" ';
							}
							?>><i class="hdr-icon icon anm anm-times-l"></i><i class="hdr-icon icon anm anm-bars-r"></i></button>
                        <?php
							if($product_enabled)
							{
                                if (!function_exists('ecom_t')) {
                                    StorefrontPaths::requireLib('EcommerceStorefrontI18n.php');
                                    function ecom_t(string $key, array $vars = []): string {
                                        return EcommerceStorefrontI18n::t($key, $vars);
                                    }
                                }
						?>
                       	 		<div class="col-7 col-sm-9 col-md-9 col-lg-2 align-self-center icons-col text-right">
                            <!--Search-->
                            <div class="search-parent iconset">
                                <div class="site-search" title="<?php echo htmlspecialchars(ecom_t('nav.search'), ENT_QUOTES, 'UTF-8'); ?>">
                                    <a href="#;" class="search-icon clr-none" data-bs-toggle="offcanvas" data-bs-target="#search-drawer"><i class="hdr-icon icon anm anm-search-l"></i></a>
                                </div>
                                <?php include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/header_search.inc.php'; ?>
                            </div>
                            <!--End Search-->
                            <!--Account-->
                            <?php if (!empty($ecom_storefront_account_enabled)) { ?>
                            <div class="account-parent iconset">
                                <div class="account-link" title="<?php echo htmlspecialchars($ecom_sf_logged_in && $ecom_sf_display_name !== '' ? $ecom_sf_display_name : ecom_t('nav.account'), ENT_QUOTES, 'UTF-8'); ?>"><i class="hdr-icon icon anm anm-user-al"></i></div>
                                <div id="accountBox">
                                    <div class="customer-links">
                                        <ul class="m-0">
                                            <?php if (!$ecom_sf_logged_in) { ?>
                                            <li><a href="<?php echo htmlspecialchars(EcommerceStorefrontAccountService::accountAuthPageHref($ecom_sf_home, 'login', (string) ($ecom_sf_auth_from_context ?? '')), ENT_QUOTES, 'UTF-8'); ?>"><i class="icon anm anm-sign-in-al"></i><?php echo htmlspecialchars(ecom_t('nav.sign_in'), ENT_QUOTES, 'UTF-8'); ?></a></li>
                                            <li><a href="<?php echo htmlspecialchars(EcommerceStorefrontAccountService::accountAuthPageHref($ecom_sf_home, 'register', (string) ($ecom_sf_auth_from_context ?? '')), ENT_QUOTES, 'UTF-8'); ?>"><i class="icon anm anm-user-al"></i><?php echo htmlspecialchars(ecom_t('nav.register'), ENT_QUOTES, 'UTF-8'); ?></a></li>
                                            <?php } else {
                                                $ecom_sf_welcome_name = $ecom_sf_display_name !== ''
                                                    ? $ecom_sf_display_name
                                                    : (trim((string) ($__ecomSfAcc['email'] ?? '')) !== ''
                                                        ? (string) $__ecomSfAcc['email']
                                                        : ecom_t('nav.account'));
                                            ?>
                                            <li class="ecom-sf-welcome px-3 py-2 border-bottom mb-1">
                                                <span class="d-block fw-semibold"><?php echo htmlspecialchars(ecom_t('nav.welcome_user', ['name' => $ecom_sf_welcome_name]), ENT_QUOTES, 'UTF-8'); ?></span>
                                            </li>
                                            <li><a href="<?php echo htmlspecialchars(EcommerceStorefrontAccountService::resolveAccountPageHref($ecom_sf_home, EcommerceStorefrontUrl::CANONICAL_MY_ACCOUNT, $CONFIG->pdo ?? null, (int) ($CONFIG->websiteId ?? 0)), ENT_QUOTES, 'UTF-8'); ?>"><i class="icon anm anm-user-cil"></i><?php echo htmlspecialchars(ecom_t('nav.my_account'), ENT_QUOTES, 'UTF-8'); ?></a></li>
                                            <?php } ?>
                                            <?php if (!empty($wishlist_enabled)) { ?>
                                            <li><a href="<?php echo htmlspecialchars((string) $ecom_sf_wishlist_href, ENT_QUOTES, 'UTF-8'); ?>"><i class="icon anm anm-heart-l"></i><?php echo htmlspecialchars(ecom_t('nav.wishlist'), ENT_QUOTES, 'UTF-8'); ?></a></li>
                                            <?php } ?>
                                            <?php if (!empty($compare_enabled)) { ?>
                                            <li><a href="<?php echo htmlspecialchars(EcommerceStorefrontUrl::canonicalHref($ecom_sf_home, EcommerceStorefrontUrl::CANONICAL_COMPARE), ENT_QUOTES, 'UTF-8'); ?>" data-ecom-header-compare><i class="icon anm anm-random-r"></i><?php echo htmlspecialchars(ecom_t('nav.compare'), ENT_QUOTES, 'UTF-8'); ?></a></li>
                                            <?php } ?>
                                            <?php if ($ecom_sf_logged_in) { ?>
                                            <li><a href="<?php echo htmlspecialchars(($ecom_sf_account_api ?? StorefrontPublicUrl::ecomStorefrontAccountApiUrl($CONFIG)) . '?action=logout', ENT_QUOTES, 'UTF-8'); ?>"><i class="icon anm anm-sign-out-al"></i><?php echo htmlspecialchars(ecom_t('nav.sign_out'), ENT_QUOTES, 'UTF-8'); ?></a></li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                            <?php } ?>
                            <!--End Account-->
                            <!--Wishlist-->
                            <?php if (!empty($wishlist_enabled)) { ?>
                            <div class="wishlist-link iconset" title="<?php echo htmlspecialchars(ecom_t('nav.wishlist'), ENT_QUOTES, 'UTF-8'); ?>"><a href="<?php echo htmlspecialchars((string) $ecom_sf_wishlist_href, ENT_QUOTES, 'UTF-8'); ?>"><i class="hdr-icon icon anm anm-heart-l"></i><span class="wishlist-count">0</span></a></div>
                            <?php } ?>
                            <!--End Wishlist-->
                            <?php if (!empty($cart_enabled)) { ?>
                            <!--Minicart-->
                            <div class="header-cart iconset" title="<?php echo htmlspecialchars(ecom_t('nav.cart'), ENT_QUOTES, 'UTF-8'); ?>">
                                <a href="#;" class="header-cart btn-minicart clr-none" data-bs-toggle="offcanvas" data-bs-target="#minicart-drawer"><i class="hdr-icon icon anm anm-cart-l"></i><span class="cart-count">0</span></a>
                            </div>
                            <!--End Minicart-->
                            <?php } ?>
                            <!--Mobile Toggle-->
                            <button type="button" class="iconset pe-0 menu-icon js-mobile-nav-toggle mobile-nav--open d-lg-none" title="Menu"><i class="hdr-icon icon anm anm-times-l"></i><i class="hdr-icon icon anm anm-bars-r"></i></button>
                            <!--End Mobile Toggle-->
                        </div>
                        <?php
							}
						?>
                        <?php //--End Right Icon-- ?>
                    </div>
                </div>
            </header>
        <?php //--End Header-- ?>
        <?php //--Mobile Menu-- ?>
        <div class="mobile-nav-wrapper" role="navigation">

                <div class="closemobileMenu">Close Menu <i class="icon anm anm-times-l"></i></div>
                <ul id="MobileNav" class="mobile-nav">
                    <?php
							echo $mobile_menu_str;
					?>
                </ul>
        </div>
        <?php //--End Mobile Menu-- ?>
        	<div id="page-content">               
				<?php
						$__storefrontIsLocalHost = ($HOST === 'localhost' || $HOST === '127.0.0.1' || str_starts_with((string) $HOST, 'localhost:'));
						$__isBlogListingRequest = false;
						if (isset($incoming_query_arr) && is_array($incoming_query_arr)) {
							if ($__storefrontIsLocalHost && isset($incoming_query_arr[0]) && ctype_digit((string) $incoming_query_arr[0])) {
								$__isBlogListingRequest = strtolower((string) ($incoming_query_arr[1] ?? '')) === 'blogs';
							} else {
								$__isBlogListingRequest = strtolower((string) ($incoming_query_arr[0] ?? '')) === 'blogs';
							}
						}
						if ($__isBlogListingRequest)
						{
							$incoming_req_arr = $incoming_query_arr;
							if ($__storefrontIsLocalHost && isset($incoming_req_arr[0]) && ctype_digit((string) $incoming_req_arr[0]))
							{
								unset($incoming_req_arr[0]);
								$incoming_req_arr = array_values($incoming_req_arr);
							}
							$blog_settings = $blogs->refinedBlogListingSettings();			//print_r($incoming_req_arr);print_r($blog_settings);
							$category = strtolower($blog_settings["BLOG_CAT_TITLE"]);
							if(count($incoming_req_arr) >= 3)
							{
								if((strtolower($incoming_req_arr[1]) == "category" || strtolower($incoming_req_arr[1]) == $category) && $blog_settings["BLOG_CAT"] == 1)
								{
									if(isset($incoming_req_arr[2]) && $incoming_req_arr[2] != "")
										$target_page = "index_cat_list.php";
									else
										$target_page = "index_cat_home.php";
								}
								else if(strtolower($incoming_req_arr[1]) == "tag" || strtolower($incoming_req_arr[1]) == "tags")
								{
									if(isset($incoming_req_arr[2]) && $incoming_req_arr[2] != "")
										$target_page = "index_tag_list.php";
									else
										$target_page = "index_tag_home.php";
								}			
								else if(strtolower($incoming_req_arr[1]) == "archive" || strtolower($incoming_req_arr[1]) == "archives")
								{
									if(isset($incoming_req_arr[2]) && $incoming_req_arr[2] != "")
										$target_page = "index_archive_list.php";
									else
										$target_page = "index_blog.php";		//"index_archive_home.php";
								}
								else if(strtolower($incoming_req_arr[1]) == "search" || strtolower($incoming_req_arr[1]) == "searches")
								{
									$target_page = "blog_search.php";
								}
							}
							else if(count($incoming_req_arr) >= 2)
							{
								if((strtolower($incoming_req_arr[1]) == "category" || strtolower($incoming_req_arr[1]) == $category) && $blog_settings["BLOG_CAT"] == 1)
									$target_page = "index_cat_home.php";			
								else if(strtolower($incoming_req_arr[1]) == "tag" || strtolower($incoming_req_arr[1]) == "tags")
									$target_page = "index_tag_home.php";		
								else if(strtolower($incoming_req_arr[1]) == "archive" || strtolower($incoming_req_arr[1]) == "archives")
									$target_page = "index_archive_home.php";		
								else if($incoming_req_arr[1] == '')
									$target_page = "index_blog.php";	
								else if(strtolower($incoming_req_arr[1]) == "search" || strtolower($incoming_req_arr[1]) == "searches")
									$target_page = "blog_search.php";
								else 		
									$target_page = "blog_pages.php";	
							}
							else
								$target_page = "index_blog.php";
							
							//echo __DIR__.DIRECTORY_SEPARATOR."__CLIENT.APP".DIRECTORY_SEPARATOR."__VIEWS".DIRECTORY_SEPARATOR."__BLOGS".DIRECTORY_SEPARATOR.$target_page;
							//echo $target_page;
							include_once(__DIR__.DIRECTORY_SEPARATOR."__CLIENT.APP".DIRECTORY_SEPARATOR."__VIEWS".DIRECTORY_SEPARATOR."__BLOGS".DIRECTORY_SEPARATOR.$target_page);	
						}
						else
						{
							$pageType = (string) ($web_info[1]['page_content_type'] ?? '');
							StorefrontPaths::requireLib('EcommerceStorefrontUrl.php');
							$pageSlug = EcommerceStorefrontUrl::normalizeStorefrontPathSegment((string) ($web_info[1]['page_link_url'] ?? ''));
							StorefrontPaths::requireLib('DealerWebsitePageSettingsService.php');
							$pageType = DealerWebsitePageSettingsService::resolveStorefrontPageType($pageType, $pageSlug);
							$isDealerFormPage = DealerWebsitePageSettingsService::isDealerFormPageType($pageType);
							$requestedPageSlug = EcommerceStorefrontUrl::normalizeStorefrontPathSegment((string) ($CONFIG->pageId ?? ''));
							$cartRoutes = ['cart-style1', 'cart-style2', 'cart'];
							$checkoutRoutes = ['checkout-style1', 'checkout-style2', 'checkout'];
							$orderSuccessRoutes = ['order-success', 'order-success.html'];
							$compareRoutes = ['compare-style2', 'compare-style1', 'compare'];
							$loginRoutes = ['login'];
							$registerRoutes = ['register'];
							$myAccountRoutes = ['my-account'];
							$isCartRoute = EcommerceStorefrontUrl::matchesStorefrontRoute($requestedPageSlug, $pageSlug, $cartRoutes);
							$isCheckoutRoute = EcommerceStorefrontUrl::matchesStorefrontRoute($requestedPageSlug, $pageSlug, $checkoutRoutes);
							$isOrderSuccessRoute = EcommerceStorefrontUrl::matchesStorefrontRoute($requestedPageSlug, $pageSlug, $orderSuccessRoutes);
							$isCompareRoute = EcommerceStorefrontUrl::matchesStorefrontRoute($requestedPageSlug, $pageSlug, $compareRoutes);
							$isLoginRoute = EcommerceStorefrontUrl::matchesStorefrontRoute($requestedPageSlug, $pageSlug, $loginRoutes);
							$isRegisterRoute = EcommerceStorefrontUrl::matchesStorefrontRoute($requestedPageSlug, $pageSlug, $registerRoutes);
							$isMyAccountRoute = EcommerceStorefrontUrl::matchesStorefrontRoute($requestedPageSlug, $pageSlug, $myAccountRoutes);
							$ecomShopTypes = ['Product_B2C', 'Product_B2B', 'Product_Bulk_B2B', 'Product'];
							$ecom_product_slug = EcommerceStorefrontUrl::parseProductSlugFromPath((string) ($_REQUEST['query_str'] ?? ''));
							if ($ecom_product_slug === '' && strtolower((string) ($CONFIG->pageId ?? '')) === 'product') {
								$qsParts = explode('/', trim((string) ($_REQUEST['query_str'] ?? ''), '/'));
								$ecom_product_slug = EcommerceStorefrontUrl::normalizeProductSlug((string) ($qsParts[count($qsParts) - 1] ?? ''));
							}
							if (!empty($product_enabled) && $ecom_product_slug !== '') {
								$pagePath = trim((string) ($CONFIG->pageId ?? ''), '/');
								if ($pagePath === '' || strtolower($pagePath) === 'product') {
									$pagePath = trim((string) ($web_info[1]['page_link_url'] ?? ''), '/');
								}
								$ecom_product_list_href = rtrim((string) $CONFIG->siteurlHttps, '/') . '/'
									. ($pagePath !== '' ? $pagePath . '/' : '');
								StorefrontPaths::requireLib('EcommerceWebsiteSettingsService.php');
								$ecom_shop_channel = EcommerceWebsiteSettingsService::channelForPageContentType($pageType)
									?? EcommerceWebsiteSettingsService::CHANNEL_B2C;
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/product_detail.inc.php';
							} elseif (!empty($cart_enabled) && $isCartRoute) {
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/cart.inc.php';
							} elseif (!empty($compare_enabled) && $isCompareRoute) {
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/compare.inc.php';
							} elseif (!empty($ecom_storefront_account_enabled) && $isLoginRoute) {
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/login.inc.php';
							} elseif (!empty($ecom_storefront_account_enabled) && $isRegisterRoute) {
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/register.inc.php';
							} elseif (!empty($ecom_storefront_account_enabled) && $isMyAccountRoute) {
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/my_account.inc.php';
							} elseif ($isCheckoutRoute) {
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/checkout.inc.php';
							} elseif ($isOrderSuccessRoute) {
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/order_success.inc.php';
							} elseif (!empty($product_enabled) && in_array($pageType, $ecomShopTypes, true)
								&& !$isCartRoute && !$isCheckoutRoute && !$isOrderSuccessRoute && !$isLoginRoute && !$isRegisterRoute && !$isMyAccountRoute) {
								StorefrontPaths::requireLib('EcommerceWebsiteSettingsService.php');
								$ecom_shop_channel = EcommerceWebsiteSettingsService::channelForPageContentType($pageType)
									?? EcommerceWebsiteSettingsService::CHANNEL_B2C;
								$pagePath = trim((string) ($CONFIG->pageId ?? ''), '/');
								if ($pagePath === '' && $pageSlug !== '') {
									$pagePath = $pageSlug;
								}
								$ecom_shop_page_href = rtrim((string) $CONFIG->siteurlHttps, '/') . '/'
									. ($pagePath !== '' ? rawurlencode($pagePath) . '/' : '');
								include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/shop_list.inc.php';
							} else {
								$pageOut = $master_html_content;
								if ($pageType === 'Tutorial') {
									if (!function_exists('h')) {
										require_once __DIR__ . '/__lib.includes/helpers.storefront.inc.php';
									}
									StorefrontPaths::requireLib('TutorialPluginAccess.php');
									StorefrontPaths::requireLib('TutorialWebsiteSettingsService.php');
									StorefrontPaths::requireLib('TutorialManagementService.php');
									StorefrontPaths::requireLib('TutorialStorefrontService.php');
									if (isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO
										&& TutorialPluginAccess::isActiveForTenant($CONFIG->pdo)) {
										$siteRowId = (int) ($web_info[1]['site_id'] ?? $CONFIG->websiteId ?? $CONFIG->siteId ?? 0);
										if ($siteRowId <= 0) {
											$siteRowId = (int) ($CONFIG->websiteSiteId ?? 0);
										}
										$tutorial_site_id = $siteRowId;
										$tutorial_page_settings = TutorialWebsiteSettingsService::load($CONFIG->pdo, $tutorial_site_id);
										$tutorial_page_href = rtrim((string) $CONFIG->siteurlHttps, '/') . '/'
											. ($pageSlug !== '' ? rawurlencode($pageSlug) . '/' : '');
										$tutorial_storefront_account = null;
										if (!empty($ecom_storefront_account_enabled)) {
											$tutorial_storefront_account = EcommerceStorefrontAccountService::currentAccount($CONFIG->pdo, $tutorial_site_id);
										}
										$assetSlug = TutorialStorefrontService::parseAssetSlugFromPath(
											(string) ($_REQUEST['query_str'] ?? ''),
											$pageSlug !== '' ? $pageSlug : TutorialManagementService::PAGE_SLUG
										);
										if ($assetSlug !== '') {
											$tutorial_asset = TutorialManagementService::getAssetBySlug($CONFIG->pdo, $tutorial_site_id, $assetSlug);
											if (is_array($tutorial_asset)) {
												$tutorial_access = TutorialStorefrontService::resolveAccess(
													$CONFIG->pdo,
													$tutorial_site_id,
													$tutorial_asset,
													$tutorial_page_settings,
													$tutorial_storefront_account
												);
												include __DIR__ . '/__CLIENT.APP/__VIEWS/__TUTORIALS/detail.inc.php';
											}
										} else {
											include __DIR__ . '/__CLIENT.APP/__VIEWS/__TUTORIALS/catalog.inc.php';
										}
									}
								} elseif ($pageType === 'TestDrive') {
									StorefrontPaths::requireLib('DealerPluginAccess.php');
									StorefrontPaths::requireLib('DealerStorefrontTestDriveService.php');
									StorefrontPaths::requireLib('StorefrontPublicUrl.php');
									if (isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO) {
										$apiUrl = StorefrontPublicUrl::dealerTestDriveApiUrl($CONFIG);
										$pageOut = DealerStorefrontTestDriveService::appendToPageHtml($CONFIG->pdo, $pageOut, $apiUrl);
									}
								} elseif ($pageType === 'DealerService') {
									StorefrontPaths::requireLib('DealerPluginAccess.php');
									StorefrontPaths::requireLib('DealerStorefrontServiceAppointmentService.php');
									StorefrontPaths::requireLib('StorefrontPublicUrl.php');
									if (isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO) {
										$apiUrl = StorefrontPublicUrl::dealerServiceAppointmentApiUrl($CONFIG);
										$pageOut = DealerStorefrontServiceAppointmentService::appendToPageHtml($CONFIG->pdo, $pageOut, $apiUrl);
									}
								} elseif ($pageType === 'Appointment') {
									StorefrontPaths::requireLib('ClinicPluginAccess.php');
									StorefrontPaths::requireLib('ClinicStorefrontAppointmentService.php');
									StorefrontPaths::requireLib('StorefrontPublicUrl.php');
									if (isset($CONFIG->pdo) && $CONFIG->pdo instanceof PDO
										&& ClinicPluginAccess::isActiveForTenant($CONFIG->pdo)) {
										$apiUrl = StorefrontPublicUrl::clinicAppointmentApiUrl($CONFIG);
										$pageOut = ClinicStorefrontAppointmentService::appendToPageHtml($CONFIG->pdo, $pageOut, $apiUrl);
									}
								} elseif ($pageType === 'Track' || strtolower($pageSlug) === 'track') {
									include __DIR__ . '/__CLIENT.APP/__VIEWS/__ECOM/track.inc.php';
									$pageOut = '';
								}
								if ($pageOut !== '' || $isDealerFormPage) {
								$pageOut = StorefrontPublishedHtml::rewriteBadTutorialApiUrls((string) $pageOut, $__tutorialApiUrlGlobal);
								echo $pageOut;
								}
							}
						}
                ?>
            </div>
        <div class="footer">
         <?php
		 /********** Footer **********/
			echo $ns_html;
			echo $footer_html;
			echo $cp_html;
			StorefrontPaths::requireLib('EcommerceStorefrontNewsletterUi.php');
			EcommerceStorefrontNewsletterUi::renderScripts(
				$CONFIG,
				is_string($ns_html ?? null) ? (string) $ns_html : '',
				is_string($footer_html ?? null) ? (string) $footer_html : ''
			);
		/********** Footer **********/
		?>
        </div>
        <div id="site-scroll"><i class="icon anm anm-arw-up"></i></div>
        <?php
        if (!empty($cart_enabled)) {
            StorefrontPaths::requireLib('EcommerceStorefrontCartUi.php');
            StorefrontPaths::requireLib('EcommerceStorefrontCartConfig.php');
            $ecomCartHome = rtrim((string) ($CONFIG->siteurlHttps ?? $CONFIG->siteurl ?? ''), '/') . '/';
            $ecomCartHrefs = EcommerceStorefrontCartConfig::resolveHrefPair($CONFIG);
            if ($ecomCartHrefs['cartPageHref'] === '#') {
                $ecomCartHrefs['cartPageHref'] = EcommerceStorefrontUrl::canonicalHref($ecomCartHome, EcommerceStorefrontUrl::CANONICAL_CART);
            } else {
                $cartPath = strtolower((string) parse_url($ecomCartHrefs['cartPageHref'], PHP_URL_PATH));
                if (preg_match('#/cart/?$#', $cartPath) && !str_contains($cartPath, 'cart-style')) {
                    $ecomCartHrefs['cartPageHref'] = EcommerceStorefrontUrl::canonicalHref($ecomCartHome, EcommerceStorefrontUrl::CANONICAL_CART);
                }
            }
            if ($ecomCartHrefs['checkoutPageHref'] === '#') {
                $ecomCartHrefs['checkoutPageHref'] = EcommerceStorefrontUrl::canonicalHref($ecomCartHome, EcommerceStorefrontUrl::CANONICAL_CHECKOUT);
            } else {
                $checkoutPath = strtolower((string) parse_url($ecomCartHrefs['checkoutPageHref'], PHP_URL_PATH));
                if (preg_match('#/checkout/?$#', $checkoutPath) && !str_contains($checkoutPath, 'checkout-style')) {
                    $ecomCartHrefs['checkoutPageHref'] = EcommerceStorefrontUrl::canonicalHref($ecomCartHome, EcommerceStorefrontUrl::CANONICAL_CHECKOUT);
                }
            }
            echo EcommerceStorefrontCartUi::renderMinicartDrawerHtml([
                'home_href' => $ecomCartHome,
                'cart_href' => $ecomCartHrefs['cartPageHref'],
                'checkout_href' => $ecomCartHrefs['checkoutPageHref'],
            ]);
            if (empty($GLOBALS['ecom_storefront_cart_shell_loaded'])) {
                echo EcommerceStorefrontCartUi::renderAddtocartSuccessModalHtml();
                $GLOBALS['ecom_storefront_cart_shell_loaded'] = true;
            }
            echo EcommerceStorefrontCartConfig::renderConfigScript($ecomCartHrefs);
        }
	if (!empty($product_enabled) || !empty($cart_enabled) || !empty($payment_enabled)) {
            StorefrontPaths::requireLib('EcommerceStorefrontI18n.php');
            echo EcommerceStorefrontI18n::renderScriptTag();
        }
        $ecomSfApi = $ecom_sf_account_api ?? StorefrontPublicUrl::ecomStorefrontAccountApiUrl($CONFIG);
        ?>
        <script>window.EcomStorefrontAccountApi = <?= json_encode($ecomSfApi, JSON_THROW_ON_ERROR) ?>;</script>
        <script>window.KischitTutorialApiUrl=<?= json_encode($__tutorialApiUrlGlobal, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES) ?>;</script>
        <script>
        (function () {
            function safeTutorialApi(siteId) {
                var u = typeof window.KischitTutorialApiUrl === 'string' ? window.KischitTutorialApiUrl.trim() : '';
                if (u && /^https?:\/\//i.test(u) && !/[A-Za-z]:[\\/]/.test(u)) {
                    return u;
                }
                var path = window.location.pathname || '/';
                var m = path.match(/^(.*?\/client_store\/\d+\/)/i);
                if (m) {
                    return window.location.origin + m[1].replace(/\/$/, '') + '/api/tutorial';
                }
                siteId = parseInt(siteId, 10) || 1;
                return window.location.origin + '/client_store/' + siteId + '/api/tutorial';
            }
            window.kischitResolveTutorialApiUrl = safeTutorialApi;
            window.KischitTutorialApiUrl = safeTutorialApi(<?= (int) ($CONFIG->storefrontUrlWebId ?? $CONFIG->clientId ?? 1) ?>);
            function stripBadTutorialApiAttrs() {
                document.querySelectorAll('.kischit-tutorial-add-cart, .kischit-tutorial-buy').forEach(function (btn) {
                    var raw = btn.getAttribute('data-api-url') || '';
                    if (raw && /[A-Za-z]:[\\/]/.test(raw)) {
                        btn.removeAttribute('data-api-url');
                    }
                });
            }
            if (document.readyState === 'loading') {
                document.addEventListener('DOMContentLoaded', stripBadTutorialApiAttrs);
            } else {
                stripBadTutorialApiAttrs();
            }
        })();
        </script>
        <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/plugins.js"></script>
        <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/vendor/jquery.elevatezoom.js"></script>
        <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/main.js"></script>
       <script src="<?php echo htmlspecialchars(rtrim((string) $CONFIG->assetsURL, '/') . '/assets/js/jquery-ui.js', ENT_QUOTES, 'UTF-8'); ?>"></script>
       <?php if (!empty($compare_enabled)): ?>
       <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL; ?>assets/css/ecom-storefront-compare.css">
       <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/ecom-storefront-compare.js"></script>
       <?php endif; ?>
       <?php if (!empty($product_enabled) || !empty($cart_enabled) || !empty($payment_enabled)): ?>
       <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/ecom-storefront-i18n.js"></script>
       <?php endif; ?>
       <?php if (!empty($product_enabled)): ?>
       <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL; ?>assets/css/ecom-storefront-product-grid.css">
       <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL; ?>assets/css/ecom-storefront-product-detail.css">
       <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/ecom-storefront-search.js"></script>
       <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/ecom-storefront-product-grid.js" defer></script>
       <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/vendor/photoswipe.min.js"></script>
       <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/ecom-storefront-product-detail.js?v=20260526" defer></script>
       <?php
       $__loadPincodeCheck = !empty($GLOBALS['ecom_load_pincode_check_assets'])
           || (!empty($shipping_enabled) && is_string($master_html_content) && str_contains($master_html_content, 'id="ecomPincodeCheck"'));
       if ($__loadPincodeCheck):
       ?>
       <link rel="stylesheet" href="<?php echo $CONFIG->assetsURL; ?>assets/css/ecom-product-pincode-check.css">
       <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/ecom-product-pincode-check.js?v=20260526"></script>
       <?php endif; ?>
       <?php endif; ?>
       <?php if (!empty($cart_enabled)): ?>
       <script src="<?php echo $CONFIG->assetsURL; ?>assets/js/ecom-storefront-cart.js"></script>
       <?php endif; ?>
    <?php if (!empty($__loadTutorialPurchase)): ?>
    <script src="<?php echo htmlspecialchars((string) $CONFIG->assetsURL, ENT_QUOTES, 'UTF-8'); ?>assets/js/kischit_tutorial_purchase.js?v=20260702" defer></script>
    <?php endif; ?>
      <?php
      StorefrontPaths::requireLib('EcommerceStorefrontContactUi.php');
      EcommerceStorefrontContactUi::renderScripts($CONFIG, (string) $master_html_content);
      echo $page_ext_js_footer;
      ?>
      <script>
      (function () {
          var siteId = <?= (int) ($CONFIG->storefrontUrlWebId ?? $CONFIG->clientId ?? 1) ?>;
          function safeTutorialApi(id) {
              var path = window.location.pathname || '/';
              var m = path.match(/^(.*?\/client_store\/\d+\/)/i);
              if (m) {
                  return window.location.origin + m[1].replace(/\/$/, '') + '/api/tutorial';
              }
              id = parseInt(id, 10) || 1;
              return window.location.origin + '/client_store/' + id + '/api/tutorial';
          }
          var locked = safeTutorialApi(siteId);
          try {
              Object.defineProperty(window, 'KischitTutorialApiUrl', { value: locked, writable: false, configurable: false });
          } catch (e) {
              window.KischitTutorialApiUrl = locked;
          }
          window.kischitResolveTutorialApiUrl = function () { return locked; };
          document.querySelectorAll('.kischit-tutorial-add-cart, .kischit-tutorial-buy').forEach(function (btn) {
              btn.removeAttribute('data-api-url');
          });
      })();
      </script>
   </div>
</body>
</html>