"use strict";
var pipelineRequest = function () {
var nextRequestId = 1;
var pipelineHandlers = {};
window.addEventListener("message", function (event) {
if (event.source === window.top && typeof event.data === "string") {
try {
var message = JSON.parse(event.data);
} catch (e) {
return;
}
if (message.pipeline && message.id) {
if (pipelineHandlers[message.id]) {
pipelineHandlers[message.id](message.payload);
delete pipelineHandlers[message.id];
} else {
console.log("Unexpected id #" + message.id + " for " + message.eventName);
}
}
}
});
return function (eventName, payload, callback) {
var id = nextRequestId++;
if (typeof callback === "function") {
pipelineHandlers[id] = callback;
}
window.top.postMessage(JSON.stringify({
pipeline: true,
id: id,
eventName: eventName,
payload: payload
}), "*");
};
}();
function sendToGTM(_ref) {
var label = _ref.label,
trigger = _ref.trigger,
action = _ref.action,
value = _ref.value,
pipelineEvent = _ref.pipelineEvent;
pipelineEvent = pipelineEvent || "gtm_event";
pipelineRequest(pipelineEvent, {
label: label,
trigger: trigger,
action: action,
value: value
});
}
function setDataLayerForGTM(data) {
pipelineRequest("gtm_datalayer", data);
}
function setTerms(offerId, terms) {
pipelineRequest("set_terms", {
offerId: offerId,
terms: terms
});
}
function sendGtmRemoveFromCart(data) {
pipelineRequest("gtm_remove_from_cart", data);
}
function sendGtmAddToCart(data) {
pipelineRequest("gtm_add_to_cart", data);
}
function sendGtmImpressions(data) {
pipelineRequest("gtm_set_impressions", data);
}
function setCookie(cookieName, cookieValue, expireDay, cookiePath) {
pipelineRequest("set_cookie", {
cookieName: cookieName,
cookieValue: cookieValue,
expireDay: expireDay,
cookiePath: cookiePath
});
}
function registerNewsletter(email) {
pipelineRequest("register_newsletter", {
email: email
});
}
function setModalDetails(modalName, modalParams) {
pipelineRequest("set_modal_details", {
modalName: modalName,
modalParams: modalParams
});
}
function addStyle(styleObj) {
var style = document.createElement('style');
style.type = 'text/css';
var text = "";
for (var key in styleObj) {
text += key + " {\n";
for (var attr in styleObj[key]) {
text += " " + attr + ": " + styleObj[key][attr] + ";\n";
}
text += "}\n\n";
}
style.innerHTML = text;
document.getElementsByTagName('head')[0].appendChild(style);
}
function addScript(src, attrs) {
var script = document.createElement("script");
document.getElementsByTagName("head")[0].appendChild(script);
for (var attr in attrs) {
script.setAttribute(attr, attrs[attr]);
}
script.setAttribute("type", "text/javascript");
script.setAttribute("src", src);
}
var getHostName = function () {
var callbacks = [];
var hostname = null;
pipelineRequest("get_suzuka", undefined, function (payload) {
hostname = payload.url;
for (var x = 0; x < callbacks.length; x++) {
callbacks[x](hostname);
}
callbacks = null;
});
return function (callback) {
if (callbacks !== null) {
callbacks.push(callback);
} else {
callback(hostname);
}
};
}();
var getHash = function () {
var callbacks = [];
var hash = null;
pipelineRequest("get_hash", undefined, function (payload) {
hash = payload.hash;
for (var x = 0; x < callbacks.length; x++) {
callbacks[x](hash);
}
callbacks = null;
});
return function (callback) {
if (callbacks !== null) {
callbacks.push(callback);
} else {
callback(hash);
}
};
}();
var getHasBeta = function () {
var callbacks = [];
var data = null;
pipelineRequest("get_has_beta", undefined, function (payload) {
data = payload;
for (var x = 0; x < callbacks.length; x++) {
callbacks[x](data);
}
callbacks = null;
});
return function (callback) {
if (callbacks !== null) {
callbacks.push(callback);
} else {
callback(data);
}
};
}();
var getRegistrationOnly = function () {
var callbacks = [];
var data = null;
pipelineRequest("get_registration_only", undefined, function (payload) {
data = payload;
for (var x = 0; x < callbacks.length; x++) {
callbacks[x](data);
}
callbacks = null;
});
return function (callback) {
if (callbacks !== null) {
callbacks.push(callback);
} else {
callback(data);
}
};
}();
var getCustomUserAddress = function () {
var callbacks = [];
var data = null;
pipelineRequest("get_custom_user_address", undefined, function (payload) {
data = payload;
for (var x = 0; x < callbacks.length; x++) {
callbacks[x](data);
}
callbacks = null;
});
return function (callback) {
if (callbacks !== null) {
callbacks.push(callback);
} else {
callback(data);
}
};
}();
function urlEncode(data) {
var result = [];
for (var key in data) {
result.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
}
return result.join('&');
}
function request(url, method, params, data, callback) {
var handled = false;
var handle = function handle(data) {
if (!handled) {
handled = true;
callback(data);
}
};
setTimeout(function () {
handle(null);
}, 10 * 1000);
if (params) {
url += '?' + urlEncode(params);
}
var xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.onload = function onload() {
if (this.status >= 200 && this.status < 300) {
var contentType = xhr.getResponseHeader('Content-Type');
if (contentType.split(',')[0] === 'application/json') {
try {
handle(JSON.parse(this.response));
} catch (e) {
console.error(e);
handle(null);
}
} else {
handle(null);
}
} else {
handle(null);
}
};
xhr.onerror = function onerror() {
handle(null);
};
if (method === 'POST') {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
xhr.send(urlEncode(data));
} else {
xhr.send();
}
}
function getClosest(element, tagName) {
while (element) {
if (element.tagName === tagName) {
return element;
}
element = element.parentElement;
}
return null;
}
function triggerInteraction(_ref2) {
var selector = _ref2.selector,
funcName = _ref2.funcName;
pipelineRequest("trigger_interaction", {
selector: selector,
funcName: funcName
});
}
function saveSelectedTerm(termId) {
pipelineRequest("save_selected_term", {
termId: termId
});
}
var getSelectedTerm = function () {
var callbacks = [];
var termId = null;
pipelineRequest("get_selected_term", undefined, function (payload) {
termId = payload.termId;
for (var x = 0; x < callbacks.length; x++) {
callbacks[x](termId);
}
callbacks = null;
});
return function (callback) {
if (callbacks !== null) {
callbacks.push(callback);
} else {
callback(termId);
}
};
}();
function sendCommercialPurchase($purchaseScope) {
sha256("".concat($purchaseScope.user.uid).concat(Date.now())).then(function (uniqueHash) {
var _$purchaseScope$input, _$purchaseScope$input2;
var selectedTerm = $purchaseScope.selectedTerm;
var taxAmount = selectedTerm.taxAmount || "0";
var cost = selectedTerm.price.indexOf("AUD") === 0 ? selectedTerm.price.slice(3) : Number(selectedTerm.chargeAmount).toFixed(2);
var value = selectedTerm.isZero ? "0" : cost;
var transactionId = ((_$purchaseScope$input = $purchaseScope.input) === null || _$purchaseScope$input === void 0 ? void 0 : (_$purchaseScope$input2 = _$purchaseScope$input.receipt) === null || _$purchaseScope$input2 === void 0 ? void 0 : _$purchaseScope$input2.paymentId) || uniqueHash;
pipelineRequest('gtm_set_commercial_purchase', {
id: selectedTerm.termId,
affiliation: 'Subscription',
revenue: value,
tax: taxAmount.indexOf("AUD") === 0 ? taxAmount.slice(3) : taxAmount,
coupon: $purchaseScope.input.promoCode || '',
type: $purchaseScope.flags.selectedPaymentMethod.identifier || 'Free',
transactionId: transactionId,
value: value
});
});
}
function sendBeginCheckout(termId) {
pipelineRequest('begin_checkout', {
termId: termId
});
}
function sha256(input) {
return new Promise(function (resolve) {
var textAsBuffer = new TextEncoder().encode(input);
window.crypto.subtle.digest("SHA-256", textAsBuffer).then(function (hashBuffer) {
resolve(Array.from(new Uint8Array(hashBuffer)).map(function (item) {
return item.toString(16).padStart(2, "0");
}).join(""));
});
});
}
;
/*function initSentry() {
Sentry.init({
dsn: 'https://2cc3647bcd8c4c0ca638ff1e1c2e9003@sentry.io/2253432'
});
}
addScript("https://browser.sentry-cdn.com/5.12.0/bundle.min.js", {
onload: "initSentry()",
integrity: "sha384-628yQYiY4aWhtsw5Qy17Mmuij8Qwsu5EeUbhpWDRUBkxa41oNaPoXwVJ7+dH7CJb",
crossorigin: "anonymous",
});*/
{{activeMeters[0].viewsLeft}} / {{activeMeters[0].maxViews}} free articles remaining | For Unlimited Access
SUBSCRIBE
"use strict";
var $scope = angular.element(document.getElementById('meter-banner')).scope();
$scope.$watch('params', function () {
var _$scope$params;
if ($scope !== null && $scope !== void 0 && (_$scope$params = $scope.params) !== null && _$scope$params !== void 0 && _$scope$params.url) {
$scope.escapedUrl = encodeURIComponent($scope.params.url);
}
});