lwc
Version:
Lightning Web Components (LWC)
1,224 lines (1,213 loc) • 216 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LWC = {}));
}(this, (function (exports) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || {
__proto__: []
} instanceof Array && function (d, b) {
d.__proto__ = b;
} || function (d, b) {
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
};
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __spreadArray(to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i];
return to;
}
/* proxy-compat-disable */
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function detect$1() {
// Don't apply polyfill when ProxyCompat is enabled.
if ('getKey' in Proxy) {
return false;
}
var proxy = new Proxy([3, 4], {});
var res = [1, 2].concat(proxy);
return res.length !== 4;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var isConcatSpreadable = Symbol.isConcatSpreadable;
var isArray$3 = Array.isArray;
var _b = Array.prototype, ArraySlice$2 = _b.slice, ArrayUnshift$2 = _b.unshift, ArrayShift = _b.shift;
function isObject$2(O) {
return typeof O === 'object' ? O !== null : typeof O === 'function';
} // https://www.ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable
function isSpreadable(O) {
if (!isObject$2(O)) {
return false;
}
var spreadable = O[isConcatSpreadable];
return spreadable !== undefined ? Boolean(spreadable) : isArray$3(O);
} // https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat
function ArrayConcatPolyfill() {
var _args = [];
for (var _i = 0; _i < arguments.length; _i++) {
_args[_i] = arguments[_i];
}
var O = Object(this);
var A = [];
var N = 0;
var items = ArraySlice$2.call(arguments);
ArrayUnshift$2.call(items, O);
while (items.length) {
var E = ArrayShift.call(items);
if (isSpreadable(E)) {
var k_1 = 0;
var length = E.length;
for (k_1; k_1 < length; k_1 += 1, N += 1) {
if (k_1 in E) {
var subElement = E[k_1];
A[N] = subElement;
}
}
}
else {
A[N] = E;
N += 1;
}
}
return A;
}
function apply() {
// eslint-disable-next-line no-extend-native
Array.prototype.concat = ArrayConcatPolyfill;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
if (detect$1()) {
apply();
}
/**
* Copyright (C) 2018 salesforce.com, inc.
*/
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function invariant$1(value, msg) {
if (!value) {
throw new Error("Invariant Violation: " + msg);
}
}
function isTrue$1$1(value, msg) {
if (!value) {
throw new Error("Assert Violation: " + msg);
}
}
function isFalse$1$1(value, msg) {
if (value) {
throw new Error("Assert Violation: " + msg);
}
}
function fail$1(msg) {
throw new Error(msg);
}
var assert$1 = /*#__PURE__*/ Object.freeze({
__proto__: null,
invariant: invariant$1,
isTrue: isTrue$1$1,
isFalse: isFalse$1$1,
fail: fail$1
});
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var assign$2 = Object.assign, create$3 = Object.create, defineProperty$2 = Object.defineProperty, freeze$2 = Object.freeze, hasOwnProperty$3 = Object.hasOwnProperty, keys$2 = Object.keys, seal$2 = Object.seal, setPrototypeOf$2 = Object.setPrototypeOf;
var isArray$2 = Array.isArray;
var _c = Array.prototype, ArrayJoin$1 = _c.join, ArrayMap$2 = _c.map, forEach$1 = _c.forEach;
var _d = String.prototype, StringReplace$1 = _d.replace, StringToLowerCase$1 = _d.toLowerCase;
function isUndefined$4(obj) {
return obj === undefined;
}
function isNull$1(obj) {
return obj === null;
}
function isFalse$3(obj) {
return obj === false;
}
function isFunction$2(obj) {
return typeof obj === 'function';
}
function isObject$1(obj) {
return typeof obj === 'object';
}
var OtS$2 = {}.toString;
function toString$2(obj) {
if (obj && obj.toString) {
// Arrays might hold objects with "null" prototype So using
// Array.prototype.toString directly will cause an error Iterate through
// all the items and handle individually.
if (isArray$2(obj)) {
return ArrayJoin$1.call(ArrayMap$2.call(obj, toString$2), ',');
}
return obj.toString();
}
else if (typeof obj === 'object') {
return OtS$2.call(obj);
}
else {
return obj + '';
}
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
/**
* According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
* ariaGrabbed) are deprecated:
* https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
*
* The above list of 46 aria attributes is consistent with the following resources:
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
* https://wicg.github.io/aom/spec/aria-reflection.html
*/
var AriaPropertyNames$1 = ['ariaActiveDescendant', 'ariaAtomic', 'ariaAutoComplete', 'ariaBusy', 'ariaChecked', 'ariaColCount', 'ariaColIndex', 'ariaColSpan', 'ariaControls', 'ariaCurrent', 'ariaDescribedBy', 'ariaDetails', 'ariaDisabled', 'ariaErrorMessage', 'ariaExpanded', 'ariaFlowTo', 'ariaHasPopup', 'ariaHidden', 'ariaInvalid', 'ariaKeyShortcuts', 'ariaLabel', 'ariaLabelledBy', 'ariaLevel', 'ariaLive', 'ariaModal', 'ariaMultiLine', 'ariaMultiSelectable', 'ariaOrientation', 'ariaOwns', 'ariaPlaceholder', 'ariaPosInSet', 'ariaPressed', 'ariaReadOnly', 'ariaRelevant', 'ariaRequired', 'ariaRoleDescription', 'ariaRowCount', 'ariaRowIndex', 'ariaRowSpan', 'ariaSelected', 'ariaSetSize', 'ariaSort', 'ariaValueMax', 'ariaValueMin', 'ariaValueNow', 'ariaValueText', 'role'];
var _e = (function () {
var AriaAttrNameToPropNameMap = create$3(null);
var AriaPropNameToAttrNameMap = create$3(null); // Synthetic creation of all AOM property descriptors for Custom Elements
forEach$1.call(AriaPropertyNames$1, function (propName) {
var attrName = StringToLowerCase$1.call(StringReplace$1.call(propName, /^aria/, function () { return 'aria-'; }));
AriaAttrNameToPropNameMap[attrName] = propName;
AriaPropNameToAttrNameMap[propName] = attrName;
});
return {
AriaAttrNameToPropNameMap: AriaAttrNameToPropNameMap,
AriaPropNameToAttrNameMap: AriaPropNameToAttrNameMap
};
})(), AriaPropNameToAttrNameMap$1 = _e.AriaPropNameToAttrNameMap;
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
// we can't use typeof since it will fail when transpiling.
var hasNativeSymbolSupport$1 = /*@__PURE__*/ (function () { return Symbol('x').toString() === 'Symbol(x)'; })();
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// This method abstracts the creation of symbols, so we can fallback to strings when native symbols
// are not supported.
function createHiddenField$1(key, namespace) {
return hasNativeSymbolSupport$1 ? Symbol(key) : "$$lwc-" + namespace + "-" + key + "$$";
}
var hiddenFieldsMap$1 = new WeakMap();
function setHiddenField$1(o, field, value) {
var valuesByField = hiddenFieldsMap$1.get(o);
if (isUndefined$4(valuesByField)) {
valuesByField = create$3(null);
hiddenFieldsMap$1.set(o, valuesByField);
}
valuesByField[field] = value;
}
function getHiddenField$1(o, field) {
var valuesByField = hiddenFieldsMap$1.get(o);
if (!isUndefined$4(valuesByField)) {
return valuesByField[field];
}
}
/** version: 2.1.2 */
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function detect(propName) {
return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var nodeToAriaPropertyValuesMap = new WeakMap();
function getAriaPropertyMap(elm) {
var map = nodeToAriaPropertyValuesMap.get(elm);
if (map === undefined) {
map = {};
nodeToAriaPropertyValuesMap.set(elm, map);
}
return map;
}
function getNormalizedAriaPropertyValue(value) {
return value == null ? null : String(value);
}
function createAriaPropertyPropertyDescriptor(propName, attrName) {
return {
get: function () {
var map = getAriaPropertyMap(this);
if (hasOwnProperty$3.call(map, propName)) {
return map[propName];
} // otherwise just reflect what's in the attribute
return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
},
set: function (newValue) {
var normalizedValue = getNormalizedAriaPropertyValue(newValue);
var map = getAriaPropertyMap(this);
map[propName] = normalizedValue; // reflect into the corresponding attribute
if (newValue === null) {
this.removeAttribute(attrName);
}
else {
this.setAttribute(attrName, newValue);
}
},
configurable: true,
enumerable: true
};
}
function patch(propName) {
// Typescript is inferring the wrong function type for this particular
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
// @ts-ignore type-mismatch
var attrName = AriaPropNameToAttrNameMap$1[propName];
var descriptor = createAriaPropertyPropertyDescriptor(propName, attrName);
Object.defineProperty(Element.prototype, propName, descriptor);
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var ElementPrototypeAriaPropertyNames = keys$2(AriaPropNameToAttrNameMap$1);
for (var i_2 = 0, len = ElementPrototypeAriaPropertyNames.length; i_2 < len; i_2 += 1) {
var propName = ElementPrototypeAriaPropertyNames[i_2];
if (detect(propName)) {
patch(propName);
}
}
/* proxy-compat-disable */
/**
* Copyright (C) 2018 salesforce.com, inc.
*/
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function invariant(value, msg) {
if (!value) {
throw new Error("Invariant Violation: " + msg);
}
}
function isTrue$1(value, msg) {
if (!value) {
throw new Error("Assert Violation: " + msg);
}
}
function isFalse$1(value, msg) {
if (value) {
throw new Error("Assert Violation: " + msg);
}
}
function fail(msg) {
throw new Error(msg);
}
var assert = /*#__PURE__*/ Object.freeze({
__proto__: null,
invariant: invariant,
isTrue: isTrue$1,
isFalse: isFalse$1,
fail: fail
});
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var assign$1 = Object.assign, create$2 = Object.create, defineProperties$1 = Object.defineProperties, defineProperty$1 = Object.defineProperty, freeze$1 = Object.freeze, getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor, getOwnPropertyNames$2 = Object.getOwnPropertyNames, getPrototypeOf$2 = Object.getPrototypeOf, hasOwnProperty$2 = Object.hasOwnProperty, isFrozen$1 = Object.isFrozen, keys$1 = Object.keys, seal$1 = Object.seal, setPrototypeOf$1 = Object.setPrototypeOf;
var isArray$1 = Array.isArray;
var _f = Array.prototype, ArrayJoin = _f.join, ArrayMap$1 = _f.map, ArrayPush$2 = _f.push, ArraySlice = _f.slice, ArrayUnshift = _f.unshift, forEach = _f.forEach;
var StringFromCharCode = String.fromCharCode;
var _g = String.prototype, StringCharCodeAt = _g.charCodeAt, StringReplace = _g.replace, StringSlice = _g.slice, StringToLowerCase = _g.toLowerCase;
function isUndefined$3(obj) {
return obj === undefined;
}
function isNull(obj) {
return obj === null;
}
function isTrue$2(obj) {
return obj === true;
}
function isFalse$2(obj) {
return obj === false;
}
function isFunction$1(obj) {
return typeof obj === 'function';
}
function isString(obj) {
return typeof obj === 'string';
}
var OtS$1 = {}.toString;
function toString$1(obj) {
if (obj && obj.toString) {
// Arrays might hold objects with "null" prototype So using
// Array.prototype.toString directly will cause an error Iterate through
// all the items and handle individually.
if (isArray$1(obj)) {
return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
}
return obj.toString();
}
else if (typeof obj === 'object') {
return OtS$1.call(obj);
}
else {
return obj + '';
}
}
function getPropertyDescriptor(o, p) {
do {
var d_1 = getOwnPropertyDescriptor$2(o, p);
if (!isUndefined$3(d_1)) {
return d_1;
}
o = getPrototypeOf$2(o);
} while (o !== null);
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
/**
* According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
* ariaGrabbed) are deprecated:
* https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
*
* The above list of 46 aria attributes is consistent with the following resources:
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
* https://wicg.github.io/aom/spec/aria-reflection.html
*/
var AriaPropertyNames = ['ariaActiveDescendant', 'ariaAtomic', 'ariaAutoComplete', 'ariaBusy', 'ariaChecked', 'ariaColCount', 'ariaColIndex', 'ariaColSpan', 'ariaControls', 'ariaCurrent', 'ariaDescribedBy', 'ariaDetails', 'ariaDisabled', 'ariaErrorMessage', 'ariaExpanded', 'ariaFlowTo', 'ariaHasPopup', 'ariaHidden', 'ariaInvalid', 'ariaKeyShortcuts', 'ariaLabel', 'ariaLabelledBy', 'ariaLevel', 'ariaLive', 'ariaModal', 'ariaMultiLine', 'ariaMultiSelectable', 'ariaOrientation', 'ariaOwns', 'ariaPlaceholder', 'ariaPosInSet', 'ariaPressed', 'ariaReadOnly', 'ariaRelevant', 'ariaRequired', 'ariaRoleDescription', 'ariaRowCount', 'ariaRowIndex', 'ariaRowSpan', 'ariaSelected', 'ariaSetSize', 'ariaSort', 'ariaValueMax', 'ariaValueMin', 'ariaValueNow', 'ariaValueText', 'role'];
var _h = (function () {
var AriaAttrNameToPropNameMap = create$2(null);
var AriaPropNameToAttrNameMap = create$2(null); // Synthetic creation of all AOM property descriptors for Custom Elements
forEach.call(AriaPropertyNames, function (propName) {
var attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, function () { return 'aria-'; }));
AriaAttrNameToPropNameMap[attrName] = propName;
AriaPropNameToAttrNameMap[propName] = attrName;
});
return {
AriaAttrNameToPropNameMap: AriaAttrNameToPropNameMap,
AriaPropNameToAttrNameMap: AriaPropNameToAttrNameMap
};
})(), AriaPropNameToAttrNameMap = _h.AriaPropNameToAttrNameMap;
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
// we can't use typeof since it will fail when transpiling.
var hasNativeSymbolSupport = /*@__PURE__*/ (function () { return Symbol('x').toString() === 'Symbol(x)'; })();
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// This method abstracts the creation of symbols, so we can fallback to strings when native symbols
// are not supported.
function createHiddenField(key, namespace) {
return hasNativeSymbolSupport ? Symbol(key) : "$$lwc-" + namespace + "-" + key + "$$";
}
var hiddenFieldsMap = new WeakMap();
function setHiddenField(o, field, value) {
var valuesByField = hiddenFieldsMap.get(o);
if (isUndefined$3(valuesByField)) {
valuesByField = create$2(null);
hiddenFieldsMap.set(o, valuesByField);
}
valuesByField[field] = value;
}
function getHiddenField(o, field) {
var valuesByField = hiddenFieldsMap.get(o);
if (!isUndefined$3(valuesByField)) {
return valuesByField[field];
}
}
/**
* Map composed of properties to attributes not following the HTML property to attribute mapping
* convention.
*/
var NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING = new Map([['accessKey', 'accesskey'], ['readOnly', 'readonly'], ['tabIndex', 'tabindex'], ['bgColor', 'bgcolor'], ['colSpan', 'colspan'], ['rowSpan', 'rowspan'], ['contentEditable', 'contenteditable'], ['crossOrigin', 'crossorigin'], ['dateTime', 'datetime'], ['formAction', 'formaction'], ['isMap', 'ismap'], ['maxLength', 'maxlength'], ['minLength', 'minlength'], ['noValidate', 'novalidate'], ['useMap', 'usemap'], ['htmlFor', 'for']]);
/**
* Map associating previously transformed HTML property into HTML attribute.
*/
var CACHED_PROPERTY_ATTRIBUTE_MAPPING = new Map();
function htmlPropertyToAttribute(propName) {
var ariaAttributeName = AriaPropNameToAttrNameMap[propName];
if (!isUndefined$3(ariaAttributeName)) {
return ariaAttributeName;
}
var specialAttributeName = NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
if (!isUndefined$3(specialAttributeName)) {
return specialAttributeName;
}
var cachedAttributeName = CACHED_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
if (!isUndefined$3(cachedAttributeName)) {
return cachedAttributeName;
}
var attributeName = '';
for (var i_3 = 0, len = propName.length; i_3 < len; i_3++) {
var code = StringCharCodeAt.call(propName, i_3);
if (code >= 65 && // "A"
code <= 90 // "Z"
) {
attributeName += '-' + StringFromCharCode(code + 32);
}
else {
attributeName += StringFromCharCode(code);
}
}
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
return attributeName;
}
/** version: 2.1.2 */
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var nextTickCallbackQueue = [];
var SPACE_CHAR = 32;
var EmptyObject = seal$1(create$2(null));
var EmptyArray = seal$1([]);
function flushCallbackQueue() {
var callbacks = nextTickCallbackQueue;
nextTickCallbackQueue = []; // reset to a new queue
for (var i_4 = 0, len = callbacks.length; i_4 < len; i_4 += 1) {
callbacks[i_4]();
}
}
function addCallbackToNextTick(callback) {
if (nextTickCallbackQueue.length === 0) {
Promise.resolve().then(flushCallbackQueue);
}
ArrayPush$2.call(nextTickCallbackQueue, callback);
}
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}
/*
* Copyright (c) 2019, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var create$1 = Object.create;
var _j = Array.prototype, ArraySplice = _j.splice, ArrayIndexOf = _j.indexOf, ArrayPush$1 = _j.push;
var TargetToReactiveRecordMap = new WeakMap();
function isUndefined$2(obj) {
return obj === undefined;
}
function getReactiveRecord(target) {
var reactiveRecord = TargetToReactiveRecordMap.get(target);
if (isUndefined$2(reactiveRecord)) {
var newRecord = create$1(null);
reactiveRecord = newRecord;
TargetToReactiveRecordMap.set(target, newRecord);
}
return reactiveRecord;
}
var currentReactiveObserver = null;
function valueMutated(target, key) {
var reactiveRecord = TargetToReactiveRecordMap.get(target);
if (!isUndefined$2(reactiveRecord)) {
var reactiveObservers = reactiveRecord[key];
if (!isUndefined$2(reactiveObservers)) {
for (var i_5 = 0, len = reactiveObservers.length; i_5 < len; i_5 += 1) {
var ro = reactiveObservers[i_5];
ro.notify();
}
}
}
}
function valueObserved(target, key) {
// We should determine if an active Observing Record is present to track mutations.
if (currentReactiveObserver === null) {
return;
}
var ro = currentReactiveObserver;
var reactiveRecord = getReactiveRecord(target);
var reactiveObservers = reactiveRecord[key];
if (isUndefined$2(reactiveObservers)) {
reactiveObservers = [];
reactiveRecord[key] = reactiveObservers;
}
else if (reactiveObservers[0] === ro) {
return; // perf optimization considering that most subscriptions will come from the same record
}
if (ArrayIndexOf.call(reactiveObservers, ro) === -1) {
ro.link(reactiveObservers);
}
}
var ReactiveObserver = /** @class */ (function () {
function ReactiveObserver(callback) {
this.listeners = [];
this.callback = callback;
}
ReactiveObserver.prototype.observe = function (job) {
var inceptionReactiveRecord = currentReactiveObserver;
currentReactiveObserver = this;
var error;
try {
job();
}
catch (e) {
error = Object(e);
}
finally {
currentReactiveObserver = inceptionReactiveRecord;
if (error !== undefined) {
throw error; // eslint-disable-line no-unsafe-finally
}
}
};
/**
* This method is responsible for disconnecting the Reactive Observer
* from any Reactive Record that has a reference to it, to prevent future
* notifications about previously recorded access.
*/
ReactiveObserver.prototype.reset = function () {
var listeners = this.listeners;
var len = listeners.length;
if (len > 0) {
for (var i_6 = 0; i_6 < len; i_6 += 1) {
var set = listeners[i_6];
var pos = ArrayIndexOf.call(listeners[i_6], this);
ArraySplice.call(set, pos, 1);
}
listeners.length = 0;
}
}; // friend methods
ReactiveObserver.prototype.notify = function () {
this.callback.call(undefined, this);
};
ReactiveObserver.prototype.link = function (reactiveObservers) {
ArrayPush$1.call(reactiveObservers, this); // we keep track of observing records where the observing record was added to so we can do some clean up later on
ArrayPush$1.call(this.listeners, reactiveObservers);
};
return ReactiveObserver;
}());
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function componentValueMutated(vm, key) {
valueMutated(vm.component, key);
}
function componentValueObserved(vm, key) {
valueObserved(vm.component, key);
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function getComponentTag(vm) {
return "<" + StringToLowerCase.call(vm.tagName) + ">";
} // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
function getErrorComponentStack(vm) {
var wcStack = [];
var currentVm = vm;
while (!isNull(currentVm)) {
ArrayPush$2.call(wcStack, getComponentTag(currentVm));
currentVm = currentVm.owner;
}
return wcStack.reverse().join('\n\t');
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function handleEvent(event, vnode) {
var type = event.type;
var on = vnode.data.on;
var handler = on && on[type]; // call event handler if exists
if (handler) {
handler.call(undefined, event);
}
}
function createListener() {
return function handler(event) {
handleEvent(event, handler.vnode);
};
}
function updateAllEventListeners(oldVnode, vnode) {
if (isUndefined$3(oldVnode.listener)) {
createAllEventListeners(vnode);
}
else {
vnode.listener = oldVnode.listener;
vnode.listener.vnode = vnode;
}
}
function createAllEventListeners(vnode) {
var elm = vnode.elm, on = vnode.data.on, renderer = vnode.owner.renderer;
if (isUndefined$3(on)) {
return;
}
var listener = vnode.listener = createListener();
listener.vnode = vnode;
var name;
for (name in on) {
renderer.addEventListener(elm, name, listener);
}
}
var modEvents = {
update: updateAllEventListeners,
create: createAllEventListeners
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
function offsetPropertyErrorMessage(name) {
return "Using the `" + name + "` property is an anti-pattern because it rounds the value to an integer. Instead, use the `getBoundingClientRect` method to obtain fractional values for the size of an element and its position relative to the viewport.";
} // Global HTML Attributes & Properties
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
assign$1(create$2(null), {
accessKey: {
attribute: 'accesskey'
},
accessKeyLabel: {
readOnly: true
},
className: {
attribute: 'class',
error: 'Using the `className` property is an anti-pattern because of slow runtime behavior and potential conflicts with classes provided by the owner element. Use the `classList` API instead.'
},
contentEditable: {
attribute: 'contenteditable'
},
dataset: {
readOnly: true,
error: "Using the `dataset` property is an anti-pattern because it can't be statically analyzed. Expose each property individually using the `@api` decorator instead."
},
dir: {
attribute: 'dir'
},
draggable: {
attribute: 'draggable'
},
dropzone: {
attribute: 'dropzone',
readOnly: true
},
hidden: {
attribute: 'hidden'
},
id: {
attribute: 'id'
},
inputMode: {
attribute: 'inputmode'
},
lang: {
attribute: 'lang'
},
slot: {
attribute: 'slot',
error: 'Using the `slot` property is an anti-pattern.'
},
spellcheck: {
attribute: 'spellcheck'
},
style: {
attribute: 'style'
},
tabIndex: {
attribute: 'tabindex'
},
title: {
attribute: 'title'
},
translate: {
attribute: 'translate'
},
// additional "global attributes" that are not present in the link above.
isContentEditable: {
readOnly: true
},
offsetHeight: {
readOnly: true,
error: offsetPropertyErrorMessage('offsetHeight')
},
offsetLeft: {
readOnly: true,
error: offsetPropertyErrorMessage('offsetLeft')
},
offsetParent: {
readOnly: true
},
offsetTop: {
readOnly: true,
error: offsetPropertyErrorMessage('offsetTop')
},
offsetWidth: {
readOnly: true,
error: offsetPropertyErrorMessage('offsetWidth')
},
role: {
attribute: 'role'
}
});
var controlledElement = null;
var controlledAttributeName;
function isAttributeLocked(elm, attrName) {
return elm !== controlledElement || attrName !== controlledAttributeName;
}
function lockAttribute(_elm, _key) {
controlledElement = null;
controlledAttributeName = undefined;
}
function unlockAttribute(elm, key) {
controlledElement = elm;
controlledAttributeName = key;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var xlinkNS = 'http://www.w3.org/1999/xlink';
var xmlNS = 'http://www.w3.org/XML/1998/namespace';
var ColonCharCode = 58;
function updateAttrs(oldVnode, vnode) {
var attrs = vnode.data.attrs, renderer = vnode.owner.renderer;
if (isUndefined$3(attrs)) {
return;
}
var oldAttrs = oldVnode.data.attrs;
if (oldAttrs === attrs) {
return;
}
var elm = vnode.elm;
var setAttribute = renderer.setAttribute, removeAttribute = renderer.removeAttribute;
var key;
oldAttrs = isUndefined$3(oldAttrs) ? EmptyObject : oldAttrs; // update modified attributes, add new attributes
// this routine is only useful for data-* attributes in all kind of elements
// and aria-* in standard elements (custom elements will use props for these)
for (key in attrs) {
var cur = attrs[key];
var old = oldAttrs[key];
if (old !== cur) {
unlockAttribute(elm, key);
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
// Assume xml namespace
setAttribute(elm, key, cur, xmlNS);
}
else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
// Assume xlink namespace
setAttribute(elm, key, cur, xlinkNS);
}
else if (isNull(cur)) {
removeAttribute(elm, key);
}
else {
setAttribute(elm, key, cur);
}
lockAttribute();
}
}
}
var emptyVNode$3 = {
data: {}
};
var modAttrs = {
create: function (vnode) { return updateAttrs(emptyVNode$3, vnode); },
update: updateAttrs
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function isLiveBindingProp(sel, key) {
// For properties with live bindings, we read values from the DOM element
// instead of relying on internally tracked values.
return sel === 'input' && (key === 'value' || key === 'checked');
}
function update(oldVnode, vnode) {
var props = vnode.data.props;
if (isUndefined$3(props)) {
return;
}
var oldProps = oldVnode.data.props;
if (oldProps === props) {
return;
}
var isFirstPatch = isUndefined$3(oldProps);
var elm = vnode.elm, sel = vnode.sel, renderer = vnode.owner.renderer;
for (var key in props) {
var cur = props[key]; // if it is the first time this element is patched, or the current value is different to the previous value...
if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? renderer.getProperty(elm, key) : oldProps[key])) {
renderer.setProperty(elm, key, cur);
}
}
}
var emptyVNode$2 = {
data: {}
};
var modProps = {
create: function (vnode) { return update(emptyVNode$2, vnode); },
update: update
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
var classNameToClassMap = create$2(null);
function getMapFromClassName(className) {
// Intentionally using == to match undefined and null values from computed style attribute
if (className == null) {
return EmptyObject;
} // computed class names must be string
className = isString(className) ? className : className + '';
var map = classNameToClassMap[className];
if (map) {
return map;
}
map = create$2(null);
var start = 0;
var o;
var len = className.length;
for (o = 0; o < len; o++) {
if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
if (o > start) {
map[StringSlice.call(className, start, o)] = true;
}
start = o + 1;
}
}
if (o > start) {
map[StringSlice.call(className, start, o)] = true;
}
classNameToClassMap[className] = map;
return map;
}
function updateClassAttribute(oldVnode, vnode) {
var elm = vnode.elm, newClass = vnode.data.className, renderer = vnode.owner.renderer;
var oldClass = oldVnode.data.className;
if (oldClass === newClass) {
return;
}
var classList = renderer.getClassList(elm);
var newClassMap = getMapFromClassName(newClass);
var oldClassMap = getMapFromClassName(oldClass);
var name;
for (name in oldClassMap) {
// remove only if it is not in the new class collection and it is not set from within the instance
if (isUndefined$3(newClassMap[name])) {
classList.remove(name);
}
}
for (name in newClassMap) {
if (isUndefined$3(oldClassMap[name])) {
classList.add(name);
}
}
}
var emptyVNode$1 = {
data: {}
};
var modComputedClassName = {
create: function (vnode) { return updateClassAttribute(emptyVNode$1, vnode); },
update: updateClassAttribute
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function updateStyleAttribute(oldVnode, vnode) {
var elm = vnode.elm, newStyle = vnode.data.style, renderer = vnode.owner.renderer;
var setAttribute = renderer.setAttribute, removeAttribute = renderer.removeAttribute;
if (oldVnode.data.style === newStyle) {
return;
}
if (!isString(newStyle) || newStyle === '') {
removeAttribute(elm, 'style');
}
else {
setAttribute(elm, 'style', newStyle);
}
}
var emptyVNode = {
data: {}
};
var modComputedStyle = {
create: function (vnode) { return updateStyleAttribute(emptyVNode, vnode); },
update: updateStyleAttribute
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
// different classnames properties individually instead of via a string.
function createClassAttribute(vnode) {
var elm = vnode.elm, classMap = vnode.data.classMap, renderer = vnode.owner.renderer;
if (isUndefined$3(classMap)) {
return;
}
var classList = renderer.getClassList(elm);
for (var name in classMap) {
classList.add(name);
}
}
var modStaticClassName = {
create: createClassAttribute
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// The compiler takes care of transforming the inline style into an object. It's faster to set the
// different style properties individually instead of via a string.
function createStyleAttribute(vnode) {
var elm = vnode.elm, styleMap = vnode.data.styleMap, renderer = vnode.owner.renderer;
if (isUndefined$3(styleMap)) {
return;
}
for (var name in styleMap) {
renderer.setCSSStyleProperty(elm, name, styleMap[name]);
}
}
var modStaticStyle = {
create: createStyleAttribute
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
/**
@license
Copyright (c) 2015 Simon Friis Vindum.
This code may only be used under the MIT License found at
https://github.com/snabbdom/snabbdom/blob/master/LICENSE
Code distributed by Snabbdom as part of the Snabbdom project at
https://github.com/snabbdom/snabbdom/
*/
function isUndef(s) {
return s === undefined;
}
function sameVnode(vnode1, vnode2) {
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
}
function isVNode(vnode) {
return vnode != null;
}
function createKeyToOldIdx(children, beginIdx, endIdx) {
var map = {};
var j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
for (j = beginIdx; j <= endIdx; ++j) {
ch = children[j];
if (isVNode(ch)) {
key = ch.key;
if (key !== undefined) {
map[key] = j;
}
}
}
return map;
}
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var ch = vnodes[startIdx];
if (isVNode(ch)) {
ch.hook.create(ch);
ch.hook.insert(ch, parentElm, before);
}
}
}
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var ch = vnodes[startIdx]; // text nodes do not have logic associated to them
if (isVNode(ch)) {
ch.hook.remove(ch, parentElm);
}
}
}
function updateDynamicChildren(parentElm, oldCh, newCh) {
var oldStartIdx = 0;
var newStartIdx = 0;
var oldEndIdx = oldCh.length - 1;
var oldStartVnode = oldCh[0];
var oldEndVnode = oldCh[oldEndIdx];
var newChEnd = newCh.length - 1;
var newEndIdx = newChEnd;
var newStartVnode = newCh[0];
var newEndVnode = newCh[newEndIdx];
var oldKeyToIdx;
var idxInOld;
var elmToMove;
var before;
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (!isVNode(oldStartVnode)) {
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
}
else if (!isVNode(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
}
else if (!isVNode(newStartVnode)) {
newStartVnode = newCh[++newStartIdx];
}
else if (!isVNode(newEndVnode)) {
newEndVnode = newCh[--newEndIdx];
}
else if (sameVnode(oldStartVnode, newStartVnode)) {
patchVnode(oldStartVnode, newStartVnode);
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
}
else if (sameVnode(oldEndVnode, newEndVnode)) {
patchVnode(oldEndVnode, newEndVnode);
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
}
else if (sameVnode(oldStartVnode, newEndVnode)) {
// Vnode moved right
patchVnode(oldStartVnode, newEndVnode);
newEndVnode.hook.move(oldStartVnode, parentElm, oldEndVnode.owner.renderer.nextSibling(oldEndVnode.elm));
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
}
else if (sameVnode(oldEndVnode, newStartVnode)) {
// Vnode moved left
patchVnode(oldEndVnode, newStartVnode);
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
}
else {
if (oldKeyToIdx === undefined) {
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
}
idxInOld = oldKeyToIdx[newStartVnode.key];
if (isUndef(idxInOld)) {
// New element
newStartVnode.hook.create(newStartVnode);
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
}
else {
elmToMove = oldCh[idxInOld];
if (isVNode(elmToMove)) {
if (elmToMove.sel !== newStartVnode.sel) {
// New element
newStartVnode.hook.create(newStartVnode);
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
}
else {
patchVnode(elmToMove, newStartVnode);
oldCh[idxInOld] = undefined;
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
}
}
newStartVnode = newCh[++newStartIdx];
}
}
}
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
if (oldStartIdx > oldEndIdx) {
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
var i_7 = newEndIdx;
var n = void 0;
do {
n = newCh[++i_7];
} while (!isVNode(n) && i_7 < newChEnd);
before = isVNode(n) ? n.elm : null;
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
}
else {
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
}
}
}
function updateStaticChildren(parentElm, oldCh, newCh) {
var oldChLength = oldCh.length;