Socket
Socket
Sign inDemoInstall

@vrembem/drawer

Package Overview
Dependencies
2
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.10 to 3.0.11

478

dev/scripts.esm.js

@@ -7,6 +7,5 @@ function _defineProperties(target, props) {

if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {

@@ -20,3 +19,2 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps);

}
function _extends() {

@@ -26,3 +24,2 @@ _extends = Object.assign ? Object.assign.bind() : function (target) {

var source = arguments[i];
for (var key in source) {

@@ -34,3 +31,2 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;

@@ -40,10 +36,7 @@ };

}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
_setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {

@@ -56,3 +49,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {

}
function _assertThisInitialized(self) {

@@ -62,12 +54,22 @@ if (self === void 0) {

}
return self;
}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}
var id = 0;
function _classPrivateFieldLooseKey(name) {
return "__private_" + id++ + "_" + name;
}
function _classPrivateFieldLooseBase(receiver, privateKey) {

@@ -77,3 +79,2 @@ if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {

}
return receiver;

@@ -83,3 +84,2 @@ }

var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler");
var Breakpoint = /*#__PURE__*/function () {

@@ -95,14 +95,15 @@ function Breakpoint(value, handler) {

}
var _proto = Breakpoint.prototype;
_proto.mount = function mount(value, handler) {
// Update passed params.
if (value) this.value = value;
if (handler) _classPrivateFieldLooseBase(this, _handler)[_handler] = handler; // Guard if no breakpoint was set.
if (handler) _classPrivateFieldLooseBase(this, _handler)[_handler] = handler;
if (!this.value) return this; // Setup and store the MediaQueryList instance.
// Guard if no breakpoint was set.
if (!this.value) return this;
this.mql = window.matchMedia("(min-width: " + this.value + ")"); // Conditionally use addListener() for IE11 support.
// Setup and store the MediaQueryList instance.
this.mql = window.matchMedia("(min-width: " + this.value + ")");
// Conditionally use addListener() for IE11 support.
if (typeof this.mql.addEventListener === 'function') {

@@ -112,14 +113,13 @@ this.mql.addEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]);

this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
} // Run the handler.
}
// Run the handler.
_classPrivateFieldLooseBase(this, _handler)[_handler](this.mql);
return this;
};
_proto.unmount = function unmount() {
// Guard if no MediaQueryList instance exists.
if (!this.mql) return this; // Conditionally use removeListener() for IE11 support.
if (!this.mql) return this;
// Conditionally use removeListener() for IE11 support.
if (typeof this.mql.removeEventListener === 'function') {

@@ -129,5 +129,5 @@ this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]);

this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
} // Set value, handler and MediaQueryList to null.
}
// Set value, handler and MediaQueryList to null.
this.value = null;

@@ -138,3 +138,2 @@ _classPrivateFieldLooseBase(this, _handler)[_handler] = null;

};
_createClass(Breakpoint, [{

@@ -144,3 +143,5 @@ key: "handler",

return _classPrivateFieldLooseBase(this, _handler)[_handler];
} // Unmount existing handler before setting a new one.
}
// Unmount existing handler before setting a new one.
,

@@ -156,7 +157,5 @@ set: function set(func) {

}
_classPrivateFieldLooseBase(this, _handler)[_handler] = func;
}
}]);
return Breakpoint;

@@ -172,3 +171,2 @@ }();

}
value = value.v;

@@ -180,3 +178,2 @@ } else {

}
if (value && value.then) {

@@ -186,7 +183,5 @@ value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));

}
pact.s = state;
pact.v = value;
var observer = pact.o;
const observer = pact.o;
if (observer) {

@@ -197,13 +192,9 @@ observer(pact);

}
var _Pact = /*#__PURE__*/function () {
function _Pact() {}
_Pact.prototype.then = function (onFulfilled, onRejected) {
var result = new _Pact();
var state = this.s;
if (state) {
var callback = state & 1 ? onFulfilled : onRejected;
if (callback) {

@@ -215,3 +206,2 @@ try {

}
return result;

@@ -222,7 +212,5 @@ } else {

}
this.o = function (_this) {
try {
var value = _this.v;
if (_this.s & 1) {

@@ -239,27 +227,19 @@ _settle(result, 1, onFulfilled ? onFulfilled(value) : value);

};
return result;
};
return _Pact;
}();
function _isSettledPact(thenable) {
return thenable instanceof _Pact && thenable.s & 1;
}
function _for(test, update, body) {
var stage;
for (;;) {
var shouldContinue = test();
if (_isSettledPact(shouldContinue)) {
shouldContinue = shouldContinue.v;
}
if (!shouldContinue) {
return result;
}
if (shouldContinue.then) {

@@ -269,5 +249,3 @@ stage = 0;

}
var result = body();
if (result && result.then) {

@@ -281,6 +259,4 @@ if (_isSettledPact(result)) {

}
if (update) {
var updateValue = update();
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {

@@ -292,17 +268,11 @@ stage = 2;

}
var pact = new _Pact();
var reject = _settle.bind(null, pact, 2);
(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
return pact;
function _resumeAfterBody(value) {
result = value;
do {
if (update) {
updateValue = update();
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {

@@ -313,11 +283,7 @@ updateValue.then(_resumeAfterUpdate).then(void 0, reject);

}
shouldContinue = test();
if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
_settle(pact, 1, result);
return;
}
if (shouldContinue.then) {

@@ -327,5 +293,3 @@ shouldContinue.then(_resumeAfterTest).then(void 0, reject);

}
result = body();
if (_isSettledPact(result)) {

@@ -335,10 +299,7 @@ result = result.v;

} while (!result || !result.then);
result.then(_resumeAfterBody).then(void 0, reject);
}
function _resumeAfterTest(shouldContinue) {
if (shouldContinue) {
result = body();
if (result && result.then) {

@@ -353,3 +314,2 @@ result.then(_resumeAfterBody).then(void 0, reject);

}
function _resumeAfterUpdate() {

@@ -367,3 +327,2 @@ if (shouldContinue = test()) {

}
var Collection = /*#__PURE__*/function () {

@@ -373,12 +332,8 @@ function Collection() {

}
var _proto = Collection.prototype;
_proto.register = function register(item) {
try {
var _this2 = this;
return Promise.resolve(_this2.deregister(item)).then(function () {
_this2.collection.push(item);
return _this2.collection;

@@ -390,11 +345,8 @@ });

};
_proto.deregister = function deregister(ref) {
try {
var _this4 = this;
var index = _this4.collection.findIndex(function (entry) {
return entry === ref;
});
if (index >= 0) {

@@ -405,6 +357,4 @@ var entry = _this4.collection[index];

});
_this4.collection.splice(index, 1);
}
return Promise.resolve(_this4.collection);

@@ -415,7 +365,5 @@ } catch (e) {

};
_proto.registerCollection = function registerCollection(items) {
try {
var _this6 = this;
return Promise.resolve(Promise.all(Array.from(items, function (item) {

@@ -430,3 +378,2 @@ _this6.register(item);

};
_proto.deregisterCollection = function deregisterCollection() {

@@ -437,5 +384,3 @@ try {

};
var _this8 = this;
var _temp4 = _for(function () {

@@ -446,3 +391,2 @@ return _this8.collection.length > 0;

});
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));

@@ -453,3 +397,2 @@ } catch (e) {

};
_proto.get = function get(value, key) {

@@ -459,3 +402,2 @@ if (key === void 0) {

}
return this.collection.find(function (item) {

@@ -465,7 +407,6 @@ return item[key] === value;

};
return Collection;
}();
var focusableSelectors = [
var e = [
'a[href]:not([tabindex^="-"])',

@@ -486,7 +427,4 @@ 'area[href]:not([tabindex^="-"])',

var _focusable = /*#__PURE__*/_classPrivateFieldLooseKey("focusable");
var _handleFocusTrap = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusTrap");
var _handleFocusLock = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusLock");
var FocusTrap = /*#__PURE__*/function () {

@@ -497,7 +435,5 @@ function FocusTrap(el, selectorFocus) {

}
if (selectorFocus === void 0) {
selectorFocus = '[data-focus]';
}
Object.defineProperty(this, _focusable, {

@@ -520,25 +456,25 @@ writable: true,

}
var _proto = FocusTrap.prototype;
_proto.mount = function mount(el, selectorFocus) {
// Update passed params.
if (el) this.el = el;
if (selectorFocus) this.selectorFocus = selectorFocus; // Get the focusable elements.
if (selectorFocus) this.selectorFocus = selectorFocus;
this.focusable = this.getFocusable(); // Set the focus on the element.
// Get the focusable elements.
this.focusable = this.getFocusable();
// Set the focus on the element.
this.focus();
};
_proto.unmount = function unmount() {
// Set element to null.
this.el = null; // Apply empty array to focusable.
this.el = null;
this.focusable = []; // Remove event listeners
// Apply empty array to focusable.
this.focusable = [];
// Remove event listeners
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
};
_proto.focus = function focus(el, selectorFocus) {

@@ -548,13 +484,10 @@ if (el === void 0) {

}
if (selectorFocus === void 0) {
selectorFocus = this.selectorFocus;
}
// Query for the focus selector, otherwise return this element.
var result = el.querySelector(selectorFocus) || el; // Give the returned element focus.
var result = el.querySelector(selectorFocus) || el;
// Give the returned element focus.
result.focus();
};
_proto.getFocusable = function getFocusable(el) {

@@ -564,15 +497,17 @@ if (el === void 0) {

}
// Initialize the focusable array.
var focusable = []; // Store the initial focus and scroll position.
var focusable = [];
// Store the initial focus and scroll position.
var initFocus = document.activeElement;
var initScrollTop = el.scrollTop; // Query for all the focusable elements.
var initScrollTop = el.scrollTop;
var els = el.querySelectorAll(focusableSelectors.join(',')); // Loop through all focusable elements.
// Query for all the focusable elements.
var els = el.querySelectorAll(e.join(','));
// Loop through all focusable elements.
els.forEach(function (el) {
// Set them to focus and check
el.focus(); // Test that the element took focus.
el.focus();
// Test that the element took focus.
if (document.activeElement === el) {

@@ -582,10 +517,11 @@ // Add element to the focusable array.

}
}); // Restore the initial scroll position and focus.
});
// Restore the initial scroll position and focus.
el.scrollTop = initScrollTop;
initFocus.focus(); // Return the focusable array.
initFocus.focus();
// Return the focusable array.
return focusable;
};
_createClass(FocusTrap, [{

@@ -598,4 +534,5 @@ key: "focusable",

// Update the focusable value.
_classPrivateFieldLooseBase(this, _focusable)[_focusable] = value; // Apply event listeners based on new focusable array length.
_classPrivateFieldLooseBase(this, _focusable)[_focusable] = value;
// Apply event listeners based on new focusable array length.
if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) {

@@ -620,11 +557,10 @@ document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);

}]);
return FocusTrap;
}();
function handleFocusTrap(event) {
// Check if the click was a tab and return if not.
var isTab = event.key === 'Tab' || event.keyCode === 9;
if (!isTab) return; // If the shift key is pressed.
if (!isTab) return;
// If the shift key is pressed.
if (event.shiftKey) {

@@ -646,3 +582,2 @@ // If the active element is either the root el or first focusable.

}
function handleFocusLock(event) {

@@ -664,3 +599,2 @@ // Ignore the tab key by preventing default.

}
var local = localStorage.getItem(key);

@@ -678,3 +612,2 @@ var store = local ? JSON.parse(local) : {};

}
if (enable) localStorage.setItem(key, JSON.stringify(store));

@@ -735,3 +668,2 @@ return store;

}
function setInert(state, selector) {

@@ -751,7 +683,7 @@ if (selector) {

}
function updateGlobalState(param, config) {
// Set inert state based on if a modal is active.
setInert(!!param, config.selectorInert); // Set overflow state based on if a modal is active.
setInert(!!param, config.selectorInert);
// Set overflow state based on if a modal is active.
setOverflowHidden(!!param, config.selectorOverflow);

@@ -793,10 +725,9 @@ }

var _this = this;
// If an open, close or toggle button was clicked, handle the click event.
var trigger = event.target.closest("\n [data-" + this.settings.dataOpen + "],\n [data-" + this.settings.dataToggle + "],\n [data-" + this.settings.dataClose + "]\n ");
if (trigger) {
// Prevent the default behavior of the trigger.
event.preventDefault(); // If it's a toggle trigger...
event.preventDefault();
// If it's a toggle trigger...
if (trigger.matches("[data-" + this.settings.dataToggle + "]")) {

@@ -806,43 +737,38 @@ var selectors = trigger.getAttribute("data-" + this.settings.dataToggle).trim().split(' ');

// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Toggle the drawer
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Toggle the drawer
entry.toggle();
});
} // If it's a open trigger...
}
// If it's a open trigger...
if (trigger.matches("[data-" + this.settings.dataOpen + "]")) {
var _selectors = trigger.getAttribute("data-" + this.settings.dataOpen).trim().split(' ');
_selectors.forEach(function (selector) {
// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Open the drawer.
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Open the drawer.
entry.open();
});
} // If it's a close trigger...
}
// If it's a close trigger...
if (trigger.matches("[data-" + this.settings.dataClose + "]")) {
var _selectors2 = trigger.getAttribute("data-" + this.settings.dataClose).trim().split(' ');
_selectors2.forEach(function (selector) {
if (selector) {
// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Close the drawer.
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Close the drawer.
entry.close();
} else {
// If no value is set on close trigger, get the parent drawer.
var parent = event.target.closest(_this.settings.selectorDrawer); // If a parent drawer was found, close it.
var parent = event.target.closest(_this.settings.selectorDrawer);
// If a parent drawer was found, close it.
if (parent) _this.close(parent);

@@ -852,7 +778,6 @@ }

}
return;
} // If the modal drawer screen was clicked...
}
// If the modal drawer screen was clicked...
if (event.target.matches(this.settings.selectorDrawer)) {

@@ -874,3 +799,2 @@ // Close the modal drawer.

}
try {

@@ -881,12 +805,10 @@ var _temp5 = function _temp5() {

};
var _this2 = this;
// Return collection if nothing was passed.
if (!obj) return Promise.resolve(_this2.collection); // Check if entry has been registered in the collection.
if (!obj) return Promise.resolve(_this2.collection);
// Check if entry has been registered in the collection.
var index = _this2.collection.findIndex(function (entry) {
return entry.id === obj.id;
});
var _temp6 = function () {

@@ -896,18 +818,19 @@ if (index >= 0) {

// Remove entry from local store.
_this2.store.set(_entry.id); // Unmount the MatchMedia functionality.
_this2.store.set(_entry.id);
// Unmount the MatchMedia functionality.
_entry.unmountBreakpoint();
_entry.unmountBreakpoint(); // Delete properties from collection entry.
// Delete properties from collection entry.
Object.getOwnPropertyNames(_entry).forEach(function (prop) {
delete _entry[prop];
}); // Remove entry from collection.
});
// Remove entry from collection.
_this2.collection.splice(index, 1);
};
// Get the collection entry.
var _entry = _this2.collection[index]; // If entry is in the opened state.
var _entry = _this2.collection[index];
// If entry is in the opened state.
var _temp8 = function () {

@@ -919,7 +842,5 @@ if (close && _entry.state === 'opened') {

}();
return _temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8);
}
}();
return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));

@@ -938,3 +859,2 @@ } catch (e) {

var bp = drawer.getAttribute("data-" + this.settings.dataBreakpoint);
if (this.settings.breakpoints && this.settings.breakpoints[bp]) {

@@ -951,4 +871,5 @@ return this.settings.breakpoints[bp];

// Get the entry from collection.
var entry = typeof query === 'string' ? this.get(query) : this.get(query.id); // Return entry if it was resolved, otherwise throw error.
var entry = typeof query === 'string' ? this.get(query) : this.get(query.id);
// Return entry if it was resolved, otherwise throw error.
if (entry) {

@@ -965,3 +886,5 @@ return entry;

return obj;
} // If it's an HTML element.
}
// If it's an HTML element.
else if (typeof obj.hasAttribute === 'function') {

@@ -971,18 +894,30 @@ // If it's a drawer open trigger, return data value.

return obj.getAttribute("data-" + this.settings.dataOpen);
} // If it's a drawer close trigger, return data value or false.
}
// If it's a drawer close trigger, return data value or false.
else if (obj.hasAttribute("data-" + this.settings.dataClose)) {
return obj.getAttribute("data-" + this.settings.dataClose) || false;
} // If it's a drawer toggle trigger, return data value.
}
// If it's a drawer toggle trigger, return data value.
else if (obj.hasAttribute("data-" + this.settings.dataToggle)) {
return obj.getAttribute("data-" + this.settings.dataToggle);
} // If it's a drawer element, return the id.
}
// If it's a drawer element, return the id.
else if (obj.closest(this.settings.selectorDrawer)) {
obj = obj.closest(this.settings.selectorDrawer);
return obj.id || false;
} // Return false if no id was found.
}
// Return false if no id was found.
else return false;
} // If it has an id property, return its value.
}
// If it has an id property, return its value.
else if (obj.id) {
return obj.id;
} // Return false if no id was found.
}
// Return false if no id was found.
else return false;

@@ -993,7 +928,5 @@ }

var id = getDrawerID.call(this, query);
if (id) {
var drawer = document.querySelector("#" + id);
var dialog = drawer ? drawer.querySelector(this.settings.selectorDialog) : null;
if (!drawer && !dialog) {

@@ -1023,3 +956,2 @@ return {

var _this2 = this;
var _temp3 = function () {

@@ -1034,3 +966,2 @@ if (_this2.store.get(entry.id)) {

}();
if (_temp4 && _temp4.then) return _temp4.then(function () {});

@@ -1043,8 +974,7 @@ } else if (entry.el.classList.contains(_this2.settings.stateOpened)) {

entry.el.classList.remove(_this2.settings.stateOpening);
entry.el.classList.remove(_this2.settings.stateClosing); // Add closed state class.
entry.el.classList.remove(_this2.settings.stateClosing);
// Add closed state class.
entry.el.classList.add(_this2.settings.stateClosed);
}
}();
// Setup initial state using the following priority:

@@ -1075,3 +1005,2 @@ // 1. If a store state is available, restore from local store.

}
this.focusTrap.unmount();

@@ -1085,3 +1014,2 @@ }

}
try {

@@ -1092,32 +1020,35 @@ var _temp3 = function _temp3() {

updateFocusState.call(_this2, drawer);
} // Dispatch custom opened event.
}
// Dispatch custom opened event.
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'opened', {
detail: _this2,
bubbles: true
})); // Return the drawer.
}));
// Return the drawer.
return drawer;
};
var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Get the modal configuration.
var drawer = getDrawer.call(_this2, query);
var config = _extends({}, _this2.settings, drawer.settings); // Add transition parameter to configuration.
// Get the modal configuration.
var config = _extends({}, _this2.settings, drawer.settings);
// Add transition parameter to configuration.
if (transition !== undefined) config.transition = transition;
if (transition !== undefined) config.transition = transition; // If drawer is closed.
// If drawer is closed.
var _temp4 = function () {
if (drawer.state === 'closed') {
// Update drawer state.
drawer.state = 'opening'; // Run the open transition.
drawer.state = 'opening';
// Run the open transition.
return Promise.resolve(openTransition(drawer.el, config)).then(function () {
// Update the global state if mode is modal.
if (drawer.mode === 'modal') updateGlobalState(true, config); // Update drawer state.
if (drawer.mode === 'modal') updateGlobalState(true, config);
// Update drawer state.
drawer.state = 'opened';

@@ -1127,3 +1058,2 @@ });

}();
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));

@@ -1139,32 +1069,36 @@ } catch (e) {

}
try {
var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Get the modal configuration.
var drawer = getDrawer.call(_this2, query);
var config = _extends({}, _this2.settings, drawer.settings); // Add transition parameter to configuration.
// Get the modal configuration.
var config = _extends({}, _this2.settings, drawer.settings);
// Add transition parameter to configuration.
if (transition !== undefined) config.transition = transition;
if (transition !== undefined) config.transition = transition; // If drawer is opened.
// If drawer is opened.
var _temp2 = function () {
if (drawer.state === 'opened') {
// Update drawer state.
drawer.state = 'closing'; // Remove focus from active element.
drawer.state = 'closing';
document.activeElement.blur(); // Run the close transition.
// Remove focus from active element.
document.activeElement.blur();
// Run the close transition.
return Promise.resolve(closeTransition(drawer.el, config)).then(function () {
// Update the global state if mode is modal.
if (drawer.mode === 'modal') updateGlobalState(false, config); // Set focus to the trigger element if the focus param is true.
if (drawer.mode === 'modal') updateGlobalState(false, config);
// Set focus to the trigger element if the focus param is true.
if (focus) {
updateFocusState.call(_this2, drawer);
} // Update drawer state.
}
// Update drawer state.
drawer.state = 'closed';
drawer.state = 'closed'; // Dispatch custom closed event.
// Dispatch custom closed event.
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'closed', {

@@ -1177,3 +1111,2 @@ detail: _this2,

}();
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {

@@ -1191,6 +1124,6 @@ // Return the drawer.

var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Open or close the drawer based on its current state.
var drawer = getDrawer.call(_this2, query);
// Open or close the drawer based on its current state.
if (drawer.state === 'closed') {

@@ -1209,15 +1142,17 @@ return Promise.resolve(open.call(_this2, drawer, transition, focus));

var _this4 = this;
// Get the drawer configuration.
// Get the drawer configuration.
// Add the modal class.
entry.el.classList.add(entry.getSetting('classModal')); // Set aria-modal attribute to true.
entry.el.classList.add(entry.getSetting('classModal'));
entry.dialog.setAttribute('aria-modal', 'true'); // If there isn't a stored state but also has the opened state class...
// Set aria-modal attribute to true.
entry.dialog.setAttribute('aria-modal', 'true');
// If there isn't a stored state but also has the opened state class...
if (!_this4.store.get(entry.id) && entry.el.classList.contains(entry.getSetting('stateOpened'))) {
// Save the opened state in local store.
_this4.store.set(entry.id, 'opened');
} // Modal drawer defaults to closed state.
}
// Modal drawer defaults to closed state.
return Promise.resolve(close.call(_this4, entry, false, false)).then(function () {

@@ -1228,4 +1163,5 @@ // Dispatch custom switch event.

bubbles: true
})); // Return the entry.
}));
// Return the entry.
return entry;

@@ -1237,17 +1173,18 @@ });

};
var toInline = function toInline(entry) {
try {
var _this2 = this;
// Remove the modal class.
entry.el.classList.remove(entry.getSetting('classModal')); // Remove the aria-modal attribute.
entry.el.classList.remove(entry.getSetting('classModal'));
entry.dialog.removeAttribute('aria-modal'); // Update the global state.
// Remove the aria-modal attribute.
entry.dialog.removeAttribute('aria-modal');
updateGlobalState(false, _extends({}, _this2.settings, entry.settings)); // Remove any focus traps.
// Update the global state.
updateGlobalState(false, _extends({}, _this2.settings, entry.settings));
_this2.focusTrap.unmount(); // Setup initial state.
// Remove any focus traps.
_this2.focusTrap.unmount();
// Setup initial state.
return Promise.resolve(initialState.call(_this2, entry)).then(function () {

@@ -1258,4 +1195,5 @@ // Dispatch custom switch event.

bubbles: true
})); // Return the entry.
}));
// Return the entry.
return entry;

@@ -1267,3 +1205,2 @@ });

};
function switchMode(entry) {

@@ -1273,6 +1210,4 @@ switch (entry.mode) {

return toInline.call(this, entry);
case 'modal':
return toModal.call(this, entry);
default:

@@ -1286,10 +1221,11 @@ throw new Error("\"" + entry.mode + "\" is not a valid drawer mode.");

var _this2 = this;
// Deregister entry incase it has already been registered.
return Promise.resolve(deregister.call(_this2, el, false)).then(function () {
// Save root this for use inside methods API.
var root = _this2; // Create an instance of the Breakpoint class.
var root = _this2;
var breakpoint = new Breakpoint(); // Setup methods API.
// Create an instance of the Breakpoint class.
var breakpoint = new Breakpoint();
// Setup methods API.
var methods = {

@@ -1325,4 +1261,5 @@ open: function open$1(transition, focus) {

}
}; // Setup the drawer object.
};
// Setup the drawer object.
var entry = _extends({

@@ -1334,14 +1271,11 @@ id: el.id,

settings: getConfig(el, _this2.settings.dataConfig),
get breakpoint() {
return getBreakpoint.call(root, el);
},
get state() {
return __state;
},
set state(value) {
__state = value; // Save 'opened' and 'closed' states to store if mode is inline.
__state = value;
// Save 'opened' and 'closed' states to store if mode is inline.
if (value === 'opened' || value === 'closed') {

@@ -1351,7 +1285,5 @@ if (this.mode === 'inline') root.store.set(this.id, this.state);

},
get mode() {
return __mode;
},
set mode(value) {

@@ -1361,12 +1293,11 @@ __mode = value;

}
}, methods);
}, methods); // Create the state var with the initial state.
// Create the state var with the initial state.
var __state = el.classList.contains(entry.getSetting('stateOpened')) ? 'opened' : 'closed';
// Create the mode var with the initial mode.
var __mode = el.classList.contains(entry.getSetting('classModal')) ? 'modal' : 'inline';
var __state = el.classList.contains(entry.getSetting('stateOpened')) ? 'opened' : 'closed'; // Create the mode var with the initial mode.
var __mode = el.classList.contains(entry.getSetting('classModal')) ? 'modal' : 'inline'; // Setup mode specific attributes.
// Setup mode specific attributes.
if (entry.mode === 'modal') {

@@ -1378,13 +1309,13 @@ // Set aria-modal attribute to true.

entry.dialog.removeAttribute('aria-modal');
} // Set tabindex="-1" so dialog is focusable via JS or click.
}
// Set tabindex="-1" so dialog is focusable via JS or click.
if (entry.getSetting('setTabindex')) {
entry.dialog.setAttribute('tabindex', '-1');
} // Add entry to collection.
}
// Add entry to collection.
_this2.collection.push(entry);
_this2.collection.push(entry); // If the entry has a breakpoint...
// If the entry has a breakpoint...
var _temp = function () {

@@ -1399,3 +1330,2 @@ if (entry.breakpoint) {

}();
return _temp && _temp.then ? _temp.then(function () {

@@ -1412,11 +1342,7 @@ // Return the registered entry.

var _handleClick = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
var _handleKeydown = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
var Drawer = /*#__PURE__*/function (_Collection) {
_inheritsLoose(Drawer, _Collection);
function Drawer(options) {
var _this;
_this = _Collection.call(this) || this;

@@ -1433,4 +1359,5 @@ Object.defineProperty(_assertThisInitialized(_this), _handleClick, {

_this.settings = _extends({}, _this.defaults, options);
_this.focusTrap = new FocusTrap(); // Setup local store for inline drawer state management.
_this.focusTrap = new FocusTrap();
// Setup local store for inline drawer state management.
_this.store = localStore(_this.settings.storeKey, _this.settings.store);

@@ -1442,5 +1369,3 @@ _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleClick)[_handleClick] = handleClick.bind(_assertThisInitialized(_this));

}
var _proto = Drawer.prototype;
_proto.init = function init(options) {

@@ -1450,11 +1375,11 @@ if (options === void 0) {

}
try {
var _this3 = this;
// Update settings with passed options.
if (options) _this3.settings = _extends({}, _this3.settings, options); // Get all the modals.
if (options) _this3.settings = _extends({}, _this3.settings, options);
var drawers = document.querySelectorAll(_this3.settings.selectorDrawer); // Register the collections array with modal instances.
// Get all the modals.
var drawers = document.querySelectorAll(_this3.settings.selectorDrawer);
// Register the collections array with modal instances.
return Promise.resolve(_this3.registerCollection(drawers)).then(function () {

@@ -1465,3 +1390,2 @@ // If eventListeners are enabled, init event listeners.

}
return _this3;

@@ -1473,7 +1397,5 @@ });

};
_proto.destroy = function destroy() {
try {
var _this5 = this;
// Remove all entries from the collection.

@@ -1485,3 +1407,2 @@ return Promise.resolve(_this5.deregisterCollection()).then(function () {

}
return _this5;

@@ -1493,15 +1414,10 @@ });

};
_proto.initEventListeners = function initEventListeners() {
document.addEventListener('click', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.addEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
};
_proto.destroyEventListeners = function destroyEventListeners() {
document.removeEventListener('click', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.removeEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
};
_proto.register = function register$1(query) {

@@ -1512,3 +1428,2 @@ var els = getDrawerElements.call(this, query);

};
_proto.deregister = function deregister$1(query) {

@@ -1518,15 +1433,11 @@ var entry = this.get(getDrawerID.call(this, query));

};
_proto.open = function open$1(id, transition, focus) {
return open.call(this, id, transition, focus);
};
_proto.close = function close$1(id, transition, focus) {
return close.call(this, id, transition, focus);
};
_proto.toggle = function toggle$1(id, transition, focus) {
return toggle.call(this, id, transition, focus);
};
_createClass(Drawer, [{

@@ -1540,3 +1451,2 @@ key: "activeModal",

}]);
return Drawer;

@@ -1543,0 +1453,0 @@ }(Collection);

@@ -7,6 +7,5 @@ function _defineProperties(target, props) {

if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {

@@ -20,3 +19,2 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps);

}
function _extends() {

@@ -26,3 +24,2 @@ _extends = Object.assign ? Object.assign.bind() : function (target) {

var source = arguments[i];
for (var key in source) {

@@ -34,3 +31,2 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;

@@ -40,10 +36,7 @@ };

}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
_setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {

@@ -56,3 +49,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {

}
function _assertThisInitialized(self) {

@@ -62,12 +54,22 @@ if (self === void 0) {

}
return self;
}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}
var id = 0;
function _classPrivateFieldLooseKey(name) {
return "__private_" + id++ + "_" + name;
}
function _classPrivateFieldLooseBase(receiver, privateKey) {

@@ -77,3 +79,2 @@ if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {

}
return receiver;

@@ -83,3 +84,2 @@ }

var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler");
var Breakpoint = /*#__PURE__*/function () {

@@ -95,14 +95,15 @@ function Breakpoint(value, handler) {

}
var _proto = Breakpoint.prototype;
_proto.mount = function mount(value, handler) {
// Update passed params.
if (value) this.value = value;
if (handler) _classPrivateFieldLooseBase(this, _handler)[_handler] = handler; // Guard if no breakpoint was set.
if (handler) _classPrivateFieldLooseBase(this, _handler)[_handler] = handler;
if (!this.value) return this; // Setup and store the MediaQueryList instance.
// Guard if no breakpoint was set.
if (!this.value) return this;
this.mql = window.matchMedia("(min-width: " + this.value + ")"); // Conditionally use addListener() for IE11 support.
// Setup and store the MediaQueryList instance.
this.mql = window.matchMedia("(min-width: " + this.value + ")");
// Conditionally use addListener() for IE11 support.
if (typeof this.mql.addEventListener === 'function') {

@@ -112,14 +113,13 @@ this.mql.addEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]);

this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
} // Run the handler.
}
// Run the handler.
_classPrivateFieldLooseBase(this, _handler)[_handler](this.mql);
return this;
};
_proto.unmount = function unmount() {
// Guard if no MediaQueryList instance exists.
if (!this.mql) return this; // Conditionally use removeListener() for IE11 support.
if (!this.mql) return this;
// Conditionally use removeListener() for IE11 support.
if (typeof this.mql.removeEventListener === 'function') {

@@ -129,5 +129,5 @@ this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]);

this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
} // Set value, handler and MediaQueryList to null.
}
// Set value, handler and MediaQueryList to null.
this.value = null;

@@ -138,3 +138,2 @@ _classPrivateFieldLooseBase(this, _handler)[_handler] = null;

};
_createClass(Breakpoint, [{

@@ -144,3 +143,5 @@ key: "handler",

return _classPrivateFieldLooseBase(this, _handler)[_handler];
} // Unmount existing handler before setting a new one.
}
// Unmount existing handler before setting a new one.
,

@@ -156,7 +157,5 @@ set: function set(func) {

}
_classPrivateFieldLooseBase(this, _handler)[_handler] = func;
}
}]);
return Breakpoint;

@@ -172,3 +171,2 @@ }();

}
value = value.v;

@@ -180,3 +178,2 @@ } else {

}
if (value && value.then) {

@@ -186,7 +183,5 @@ value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));

}
pact.s = state;
pact.v = value;
var observer = pact.o;
const observer = pact.o;
if (observer) {

@@ -197,13 +192,9 @@ observer(pact);

}
var _Pact = /*#__PURE__*/function () {
function _Pact() {}
_Pact.prototype.then = function (onFulfilled, onRejected) {
var result = new _Pact();
var state = this.s;
if (state) {
var callback = state & 1 ? onFulfilled : onRejected;
if (callback) {

@@ -215,3 +206,2 @@ try {

}
return result;

@@ -222,7 +212,5 @@ } else {

}
this.o = function (_this) {
try {
var value = _this.v;
if (_this.s & 1) {

@@ -239,27 +227,19 @@ _settle(result, 1, onFulfilled ? onFulfilled(value) : value);

};
return result;
};
return _Pact;
}();
function _isSettledPact(thenable) {
return thenable instanceof _Pact && thenable.s & 1;
}
function _for(test, update, body) {
var stage;
for (;;) {
var shouldContinue = test();
if (_isSettledPact(shouldContinue)) {
shouldContinue = shouldContinue.v;
}
if (!shouldContinue) {
return result;
}
if (shouldContinue.then) {

@@ -269,5 +249,3 @@ stage = 0;

}
var result = body();
if (result && result.then) {

@@ -281,6 +259,4 @@ if (_isSettledPact(result)) {

}
if (update) {
var updateValue = update();
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {

@@ -292,17 +268,11 @@ stage = 2;

}
var pact = new _Pact();
var reject = _settle.bind(null, pact, 2);
(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
return pact;
function _resumeAfterBody(value) {
result = value;
do {
if (update) {
updateValue = update();
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {

@@ -313,11 +283,7 @@ updateValue.then(_resumeAfterUpdate).then(void 0, reject);

}
shouldContinue = test();
if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
_settle(pact, 1, result);
return;
}
if (shouldContinue.then) {

@@ -327,5 +293,3 @@ shouldContinue.then(_resumeAfterTest).then(void 0, reject);

}
result = body();
if (_isSettledPact(result)) {

@@ -335,10 +299,7 @@ result = result.v;

} while (!result || !result.then);
result.then(_resumeAfterBody).then(void 0, reject);
}
function _resumeAfterTest(shouldContinue) {
if (shouldContinue) {
result = body();
if (result && result.then) {

@@ -353,3 +314,2 @@ result.then(_resumeAfterBody).then(void 0, reject);

}
function _resumeAfterUpdate() {

@@ -367,3 +327,2 @@ if (shouldContinue = test()) {

}
var Collection = /*#__PURE__*/function () {

@@ -373,12 +332,8 @@ function Collection() {

}
var _proto = Collection.prototype;
_proto.register = function register(item) {
try {
var _this2 = this;
return Promise.resolve(_this2.deregister(item)).then(function () {
_this2.collection.push(item);
return _this2.collection;

@@ -390,11 +345,8 @@ });

};
_proto.deregister = function deregister(ref) {
try {
var _this4 = this;
var index = _this4.collection.findIndex(function (entry) {
return entry === ref;
});
if (index >= 0) {

@@ -405,6 +357,4 @@ var entry = _this4.collection[index];

});
_this4.collection.splice(index, 1);
}
return Promise.resolve(_this4.collection);

@@ -415,7 +365,5 @@ } catch (e) {

};
_proto.registerCollection = function registerCollection(items) {
try {
var _this6 = this;
return Promise.resolve(Promise.all(Array.from(items, function (item) {

@@ -430,3 +378,2 @@ _this6.register(item);

};
_proto.deregisterCollection = function deregisterCollection() {

@@ -437,5 +384,3 @@ try {

};
var _this8 = this;
var _temp4 = _for(function () {

@@ -446,3 +391,2 @@ return _this8.collection.length > 0;

});
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));

@@ -453,3 +397,2 @@ } catch (e) {

};
_proto.get = function get(value, key) {

@@ -459,3 +402,2 @@ if (key === void 0) {

}
return this.collection.find(function (item) {

@@ -465,7 +407,6 @@ return item[key] === value;

};
return Collection;
}();
var focusableSelectors = [
var e = [
'a[href]:not([tabindex^="-"])',

@@ -486,7 +427,4 @@ 'area[href]:not([tabindex^="-"])',

var _focusable = /*#__PURE__*/_classPrivateFieldLooseKey("focusable");
var _handleFocusTrap = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusTrap");
var _handleFocusLock = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusLock");
var FocusTrap = /*#__PURE__*/function () {

@@ -497,7 +435,5 @@ function FocusTrap(el, selectorFocus) {

}
if (selectorFocus === void 0) {
selectorFocus = '[data-focus]';
}
Object.defineProperty(this, _focusable, {

@@ -520,25 +456,25 @@ writable: true,

}
var _proto = FocusTrap.prototype;
_proto.mount = function mount(el, selectorFocus) {
// Update passed params.
if (el) this.el = el;
if (selectorFocus) this.selectorFocus = selectorFocus; // Get the focusable elements.
if (selectorFocus) this.selectorFocus = selectorFocus;
this.focusable = this.getFocusable(); // Set the focus on the element.
// Get the focusable elements.
this.focusable = this.getFocusable();
// Set the focus on the element.
this.focus();
};
_proto.unmount = function unmount() {
// Set element to null.
this.el = null; // Apply empty array to focusable.
this.el = null;
this.focusable = []; // Remove event listeners
// Apply empty array to focusable.
this.focusable = [];
// Remove event listeners
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
};
_proto.focus = function focus(el, selectorFocus) {

@@ -548,13 +484,10 @@ if (el === void 0) {

}
if (selectorFocus === void 0) {
selectorFocus = this.selectorFocus;
}
// Query for the focus selector, otherwise return this element.
var result = el.querySelector(selectorFocus) || el; // Give the returned element focus.
var result = el.querySelector(selectorFocus) || el;
// Give the returned element focus.
result.focus();
};
_proto.getFocusable = function getFocusable(el) {

@@ -564,15 +497,17 @@ if (el === void 0) {

}
// Initialize the focusable array.
var focusable = []; // Store the initial focus and scroll position.
var focusable = [];
// Store the initial focus and scroll position.
var initFocus = document.activeElement;
var initScrollTop = el.scrollTop; // Query for all the focusable elements.
var initScrollTop = el.scrollTop;
var els = el.querySelectorAll(focusableSelectors.join(',')); // Loop through all focusable elements.
// Query for all the focusable elements.
var els = el.querySelectorAll(e.join(','));
// Loop through all focusable elements.
els.forEach(function (el) {
// Set them to focus and check
el.focus(); // Test that the element took focus.
el.focus();
// Test that the element took focus.
if (document.activeElement === el) {

@@ -582,10 +517,11 @@ // Add element to the focusable array.

}
}); // Restore the initial scroll position and focus.
});
// Restore the initial scroll position and focus.
el.scrollTop = initScrollTop;
initFocus.focus(); // Return the focusable array.
initFocus.focus();
// Return the focusable array.
return focusable;
};
_createClass(FocusTrap, [{

@@ -598,4 +534,5 @@ key: "focusable",

// Update the focusable value.
_classPrivateFieldLooseBase(this, _focusable)[_focusable] = value; // Apply event listeners based on new focusable array length.
_classPrivateFieldLooseBase(this, _focusable)[_focusable] = value;
// Apply event listeners based on new focusable array length.
if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) {

@@ -620,11 +557,10 @@ document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);

}]);
return FocusTrap;
}();
function handleFocusTrap(event) {
// Check if the click was a tab and return if not.
var isTab = event.key === 'Tab' || event.keyCode === 9;
if (!isTab) return; // If the shift key is pressed.
if (!isTab) return;
// If the shift key is pressed.
if (event.shiftKey) {

@@ -646,3 +582,2 @@ // If the active element is either the root el or first focusable.

}
function handleFocusLock(event) {

@@ -664,3 +599,2 @@ // Ignore the tab key by preventing default.

}
var local = localStorage.getItem(key);

@@ -678,3 +612,2 @@ var store = local ? JSON.parse(local) : {};

}
if (enable) localStorage.setItem(key, JSON.stringify(store));

@@ -735,3 +668,2 @@ return store;

}
function setInert(state, selector) {

@@ -751,7 +683,7 @@ if (selector) {

}
function updateGlobalState(param, config) {
// Set inert state based on if a modal is active.
setInert(!!param, config.selectorInert); // Set overflow state based on if a modal is active.
setInert(!!param, config.selectorInert);
// Set overflow state based on if a modal is active.
setOverflowHidden(!!param, config.selectorOverflow);

@@ -793,10 +725,9 @@ }

var _this = this;
// If an open, close or toggle button was clicked, handle the click event.
var trigger = event.target.closest("\n [data-" + this.settings.dataOpen + "],\n [data-" + this.settings.dataToggle + "],\n [data-" + this.settings.dataClose + "]\n ");
if (trigger) {
// Prevent the default behavior of the trigger.
event.preventDefault(); // If it's a toggle trigger...
event.preventDefault();
// If it's a toggle trigger...
if (trigger.matches("[data-" + this.settings.dataToggle + "]")) {

@@ -806,43 +737,38 @@ var selectors = trigger.getAttribute("data-" + this.settings.dataToggle).trim().split(' ');

// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Toggle the drawer
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Toggle the drawer
entry.toggle();
});
} // If it's a open trigger...
}
// If it's a open trigger...
if (trigger.matches("[data-" + this.settings.dataOpen + "]")) {
var _selectors = trigger.getAttribute("data-" + this.settings.dataOpen).trim().split(' ');
_selectors.forEach(function (selector) {
// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Open the drawer.
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Open the drawer.
entry.open();
});
} // If it's a close trigger...
}
// If it's a close trigger...
if (trigger.matches("[data-" + this.settings.dataClose + "]")) {
var _selectors2 = trigger.getAttribute("data-" + this.settings.dataClose).trim().split(' ');
_selectors2.forEach(function (selector) {
if (selector) {
// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Close the drawer.
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Close the drawer.
entry.close();
} else {
// If no value is set on close trigger, get the parent drawer.
var parent = event.target.closest(_this.settings.selectorDrawer); // If a parent drawer was found, close it.
var parent = event.target.closest(_this.settings.selectorDrawer);
// If a parent drawer was found, close it.
if (parent) _this.close(parent);

@@ -852,7 +778,6 @@ }

}
return;
} // If the modal drawer screen was clicked...
}
// If the modal drawer screen was clicked...
if (event.target.matches(this.settings.selectorDrawer)) {

@@ -874,3 +799,2 @@ // Close the modal drawer.

}
try {

@@ -881,12 +805,10 @@ var _temp5 = function _temp5() {

};
var _this2 = this;
// Return collection if nothing was passed.
if (!obj) return Promise.resolve(_this2.collection); // Check if entry has been registered in the collection.
if (!obj) return Promise.resolve(_this2.collection);
// Check if entry has been registered in the collection.
var index = _this2.collection.findIndex(function (entry) {
return entry.id === obj.id;
});
var _temp6 = function () {

@@ -896,18 +818,19 @@ if (index >= 0) {

// Remove entry from local store.
_this2.store.set(_entry.id); // Unmount the MatchMedia functionality.
_this2.store.set(_entry.id);
// Unmount the MatchMedia functionality.
_entry.unmountBreakpoint();
_entry.unmountBreakpoint(); // Delete properties from collection entry.
// Delete properties from collection entry.
Object.getOwnPropertyNames(_entry).forEach(function (prop) {
delete _entry[prop];
}); // Remove entry from collection.
});
// Remove entry from collection.
_this2.collection.splice(index, 1);
};
// Get the collection entry.
var _entry = _this2.collection[index]; // If entry is in the opened state.
var _entry = _this2.collection[index];
// If entry is in the opened state.
var _temp8 = function () {

@@ -919,7 +842,5 @@ if (close && _entry.state === 'opened') {

}();
return _temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8);
}
}();
return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));

@@ -938,3 +859,2 @@ } catch (e) {

var bp = drawer.getAttribute("data-" + this.settings.dataBreakpoint);
if (this.settings.breakpoints && this.settings.breakpoints[bp]) {

@@ -951,4 +871,5 @@ return this.settings.breakpoints[bp];

// Get the entry from collection.
var entry = typeof query === 'string' ? this.get(query) : this.get(query.id); // Return entry if it was resolved, otherwise throw error.
var entry = typeof query === 'string' ? this.get(query) : this.get(query.id);
// Return entry if it was resolved, otherwise throw error.
if (entry) {

@@ -965,3 +886,5 @@ return entry;

return obj;
} // If it's an HTML element.
}
// If it's an HTML element.
else if (typeof obj.hasAttribute === 'function') {

@@ -971,18 +894,30 @@ // If it's a drawer open trigger, return data value.

return obj.getAttribute("data-" + this.settings.dataOpen);
} // If it's a drawer close trigger, return data value or false.
}
// If it's a drawer close trigger, return data value or false.
else if (obj.hasAttribute("data-" + this.settings.dataClose)) {
return obj.getAttribute("data-" + this.settings.dataClose) || false;
} // If it's a drawer toggle trigger, return data value.
}
// If it's a drawer toggle trigger, return data value.
else if (obj.hasAttribute("data-" + this.settings.dataToggle)) {
return obj.getAttribute("data-" + this.settings.dataToggle);
} // If it's a drawer element, return the id.
}
// If it's a drawer element, return the id.
else if (obj.closest(this.settings.selectorDrawer)) {
obj = obj.closest(this.settings.selectorDrawer);
return obj.id || false;
} // Return false if no id was found.
}
// Return false if no id was found.
else return false;
} // If it has an id property, return its value.
}
// If it has an id property, return its value.
else if (obj.id) {
return obj.id;
} // Return false if no id was found.
}
// Return false if no id was found.
else return false;

@@ -993,7 +928,5 @@ }

var id = getDrawerID.call(this, query);
if (id) {
var drawer = document.querySelector("#" + id);
var dialog = drawer ? drawer.querySelector(this.settings.selectorDialog) : null;
if (!drawer && !dialog) {

@@ -1023,3 +956,2 @@ return {

var _this2 = this;
var _temp3 = function () {

@@ -1034,3 +966,2 @@ if (_this2.store.get(entry.id)) {

}();
if (_temp4 && _temp4.then) return _temp4.then(function () {});

@@ -1043,8 +974,7 @@ } else if (entry.el.classList.contains(_this2.settings.stateOpened)) {

entry.el.classList.remove(_this2.settings.stateOpening);
entry.el.classList.remove(_this2.settings.stateClosing); // Add closed state class.
entry.el.classList.remove(_this2.settings.stateClosing);
// Add closed state class.
entry.el.classList.add(_this2.settings.stateClosed);
}
}();
// Setup initial state using the following priority:

@@ -1075,3 +1005,2 @@ // 1. If a store state is available, restore from local store.

}
this.focusTrap.unmount();

@@ -1085,3 +1014,2 @@ }

}
try {

@@ -1092,32 +1020,35 @@ var _temp3 = function _temp3() {

updateFocusState.call(_this2, drawer);
} // Dispatch custom opened event.
}
// Dispatch custom opened event.
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'opened', {
detail: _this2,
bubbles: true
})); // Return the drawer.
}));
// Return the drawer.
return drawer;
};
var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Get the modal configuration.
var drawer = getDrawer.call(_this2, query);
var config = _extends({}, _this2.settings, drawer.settings); // Add transition parameter to configuration.
// Get the modal configuration.
var config = _extends({}, _this2.settings, drawer.settings);
// Add transition parameter to configuration.
if (transition !== undefined) config.transition = transition;
if (transition !== undefined) config.transition = transition; // If drawer is closed.
// If drawer is closed.
var _temp4 = function () {
if (drawer.state === 'closed') {
// Update drawer state.
drawer.state = 'opening'; // Run the open transition.
drawer.state = 'opening';
// Run the open transition.
return Promise.resolve(openTransition(drawer.el, config)).then(function () {
// Update the global state if mode is modal.
if (drawer.mode === 'modal') updateGlobalState(true, config); // Update drawer state.
if (drawer.mode === 'modal') updateGlobalState(true, config);
// Update drawer state.
drawer.state = 'opened';

@@ -1127,3 +1058,2 @@ });

}();
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));

@@ -1139,32 +1069,36 @@ } catch (e) {

}
try {
var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Get the modal configuration.
var drawer = getDrawer.call(_this2, query);
var config = _extends({}, _this2.settings, drawer.settings); // Add transition parameter to configuration.
// Get the modal configuration.
var config = _extends({}, _this2.settings, drawer.settings);
// Add transition parameter to configuration.
if (transition !== undefined) config.transition = transition;
if (transition !== undefined) config.transition = transition; // If drawer is opened.
// If drawer is opened.
var _temp2 = function () {
if (drawer.state === 'opened') {
// Update drawer state.
drawer.state = 'closing'; // Remove focus from active element.
drawer.state = 'closing';
document.activeElement.blur(); // Run the close transition.
// Remove focus from active element.
document.activeElement.blur();
// Run the close transition.
return Promise.resolve(closeTransition(drawer.el, config)).then(function () {
// Update the global state if mode is modal.
if (drawer.mode === 'modal') updateGlobalState(false, config); // Set focus to the trigger element if the focus param is true.
if (drawer.mode === 'modal') updateGlobalState(false, config);
// Set focus to the trigger element if the focus param is true.
if (focus) {
updateFocusState.call(_this2, drawer);
} // Update drawer state.
}
// Update drawer state.
drawer.state = 'closed';
drawer.state = 'closed'; // Dispatch custom closed event.
// Dispatch custom closed event.
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'closed', {

@@ -1177,3 +1111,2 @@ detail: _this2,

}();
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {

@@ -1191,6 +1124,6 @@ // Return the drawer.

var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Open or close the drawer based on its current state.
var drawer = getDrawer.call(_this2, query);
// Open or close the drawer based on its current state.
if (drawer.state === 'closed') {

@@ -1209,15 +1142,17 @@ return Promise.resolve(open.call(_this2, drawer, transition, focus));

var _this4 = this;
// Get the drawer configuration.
// Get the drawer configuration.
// Add the modal class.
entry.el.classList.add(entry.getSetting('classModal')); // Set aria-modal attribute to true.
entry.el.classList.add(entry.getSetting('classModal'));
entry.dialog.setAttribute('aria-modal', 'true'); // If there isn't a stored state but also has the opened state class...
// Set aria-modal attribute to true.
entry.dialog.setAttribute('aria-modal', 'true');
// If there isn't a stored state but also has the opened state class...
if (!_this4.store.get(entry.id) && entry.el.classList.contains(entry.getSetting('stateOpened'))) {
// Save the opened state in local store.
_this4.store.set(entry.id, 'opened');
} // Modal drawer defaults to closed state.
}
// Modal drawer defaults to closed state.
return Promise.resolve(close.call(_this4, entry, false, false)).then(function () {

@@ -1228,4 +1163,5 @@ // Dispatch custom switch event.

bubbles: true
})); // Return the entry.
}));
// Return the entry.
return entry;

@@ -1237,17 +1173,18 @@ });

};
var toInline = function toInline(entry) {
try {
var _this2 = this;
// Remove the modal class.
entry.el.classList.remove(entry.getSetting('classModal')); // Remove the aria-modal attribute.
entry.el.classList.remove(entry.getSetting('classModal'));
entry.dialog.removeAttribute('aria-modal'); // Update the global state.
// Remove the aria-modal attribute.
entry.dialog.removeAttribute('aria-modal');
updateGlobalState(false, _extends({}, _this2.settings, entry.settings)); // Remove any focus traps.
// Update the global state.
updateGlobalState(false, _extends({}, _this2.settings, entry.settings));
_this2.focusTrap.unmount(); // Setup initial state.
// Remove any focus traps.
_this2.focusTrap.unmount();
// Setup initial state.
return Promise.resolve(initialState.call(_this2, entry)).then(function () {

@@ -1258,4 +1195,5 @@ // Dispatch custom switch event.

bubbles: true
})); // Return the entry.
}));
// Return the entry.
return entry;

@@ -1267,3 +1205,2 @@ });

};
function switchMode(entry) {

@@ -1273,6 +1210,4 @@ switch (entry.mode) {

return toInline.call(this, entry);
case 'modal':
return toModal.call(this, entry);
default:

@@ -1286,10 +1221,11 @@ throw new Error("\"" + entry.mode + "\" is not a valid drawer mode.");

var _this2 = this;
// Deregister entry incase it has already been registered.
return Promise.resolve(deregister.call(_this2, el, false)).then(function () {
// Save root this for use inside methods API.
var root = _this2; // Create an instance of the Breakpoint class.
var root = _this2;
var breakpoint = new Breakpoint(); // Setup methods API.
// Create an instance of the Breakpoint class.
var breakpoint = new Breakpoint();
// Setup methods API.
var methods = {

@@ -1325,4 +1261,5 @@ open: function open$1(transition, focus) {

}
}; // Setup the drawer object.
};
// Setup the drawer object.
var entry = _extends({

@@ -1334,14 +1271,11 @@ id: el.id,

settings: getConfig(el, _this2.settings.dataConfig),
get breakpoint() {
return getBreakpoint.call(root, el);
},
get state() {
return __state;
},
set state(value) {
__state = value; // Save 'opened' and 'closed' states to store if mode is inline.
__state = value;
// Save 'opened' and 'closed' states to store if mode is inline.
if (value === 'opened' || value === 'closed') {

@@ -1351,7 +1285,5 @@ if (this.mode === 'inline') root.store.set(this.id, this.state);

},
get mode() {
return __mode;
},
set mode(value) {

@@ -1361,12 +1293,11 @@ __mode = value;

}
}, methods);
}, methods); // Create the state var with the initial state.
// Create the state var with the initial state.
var __state = el.classList.contains(entry.getSetting('stateOpened')) ? 'opened' : 'closed';
// Create the mode var with the initial mode.
var __mode = el.classList.contains(entry.getSetting('classModal')) ? 'modal' : 'inline';
var __state = el.classList.contains(entry.getSetting('stateOpened')) ? 'opened' : 'closed'; // Create the mode var with the initial mode.
var __mode = el.classList.contains(entry.getSetting('classModal')) ? 'modal' : 'inline'; // Setup mode specific attributes.
// Setup mode specific attributes.
if (entry.mode === 'modal') {

@@ -1378,13 +1309,13 @@ // Set aria-modal attribute to true.

entry.dialog.removeAttribute('aria-modal');
} // Set tabindex="-1" so dialog is focusable via JS or click.
}
// Set tabindex="-1" so dialog is focusable via JS or click.
if (entry.getSetting('setTabindex')) {
entry.dialog.setAttribute('tabindex', '-1');
} // Add entry to collection.
}
// Add entry to collection.
_this2.collection.push(entry);
_this2.collection.push(entry); // If the entry has a breakpoint...
// If the entry has a breakpoint...
var _temp = function () {

@@ -1399,3 +1330,2 @@ if (entry.breakpoint) {

}();
return _temp && _temp.then ? _temp.then(function () {

@@ -1412,11 +1342,7 @@ // Return the registered entry.

var _handleClick = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
var _handleKeydown = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
var Drawer = /*#__PURE__*/function (_Collection) {
_inheritsLoose(Drawer, _Collection);
function Drawer(options) {
var _this;
_this = _Collection.call(this) || this;

@@ -1433,4 +1359,5 @@ Object.defineProperty(_assertThisInitialized(_this), _handleClick, {

_this.settings = _extends({}, _this.defaults, options);
_this.focusTrap = new FocusTrap(); // Setup local store for inline drawer state management.
_this.focusTrap = new FocusTrap();
// Setup local store for inline drawer state management.
_this.store = localStore(_this.settings.storeKey, _this.settings.store);

@@ -1442,5 +1369,3 @@ _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleClick)[_handleClick] = handleClick.bind(_assertThisInitialized(_this));

}
var _proto = Drawer.prototype;
_proto.init = function init(options) {

@@ -1450,11 +1375,11 @@ if (options === void 0) {

}
try {
var _this3 = this;
// Update settings with passed options.
if (options) _this3.settings = _extends({}, _this3.settings, options); // Get all the modals.
if (options) _this3.settings = _extends({}, _this3.settings, options);
var drawers = document.querySelectorAll(_this3.settings.selectorDrawer); // Register the collections array with modal instances.
// Get all the modals.
var drawers = document.querySelectorAll(_this3.settings.selectorDrawer);
// Register the collections array with modal instances.
return Promise.resolve(_this3.registerCollection(drawers)).then(function () {

@@ -1465,3 +1390,2 @@ // If eventListeners are enabled, init event listeners.

}
return _this3;

@@ -1473,7 +1397,5 @@ });

};
_proto.destroy = function destroy() {
try {
var _this5 = this;
// Remove all entries from the collection.

@@ -1485,3 +1407,2 @@ return Promise.resolve(_this5.deregisterCollection()).then(function () {

}
return _this5;

@@ -1493,15 +1414,10 @@ });

};
_proto.initEventListeners = function initEventListeners() {
document.addEventListener('click', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.addEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
};
_proto.destroyEventListeners = function destroyEventListeners() {
document.removeEventListener('click', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.removeEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
};
_proto.register = function register$1(query) {

@@ -1512,3 +1428,2 @@ var els = getDrawerElements.call(this, query);

};
_proto.deregister = function deregister$1(query) {

@@ -1518,15 +1433,11 @@ var entry = this.get(getDrawerID.call(this, query));

};
_proto.open = function open$1(id, transition, focus) {
return open.call(this, id, transition, focus);
};
_proto.close = function close$1(id, transition, focus) {
return close.call(this, id, transition, focus);
};
_proto.toggle = function toggle$1(id, transition, focus) {
return toggle.call(this, id, transition, focus);
};
_createClass(Drawer, [{

@@ -1540,3 +1451,2 @@ key: "activeModal",

}]);
return Drawer;

@@ -1543,0 +1453,0 @@ }(Collection);

@@ -12,6 +12,5 @@ (function (global, factory) {

if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {

@@ -25,3 +24,2 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps);

}
function _extends() {

@@ -31,3 +29,2 @@ _extends = Object.assign ? Object.assign.bind() : function (target) {

var source = arguments[i];
for (var key in source) {

@@ -39,3 +36,2 @@ if (Object.prototype.hasOwnProperty.call(source, key)) {

}
return target;

@@ -45,10 +41,7 @@ };

}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
_setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {

@@ -61,3 +54,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {

}
function _assertThisInitialized(self) {

@@ -67,12 +59,22 @@ if (self === void 0) {

}
return self;
}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}
var id = 0;
function _classPrivateFieldLooseKey(name) {
return "__private_" + id++ + "_" + name;
}
function _classPrivateFieldLooseBase(receiver, privateKey) {

@@ -82,3 +84,2 @@ if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {

}
return receiver;

@@ -88,3 +89,2 @@ }

var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler");
var Breakpoint = /*#__PURE__*/function () {

@@ -100,14 +100,15 @@ function Breakpoint(value, handler) {

}
var _proto = Breakpoint.prototype;
_proto.mount = function mount(value, handler) {
// Update passed params.
if (value) this.value = value;
if (handler) _classPrivateFieldLooseBase(this, _handler)[_handler] = handler; // Guard if no breakpoint was set.
if (handler) _classPrivateFieldLooseBase(this, _handler)[_handler] = handler;
if (!this.value) return this; // Setup and store the MediaQueryList instance.
// Guard if no breakpoint was set.
if (!this.value) return this;
this.mql = window.matchMedia("(min-width: " + this.value + ")"); // Conditionally use addListener() for IE11 support.
// Setup and store the MediaQueryList instance.
this.mql = window.matchMedia("(min-width: " + this.value + ")");
// Conditionally use addListener() for IE11 support.
if (typeof this.mql.addEventListener === 'function') {

@@ -117,14 +118,13 @@ this.mql.addEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]);

this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
} // Run the handler.
}
// Run the handler.
_classPrivateFieldLooseBase(this, _handler)[_handler](this.mql);
return this;
};
_proto.unmount = function unmount() {
// Guard if no MediaQueryList instance exists.
if (!this.mql) return this; // Conditionally use removeListener() for IE11 support.
if (!this.mql) return this;
// Conditionally use removeListener() for IE11 support.
if (typeof this.mql.removeEventListener === 'function') {

@@ -134,5 +134,5 @@ this.mql.removeEventListener('change', _classPrivateFieldLooseBase(this, _handler)[_handler]);

this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
} // Set value, handler and MediaQueryList to null.
}
// Set value, handler and MediaQueryList to null.
this.value = null;

@@ -143,3 +143,2 @@ _classPrivateFieldLooseBase(this, _handler)[_handler] = null;

};
_createClass(Breakpoint, [{

@@ -149,3 +148,5 @@ key: "handler",

return _classPrivateFieldLooseBase(this, _handler)[_handler];
} // Unmount existing handler before setting a new one.
}
// Unmount existing handler before setting a new one.
,

@@ -161,7 +162,5 @@ set: function set(func) {

}
_classPrivateFieldLooseBase(this, _handler)[_handler] = func;
}
}]);
return Breakpoint;

@@ -177,3 +176,2 @@ }();

}
value = value.v;

@@ -185,3 +183,2 @@ } else {

}
if (value && value.then) {

@@ -191,7 +188,5 @@ value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));

}
pact.s = state;
pact.v = value;
var observer = pact.o;
const observer = pact.o;
if (observer) {

@@ -202,13 +197,9 @@ observer(pact);

}
var _Pact = /*#__PURE__*/function () {
function _Pact() {}
_Pact.prototype.then = function (onFulfilled, onRejected) {
var result = new _Pact();
var state = this.s;
if (state) {
var callback = state & 1 ? onFulfilled : onRejected;
if (callback) {

@@ -220,3 +211,2 @@ try {

}
return result;

@@ -227,7 +217,5 @@ } else {

}
this.o = function (_this) {
try {
var value = _this.v;
if (_this.s & 1) {

@@ -244,27 +232,19 @@ _settle(result, 1, onFulfilled ? onFulfilled(value) : value);

};
return result;
};
return _Pact;
}();
function _isSettledPact(thenable) {
return thenable instanceof _Pact && thenable.s & 1;
}
function _for(test, update, body) {
var stage;
for (;;) {
var shouldContinue = test();
if (_isSettledPact(shouldContinue)) {
shouldContinue = shouldContinue.v;
}
if (!shouldContinue) {
return result;
}
if (shouldContinue.then) {

@@ -274,5 +254,3 @@ stage = 0;

}
var result = body();
if (result && result.then) {

@@ -286,6 +264,4 @@ if (_isSettledPact(result)) {

}
if (update) {
var updateValue = update();
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {

@@ -297,17 +273,11 @@ stage = 2;

}
var pact = new _Pact();
var reject = _settle.bind(null, pact, 2);
(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
return pact;
function _resumeAfterBody(value) {
result = value;
do {
if (update) {
updateValue = update();
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {

@@ -318,11 +288,7 @@ updateValue.then(_resumeAfterUpdate).then(void 0, reject);

}
shouldContinue = test();
if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
_settle(pact, 1, result);
return;
}
if (shouldContinue.then) {

@@ -332,5 +298,3 @@ shouldContinue.then(_resumeAfterTest).then(void 0, reject);

}
result = body();
if (_isSettledPact(result)) {

@@ -340,10 +304,7 @@ result = result.v;

} while (!result || !result.then);
result.then(_resumeAfterBody).then(void 0, reject);
}
function _resumeAfterTest(shouldContinue) {
if (shouldContinue) {
result = body();
if (result && result.then) {

@@ -358,3 +319,2 @@ result.then(_resumeAfterBody).then(void 0, reject);

}
function _resumeAfterUpdate() {

@@ -372,3 +332,2 @@ if (shouldContinue = test()) {

}
var Collection = /*#__PURE__*/function () {

@@ -378,12 +337,8 @@ function Collection() {

}
var _proto = Collection.prototype;
_proto.register = function register(item) {
try {
var _this2 = this;
return Promise.resolve(_this2.deregister(item)).then(function () {
_this2.collection.push(item);
return _this2.collection;

@@ -395,11 +350,8 @@ });

};
_proto.deregister = function deregister(ref) {
try {
var _this4 = this;
var index = _this4.collection.findIndex(function (entry) {
return entry === ref;
});
if (index >= 0) {

@@ -410,6 +362,4 @@ var entry = _this4.collection[index];

});
_this4.collection.splice(index, 1);
}
return Promise.resolve(_this4.collection);

@@ -420,7 +370,5 @@ } catch (e) {

};
_proto.registerCollection = function registerCollection(items) {
try {
var _this6 = this;
return Promise.resolve(Promise.all(Array.from(items, function (item) {

@@ -435,3 +383,2 @@ _this6.register(item);

};
_proto.deregisterCollection = function deregisterCollection() {

@@ -442,5 +389,3 @@ try {

};
var _this8 = this;
var _temp4 = _for(function () {

@@ -451,3 +396,2 @@ return _this8.collection.length > 0;

});
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));

@@ -458,3 +402,2 @@ } catch (e) {

};
_proto.get = function get(value, key) {

@@ -464,3 +407,2 @@ if (key === void 0) {

}
return this.collection.find(function (item) {

@@ -470,7 +412,6 @@ return item[key] === value;

};
return Collection;
}();
var focusableSelectors = [
var e = [
'a[href]:not([tabindex^="-"])',

@@ -491,7 +432,4 @@ 'area[href]:not([tabindex^="-"])',

var _focusable = /*#__PURE__*/_classPrivateFieldLooseKey("focusable");
var _handleFocusTrap = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusTrap");
var _handleFocusLock = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusLock");
var FocusTrap = /*#__PURE__*/function () {

@@ -502,7 +440,5 @@ function FocusTrap(el, selectorFocus) {

}
if (selectorFocus === void 0) {
selectorFocus = '[data-focus]';
}
Object.defineProperty(this, _focusable, {

@@ -525,25 +461,25 @@ writable: true,

}
var _proto = FocusTrap.prototype;
_proto.mount = function mount(el, selectorFocus) {
// Update passed params.
if (el) this.el = el;
if (selectorFocus) this.selectorFocus = selectorFocus; // Get the focusable elements.
if (selectorFocus) this.selectorFocus = selectorFocus;
this.focusable = this.getFocusable(); // Set the focus on the element.
// Get the focusable elements.
this.focusable = this.getFocusable();
// Set the focus on the element.
this.focus();
};
_proto.unmount = function unmount() {
// Set element to null.
this.el = null; // Apply empty array to focusable.
this.el = null;
this.focusable = []; // Remove event listeners
// Apply empty array to focusable.
this.focusable = [];
// Remove event listeners
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
};
_proto.focus = function focus(el, selectorFocus) {

@@ -553,13 +489,10 @@ if (el === void 0) {

}
if (selectorFocus === void 0) {
selectorFocus = this.selectorFocus;
}
// Query for the focus selector, otherwise return this element.
var result = el.querySelector(selectorFocus) || el; // Give the returned element focus.
var result = el.querySelector(selectorFocus) || el;
// Give the returned element focus.
result.focus();
};
_proto.getFocusable = function getFocusable(el) {

@@ -569,15 +502,17 @@ if (el === void 0) {

}
// Initialize the focusable array.
var focusable = []; // Store the initial focus and scroll position.
var focusable = [];
// Store the initial focus and scroll position.
var initFocus = document.activeElement;
var initScrollTop = el.scrollTop; // Query for all the focusable elements.
var initScrollTop = el.scrollTop;
var els = el.querySelectorAll(focusableSelectors.join(',')); // Loop through all focusable elements.
// Query for all the focusable elements.
var els = el.querySelectorAll(e.join(','));
// Loop through all focusable elements.
els.forEach(function (el) {
// Set them to focus and check
el.focus(); // Test that the element took focus.
el.focus();
// Test that the element took focus.
if (document.activeElement === el) {

@@ -587,10 +522,11 @@ // Add element to the focusable array.

}
}); // Restore the initial scroll position and focus.
});
// Restore the initial scroll position and focus.
el.scrollTop = initScrollTop;
initFocus.focus(); // Return the focusable array.
initFocus.focus();
// Return the focusable array.
return focusable;
};
_createClass(FocusTrap, [{

@@ -603,4 +539,5 @@ key: "focusable",

// Update the focusable value.
_classPrivateFieldLooseBase(this, _focusable)[_focusable] = value; // Apply event listeners based on new focusable array length.
_classPrivateFieldLooseBase(this, _focusable)[_focusable] = value;
// Apply event listeners based on new focusable array length.
if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) {

@@ -625,11 +562,10 @@ document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);

}]);
return FocusTrap;
}();
function handleFocusTrap(event) {
// Check if the click was a tab and return if not.
var isTab = event.key === 'Tab' || event.keyCode === 9;
if (!isTab) return; // If the shift key is pressed.
if (!isTab) return;
// If the shift key is pressed.
if (event.shiftKey) {

@@ -651,3 +587,2 @@ // If the active element is either the root el or first focusable.

}
function handleFocusLock(event) {

@@ -669,3 +604,2 @@ // Ignore the tab key by preventing default.

}
var local = localStorage.getItem(key);

@@ -683,3 +617,2 @@ var store = local ? JSON.parse(local) : {};

}
if (enable) localStorage.setItem(key, JSON.stringify(store));

@@ -740,3 +673,2 @@ return store;

}
function setInert(state, selector) {

@@ -756,7 +688,7 @@ if (selector) {

}
function updateGlobalState(param, config) {
// Set inert state based on if a modal is active.
setInert(!!param, config.selectorInert); // Set overflow state based on if a modal is active.
setInert(!!param, config.selectorInert);
// Set overflow state based on if a modal is active.
setOverflowHidden(!!param, config.selectorOverflow);

@@ -798,10 +730,9 @@ }

var _this = this;
// If an open, close or toggle button was clicked, handle the click event.
var trigger = event.target.closest("\n [data-" + this.settings.dataOpen + "],\n [data-" + this.settings.dataToggle + "],\n [data-" + this.settings.dataClose + "]\n ");
if (trigger) {
// Prevent the default behavior of the trigger.
event.preventDefault(); // If it's a toggle trigger...
event.preventDefault();
// If it's a toggle trigger...
if (trigger.matches("[data-" + this.settings.dataToggle + "]")) {

@@ -811,43 +742,38 @@ var selectors = trigger.getAttribute("data-" + this.settings.dataToggle).trim().split(' ');

// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Toggle the drawer
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Toggle the drawer
entry.toggle();
});
} // If it's a open trigger...
}
// If it's a open trigger...
if (trigger.matches("[data-" + this.settings.dataOpen + "]")) {
var _selectors = trigger.getAttribute("data-" + this.settings.dataOpen).trim().split(' ');
_selectors.forEach(function (selector) {
// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Open the drawer.
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Open the drawer.
entry.open();
});
} // If it's a close trigger...
}
// If it's a close trigger...
if (trigger.matches("[data-" + this.settings.dataClose + "]")) {
var _selectors2 = trigger.getAttribute("data-" + this.settings.dataClose).trim().split(' ');
_selectors2.forEach(function (selector) {
if (selector) {
// Get the entry from collection using the attribute value.
var entry = _this.get(selector); // Store the trigger on the entry.
entry.trigger = trigger; // Close the drawer.
var entry = _this.get(selector);
// Store the trigger on the entry.
entry.trigger = trigger;
// Close the drawer.
entry.close();
} else {
// If no value is set on close trigger, get the parent drawer.
var parent = event.target.closest(_this.settings.selectorDrawer); // If a parent drawer was found, close it.
var parent = event.target.closest(_this.settings.selectorDrawer);
// If a parent drawer was found, close it.
if (parent) _this.close(parent);

@@ -857,7 +783,6 @@ }

}
return;
} // If the modal drawer screen was clicked...
}
// If the modal drawer screen was clicked...
if (event.target.matches(this.settings.selectorDrawer)) {

@@ -879,3 +804,2 @@ // Close the modal drawer.

}
try {

@@ -886,12 +810,10 @@ var _temp5 = function _temp5() {

};
var _this2 = this;
// Return collection if nothing was passed.
if (!obj) return Promise.resolve(_this2.collection); // Check if entry has been registered in the collection.
if (!obj) return Promise.resolve(_this2.collection);
// Check if entry has been registered in the collection.
var index = _this2.collection.findIndex(function (entry) {
return entry.id === obj.id;
});
var _temp6 = function () {

@@ -901,18 +823,19 @@ if (index >= 0) {

// Remove entry from local store.
_this2.store.set(_entry.id); // Unmount the MatchMedia functionality.
_this2.store.set(_entry.id);
// Unmount the MatchMedia functionality.
_entry.unmountBreakpoint();
_entry.unmountBreakpoint(); // Delete properties from collection entry.
// Delete properties from collection entry.
Object.getOwnPropertyNames(_entry).forEach(function (prop) {
delete _entry[prop];
}); // Remove entry from collection.
});
// Remove entry from collection.
_this2.collection.splice(index, 1);
};
// Get the collection entry.
var _entry = _this2.collection[index]; // If entry is in the opened state.
var _entry = _this2.collection[index];
// If entry is in the opened state.
var _temp8 = function () {

@@ -924,7 +847,5 @@ if (close && _entry.state === 'opened') {

}();
return _temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8);
}
}();
return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));

@@ -943,3 +864,2 @@ } catch (e) {

var bp = drawer.getAttribute("data-" + this.settings.dataBreakpoint);
if (this.settings.breakpoints && this.settings.breakpoints[bp]) {

@@ -956,4 +876,5 @@ return this.settings.breakpoints[bp];

// Get the entry from collection.
var entry = typeof query === 'string' ? this.get(query) : this.get(query.id); // Return entry if it was resolved, otherwise throw error.
var entry = typeof query === 'string' ? this.get(query) : this.get(query.id);
// Return entry if it was resolved, otherwise throw error.
if (entry) {

@@ -970,3 +891,5 @@ return entry;

return obj;
} // If it's an HTML element.
}
// If it's an HTML element.
else if (typeof obj.hasAttribute === 'function') {

@@ -976,18 +899,30 @@ // If it's a drawer open trigger, return data value.

return obj.getAttribute("data-" + this.settings.dataOpen);
} // If it's a drawer close trigger, return data value or false.
}
// If it's a drawer close trigger, return data value or false.
else if (obj.hasAttribute("data-" + this.settings.dataClose)) {
return obj.getAttribute("data-" + this.settings.dataClose) || false;
} // If it's a drawer toggle trigger, return data value.
}
// If it's a drawer toggle trigger, return data value.
else if (obj.hasAttribute("data-" + this.settings.dataToggle)) {
return obj.getAttribute("data-" + this.settings.dataToggle);
} // If it's a drawer element, return the id.
}
// If it's a drawer element, return the id.
else if (obj.closest(this.settings.selectorDrawer)) {
obj = obj.closest(this.settings.selectorDrawer);
return obj.id || false;
} // Return false if no id was found.
}
// Return false if no id was found.
else return false;
} // If it has an id property, return its value.
}
// If it has an id property, return its value.
else if (obj.id) {
return obj.id;
} // Return false if no id was found.
}
// Return false if no id was found.
else return false;

@@ -998,7 +933,5 @@ }

var id = getDrawerID.call(this, query);
if (id) {
var drawer = document.querySelector("#" + id);
var dialog = drawer ? drawer.querySelector(this.settings.selectorDialog) : null;
if (!drawer && !dialog) {

@@ -1028,3 +961,2 @@ return {

var _this2 = this;
var _temp3 = function () {

@@ -1039,3 +971,2 @@ if (_this2.store.get(entry.id)) {

}();
if (_temp4 && _temp4.then) return _temp4.then(function () {});

@@ -1048,8 +979,7 @@ } else if (entry.el.classList.contains(_this2.settings.stateOpened)) {

entry.el.classList.remove(_this2.settings.stateOpening);
entry.el.classList.remove(_this2.settings.stateClosing); // Add closed state class.
entry.el.classList.remove(_this2.settings.stateClosing);
// Add closed state class.
entry.el.classList.add(_this2.settings.stateClosed);
}
}();
// Setup initial state using the following priority:

@@ -1080,3 +1010,2 @@ // 1. If a store state is available, restore from local store.

}
this.focusTrap.unmount();

@@ -1090,3 +1019,2 @@ }

}
try {

@@ -1097,32 +1025,35 @@ var _temp3 = function _temp3() {

updateFocusState.call(_this2, drawer);
} // Dispatch custom opened event.
}
// Dispatch custom opened event.
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'opened', {
detail: _this2,
bubbles: true
})); // Return the drawer.
}));
// Return the drawer.
return drawer;
};
var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Get the modal configuration.
var drawer = getDrawer.call(_this2, query);
var config = _extends({}, _this2.settings, drawer.settings); // Add transition parameter to configuration.
// Get the modal configuration.
var config = _extends({}, _this2.settings, drawer.settings);
// Add transition parameter to configuration.
if (transition !== undefined) config.transition = transition;
if (transition !== undefined) config.transition = transition; // If drawer is closed.
// If drawer is closed.
var _temp4 = function () {
if (drawer.state === 'closed') {
// Update drawer state.
drawer.state = 'opening'; // Run the open transition.
drawer.state = 'opening';
// Run the open transition.
return Promise.resolve(openTransition(drawer.el, config)).then(function () {
// Update the global state if mode is modal.
if (drawer.mode === 'modal') updateGlobalState(true, config); // Update drawer state.
if (drawer.mode === 'modal') updateGlobalState(true, config);
// Update drawer state.
drawer.state = 'opened';

@@ -1132,3 +1063,2 @@ });

}();
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));

@@ -1144,32 +1074,36 @@ } catch (e) {

}
try {
var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Get the modal configuration.
var drawer = getDrawer.call(_this2, query);
var config = _extends({}, _this2.settings, drawer.settings); // Add transition parameter to configuration.
// Get the modal configuration.
var config = _extends({}, _this2.settings, drawer.settings);
// Add transition parameter to configuration.
if (transition !== undefined) config.transition = transition;
if (transition !== undefined) config.transition = transition; // If drawer is opened.
// If drawer is opened.
var _temp2 = function () {
if (drawer.state === 'opened') {
// Update drawer state.
drawer.state = 'closing'; // Remove focus from active element.
drawer.state = 'closing';
document.activeElement.blur(); // Run the close transition.
// Remove focus from active element.
document.activeElement.blur();
// Run the close transition.
return Promise.resolve(closeTransition(drawer.el, config)).then(function () {
// Update the global state if mode is modal.
if (drawer.mode === 'modal') updateGlobalState(false, config); // Set focus to the trigger element if the focus param is true.
if (drawer.mode === 'modal') updateGlobalState(false, config);
// Set focus to the trigger element if the focus param is true.
if (focus) {
updateFocusState.call(_this2, drawer);
} // Update drawer state.
}
// Update drawer state.
drawer.state = 'closed';
drawer.state = 'closed'; // Dispatch custom closed event.
// Dispatch custom closed event.
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + 'closed', {

@@ -1182,3 +1116,2 @@ detail: _this2,

}();
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {

@@ -1196,6 +1129,6 @@ // Return the drawer.

var _this2 = this;
// Get the drawer from collection.
var drawer = getDrawer.call(_this2, query); // Open or close the drawer based on its current state.
var drawer = getDrawer.call(_this2, query);
// Open or close the drawer based on its current state.
if (drawer.state === 'closed') {

@@ -1214,15 +1147,17 @@ return Promise.resolve(open.call(_this2, drawer, transition, focus));

var _this4 = this;
// Get the drawer configuration.
// Get the drawer configuration.
// Add the modal class.
entry.el.classList.add(entry.getSetting('classModal')); // Set aria-modal attribute to true.
entry.el.classList.add(entry.getSetting('classModal'));
entry.dialog.setAttribute('aria-modal', 'true'); // If there isn't a stored state but also has the opened state class...
// Set aria-modal attribute to true.
entry.dialog.setAttribute('aria-modal', 'true');
// If there isn't a stored state but also has the opened state class...
if (!_this4.store.get(entry.id) && entry.el.classList.contains(entry.getSetting('stateOpened'))) {
// Save the opened state in local store.
_this4.store.set(entry.id, 'opened');
} // Modal drawer defaults to closed state.
}
// Modal drawer defaults to closed state.
return Promise.resolve(close.call(_this4, entry, false, false)).then(function () {

@@ -1233,4 +1168,5 @@ // Dispatch custom switch event.

bubbles: true
})); // Return the entry.
}));
// Return the entry.
return entry;

@@ -1242,17 +1178,18 @@ });

};
var toInline = function toInline(entry) {
try {
var _this2 = this;
// Remove the modal class.
entry.el.classList.remove(entry.getSetting('classModal')); // Remove the aria-modal attribute.
entry.el.classList.remove(entry.getSetting('classModal'));
entry.dialog.removeAttribute('aria-modal'); // Update the global state.
// Remove the aria-modal attribute.
entry.dialog.removeAttribute('aria-modal');
updateGlobalState(false, _extends({}, _this2.settings, entry.settings)); // Remove any focus traps.
// Update the global state.
updateGlobalState(false, _extends({}, _this2.settings, entry.settings));
_this2.focusTrap.unmount(); // Setup initial state.
// Remove any focus traps.
_this2.focusTrap.unmount();
// Setup initial state.
return Promise.resolve(initialState.call(_this2, entry)).then(function () {

@@ -1263,4 +1200,5 @@ // Dispatch custom switch event.

bubbles: true
})); // Return the entry.
}));
// Return the entry.
return entry;

@@ -1272,3 +1210,2 @@ });

};
function switchMode(entry) {

@@ -1278,6 +1215,4 @@ switch (entry.mode) {

return toInline.call(this, entry);
case 'modal':
return toModal.call(this, entry);
default:

@@ -1291,10 +1226,11 @@ throw new Error("\"" + entry.mode + "\" is not a valid drawer mode.");

var _this2 = this;
// Deregister entry incase it has already been registered.
return Promise.resolve(deregister.call(_this2, el, false)).then(function () {
// Save root this for use inside methods API.
var root = _this2; // Create an instance of the Breakpoint class.
var root = _this2;
var breakpoint = new Breakpoint(); // Setup methods API.
// Create an instance of the Breakpoint class.
var breakpoint = new Breakpoint();
// Setup methods API.
var methods = {

@@ -1330,4 +1266,5 @@ open: function open$1(transition, focus) {

}
}; // Setup the drawer object.
};
// Setup the drawer object.
var entry = _extends({

@@ -1339,14 +1276,11 @@ id: el.id,

settings: getConfig(el, _this2.settings.dataConfig),
get breakpoint() {
return getBreakpoint.call(root, el);
},
get state() {
return __state;
},
set state(value) {
__state = value; // Save 'opened' and 'closed' states to store if mode is inline.
__state = value;
// Save 'opened' and 'closed' states to store if mode is inline.
if (value === 'opened' || value === 'closed') {

@@ -1356,7 +1290,5 @@ if (this.mode === 'inline') root.store.set(this.id, this.state);

},
get mode() {
return __mode;
},
set mode(value) {

@@ -1366,12 +1298,11 @@ __mode = value;

}
}, methods);
}, methods); // Create the state var with the initial state.
// Create the state var with the initial state.
var __state = el.classList.contains(entry.getSetting('stateOpened')) ? 'opened' : 'closed';
// Create the mode var with the initial mode.
var __mode = el.classList.contains(entry.getSetting('classModal')) ? 'modal' : 'inline';
var __state = el.classList.contains(entry.getSetting('stateOpened')) ? 'opened' : 'closed'; // Create the mode var with the initial mode.
var __mode = el.classList.contains(entry.getSetting('classModal')) ? 'modal' : 'inline'; // Setup mode specific attributes.
// Setup mode specific attributes.
if (entry.mode === 'modal') {

@@ -1383,13 +1314,13 @@ // Set aria-modal attribute to true.

entry.dialog.removeAttribute('aria-modal');
} // Set tabindex="-1" so dialog is focusable via JS or click.
}
// Set tabindex="-1" so dialog is focusable via JS or click.
if (entry.getSetting('setTabindex')) {
entry.dialog.setAttribute('tabindex', '-1');
} // Add entry to collection.
}
// Add entry to collection.
_this2.collection.push(entry);
_this2.collection.push(entry); // If the entry has a breakpoint...
// If the entry has a breakpoint...
var _temp = function () {

@@ -1404,3 +1335,2 @@ if (entry.breakpoint) {

}();
return _temp && _temp.then ? _temp.then(function () {

@@ -1417,11 +1347,7 @@ // Return the registered entry.

var _handleClick = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
var _handleKeydown = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
var Drawer = /*#__PURE__*/function (_Collection) {
_inheritsLoose(Drawer, _Collection);
function Drawer(options) {
var _this;
_this = _Collection.call(this) || this;

@@ -1438,4 +1364,5 @@ Object.defineProperty(_assertThisInitialized(_this), _handleClick, {

_this.settings = _extends({}, _this.defaults, options);
_this.focusTrap = new FocusTrap(); // Setup local store for inline drawer state management.
_this.focusTrap = new FocusTrap();
// Setup local store for inline drawer state management.
_this.store = localStore(_this.settings.storeKey, _this.settings.store);

@@ -1447,5 +1374,3 @@ _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleClick)[_handleClick] = handleClick.bind(_assertThisInitialized(_this));

}
var _proto = Drawer.prototype;
_proto.init = function init(options) {

@@ -1455,11 +1380,11 @@ if (options === void 0) {

}
try {
var _this3 = this;
// Update settings with passed options.
if (options) _this3.settings = _extends({}, _this3.settings, options); // Get all the modals.
if (options) _this3.settings = _extends({}, _this3.settings, options);
var drawers = document.querySelectorAll(_this3.settings.selectorDrawer); // Register the collections array with modal instances.
// Get all the modals.
var drawers = document.querySelectorAll(_this3.settings.selectorDrawer);
// Register the collections array with modal instances.
return Promise.resolve(_this3.registerCollection(drawers)).then(function () {

@@ -1470,3 +1395,2 @@ // If eventListeners are enabled, init event listeners.

}
return _this3;

@@ -1478,7 +1402,5 @@ });

};
_proto.destroy = function destroy() {
try {
var _this5 = this;
// Remove all entries from the collection.

@@ -1490,3 +1412,2 @@ return Promise.resolve(_this5.deregisterCollection()).then(function () {

}
return _this5;

@@ -1498,15 +1419,10 @@ });

};
_proto.initEventListeners = function initEventListeners() {
document.addEventListener('click', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.addEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.addEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
};
_proto.destroyEventListeners = function destroyEventListeners() {
document.removeEventListener('click', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.removeEventListener('touchend', _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
document.removeEventListener('keydown', _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
};
_proto.register = function register$1(query) {

@@ -1517,3 +1433,2 @@ var els = getDrawerElements.call(this, query);

};
_proto.deregister = function deregister$1(query) {

@@ -1523,15 +1438,11 @@ var entry = this.get(getDrawerID.call(this, query));

};
_proto.open = function open$1(id, transition, focus) {
return open.call(this, id, transition, focus);
};
_proto.close = function close$1(id, transition, focus) {
return close.call(this, id, transition, focus);
};
_proto.toggle = function toggle$1(id, transition, focus) {
return toggle.call(this, id, transition, focus);
};
_createClass(Drawer, [{

@@ -1545,3 +1456,2 @@ key: "activeModal",

}]);
return Drawer;

@@ -1548,0 +1458,0 @@ }(Collection);

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

function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function e(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function i(t,e){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var o=0;function s(t){return"__private_"+o+++"_"+t}function a(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var c=/*#__PURE__*/s("handler"),l=/*#__PURE__*/function(){function t(t,e){Object.defineProperty(this,c,{writable:!0,value:void 0}),this.value=t,a(this,c)[c]=e,this.mql=null}var n=t.prototype;return n.mount=function(t,e){return t&&(this.value=t),e&&(a(this,c)[c]=e),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",a(this,c)[c]):this.mql.addListener(a(this,c)[c]),a(this,c)[c](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c]),this.value=null,a(this,c)[c]=null,this.mql=null,this):this},e(t,[{key:"handler",get:function(){return a(this,c)[c]},set:function(t){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c])),a(this,c)[c]=t}}]),t}();function u(t,e,n){if(!t.s){if(n instanceof d){if(!n.s)return void(n.o=u.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(u.bind(null,t,e),u.bind(null,t,2));t.s=e,t.v=n;var i=t.o;i&&i(t)}}var d=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var i=new t,r=this.s;if(r){var o=1&r?e:n;if(o){try{u(i,1,o(this.v))}catch(t){u(i,2,t)}return i}return this}return this.o=function(t){try{var r=t.v;1&t.s?u(i,1,e?e(r):r):n?u(i,1,n(r)):u(i,2,r)}catch(t){u(i,2,t)}},i},t}();function h(t){return t instanceof d&&1&t.s}var f=/*#__PURE__*/function(){function t(){this.collection=[]}var e=t.prototype;return e.register=function(t){try{var e=this;return Promise.resolve(e.deregister(t)).then(function(){return e.collection.push(t),e.collection})}catch(t){return Promise.reject(t)}},e.deregister=function(t){try{var e=this,n=e.collection.findIndex(function(e){return e===t});if(n>=0){var i=e.collection[n];Object.getOwnPropertyNames(i).forEach(function(t){delete i[t]}),e.collection.splice(n,1)}return Promise.resolve(e.collection)}catch(t){return Promise.reject(t)}},e.registerCollection=function(t){try{var e=this;return Promise.resolve(Promise.all(Array.from(t,function(t){e.register(t)}))).then(function(){return e.collection})}catch(t){return Promise.reject(t)}},e.deregisterCollection=function(){try{var t=function(){return e.collection},e=this,n=function(t,e,n){for(var i;;){var r=t();if(h(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!h(o)){i=1;break}o=o.s}}var s=new d,a=u.bind(null,s,2);return(0===i?r.then(l):1===i?o.then(c):(void 0).then(function(){(r=t())?r.then?r.then(l).then(void 0,a):l(r):u(s,1,o)})).then(void 0,a),s;function c(e){o=e;do{if(!(r=t())||h(r)&&!r.v)return void u(s,1,o);if(r.then)return void r.then(l).then(void 0,a);h(o=n())&&(o=o.v)}while(!o||!o.then);o.then(c).then(void 0,a)}function l(t){t?(o=n())&&o.then?o.then(c).then(void 0,a):c(o):u(s,1,o)}}(function(){return e.collection.length>0},0,function(){return Promise.resolve(e.deregister(e.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(t){return Promise.reject(t)}},e.get=function(t,e){return void 0===e&&(e="id"),this.collection.find(function(n){return n[e]===t})},t}(),v=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'],g=/*#__PURE__*/s("focusable"),m=/*#__PURE__*/s("handleFocusTrap"),p=/*#__PURE__*/s("handleFocusLock"),b=/*#__PURE__*/function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e="[data-focus]"),Object.defineProperty(this,g,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),this.el=t,this.selectorFocus=e,a(this,m)[m]=y.bind(this),a(this,p)[p]=w.bind(this)}var n=t.prototype;return n.mount=function(t,e){t&&(this.el=t),e&&(this.selectorFocus=e),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",a(this,m)[m]),document.removeEventListener("keydown",a(this,p)[p])},n.focus=function(t,e){void 0===t&&(t=this.el),void 0===e&&(e=this.selectorFocus),(t.querySelector(e)||t).focus()},n.getFocusable=function(t){void 0===t&&(t=this.el);var e=[],n=document.activeElement,i=t.scrollTop;return t.querySelectorAll(v.join(",")).forEach(function(t){t.focus(),document.activeElement===t&&e.push(t)}),t.scrollTop=i,n.focus(),e},e(t,[{key:"focusable",get:function(){return a(this,g)[g]},set:function(t){a(this,g)[g]=t,a(this,g)[g].length?(document.removeEventListener("keydown",a(this,p)[p]),document.addEventListener("keydown",a(this,m)[m])):(document.removeEventListener("keydown",a(this,m)[m]),document.addEventListener("keydown",a(this,p)[p]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),t}();function y(t){("Tab"===t.key||9===t.keyCode)&&(t.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(t.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(t.preventDefault(),this.focusableFirst.focus()))}function w(t){("Tab"===t.key||9===t.keyCode)&&t.preventDefault()}function P(t,e){var n=(t.getAttribute("data-"+e)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function E(t,e){var n,i;n=!!t,(i=e.selectorInert)&&document.querySelectorAll(i).forEach(function(t){n?(t.inert=!0,t.setAttribute("aria-hidden",!0)):(t.inert=null,t.removeAttribute("aria-hidden"))}),function(t,e){e&&document.querySelectorAll(e).forEach(function(e){t?e.style.overflow="hidden":e.style.removeProperty("overflow")})}(!!t,e.selectorOverflow)}var L={autoInit:!1,dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",dataBreakpoint:"drawer-breakpoint",dataConfig:"drawer-config",selectorDrawer:".drawer",selectorDialog:".drawer__dialog",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",breakpoints:null,customEventPrefix:"drawer:",eventListeners:!0,store:!0,storeKey:"VB:DrawerState",setTabindex:!0,transition:!0};function O(t){var e=this,n=t.target.closest("\n [data-"+this.settings.dataOpen+"],\n [data-"+this.settings.dataToggle+"],\n [data-"+this.settings.dataClose+"]\n ");n?(t.preventDefault(),n.matches("[data-"+this.settings.dataToggle+"]")&&n.getAttribute("data-"+this.settings.dataToggle).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.toggle()}),n.matches("[data-"+this.settings.dataOpen+"]")&&n.getAttribute("data-"+this.settings.dataOpen).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.open()}),n.matches("[data-"+this.settings.dataClose+"]")&&n.getAttribute("data-"+this.settings.dataClose).trim().split(" ").forEach(function(i){if(i){var r=e.get(i);r.trigger=n,r.close()}else{var o=t.target.closest(e.settings.selectorDrawer);o&&e.close(o)}})):t.target.matches(this.settings.selectorDrawer)&&this.close(t.target.id)}function k(t){if("Escape"===t.key){var e=this.activeModal;e&&this.close(e)}}var j=function(t,e){void 0===e&&(e=!0);try{var n=function(){return i.collection},i=this;if(!t)return Promise.resolve(i.collection);var r=i.collection.findIndex(function(e){return e.id===t.id}),o=function(){if(r>=0){var t=function(){i.store.set(n.id),n.unmountBreakpoint(),Object.getOwnPropertyNames(n).forEach(function(t){delete n[t]}),i.collection.splice(r,1)},n=i.collection[r],o=function(){if(e&&"opened"===n.state)return Promise.resolve(n.close(!1)).then(function(){})}();return o&&o.then?o.then(t):t()}}();return Promise.resolve(o&&o.then?o.then(n):n())}catch(t){return Promise.reject(t)}};function C(t){var e=getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(),n=t.getAttribute("data-"+this.settings.dataBreakpoint);return this.settings.breakpoints&&this.settings.breakpoints[n]?this.settings.breakpoints[n]:getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim()?getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim():n}function x(t){var e=this.get("string"==typeof t?t:t.id);if(e)return e;throw new Error('Drawer not found in collection with id of "'+(t.id||t)+'".')}function S(t){return"string"==typeof t?t:"function"==typeof t.hasAttribute?t.hasAttribute("data-"+this.settings.dataOpen)?t.getAttribute("data-"+this.settings.dataOpen):t.hasAttribute("data-"+this.settings.dataClose)?t.getAttribute("data-"+this.settings.dataClose)||!1:t.hasAttribute("data-"+this.settings.dataToggle)?t.getAttribute("data-"+this.settings.dataToggle):t.closest(this.settings.selectorDrawer)&&(t=t.closest(this.settings.selectorDrawer)).id||!1:!!t.id&&t.id}function A(t){var e=S.call(this,t);if(e){var n=document.querySelector("#"+e),i=n?n.querySelector(this.settings.selectorDialog):null;return n||i?i?{drawer:n,dialog:i}:{error:new Error("Drawer is missing dialog element.")}:{error:new Error('No drawer elements found using the ID: "'+e+'".')}}return{error:new Error("Could not resolve the drawer ID.")}}var q=function(t){try{var e=this,n=function(){if(e.store.get(t.id)){var n="opened"===e.store.get(t.id)?Promise.resolve(t.open(!1,!1)).then(function(){}):Promise.resolve(t.close(!1,!1)).then(function(){});if(n&&n.then)return n.then(function(){})}else t.el.classList.contains(e.settings.stateOpened)?t.state="opened":(t.el.classList.remove(e.settings.stateOpening),t.el.classList.remove(e.settings.stateClosing),t.el.classList.add(e.settings.stateClosed))}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(t){return Promise.reject(t)}};function T(t){"opened"===t.state?"modal"===t.mode?this.focusTrap.mount(t.dialog,this.settings.selectorFocus):this.focusTrap.focus(t.dialog,this.settings.selectorFocus):(t.trigger&&(t.trigger.focus(),t.trigger=null),this.focusTrap.unmount())}var D=function(t,e,i){void 0===i&&(i=!0);try{var r=function(){return i&&T.call(o,s),s.el.dispatchEvent(new CustomEvent(a.customEventPrefix+"opened",{detail:o,bubbles:!0})),s},o=this,s=x.call(o,t),a=n({},o.settings,s.settings);void 0!==e&&(a.transition=e);var c=function(){if("closed"===s.state)return s.state="opening",Promise.resolve((t=s.el,e=a,new Promise(function(n){e.transition?(t.classList.remove(e.stateClosed),t.classList.add(e.stateOpening),t.addEventListener("transitionend",function i(){t.classList.add(e.stateOpened),t.classList.remove(e.stateOpening),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateOpened),t.classList.remove(e.stateClosed),n(t))}))).then(function(){"modal"===s.mode&&E(!0,a),s.state="opened"});var t,e}();return Promise.resolve(c&&c.then?c.then(r):r())}catch(t){return Promise.reject(t)}},F=function(t,e,i){void 0===i&&(i=!0);try{var r=this,o=x.call(r,t),s=n({},r.settings,o.settings);void 0!==e&&(s.transition=e);var a=function(){if("opened"===o.state)return o.state="closing",document.activeElement.blur(),Promise.resolve((t=o.el,e=s,new Promise(function(n){e.transition?(t.classList.add(e.stateClosing),t.classList.remove(e.stateOpened),t.addEventListener("transitionend",function i(){t.classList.remove(e.stateClosing),t.classList.add(e.stateClosed),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateClosed),t.classList.remove(e.stateOpened),n(t))}))).then(function(){"modal"===o.mode&&E(!1,s),i&&T.call(r,o),o.state="closed",o.el.dispatchEvent(new CustomEvent(s.customEventPrefix+"closed",{detail:r,bubbles:!0}))});var t,e}();return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(t){return Promise.reject(t)}},_=function(t,e,n){try{var i=this,r=x.call(i,t);return Promise.resolve("closed"===r.state?D.call(i,r,e,n):F.call(i,r,e,n))}catch(t){return Promise.reject(t)}},I=function(t){try{var e=this;return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),!e.store.get(t.id)&&t.el.classList.contains(t.getSetting("stateOpened"))&&e.store.set(t.id,"opened"),Promise.resolve(F.call(e,t,!1,!1)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}},B=function(t){try{var e=this;return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),E(!1,n({},e.settings,t.settings)),e.focusTrap.unmount(),Promise.resolve(q.call(e,t)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}};function M(t){switch(t.mode){case"inline":return B.call(this,t);case"modal":return I.call(this,t);default:throw new Error('"'+t.mode+'" is not a valid drawer mode.')}}var N=function(t,e){try{var i=this;return Promise.resolve(j.call(i,t,!1)).then(function(){var r=i,o=new l,s={open:function(t,e){return D.call(r,this,t,e)},close:function(t,e){return F.call(r,this,t,e)},toggle:function(t,e){return _.call(r,this,t,e)},deregister:function(){return j.call(r,this)},mountBreakpoint:function(){var t=this.breakpoint,e=this.handleBreakpoint.bind(this);return o.mount(t,e),this},unmountBreakpoint:function(){return o.unmount(),this},handleBreakpoint:function(t){return this.mode=t.matches?"inline":"modal",this},getSetting:function(t){return t in this.settings?this.settings[t]:r.settings[t]}},a=n({id:t.id,el:t,dialog:e,trigger:null,settings:P(t,i.settings.dataConfig),get breakpoint(){return C.call(r,t)},get state(){return c},set state(t){c=t,"opened"!==t&&"closed"!==t||"inline"===this.mode&&r.store.set(this.id,this.state)},get mode(){return u},set mode(t){u=t,M.call(r,this)}},s),c=t.classList.contains(a.getSetting("stateOpened"))?"opened":"closed",u=t.classList.contains(a.getSetting("classModal"))?"modal":"inline";"modal"===a.mode?a.dialog.setAttribute("aria-modal","true"):a.dialog.removeAttribute("aria-modal"),a.getSetting("setTabindex")&&a.dialog.setAttribute("tabindex","-1"),i.collection.push(a);var d=function(){if(!a.breakpoint)return Promise.resolve(q.call(i,a)).then(function(){});a.mountBreakpoint()}();return d&&d.then?d.then(function(){return a}):a})}catch(t){return Promise.reject(t)}},K=/*#__PURE__*/s("handleClick"),V=/*#__PURE__*/s("handleKeydown"),J=/*#__PURE__*/function(t){var o,s;function c(e){var i;return i=t.call(this)||this,Object.defineProperty(r(i),K,{writable:!0,value:void 0}),Object.defineProperty(r(i),V,{writable:!0,value:void 0}),i.defaults=L,i.settings=n({},i.defaults,e),i.focusTrap=new b,i.store=function(t,e){void 0===e&&(e=!0);var n=localStorage.getItem(t),i=n?JSON.parse(n):{};return{get:function(t){return t?i[t]:i},set:function(n,r){return r?i[n]=r:delete i[n],e&&localStorage.setItem(t,JSON.stringify(i)),i}}}(i.settings.storeKey,i.settings.store),a(r(i),K)[K]=O.bind(r(i)),a(r(i),V)[V]=k.bind(r(i)),i.settings.autoInit&&i.init(),i}s=t,(o=c).prototype=Object.create(s.prototype),o.prototype.constructor=o,i(o,s);var l=c.prototype;return l.init=function(t){void 0===t&&(t=null);try{var e=this;t&&(e.settings=n({},e.settings,t));var i=document.querySelectorAll(e.settings.selectorDrawer);return Promise.resolve(e.registerCollection(i)).then(function(){return e.settings.eventListeners&&e.initEventListeners(),e})}catch(t){return Promise.reject(t)}},l.destroy=function(){try{var t=this;return Promise.resolve(t.deregisterCollection()).then(function(){return t.settings.eventListeners&&t.destroyEventListeners(),t})}catch(t){return Promise.reject(t)}},l.initEventListeners=function(){document.addEventListener("click",a(this,K)[K],!1),document.addEventListener("touchend",a(this,K)[K],!1),document.addEventListener("keydown",a(this,V)[V],!1)},l.destroyEventListeners=function(){document.removeEventListener("click",a(this,K)[K],!1),document.removeEventListener("touchend",a(this,K)[K],!1),document.removeEventListener("keydown",a(this,V)[V],!1)},l.register=function(t){var e=A.call(this,t);return e.error?Promise.reject(e.error):N.call(this,e.drawer,e.dialog)},l.deregister=function(t){var e=this.get(S.call(this,t));return j.call(this,e)},l.open=function(t,e,n){return D.call(this,t,e,n)},l.close=function(t,e,n){return F.call(this,t,e,n)},l.toggle=function(t,e,n){return _.call(this,t,e,n)},e(c,[{key:"activeModal",get:function(){return this.collection.find(function(t){return"opened"===t.state&&"modal"===t.mode})}}]),c}(f);export default J;
function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key))?r:String(r),i)}var r}function e(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function i(t,e){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var o=0;function s(t){return"__private_"+o+++"_"+t}function a(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var c=/*#__PURE__*/s("handler"),l=/*#__PURE__*/function(){function t(t,e){Object.defineProperty(this,c,{writable:!0,value:void 0}),this.value=t,a(this,c)[c]=e,this.mql=null}var n=t.prototype;return n.mount=function(t,e){return t&&(this.value=t),e&&(a(this,c)[c]=e),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",a(this,c)[c]):this.mql.addListener(a(this,c)[c]),a(this,c)[c](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c]),this.value=null,a(this,c)[c]=null,this.mql=null,this):this},e(t,[{key:"handler",get:function(){return a(this,c)[c]},set:function(t){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c])),a(this,c)[c]=t}}]),t}();function u(t,e,n){if(!t.s){if(n instanceof d){if(!n.s)return void(n.o=u.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(u.bind(null,t,e),u.bind(null,t,2));t.s=e,t.v=n;const i=t.o;i&&i(t)}}var d=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var i=new t,r=this.s;if(r){var o=1&r?e:n;if(o){try{u(i,1,o(this.v))}catch(t){u(i,2,t)}return i}return this}return this.o=function(t){try{var r=t.v;1&t.s?u(i,1,e?e(r):r):n?u(i,1,n(r)):u(i,2,r)}catch(t){u(i,2,t)}},i},t}();function h(t){return t instanceof d&&1&t.s}var f=/*#__PURE__*/function(){function t(){this.collection=[]}var e=t.prototype;return e.register=function(t){try{var e=this;return Promise.resolve(e.deregister(t)).then(function(){return e.collection.push(t),e.collection})}catch(t){return Promise.reject(t)}},e.deregister=function(t){try{var e=this,n=e.collection.findIndex(function(e){return e===t});if(n>=0){var i=e.collection[n];Object.getOwnPropertyNames(i).forEach(function(t){delete i[t]}),e.collection.splice(n,1)}return Promise.resolve(e.collection)}catch(t){return Promise.reject(t)}},e.registerCollection=function(t){try{var e=this;return Promise.resolve(Promise.all(Array.from(t,function(t){e.register(t)}))).then(function(){return e.collection})}catch(t){return Promise.reject(t)}},e.deregisterCollection=function(){try{var t=function(){return e.collection},e=this,n=function(t,e,n){for(var i;;){var r=t();if(h(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!h(o)){i=1;break}o=o.s}}var s=new d,a=u.bind(null,s,2);return(0===i?r.then(l):1===i?o.then(c):(void 0).then(function(){(r=t())?r.then?r.then(l).then(void 0,a):l(r):u(s,1,o)})).then(void 0,a),s;function c(e){o=e;do{if(!(r=t())||h(r)&&!r.v)return void u(s,1,o);if(r.then)return void r.then(l).then(void 0,a);h(o=n())&&(o=o.v)}while(!o||!o.then);o.then(c).then(void 0,a)}function l(t){t?(o=n())&&o.then?o.then(c).then(void 0,a):c(o):u(s,1,o)}}(function(){return e.collection.length>0},0,function(){return Promise.resolve(e.deregister(e.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(t){return Promise.reject(t)}},e.get=function(t,e){return void 0===e&&(e="id"),this.collection.find(function(n){return n[e]===t})},t}(),v=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'],g=/*#__PURE__*/s("focusable"),m=/*#__PURE__*/s("handleFocusTrap"),p=/*#__PURE__*/s("handleFocusLock"),b=/*#__PURE__*/function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e="[data-focus]"),Object.defineProperty(this,g,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),this.el=t,this.selectorFocus=e,a(this,m)[m]=y.bind(this),a(this,p)[p]=w.bind(this)}var n=t.prototype;return n.mount=function(t,e){t&&(this.el=t),e&&(this.selectorFocus=e),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",a(this,m)[m]),document.removeEventListener("keydown",a(this,p)[p])},n.focus=function(t,e){void 0===t&&(t=this.el),void 0===e&&(e=this.selectorFocus),(t.querySelector(e)||t).focus()},n.getFocusable=function(t){void 0===t&&(t=this.el);var e=[],n=document.activeElement,i=t.scrollTop;return t.querySelectorAll(v.join(",")).forEach(function(t){t.focus(),document.activeElement===t&&e.push(t)}),t.scrollTop=i,n.focus(),e},e(t,[{key:"focusable",get:function(){return a(this,g)[g]},set:function(t){a(this,g)[g]=t,a(this,g)[g].length?(document.removeEventListener("keydown",a(this,p)[p]),document.addEventListener("keydown",a(this,m)[m])):(document.removeEventListener("keydown",a(this,m)[m]),document.addEventListener("keydown",a(this,p)[p]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),t}();function y(t){("Tab"===t.key||9===t.keyCode)&&(t.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(t.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(t.preventDefault(),this.focusableFirst.focus()))}function w(t){("Tab"===t.key||9===t.keyCode)&&t.preventDefault()}function P(t,e){var n=(t.getAttribute("data-"+e)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function E(t,e){var n,i;n=!!t,(i=e.selectorInert)&&document.querySelectorAll(i).forEach(function(t){n?(t.inert=!0,t.setAttribute("aria-hidden",!0)):(t.inert=null,t.removeAttribute("aria-hidden"))}),function(t,e){e&&document.querySelectorAll(e).forEach(function(e){t?e.style.overflow="hidden":e.style.removeProperty("overflow")})}(!!t,e.selectorOverflow)}var L={autoInit:!1,dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",dataBreakpoint:"drawer-breakpoint",dataConfig:"drawer-config",selectorDrawer:".drawer",selectorDialog:".drawer__dialog",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",breakpoints:null,customEventPrefix:"drawer:",eventListeners:!0,store:!0,storeKey:"VB:DrawerState",setTabindex:!0,transition:!0};function O(t){var e=this,n=t.target.closest("\n [data-"+this.settings.dataOpen+"],\n [data-"+this.settings.dataToggle+"],\n [data-"+this.settings.dataClose+"]\n ");n?(t.preventDefault(),n.matches("[data-"+this.settings.dataToggle+"]")&&n.getAttribute("data-"+this.settings.dataToggle).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.toggle()}),n.matches("[data-"+this.settings.dataOpen+"]")&&n.getAttribute("data-"+this.settings.dataOpen).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.open()}),n.matches("[data-"+this.settings.dataClose+"]")&&n.getAttribute("data-"+this.settings.dataClose).trim().split(" ").forEach(function(i){if(i){var r=e.get(i);r.trigger=n,r.close()}else{var o=t.target.closest(e.settings.selectorDrawer);o&&e.close(o)}})):t.target.matches(this.settings.selectorDrawer)&&this.close(t.target.id)}function k(t){if("Escape"===t.key){var e=this.activeModal;e&&this.close(e)}}var j=function(t,e){void 0===e&&(e=!0);try{var n=function(){return i.collection},i=this;if(!t)return Promise.resolve(i.collection);var r=i.collection.findIndex(function(e){return e.id===t.id}),o=function(){if(r>=0){var t=function(){i.store.set(n.id),n.unmountBreakpoint(),Object.getOwnPropertyNames(n).forEach(function(t){delete n[t]}),i.collection.splice(r,1)},n=i.collection[r],o=function(){if(e&&"opened"===n.state)return Promise.resolve(n.close(!1)).then(function(){})}();return o&&o.then?o.then(t):t()}}();return Promise.resolve(o&&o.then?o.then(n):n())}catch(t){return Promise.reject(t)}};function C(t){var e=getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(),n=t.getAttribute("data-"+this.settings.dataBreakpoint);return this.settings.breakpoints&&this.settings.breakpoints[n]?this.settings.breakpoints[n]:getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim()?getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim():n}function S(t){var e=this.get("string"==typeof t?t:t.id);if(e)return e;throw new Error('Drawer not found in collection with id of "'+(t.id||t)+'".')}function x(t){return"string"==typeof t?t:"function"==typeof t.hasAttribute?t.hasAttribute("data-"+this.settings.dataOpen)?t.getAttribute("data-"+this.settings.dataOpen):t.hasAttribute("data-"+this.settings.dataClose)?t.getAttribute("data-"+this.settings.dataClose)||!1:t.hasAttribute("data-"+this.settings.dataToggle)?t.getAttribute("data-"+this.settings.dataToggle):t.closest(this.settings.selectorDrawer)&&(t=t.closest(this.settings.selectorDrawer)).id||!1:!!t.id&&t.id}function A(t){var e=x.call(this,t);if(e){var n=document.querySelector("#"+e),i=n?n.querySelector(this.settings.selectorDialog):null;return n||i?i?{drawer:n,dialog:i}:{error:new Error("Drawer is missing dialog element.")}:{error:new Error('No drawer elements found using the ID: "'+e+'".')}}return{error:new Error("Could not resolve the drawer ID.")}}var q=function(t){try{var e=this,n=function(){if(e.store.get(t.id)){var n="opened"===e.store.get(t.id)?Promise.resolve(t.open(!1,!1)).then(function(){}):Promise.resolve(t.close(!1,!1)).then(function(){});if(n&&n.then)return n.then(function(){})}else t.el.classList.contains(e.settings.stateOpened)?t.state="opened":(t.el.classList.remove(e.settings.stateOpening),t.el.classList.remove(e.settings.stateClosing),t.el.classList.add(e.settings.stateClosed))}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(t){return Promise.reject(t)}};function T(t){"opened"===t.state?"modal"===t.mode?this.focusTrap.mount(t.dialog,this.settings.selectorFocus):this.focusTrap.focus(t.dialog,this.settings.selectorFocus):(t.trigger&&(t.trigger.focus(),t.trigger=null),this.focusTrap.unmount())}var D=function(t,e,i){void 0===i&&(i=!0);try{var r=function(){return i&&T.call(o,s),s.el.dispatchEvent(new CustomEvent(a.customEventPrefix+"opened",{detail:o,bubbles:!0})),s},o=this,s=S.call(o,t),a=n({},o.settings,s.settings);void 0!==e&&(a.transition=e);var c=function(){if("closed"===s.state)return s.state="opening",Promise.resolve((t=s.el,e=a,new Promise(function(n){e.transition?(t.classList.remove(e.stateClosed),t.classList.add(e.stateOpening),t.addEventListener("transitionend",function i(){t.classList.add(e.stateOpened),t.classList.remove(e.stateOpening),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateOpened),t.classList.remove(e.stateClosed),n(t))}))).then(function(){"modal"===s.mode&&E(!0,a),s.state="opened"});var t,e}();return Promise.resolve(c&&c.then?c.then(r):r())}catch(t){return Promise.reject(t)}},F=function(t,e,i){void 0===i&&(i=!0);try{var r=this,o=S.call(r,t),s=n({},r.settings,o.settings);void 0!==e&&(s.transition=e);var a=function(){if("opened"===o.state)return o.state="closing",document.activeElement.blur(),Promise.resolve((t=o.el,e=s,new Promise(function(n){e.transition?(t.classList.add(e.stateClosing),t.classList.remove(e.stateOpened),t.addEventListener("transitionend",function i(){t.classList.remove(e.stateClosing),t.classList.add(e.stateClosed),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateClosed),t.classList.remove(e.stateOpened),n(t))}))).then(function(){"modal"===o.mode&&E(!1,s),i&&T.call(r,o),o.state="closed",o.el.dispatchEvent(new CustomEvent(s.customEventPrefix+"closed",{detail:r,bubbles:!0}))});var t,e}();return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(t){return Promise.reject(t)}},_=function(t,e,n){try{var i=this,r=S.call(i,t);return Promise.resolve("closed"===r.state?D.call(i,r,e,n):F.call(i,r,e,n))}catch(t){return Promise.reject(t)}},I=function(t){try{var e=this;return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),!e.store.get(t.id)&&t.el.classList.contains(t.getSetting("stateOpened"))&&e.store.set(t.id,"opened"),Promise.resolve(F.call(e,t,!1,!1)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}},B=function(t){try{var e=this;return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),E(!1,n({},e.settings,t.settings)),e.focusTrap.unmount(),Promise.resolve(q.call(e,t)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}};function M(t){switch(t.mode){case"inline":return B.call(this,t);case"modal":return I.call(this,t);default:throw new Error('"'+t.mode+'" is not a valid drawer mode.')}}var N=function(t,e){try{var i=this;return Promise.resolve(j.call(i,t,!1)).then(function(){var r=i,o=new l,s={open:function(t,e){return D.call(r,this,t,e)},close:function(t,e){return F.call(r,this,t,e)},toggle:function(t,e){return _.call(r,this,t,e)},deregister:function(){return j.call(r,this)},mountBreakpoint:function(){var t=this.breakpoint,e=this.handleBreakpoint.bind(this);return o.mount(t,e),this},unmountBreakpoint:function(){return o.unmount(),this},handleBreakpoint:function(t){return this.mode=t.matches?"inline":"modal",this},getSetting:function(t){return t in this.settings?this.settings[t]:r.settings[t]}},a=n({id:t.id,el:t,dialog:e,trigger:null,settings:P(t,i.settings.dataConfig),get breakpoint(){return C.call(r,t)},get state(){return c},set state(t){c=t,"opened"!==t&&"closed"!==t||"inline"===this.mode&&r.store.set(this.id,this.state)},get mode(){return u},set mode(t){u=t,M.call(r,this)}},s),c=t.classList.contains(a.getSetting("stateOpened"))?"opened":"closed",u=t.classList.contains(a.getSetting("classModal"))?"modal":"inline";"modal"===a.mode?a.dialog.setAttribute("aria-modal","true"):a.dialog.removeAttribute("aria-modal"),a.getSetting("setTabindex")&&a.dialog.setAttribute("tabindex","-1"),i.collection.push(a);var d=function(){if(!a.breakpoint)return Promise.resolve(q.call(i,a)).then(function(){});a.mountBreakpoint()}();return d&&d.then?d.then(function(){return a}):a})}catch(t){return Promise.reject(t)}},K=/*#__PURE__*/s("handleClick"),V=/*#__PURE__*/s("handleKeydown"),J=/*#__PURE__*/function(t){var o,s;function c(e){var i;return i=t.call(this)||this,Object.defineProperty(r(i),K,{writable:!0,value:void 0}),Object.defineProperty(r(i),V,{writable:!0,value:void 0}),i.defaults=L,i.settings=n({},i.defaults,e),i.focusTrap=new b,i.store=function(t,e){void 0===e&&(e=!0);var n=localStorage.getItem(t),i=n?JSON.parse(n):{};return{get:function(t){return t?i[t]:i},set:function(n,r){return r?i[n]=r:delete i[n],e&&localStorage.setItem(t,JSON.stringify(i)),i}}}(i.settings.storeKey,i.settings.store),a(r(i),K)[K]=O.bind(r(i)),a(r(i),V)[V]=k.bind(r(i)),i.settings.autoInit&&i.init(),i}s=t,(o=c).prototype=Object.create(s.prototype),o.prototype.constructor=o,i(o,s);var l=c.prototype;return l.init=function(t){void 0===t&&(t=null);try{var e=this;t&&(e.settings=n({},e.settings,t));var i=document.querySelectorAll(e.settings.selectorDrawer);return Promise.resolve(e.registerCollection(i)).then(function(){return e.settings.eventListeners&&e.initEventListeners(),e})}catch(t){return Promise.reject(t)}},l.destroy=function(){try{var t=this;return Promise.resolve(t.deregisterCollection()).then(function(){return t.settings.eventListeners&&t.destroyEventListeners(),t})}catch(t){return Promise.reject(t)}},l.initEventListeners=function(){document.addEventListener("click",a(this,K)[K],!1),document.addEventListener("keydown",a(this,V)[V],!1)},l.destroyEventListeners=function(){document.removeEventListener("click",a(this,K)[K],!1),document.removeEventListener("keydown",a(this,V)[V],!1)},l.register=function(t){var e=A.call(this,t);return e.error?Promise.reject(e.error):N.call(this,e.drawer,e.dialog)},l.deregister=function(t){var e=this.get(x.call(this,t));return j.call(this,e)},l.open=function(t,e,n){return D.call(this,t,e,n)},l.close=function(t,e,n){return F.call(this,t,e,n)},l.toggle=function(t,e,n){return _.call(this,t,e,n)},e(c,[{key:"activeModal",get:function(){return this.collection.find(function(t){return"opened"===t.state&&"modal"===t.mode})}}]),c}(f);export default J;
//# sourceMappingURL=scripts.esm.js.map

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

function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function e(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function i(t,e){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var o=0;function s(t){return"__private_"+o+++"_"+t}function a(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var c=/*#__PURE__*/s("handler"),l=/*#__PURE__*/function(){function t(t,e){Object.defineProperty(this,c,{writable:!0,value:void 0}),this.value=t,a(this,c)[c]=e,this.mql=null}var n=t.prototype;return n.mount=function(t,e){return t&&(this.value=t),e&&(a(this,c)[c]=e),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",a(this,c)[c]):this.mql.addListener(a(this,c)[c]),a(this,c)[c](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c]),this.value=null,a(this,c)[c]=null,this.mql=null,this):this},e(t,[{key:"handler",get:function(){return a(this,c)[c]},set:function(t){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c])),a(this,c)[c]=t}}]),t}();function u(t,e,n){if(!t.s){if(n instanceof d){if(!n.s)return void(n.o=u.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(u.bind(null,t,e),u.bind(null,t,2));t.s=e,t.v=n;var i=t.o;i&&i(t)}}var d=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var i=new t,r=this.s;if(r){var o=1&r?e:n;if(o){try{u(i,1,o(this.v))}catch(t){u(i,2,t)}return i}return this}return this.o=function(t){try{var r=t.v;1&t.s?u(i,1,e?e(r):r):n?u(i,1,n(r)):u(i,2,r)}catch(t){u(i,2,t)}},i},t}();function h(t){return t instanceof d&&1&t.s}var f=/*#__PURE__*/function(){function t(){this.collection=[]}var e=t.prototype;return e.register=function(t){try{var e=this;return Promise.resolve(e.deregister(t)).then(function(){return e.collection.push(t),e.collection})}catch(t){return Promise.reject(t)}},e.deregister=function(t){try{var e=this,n=e.collection.findIndex(function(e){return e===t});if(n>=0){var i=e.collection[n];Object.getOwnPropertyNames(i).forEach(function(t){delete i[t]}),e.collection.splice(n,1)}return Promise.resolve(e.collection)}catch(t){return Promise.reject(t)}},e.registerCollection=function(t){try{var e=this;return Promise.resolve(Promise.all(Array.from(t,function(t){e.register(t)}))).then(function(){return e.collection})}catch(t){return Promise.reject(t)}},e.deregisterCollection=function(){try{var t=function(){return e.collection},e=this,n=function(t,e,n){for(var i;;){var r=t();if(h(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!h(o)){i=1;break}o=o.s}}var s=new d,a=u.bind(null,s,2);return(0===i?r.then(l):1===i?o.then(c):(void 0).then(function(){(r=t())?r.then?r.then(l).then(void 0,a):l(r):u(s,1,o)})).then(void 0,a),s;function c(e){o=e;do{if(!(r=t())||h(r)&&!r.v)return void u(s,1,o);if(r.then)return void r.then(l).then(void 0,a);h(o=n())&&(o=o.v)}while(!o||!o.then);o.then(c).then(void 0,a)}function l(t){t?(o=n())&&o.then?o.then(c).then(void 0,a):c(o):u(s,1,o)}}(function(){return e.collection.length>0},0,function(){return Promise.resolve(e.deregister(e.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(t){return Promise.reject(t)}},e.get=function(t,e){return void 0===e&&(e="id"),this.collection.find(function(n){return n[e]===t})},t}(),v=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'],g=/*#__PURE__*/s("focusable"),m=/*#__PURE__*/s("handleFocusTrap"),p=/*#__PURE__*/s("handleFocusLock"),b=/*#__PURE__*/function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e="[data-focus]"),Object.defineProperty(this,g,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),this.el=t,this.selectorFocus=e,a(this,m)[m]=y.bind(this),a(this,p)[p]=w.bind(this)}var n=t.prototype;return n.mount=function(t,e){t&&(this.el=t),e&&(this.selectorFocus=e),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",a(this,m)[m]),document.removeEventListener("keydown",a(this,p)[p])},n.focus=function(t,e){void 0===t&&(t=this.el),void 0===e&&(e=this.selectorFocus),(t.querySelector(e)||t).focus()},n.getFocusable=function(t){void 0===t&&(t=this.el);var e=[],n=document.activeElement,i=t.scrollTop;return t.querySelectorAll(v.join(",")).forEach(function(t){t.focus(),document.activeElement===t&&e.push(t)}),t.scrollTop=i,n.focus(),e},e(t,[{key:"focusable",get:function(){return a(this,g)[g]},set:function(t){a(this,g)[g]=t,a(this,g)[g].length?(document.removeEventListener("keydown",a(this,p)[p]),document.addEventListener("keydown",a(this,m)[m])):(document.removeEventListener("keydown",a(this,m)[m]),document.addEventListener("keydown",a(this,p)[p]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),t}();function y(t){("Tab"===t.key||9===t.keyCode)&&(t.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(t.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(t.preventDefault(),this.focusableFirst.focus()))}function w(t){("Tab"===t.key||9===t.keyCode)&&t.preventDefault()}function P(t,e){var n=(t.getAttribute("data-"+e)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function E(t,e){var n,i;n=!!t,(i=e.selectorInert)&&document.querySelectorAll(i).forEach(function(t){n?(t.inert=!0,t.setAttribute("aria-hidden",!0)):(t.inert=null,t.removeAttribute("aria-hidden"))}),function(t,e){e&&document.querySelectorAll(e).forEach(function(e){t?e.style.overflow="hidden":e.style.removeProperty("overflow")})}(!!t,e.selectorOverflow)}var L={autoInit:!1,dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",dataBreakpoint:"drawer-breakpoint",dataConfig:"drawer-config",selectorDrawer:".drawer",selectorDialog:".drawer__dialog",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",breakpoints:null,customEventPrefix:"drawer:",eventListeners:!0,store:!0,storeKey:"VB:DrawerState",setTabindex:!0,transition:!0};function O(t){var e=this,n=t.target.closest("\n [data-"+this.settings.dataOpen+"],\n [data-"+this.settings.dataToggle+"],\n [data-"+this.settings.dataClose+"]\n ");n?(t.preventDefault(),n.matches("[data-"+this.settings.dataToggle+"]")&&n.getAttribute("data-"+this.settings.dataToggle).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.toggle()}),n.matches("[data-"+this.settings.dataOpen+"]")&&n.getAttribute("data-"+this.settings.dataOpen).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.open()}),n.matches("[data-"+this.settings.dataClose+"]")&&n.getAttribute("data-"+this.settings.dataClose).trim().split(" ").forEach(function(i){if(i){var r=e.get(i);r.trigger=n,r.close()}else{var o=t.target.closest(e.settings.selectorDrawer);o&&e.close(o)}})):t.target.matches(this.settings.selectorDrawer)&&this.close(t.target.id)}function k(t){if("Escape"===t.key){var e=this.activeModal;e&&this.close(e)}}var j=function(t,e){void 0===e&&(e=!0);try{var n=function(){return i.collection},i=this;if(!t)return Promise.resolve(i.collection);var r=i.collection.findIndex(function(e){return e.id===t.id}),o=function(){if(r>=0){var t=function(){i.store.set(n.id),n.unmountBreakpoint(),Object.getOwnPropertyNames(n).forEach(function(t){delete n[t]}),i.collection.splice(r,1)},n=i.collection[r],o=function(){if(e&&"opened"===n.state)return Promise.resolve(n.close(!1)).then(function(){})}();return o&&o.then?o.then(t):t()}}();return Promise.resolve(o&&o.then?o.then(n):n())}catch(t){return Promise.reject(t)}};function C(t){var e=getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(),n=t.getAttribute("data-"+this.settings.dataBreakpoint);return this.settings.breakpoints&&this.settings.breakpoints[n]?this.settings.breakpoints[n]:getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim()?getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim():n}function x(t){var e=this.get("string"==typeof t?t:t.id);if(e)return e;throw new Error('Drawer not found in collection with id of "'+(t.id||t)+'".')}function S(t){return"string"==typeof t?t:"function"==typeof t.hasAttribute?t.hasAttribute("data-"+this.settings.dataOpen)?t.getAttribute("data-"+this.settings.dataOpen):t.hasAttribute("data-"+this.settings.dataClose)?t.getAttribute("data-"+this.settings.dataClose)||!1:t.hasAttribute("data-"+this.settings.dataToggle)?t.getAttribute("data-"+this.settings.dataToggle):t.closest(this.settings.selectorDrawer)&&(t=t.closest(this.settings.selectorDrawer)).id||!1:!!t.id&&t.id}function A(t){var e=S.call(this,t);if(e){var n=document.querySelector("#"+e),i=n?n.querySelector(this.settings.selectorDialog):null;return n||i?i?{drawer:n,dialog:i}:{error:new Error("Drawer is missing dialog element.")}:{error:new Error('No drawer elements found using the ID: "'+e+'".')}}return{error:new Error("Could not resolve the drawer ID.")}}var q=function(t){try{var e=this,n=function(){if(e.store.get(t.id)){var n="opened"===e.store.get(t.id)?Promise.resolve(t.open(!1,!1)).then(function(){}):Promise.resolve(t.close(!1,!1)).then(function(){});if(n&&n.then)return n.then(function(){})}else t.el.classList.contains(e.settings.stateOpened)?t.state="opened":(t.el.classList.remove(e.settings.stateOpening),t.el.classList.remove(e.settings.stateClosing),t.el.classList.add(e.settings.stateClosed))}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(t){return Promise.reject(t)}};function T(t){"opened"===t.state?"modal"===t.mode?this.focusTrap.mount(t.dialog,this.settings.selectorFocus):this.focusTrap.focus(t.dialog,this.settings.selectorFocus):(t.trigger&&(t.trigger.focus(),t.trigger=null),this.focusTrap.unmount())}var D=function(t,e,i){void 0===i&&(i=!0);try{var r=function(){return i&&T.call(o,s),s.el.dispatchEvent(new CustomEvent(a.customEventPrefix+"opened",{detail:o,bubbles:!0})),s},o=this,s=x.call(o,t),a=n({},o.settings,s.settings);void 0!==e&&(a.transition=e);var c=function(){if("closed"===s.state)return s.state="opening",Promise.resolve((t=s.el,e=a,new Promise(function(n){e.transition?(t.classList.remove(e.stateClosed),t.classList.add(e.stateOpening),t.addEventListener("transitionend",function i(){t.classList.add(e.stateOpened),t.classList.remove(e.stateOpening),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateOpened),t.classList.remove(e.stateClosed),n(t))}))).then(function(){"modal"===s.mode&&E(!0,a),s.state="opened"});var t,e}();return Promise.resolve(c&&c.then?c.then(r):r())}catch(t){return Promise.reject(t)}},F=function(t,e,i){void 0===i&&(i=!0);try{var r=this,o=x.call(r,t),s=n({},r.settings,o.settings);void 0!==e&&(s.transition=e);var a=function(){if("opened"===o.state)return o.state="closing",document.activeElement.blur(),Promise.resolve((t=o.el,e=s,new Promise(function(n){e.transition?(t.classList.add(e.stateClosing),t.classList.remove(e.stateOpened),t.addEventListener("transitionend",function i(){t.classList.remove(e.stateClosing),t.classList.add(e.stateClosed),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateClosed),t.classList.remove(e.stateOpened),n(t))}))).then(function(){"modal"===o.mode&&E(!1,s),i&&T.call(r,o),o.state="closed",o.el.dispatchEvent(new CustomEvent(s.customEventPrefix+"closed",{detail:r,bubbles:!0}))});var t,e}();return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(t){return Promise.reject(t)}},_=function(t,e,n){try{var i=this,r=x.call(i,t);return Promise.resolve("closed"===r.state?D.call(i,r,e,n):F.call(i,r,e,n))}catch(t){return Promise.reject(t)}},I=function(t){try{var e=this;return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),!e.store.get(t.id)&&t.el.classList.contains(t.getSetting("stateOpened"))&&e.store.set(t.id,"opened"),Promise.resolve(F.call(e,t,!1,!1)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}},B=function(t){try{var e=this;return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),E(!1,n({},e.settings,t.settings)),e.focusTrap.unmount(),Promise.resolve(q.call(e,t)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}};function M(t){switch(t.mode){case"inline":return B.call(this,t);case"modal":return I.call(this,t);default:throw new Error('"'+t.mode+'" is not a valid drawer mode.')}}var N=function(t,e){try{var i=this;return Promise.resolve(j.call(i,t,!1)).then(function(){var r=i,o=new l,s={open:function(t,e){return D.call(r,this,t,e)},close:function(t,e){return F.call(r,this,t,e)},toggle:function(t,e){return _.call(r,this,t,e)},deregister:function(){return j.call(r,this)},mountBreakpoint:function(){var t=this.breakpoint,e=this.handleBreakpoint.bind(this);return o.mount(t,e),this},unmountBreakpoint:function(){return o.unmount(),this},handleBreakpoint:function(t){return this.mode=t.matches?"inline":"modal",this},getSetting:function(t){return t in this.settings?this.settings[t]:r.settings[t]}},a=n({id:t.id,el:t,dialog:e,trigger:null,settings:P(t,i.settings.dataConfig),get breakpoint(){return C.call(r,t)},get state(){return c},set state(t){c=t,"opened"!==t&&"closed"!==t||"inline"===this.mode&&r.store.set(this.id,this.state)},get mode(){return u},set mode(t){u=t,M.call(r,this)}},s),c=t.classList.contains(a.getSetting("stateOpened"))?"opened":"closed",u=t.classList.contains(a.getSetting("classModal"))?"modal":"inline";"modal"===a.mode?a.dialog.setAttribute("aria-modal","true"):a.dialog.removeAttribute("aria-modal"),a.getSetting("setTabindex")&&a.dialog.setAttribute("tabindex","-1"),i.collection.push(a);var d=function(){if(!a.breakpoint)return Promise.resolve(q.call(i,a)).then(function(){});a.mountBreakpoint()}();return d&&d.then?d.then(function(){return a}):a})}catch(t){return Promise.reject(t)}},K=/*#__PURE__*/s("handleClick"),V=/*#__PURE__*/s("handleKeydown");module.exports=/*#__PURE__*/function(t){var o,s;function c(e){var i;return i=t.call(this)||this,Object.defineProperty(r(i),K,{writable:!0,value:void 0}),Object.defineProperty(r(i),V,{writable:!0,value:void 0}),i.defaults=L,i.settings=n({},i.defaults,e),i.focusTrap=new b,i.store=function(t,e){void 0===e&&(e=!0);var n=localStorage.getItem(t),i=n?JSON.parse(n):{};return{get:function(t){return t?i[t]:i},set:function(n,r){return r?i[n]=r:delete i[n],e&&localStorage.setItem(t,JSON.stringify(i)),i}}}(i.settings.storeKey,i.settings.store),a(r(i),K)[K]=O.bind(r(i)),a(r(i),V)[V]=k.bind(r(i)),i.settings.autoInit&&i.init(),i}s=t,(o=c).prototype=Object.create(s.prototype),o.prototype.constructor=o,i(o,s);var l=c.prototype;return l.init=function(t){void 0===t&&(t=null);try{var e=this;t&&(e.settings=n({},e.settings,t));var i=document.querySelectorAll(e.settings.selectorDrawer);return Promise.resolve(e.registerCollection(i)).then(function(){return e.settings.eventListeners&&e.initEventListeners(),e})}catch(t){return Promise.reject(t)}},l.destroy=function(){try{var t=this;return Promise.resolve(t.deregisterCollection()).then(function(){return t.settings.eventListeners&&t.destroyEventListeners(),t})}catch(t){return Promise.reject(t)}},l.initEventListeners=function(){document.addEventListener("click",a(this,K)[K],!1),document.addEventListener("touchend",a(this,K)[K],!1),document.addEventListener("keydown",a(this,V)[V],!1)},l.destroyEventListeners=function(){document.removeEventListener("click",a(this,K)[K],!1),document.removeEventListener("touchend",a(this,K)[K],!1),document.removeEventListener("keydown",a(this,V)[V],!1)},l.register=function(t){var e=A.call(this,t);return e.error?Promise.reject(e.error):N.call(this,e.drawer,e.dialog)},l.deregister=function(t){var e=this.get(S.call(this,t));return j.call(this,e)},l.open=function(t,e,n){return D.call(this,t,e,n)},l.close=function(t,e,n){return F.call(this,t,e,n)},l.toggle=function(t,e,n){return _.call(this,t,e,n)},e(c,[{key:"activeModal",get:function(){return this.collection.find(function(t){return"opened"===t.state&&"modal"===t.mode})}}]),c}(f);
function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key))?r:String(r),i)}var r}function e(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function i(t,e){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var o=0;function s(t){return"__private_"+o+++"_"+t}function a(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var c=/*#__PURE__*/s("handler"),l=/*#__PURE__*/function(){function t(t,e){Object.defineProperty(this,c,{writable:!0,value:void 0}),this.value=t,a(this,c)[c]=e,this.mql=null}var n=t.prototype;return n.mount=function(t,e){return t&&(this.value=t),e&&(a(this,c)[c]=e),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",a(this,c)[c]):this.mql.addListener(a(this,c)[c]),a(this,c)[c](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c]),this.value=null,a(this,c)[c]=null,this.mql=null,this):this},e(t,[{key:"handler",get:function(){return a(this,c)[c]},set:function(t){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c])),a(this,c)[c]=t}}]),t}();function u(t,e,n){if(!t.s){if(n instanceof d){if(!n.s)return void(n.o=u.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(u.bind(null,t,e),u.bind(null,t,2));t.s=e,t.v=n;const i=t.o;i&&i(t)}}var d=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var i=new t,r=this.s;if(r){var o=1&r?e:n;if(o){try{u(i,1,o(this.v))}catch(t){u(i,2,t)}return i}return this}return this.o=function(t){try{var r=t.v;1&t.s?u(i,1,e?e(r):r):n?u(i,1,n(r)):u(i,2,r)}catch(t){u(i,2,t)}},i},t}();function h(t){return t instanceof d&&1&t.s}var f=/*#__PURE__*/function(){function t(){this.collection=[]}var e=t.prototype;return e.register=function(t){try{var e=this;return Promise.resolve(e.deregister(t)).then(function(){return e.collection.push(t),e.collection})}catch(t){return Promise.reject(t)}},e.deregister=function(t){try{var e=this,n=e.collection.findIndex(function(e){return e===t});if(n>=0){var i=e.collection[n];Object.getOwnPropertyNames(i).forEach(function(t){delete i[t]}),e.collection.splice(n,1)}return Promise.resolve(e.collection)}catch(t){return Promise.reject(t)}},e.registerCollection=function(t){try{var e=this;return Promise.resolve(Promise.all(Array.from(t,function(t){e.register(t)}))).then(function(){return e.collection})}catch(t){return Promise.reject(t)}},e.deregisterCollection=function(){try{var t=function(){return e.collection},e=this,n=function(t,e,n){for(var i;;){var r=t();if(h(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!h(o)){i=1;break}o=o.s}}var s=new d,a=u.bind(null,s,2);return(0===i?r.then(l):1===i?o.then(c):(void 0).then(function(){(r=t())?r.then?r.then(l).then(void 0,a):l(r):u(s,1,o)})).then(void 0,a),s;function c(e){o=e;do{if(!(r=t())||h(r)&&!r.v)return void u(s,1,o);if(r.then)return void r.then(l).then(void 0,a);h(o=n())&&(o=o.v)}while(!o||!o.then);o.then(c).then(void 0,a)}function l(t){t?(o=n())&&o.then?o.then(c).then(void 0,a):c(o):u(s,1,o)}}(function(){return e.collection.length>0},0,function(){return Promise.resolve(e.deregister(e.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(t){return Promise.reject(t)}},e.get=function(t,e){return void 0===e&&(e="id"),this.collection.find(function(n){return n[e]===t})},t}(),v=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'],g=/*#__PURE__*/s("focusable"),m=/*#__PURE__*/s("handleFocusTrap"),p=/*#__PURE__*/s("handleFocusLock"),b=/*#__PURE__*/function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e="[data-focus]"),Object.defineProperty(this,g,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),this.el=t,this.selectorFocus=e,a(this,m)[m]=y.bind(this),a(this,p)[p]=w.bind(this)}var n=t.prototype;return n.mount=function(t,e){t&&(this.el=t),e&&(this.selectorFocus=e),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",a(this,m)[m]),document.removeEventListener("keydown",a(this,p)[p])},n.focus=function(t,e){void 0===t&&(t=this.el),void 0===e&&(e=this.selectorFocus),(t.querySelector(e)||t).focus()},n.getFocusable=function(t){void 0===t&&(t=this.el);var e=[],n=document.activeElement,i=t.scrollTop;return t.querySelectorAll(v.join(",")).forEach(function(t){t.focus(),document.activeElement===t&&e.push(t)}),t.scrollTop=i,n.focus(),e},e(t,[{key:"focusable",get:function(){return a(this,g)[g]},set:function(t){a(this,g)[g]=t,a(this,g)[g].length?(document.removeEventListener("keydown",a(this,p)[p]),document.addEventListener("keydown",a(this,m)[m])):(document.removeEventListener("keydown",a(this,m)[m]),document.addEventListener("keydown",a(this,p)[p]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),t}();function y(t){("Tab"===t.key||9===t.keyCode)&&(t.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(t.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(t.preventDefault(),this.focusableFirst.focus()))}function w(t){("Tab"===t.key||9===t.keyCode)&&t.preventDefault()}function P(t,e){var n=(t.getAttribute("data-"+e)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function E(t,e){var n,i;n=!!t,(i=e.selectorInert)&&document.querySelectorAll(i).forEach(function(t){n?(t.inert=!0,t.setAttribute("aria-hidden",!0)):(t.inert=null,t.removeAttribute("aria-hidden"))}),function(t,e){e&&document.querySelectorAll(e).forEach(function(e){t?e.style.overflow="hidden":e.style.removeProperty("overflow")})}(!!t,e.selectorOverflow)}var L={autoInit:!1,dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",dataBreakpoint:"drawer-breakpoint",dataConfig:"drawer-config",selectorDrawer:".drawer",selectorDialog:".drawer__dialog",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",breakpoints:null,customEventPrefix:"drawer:",eventListeners:!0,store:!0,storeKey:"VB:DrawerState",setTabindex:!0,transition:!0};function O(t){var e=this,n=t.target.closest("\n [data-"+this.settings.dataOpen+"],\n [data-"+this.settings.dataToggle+"],\n [data-"+this.settings.dataClose+"]\n ");n?(t.preventDefault(),n.matches("[data-"+this.settings.dataToggle+"]")&&n.getAttribute("data-"+this.settings.dataToggle).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.toggle()}),n.matches("[data-"+this.settings.dataOpen+"]")&&n.getAttribute("data-"+this.settings.dataOpen).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.open()}),n.matches("[data-"+this.settings.dataClose+"]")&&n.getAttribute("data-"+this.settings.dataClose).trim().split(" ").forEach(function(i){if(i){var r=e.get(i);r.trigger=n,r.close()}else{var o=t.target.closest(e.settings.selectorDrawer);o&&e.close(o)}})):t.target.matches(this.settings.selectorDrawer)&&this.close(t.target.id)}function k(t){if("Escape"===t.key){var e=this.activeModal;e&&this.close(e)}}var j=function(t,e){void 0===e&&(e=!0);try{var n=function(){return i.collection},i=this;if(!t)return Promise.resolve(i.collection);var r=i.collection.findIndex(function(e){return e.id===t.id}),o=function(){if(r>=0){var t=function(){i.store.set(n.id),n.unmountBreakpoint(),Object.getOwnPropertyNames(n).forEach(function(t){delete n[t]}),i.collection.splice(r,1)},n=i.collection[r],o=function(){if(e&&"opened"===n.state)return Promise.resolve(n.close(!1)).then(function(){})}();return o&&o.then?o.then(t):t()}}();return Promise.resolve(o&&o.then?o.then(n):n())}catch(t){return Promise.reject(t)}};function C(t){var e=getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(),n=t.getAttribute("data-"+this.settings.dataBreakpoint);return this.settings.breakpoints&&this.settings.breakpoints[n]?this.settings.breakpoints[n]:getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim()?getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim():n}function S(t){var e=this.get("string"==typeof t?t:t.id);if(e)return e;throw new Error('Drawer not found in collection with id of "'+(t.id||t)+'".')}function x(t){return"string"==typeof t?t:"function"==typeof t.hasAttribute?t.hasAttribute("data-"+this.settings.dataOpen)?t.getAttribute("data-"+this.settings.dataOpen):t.hasAttribute("data-"+this.settings.dataClose)?t.getAttribute("data-"+this.settings.dataClose)||!1:t.hasAttribute("data-"+this.settings.dataToggle)?t.getAttribute("data-"+this.settings.dataToggle):t.closest(this.settings.selectorDrawer)&&(t=t.closest(this.settings.selectorDrawer)).id||!1:!!t.id&&t.id}function A(t){var e=x.call(this,t);if(e){var n=document.querySelector("#"+e),i=n?n.querySelector(this.settings.selectorDialog):null;return n||i?i?{drawer:n,dialog:i}:{error:new Error("Drawer is missing dialog element.")}:{error:new Error('No drawer elements found using the ID: "'+e+'".')}}return{error:new Error("Could not resolve the drawer ID.")}}var q=function(t){try{var e=this,n=function(){if(e.store.get(t.id)){var n="opened"===e.store.get(t.id)?Promise.resolve(t.open(!1,!1)).then(function(){}):Promise.resolve(t.close(!1,!1)).then(function(){});if(n&&n.then)return n.then(function(){})}else t.el.classList.contains(e.settings.stateOpened)?t.state="opened":(t.el.classList.remove(e.settings.stateOpening),t.el.classList.remove(e.settings.stateClosing),t.el.classList.add(e.settings.stateClosed))}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(t){return Promise.reject(t)}};function T(t){"opened"===t.state?"modal"===t.mode?this.focusTrap.mount(t.dialog,this.settings.selectorFocus):this.focusTrap.focus(t.dialog,this.settings.selectorFocus):(t.trigger&&(t.trigger.focus(),t.trigger=null),this.focusTrap.unmount())}var D=function(t,e,i){void 0===i&&(i=!0);try{var r=function(){return i&&T.call(o,s),s.el.dispatchEvent(new CustomEvent(a.customEventPrefix+"opened",{detail:o,bubbles:!0})),s},o=this,s=S.call(o,t),a=n({},o.settings,s.settings);void 0!==e&&(a.transition=e);var c=function(){if("closed"===s.state)return s.state="opening",Promise.resolve((t=s.el,e=a,new Promise(function(n){e.transition?(t.classList.remove(e.stateClosed),t.classList.add(e.stateOpening),t.addEventListener("transitionend",function i(){t.classList.add(e.stateOpened),t.classList.remove(e.stateOpening),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateOpened),t.classList.remove(e.stateClosed),n(t))}))).then(function(){"modal"===s.mode&&E(!0,a),s.state="opened"});var t,e}();return Promise.resolve(c&&c.then?c.then(r):r())}catch(t){return Promise.reject(t)}},F=function(t,e,i){void 0===i&&(i=!0);try{var r=this,o=S.call(r,t),s=n({},r.settings,o.settings);void 0!==e&&(s.transition=e);var a=function(){if("opened"===o.state)return o.state="closing",document.activeElement.blur(),Promise.resolve((t=o.el,e=s,new Promise(function(n){e.transition?(t.classList.add(e.stateClosing),t.classList.remove(e.stateOpened),t.addEventListener("transitionend",function i(){t.classList.remove(e.stateClosing),t.classList.add(e.stateClosed),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateClosed),t.classList.remove(e.stateOpened),n(t))}))).then(function(){"modal"===o.mode&&E(!1,s),i&&T.call(r,o),o.state="closed",o.el.dispatchEvent(new CustomEvent(s.customEventPrefix+"closed",{detail:r,bubbles:!0}))});var t,e}();return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(t){return Promise.reject(t)}},_=function(t,e,n){try{var i=this,r=S.call(i,t);return Promise.resolve("closed"===r.state?D.call(i,r,e,n):F.call(i,r,e,n))}catch(t){return Promise.reject(t)}},I=function(t){try{var e=this;return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),!e.store.get(t.id)&&t.el.classList.contains(t.getSetting("stateOpened"))&&e.store.set(t.id,"opened"),Promise.resolve(F.call(e,t,!1,!1)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}},B=function(t){try{var e=this;return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),E(!1,n({},e.settings,t.settings)),e.focusTrap.unmount(),Promise.resolve(q.call(e,t)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}};function M(t){switch(t.mode){case"inline":return B.call(this,t);case"modal":return I.call(this,t);default:throw new Error('"'+t.mode+'" is not a valid drawer mode.')}}var N=function(t,e){try{var i=this;return Promise.resolve(j.call(i,t,!1)).then(function(){var r=i,o=new l,s={open:function(t,e){return D.call(r,this,t,e)},close:function(t,e){return F.call(r,this,t,e)},toggle:function(t,e){return _.call(r,this,t,e)},deregister:function(){return j.call(r,this)},mountBreakpoint:function(){var t=this.breakpoint,e=this.handleBreakpoint.bind(this);return o.mount(t,e),this},unmountBreakpoint:function(){return o.unmount(),this},handleBreakpoint:function(t){return this.mode=t.matches?"inline":"modal",this},getSetting:function(t){return t in this.settings?this.settings[t]:r.settings[t]}},a=n({id:t.id,el:t,dialog:e,trigger:null,settings:P(t,i.settings.dataConfig),get breakpoint(){return C.call(r,t)},get state(){return c},set state(t){c=t,"opened"!==t&&"closed"!==t||"inline"===this.mode&&r.store.set(this.id,this.state)},get mode(){return u},set mode(t){u=t,M.call(r,this)}},s),c=t.classList.contains(a.getSetting("stateOpened"))?"opened":"closed",u=t.classList.contains(a.getSetting("classModal"))?"modal":"inline";"modal"===a.mode?a.dialog.setAttribute("aria-modal","true"):a.dialog.removeAttribute("aria-modal"),a.getSetting("setTabindex")&&a.dialog.setAttribute("tabindex","-1"),i.collection.push(a);var d=function(){if(!a.breakpoint)return Promise.resolve(q.call(i,a)).then(function(){});a.mountBreakpoint()}();return d&&d.then?d.then(function(){return a}):a})}catch(t){return Promise.reject(t)}},K=/*#__PURE__*/s("handleClick"),V=/*#__PURE__*/s("handleKeydown");module.exports=/*#__PURE__*/function(t){var o,s;function c(e){var i;return i=t.call(this)||this,Object.defineProperty(r(i),K,{writable:!0,value:void 0}),Object.defineProperty(r(i),V,{writable:!0,value:void 0}),i.defaults=L,i.settings=n({},i.defaults,e),i.focusTrap=new b,i.store=function(t,e){void 0===e&&(e=!0);var n=localStorage.getItem(t),i=n?JSON.parse(n):{};return{get:function(t){return t?i[t]:i},set:function(n,r){return r?i[n]=r:delete i[n],e&&localStorage.setItem(t,JSON.stringify(i)),i}}}(i.settings.storeKey,i.settings.store),a(r(i),K)[K]=O.bind(r(i)),a(r(i),V)[V]=k.bind(r(i)),i.settings.autoInit&&i.init(),i}s=t,(o=c).prototype=Object.create(s.prototype),o.prototype.constructor=o,i(o,s);var l=c.prototype;return l.init=function(t){void 0===t&&(t=null);try{var e=this;t&&(e.settings=n({},e.settings,t));var i=document.querySelectorAll(e.settings.selectorDrawer);return Promise.resolve(e.registerCollection(i)).then(function(){return e.settings.eventListeners&&e.initEventListeners(),e})}catch(t){return Promise.reject(t)}},l.destroy=function(){try{var t=this;return Promise.resolve(t.deregisterCollection()).then(function(){return t.settings.eventListeners&&t.destroyEventListeners(),t})}catch(t){return Promise.reject(t)}},l.initEventListeners=function(){document.addEventListener("click",a(this,K)[K],!1),document.addEventListener("keydown",a(this,V)[V],!1)},l.destroyEventListeners=function(){document.removeEventListener("click",a(this,K)[K],!1),document.removeEventListener("keydown",a(this,V)[V],!1)},l.register=function(t){var e=A.call(this,t);return e.error?Promise.reject(e.error):N.call(this,e.drawer,e.dialog)},l.deregister=function(t){var e=this.get(x.call(this,t));return j.call(this,e)},l.open=function(t,e,n){return D.call(this,t,e,n)},l.close=function(t,e,n){return F.call(this,t,e,n)},l.toggle=function(t,e,n){return _.call(this,t,e,n)},e(c,[{key:"activeModal",get:function(){return this.collection.find(function(t){return"opened"===t.state&&"modal"===t.mode})}}]),c}(f);
//# sourceMappingURL=scripts.js.map

@@ -1,3 +0,3 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t||self).vrembem=t.vrembem||{},t.vrembem.Drawer=e())}(this,function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function e(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function i(t,e){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var o=0;function s(t){return"__private_"+o+++"_"+t}function a(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var c=/*#__PURE__*/s("handler"),l=/*#__PURE__*/function(){function t(t,e){Object.defineProperty(this,c,{writable:!0,value:void 0}),this.value=t,a(this,c)[c]=e,this.mql=null}var n=t.prototype;return n.mount=function(t,e){return t&&(this.value=t),e&&(a(this,c)[c]=e),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",a(this,c)[c]):this.mql.addListener(a(this,c)[c]),a(this,c)[c](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c]),this.value=null,a(this,c)[c]=null,this.mql=null,this):this},e(t,[{key:"handler",get:function(){return a(this,c)[c]},set:function(t){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c])),a(this,c)[c]=t}}]),t}();function u(t,e,n){if(!t.s){if(n instanceof d){if(!n.s)return void(n.o=u.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(u.bind(null,t,e),u.bind(null,t,2));t.s=e,t.v=n;var i=t.o;i&&i(t)}}var d=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var i=new t,r=this.s;if(r){var o=1&r?e:n;if(o){try{u(i,1,o(this.v))}catch(t){u(i,2,t)}return i}return this}return this.o=function(t){try{var r=t.v;1&t.s?u(i,1,e?e(r):r):n?u(i,1,n(r)):u(i,2,r)}catch(t){u(i,2,t)}},i},t}();function h(t){return t instanceof d&&1&t.s}var f=/*#__PURE__*/function(){function t(){this.collection=[]}var e=t.prototype;return e.register=function(t){try{var e=this;return Promise.resolve(e.deregister(t)).then(function(){return e.collection.push(t),e.collection})}catch(t){return Promise.reject(t)}},e.deregister=function(t){try{var e=this,n=e.collection.findIndex(function(e){return e===t});if(n>=0){var i=e.collection[n];Object.getOwnPropertyNames(i).forEach(function(t){delete i[t]}),e.collection.splice(n,1)}return Promise.resolve(e.collection)}catch(t){return Promise.reject(t)}},e.registerCollection=function(t){try{var e=this;return Promise.resolve(Promise.all(Array.from(t,function(t){e.register(t)}))).then(function(){return e.collection})}catch(t){return Promise.reject(t)}},e.deregisterCollection=function(){try{var t=function(){return e.collection},e=this,n=function(t,e,n){for(var i;;){var r=t();if(h(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!h(o)){i=1;break}o=o.s}}var s=new d,a=u.bind(null,s,2);return(0===i?r.then(l):1===i?o.then(c):(void 0).then(function(){(r=t())?r.then?r.then(l).then(void 0,a):l(r):u(s,1,o)})).then(void 0,a),s;function c(e){o=e;do{if(!(r=t())||h(r)&&!r.v)return void u(s,1,o);if(r.then)return void r.then(l).then(void 0,a);h(o=n())&&(o=o.v)}while(!o||!o.then);o.then(c).then(void 0,a)}function l(t){t?(o=n())&&o.then?o.then(c).then(void 0,a):c(o):u(s,1,o)}}(function(){return e.collection.length>0},0,function(){return Promise.resolve(e.deregister(e.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(t){return Promise.reject(t)}},e.get=function(t,e){return void 0===e&&(e="id"),this.collection.find(function(n){return n[e]===t})},t}(),v=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'],g=/*#__PURE__*/s("focusable"),m=/*#__PURE__*/s("handleFocusTrap"),p=/*#__PURE__*/s("handleFocusLock"),b=/*#__PURE__*/function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e="[data-focus]"),Object.defineProperty(this,g,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),this.el=t,this.selectorFocus=e,a(this,m)[m]=y.bind(this),a(this,p)[p]=w.bind(this)}var n=t.prototype;return n.mount=function(t,e){t&&(this.el=t),e&&(this.selectorFocus=e),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",a(this,m)[m]),document.removeEventListener("keydown",a(this,p)[p])},n.focus=function(t,e){void 0===t&&(t=this.el),void 0===e&&(e=this.selectorFocus),(t.querySelector(e)||t).focus()},n.getFocusable=function(t){void 0===t&&(t=this.el);var e=[],n=document.activeElement,i=t.scrollTop;return t.querySelectorAll(v.join(",")).forEach(function(t){t.focus(),document.activeElement===t&&e.push(t)}),t.scrollTop=i,n.focus(),e},e(t,[{key:"focusable",get:function(){return a(this,g)[g]},set:function(t){a(this,g)[g]=t,a(this,g)[g].length?(document.removeEventListener("keydown",a(this,p)[p]),document.addEventListener("keydown",a(this,m)[m])):(document.removeEventListener("keydown",a(this,m)[m]),document.addEventListener("keydown",a(this,p)[p]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),t}();function y(t){("Tab"===t.key||9===t.keyCode)&&(t.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(t.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(t.preventDefault(),this.focusableFirst.focus()))}function w(t){("Tab"===t.key||9===t.keyCode)&&t.preventDefault()}function P(t,e){var n=(t.getAttribute("data-"+e)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function E(t,e){var n,i;n=!!t,(i=e.selectorInert)&&document.querySelectorAll(i).forEach(function(t){n?(t.inert=!0,t.setAttribute("aria-hidden",!0)):(t.inert=null,t.removeAttribute("aria-hidden"))}),function(t,e){e&&document.querySelectorAll(e).forEach(function(e){t?e.style.overflow="hidden":e.style.removeProperty("overflow")})}(!!t,e.selectorOverflow)}var L={autoInit:!1,dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",dataBreakpoint:"drawer-breakpoint",dataConfig:"drawer-config",selectorDrawer:".drawer",selectorDialog:".drawer__dialog",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",breakpoints:null,customEventPrefix:"drawer:",eventListeners:!0,store:!0,storeKey:"VB:DrawerState",setTabindex:!0,transition:!0};function O(t){var e=this,n=t.target.closest("\n [data-"+this.settings.dataOpen+"],\n [data-"+this.settings.dataToggle+"],\n [data-"+this.settings.dataClose+"]\n ");n?(t.preventDefault(),n.matches("[data-"+this.settings.dataToggle+"]")&&n.getAttribute("data-"+this.settings.dataToggle).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.toggle()}),n.matches("[data-"+this.settings.dataOpen+"]")&&n.getAttribute("data-"+this.settings.dataOpen).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.open()}),n.matches("[data-"+this.settings.dataClose+"]")&&n.getAttribute("data-"+this.settings.dataClose).trim().split(" ").forEach(function(i){if(i){var r=e.get(i);r.trigger=n,r.close()}else{var o=t.target.closest(e.settings.selectorDrawer);o&&e.close(o)}})):t.target.matches(this.settings.selectorDrawer)&&this.close(t.target.id)}function k(t){if("Escape"===t.key){var e=this.activeModal;e&&this.close(e)}}var j=function(t,e){void 0===e&&(e=!0);try{var n=function(){return i.collection},i=this;if(!t)return Promise.resolve(i.collection);var r=i.collection.findIndex(function(e){return e.id===t.id}),o=function(){if(r>=0){var t=function(){i.store.set(n.id),n.unmountBreakpoint(),Object.getOwnPropertyNames(n).forEach(function(t){delete n[t]}),i.collection.splice(r,1)},n=i.collection[r],o=function(){if(e&&"opened"===n.state)return Promise.resolve(n.close(!1)).then(function(){})}();return o&&o.then?o.then(t):t()}}();return Promise.resolve(o&&o.then?o.then(n):n())}catch(t){return Promise.reject(t)}};function C(t){var e=getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(),n=t.getAttribute("data-"+this.settings.dataBreakpoint);return this.settings.breakpoints&&this.settings.breakpoints[n]?this.settings.breakpoints[n]:getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim()?getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim():n}function x(t){var e=this.get("string"==typeof t?t:t.id);if(e)return e;throw new Error('Drawer not found in collection with id of "'+(t.id||t)+'".')}function S(t){return"string"==typeof t?t:"function"==typeof t.hasAttribute?t.hasAttribute("data-"+this.settings.dataOpen)?t.getAttribute("data-"+this.settings.dataOpen):t.hasAttribute("data-"+this.settings.dataClose)?t.getAttribute("data-"+this.settings.dataClose)||!1:t.hasAttribute("data-"+this.settings.dataToggle)?t.getAttribute("data-"+this.settings.dataToggle):t.closest(this.settings.selectorDrawer)&&(t=t.closest(this.settings.selectorDrawer)).id||!1:!!t.id&&t.id}function A(t){var e=S.call(this,t);if(e){var n=document.querySelector("#"+e),i=n?n.querySelector(this.settings.selectorDialog):null;return n||i?i?{drawer:n,dialog:i}:{error:new Error("Drawer is missing dialog element.")}:{error:new Error('No drawer elements found using the ID: "'+e+'".')}}return{error:new Error("Could not resolve the drawer ID.")}}var q=function(t){try{var e=this,n=function(){if(e.store.get(t.id)){var n="opened"===e.store.get(t.id)?Promise.resolve(t.open(!1,!1)).then(function(){}):Promise.resolve(t.close(!1,!1)).then(function(){});if(n&&n.then)return n.then(function(){})}else t.el.classList.contains(e.settings.stateOpened)?t.state="opened":(t.el.classList.remove(e.settings.stateOpening),t.el.classList.remove(e.settings.stateClosing),t.el.classList.add(e.settings.stateClosed))}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(t){return Promise.reject(t)}};function T(t){"opened"===t.state?"modal"===t.mode?this.focusTrap.mount(t.dialog,this.settings.selectorFocus):this.focusTrap.focus(t.dialog,this.settings.selectorFocus):(t.trigger&&(t.trigger.focus(),t.trigger=null),this.focusTrap.unmount())}var D=function(t,e,i){void 0===i&&(i=!0);try{var r=function(){return i&&T.call(o,s),s.el.dispatchEvent(new CustomEvent(a.customEventPrefix+"opened",{detail:o,bubbles:!0})),s},o=this,s=x.call(o,t),a=n({},o.settings,s.settings);void 0!==e&&(a.transition=e);var c=function(){if("closed"===s.state)return s.state="opening",Promise.resolve((t=s.el,e=a,new Promise(function(n){e.transition?(t.classList.remove(e.stateClosed),t.classList.add(e.stateOpening),t.addEventListener("transitionend",function i(){t.classList.add(e.stateOpened),t.classList.remove(e.stateOpening),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateOpened),t.classList.remove(e.stateClosed),n(t))}))).then(function(){"modal"===s.mode&&E(!0,a),s.state="opened"});var t,e}();return Promise.resolve(c&&c.then?c.then(r):r())}catch(t){return Promise.reject(t)}},F=function(t,e,i){void 0===i&&(i=!0);try{var r=this,o=x.call(r,t),s=n({},r.settings,o.settings);void 0!==e&&(s.transition=e);var a=function(){if("opened"===o.state)return o.state="closing",document.activeElement.blur(),Promise.resolve((t=o.el,e=s,new Promise(function(n){e.transition?(t.classList.add(e.stateClosing),t.classList.remove(e.stateOpened),t.addEventListener("transitionend",function i(){t.classList.remove(e.stateClosing),t.classList.add(e.stateClosed),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateClosed),t.classList.remove(e.stateOpened),n(t))}))).then(function(){"modal"===o.mode&&E(!1,s),i&&T.call(r,o),o.state="closed",o.el.dispatchEvent(new CustomEvent(s.customEventPrefix+"closed",{detail:r,bubbles:!0}))});var t,e}();return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(t){return Promise.reject(t)}},_=function(t,e,n){try{var i=this,r=x.call(i,t);return Promise.resolve("closed"===r.state?D.call(i,r,e,n):F.call(i,r,e,n))}catch(t){return Promise.reject(t)}},I=function(t){try{var e=this;return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),!e.store.get(t.id)&&t.el.classList.contains(t.getSetting("stateOpened"))&&e.store.set(t.id,"opened"),Promise.resolve(F.call(e,t,!1,!1)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}},B=function(t){try{var e=this;return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),E(!1,n({},e.settings,t.settings)),e.focusTrap.unmount(),Promise.resolve(q.call(e,t)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}};function M(t){switch(t.mode){case"inline":return B.call(this,t);case"modal":return I.call(this,t);default:throw new Error('"'+t.mode+'" is not a valid drawer mode.')}}var N=function(t,e){try{var i=this;return Promise.resolve(j.call(i,t,!1)).then(function(){var r=i,o=new l,s={open:function(t,e){return D.call(r,this,t,e)},close:function(t,e){return F.call(r,this,t,e)},toggle:function(t,e){return _.call(r,this,t,e)},deregister:function(){return j.call(r,this)},mountBreakpoint:function(){var t=this.breakpoint,e=this.handleBreakpoint.bind(this);return o.mount(t,e),this},unmountBreakpoint:function(){return o.unmount(),this},handleBreakpoint:function(t){return this.mode=t.matches?"inline":"modal",this},getSetting:function(t){return t in this.settings?this.settings[t]:r.settings[t]}},a=n({id:t.id,el:t,dialog:e,trigger:null,settings:P(t,i.settings.dataConfig),get breakpoint(){return C.call(r,t)},get state(){return c},set state(t){c=t,"opened"!==t&&"closed"!==t||"inline"===this.mode&&r.store.set(this.id,this.state)},get mode(){return u},set mode(t){u=t,M.call(r,this)}},s),c=t.classList.contains(a.getSetting("stateOpened"))?"opened":"closed",u=t.classList.contains(a.getSetting("classModal"))?"modal":"inline";"modal"===a.mode?a.dialog.setAttribute("aria-modal","true"):a.dialog.removeAttribute("aria-modal"),a.getSetting("setTabindex")&&a.dialog.setAttribute("tabindex","-1"),i.collection.push(a);var d=function(){if(!a.breakpoint)return Promise.resolve(q.call(i,a)).then(function(){});a.mountBreakpoint()}();return d&&d.then?d.then(function(){return a}):a})}catch(t){return Promise.reject(t)}},K=/*#__PURE__*/s("handleClick"),V=/*#__PURE__*/s("handleKeydown");/*#__PURE__*/
return function(t){var o,s;function c(e){var i;return i=t.call(this)||this,Object.defineProperty(r(i),K,{writable:!0,value:void 0}),Object.defineProperty(r(i),V,{writable:!0,value:void 0}),i.defaults=L,i.settings=n({},i.defaults,e),i.focusTrap=new b,i.store=function(t,e){void 0===e&&(e=!0);var n=localStorage.getItem(t),i=n?JSON.parse(n):{};return{get:function(t){return t?i[t]:i},set:function(n,r){return r?i[n]=r:delete i[n],e&&localStorage.setItem(t,JSON.stringify(i)),i}}}(i.settings.storeKey,i.settings.store),a(r(i),K)[K]=O.bind(r(i)),a(r(i),V)[V]=k.bind(r(i)),i.settings.autoInit&&i.init(),i}s=t,(o=c).prototype=Object.create(s.prototype),o.prototype.constructor=o,i(o,s);var l=c.prototype;return l.init=function(t){void 0===t&&(t=null);try{var e=this;t&&(e.settings=n({},e.settings,t));var i=document.querySelectorAll(e.settings.selectorDrawer);return Promise.resolve(e.registerCollection(i)).then(function(){return e.settings.eventListeners&&e.initEventListeners(),e})}catch(t){return Promise.reject(t)}},l.destroy=function(){try{var t=this;return Promise.resolve(t.deregisterCollection()).then(function(){return t.settings.eventListeners&&t.destroyEventListeners(),t})}catch(t){return Promise.reject(t)}},l.initEventListeners=function(){document.addEventListener("click",a(this,K)[K],!1),document.addEventListener("touchend",a(this,K)[K],!1),document.addEventListener("keydown",a(this,V)[V],!1)},l.destroyEventListeners=function(){document.removeEventListener("click",a(this,K)[K],!1),document.removeEventListener("touchend",a(this,K)[K],!1),document.removeEventListener("keydown",a(this,V)[V],!1)},l.register=function(t){var e=A.call(this,t);return e.error?Promise.reject(e.error):N.call(this,e.drawer,e.dialog)},l.deregister=function(t){var e=this.get(S.call(this,t));return j.call(this,e)},l.open=function(t,e,n){return D.call(this,t,e,n)},l.close=function(t,e,n){return F.call(this,t,e,n)},l.toggle=function(t,e,n){return _.call(this,t,e,n)},e(c,[{key:"activeModal",get:function(){return this.collection.find(function(t){return"opened"===t.state&&"modal"===t.mode})}}]),c}(f)});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t||self).vrembem=t.vrembem||{},t.vrembem.Drawer=e())}(this,function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i.key))?r:String(r),i)}var r}function e(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(){return(n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function i(t,e){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var o=0;function s(t){return"__private_"+o+++"_"+t}function a(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var c=/*#__PURE__*/s("handler"),l=/*#__PURE__*/function(){function t(t,e){Object.defineProperty(this,c,{writable:!0,value:void 0}),this.value=t,a(this,c)[c]=e,this.mql=null}var n=t.prototype;return n.mount=function(t,e){return t&&(this.value=t),e&&(a(this,c)[c]=e),this.value?(this.mql=window.matchMedia("(min-width: "+this.value+")"),"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",a(this,c)[c]):this.mql.addListener(a(this,c)[c]),a(this,c)[c](this.mql),this):this},n.unmount=function(){return this.mql?("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c]),this.value=null,a(this,c)[c]=null,this.mql=null,this):this},e(t,[{key:"handler",get:function(){return a(this,c)[c]},set:function(t){this.mql&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",a(this,c)[c]):this.mql.removeListener(a(this,c)[c])),a(this,c)[c]=t}}]),t}();function u(t,e,n){if(!t.s){if(n instanceof d){if(!n.s)return void(n.o=u.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(u.bind(null,t,e),u.bind(null,t,2));t.s=e,t.v=n;const i=t.o;i&&i(t)}}var d=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var i=new t,r=this.s;if(r){var o=1&r?e:n;if(o){try{u(i,1,o(this.v))}catch(t){u(i,2,t)}return i}return this}return this.o=function(t){try{var r=t.v;1&t.s?u(i,1,e?e(r):r):n?u(i,1,n(r)):u(i,2,r)}catch(t){u(i,2,t)}},i},t}();function h(t){return t instanceof d&&1&t.s}var f=/*#__PURE__*/function(){function t(){this.collection=[]}var e=t.prototype;return e.register=function(t){try{var e=this;return Promise.resolve(e.deregister(t)).then(function(){return e.collection.push(t),e.collection})}catch(t){return Promise.reject(t)}},e.deregister=function(t){try{var e=this,n=e.collection.findIndex(function(e){return e===t});if(n>=0){var i=e.collection[n];Object.getOwnPropertyNames(i).forEach(function(t){delete i[t]}),e.collection.splice(n,1)}return Promise.resolve(e.collection)}catch(t){return Promise.reject(t)}},e.registerCollection=function(t){try{var e=this;return Promise.resolve(Promise.all(Array.from(t,function(t){e.register(t)}))).then(function(){return e.collection})}catch(t){return Promise.reject(t)}},e.deregisterCollection=function(){try{var t=function(){return e.collection},e=this,n=function(t,e,n){for(var i;;){var r=t();if(h(r)&&(r=r.v),!r)return o;if(r.then){i=0;break}var o=n();if(o&&o.then){if(!h(o)){i=1;break}o=o.s}}var s=new d,a=u.bind(null,s,2);return(0===i?r.then(l):1===i?o.then(c):(void 0).then(function(){(r=t())?r.then?r.then(l).then(void 0,a):l(r):u(s,1,o)})).then(void 0,a),s;function c(e){o=e;do{if(!(r=t())||h(r)&&!r.v)return void u(s,1,o);if(r.then)return void r.then(l).then(void 0,a);h(o=n())&&(o=o.v)}while(!o||!o.then);o.then(c).then(void 0,a)}function l(t){t?(o=n())&&o.then?o.then(c).then(void 0,a):c(o):u(s,1,o)}}(function(){return e.collection.length>0},0,function(){return Promise.resolve(e.deregister(e.collection[0])).then(function(){})});return Promise.resolve(n&&n.then?n.then(t):t())}catch(t){return Promise.reject(t)}},e.get=function(t,e){return void 0===e&&(e="id"),this.collection.find(function(n){return n[e]===t})},t}(),v=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'],g=/*#__PURE__*/s("focusable"),m=/*#__PURE__*/s("handleFocusTrap"),p=/*#__PURE__*/s("handleFocusLock"),b=/*#__PURE__*/function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e="[data-focus]"),Object.defineProperty(this,g,{writable:!0,value:void 0}),Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:void 0}),this.el=t,this.selectorFocus=e,a(this,m)[m]=y.bind(this),a(this,p)[p]=w.bind(this)}var n=t.prototype;return n.mount=function(t,e){t&&(this.el=t),e&&(this.selectorFocus=e),this.focusable=this.getFocusable(),this.focus()},n.unmount=function(){this.el=null,this.focusable=[],document.removeEventListener("keydown",a(this,m)[m]),document.removeEventListener("keydown",a(this,p)[p])},n.focus=function(t,e){void 0===t&&(t=this.el),void 0===e&&(e=this.selectorFocus),(t.querySelector(e)||t).focus()},n.getFocusable=function(t){void 0===t&&(t=this.el);var e=[],n=document.activeElement,i=t.scrollTop;return t.querySelectorAll(v.join(",")).forEach(function(t){t.focus(),document.activeElement===t&&e.push(t)}),t.scrollTop=i,n.focus(),e},e(t,[{key:"focusable",get:function(){return a(this,g)[g]},set:function(t){a(this,g)[g]=t,a(this,g)[g].length?(document.removeEventListener("keydown",a(this,p)[p]),document.addEventListener("keydown",a(this,m)[m])):(document.removeEventListener("keydown",a(this,m)[m]),document.addEventListener("keydown",a(this,p)[p]))}},{key:"focusableFirst",get:function(){return this.focusable[0]}},{key:"focusableLast",get:function(){return this.focusable[this.focusable.length-1]}}]),t}();function y(t){("Tab"===t.key||9===t.keyCode)&&(t.shiftKey?document.activeElement!==this.focusableFirst&&document.activeElement!==this.el||(t.preventDefault(),this.focusableLast.focus()):document.activeElement!==this.focusableLast&&document.activeElement!==this.el||(t.preventDefault(),this.focusableFirst.focus()))}function w(t){("Tab"===t.key||9===t.keyCode)&&t.preventDefault()}function P(t,e){var n=(t.getAttribute("data-"+e)||"").replace(/'/g,'"');return n?JSON.parse(n):{}}function E(t,e){var n,i;n=!!t,(i=e.selectorInert)&&document.querySelectorAll(i).forEach(function(t){n?(t.inert=!0,t.setAttribute("aria-hidden",!0)):(t.inert=null,t.removeAttribute("aria-hidden"))}),function(t,e){e&&document.querySelectorAll(e).forEach(function(e){t?e.style.overflow="hidden":e.style.removeProperty("overflow")})}(!!t,e.selectorOverflow)}var L={autoInit:!1,dataOpen:"drawer-open",dataClose:"drawer-close",dataToggle:"drawer-toggle",dataBreakpoint:"drawer-breakpoint",dataConfig:"drawer-config",selectorDrawer:".drawer",selectorDialog:".drawer__dialog",selectorFocus:"[data-focus]",selectorInert:null,selectorOverflow:"body",stateOpened:"is-opened",stateOpening:"is-opening",stateClosing:"is-closing",stateClosed:"is-closed",classModal:"drawer_modal",breakpoints:null,customEventPrefix:"drawer:",eventListeners:!0,store:!0,storeKey:"VB:DrawerState",setTabindex:!0,transition:!0};function O(t){var e=this,n=t.target.closest("\n [data-"+this.settings.dataOpen+"],\n [data-"+this.settings.dataToggle+"],\n [data-"+this.settings.dataClose+"]\n ");n?(t.preventDefault(),n.matches("[data-"+this.settings.dataToggle+"]")&&n.getAttribute("data-"+this.settings.dataToggle).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.toggle()}),n.matches("[data-"+this.settings.dataOpen+"]")&&n.getAttribute("data-"+this.settings.dataOpen).trim().split(" ").forEach(function(t){var i=e.get(t);i.trigger=n,i.open()}),n.matches("[data-"+this.settings.dataClose+"]")&&n.getAttribute("data-"+this.settings.dataClose).trim().split(" ").forEach(function(i){if(i){var r=e.get(i);r.trigger=n,r.close()}else{var o=t.target.closest(e.settings.selectorDrawer);o&&e.close(o)}})):t.target.matches(this.settings.selectorDrawer)&&this.close(t.target.id)}function k(t){if("Escape"===t.key){var e=this.activeModal;e&&this.close(e)}}var j=function(t,e){void 0===e&&(e=!0);try{var n=function(){return i.collection},i=this;if(!t)return Promise.resolve(i.collection);var r=i.collection.findIndex(function(e){return e.id===t.id}),o=function(){if(r>=0){var t=function(){i.store.set(n.id),n.unmountBreakpoint(),Object.getOwnPropertyNames(n).forEach(function(t){delete n[t]}),i.collection.splice(r,1)},n=i.collection[r],o=function(){if(e&&"opened"===n.state)return Promise.resolve(n.close(!1)).then(function(){})}();return o&&o.then?o.then(t):t()}}();return Promise.resolve(o&&o.then?o.then(n):n())}catch(t){return Promise.reject(t)}};function C(t){var e=getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim(),n=t.getAttribute("data-"+this.settings.dataBreakpoint);return this.settings.breakpoints&&this.settings.breakpoints[n]?this.settings.breakpoints[n]:getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim()?getComputedStyle(document.body).getPropertyValue("--"+e+"breakpoint-"+n).trim():n}function S(t){var e=this.get("string"==typeof t?t:t.id);if(e)return e;throw new Error('Drawer not found in collection with id of "'+(t.id||t)+'".')}function x(t){return"string"==typeof t?t:"function"==typeof t.hasAttribute?t.hasAttribute("data-"+this.settings.dataOpen)?t.getAttribute("data-"+this.settings.dataOpen):t.hasAttribute("data-"+this.settings.dataClose)?t.getAttribute("data-"+this.settings.dataClose)||!1:t.hasAttribute("data-"+this.settings.dataToggle)?t.getAttribute("data-"+this.settings.dataToggle):t.closest(this.settings.selectorDrawer)&&(t=t.closest(this.settings.selectorDrawer)).id||!1:!!t.id&&t.id}function A(t){var e=x.call(this,t);if(e){var n=document.querySelector("#"+e),i=n?n.querySelector(this.settings.selectorDialog):null;return n||i?i?{drawer:n,dialog:i}:{error:new Error("Drawer is missing dialog element.")}:{error:new Error('No drawer elements found using the ID: "'+e+'".')}}return{error:new Error("Could not resolve the drawer ID.")}}var q=function(t){try{var e=this,n=function(){if(e.store.get(t.id)){var n="opened"===e.store.get(t.id)?Promise.resolve(t.open(!1,!1)).then(function(){}):Promise.resolve(t.close(!1,!1)).then(function(){});if(n&&n.then)return n.then(function(){})}else t.el.classList.contains(e.settings.stateOpened)?t.state="opened":(t.el.classList.remove(e.settings.stateOpening),t.el.classList.remove(e.settings.stateClosing),t.el.classList.add(e.settings.stateClosed))}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(t){return Promise.reject(t)}};function T(t){"opened"===t.state?"modal"===t.mode?this.focusTrap.mount(t.dialog,this.settings.selectorFocus):this.focusTrap.focus(t.dialog,this.settings.selectorFocus):(t.trigger&&(t.trigger.focus(),t.trigger=null),this.focusTrap.unmount())}var D=function(t,e,i){void 0===i&&(i=!0);try{var r=function(){return i&&T.call(o,s),s.el.dispatchEvent(new CustomEvent(a.customEventPrefix+"opened",{detail:o,bubbles:!0})),s},o=this,s=S.call(o,t),a=n({},o.settings,s.settings);void 0!==e&&(a.transition=e);var c=function(){if("closed"===s.state)return s.state="opening",Promise.resolve((t=s.el,e=a,new Promise(function(n){e.transition?(t.classList.remove(e.stateClosed),t.classList.add(e.stateOpening),t.addEventListener("transitionend",function i(){t.classList.add(e.stateOpened),t.classList.remove(e.stateOpening),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateOpened),t.classList.remove(e.stateClosed),n(t))}))).then(function(){"modal"===s.mode&&E(!0,a),s.state="opened"});var t,e}();return Promise.resolve(c&&c.then?c.then(r):r())}catch(t){return Promise.reject(t)}},F=function(t,e,i){void 0===i&&(i=!0);try{var r=this,o=S.call(r,t),s=n({},r.settings,o.settings);void 0!==e&&(s.transition=e);var a=function(){if("opened"===o.state)return o.state="closing",document.activeElement.blur(),Promise.resolve((t=o.el,e=s,new Promise(function(n){e.transition?(t.classList.add(e.stateClosing),t.classList.remove(e.stateOpened),t.addEventListener("transitionend",function i(){t.classList.remove(e.stateClosing),t.classList.add(e.stateClosed),n(t),this.removeEventListener("transitionend",i)})):(t.classList.add(e.stateClosed),t.classList.remove(e.stateOpened),n(t))}))).then(function(){"modal"===o.mode&&E(!1,s),i&&T.call(r,o),o.state="closed",o.el.dispatchEvent(new CustomEvent(s.customEventPrefix+"closed",{detail:r,bubbles:!0}))});var t,e}();return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(t){return Promise.reject(t)}},_=function(t,e,n){try{var i=this,r=S.call(i,t);return Promise.resolve("closed"===r.state?D.call(i,r,e,n):F.call(i,r,e,n))}catch(t){return Promise.reject(t)}},I=function(t){try{var e=this;return t.el.classList.add(t.getSetting("classModal")),t.dialog.setAttribute("aria-modal","true"),!e.store.get(t.id)&&t.el.classList.contains(t.getSetting("stateOpened"))&&e.store.set(t.id,"opened"),Promise.resolve(F.call(e,t,!1,!1)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}},B=function(t){try{var e=this;return t.el.classList.remove(t.getSetting("classModal")),t.dialog.removeAttribute("aria-modal"),E(!1,n({},e.settings,t.settings)),e.focusTrap.unmount(),Promise.resolve(q.call(e,t)).then(function(){return t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix")+"switchMode",{detail:e,bubbles:!0})),t})}catch(t){return Promise.reject(t)}};function M(t){switch(t.mode){case"inline":return B.call(this,t);case"modal":return I.call(this,t);default:throw new Error('"'+t.mode+'" is not a valid drawer mode.')}}var N=function(t,e){try{var i=this;return Promise.resolve(j.call(i,t,!1)).then(function(){var r=i,o=new l,s={open:function(t,e){return D.call(r,this,t,e)},close:function(t,e){return F.call(r,this,t,e)},toggle:function(t,e){return _.call(r,this,t,e)},deregister:function(){return j.call(r,this)},mountBreakpoint:function(){var t=this.breakpoint,e=this.handleBreakpoint.bind(this);return o.mount(t,e),this},unmountBreakpoint:function(){return o.unmount(),this},handleBreakpoint:function(t){return this.mode=t.matches?"inline":"modal",this},getSetting:function(t){return t in this.settings?this.settings[t]:r.settings[t]}},a=n({id:t.id,el:t,dialog:e,trigger:null,settings:P(t,i.settings.dataConfig),get breakpoint(){return C.call(r,t)},get state(){return c},set state(t){c=t,"opened"!==t&&"closed"!==t||"inline"===this.mode&&r.store.set(this.id,this.state)},get mode(){return u},set mode(t){u=t,M.call(r,this)}},s),c=t.classList.contains(a.getSetting("stateOpened"))?"opened":"closed",u=t.classList.contains(a.getSetting("classModal"))?"modal":"inline";"modal"===a.mode?a.dialog.setAttribute("aria-modal","true"):a.dialog.removeAttribute("aria-modal"),a.getSetting("setTabindex")&&a.dialog.setAttribute("tabindex","-1"),i.collection.push(a);var d=function(){if(!a.breakpoint)return Promise.resolve(q.call(i,a)).then(function(){});a.mountBreakpoint()}();return d&&d.then?d.then(function(){return a}):a})}catch(t){return Promise.reject(t)}},K=/*#__PURE__*/s("handleClick"),V=/*#__PURE__*/s("handleKeydown");/*#__PURE__*/
return function(t){var o,s;function c(e){var i;return i=t.call(this)||this,Object.defineProperty(r(i),K,{writable:!0,value:void 0}),Object.defineProperty(r(i),V,{writable:!0,value:void 0}),i.defaults=L,i.settings=n({},i.defaults,e),i.focusTrap=new b,i.store=function(t,e){void 0===e&&(e=!0);var n=localStorage.getItem(t),i=n?JSON.parse(n):{};return{get:function(t){return t?i[t]:i},set:function(n,r){return r?i[n]=r:delete i[n],e&&localStorage.setItem(t,JSON.stringify(i)),i}}}(i.settings.storeKey,i.settings.store),a(r(i),K)[K]=O.bind(r(i)),a(r(i),V)[V]=k.bind(r(i)),i.settings.autoInit&&i.init(),i}s=t,(o=c).prototype=Object.create(s.prototype),o.prototype.constructor=o,i(o,s);var l=c.prototype;return l.init=function(t){void 0===t&&(t=null);try{var e=this;t&&(e.settings=n({},e.settings,t));var i=document.querySelectorAll(e.settings.selectorDrawer);return Promise.resolve(e.registerCollection(i)).then(function(){return e.settings.eventListeners&&e.initEventListeners(),e})}catch(t){return Promise.reject(t)}},l.destroy=function(){try{var t=this;return Promise.resolve(t.deregisterCollection()).then(function(){return t.settings.eventListeners&&t.destroyEventListeners(),t})}catch(t){return Promise.reject(t)}},l.initEventListeners=function(){document.addEventListener("click",a(this,K)[K],!1),document.addEventListener("keydown",a(this,V)[V],!1)},l.destroyEventListeners=function(){document.removeEventListener("click",a(this,K)[K],!1),document.removeEventListener("keydown",a(this,V)[V],!1)},l.register=function(t){var e=A.call(this,t);return e.error?Promise.reject(e.error):N.call(this,e.drawer,e.dialog)},l.deregister=function(t){var e=this.get(x.call(this,t));return j.call(this,e)},l.open=function(t,e,n){return D.call(this,t,e,n)},l.close=function(t,e,n){return F.call(this,t,e,n)},l.toggle=function(t,e,n){return _.call(this,t,e,n)},e(c,[{key:"activeModal",get:function(){return this.collection.find(function(t){return"opened"===t.state&&"modal"===t.mode})}}]),c}(f)});
//# sourceMappingURL=scripts.umd.js.map
{
"name": "@vrembem/drawer",
"description": "A container component that slides in from the left or right. Typically containing menus, search or other content.",
"version": "3.0.10",
"version": "3.0.11",
"license": "MIT",

@@ -45,3 +45,3 @@ "keywords": [

"dependencies": {
"@vrembem/core": "^3.0.10"
"@vrembem/core": "^3.0.11"
},

@@ -51,3 +51,3 @@ "publishConfig": {

},
"gitHead": "75c6eaa134958afba7cf5c19afc03adbfbebc8d2"
"gitHead": "d966f513f86f66dddf93ed60ddefe51124562dc0"
}

@@ -68,3 +68,2 @@ import { Collection, FocusTrap, localStore } from '@vrembem/core/index';

document.addEventListener('click', this.#handleClick, false);
document.addEventListener('touchend', this.#handleClick, false);
document.addEventListener('keydown', this.#handleKeydown, false);

@@ -75,3 +74,2 @@ }

document.removeEventListener('click', this.#handleClick, false);
document.removeEventListener('touchend', this.#handleClick, false);
document.removeEventListener('keydown', this.#handleKeydown, false);

@@ -78,0 +76,0 @@ }

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc