(function ()()

in libs/@guardian/libs/src/consent-management-platform/stub_tcfv2.js [100:176]


				(function () {
					if ('function' != typeof window.__tcfapi) {
						var t,
							e = [],
							n = window,
							r = n.document;
						!n.__tcfapi &&
							(function t() {
								var e = !!n.frames.__tcfapiLocator;
								if (!e)
									if (r.body) {
										var o = r.createElement('iframe');
										(o.style.cssText = 'display:none'),
											(o.name = '__tcfapiLocator'),
											r.body.appendChild(o);
									} else setTimeout(t, 5);
								return !e;
							})() &&
							((n.__tcfapi = function () {
								for (
									var n = arguments.length, r = new Array(n), o = 0;
									o < n;
									o++
								)
									r[o] = arguments[o];
								if (!r.length) return e;
								if ('setGdprApplies' === r[0])
									r.length > 3 &&
										2 === parseInt(r[1], 10) &&
										'boolean' == typeof r[3] &&
										((t = r[3]), 'function' == typeof r[2] && r[2]('set', !0));
								else if ('ping' === r[0]) {
									var i = {
										gdprApplies: t,
										cmpLoaded: !1,
										apiVersion: '2.0',
									};
									'function' == typeof r[2] && r[2](i, !0);
								} else e.push(r);
							}),
							n.addEventListener(
								'message',
								function (t) {
									var e = 'string' == typeof t.data,
										r = {};
									try {
										r = e ? JSON.parse(t.data) : t.data;
									} catch (t) {}
									var o = r.__tcfapiCall;
									// WARNING
									// This function call has been modified from the provided Sourcepoint code.
									// The parameter order has been updated as the original function call was incorrect as per the TCF specification.
									// See:
									// - Required interface: https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#how-does-the-cmp-provide-the-api
									// - Update to function: https://github.com/guardian/consent-management-platform/pull/561/commits/f6113f4a1f8fbe6cec5b4ea8e7b29b969fdb60f3#diff-b58313c0ab5f7b3c35c9d788a1e37e18c982fef7fb8a9b562d728163ffb8a8a1L152
									o &&
										n.__tcfapi(
											o.command,
											o.version,
											function (n, r) {
												var i = {
													__tcfapiReturn: {
														returnValue: n,
														success: r,
														callId: o.callId,
													},
												};
												e && (i = JSON.stringify(i)),
													t.source.postMessage(i, '*');
											},
											o.parameter,
										);
								},
								!1,
							));
					}
				})();