var detectIncognito = function () { return new Promise(function (o, n) { var e, t = "Unknown"; function i(e) { o({ isPrivate: e, browserName: t }) } function r(e) { return e === eval.toString().length } function a() { var e, o = window; void 0 !== navigator.maxTouchPoints ? void 0 !== o.safari && void 0 === o.DeviceMotionEvent ? (t = "Safari for macOS", function () { try { window.safari.pushNotification.requestPermission("https://example.com", "private", {}, function () { }) } catch (e) { return i(!new RegExp("gesture").test(e)) } i(!1) }()) : void 0 !== o.DeviceMotionEvent ? (e = !(t = "Safari for iOS"), (o = document.createElement("iframe")).style.display = "none", document.body.appendChild(o), o.contentWindow.applicationCache.addEventListener("error", function () { return i(e = !0) }), setTimeout(function () { e || i(!1) }, 100)) : n(new Error("detectIncognito Could not identify this version of Safari")) : (t = "Safari", function () { var e = window.openDatabase, o = window.localStorage; try { e(null, null, null, null) } catch (e) { return i(!0) } try { o.setItem("test", "1"), o.removeItem("test") } catch (e) { return i(!0) } i(!1) }()) } function c() { navigator.webkitTemporaryStorage.queryUsageAndQuota(function (e, o) { i(o < (void 0 !== (o = window).performance && void 0 !== o.performance.memory && void 0 !== o.performance.memory.jsHeapSizeLimit ? performance.memory.jsHeapSizeLimit : 1073741824)) }, function (e) { n(new Error("detectIncognito somehow failed to query storage quota: " + e.message)) }) } function d() { void 0 !== Promise && void 0 !== Promise.allSettled ? c() : (0, window.webkitRequestFileSystem)(0, 1, function () { i(!1) }, function () { i(!0) }) } void 0 !== (e = navigator.vendor) && 0 === e.indexOf("Apple") && r(37) ? a() : void 0 !== (e = navigator.vendor) && 0 === e.indexOf("Google") && r(33) ? (e = navigator.userAgent, t = e.match(/Chrome/) ? void 0 !== navigator.brave ? "Brave" : e.match(/Edg/) ? "Edge" : e.match(/OPR/) ? "Opera" : "Chrome" : "Chromium", d()) : void 0 !== document.documentElement && void 0 !== document.documentElement.style.MozAppearance && r(37) ? (t = "Firefox", i(void 0 === navigator.serviceWorker)) : void 0 !== navigator.msSaveBlob && r(39) ? (t = "Internet Explorer", i(void 0 === window.indexedDB)) : n(new Error("detectIncognito cannot determine the browser")) }) };

var thisPageUsingOtherJSLibrary = false;

// Only do anything if jQuery isn't defined
if (typeof jQuery == 'undefined') {

	if (typeof $ == 'function') {
		// warning, global var
		thisPageUsingOtherJSLibrary = true;
	}

	function getScript(url, success) {

		var script = document.createElement('script');
		script.src = url;

		var head = document.getElementsByTagName('head')[0],
			done = false;

		// Attach handlers for all browsers
		script.onload = script.onreadystatechange = function () {

			if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {

				done = true;

				// callback function provided as param
				success();

				script.onload = script.onreadystatechange = null;
				head.removeChild(script);

			};

		};

		head.appendChild(script);

	};

	getScript('https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js', function () {

		if (typeof jQuery == 'undefined') {

			// Super failsafe - still somehow failed...

		} else {

			$.noConflict(true);

			if (thisPageUsingOtherJSLibrary) {

				runTicketShopCode();

			} else {

				runTicketShopCode();

			}

		}

	});

} else { // jQuery was already loaded

	runTicketShopCode();

};

function runTicketShopCode() {
	var script_tag = document.getElementById('shopscript-eventgoose');
	var query = script_tag.src.replace(/^[^\?]+\??/, '');
	// Parse the querystring into arguments and parameters
	var vars = query.split("&");
	var args = {};
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		// decodeURI doesn't expand "+" to a space.
		args[pair[0]] = decodeURI(pair[1]).replace(/\+/g, ' ');
	}
	var shopUrl = args['shopurl'];

	// var is_safari = navigator.userAgent.indexOf("Safari") > -1;
	// var is_chrome = navigator.userAgent.indexOf('Chrome') > -1;
	// var is_facebook = navigator.userAgent.indexOf('FBAN') > -1;
	// if ((is_chrome) && (is_safari)) { is_safari = false; }

	var parentUrl = parent.document.URL;

	// detectIncognito()
	// 	.then(function (result) {
	// 		if (result.isPrivate) {
	// 			$('#shop-frame').remove();
	// 			$('.shop-trigger').off();
	// 			jQuery(document).on('click', '.shop-trigger', function () {
	// 				window.open(shopUrl + '/safari', '_blank');
	// 			});
	// 		} else {
	// 			if (!is_safari && !is_facebook) {
	// 				jQuery('body').append('<iframe id="shop-frame" style="position:fixed; top:0px; left:0px; width:100%; height: 100%; z-index: -1; opacity: 0; display: block;" src="' + shopUrl + '?parenturl=' + parentUrl + '"></iframe>');
	// 			}

	// 			jQuery(document).on('click', '.shop-trigger', function () {

	// 				if (is_safari || is_facebook) {
	// 					window.open(shopUrl + '/safari', '_blank');
	// 				}
	// 				else {
	// 					jQuery('#shop-frame').css('z-index', '999999999999');
	// 					jQuery('#shop-frame').fadeTo(400, 1);
	// 				}
	// 			});
	// 		}
	// 	})
	// 	.catch(function (error) { console.error(error) });

	// var _trigger = document.getElementsByClassName('shop-trigger')[0];
	// _trigger.addEventListener("click", function (e) {
	// 	if (is_safari || is_facebook) {
	// 		window.open(shopUrl + '/safari', '_blank');
	// 	} else {
	// 		window.open(shopUrl, '_blank');
	// 	}
	// }, false);

	// if (!is_safari && !is_facebook) {
	// jQuery('body').append('<iframe id="shop-frame" style="position:fixed; top:0px; left:0px; width:100%; height: 100%; z-index: -1; opacity: 0; display: block;" src="' + shopUrl + '?parenturl=' + parentUrl + '"></iframe>');
	// }
	jQuery('body').append('<iframe id="shop-frame" style="position:fixed; top:0px; left:0px; width:100%; height: 100%; z-index: -1; opacity: 0; display: block;" src="' + shopUrl + '?parenturl=' + parentUrl + '"></iframe>');

	jQuery(document).on('click', '.shop-trigger', function () {
		jQuery('#shop-frame').css('z-index', '999999999999');
		jQuery('#shop-frame').fadeTo(400, 1);
		// if (is_safari || is_facebook) {
		// 	window.open(shopUrl + '/safari', '_blank');
		// }
		// else {
		// 	jQuery('#shop-frame').css('z-index', '999999999999');
		// 	jQuery('#shop-frame').fadeTo(400, 1);
		// }
	});

}


