New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@entur/utils

Package Overview
Dependencies
Maintainers
0
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@entur/utils - npm Package Compare versions

Comparing version 0.12.1 to 1.0.0-alpha.0

dist/consentUtils.d.ts

1

dist/index.d.ts

@@ -14,1 +14,2 @@ export * from './PolymorphicComponent';

export * from './getNodeText';
export * from './consentUtils';
export * from './variants';
export * from './usercentrics';

@@ -7,2 +7,3 @@ 'use strict';

var warning = require('tiny-warning');
var tokens = require('@entur/tokens');

@@ -206,3 +207,450 @@ function useDebounce(callBack, debounceTime) {

function _regeneratorRuntime() {
_regeneratorRuntime = function () {
return exports;
};
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
defineProperty = Object.defineProperty || function (obj, key, desc) {
obj[key] = desc.value;
},
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function (obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return defineProperty(generator, "_invoke", {
value: makeInvokeMethod(innerFn, self, context)
}), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
defineProperty(this, "_invoke", {
value: function (method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}
function maybeInvokeDelegate(delegate, context) {
var methodName = context.method,
method = delegate.iterator[methodName];
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
value: GeneratorFunctionPrototype,
configurable: !0
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: !0
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (val) {
var object = Object(val),
keys = [];
for (var key in object) keys.push(key);
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function (skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
},
stop: function () {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function (exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function (record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
catch: function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function (iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
var CMP_INITIALIZE_EVENT = 'UC_UI_INITIALIZED';
var CONSENT_UPDATED_EVENT = 'UC_CONSENT';
var CMP_SHADOW_ROOT_ID = 'usercentrics-cmp-ui';
var acceptAllConsents = function acceptAllConsents() {
return window.__ucCmp.acceptAllConsents();
};
var denyAllConsents = function denyAllConsents() {
return window.__ucCmp.denyAllConsents();
};
var updateServicesConsents = function updateServicesConsents(serviceConsents) {
return window.__ucCmp.updateServicesConsents(serviceConsents);
};
var changeLanguage = function changeLanguage(language) {
return window.__ucCmp.changeLanguage(language);
};
var showCookieBanner = function showCookieBanner() {
return window.__ucCmp.showFirstLayer();
};
var hideCookieBanner = function hideCookieBanner() {
return window.__ucCmp.closeCmp();
};
function styleCookieBanner() {
return _styleCookieBanner.apply(this, arguments);
}
function _styleCookieBanner() {
_styleCookieBanner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var _cmpElement$shadowRoo;
var cmpElement, sheet;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return waitForElementWithId(CMP_SHADOW_ROOT_ID);
case 2:
cmpElement = document.getElementById(CMP_SHADOW_ROOT_ID);
console.log('cmp', cmpElement);
sheet = new CSSStyleSheet();
sheet.replaceSync(cmpStyleSheet);
cmpElement == null ? void 0 : (_cmpElement$shadowRoo = cmpElement.shadowRoot) == null ? void 0 : _cmpElement$shadowRoo.adoptedStyleSheets.push(sheet);
case 7:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _styleCookieBanner.apply(this, arguments);
}
function formatConsentEvent(event) {
var _event$detail$service, _event$detail;
return Object.entries((_event$detail$service = event == null ? void 0 : (_event$detail = event.detail) == null ? void 0 : _event$detail.services) != null ? _event$detail$service : {}).map(function (service) {
var _service$1$consent$gi, _service$1$consent;
return {
id: service[0],
name: service[1].name,
consentGiven: (_service$1$consent$gi = (_service$1$consent = service[1].consent) == null ? void 0 : _service$1$consent.given) != null ? _service$1$consent$gi : false,
category: service[1].category
};
});
}
var cookieBanner = {
acceptAllConsents: acceptAllConsents,
denyAllConsents: denyAllConsents,
updateServicesConsents: updateServicesConsents,
changeLanguage: changeLanguage,
showCookieBanner: showCookieBanner,
hideCookieBanner: hideCookieBanner,
eventListner: {
CONSENT_UPDATED_EVENT: CONSENT_UPDATED_EVENT,
CMP_INITIALIZE_EVENT: CMP_INITIALIZE_EVENT
},
formatConsentEvent: formatConsentEvent
};
if (typeof window !== 'undefined') styleCookieBanner();
/** Utils */
// Returns true when element with id is available in the DOM
function waitForElementWithId(_x) {
return _waitForElementWithId.apply(this, arguments);
}
/** Stylesheet for CookieBanner */
function _waitForElementWithId() {
_waitForElementWithId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(selector) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
return _context2.abrupt("return", new Promise(function (resolve) {
var observer = new MutationObserver(function (_, observer) {
var element = document.querySelector('#' + selector);
if (element) {
observer.disconnect();
resolve(true);
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}));
case 1:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _waitForElementWithId.apply(this, arguments);
}
var cmpStyleSheet = "\n .cmp-wrapper.cmp-wrapper.cmp-wrapper { \n width: 100%;\n\n .cmp:not(.second) {\n padding: " + tokens.space.rem.large + "rem calc((100dvw - 54rem) / 2);\n border-radius: unset;\n box-shadow: " + tokens.shadows.cardShadow + ";\n\n .language-selector-menu {\n right: calc((100dvw - 64rem) / 2);\n }\n } \n\n .privacy-title {\n font-size: " + tokens.fontSizes.rem.extraLarge2 + "rem;\n }\n .privacy-text {\n font-size: " + tokens.fontSizes.rem.large + "rem;\n line-height: " + tokens.lineHeights.rem.large + "rem;\n }\n\n\n .buttons-row {\n justify-content: flex-end;\n }\n\n button[data-action=\"consent\"] {\n flex-grow: unset;\n flex-basis: unset;\n width: fit-content;\n min-width: 9.5rem;\n height: 3rem;\n cursor: pointer;\n font-size: 1rem;\n line-height: 1.5rem;\n font-weight: 500;\n \n &[data-action-type=\"accept\"] {\n background-color: var(--components-button-primary-contrast-default);\n color: var(--components-button-primary-contrast-text);\n\n &:hover {\n background-color: var(--components-button-primary-contrast-hover);\n }\n }\n \n &[data-action-type=\"more\"],\n &[data-action-type=\"deny\"] {\n background-color: transparent;\n color: var(--components-button-secondary-contrast-text);\n border: 2px solid var(--components-button-secondary-contrast-border);\n\n &:hover {\n background-color: var(--components-button-secondary-contrast-hover);\n }\n }\n }\n\n .poweredBy {\n display: none;\n }\n }\n";
exports.CMP_INITIALIZE_EVENT = CMP_INITIALIZE_EVENT;
exports.CONSENT_UPDATED_EVENT = CONSENT_UPDATED_EVENT;
exports.ConditionalWrapper = ConditionalWrapper;
exports.cmpStyleSheet = cmpStyleSheet;
exports.cookieBanner = cookieBanner;
exports.getNodeText = getNodeText;

@@ -217,3 +665,4 @@ exports.mergeRefs = mergeRefs;

exports.useWindowDimensions = useWindowDimensions;
exports.waitForElementWithId = waitForElementWithId;
exports.warnAboutMissingStyles = warnAboutMissingStyles;
//# sourceMappingURL=utils.cjs.development.js.map

2

dist/utils.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react");require("tiny-warning");var e=function(){if("undefined"==typeof window)return{width:void 0,height:void 0};var n=window;return{width:n.innerWidth,height:n.innerHeight}};exports.ConditionalWrapper=function(e){var t=e.children;return e.condition?(0,e.wrapper)(t):n.createElement(n.Fragment,null,t)},exports.getNodeText=function n(e){var t,r;return null==e?"":["string","number"].includes(typeof e)?e.toString():e instanceof Array?e.map(n).join("").trim():"object"==typeof e?n(null!=(t=null==(r=e.props)?void 0:r.children)?t:"").trim():"unknown"},exports.mergeRefs=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return function(n){for(var t=0,r=e;t<r.length;t++){var o=r[t];"function"==typeof o?o(n):o&&(o.current=n)}}},exports.useDebounce=function(e,t){var r=n.useRef();return n.useEffect((function(){return function(){r.current&&clearTimeout(r.current)}}),[]),function(){for(var n=arguments.length,o=new Array(n),u=0;u<n;u++)o[u]=arguments[u];r.current&&clearTimeout(r.current),r.current=setTimeout((function(){e.apply(void 0,o)}),t)}},exports.useForceUpdate=function(){var e=n.useState(0)[1];return function(){return e((function(n){return n+1}))}},exports.useOnClickOutside=function(e,t){n.useEffect((function(){var n=function(n){e.some((function(e){return function(n,e){return!(!n||!(n.contains(e.target)||e.composed&&e.composedPath&&e.composedPath().find((function(e){return e!==window&&n.contains(e)}))))}(e.current,n)}))||t()};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),function(){document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}}),[e,t])},exports.useOnEscape=function(e,t){n.useEffect((function(){var n=function(n){"Escape"===n.key&&t()},r=e.current;return null==r||r.addEventListener("keydown",n),function(){return null==r?void 0:r.removeEventListener("keydown",n)}}),[e,t])},exports.useOnMount=function(e){var t=n.useRef(!1);n.useEffect((function(){t.current||(t.current=!0,e())}),[e])},exports.useRandomId=function(e){return e+"-"+n.useRef(String(Math.random()).substring(2)).current},exports.useWindowDimensions=function(){var t=n.useState(e()),r=t[0],o=t[1];return n.useEffect((function(){function n(){o(e())}if("undefined"!=typeof window)return window.addEventListener("resize",n),function(){return window.removeEventListener("resize",n)}}),[]),r},exports.warnAboutMissingStyles=function(){};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");require("tiny-warning");var n=require("@entur/tokens"),e=function(){if("undefined"==typeof window)return{width:void 0,height:void 0};var t=window;return{width:t.innerWidth,height:t.innerHeight}};function r(){r=function(){return t};var t={},n=Object.prototype,e=n.hasOwnProperty,o=Object.defineProperty||function(t,n,e){t[n]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{s({},"")}catch(t){s=function(t,n,e){return t[n]=e}}function f(t,n,e,r){var i=Object.create((n&&n.prototype instanceof d?n:d).prototype),a=new C(r||[]);return o(i,"_invoke",{value:b(t,e,a)}),i}function l(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var p={};function d(){}function h(){}function v(){}var y={};s(y,a,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(O([])));w&&w!==n&&e.call(w,a)&&(y=w);var g=v.prototype=d.prototype=Object.create(y);function x(t){["next","throw","return"].forEach((function(n){s(t,n,(function(t){return this._invoke(n,t)}))}))}function E(t,n){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&e.call(f,"__await")?n.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):n.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,e){function o(){return new n((function(n,o){r(t,e,n,o)}))}return i=i?i.then(o,o):o()}})}function b(t,n,e){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var c=L(a,e);if(c){if(c===p)continue;return c}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===r)throw r="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);r="executing";var u=l(t,n,e);if("normal"===u.type){if(r=e.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(r="completed",e.method="throw",e.arg=u.arg)}}}function L(t,n){var e=n.method,r=t.iterator[e];if(void 0===r)return n.delegate=null,"throw"===e&&t.iterator.return&&(n.method="return",n.arg=void 0,L(t,n),"throw"===n.method)||"return"!==e&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+e+"' method")),p;var o=l(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,p;var i=o.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,p):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,p)}function _(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function S(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function O(t){if(t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function n(){for(;++r<t.length;)if(e.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=void 0,n.done=!0,n};return o.next=o}}return{next:k}}function k(){return{value:void 0,done:!0}}return h.prototype=v,o(g,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:h,configurable:!0}),h.displayName=s(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===h||"GeneratorFunction"===(n.displayName||n.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},x(E.prototype),s(E.prototype,c,(function(){return this})),t.AsyncIterator=E,t.async=function(n,e,r,o,i){void 0===i&&(i=Promise);var a=new E(f(n,e,r,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(g),s(g,u,"Generator"),s(g,a,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var n=Object(t),e=[];for(var r in n)e.push(r);return e.reverse(),function t(){for(;e.length;){var r=e.pop();if(r in n)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=O,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var n in this)"t"===n.charAt(0)&&e.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(e,r){return a.type="throw",a.arg=t,n.next=e,r&&(n.method="next",n.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=e.call(i,"catchLoc"),u=e.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,n){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=n,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),p},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),S(e),p}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var r=e.completion;if("throw"===r.type){var o=r.arg;S(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,e){return this.delegate={iterator:O(t),resultName:n,nextLoc:e},"next"===this.method&&(this.arg=void 0),p}},t}function o(t,n,e,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?n(u):Promise.resolve(u).then(r,o)}function i(t){return function(){var n=this,e=arguments;return new Promise((function(r,i){var a=t.apply(n,e);function c(t){o(a,r,i,c,u,"next",t)}function u(t){o(a,r,i,c,u,"throw",t)}c(void 0)}))}}var a="UC_UI_INITIALIZED",c="UC_CONSENT",u="usercentrics-cmp-ui";function s(){return(s=i(r().mark((function t(){var n,e,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,l(u);case 2:e=document.getElementById(u),console.log("cmp",e),(o=new CSSStyleSheet).replaceSync(d),null==e||null==(n=e.shadowRoot)||n.adoptedStyleSheets.push(o);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var f={acceptAllConsents:function(){return window.__ucCmp.acceptAllConsents()},denyAllConsents:function(){return window.__ucCmp.denyAllConsents()},updateServicesConsents:function(t){return window.__ucCmp.updateServicesConsents(t)},changeLanguage:function(t){return window.__ucCmp.changeLanguage(t)},showCookieBanner:function(){return window.__ucCmp.showFirstLayer()},hideCookieBanner:function(){return window.__ucCmp.closeCmp()},eventListner:{CONSENT_UPDATED_EVENT:c,CMP_INITIALIZE_EVENT:a},formatConsentEvent:function(t){var n,e;return Object.entries(null!=(n=null==t||null==(e=t.detail)?void 0:e.services)?n:{}).map((function(t){var n,e;return{id:t[0],name:t[1].name,consentGiven:null!=(n=null==(e=t[1].consent)?void 0:e.given)&&n,category:t[1].category}}))}};function l(t){return p.apply(this,arguments)}function p(){return(p=i(r().mark((function t(n){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){new MutationObserver((function(e,r){document.querySelector("#"+n)&&(r.disconnect(),t(!0))})).observe(document.body,{childList:!0,subtree:!0})})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}"undefined"!=typeof window&&function(){s.apply(this,arguments)}();var d="\n .cmp-wrapper.cmp-wrapper.cmp-wrapper { \n width: 100%;\n\n .cmp:not(.second) {\n padding: "+n.space.rem.large+"rem calc((100dvw - 54rem) / 2);\n border-radius: unset;\n box-shadow: "+n.shadows.cardShadow+";\n\n .language-selector-menu {\n right: calc((100dvw - 64rem) / 2);\n }\n } \n\n .privacy-title {\n font-size: "+n.fontSizes.rem.extraLarge2+"rem;\n }\n .privacy-text {\n font-size: "+n.fontSizes.rem.large+"rem;\n line-height: "+n.lineHeights.rem.large+'rem;\n }\n\n\n .buttons-row {\n justify-content: flex-end;\n }\n\n button[data-action="consent"] {\n flex-grow: unset;\n flex-basis: unset;\n width: fit-content;\n min-width: 9.5rem;\n height: 3rem;\n cursor: pointer;\n font-size: 1rem;\n line-height: 1.5rem;\n font-weight: 500;\n \n &[data-action-type="accept"] {\n background-color: var(--components-button-primary-contrast-default);\n color: var(--components-button-primary-contrast-text);\n\n &:hover {\n background-color: var(--components-button-primary-contrast-hover);\n }\n }\n \n &[data-action-type="more"],\n &[data-action-type="deny"] {\n background-color: transparent;\n color: var(--components-button-secondary-contrast-text);\n border: 2px solid var(--components-button-secondary-contrast-border);\n\n &:hover {\n background-color: var(--components-button-secondary-contrast-hover);\n }\n }\n }\n\n .poweredBy {\n display: none;\n }\n }\n';exports.CMP_INITIALIZE_EVENT=a,exports.CONSENT_UPDATED_EVENT=c,exports.ConditionalWrapper=function(n){var e=n.children;return n.condition?(0,n.wrapper)(e):t.createElement(t.Fragment,null,e)},exports.cmpStyleSheet=d,exports.cookieBanner=f,exports.getNodeText=function t(n){var e,r;return null==n?"":["string","number"].includes(typeof n)?n.toString():n instanceof Array?n.map(t).join("").trim():"object"==typeof n?t(null!=(e=null==(r=n.props)?void 0:r.children)?e:"").trim():"unknown"},exports.mergeRefs=function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];return function(t){for(var e=0,r=n;e<r.length;e++){var o=r[e];"function"==typeof o?o(t):o&&(o.current=t)}}},exports.useDebounce=function(n,e){var r=t.useRef();return t.useEffect((function(){return function(){r.current&&clearTimeout(r.current)}}),[]),function(){for(var t=arguments.length,o=new Array(t),i=0;i<t;i++)o[i]=arguments[i];r.current&&clearTimeout(r.current),r.current=setTimeout((function(){n.apply(void 0,o)}),e)}},exports.useForceUpdate=function(){var n=t.useState(0)[1];return function(){return n((function(t){return t+1}))}},exports.useOnClickOutside=function(n,e){t.useEffect((function(){var t=function(t){n.some((function(n){return function(t,n){return!(!t||!(t.contains(n.target)||n.composed&&n.composedPath&&n.composedPath().find((function(n){return n!==window&&t.contains(n)}))))}(n.current,t)}))||e()};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),function(){document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}}),[n,e])},exports.useOnEscape=function(n,e){t.useEffect((function(){var t=function(t){"Escape"===t.key&&e()},r=n.current;return null==r||r.addEventListener("keydown",t),function(){return null==r?void 0:r.removeEventListener("keydown",t)}}),[n,e])},exports.useOnMount=function(n){var e=t.useRef(!1);t.useEffect((function(){e.current||(e.current=!0,n())}),[n])},exports.useRandomId=function(n){return n+"-"+t.useRef(String(Math.random()).substring(2)).current},exports.useWindowDimensions=function(){var n=t.useState(e()),r=n[0],o=n[1];return t.useEffect((function(){function t(){o(e())}if("undefined"!=typeof window)return window.addEventListener("resize",t),function(){return window.removeEventListener("resize",t)}}),[]),r},exports.waitForElementWithId=l,exports.warnAboutMissingStyles=function(){};
//# sourceMappingURL=utils.cjs.production.min.js.map
import React, { useRef, useEffect, useState } from 'react';
import warning from 'tiny-warning';
import { space, shadows, fontSizes, lineHeights } from '@entur/tokens';

@@ -201,3 +202,446 @@ function useDebounce(callBack, debounceTime) {

export { ConditionalWrapper, getNodeText, mergeRefs, useDebounce, useForceUpdate, useOnClickOutside, useOnEscape, useOnMount, useRandomId, useWindowDimensions, warnAboutMissingStyles };
function _regeneratorRuntime() {
_regeneratorRuntime = function () {
return exports;
};
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
defineProperty = Object.defineProperty || function (obj, key, desc) {
obj[key] = desc.value;
},
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function (obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return defineProperty(generator, "_invoke", {
value: makeInvokeMethod(innerFn, self, context)
}), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
defineProperty(this, "_invoke", {
value: function (method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}
function maybeInvokeDelegate(delegate, context) {
var methodName = context.method,
method = delegate.iterator[methodName];
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
value: GeneratorFunctionPrototype,
configurable: !0
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: !0
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (val) {
var object = Object(val),
keys = [];
for (var key in object) keys.push(key);
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function (skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
},
stop: function () {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function (exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function (type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function (record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
catch: function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function (iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
var CMP_INITIALIZE_EVENT = 'UC_UI_INITIALIZED';
var CONSENT_UPDATED_EVENT = 'UC_CONSENT';
var CMP_SHADOW_ROOT_ID = 'usercentrics-cmp-ui';
var acceptAllConsents = function acceptAllConsents() {
return window.__ucCmp.acceptAllConsents();
};
var denyAllConsents = function denyAllConsents() {
return window.__ucCmp.denyAllConsents();
};
var updateServicesConsents = function updateServicesConsents(serviceConsents) {
return window.__ucCmp.updateServicesConsents(serviceConsents);
};
var changeLanguage = function changeLanguage(language) {
return window.__ucCmp.changeLanguage(language);
};
var showCookieBanner = function showCookieBanner() {
return window.__ucCmp.showFirstLayer();
};
var hideCookieBanner = function hideCookieBanner() {
return window.__ucCmp.closeCmp();
};
function styleCookieBanner() {
return _styleCookieBanner.apply(this, arguments);
}
function _styleCookieBanner() {
_styleCookieBanner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var _cmpElement$shadowRoo;
var cmpElement, sheet;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return waitForElementWithId(CMP_SHADOW_ROOT_ID);
case 2:
cmpElement = document.getElementById(CMP_SHADOW_ROOT_ID);
console.log('cmp', cmpElement);
sheet = new CSSStyleSheet();
sheet.replaceSync(cmpStyleSheet);
cmpElement == null ? void 0 : (_cmpElement$shadowRoo = cmpElement.shadowRoot) == null ? void 0 : _cmpElement$shadowRoo.adoptedStyleSheets.push(sheet);
case 7:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _styleCookieBanner.apply(this, arguments);
}
function formatConsentEvent(event) {
var _event$detail$service, _event$detail;
return Object.entries((_event$detail$service = event == null ? void 0 : (_event$detail = event.detail) == null ? void 0 : _event$detail.services) != null ? _event$detail$service : {}).map(function (service) {
var _service$1$consent$gi, _service$1$consent;
return {
id: service[0],
name: service[1].name,
consentGiven: (_service$1$consent$gi = (_service$1$consent = service[1].consent) == null ? void 0 : _service$1$consent.given) != null ? _service$1$consent$gi : false,
category: service[1].category
};
});
}
var cookieBanner = {
acceptAllConsents: acceptAllConsents,
denyAllConsents: denyAllConsents,
updateServicesConsents: updateServicesConsents,
changeLanguage: changeLanguage,
showCookieBanner: showCookieBanner,
hideCookieBanner: hideCookieBanner,
eventListner: {
CONSENT_UPDATED_EVENT: CONSENT_UPDATED_EVENT,
CMP_INITIALIZE_EVENT: CMP_INITIALIZE_EVENT
},
formatConsentEvent: formatConsentEvent
};
if (typeof window !== 'undefined') styleCookieBanner();
/** Utils */
// Returns true when element with id is available in the DOM
function waitForElementWithId(_x) {
return _waitForElementWithId.apply(this, arguments);
}
/** Stylesheet for CookieBanner */
function _waitForElementWithId() {
_waitForElementWithId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(selector) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
return _context2.abrupt("return", new Promise(function (resolve) {
var observer = new MutationObserver(function (_, observer) {
var element = document.querySelector('#' + selector);
if (element) {
observer.disconnect();
resolve(true);
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}));
case 1:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _waitForElementWithId.apply(this, arguments);
}
var cmpStyleSheet = "\n .cmp-wrapper.cmp-wrapper.cmp-wrapper { \n width: 100%;\n\n .cmp:not(.second) {\n padding: " + space.rem.large + "rem calc((100dvw - 54rem) / 2);\n border-radius: unset;\n box-shadow: " + shadows.cardShadow + ";\n\n .language-selector-menu {\n right: calc((100dvw - 64rem) / 2);\n }\n } \n\n .privacy-title {\n font-size: " + fontSizes.rem.extraLarge2 + "rem;\n }\n .privacy-text {\n font-size: " + fontSizes.rem.large + "rem;\n line-height: " + lineHeights.rem.large + "rem;\n }\n\n\n .buttons-row {\n justify-content: flex-end;\n }\n\n button[data-action=\"consent\"] {\n flex-grow: unset;\n flex-basis: unset;\n width: fit-content;\n min-width: 9.5rem;\n height: 3rem;\n cursor: pointer;\n font-size: 1rem;\n line-height: 1.5rem;\n font-weight: 500;\n \n &[data-action-type=\"accept\"] {\n background-color: var(--components-button-primary-contrast-default);\n color: var(--components-button-primary-contrast-text);\n\n &:hover {\n background-color: var(--components-button-primary-contrast-hover);\n }\n }\n \n &[data-action-type=\"more\"],\n &[data-action-type=\"deny\"] {\n background-color: transparent;\n color: var(--components-button-secondary-contrast-text);\n border: 2px solid var(--components-button-secondary-contrast-border);\n\n &:hover {\n background-color: var(--components-button-secondary-contrast-hover);\n }\n }\n }\n\n .poweredBy {\n display: none;\n }\n }\n";
export { CMP_INITIALIZE_EVENT, CONSENT_UPDATED_EVENT, ConditionalWrapper, cmpStyleSheet, cookieBanner, getNodeText, mergeRefs, useDebounce, useForceUpdate, useOnClickOutside, useOnEscape, useOnMount, useRandomId, useWindowDimensions, waitForElementWithId, warnAboutMissingStyles };
//# sourceMappingURL=utils.esm.js.map
{
"name": "@entur/utils",
"version": "0.12.1",
"version": "1.0.0-alpha.0",
"license": "EUPL-1.2",

@@ -29,5 +29,6 @@ "main": "dist/index.js",

"dependencies": {
"@entur/tokens": "^3.17.3",
"tiny-warning": "^1.0.3"
},
"gitHead": "214480c52396a9b6f7133bdb21c81986e69c5ec4"
"gitHead": "b653c119e54372ec210ed20aa99ded642f114c69"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc