(function() {
/*!
* @overview Ember - JavaScript Application Framework
* @copyright Copyright 2011-2018 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
* @version 3.6.0
*/
/*globals process */
var enifed, requireModule, Ember;
// Used in @ember/-internals/environment/lib/global.js
mainContext = this; // eslint-disable-line no-undef
(function() {
function missingModule(name, referrerName) {
if (referrerName) {
throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
} else {
throw new Error('Could not find module ' + name);
}
}
function internalRequire(_name, referrerName) {
var name = _name;
var mod = registry[name];
if (!mod) {
name = name + '/index';
mod = registry[name];
}
var exports = seen[name];
if (exports !== undefined) {
return exports;
}
exports = seen[name] = {};
if (!mod) {
missingModule(_name, referrerName);
}
var deps = mod.deps;
var callback = mod.callback;
var reified = new Array(deps.length);
for (var i = 0; i < deps.length; i++) {
if (deps[i] === 'exports') {
reified[i] = exports;
} else if (deps[i] === 'require') {
reified[i] = requireModule;
} else {
reified[i] = internalRequire(deps[i], name);
}
}
callback.apply(this, reified);
return exports;
}
var isNode =
typeof window === 'undefined' &&
typeof process !== 'undefined' &&
{}.toString.call(process) === '[object process]';
if (!isNode) {
Ember = this.Ember = this.Ember || {};
}
if (typeof Ember === 'undefined') {
Ember = {};
}
if (typeof Ember.__loader === 'undefined') {
var registry = Object.create(null);
var seen = Object.create(null);
enifed = function(name, deps, callback) {
var value = {};
if (!callback) {
value.deps = [];
value.callback = deps;
} else {
value.deps = deps;
value.callback = callback;
}
registry[name] = value;
};
requireModule = function(name) {
return internalRequire(name, null);
};
// setup `require` module
requireModule['default'] = requireModule;
requireModule.has = function registryHas(moduleName) {
return !!registry[moduleName] || !!registry[moduleName + '/index'];
};
requireModule._eak_seen = registry;
Ember.__loader = {
define: enifed,
require: requireModule,
registry: registry,
};
} else {
enifed = Ember.__loader.define;
requireModule = Ember.__loader.require;
}
})();
enifed('@ember/-internals/browser-environment', ['exports'], function (exports) {
'use strict';
// check if window exists and actually is the global
var hasDom = typeof self === 'object' && self !== null && self.Object === Object && typeof Window !== 'undefined' && self.constructor === Window && typeof document === 'object' && document !== null && self.document === document && typeof location === 'object' && location !== null && self.location === location && typeof history === 'object' && history !== null && self.history === history && typeof navigator === 'object' && navigator !== null && self.navigator === navigator && typeof navigator.userAgent === 'string';
const window = hasDom ? self : null;
const location$1 = hasDom ? self.location : null;
const history$1 = hasDom ? self.history : null;
const userAgent = hasDom ? self.navigator.userAgent : 'Lynx (textmode)';
const isChrome = hasDom ? !!window.chrome && !window.opera : false;
const isFirefox = hasDom ? typeof InstallTrigger !== 'undefined' : false;
exports.window = window;
exports.location = location$1;
exports.history = history$1;
exports.userAgent = userAgent;
exports.isChrome = isChrome;
exports.isFirefox = isFirefox;
exports.hasDOM = hasDom;
});
enifed('@ember/-internals/environment', ['exports'], function (exports) {
'use strict';
// from lodash to catch fake globals
function checkGlobal(value) {
return value && value.Object === Object ? value : undefined;
}
// element ids can ruin global miss checks
function checkElementIdShadowing(value) {
return value && value.nodeType === undefined ? value : undefined;
}
// export real global
var global$1 = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || typeof mainContext !== 'undefined' && mainContext || // set before strict mode in Ember loader/wrapper
new Function('return this')(); // eval outside of strict mode
// legacy imports/exports/lookup stuff (should we keep this??)
const context = function (global, Ember) {
return Ember === undefined ? { imports: global, exports: global, lookup: global } : {
// import jQuery
imports: Ember.imports || global,
// export Ember
exports: Ember.exports || global,
// search for Namespaces
lookup: Ember.lookup || global
};
}(global$1, global$1.Ember);
function getLookup() {
return context.lookup;
}
function setLookup(value) {
context.lookup = value;
}
/**
The hash of environment variables used to control various configuration
settings. To specify your own or override default settings, add the
desired properties to a global hash named `EmberENV` (or `ENV` for
backwards compatibility with earlier versions of Ember). The `EmberENV`
hash must be created before loading Ember.
@class EmberENV
@type Object
@public
*/
const ENV = {
ENABLE_OPTIONAL_FEATURES: false,
/**
Determines whether Ember should add to `Array`, `Function`, and `String`
native object prototypes, a few extra methods in order to provide a more
friendly API.
We generally recommend leaving this option set to true however, if you need
to turn it off, you can add the configuration property
`EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`.
Note, when disabled (the default configuration for Ember Addons), you will
instead have to access all methods and functions from the Ember
namespace.
@property EXTEND_PROTOTYPES
@type Boolean
@default true
@for EmberENV
@public
*/
EXTEND_PROTOTYPES: {
Array: true,
Function: true,
String: true
},
/**
The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log
a full stack trace during deprecation warnings.
@property LOG_STACKTRACE_ON_DEPRECATION
@type Boolean
@default true
@for EmberENV
@public
*/
LOG_STACKTRACE_ON_DEPRECATION: true,
/**
The `LOG_VERSION` property, when true, tells Ember to log versions of all
dependent libraries in use.
@property LOG_VERSION
@type Boolean
@default true
@for EmberENV
@public
*/
LOG_VERSION: true,
RAISE_ON_DEPRECATION: false,
STRUCTURED_PROFILE: false,
/**
Whether to insert a `
` wrapper around the
application template. See RFC #280.
This is not intended to be set directly, as the implementation may change in
the future. Use `@ember/optional-features` instead.
@property _APPLICATION_TEMPLATE_WRAPPER
@for EmberENV
@type Boolean
@default true
@private
*/
_APPLICATION_TEMPLATE_WRAPPER: true,
/**
Whether to use Glimmer Component semantics (as opposed to the classic "Curly"
components semantics) for template-only components. See RFC #278.
This is not intended to be set directly, as the implementation may change in
the future. Use `@ember/optional-features` instead.
@property _TEMPLATE_ONLY_GLIMMER_COMPONENTS
@for EmberENV
@type Boolean
@default false
@private
*/
_TEMPLATE_ONLY_GLIMMER_COMPONENTS: false,
/**
Whether the app is using jQuery. See RFC #294.
This is not intended to be set directly, as the implementation may change in
the future. Use `@ember/optional-features` instead.
@property _JQUERY_INTEGRATION
@for EmberENV
@type Boolean
@default true
@private
*/
_JQUERY_INTEGRATION: true,
EMBER_LOAD_HOOKS: {},
FEATURES: {}
};
(EmberENV => {
if (typeof EmberENV !== 'object' || EmberENV === null) return;
for (let flag in EmberENV) {
if (!EmberENV.hasOwnProperty(flag) || flag === 'EXTEND_PROTOTYPES' || flag === 'EMBER_LOAD_HOOKS') continue;
let defaultValue = ENV[flag];
if (defaultValue === true) {
ENV[flag] = EmberENV[flag] !== false;
} else if (defaultValue === false) {
ENV[flag] = EmberENV[flag] === true;
}
}
let { EXTEND_PROTOTYPES } = EmberENV;
if (EXTEND_PROTOTYPES !== undefined) {
if (typeof EXTEND_PROTOTYPES === 'object' && EXTEND_PROTOTYPES !== null) {
ENV.EXTEND_PROTOTYPES.String = EXTEND_PROTOTYPES.String !== false;
ENV.EXTEND_PROTOTYPES.Function = EXTEND_PROTOTYPES.Function !== false;
ENV.EXTEND_PROTOTYPES.Array = EXTEND_PROTOTYPES.Array !== false;
} else {
let isEnabled = EXTEND_PROTOTYPES !== false;
ENV.EXTEND_PROTOTYPES.String = isEnabled;
ENV.EXTEND_PROTOTYPES.Function = isEnabled;
ENV.EXTEND_PROTOTYPES.Array = isEnabled;
}
}
// TODO this does not seem to be used by anything,
// can we remove it? do we need to deprecate it?
let { EMBER_LOAD_HOOKS } = EmberENV;
if (typeof EMBER_LOAD_HOOKS === 'object' && EMBER_LOAD_HOOKS !== null) {
for (let hookName in EMBER_LOAD_HOOKS) {
if (!EMBER_LOAD_HOOKS.hasOwnProperty(hookName)) continue;
let hooks = EMBER_LOAD_HOOKS[hookName];
if (Array.isArray(hooks)) {
ENV.EMBER_LOAD_HOOKS[hookName] = hooks.filter(hook => typeof hook === 'function');
}
}
}
let { FEATURES } = EmberENV;
if (typeof FEATURES === 'object' && FEATURES !== null) {
for (let feature in FEATURES) {
if (!FEATURES.hasOwnProperty(feature)) continue;
ENV.FEATURES[feature] = FEATURES[feature] === true;
}
}
})(global$1.EmberENV || global$1.ENV);
function getENV() {
return ENV;
}
exports.global = global$1;
exports.context = context;
exports.getLookup = getLookup;
exports.setLookup = setLookup;
exports.ENV = ENV;
exports.getENV = getENV;
});
enifed('@ember/-internals/utils', ['exports', '@ember/polyfills'], function (exports, _polyfills) {
'use strict';
exports.Cache = exports.setProxy = exports.isProxy = exports.HAS_NATIVE_PROXY = exports.HAS_NATIVE_SYMBOL = exports.toString = exports.setName = exports.getName = exports.makeArray = exports.tryInvoke = exports.canInvoke = exports.lookupDescriptor = exports.inspect = exports.setListeners = exports.setObservers = exports.getListeners = exports.getObservers = exports.wrap = exports.ROOT = exports.checkHasSuper = exports.intern = exports.guidFor = exports.generateGuid = exports.GUID_KEY = exports.uuid = exports.dictionary = exports.isInternalSymbol = exports.symbol = exports.NAME_KEY = undefined;
/**
Strongly hint runtimes to intern the provided string.
When do I need to use this function?
For the most part, never. Pre-mature optimization is bad, and often the
runtime does exactly what you need it to, and more often the trade-off isn't
worth it.
Why?
Runtimes store strings in at least 2 different representations:
Ropes and Symbols (interned strings). The Rope provides a memory efficient
data-structure for strings created from concatenation or some other string
manipulation like splitting.
Unfortunately checking equality of different ropes can be quite costly as
runtimes must resort to clever string comparison algorithms. These
algorithms typically cost in proportion to the length of the string.
Luckily, this is where the Symbols (interned strings) shine. As Symbols are
unique by their string content, equality checks can be done by pointer
comparison.
How do I know if my string is a rope or symbol?
Typically (warning general sweeping statement, but truthy in runtimes at
present) static strings created as part of the JS source are interned.
Strings often used for comparisons can be interned at runtime if some
criteria are met. One of these criteria can be the size of the entire rope.
For example, in chrome 38 a rope longer then 12 characters will not
intern, nor will segments of that rope.
Some numbers: http://jsperf.com/eval-vs-keys/8
Known Trick™
@private
@return {String} interned version of the provided string
*/
function intern(str) {
let obj = {};
obj[str] = 1;
for (let key in obj) {
if (key === str) {
return key;
}
}
return str;
}
/**
Returns whether Type(value) is Object.
Useful for checking whether a value is a valid WeakMap key.
Refs: https://tc39.github.io/ecma262/#sec-typeof-operator-runtime-semantics-evaluation
https://tc39.github.io/ecma262/#sec-weakmap.prototype.set
@private
@function isObject
*/
function isObject(value) {
return value !== null && (typeof value === 'object' || typeof value === 'function');
}
/**
@module @ember/object
*/
/**
Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from
jQuery master. We'll just bootstrap our own uuid now.
@private
@return {Number} the uuid
*/
let _uuid = 0;
/**
Generates a universally unique identifier. This method
is used internally by Ember for assisting with
the generation of GUID's and other unique identifiers.
@public
@return {Number} [description]
*/
function uuid() {
return ++_uuid;
}
/**
Prefix used for guids through out Ember.
@private
@property GUID_PREFIX
@for Ember
@type String
@final
*/
const GUID_PREFIX = 'ember';
// Used for guid generation...
const OBJECT_GUIDS = new WeakMap();
const NON_OBJECT_GUIDS = new Map();
/**
A unique key used to assign guids and other private metadata to objects.
If you inspect an object in your browser debugger you will often see these.
They can be safely ignored.
On browsers that support it, these properties are added with enumeration
disabled so they won't show up when you iterate over your properties.
@private
@property GUID_KEY
@for Ember
@type String
@final
*/
const GUID_KEY = intern(`__ember${+new Date()}`);
/**
Generates a new guid, optionally saving the guid to the object that you
pass in. You will rarely need to use this method. Instead you should
call `guidFor(obj)`, which return an existing guid if available.
@private
@method generateGuid
@static
@for @ember/object/internals
@param {Object} [obj] Object the guid will be used for. If passed in, the guid will
be saved on the object and reused whenever you pass the same object
again.
If no object is passed, just generate a new guid.
@param {String} [prefix] Prefix to place in front of the guid. Useful when you want to
separate the guid into separate namespaces.
@return {String} the guid
*/
function generateGuid(obj, prefix = GUID_PREFIX) {
let guid = prefix + uuid();
if (isObject(obj)) {
OBJECT_GUIDS.set(obj, guid);
}
return guid;
}
/**
Returns a unique id for the object. If the object does not yet have a guid,
one will be assigned to it. You can call this on any object,
`EmberObject`-based or not.
You can also use this method on DOM Element objects.
@public
@static
@method guidFor
@for @ember/object/internals
@param {Object} obj any object, string, number, Element, or primitive
@return {String} the unique guid for this instance.
*/
function guidFor(value) {
let guid;
if (isObject(value)) {
guid = OBJECT_GUIDS.get(value);
if (guid === undefined) {
guid = GUID_PREFIX + uuid();
OBJECT_GUIDS.set(value, guid);
}
} else {
guid = NON_OBJECT_GUIDS.get(value);
if (guid === undefined) {
let type = typeof value;
if (type === 'string') {
guid = 'st' + uuid();
} else if (type === 'number') {
guid = 'nu' + uuid();
} else if (type === 'symbol') {
guid = 'sy' + uuid();
} else {
guid = '(' + value + ')';
}
NON_OBJECT_GUIDS.set(value, guid);
}
}
return guid;
}
const GENERATED_SYMBOLS = [];
function isInternalSymbol(possibleSymbol) {
return GENERATED_SYMBOLS.indexOf(possibleSymbol) !== -1;
}
function symbol(debugName) {
// TODO: Investigate using platform symbols, but we do not
// want to require non-enumerability for this API, which
// would introduce a large cost.
let id = GUID_KEY + Math.floor(Math.random() * +new Date());
let symbol = intern(`__${debugName}${id}__`);
GENERATED_SYMBOLS.push(symbol);
return symbol;
}
// the delete is meant to hint at runtimes that this object should remain in
// dictionary mode. This is clearly a runtime specific hack, but currently it
// appears worthwhile in some usecases. Please note, these deletes do increase
// the cost of creation dramatically over a plain Object.create. And as this
// only makes sense for long-lived dictionaries that aren't instantiated often.
function makeDictionary(parent) {
let dict = Object.create(parent);
dict['_dict'] = null;
delete dict['_dict'];
return dict;
}
const HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/;
const fnToString = Function.prototype.toString;
const checkHasSuper = (() => {
let sourceAvailable = fnToString.call(function () {
return this;
}).indexOf('return this') > -1;
if (sourceAvailable) {
return function checkHasSuper(func) {
return HAS_SUPER_PATTERN.test(fnToString.call(func));
};
}
return function checkHasSuper() {
return true;
};
})();
const HAS_SUPER_MAP = new WeakMap();
const ROOT = Object.freeze(function () {});
HAS_SUPER_MAP.set(ROOT, false);
function hasSuper(func) {
let hasSuper = HAS_SUPER_MAP.get(func);
if (hasSuper === undefined) {
hasSuper = checkHasSuper(func);
HAS_SUPER_MAP.set(func, hasSuper);
}
return hasSuper;
}
const OBSERVERS_MAP = new WeakMap();
function setObservers(func, observers) {
if (observers) {
OBSERVERS_MAP.set(func, observers);
}
}
function getObservers(func) {
return OBSERVERS_MAP.get(func);
}
const LISTENERS_MAP = new WeakMap();
function setListeners(func, listeners) {
if (listeners) {
LISTENERS_MAP.set(func, listeners);
}
}
function getListeners(func) {
return LISTENERS_MAP.get(func);
}
const IS_WRAPPED_FUNCTION_SET = new _polyfills._WeakSet();
/**
Wraps the passed function so that `this._super` will point to the superFunc
when the function is invoked. This is the primitive we use to implement
calls to super.
@private
@method wrap
@for Ember
@param {Function} func The function to call
@param {Function} superFunc The super function.
@return {Function} wrapped function.
*/
function wrap(func, superFunc) {
if (!hasSuper(func)) {
return func;
}
// ensure an unwrapped super that calls _super is wrapped with a terminal _super
if (!IS_WRAPPED_FUNCTION_SET.has(superFunc) && hasSuper(superFunc)) {
return _wrap(func, _wrap(superFunc, ROOT));
}
return _wrap(func, superFunc);
}
function _wrap(func, superFunc) {
function superWrapper() {
let orig = this._super;
this._super = superFunc;
let ret = func.apply(this, arguments);
this._super = orig;
return ret;
}
IS_WRAPPED_FUNCTION_SET.add(superWrapper);
setObservers(superWrapper, getObservers(func));
setListeners(superWrapper, getListeners(func));
return superWrapper;
}
const { toString: objectToString } = Object.prototype;
const { toString: functionToString } = Function.prototype;
const { isArray } = Array;
const { keys: objectKeys } = Object;
const { stringify } = JSON;
const LIST_LIMIT = 100;
const DEPTH_LIMIT = 4;
const SAFE_KEY = /^[\w$]+$/;
/**
@module @ember/debug
*/
/**
Convenience method to inspect an object. This method will attempt to
convert the object into a useful string description.
It is a pretty simple implementation. If you want something more robust,
use something like JSDump: https://github.com/NV/jsDump
@method inspect
@static
@param {Object} obj The object you want to inspect.
@return {String} A description of the object
@since 1.4.0
@private
*/
function inspect(obj) {
// detect Node util.inspect call inspect(depth: number, opts: object)
if (typeof obj === 'number' && arguments.length === 2) {
return this;
}
return inspectValue(obj, 0);
}
function inspectValue(value, depth, seen) {
let valueIsArray = false;
switch (typeof value) {
case 'undefined':
return 'undefined';
case 'object':
if (value === null) return 'null';
if (isArray(value)) {
valueIsArray = true;
break;
}
// is toString Object.prototype.toString or undefined then traverse
if (value.toString === objectToString || value.toString === undefined) {
break;
}
// custom toString
return value.toString();
case 'function':
return value.toString === functionToString ? value.name ? `[Function:${value.name}]` : `[Function]` : value.toString();
case 'string':
return stringify(value);
case 'symbol':
case 'boolean':
case 'number':
default:
return value.toString();
}
if (seen === undefined) {
seen = new _polyfills._WeakSet();
} else {
if (seen.has(value)) return `[Circular]`;
}
seen.add(value);
return valueIsArray ? inspectArray(value, depth + 1, seen) : inspectObject(value, depth + 1, seen);
}
function inspectKey(key) {
return SAFE_KEY.test(key) ? key : stringify(key);
}
function inspectObject(obj, depth, seen) {
if (depth > DEPTH_LIMIT) {
return '[Object]';
}
let s = '{';
let keys = objectKeys(obj);
for (let i = 0; i < keys.length; i++) {
s += i === 0 ? ' ' : ', ';
if (i >= LIST_LIMIT) {
s += `... ${keys.length - LIST_LIMIT} more keys`;
break;
}
let key = keys[i];
s += inspectKey(key) + ': ' + inspectValue(obj[key], depth, seen);
}
s += ' }';
return s;
}
function inspectArray(arr, depth, seen) {
if (depth > DEPTH_LIMIT) {
return '[Array]';
}
let s = '[';
for (let i = 0; i < arr.length; i++) {
s += i === 0 ? ' ' : ', ';
if (i >= LIST_LIMIT) {
s += `... ${arr.length - LIST_LIMIT} more items`;
break;
}
s += inspectValue(arr[i], depth, seen);
}
s += ' ]';
return s;
}
function lookupDescriptor(obj, keyName) {
let current = obj;
do {
let descriptor = Object.getOwnPropertyDescriptor(current, keyName);
if (descriptor !== undefined) {
return descriptor;
}
current = Object.getPrototypeOf(current);
} while (current !== null);
return null;
}
/**
Checks to see if the `methodName` exists on the `obj`.
```javascript
let foo = { bar: function() { return 'bar'; }, baz: null };
Ember.canInvoke(foo, 'bar'); // true
Ember.canInvoke(foo, 'baz'); // false
Ember.canInvoke(foo, 'bat'); // false
```
@method canInvoke
@for Ember
@param {Object} obj The object to check for the method
@param {String} methodName The method name to check for
@return {Boolean}
@private
*/
function canInvoke(obj, methodName) {
return obj !== null && obj !== undefined && typeof obj[methodName] === 'function';
}
/**
@module @ember/utils
*/
/**
Checks to see if the `methodName` exists on the `obj`,
and if it does, invokes it with the arguments passed.
```javascript
import { tryInvoke } from '@ember/utils';
let d = new Date('03/15/2013');
tryInvoke(d, 'getTime'); // 1363320000000
tryInvoke(d, 'setFullYear', [2014]); // 1394856000000
tryInvoke(d, 'noSuchMethod', [2014]); // undefined
```
@method tryInvoke
@for @ember/utils
@static
@param {Object} obj The object to check for the method
@param {String} methodName The method name to check for
@param {Array} [args] The arguments to pass to the method
@return {*} the return value of the invoked method or undefined if it cannot be invoked
@public
*/
function tryInvoke(obj, methodName, args) {
if (canInvoke(obj, methodName)) {
let method = obj[methodName];
return method.apply(obj, args);
}
}
const { isArray: isArray$1 } = Array;
function makeArray(obj) {
if (obj === null || obj === undefined) {
return [];
}
return isArray$1(obj) ? obj : [obj];
}
const NAMES = new WeakMap();
function setName(obj, name) {
if (isObject(obj)) NAMES.set(obj, name);
}
function getName(obj) {
return NAMES.get(obj);
}
const objectToString$1 = Object.prototype.toString;
function isNone(obj) {
return obj === null || obj === undefined;
}
/*
A `toString` util function that supports objects without a `toString`
method, e.g. an object created with `Object.create(null)`.
*/
function toString(obj) {
if (typeof obj === 'string') {
return obj;
}
if (null === obj) return 'null';
if (undefined === obj) return 'undefined';
if (Array.isArray(obj)) {
// Reimplement Array.prototype.join according to spec (22.1.3.13)
// Changing ToString(element) with this safe version of ToString.
let r = '';
for (let k = 0; k < obj.length; k++) {
if (k > 0) {
r += ',';
}
if (!isNone(obj[k])) {
r += toString(obj[k]);
}
}
return r;
}
if (typeof obj.toString === 'function') {
return obj.toString();
}
return objectToString$1.call(obj);
}
const HAS_NATIVE_SYMBOL = function () {
if (typeof Symbol !== 'function') {
return false;
}
// use `Object`'s `.toString` directly to prevent us from detecting
// polyfills as native
return Object.prototype.toString.call(Symbol()) === '[object Symbol]';
}();
const HAS_NATIVE_PROXY = typeof Proxy === 'function';
const PROXIES = new _polyfills._WeakSet();
function isProxy(object) {
if (isObject(object)) {
return PROXIES.has(object);
}
return false;
}
function setProxy(object) {
if (isObject(object)) {
PROXIES.add(object);
}
}
class Cache {
constructor(limit, func, store) {
this.limit = limit;
this.func = func;
this.store = store;
this.size = 0;
this.misses = 0;
this.hits = 0;
this.store = store || new Map();
}
get(key) {
let value = this.store.get(key);
if (this.store.has(key)) {
this.hits++;
return this.store.get(key);
} else {
this.misses++;
value = this.set(key, this.func(key));
}
return value;
}
set(key, value) {
if (this.limit > this.size) {
this.size++;
this.store.set(key, value);
}
return value;
}
purge() {
this.store.clear();
this.size = 0;
this.hits = 0;
this.misses = 0;
}
}
/*
This package will be eagerly parsed and should have no dependencies on external
packages.
It is intended to be used to share utility methods that will be needed
by every Ember application (and is **not** a dumping ground of useful utilities).
Utility methods that are needed in < 80% of cases should be placed
elsewhere (so they can be lazily evaluated / parsed).
*/
const NAME_KEY = symbol('NAME_KEY');
exports.NAME_KEY = NAME_KEY;
exports.symbol = symbol;
exports.isInternalSymbol = isInternalSymbol;
exports.dictionary = makeDictionary;
exports.uuid = uuid;
exports.GUID_KEY = GUID_KEY;
exports.generateGuid = generateGuid;
exports.guidFor = guidFor;
exports.intern = intern;
exports.checkHasSuper = checkHasSuper;
exports.ROOT = ROOT;
exports.wrap = wrap;
exports.getObservers = getObservers;
exports.getListeners = getListeners;
exports.setObservers = setObservers;
exports.setListeners = setListeners;
exports.inspect = inspect;
exports.lookupDescriptor = lookupDescriptor;
exports.canInvoke = canInvoke;
exports.tryInvoke = tryInvoke;
exports.makeArray = makeArray;
exports.getName = getName;
exports.setName = setName;
exports.toString = toString;
exports.HAS_NATIVE_SYMBOL = HAS_NATIVE_SYMBOL;
exports.HAS_NATIVE_PROXY = HAS_NATIVE_PROXY;
exports.isProxy = isProxy;
exports.setProxy = setProxy;
exports.Cache = Cache;
});
enifed('@ember/canary-features/index', ['exports', '@ember/-internals/environment', '@ember/polyfills'], function (exports, _environment, _polyfills) {
'use strict';
exports.EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION = exports.EMBER_TEMPLATE_BLOCK_LET_HELPER = exports.GLIMMER_CUSTOM_COMPONENT_MANAGER = exports.EMBER_METAL_TRACKED_PROPERTIES = exports.EMBER_MODULE_UNIFICATION = exports.EMBER_ENGINES_MOUNT_PARAMS = exports.EMBER_ROUTING_ROUTER_SERVICE = exports.EMBER_GLIMMER_NAMED_ARGUMENTS = exports.EMBER_IMPROVED_INSTRUMENTATION = exports.EMBER_LIBRARIES_ISREGISTERED = exports.FEATURES = exports.DEFAULT_FEATURES = undefined;
exports.isEnabled = isEnabled;
/**
Set `EmberENV.FEATURES` in your application's `config/environment.js` file
to enable canary features in your application.
See the [feature flag guide](https://guides.emberjs.com/release/configuring-ember/feature-flags/)
for more details.
@module @ember/canary-features
@public
*/
const DEFAULT_FEATURES = exports.DEFAULT_FEATURES = {
EMBER_LIBRARIES_ISREGISTERED: false,
EMBER_IMPROVED_INSTRUMENTATION: false,
EMBER_GLIMMER_NAMED_ARGUMENTS: true,
EMBER_ROUTING_ROUTER_SERVICE: true,
EMBER_ENGINES_MOUNT_PARAMS: true,
EMBER_MODULE_UNIFICATION: false,
GLIMMER_CUSTOM_COMPONENT_MANAGER: true,
EMBER_TEMPLATE_BLOCK_LET_HELPER: true,
EMBER_METAL_TRACKED_PROPERTIES: false,
EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION: true
};
/**
The hash of enabled Canary features. Add to this, any canary features
before creating your application.
@class FEATURES
@static
@since 1.1.0
@public
*/
const FEATURES = exports.FEATURES = (0, _polyfills.assign)(DEFAULT_FEATURES, _environment.ENV.FEATURES);
/**
Determine whether the specified `feature` is enabled. Used by Ember's
build tools to exclude experimental features from beta/stable builds.
You can define the following configuration options:
* `EmberENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly
enabled/disabled.
@method isEnabled
@param {String} feature The feature to check
@return {Boolean}
@since 1.1.0
@public
*/
function isEnabled(feature) {
let featureValue = FEATURES[feature];
if (featureValue === true || featureValue === false) {
return featureValue;
} else if (_environment.ENV.ENABLE_OPTIONAL_FEATURES) {
return true;
} else {
return false;
}
}
function featureValue(value) {
if (_environment.ENV.ENABLE_OPTIONAL_FEATURES && value === null) {
return true;
}
return value;
}
const EMBER_LIBRARIES_ISREGISTERED = exports.EMBER_LIBRARIES_ISREGISTERED = featureValue(FEATURES.EMBER_LIBRARIES_ISREGISTERED);
const EMBER_IMPROVED_INSTRUMENTATION = exports.EMBER_IMPROVED_INSTRUMENTATION = featureValue(FEATURES.EMBER_IMPROVED_INSTRUMENTATION);
const EMBER_GLIMMER_NAMED_ARGUMENTS = exports.EMBER_GLIMMER_NAMED_ARGUMENTS = featureValue(FEATURES.EMBER_GLIMMER_NAMED_ARGUMENTS);
const EMBER_ROUTING_ROUTER_SERVICE = exports.EMBER_ROUTING_ROUTER_SERVICE = featureValue(FEATURES.EMBER_ROUTING_ROUTER_SERVICE);
const EMBER_ENGINES_MOUNT_PARAMS = exports.EMBER_ENGINES_MOUNT_PARAMS = featureValue(FEATURES.EMBER_ENGINES_MOUNT_PARAMS);
const EMBER_MODULE_UNIFICATION = exports.EMBER_MODULE_UNIFICATION = featureValue(FEATURES.EMBER_MODULE_UNIFICATION);
const EMBER_METAL_TRACKED_PROPERTIES = exports.EMBER_METAL_TRACKED_PROPERTIES = featureValue(FEATURES.EMBER_METAL_TRACKED_PROPERTIES);
const GLIMMER_CUSTOM_COMPONENT_MANAGER = exports.GLIMMER_CUSTOM_COMPONENT_MANAGER = featureValue(FEATURES.GLIMMER_CUSTOM_COMPONENT_MANAGER);
const EMBER_TEMPLATE_BLOCK_LET_HELPER = exports.EMBER_TEMPLATE_BLOCK_LET_HELPER = featureValue(FEATURES.EMBER_TEMPLATE_BLOCK_LET_HELPER);
const EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION = exports.EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION = featureValue(FEATURES.EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION);
});
enifed('@ember/debug/index', ['exports', '@ember/debug/lib/warn', '@ember/debug/lib/deprecate', '@ember/debug/lib/testing', '@ember/-internals/browser-environment', '@ember/error'], function (exports, _warn2, _deprecate2, _testing, _browserEnvironment, _error) {
'use strict';
exports._warnIfUsingStrippedFeatureFlags = exports.getDebugFunction = exports.setDebugFunction = exports.deprecateFunc = exports.runInDebug = exports.debugFreeze = exports.debugSeal = exports.deprecate = exports.debug = exports.warn = exports.info = exports.assert = exports.setTesting = exports.isTesting = exports.registerDeprecationHandler = exports.registerWarnHandler = undefined;
Object.defineProperty(exports, 'registerWarnHandler', {
enumerable: true,
get: function () {
return _warn2.registerHandler;
}
});
Object.defineProperty(exports, 'registerDeprecationHandler', {
enumerable: true,
get: function () {
return _deprecate2.registerHandler;
}
});
Object.defineProperty(exports, 'isTesting', {
enumerable: true,
get: function () {
return _testing.isTesting;
}
});
Object.defineProperty(exports, 'setTesting', {
enumerable: true,
get: function () {
return _testing.setTesting;
}
});
// These are the default production build versions:
const noop = () => {};
let assert = noop;
let info = noop;
let warn = noop;
let debug = noop;
let deprecate = noop;
let debugSeal = noop;
let debugFreeze = noop;
let runInDebug = noop;
let setDebugFunction = noop;
let getDebugFunction = noop;
let deprecateFunc = function () {
return arguments[arguments.length - 1];
};
if (true /* DEBUG */) {
exports.setDebugFunction = setDebugFunction = function (type, callback) {
switch (type) {
case 'assert':
return exports.assert = assert = callback;
case 'info':
return exports.info = info = callback;
case 'warn':
return exports.warn = warn = callback;
case 'debug':
return exports.debug = debug = callback;
case 'deprecate':
return exports.deprecate = deprecate = callback;
case 'debugSeal':
return exports.debugSeal = debugSeal = callback;
case 'debugFreeze':
return exports.debugFreeze = debugFreeze = callback;
case 'runInDebug':
return exports.runInDebug = runInDebug = callback;
case 'deprecateFunc':
return exports.deprecateFunc = deprecateFunc = callback;
}
};
exports.getDebugFunction = getDebugFunction = function (type) {
switch (type) {
case 'assert':
return assert;
case 'info':
return info;
case 'warn':
return warn;
case 'debug':
return debug;
case 'deprecate':
return deprecate;
case 'debugSeal':
return debugSeal;
case 'debugFreeze':
return debugFreeze;
case 'runInDebug':
return runInDebug;
case 'deprecateFunc':
return deprecateFunc;
}
};
}
/**
@module @ember/debug
*/
if (true /* DEBUG */) {
/**
Verify that a certain expectation is met, or throw a exception otherwise.
This is useful for communicating assumptions in the code to other human
readers as well as catching bugs that accidentally violates these
expectations.
Assertions are removed from production builds, so they can be freely added
for documentation and debugging purposes without worries of incuring any
performance penalty. However, because of that, they should not be used for
checks that could reasonably fail during normal usage. Furthermore, care
should be taken to avoid accidentally relying on side-effects produced from
evaluating the condition itself, since the code will not run in production.
```javascript
import { assert } from '@ember/debug';
// Test for truthiness
assert('Must pass a string', typeof str === 'string');
// Fail unconditionally
assert('This code path should never be run');
```
@method assert
@static
@for @ember/debug
@param {String} description Describes the expectation. This will become the
text of the Error thrown if the assertion fails.
@param {Boolean} condition Must be truthy for the assertion to pass. If
falsy, an exception will be thrown.
@public
@since 1.0.0
*/
setDebugFunction('assert', function assert(desc, test) {
if (!test) {
throw new _error.default(`Assertion Failed: ${desc}`);
}
});
/**
Display a debug notice.
Calls to this function are removed from production builds, so they can be
freely added for documentation and debugging purposes without worries of
incuring any performance penalty.
```javascript
import { debug } from '@ember/debug';
debug('I\'m a debug notice!');
```
@method debug
@for @ember/debug
@static
@param {String} message A debug message to display.
@public
*/
setDebugFunction('debug', function debug(message) {
/* eslint-disable no-console */
if (console.debug) {
console.debug(`DEBUG: ${message}`);
} else {
console.log(`DEBUG: ${message}`);
}
/* eslint-ensable no-console */
});
/**
Display an info notice.
Calls to this function are removed from production builds, so they can be
freely added for documentation and debugging purposes without worries of
incuring any performance penalty.
@method info
@private
*/
setDebugFunction('info', function info() {
console.info(...arguments); /* eslint-disable-line no-console */
});
/**
@module @ember/application
@public
*/
/**
Alias an old, deprecated method with its new counterpart.
Display a deprecation warning with the provided message and a stack trace
(Chrome and Firefox only) when the assigned method is called.
Calls to this function are removed from production builds, so they can be
freely added for documentation and debugging purposes without worries of
incuring any performance penalty.
```javascript
import { deprecateFunc } from '@ember/application/deprecations';
Ember.oldMethod = deprecateFunc('Please use the new, updated method', options, Ember.newMethod);
```
@method deprecateFunc
@static
@for @ember/application/deprecations
@param {String} message A description of the deprecation.
@param {Object} [options] The options object for `deprecate`.
@param {Function} func The new function called to replace its deprecated counterpart.
@return {Function} A new function that wraps the original function with a deprecation warning
@private
*/
setDebugFunction('deprecateFunc', function deprecateFunc(...args) {
if (args.length === 3) {
let [message, options, func] = args;
return function () {
deprecate(message, false, options);
return func.apply(this, arguments);
};
} else {
let [message, func] = args;
return function () {
deprecate(message);
return func.apply(this, arguments);
};
}
});
/**
@module @ember/debug
@public
*/
/**
Run a function meant for debugging.
Calls to this function are removed from production builds, so they can be
freely added for documentation and debugging purposes without worries of
incuring any performance penalty.
```javascript
import Component from '@ember/component';
import { runInDebug } from '@ember/debug';
runInDebug(() => {
Component.reopen({
didInsertElement() {
console.log("I'm happy");
}
});
});
```
@method runInDebug
@for @ember/debug
@static
@param {Function} func The function to be executed.
@since 1.5.0
@public
*/
setDebugFunction('runInDebug', function runInDebug(func) {
func();
});
setDebugFunction('debugSeal', function debugSeal(obj) {
Object.seal(obj);
});
setDebugFunction('debugFreeze', function debugFreeze(obj) {
Object.freeze(obj);
});
setDebugFunction('deprecate', _deprecate2.default);
setDebugFunction('warn', _warn2.default);
}
let _warnIfUsingStrippedFeatureFlags;
if (true /* DEBUG */ && !(0, _testing.isTesting)()) {
if (typeof window !== 'undefined' && (_browserEnvironment.isFirefox || _browserEnvironment.isChrome) && window.addEventListener) {
window.addEventListener('load', () => {
if (document.documentElement && document.documentElement.dataset && !document.documentElement.dataset.emberExtension) {
let downloadURL;
if (_browserEnvironment.isChrome) {
downloadURL = 'https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi';
} else if (_browserEnvironment.isFirefox) {
downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/';
}
debug(`For more advanced debugging, install the Ember Inspector from ${downloadURL}`);
}
}, false);
}
}
exports.assert = assert;
exports.info = info;
exports.warn = warn;
exports.debug = debug;
exports.deprecate = deprecate;
exports.debugSeal = debugSeal;
exports.debugFreeze = debugFreeze;
exports.runInDebug = runInDebug;
exports.deprecateFunc = deprecateFunc;
exports.setDebugFunction = setDebugFunction;
exports.getDebugFunction = getDebugFunction;
exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags;
});
enifed('@ember/debug/lib/deprecate', ['exports', '@ember/-internals/environment', '@ember/debug/index', '@ember/debug/lib/handlers'], function (exports, _environment, _index, _handlers) {
'use strict';
exports.missingOptionsUntilDeprecation = exports.missingOptionsIdDeprecation = exports.missingOptionsDeprecation = exports.registerHandler = undefined;
/**
@module @ember/debug
@public
*/
/**
Allows for runtime registration of handler functions that override the default deprecation behavior.
Deprecations are invoked by calls to [@ember/application/deprecations/deprecate](https://emberjs.com/api/ember/release/classes/@ember%2Fapplication%2Fdeprecations/methods/deprecate?anchor=deprecate).
The following example demonstrates its usage by registering a handler that throws an error if the
message contains the word "should", otherwise defers to the default handler.
```javascript
import { registerDeprecationHandler } from '@ember/debug';
registerDeprecationHandler((message, options, next) => {
if (message.indexOf('should') !== -1) {
throw new Error(`Deprecation message with should: ${message}`);
} else {
// defer to whatever handler was registered before this one
next(message, options);
}
});
```
The handler function takes the following arguments:
message - The message received from the deprecation call.
options - An object passed in with the deprecation call containing additional information including:
id - An id of the deprecation in the form of package-name.specific-deprecation.
until - The Ember version number the feature and deprecation will be removed in.
next - A function that calls into the previously registered handler.
@public
@static
@method registerDeprecationHandler
@for @ember/debug
@param handler {Function} A function to handle deprecation calls.
@since 2.1.0
*/
let registerHandler = () => {};
let missingOptionsDeprecation;
let missingOptionsIdDeprecation;
let missingOptionsUntilDeprecation;
let deprecate = () => {};
if (true /* DEBUG */) {
exports.registerHandler = registerHandler = function registerHandler(handler) {
(0, _handlers.registerHandler)('deprecate', handler);
};
let formatMessage = function formatMessage(_message, options) {
let message = _message;
if (options && options.id) {
message = message + ` [deprecation id: ${options.id}]`;
}
if (options && options.url) {
message += ` See ${options.url} for more details.`;
}
return message;
};
registerHandler(function logDeprecationToConsole(message, options) {
let updatedMessage = formatMessage(message, options);
console.warn(`DEPRECATION: ${updatedMessage}`); // eslint-disable-line no-console
});
let captureErrorForStack;
if (new Error().stack) {
captureErrorForStack = () => new Error();
} else {
captureErrorForStack = () => {
try {
__fail__.fail();
} catch (e) {
return e;
}
};
}
registerHandler(function logDeprecationStackTrace(message, options, next) {
if (_environment.ENV.LOG_STACKTRACE_ON_DEPRECATION) {
let stackStr = '';
let error = captureErrorForStack();
let stack;
if (error.stack) {
if (error['arguments']) {
// Chrome
stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n');
stack.shift();
} else {
// Firefox
stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n');
}
stackStr = `\n ${stack.slice(2).join('\n ')}`;
}
let updatedMessage = formatMessage(message, options);
console.warn(`DEPRECATION: ${updatedMessage}${stackStr}`); // eslint-disable-line no-console
} else {
next(message, options);
}
});
registerHandler(function raiseOnDeprecation(message, options, next) {
if (_environment.ENV.RAISE_ON_DEPRECATION) {
let updatedMessage = formatMessage(message);
throw new Error(updatedMessage);
} else {
next(message, options);
}
});
exports.missingOptionsDeprecation = missingOptionsDeprecation = 'When calling `deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.';
exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation = 'When calling `deprecate` you must provide `id` in options.';
exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation = 'When calling `deprecate` you must provide `until` in options.';
/**
@module @ember/application
@public
*/
/**
Display a deprecation warning with the provided message and a stack trace
(Chrome and Firefox only).
* In a production build, this method is defined as an empty function (NOP).
Uses of this method in Ember itself are stripped from the ember.prod.js build.
@method deprecate
@for @ember/application/deprecations
@param {String} message A description of the deprecation.
@param {Boolean} test A boolean. If falsy, the deprecation will be displayed.
@param {Object} options
@param {String} options.id A unique id for this deprecation. The id can be
used by Ember debugging tools to change the behavior (raise, log or silence)
for that specific deprecation. The id should be namespaced by dots, e.g.
"view.helper.select".
@param {string} options.until The version of Ember when this deprecation
warning will be removed.
@param {String} [options.url] An optional url to the transition guide on the
emberjs.com website.
@static
@public
@since 1.0.0
*/
deprecate = function deprecate(message, test, options) {
(0, _index.assert)(missingOptionsDeprecation, !!(options && (options.id || options.until)));
(0, _index.assert)(missingOptionsIdDeprecation, !!options.id);
(0, _index.assert)(missingOptionsUntilDeprecation, !!options.until);
(0, _handlers.invoke)('deprecate', message, test, options);
};
}
exports.default = deprecate;
exports.registerHandler = registerHandler;
exports.missingOptionsDeprecation = missingOptionsDeprecation;
exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation;
exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation;
});
enifed("@ember/debug/lib/handlers", ["exports"], function (exports) {
"use strict";
let HANDLERS = exports.HANDLERS = {};
let registerHandler = () => {};
let invoke = () => {};
if (true /* DEBUG */) {
exports.registerHandler = registerHandler = function registerHandler(type, callback) {
let nextHandler = HANDLERS[type] || (() => {});
HANDLERS[type] = (message, options) => {
callback(message, options, nextHandler);
};
};
exports.invoke = invoke = function invoke(type, message, test, options) {
if (test) {
return;
}
let handlerForType = HANDLERS[type];
if (handlerForType) {
handlerForType(message, options);
}
};
}
exports.registerHandler = registerHandler;
exports.invoke = invoke;
});
enifed("@ember/debug/lib/testing", ["exports"], function (exports) {
"use strict";
exports.isTesting = isTesting;
exports.setTesting = setTesting;
let testing = false;
function isTesting() {
return testing;
}
function setTesting(value) {
testing = !!value;
}
});
enifed('@ember/debug/lib/warn', ['exports', '@ember/debug/index', '@ember/debug/lib/handlers'], function (exports, _index, _handlers) {
'use strict';
exports.missingOptionsDeprecation = exports.missingOptionsIdDeprecation = exports.registerHandler = undefined;
let registerHandler = () => {};
let warn = () => {};
let missingOptionsDeprecation;
let missingOptionsIdDeprecation;
/**
@module @ember/debug
*/
if (true /* DEBUG */) {
/**
Allows for runtime registration of handler functions that override the default warning behavior.
Warnings are invoked by calls made to [@ember/debug/warn](https://emberjs.com/api/ember/release/classes/@ember%2Fdebug/methods/warn?anchor=warn).
The following example demonstrates its usage by registering a handler that does nothing overriding Ember's
default warning behavior.
```javascript
import { registerWarnHandler } from '@ember/debug';
// next is not called, so no warnings get the default behavior
registerWarnHandler(() => {});
```
The handler function takes the following arguments:
message - The message received from the warn call.
options - An object passed in with the warn call containing additional information including:
id - An id of the warning in the form of package-name.specific-warning.
next - A function that calls into the previously registered handler.
@public
@static
@method registerWarnHandler
@for @ember/debug
@param handler {Function} A function to handle warnings.
@since 2.1.0
*/
exports.registerHandler = registerHandler = function registerHandler(handler) {
(0, _handlers.registerHandler)('warn', handler);
};
registerHandler(function logWarning(message) {
/* eslint-disable no-console */
console.warn(`WARNING: ${message}`);
if (console.trace) {
console.trace();
}
/* eslint-enable no-console */
});
exports.missingOptionsDeprecation = missingOptionsDeprecation = 'When calling `warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.';
exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation = 'When calling `warn` you must provide `id` in options.';
/**
Display a warning with the provided message.
* In a production build, this method is defined as an empty function (NOP).
Uses of this method in Ember itself are stripped from the ember.prod.js build.
```javascript
import { warn } from '@ember/debug';
import tomsterCount from './tomster-counter'; // a module in my project
// Log a warning if we have more than 3 tomsters
warn('Too many tomsters!', tomsterCount <= 3, {
id: 'ember-debug.too-many-tomsters'
});
```
@method warn
@for @ember/debug
@static
@param {String} message A warning to display.
@param {Boolean} test An optional boolean. If falsy, the warning
will be displayed.
@param {Object} options An object that can be used to pass a unique
`id` for this warning. The `id` can be used by Ember debugging tools
to change the behavior (raise, log, or silence) for that specific warning.
The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped"
@public
@since 1.0.0
*/
warn = function warn(message, test, options) {
if (arguments.length === 2 && typeof test === 'object') {
options = test;
test = false;
}
(0, _index.assert)(missingOptionsDeprecation, !!options);
(0, _index.assert)(missingOptionsIdDeprecation, !!(options && options.id));
(0, _handlers.invoke)('warn', message, test, options);
};
}
exports.default = warn;
exports.registerHandler = registerHandler;
exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation;
exports.missingOptionsDeprecation = missingOptionsDeprecation;
});
enifed('@ember/deprecated-features/index', ['exports'], function (exports) {
'use strict';
const SEND_ACTION = exports.SEND_ACTION = !!'3.4.0';
const EMBER_EXTEND_PROTOTYPES = exports.EMBER_EXTEND_PROTOTYPES = !!'3.2.0-beta.5';
const RUN_SYNC = exports.RUN_SYNC = !!'3.0.0-beta.4';
const LOGGER = exports.LOGGER = !!'3.2.0-beta.1';
const POSITIONAL_PARAM_CONFLICT = exports.POSITIONAL_PARAM_CONFLICT = !!'3.1.0-beta.1';
const PROPERTY_WILL_CHANGE = exports.PROPERTY_WILL_CHANGE = !!'3.1.0-beta.1';
const PROPERTY_DID_CHANGE = exports.PROPERTY_DID_CHANGE = !!'3.1.0-beta.1';
const ROUTER_ROUTER = exports.ROUTER_ROUTER = !!'3.2.0-beta.1';
const ARRAY_AT_EACH = exports.ARRAY_AT_EACH = !!'3.1.0-beta.1';
const TARGET_OBJECT = exports.TARGET_OBJECT = !!'2.18.0-beta.1';
const MAP = exports.MAP = !!'3.3.0-beta.1';
const ORDERED_SET = exports.ORDERED_SET = !!'3.3.0-beta.1';
const MERGE = exports.MERGE = !!'3.6.0-beta.1';
const HANDLER_INFOS = exports.HANDLER_INFOS = !!'3.9.0';
const ROUTER_EVENTS = exports.ROUTER_EVENTS = !!'3.9.0';
const TRANSITION_STATE = exports.TRANSITION_STATE = !!'3.9.0';
});
enifed("@ember/error/index", ["exports"], function (exports) {
"use strict";
exports.default = EmberError;
/**
A subclass of the JavaScript Error object for use in Ember.
@class Error
@namespace Ember
@extends Error
@constructor
@public
*/
function EmberError(message) {
if (!(this instanceof EmberError)) {
return new EmberError(message);
}
let error = Error.call(this, message);
this.stack = error.stack;
this.description = error.description;
this.fileName = error.fileName;
this.lineNumber = error.lineNumber;
this.message = error.message;
this.name = error.name;
this.number = error.number;
this.code = error.code;
}
EmberError.prototype = Object.create(Error.prototype);
EmberError.prototype.constructor = EmberError;
});
enifed('@ember/polyfills/index', ['exports', '@ember/polyfills/lib/assign', '@ember/polyfills/lib/weak_set', '@ember/deprecated-features', '@ember/polyfills/lib/merge'], function (exports, _assign, _weak_set, _deprecatedFeatures, _merge) {
'use strict';
exports.merge = exports._WeakSet = exports.assignPolyfill = exports.assign = undefined;
Object.defineProperty(exports, 'assign', {
enumerable: true,
get: function () {
return _assign.default;
}
});
Object.defineProperty(exports, 'assignPolyfill', {
enumerable: true,
get: function () {
return _assign.assign;
}
});
Object.defineProperty(exports, '_WeakSet', {
enumerable: true,
get: function () {
return _weak_set.default;
}
});
let merge = _deprecatedFeatures.MERGE ? _merge.default : undefined;
// Export `assignPolyfill` for testing
exports.merge = merge;
});
enifed("@ember/polyfills/lib/assign", ["exports"], function (exports) {
"use strict";
exports.assign = assign;
/**
@module @ember/polyfills
*/
/**
Copy properties from a source object to a target object.
```javascript
import { assign } from '@ember/polyfills';
var a = { first: 'Yehuda' };
var b = { last: 'Katz' };
var c = { company: 'Tilde Inc.' };
assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' }
```
@method assign
@for @ember/polyfills
@param {Object} target The object to assign into
@param {Object} ...args The objects to copy properties from
@return {Object}
@public
@static
*/
function assign(target) {
for (let i = 1; i < arguments.length; i++) {
let arg = arguments[i];
if (!arg) {
continue;
}
let updates = Object.keys(arg);
for (let i = 0; i < updates.length; i++) {
let prop = updates[i];
target[prop] = arg[prop];
}
}
return target;
}
// Note: We use the bracket notation so
// that the babel plugin does not
// transform it.
// https://www.npmjs.com/package/babel-plugin-transform-object-assign
const { assign: _assign } = Object;
exports.default = _assign || assign;
});
enifed('@ember/polyfills/lib/merge', ['exports', '@ember/debug'], function (exports, _debug) {
'use strict';
exports.default = merge;
/**
Merge the contents of two objects together into the first object.
```javascript
import { merge } from '@ember/polyfills';
merge({ first: 'Tom' }, { last: 'Dale' }); // { first: 'Tom', last: 'Dale' }
var a = { first: 'Yehuda' };
var b = { last: 'Katz' };
merge(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' }
```
@method merge
@static
@for @ember/polyfills
@param {Object} original The object to merge into
@param {Object} updates The object to copy properties from
@return {Object}
@public
*/
function merge(original, updates) {
true && !false && (0, _debug.deprecate)('Use of `merge` has been deprecated. Please use `assign` instead.', false, {
id: 'ember-polyfills.deprecate-merge',
until: '4.0.0',
url: 'https://emberjs.com/deprecations/v3.x/#toc_ember-polyfills-deprecate-merge'
});
if (updates === null || typeof updates !== 'object') {
return original;
}
let props = Object.keys(updates);
let prop;
for (let i = 0; i < props.length; i++) {
prop = props[i];
original[prop] = updates[prop];
}
return original;
}
});
enifed('@ember/polyfills/lib/weak_set', ['exports'], function (exports) {
'use strict';
exports.default = typeof WeakSet === 'function' ? WeakSet : class WeakSetPolyFill {
constructor() {
this._map = new WeakMap();
}
add(val) {
this._map.set(val, true);
return this;
}
delete(val) {
return this._map.delete(val);
}
has(val) {
return this._map.has(val);
}
};
});
enifed('@glimmer/compiler', ['exports', 'node-module', '@glimmer/util', '@glimmer/wire-format', '@glimmer/syntax'], function (exports, _nodeModule, _util, _wireFormat, _syntax) {
'use strict';
exports.TemplateVisitor = exports.TemplateCompiler = exports.precompile = exports.defaultId = undefined;
class SymbolTable {
static top() {
return new ProgramSymbolTable();
}
child(locals) {
let symbols = locals.map(name => this.allocate(name));
return new BlockSymbolTable(this, locals, symbols);
}
}
class ProgramSymbolTable extends SymbolTable {
constructor() {
super(...arguments);
this.symbols = [];
this.size = 1;
this.named = (0, _util.dict)();
this.blocks = (0, _util.dict)();
}
has(_name) {
return false;
}
get(_name) {
throw (0, _util.unreachable)();
}
getLocalsMap() {
return {};
}
getEvalInfo() {
return [];
}
allocateNamed(name) {
let named = this.named[name];
if (!named) {
named = this.named[name] = this.allocate(name);
}
return named;
}
allocateBlock(name) {
let block = this.blocks[name];
if (!block) {
block = this.blocks[name] = this.allocate(`&${name}`);
}
return block;
}
allocate(identifier) {
this.symbols.push(identifier);
return this.size++;
}
}
class BlockSymbolTable extends SymbolTable {
constructor(parent, symbols, slots) {
super();
this.parent = parent;
this.symbols = symbols;
this.slots = slots;
}
has(name) {
return this.symbols.indexOf(name) !== -1 || this.parent.has(name);
}
get(name) {
let slot = this.symbols.indexOf(name);
return slot === -1 ? this.parent.get(name) : this.slots[slot];
}
getLocalsMap() {
let dict$$1 = this.parent.getLocalsMap();
this.symbols.forEach(symbol => dict$$1[symbol] = this.get(symbol));
return dict$$1;
}
getEvalInfo() {
let locals = this.getLocalsMap();
return Object.keys(locals).map(symbol => locals[symbol]);
}
allocateNamed(name) {
return this.parent.allocateNamed(name);
}
allocateBlock(name) {
return this.parent.allocateBlock(name);
}
allocate(identifier) {
return this.parent.allocate(identifier);
}
}
/**
* Takes in an AST and outputs a list of actions to be consumed
* by a compiler. For example, the template
*
* foo{{bar}}
baz
*
* produces the actions
*
* [['startProgram', [programNode, 0]],
* ['text', [textNode, 0, 3]],
* ['mustache', [mustacheNode, 1, 3]],
* ['openElement', [elementNode, 2, 3, 0]],
* ['text', [textNode, 0, 1]],
* ['closeElement', [elementNode, 2, 3],
* ['endProgram', [programNode]]]
*
* This visitor walks the AST depth first and backwards. As
* a result the bottom-most child template will appear at the
* top of the actions list whereas the root template will appear
* at the bottom of the list. For example,
*
*
{{#if}}foo{{else}}bar{{/if}}
*
* produces the actions
*
* [['startProgram', [programNode, 0]],
* ['text', [textNode, 0, 2, 0]],
* ['openElement', [elementNode, 1, 2, 0]],
* ['closeElement', [elementNode, 1, 2]],
* ['endProgram', [programNode]],
* ['startProgram', [programNode, 0]],
* ['text', [textNode, 0, 1]],
* ['endProgram', [programNode]],
* ['startProgram', [programNode, 2]],
* ['openElement', [elementNode, 0, 1, 1]],
* ['block', [blockNode, 0, 1]],
* ['closeElement', [elementNode, 0, 1]],
* ['endProgram', [programNode]]]
*
* The state of the traversal is maintained by a stack of frames.
* Whenever a node with children is entered (either a ProgramNode
* or an ElementNode) a frame is pushed onto the stack. The frame
* contains information about the state of the traversal of that
* node. For example,
*
* - index of the current child node being visited
* - the number of mustaches contained within its child nodes
* - the list of actions generated by its child nodes
*/
class Frame {
constructor() {
this.parentNode = null;
this.children = null;
this.childIndex = null;
this.childCount = null;
this.childTemplateCount = 0;
this.mustacheCount = 0;
this.actions = [];
this.blankChildTextNodes = null;
this.symbols = null;
}
}
class TemplateVisitor {
constructor() {
this.frameStack = [];
this.actions = [];
this.programDepth = -1;
}
visit(node) {
this[node.type](node);
}
// Traversal methods
Program(program) {
this.programDepth++;
let parentFrame = this.getCurrentFrame();
let programFrame = this.pushFrame();
if (!parentFrame) {
program['symbols'] = SymbolTable.top();
} else {
program['symbols'] = parentFrame.symbols.child(program.blockParams);
}
let startType, endType;
if (this.programDepth === 0) {
startType = 'startProgram';
endType = 'endProgram';
} else {
startType = 'startBlock';
endType = 'endBlock';
}
programFrame.parentNode = program;
programFrame.children = program.body;
programFrame.childCount = program.body.length;
programFrame.blankChildTextNodes = [];
programFrame.actions.push([endType, [program, this.programDepth]]);
programFrame.symbols = program['symbols'];
for (let i = program.body.length - 1; i >= 0; i--) {
programFrame.childIndex = i;
this.visit(program.body[i]);
}
programFrame.actions.push([startType, [program, programFrame.childTemplateCount, programFrame.blankChildTextNodes.reverse()]]);
this.popFrame();
this.programDepth--;
// Push the completed template into the global actions list
if (parentFrame) {
parentFrame.childTemplateCount++;
}
this.actions.push(...programFrame.actions.reverse());
}
ElementNode(element) {
let parentFrame = this.currentFrame;
let elementFrame = this.pushFrame();
elementFrame.parentNode = element;
elementFrame.children = element.children;
elementFrame.childCount = element.children.length;
elementFrame.mustacheCount += element.modifiers.length;
elementFrame.blankChildTextNodes = [];
elementFrame.symbols = element['symbols'] = parentFrame.symbols.child(element.blockParams);
let actionArgs = [element, parentFrame.childIndex, parentFrame.childCount];
elementFrame.actions.push(['closeElement', actionArgs]);
for (let i = element.attributes.length - 1; i >= 0; i--) {
this.visit(element.attributes[i]);
}
for (let i = element.children.length - 1; i >= 0; i--) {
elementFrame.childIndex = i;
this.visit(element.children[i]);
}
let open = ['openElement', [...actionArgs, elementFrame.mustacheCount, elementFrame.blankChildTextNodes.reverse()]];
elementFrame.actions.push(open);
this.popFrame();
// Propagate the element's frame state to the parent frame
if (elementFrame.mustacheCount > 0) {
parentFrame.mustacheCount++;
}
parentFrame.childTemplateCount += elementFrame.childTemplateCount;
parentFrame.actions.push(...elementFrame.actions);
}
AttrNode(attr) {
if (attr.value.type !== 'TextNode') {
this.currentFrame.mustacheCount++;
}
}
TextNode(text) {
let frame = this.currentFrame;
if (text.chars === '') {
frame.blankChildTextNodes.push(domIndexOf(frame.children, text));
}
frame.actions.push(['text', [text, frame.childIndex, frame.childCount]]);
}
BlockStatement(node) {
let frame = this.currentFrame;
frame.mustacheCount++;
frame.actions.push(['block', [node, frame.childIndex, frame.childCount]]);
if (node.inverse) {
this.visit(node.inverse);
}
if (node.program) {
this.visit(node.program);
}
}
PartialStatement(node) {
let frame = this.currentFrame;
frame.mustacheCount++;
frame.actions.push(['mustache', [node, frame.childIndex, frame.childCount]]);
}
CommentStatement(text) {
let frame = this.currentFrame;
frame.actions.push(['comment', [text, frame.childIndex, frame.childCount]]);
}
MustacheCommentStatement() {
// Intentional empty: Handlebars comments should not affect output.
}
MustacheStatement(mustache) {
let frame = this.currentFrame;
frame.mustacheCount++;
frame.actions.push(['mustache', [mustache, frame.childIndex, frame.childCount]]);
}
// Frame helpers
get currentFrame() {
return this.getCurrentFrame();
}
getCurrentFrame() {
return this.frameStack[this.frameStack.length - 1];
}
pushFrame() {
let frame = new Frame();
this.frameStack.push(frame);
return frame;
}
popFrame() {
return this.frameStack.pop();
}
}
// Returns the index of `domNode` in the `nodes` array, skipping
// over any nodes which do not represent DOM nodes.
function domIndexOf(nodes, domNode) {
let index = -1;
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i];
if (node.type !== 'TextNode' && node.type !== 'ElementNode') {
continue;
} else {
index++;
}
if (node === domNode) {
return index;
}
}
return -1;
}
class Block {
constructor() {
this.statements = [];
}
push(statement) {
this.statements.push(statement);
}
}
class InlineBlock extends Block {
constructor(table) {
super();
this.table = table;
}
toJSON() {
return {
statements: this.statements,
parameters: this.table.slots
};
}
}
class TemplateBlock extends Block {
constructor(symbolTable) {
super();
this.symbolTable = symbolTable;
this.type = 'template';
this.yields = new _util.DictSet();
this.named = new _util.DictSet();
this.blocks = [];
this.hasEval = false;
}
push(statement) {
this.statements.push(statement);
}
toJSON() {
return {
symbols: this.symbolTable.symbols,
statements: this.statements,
hasEval: this.hasEval
};
}
}
class ComponentBlock extends Block {
constructor(tag, table, selfClosing) {
super();
this.tag = tag;
this.table = table;
this.selfClosing = selfClosing;
this.attributes = [];
this.arguments = [];
this.inParams = true;
this.positionals = [];
}
push(statement) {
if (this.inParams) {
if ((0, _wireFormat.isFlushElement)(statement)) {
this.inParams = false;
} else if ((0, _wireFormat.isArgument)(statement)) {
this.arguments.push(statement);
} else if ((0, _wireFormat.isAttribute)(statement)) {
this.attributes.push(statement);
} else if ((0, _wireFormat.isAttrSplat)(statement)) {
this.attributes.push(statement);
} else {
throw new Error('Compile Error: only parameters allowed before flush-element');
}
} else {
this.statements.push(statement);
}
}
toJSON() {
let args = this.arguments;
let keys = args.map(arg => arg[1]);
let values = args.map(arg => arg[2]);
let block = this.selfClosing ? null : {
statements: this.statements,
parameters: this.table.slots
};
return [this.tag, this.attributes, [keys, values], block];
}
}
class Template {
constructor(symbols) {
this.block = new TemplateBlock(symbols);
}
toJSON() {
return this.block.toJSON();
}
}
class JavaScriptCompiler {
constructor(opcodes, symbols, options) {
this.blocks = new _util.Stack();
this.values = [];
this.opcodes = opcodes;
this.template = new Template(symbols);
this.options = options;
}
static process(opcodes, symbols, options) {
let compiler = new JavaScriptCompiler(opcodes, symbols, options);
return compiler.process();
}
get currentBlock() {
return this.blocks.current;
}
process() {
this.opcodes.forEach(op => {
let opcode = op[0];
let arg = op[1];
if (!this[opcode]) {
throw new Error(`unimplemented ${opcode} on JavaScriptCompiler`);
}
this[opcode](arg);
});
return this.template;
}
/// Nesting
startBlock(program) {
let block = new InlineBlock(program['symbols']);
this.blocks.push(block);
}
endBlock() {
let { template, blocks } = this;
let block = blocks.pop();
template.block.blocks.push(block.toJSON());
}
startProgram() {
this.blocks.push(this.template.block);
}
endProgram() {}
/// Statements
text(content) {
this.push([_wireFormat.Ops.Text, content]);
}
append(trusted) {
this.push([_wireFormat.Ops.Append, this.popValue(), trusted]);
}
comment(value) {
this.push([_wireFormat.Ops.Comment, value]);
}
modifier(name) {
let params = this.popValue();
let hash = this.popValue();
this.push([_wireFormat.Ops.Modifier, name, params, hash]);
}
block([name, template, inverse]) {
let params = this.popValue();
let hash = this.popValue();
let blocks = this.template.block.blocks;
this.push([_wireFormat.Ops.Block, name, params, hash, blocks[template], blocks[inverse]]);
}
openComponent(element) {
let tag = this.options && this.options.customizeComponentName ? this.options.customizeComponentName(element.tag) : element.tag;
let component = new ComponentBlock(tag, element['symbols'], element.selfClosing);
this.blocks.push(component);
}
openSplattedElement(element) {
let tag = element.tag;
if (element.blockParams.length > 0) {
throw new Error(`Compile Error: <${element.tag}> is not a component and doesn't support block parameters`);
} else {
this.push([_wireFormat.Ops.OpenSplattedElement, tag]);
}
}
openElement(element) {
let tag = element.tag;
if (element.blockParams.length > 0) {
throw new Error(`Compile Error: <${element.tag}> is not a component and doesn't support block parameters`);
} else {
this.push([_wireFormat.Ops.OpenElement, tag]);
}
}
flushElement() {
this.push([_wireFormat.Ops.FlushElement]);
}
closeComponent(_element) {
if (_element.modifiers.length > 0) {
throw new Error('Compile Error: Element modifiers are not allowed in components');
}
let [tag, attrs, args, block] = this.endComponent();
this.push([_wireFormat.Ops.Component, tag, attrs, args, block]);
}
closeDynamicComponent(_element) {
let [, attrs, args, block] = this.endComponent();
this.push([_wireFormat.Ops.DynamicComponent, this.popValue(), attrs, args, block]);
}
closeElement(_element) {
this.push([_wireFormat.Ops.CloseElement]);
}
staticAttr([name, namespace]) {
let value = this.popValue();
this.push([_wireFormat.Ops.StaticAttr, name, value, namespace]);
}
dynamicAttr([name, namespace]) {
let value = this.popValue();
this.push([_wireFormat.Ops.DynamicAttr, name, value, namespace]);
}
trustingAttr([name, namespace]) {
let value = this.popValue();
this.push([_wireFormat.Ops.TrustingAttr, name, value, namespace]);
}
staticArg(name) {
let value = this.popValue();
this.push([_wireFormat.Ops.StaticArg, name, value]);
}
dynamicArg(name) {
let value = this.popValue();
this.push([_wireFormat.Ops.DynamicArg, name, value]);
}
yield(to) {
let params = this.popValue();
this.push([_wireFormat.Ops.Yield, to, params]);
}
attrSplat(to) {
this.push([_wireFormat.Ops.AttrSplat, to]);
}
debugger(evalInfo) {
this.push([_wireFormat.Ops.Debugger, evalInfo]);
this.template.block.hasEval = true;
}
hasBlock(name) {
this.pushValue([_wireFormat.Ops.HasBlock, name]);
}
hasBlockParams(name) {
this.pushValue([_wireFormat.Ops.HasBlockParams, name]);
}
partial(evalInfo) {
let params = this.popValue();
this.push([_wireFormat.Ops.Partial, params[0], evalInfo]);
this.template.block.hasEval = true;
}
/// Expressions
literal(value) {
if (value === undefined) {
this.pushValue([_wireFormat.Ops.Undefined]);
} else {
this.pushValue(value);
}
}
unknown(name) {
this.pushValue([_wireFormat.Ops.Unknown, name]);
}
get([head, path]) {
this.pushValue([_wireFormat.Ops.Get, head, path]);
}
maybeLocal(path) {
this.pushValue([_wireFormat.Ops.MaybeLocal, path]);
}
concat() {
this.pushValue([_wireFormat.Ops.Concat, this.popValue()]);
}
helper(name) {
let params = this.popValue();
let hash = this.popValue();
this.pushValue([_wireFormat.Ops.Helper, name, params, hash]);
}
/// Stack Management Opcodes
prepareArray(size) {
let values = [];
for (let i = 0; i < size; i++) {
values.push(this.popValue());
}
this.pushValue(values);
}
prepareObject(size) {
let keys = new Array(size);
let values = new Array(size);
for (let i = 0; i < size; i++) {
keys[i] = this.popValue();
values[i] = this.popValue();
}
this.pushValue([keys, values]);
}
/// Utilities
endComponent() {
let component = this.blocks.pop();
return component.toJSON();
}
push(args) {
while (args[args.length - 1] === null) {
args.pop();
}
this.currentBlock.push(args);
}
pushValue(val) {
this.values.push(val);
}
popValue() {
return this.values.pop();
}
}
// There is a small whitelist of namespaced attributes specially
// enumerated in
// https://www.w3.org/TR/html/syntax.html#attributes-0
//
// > When a foreign element has one of the namespaced attributes given by
// > the local name and namespace of the first and second cells of a row
// > from the following table, it must be written using the name given by
// > the third cell from the same row.
//
// In all other cases, colons are interpreted as a regular character
// with no special meaning:
//
// > No other namespaced attribute can be expressed in the HTML syntax.
const XLINK = 'http://www.w3.org/1999/xlink';
const XML = 'http://www.w3.org/XML/1998/namespace';
const XMLNS = 'http://www.w3.org/2000/xmlns/';
const WHITELIST = {
'xlink:actuate': XLINK,
'xlink:arcrole': XLINK,
'xlink:href': XLINK,
'xlink:role': XLINK,
'xlink:show': XLINK,
'xlink:title': XLINK,
'xlink:type': XLINK,
'xml:base': XML,
'xml:lang': XML,
'xml:space': XML,
xmlns: XMLNS,
'xmlns:xlink': XMLNS
};
function getAttrNamespace(attrName) {
return WHITELIST[attrName] || null;
}
class SymbolAllocator {
constructor(ops) {
this.ops = ops;
this.symbolStack = new _util.Stack();
}
process() {
let out = [];
let { ops } = this;
for (let i = 0; i < ops.length; i++) {
let op = ops[i];
let result = this.dispatch(op);
if (result === undefined) {
out.push(op);
} else {
out.push(result);
}
}
return out;
}
dispatch(op) {
let name = op[0];
let operand = op[1];
return this[name](operand);
}
get symbols() {
return this.symbolStack.current;
}
startProgram(op) {
this.symbolStack.push(op['symbols']);
}
endProgram(_op) {
this.symbolStack.pop();
}
startBlock(op) {
this.symbolStack.push(op['symbols']);
}
endBlock(_op) {
this.symbolStack.pop();
}
flushElement(op) {
this.symbolStack.push(op['symbols']);
}
closeElement(_op) {
this.symbolStack.pop();
}
closeComponent(_op) {
this.symbolStack.pop();
}
closeDynamicComponent(_op) {
this.symbolStack.pop();
}
attrSplat(_op) {
return ['attrSplat', this.symbols.allocateBlock('attrs')];
}
get(op) {
let [name, rest] = op;
if (name === 0) {
return ['get', [0, rest]];
}
if (isLocal(name, this.symbols)) {
let head = this.symbols.get(name);
return ['get', [head, rest]];
} else if (name[0] === '@') {
let head = this.symbols.allocateNamed(name);
return ['get', [head, rest]];
} else {
return ['maybeLocal', [name, ...rest]];
}
}
maybeGet(op) {
let [name, rest] = op;
if (name === 0) {
return ['get', [0, rest]];
}
if (isLocal(name, this.symbols)) {
let head = this.symbols.get(name);
return ['get', [head, rest]];
} else if (name[0] === '@') {
let head = this.symbols.allocateNamed(name);
return ['get', [head, rest]];
} else if (rest.length === 0) {
return ['unknown', name];
} else {
return ['maybeLocal', [name, ...rest]];
}
}
yield(op) {
if (op === 0) {
throw new Error('Cannot yield to this');
}
return ['yield', this.symbols.allocateBlock(op)];
}
debugger(_op) {
return ['debugger', this.symbols.getEvalInfo()];
}
hasBlock(op) {
if (op === 0) {
throw new Error('Cannot hasBlock this');
}
return ['hasBlock', this.symbols.allocateBlock(op)];
}
hasBlockParams(op) {
if (op === 0) {
throw new Error('Cannot hasBlockParams this');
}
return ['hasBlockParams', this.symbols.allocateBlock(op)];
}
partial(_op) {
return ['partial', this.symbols.getEvalInfo()];
}
text(_op) {}
comment(_op) {}
openComponent(_op) {}
openElement(_op) {}
openSplattedElement(_op) {}
staticArg(_op) {}
dynamicArg(_op) {}
staticAttr(_op) {}
trustingAttr(_op) {}
dynamicAttr(_op) {}
modifier(_op) {}
append(_op) {}
block(_op) {}
literal(_op) {}
helper(_op) {}
unknown(_op) {}
maybeLocal(_op) {}
prepareArray(_op) {}
prepareObject(_op) {}
concat(_op) {}
}
function isLocal(name, symbols) {
return symbols && symbols.has(name);
}
function isTrustedValue(value) {
return value.escaped !== undefined && !value.escaped;
}
class TemplateCompiler {
constructor() {
this.templateId = 0;
this.templateIds = [];
this.opcodes = [];
this.includeMeta = false;
}
static compile(ast, options) {
let templateVisitor = new TemplateVisitor();
templateVisitor.visit(ast);
let compiler = new TemplateCompiler();
let opcodes = compiler.process(templateVisitor.actions);
let symbols = new SymbolAllocator(opcodes).process();
return JavaScriptCompiler.process(symbols, ast['symbols'], options);
}
process(actions) {
actions.forEach(([name, ...args]) => {
if (!this[name]) {
throw new Error(`Unimplemented ${name} on TemplateCompiler`);
}
this[name](...args);
});
return this.opcodes;
}
startProgram([program]) {
this.opcode(['startProgram', program], program);
}
endProgram() {
this.opcode(['endProgram', null], null);
}
startBlock([program]) {
this.templateId++;
this.opcode(['startBlock', program], program);
}
endBlock() {
this.templateIds.push(this.templateId - 1);
this.opcode(['endBlock', null], null);
}
text([action]) {
this.opcode(['text', action.chars], action);
}
comment([action]) {
this.opcode(['comment', action.value], action);
}
openElement([action]) {
let attributes = action.attributes;
let hasSplat;
for (let i = 0; i < attributes.length; i++) {
let attr = attributes[i];
if (attr.name === '...attributes') {
hasSplat = attr;
break;
}
}
if (isDynamicComponent(action)) {
let head, rest;
[head, ...rest] = action.tag.split('.');
if (head === 'this') {
head = 0;
}
this.opcode(['get', [head, rest]]);
this.opcode(['openComponent', action], action);
} else if (isComponent(action)) {
this.opcode(['openComponent', action], action);
} else if (hasSplat) {
this.opcode(['openSplattedElement', action], action);
} else {
this.opcode(['openElement', action], action);
}
let typeAttr = null;
let attrs = action.attributes;
for (let i = 0; i < attrs.length; i++) {
if (attrs[i].name === 'type') {
typeAttr = attrs[i];
continue;
}
this.attribute([attrs[i]]);
}
if (typeAttr) {
this.attribute([typeAttr]);
}
this.opcode(['flushElement', action], null);
}
closeElement([action]) {
if (isDynamicComponent(action)) {
this.opcode(['closeDynamicComponent', action], action);
} else if (isComponent(action)) {
this.opcode(['closeComponent', action], action);
} else if (action.modifiers.length > 0) {
for (let i = 0; i < action.modifiers.length; i++) {
this.modifier([action.modifiers[i]]);
}
this.opcode(['closeElement', action], action);
} else {
this.opcode(['closeElement', action], action);
}
}
attribute([action]) {
let { name, value } = action;
let namespace = getAttrNamespace(name);
let isStatic = this.prepareAttributeValue(value);
if (name.charAt(0) === '@') {
// Arguments
if (isStatic) {
this.opcode(['staticArg', name], action);
} else if (action.value.type === 'MustacheStatement') {
this.opcode(['dynamicArg', name], action);
} else {
this.opcode(['dynamicArg', name], action);
}
} else {
let isTrusting = isTrustedValue(value);
if (isStatic && name === '...attributes') {
this.opcode(['attrSplat', null], action);
} else if (isStatic) {
this.opcode(['staticAttr', [name, namespace]], action);
} else if (isTrusting) {
this.opcode(['trustingAttr', [name, namespace]], action);
} else if (action.value.type === 'MustacheStatement') {
this.opcode(['dynamicAttr', [name, null]], action);
} else {
this.opcode(['dynamicAttr', [name, namespace]], action);
}
}
}
modifier([action]) {
assertIsSimplePath(action.path, action.loc, 'modifier');
let { path: { parts } } = action;
this.prepareHelper(action);
this.opcode(['modifier', parts[0]], action);
}
mustache([action]) {
let { path } = action;
if ((0, _syntax.isLiteral)(path)) {
this.mustacheExpression(action);
this.opcode(['append', !action.escaped], action);
} else if (isYield(path)) {
let to = assertValidYield(action);
this.yield(to, action);
} else if (isPartial(path)) {
let params = assertValidPartial(action);
this.partial(params, action);
} else if (isDebugger(path)) {
assertValidDebuggerUsage(action);
this.debugger('debugger', action);
} else {
this.mustacheExpression(action);
this.opcode(['append', !action.escaped], action);
}
}
block([action /*, index, count*/]) {
this.prepareHelper(action);
let templateId = this.templateIds.pop();
let inverseId = action.inverse === null ? null : this.templateIds.pop();
this.opcode(['block', [action.path.parts[0], templateId, inverseId]], action);
}
/// Internal actions, not found in the original processed actions
arg([path]) {
let { parts: [head, ...rest] } = path;
this.opcode(['get', [`@${head}`, rest]], path);
}
mustacheExpression(expr) {
let { path } = expr;
if ((0, _syntax.isLiteral)(path)) {
this.opcode(['literal', path.value], expr);
} else if (isBuiltInHelper(path)) {
this.builtInHelper(expr);
} else if (isArg(path)) {
this.arg([path]);
} else if (isHelperInvocation(expr)) {
this.prepareHelper(expr);
this.opcode(['helper', path.parts[0]], expr);
} else if (path.this) {
this.opcode(['get', [0, path.parts]], expr);
} else {
let [head, ...parts] = path.parts;
this.opcode(['maybeGet', [head, parts]], expr);
}
// } else if (isLocal(path, this.symbols)) {
// let [head, ...parts] = path.parts;
// this.opcode(['get', [head, parts]], expr);
// } else if (isSimplePath(path)) {
// this.opcode(['unknown', path.parts[0]], expr);
// } else {
// this.opcode(['maybeLocal', path.parts], expr);
// }
}
/// Internal Syntax
yield(to, action) {
this.prepareParams(action.params);
this.opcode(['yield', to], action);
}
debugger(_name, action) {
this.opcode(['debugger', null], action);
}
hasBlock(name, action) {
this.opcode(['hasBlock', name], action);
}
hasBlockParams(name, action) {
this.opcode(['hasBlockParams', name], action);
}
partial(_params, action) {
this.prepareParams(action.params);
this.opcode(['partial', null], action);
}
builtInHelper(expr) {
let { path } = expr;
if (isHasBlock(path)) {
let name = assertValidHasBlockUsage(expr.path.original, expr);
this.hasBlock(name, expr);
} else if (isHasBlockParams(path)) {
let name = assertValidHasBlockUsage(expr.path.original, expr);
this.hasBlockParams(name, expr);
}
}
/// Expressions, invoked recursively from prepareParams and prepareHash
SubExpression(expr) {
if (isBuiltInHelper(expr.path)) {
this.builtInHelper(expr);
} else {
this.prepareHelper(expr);
this.opcode(['helper', expr.path.parts[0]], expr);
}
}
PathExpression(expr) {
if (expr.data) {
this.arg([expr]);
} else {
let [head, ...rest] = expr.parts;
if (expr.this) {
this.opcode(['get', [0, expr.parts]], expr);
} else {
this.opcode(['get', [head, rest]], expr);
}
}
}
StringLiteral(action) {
this.opcode(['literal', action.value], action);
}
BooleanLiteral(action) {
this.opcode(['literal', action.value], action);
}
NumberLiteral(action) {
this.opcode(['literal', action.value], action);
}
NullLiteral(action) {
this.opcode(['literal', action.value], action);
}
UndefinedLiteral(action) {
this.opcode(['literal', action.value], action);
}
/// Utilities
opcode(opcode, action = null) {
// TODO: This doesn't really work
if (this.includeMeta && action) {
opcode.push(this.meta(action));
}
this.opcodes.push(opcode);
}
prepareHelper(expr) {
assertIsSimplePath(expr.path, expr.loc, 'helper');
let { params, hash } = expr;
this.prepareHash(hash);
this.prepareParams(params);
}
prepareParams(params) {
if (!params.length) {
this.opcode(['literal', null], null);
return;
}
for (let i = params.length - 1; i >= 0; i--) {
let param = params[i];
this[param.type](param);
}
this.opcode(['prepareArray', params.length], null);
}
prepareHash(hash) {
let pairs = hash.pairs;
if (!pairs.length) {
this.opcode(['literal', null], null);
return;
}
for (let i = pairs.length - 1; i >= 0; i--) {
let { key, value } = pairs[i];
this[value.type](value);
this.opcode(['literal', key], null);
}
this.opcode(['prepareObject', pairs.length], null);
}
prepareAttributeValue(value) {
// returns the static value if the value is static
switch (value.type) {
case 'TextNode':
this.opcode(['literal', value.chars], value);
return true;
case 'MustacheStatement':
this.attributeMustache([value]);
return false;
case 'ConcatStatement':
this.prepareConcatParts(value.parts);
this.opcode(['concat', null], value);
return false;
}
}
prepareConcatParts(parts) {
for (let i = parts.length - 1; i >= 0; i--) {
let part = parts[i];
if (part.type === 'MustacheStatement') {
this.attributeMustache([part]);
} else if (part.type === 'TextNode') {
this.opcode(['literal', part.chars], null);
}
}
this.opcode(['prepareArray', parts.length], null);
}
attributeMustache([action]) {
this.mustacheExpression(action);
}
meta(node) {
let loc = node.loc;
if (!loc) {
return [];
}
let { source, start, end } = loc;
return ['loc', [source || null, [start.line, start.column], [end.line, end.column]]];
}
}
function isHelperInvocation(mustache) {
return mustache.params && mustache.params.length > 0 || mustache.hash && mustache.hash.pairs.length > 0;
}
function isSimplePath({ parts }) {
return parts.length === 1;
}
function isYield(path) {
return path.original === 'yield';
}
function isPartial(path) {
return path.original === 'partial';
}
function isDebugger(path) {
return path.original === 'debugger';
}
function isHasBlock(path) {
return path.original === 'has-block';
}
function isHasBlockParams(path) {
return path.original === 'has-block-params';
}
function isBuiltInHelper(path) {
return isHasBlock(path) || isHasBlockParams(path);
}
function isArg(path) {
return !!path['data'];
}
function isDynamicComponent(element) {
let open = element.tag.charAt(0);
let [maybeLocal] = element.tag.split('.');
let isNamedArgument = open === '@';
let isLocal = element['symbols'].has(maybeLocal);
let isThisPath = element.tag.indexOf('this.') === 0;
return isLocal || isNamedArgument || isThisPath;
}
function isComponent(element) {
let open = element.tag.charAt(0);
let isPath = element.tag.indexOf('.') > -1;
let isUpperCase = open === open.toUpperCase() && open !== open.toLowerCase();
return isUpperCase && !isPath || isDynamicComponent(element);
}
function assertIsSimplePath(path, loc, context) {
if (!isSimplePath(path)) {
throw new _syntax.SyntaxError(`\`${path.original}\` is not a valid name for a ${context} on line ${loc.start.line}.`, path.loc);
}
}
function assertValidYield(statement) {
let { pairs } = statement.hash;
if (pairs.length === 1 && pairs[0].key !== 'to' || pairs.length > 1) {
throw new _syntax.SyntaxError(`yield only takes a single named argument: 'to'`, statement.loc);
} else if (pairs.length === 1 && pairs[0].value.type !== 'StringLiteral') {
throw new _syntax.SyntaxError(`you can only yield to a literal value`, statement.loc);
} else if (pairs.length === 0) {
return 'default';
} else {
return pairs[0].value.value;
}
}
function assertValidPartial(statement) {
let { params, hash, escaped, loc } = statement;
if (params && params.length !== 1) {
throw new _syntax.SyntaxError(`Partial found with no arguments. You must specify a template name. (on line ${loc.start.line})`, statement.loc);
} else if (hash && hash.pairs.length > 0) {
throw new _syntax.SyntaxError(`partial does not take any named arguments (on line ${loc.start.line})`, statement.loc);
} else if (!escaped) {
throw new _syntax.SyntaxError(`{{{partial ...}}} is not supported, please use {{partial ...}} instead (on line ${loc.start.line})`, statement.loc);
}
return params;
}
function assertValidHasBlockUsage(type, call) {
let { params, hash, loc } = call;
if (hash && hash.pairs.length > 0) {
throw new _syntax.SyntaxError(`${type} does not take any named arguments`, call.loc);
}
if (params.length === 0) {
return 'default';
} else if (params.length === 1) {
let param = params[0];
if (param.type === 'StringLiteral') {
return param.value;
} else {
throw new _syntax.SyntaxError(`you can only yield to a literal value (on line ${loc.start.line})`, call.loc);
}
} else {
throw new _syntax.SyntaxError(`${type} only takes a single positional argument (on line ${loc.start.line})`, call.loc);
}
}
function assertValidDebuggerUsage(statement) {
let { params, hash } = statement;
if (hash && hash.pairs.length > 0) {
throw new _syntax.SyntaxError(`debugger does not take any named arguments`, statement.loc);
}
if (params.length === 0) {
return 'default';
} else {
throw new _syntax.SyntaxError(`debugger does not take any positional arguments`, statement.loc);
}
}
const defaultId = (() => {
if (typeof _nodeModule.require === 'function') {
try {
/* tslint:disable:no-require-imports */
const crypto = (0, _nodeModule.require)('crypto');
/* tslint:enable:no-require-imports */
let idFn = src => {
let hash = crypto.createHash('sha1');
hash.update(src, 'utf8');
// trim to 6 bytes of data (2^48 - 1)
return hash.digest('base64').substring(0, 8);
};
idFn('test');
return idFn;
} catch (e) {}
}
return function idFn() {
return null;
};
})();
const defaultOptions = {
id: defaultId,
meta: {}
};
function precompile(string, options = defaultOptions) {
let ast = (0, _syntax.preprocess)(string, options);
let { meta } = options;
let { block } = TemplateCompiler.compile(ast, options);
let idFn = options.id || defaultId;
let blockJSON = JSON.stringify(block.toJSON());
let templateJSONObject = {
id: idFn(JSON.stringify(meta) + blockJSON),
block: blockJSON,
meta: meta
};
// JSON is javascript
return JSON.stringify(templateJSONObject);
}
exports.defaultId = defaultId;
exports.precompile = precompile;
exports.TemplateCompiler = TemplateCompiler;
exports.TemplateVisitor = TemplateVisitor;
});
enifed('@glimmer/syntax', ['exports', 'simple-html-tokenizer', '@glimmer/util', 'handlebars'], function (exports, _simpleHtmlTokenizer, _util, _handlebars) {
'use strict';
exports.printLiteral = exports.isLiteral = exports.SyntaxError = exports.print = exports.Walker = exports.traverse = exports.cannotReplaceOrRemoveInKeyHandlerYet = exports.cannotReplaceNode = exports.cannotRemoveNode = exports.TraversalError = exports.builders = exports.preprocess = exports.AST = undefined;
function buildMustache(path, params, hash, raw, loc) {
if (typeof path === 'string') {
path = buildPath(path);
}
return {
type: 'MustacheStatement',
path,
params: params || [],
hash: hash || buildHash([]),
escaped: !raw,
loc: buildLoc(loc || null)
};
}
function buildBlock(path, params, hash, program, inverse, loc) {
return {
type: 'BlockStatement',
path: buildPath(path),
params: params || [],
hash: hash || buildHash([]),
program: program || null,
inverse: inverse || null,
loc: buildLoc(loc || null)
};
}
function buildElementModifier(path, params, hash, loc) {
return {
type: 'ElementModifierStatement',
path: buildPath(path),
params: params || [],
hash: hash || buildHash([]),
loc: buildLoc(loc || null)
};
}
function buildPartial(name, params, hash, indent, loc) {
return {
type: 'PartialStatement',
name: name,
params: params || [],
hash: hash || buildHash([]),
indent: indent || '',
strip: { open: false, close: false },
loc: buildLoc(loc || null)
};
}
function buildComment(value, loc) {
return {
type: 'CommentStatement',
value: value,
loc: buildLoc(loc || null)
};
}
function buildMustacheComment(value, loc) {
return {
type: 'MustacheCommentStatement',
value: value,
loc: buildLoc(loc || null)
};
}
function buildConcat(parts, loc) {
return {
type: 'ConcatStatement',
parts: parts || [],
loc: buildLoc(loc || null)
};
}
function buildElement(tag, attributes, modifiers, children, comments, blockParams, loc) {
// this is used for backwards compat prior to `blockParams` being added to the AST
if (Array.isArray(comments)) {
if (isBlockParms(comments)) {
blockParams = comments;
comments = [];
} else if (isLoc(blockParams)) {
loc = blockParams;
blockParams = [];
}
} else if (isLoc(comments)) {
// this is used for backwards compat prior to `comments` being added to the AST
loc = comments;
comments = [];
} else if (isLoc(blockParams)) {
loc = blockParams;
blockParams = [];
}
// this is used for backwards compat, prior to `selfClosing` being part of the ElementNode AST
let selfClosing = false;
if (typeof tag === 'object') {
selfClosing = tag.selfClosing;
tag = tag.name;
}
return {
type: 'ElementNode',
tag: tag || '',
selfClosing: selfClosing,
attributes: attributes || [],
blockParams: blockParams || [],
modifiers: modifiers || [],
comments: comments || [],
children: children || [],
loc: buildLoc(loc || null)
};
}
function buildAttr(name, value, loc) {
return {
type: 'AttrNode',
name: name,
value: value,
loc: buildLoc(loc || null)
};
}
function buildText(chars, loc) {
return {
type: 'TextNode',
chars: chars || '',
loc: buildLoc(loc || null)
};
}
// Expressions
function buildSexpr(path, params, hash, loc) {
return {
type: 'SubExpression',
path: buildPath(path),
params: params || [],
hash: hash || buildHash([]),
loc: buildLoc(loc || null)
};
}
function buildPath(original, loc) {
if (typeof original !== 'string') return original;
let parts = original.split('.');
let thisHead = false;
if (parts[0] === 'this') {
thisHead = true;
parts = parts.slice(1);
}
return {
type: 'PathExpression',
original,
this: thisHead,
parts,
data: false,
loc: buildLoc(loc || null)
};
}
function buildLiteral(type, value, loc) {
return {
type,
value,
original: value,
loc: buildLoc(loc || null)
};
}
// Miscellaneous
function buildHash(pairs, loc) {
return {
type: 'Hash',
pairs: pairs || [],
loc: buildLoc(loc || null)
};
}
function buildPair(key, value, loc) {
return {
type: 'HashPair',
key: key,
value,
loc: buildLoc(loc || null)
};
}
function buildProgram(body, blockParams, loc) {
return {
type: 'Program',
body: body || [],
blockParams: blockParams || [],
loc: buildLoc(loc || null)
};
}
function buildSource(source) {
return source || null;
}
function buildPosition(line, column) {
return {
line,
column
};
}
const SYNTHETIC = {
source: '(synthetic)',
start: { line: 1, column: 0 },
end: { line: 1, column: 0 }
};
function buildLoc(...args) {
if (args.length === 1) {
let loc = args[0];
if (loc && typeof loc === 'object') {
return {
source: buildSource(loc.source),
start: buildPosition(loc.start.line, loc.start.column),
end: buildPosition(loc.end.line, loc.end.column)
};
} else {
return SYNTHETIC;
}
} else {
let [startLine, startColumn, endLine, endColumn, source] = args;
return {
source: buildSource(source),
start: buildPosition(startLine, startColumn),
end: buildPosition(endLine, endColumn)
};
}
}
function isBlockParms(arr) {
return arr[0] === 'string';
}
function isLoc(item) {
return !Array.isArray(item);
}
var b = {
mustache: buildMustache,
block: buildBlock,
partial: buildPartial,
comment: buildComment,
mustacheComment: buildMustacheComment,
element: buildElement,
elementModifier: buildElementModifier,
attr: buildAttr,
text: buildText,
sexpr: buildSexpr,
path: buildPath,
concat: buildConcat,
hash: buildHash,
pair: buildPair,
literal: buildLiteral,
program: buildProgram,
loc: buildLoc,
pos: buildPosition,
string: literal('StringLiteral'),
boolean: literal('BooleanLiteral'),
number: literal('NumberLiteral'),
undefined() {
return buildLiteral('UndefinedLiteral', undefined);
},
null() {
return buildLiteral('NullLiteral', null);
}
};
function literal(type) {
return function (value) {
return buildLiteral(type, value);
};
}
/**
* Subclass of `Error` with additional information
* about location of incorrect markup.
*/
const SyntaxError = function () {
SyntaxError.prototype = Object.create(Error.prototype);
SyntaxError.prototype.constructor = SyntaxError;
function SyntaxError(message, location) {
let error = Error.call(this, message);
this.message = message;
this.stack = error.stack;
this.location = location;
}
return SyntaxError;
}();
// Regex to validate the identifier for block parameters.
// Based on the ID validation regex in Handlebars.
let ID_INVERSE_PATTERN = /[!"#%-,\.\/;->@\[-\^`\{-~]/;
// Checks the element's attributes to see if it uses block params.
// If it does, registers the block params with the program and
// removes the corresponding attributes from the element.
function parseElementBlockParams(element) {
let params = parseBlockParams(element);
if (params) element.blockParams = params;
}
function parseBlockParams(element) {
let l = element.attributes.length;
let attrNames = [];
for (let i = 0; i < l; i++) {
attrNames.push(element.attributes[i].name);
}
let asIndex = attrNames.indexOf('as');
if (asIndex !== -1 && l > asIndex && attrNames[asIndex + 1].charAt(0) === '|') {
// Some basic validation, since we're doing the parsing ourselves
let paramsString = attrNames.slice(asIndex).join(' ');
if (paramsString.charAt(paramsString.length - 1) !== '|' || paramsString.match(/\|/g).length !== 2) {
throw new SyntaxError("Invalid block parameters syntax: '" + paramsString + "'", element.loc);
}
let params = [];
for (let i = asIndex + 1; i < l; i++) {
let param = attrNames[i].replace(/\|/g, '');
if (param !== '') {
if (ID_INVERSE_PATTERN.test(param)) {
throw new SyntaxError("Invalid identifier for block parameters: '" + param + "' in '" + paramsString + "'", element.loc);
}
params.push(param);
}
}
if (params.length === 0) {
throw new SyntaxError("Cannot use zero block parameters: '" + paramsString + "'", element.loc);
}
element.attributes = element.attributes.slice(0, asIndex);
return params;
}
return null;
}
function childrenFor(node) {
switch (node.type) {
case 'Program':
return node.body;
case 'ElementNode':
return node.children;
}
}
function appendChild(parent, node) {
childrenFor(parent).push(node);
}
function isLiteral(path) {
return path.type === 'StringLiteral' || path.type === 'BooleanLiteral' || path.type === 'NumberLiteral' || path.type === 'NullLiteral' || path.type === 'UndefinedLiteral';
}
function printLiteral(literal) {
if (literal.type === 'UndefinedLiteral') {
return 'undefined';
} else {
return JSON.stringify(literal.value);
}
}
const entityParser = new _simpleHtmlTokenizer.EntityParser(_simpleHtmlTokenizer.HTML5NamedCharRefs);
class Parser {
constructor(source) {
this.elementStack = [];
this.currentAttribute = null;
this.currentNode = null;
this.tokenizer = new _simpleHtmlTokenizer.EventedTokenizer(this, entityParser);
this.source = source.split(/(?:\r\n?|\n)/g);
}
get currentAttr() {
return this.currentAttribute;
}
get currentTag() {
let node = this.currentNode;
return node;
}
get currentStartTag() {
let node = this.currentNode;
return node;
}
get currentEndTag() {
let node = this.currentNode;
return node;
}
get currentComment() {
let node = this.currentNode;
return node;
}
get currentData() {
let node = this.currentNode;
return node;
}
acceptNode(node) {
return this[node.type](node);
}
currentElement() {
return this.elementStack[this.elementStack.length - 1];
}
sourceForNode(node, endNode) {
let firstLine = node.loc.start.line - 1;
let currentLine = firstLine - 1;
let firstColumn = node.loc.start.column;
let string = [];
let line;
let lastLine;
let lastColumn;
if (endNode) {
lastLine = endNode.loc.end.line - 1;
lastColumn = endNode.loc.end.column;
} else {
lastLine = node.loc.end.line - 1;
lastColumn = node.loc.end.column;
}
while (currentLine < lastLine) {
currentLine++;
line = this.source[currentLine];
if (currentLine === firstLine) {
if (firstLine === lastLine) {
string.push(line.slice(firstColumn, lastColumn));
} else {
string.push(line.slice(firstColumn));
}
} else if (currentLine === lastLine) {
string.push(line.slice(0, lastColumn));
} else {
string.push(line);
}
}
return string.join('\n');
}
}
class HandlebarsNodeVisitors extends Parser {
constructor() {
super(...arguments);
this.cursorCount = 0;
}
cursor() {
return `%cursor:${this.cursorCount++}%`;
}
Program(program) {
let body = [];
this.cursorCount = 0;
let node = b.program(body, program.blockParams, program.loc);
let i,
l = program.body.length;
this.elementStack.push(node);
if (l === 0) {
return this.elementStack.pop();
}
for (i = 0; i < l; i++) {
this.acceptNode(program.body[i]);
}
// Ensure that that the element stack is balanced properly.
let poppedNode = this.elementStack.pop();
if (poppedNode !== node) {
let elementNode = poppedNode;
throw new SyntaxError('Unclosed element `' + elementNode.tag + '` (on line ' + elementNode.loc.start.line + ').', elementNode.loc);
}
return node;
}
BlockStatement(block) {
if (this.tokenizer['state'] === 'comment') {
this.appendToCommentData(this.sourceForNode(block));
return;
}
if (this.tokenizer['state'] !== 'comment' && this.tokenizer['state'] !== 'data' && this.tokenizer['state'] !== 'beforeData') {
throw new SyntaxError('A block may only be used inside an HTML element or another block.', block.loc);
}
let { path, params, hash } = acceptCallNodes(this, block);
let program = this.Program(block.program);
let inverse = block.inverse ? this.Program(block.inverse) : null;
if (path.original === 'in-element') {
hash = addInElementHash(this.cursor(), hash, block.loc);
}
let node = b.block(path, params, hash, program, inverse, block.loc);
let parentProgram = this.currentElement();
appendChild(parentProgram, node);
}
MustacheStatement(rawMustache) {
let { tokenizer } = this;
if (tokenizer.state === 'comment') {
this.appendToCommentData(this.sourceForNode(rawMustache));
return;
}
let mustache;
let { escaped, loc } = rawMustache;
if (rawMustache.path.type.match(/Literal$/)) {
mustache = {
type: 'MustacheStatement',
path: this.acceptNode(rawMustache.path),
params: [],
hash: b.hash(),
escaped,
loc
};
} else {
let { path, params, hash } = acceptCallNodes(this, rawMustache);
mustache = b.mustache(path, params, hash, !escaped, loc);
}
switch (tokenizer.state) {
// Tag helpers
case "tagOpen" /* tagOpen */:
case "tagName" /* tagName */:
throw new SyntaxError(`Cannot use mustaches in an elements tagname: \`${this.sourceForNode(rawMustache, rawMustache.path)}\` at L${loc.start.line}:C${loc.start.column}`, mustache.loc);
case "beforeAttributeName" /* beforeAttributeName */:
addElementModifier(this.currentStartTag, mustache);
break;
case "attributeName" /* attributeName */:
case "afterAttributeName" /* afterAttributeName */:
this.beginAttributeValue(false);
this.finishAttributeValue();
addElementModifier(this.currentStartTag, mustache);
tokenizer.transitionTo("beforeAttributeName" /* beforeAttributeName */);
break;
case "afterAttributeValueQuoted" /* afterAttributeValueQuoted */:
addElementModifier(this.currentStartTag, mustache);
tokenizer.transitionTo("beforeAttributeName" /* beforeAttributeName */);
break;
// Attribute values
case "beforeAttributeValue" /* beforeAttributeValue */:
this.beginAttributeValue(false);
appendDynamicAttributeValuePart(this.currentAttribute, mustache);
tokenizer.transitionTo("attributeValueUnquoted" /* attributeValueUnquoted */);
break;
case "attributeValueDoubleQuoted" /* attributeValueDoubleQuoted */:
case "attributeValueSingleQuoted" /* attributeValueSingleQuoted */:
case "attributeValueUnquoted" /* attributeValueUnquoted */:
appendDynamicAttributeValuePart(this.currentAttribute, mustache);
break;
// TODO: Only append child when the tokenizer state makes
// sense to do so, otherwise throw an error.
default:
appendChild(this.currentElement(), mustache);
}
return mustache;
}
ContentStatement(content) {
updateTokenizerLocation(this.tokenizer, content);
this.tokenizer.tokenizePart(content.value);
this.tokenizer.flushData();
}
CommentStatement(rawComment) {
let { tokenizer } = this;
if (tokenizer.state === "comment" /* comment */) {
this.appendToCommentData(this.sourceForNode(rawComment));
return null;
}
let { value, loc } = rawComment;
let comment = b.mustacheComment(value, loc);
switch (tokenizer.state) {
case "beforeAttributeName" /* beforeAttributeName */:
this.currentStartTag.comments.push(comment);
break;
case "beforeData" /* beforeData */:
case "data" /* data */:
appendChild(this.currentElement(), comment);
break;
default:
throw new SyntaxError(`Using a Handlebars comment when in the \`${tokenizer['state']}\` state is not supported: "${comment.value}" on line ${loc.start.line}:${loc.start.column}`, rawComment.loc);
}
return comment;
}
PartialStatement(partial) {
let { loc } = partial;
throw new SyntaxError(`Handlebars partials are not supported: "${this.sourceForNode(partial, partial.name)}" at L${loc.start.line}:C${loc.start.column}`, partial.loc);
}
PartialBlockStatement(partialBlock) {
let { loc } = partialBlock;
throw new SyntaxError(`Handlebars partial blocks are not supported: "${this.sourceForNode(partialBlock, partialBlock.name)}" at L${loc.start.line}:C${loc.start.column}`, partialBlock.loc);
}
Decorator(decorator) {
let { loc } = decorator;
throw new SyntaxError(`Handlebars decorators are not supported: "${this.sourceForNode(decorator, decorator.path)}" at L${loc.start.line}:C${loc.start.column}`, decorator.loc);
}
DecoratorBlock(decoratorBlock) {
let { loc } = decoratorBlock;
throw new SyntaxError(`Handlebars decorator blocks are not supported: "${this.sourceForNode(decoratorBlock, decoratorBlock.path)}" at L${loc.start.line}:C${loc.start.column}`, decoratorBlock.loc);
}
SubExpression(sexpr) {
let { path, params, hash } = acceptCallNodes(this, sexpr);
return b.sexpr(path, params, hash, sexpr.loc);
}
PathExpression(path) {
let { original, loc } = path;
let parts;
if (original.indexOf('/') !== -1) {
if (original.slice(0, 2) === './') {
throw new SyntaxError(`Using "./" is not supported in Glimmer and unnecessary: "${path.original}" on line ${loc.start.line}.`, path.loc);
}
if (original.slice(0, 3) === '../') {
throw new SyntaxError(`Changing context using "../" is not supported in Glimmer: "${path.original}" on line ${loc.start.line}.`, path.loc);
}
if (original.indexOf('.') !== -1) {
throw new SyntaxError(`Mixing '.' and '/' in paths is not supported in Glimmer; use only '.' to separate property paths: "${path.original}" on line ${loc.start.line}.`, path.loc);
}
parts = [path.parts.join('/')];
} else if (original === '.') {
let locationInfo = `L${loc.start.line}:C${loc.start.column}`;
throw new SyntaxError(`'.' is not a supported path in Glimmer; check for a path with a trailing '.' at ${locationInfo}.`, path.loc);
} else {
parts = path.parts;
}
let thisHead = false;
// This is to fix a bug in the Handlebars AST where the path expressions in
// `{{this.foo}}` (and similarly `{{foo-bar this.foo named=this.foo}}` etc)
// are simply turned into `{{foo}}`. The fix is to push it back onto the
// parts array and let the runtime see the difference. However, we cannot
// simply use the string `this` as it means literally the property called
// "this" in the current context (it can be expressed in the syntax as
// `{{[this]}}`, where the square bracket are generally for this kind of
// escaping – such as `{{foo.["bar.baz"]}}` would mean lookup a property
// named literally "bar.baz" on `this.foo`). By convention, we use `null`
// for this purpose.
if (original.match(/^this(\..+)?$/)) {
thisHead = true;
}
return {
type: 'PathExpression',
original: path.original,
this: thisHead,
parts,
data: path.data,
loc: path.loc
};
}
Hash(hash) {
let pairs = [];
for (let i = 0; i < hash.pairs.length; i++) {
let pair = hash.pairs[i];
pairs.push(b.pair(pair.key, this.acceptNode(pair.value), pair.loc));
}
return b.hash(pairs, hash.loc);
}
StringLiteral(string) {
return b.literal('StringLiteral', string.value, string.loc);
}
BooleanLiteral(boolean) {
return b.literal('BooleanLiteral', boolean.value, boolean.loc);
}
NumberLiteral(number) {
return b.literal('NumberLiteral', number.value, number.loc);
}
UndefinedLiteral(undef) {
return b.literal('UndefinedLiteral', undefined, undef.loc);
}
NullLiteral(nul) {
return b.literal('NullLiteral', null, nul.loc);
}
}
function calculateRightStrippedOffsets(original, value) {
if (value === '') {
// if it is empty, just return the count of newlines
// in original
return {
lines: original.split('\n').length - 1,
columns: 0
};
}
// otherwise, return the number of newlines prior to
// `value`
let difference = original.split(value)[0];
let lines = difference.split(/\n/);
let lineCount = lines.length - 1;
return {
lines: lineCount,
columns: lines[lineCount].length
};
}
function updateTokenizerLocation(tokenizer, content) {
let line = content.loc.start.line;
let column = content.loc.start.column;
let offsets = calculateRightStrippedOffsets(content.original, content.value);
line = line + offsets.lines;
if (offsets.lines) {
column = offsets.columns;
} else {
column = column + offsets.columns;
}
tokenizer.line = line;
tokenizer.column = column;
}
function acceptCallNodes(compiler, node) {
let path = compiler.PathExpression(node.path);
let params = node.params ? node.params.map(e => compiler.acceptNode(e)) : [];
let hash = node.hash ? compiler.Hash(node.hash) : b.hash();
return { path, params, hash };
}
function addElementModifier(element, mustache) {
let { path, params, hash, loc } = mustache;
if (isLiteral(path)) {
let modifier = `{{${printLiteral(path)}}}`;
let tag = `<${element.name} ... ${modifier} ...`;
throw new SyntaxError(`In ${tag}, ${modifier} is not a valid modifier: "${path.original}" on line ${loc && loc.start.line}.`, mustache.loc);
}
let modifier = b.elementModifier(path, params, hash, loc);
element.modifiers.push(modifier);
}
function addInElementHash(cursor, hash, loc) {
let hasNextSibling = false;
hash.pairs.forEach(pair => {
if (pair.key === 'guid') {
throw new SyntaxError('Cannot pass `guid` from user space', loc);
}
if (pair.key === 'nextSibling') {
hasNextSibling = true;
}
});
let guid = b.literal('StringLiteral', cursor);
let guidPair = b.pair('guid', guid);
hash.pairs.unshift(guidPair);
if (!hasNextSibling) {
let nullLiteral = b.literal('NullLiteral', null);
let nextSibling = b.pair('nextSibling', nullLiteral);
hash.pairs.push(nextSibling);
}
return hash;
}
function appendDynamicAttributeValuePart(attribute, part) {
attribute.isDynamic = true;
attribute.parts.push(part);
}
// ensure stays in sync with typing
// ParentNode and ChildKey types are derived from VisitorKeysMap
const visitorKeys = {
Program: ['body'],
MustacheStatement: ['path', 'params', 'hash'],
BlockStatement: ['path', 'params', 'hash', 'program', 'inverse'],
ElementModifierStatement: ['path', 'params', 'hash'],
PartialStatement: ['name', 'params', 'hash'],
CommentStatement: [],
MustacheCommentStatement: [],
ElementNode: ['attributes', 'modifiers', 'children', 'comments'],
AttrNode: ['value'],
TextNode: [],
ConcatStatement: ['parts'],
SubExpression: ['path', 'params', 'hash'],
PathExpression: [],
StringLiteral: [],
BooleanLiteral: [],
NumberLiteral: [],
NullLiteral: [],
UndefinedLiteral: [],
Hash: ['pairs'],
HashPair: ['value']
};
const TraversalError = function () {
TraversalError.prototype = Object.create(Error.prototype);
TraversalError.prototype.constructor = TraversalError;
function TraversalError(message, node, parent, key) {
let error = Error.call(this, message);
this.key = key;
this.message = message;
this.node = node;
this.parent = parent;
this.stack = error.stack;
}
return TraversalError;
}();
function cannotRemoveNode(node, parent, key) {
return new TraversalError('Cannot remove a node unless it is part of an array', node, parent, key);
}
function cannotReplaceNode(node, parent, key) {
return new TraversalError('Cannot replace a node with multiple nodes unless it is part of an array', node, parent, key);
}
function cannotReplaceOrRemoveInKeyHandlerYet(node, key) {
return new TraversalError('Replacing and removing in key handlers is not yet supported.', node, null, key);
}
function getEnterFunction(handler) {
return typeof handler === 'function' ? handler : handler.enter;
}
function getExitFunction(handler) {
return typeof handler !== 'function' ? handler.exit : undefined;
}
function getKeyHandler(handler, key) {
let keyVisitor = typeof handler !== 'function' ? handler.keys : undefined;
if (keyVisitor === undefined) return;
let keyHandler = keyVisitor[key];
if (keyHandler !== undefined) {
// widen specific key to all keys
return keyHandler;
}
return keyVisitor.All;
}
function getNodeHandler(visitor, nodeType) {
let handler = visitor[nodeType];
if (handler !== undefined) {
// widen specific Node to all nodes
return handler;
}
return visitor.All;
}
function visitNode(visitor, node) {
let handler = getNodeHandler(visitor, node.type);
let enter;
let exit;
if (handler !== undefined) {
enter = getEnterFunction(handler);
exit = getExitFunction(handler);
}
let result;
if (enter !== undefined) {
result = enter(node);
}
if (result !== undefined && result !== null) {
if (JSON.stringify(node) === JSON.stringify(result)) {
result = undefined;
} else if (Array.isArray(result)) {
return visitArray(visitor, result) || result;
} else {
return visitNode(visitor, result) || result;
}
}
if (result === undefined) {
let keys = visitorKeys[node.type];
for (let i = 0; i < keys.length; i++) {
// we know if it has child keys we can widen to a ParentNode
visitKey(visitor, handler, node, keys[i]);
}
if (exit !== undefined) {
result = exit(node);
}
}
return result;
}
function visitKey(visitor, handler, node, key) {
let value = node[key];
if (!value) {
return;
}
let keyEnter;
let keyExit;
if (handler !== undefined) {
let keyHandler = getKeyHandler(handler, key);
if (keyHandler !== undefined) {
keyEnter = getEnterFunction(keyHandler);
keyExit = getExitFunction(keyHandler);
}
}
if (keyEnter !== undefined) {
if (keyEnter(node, key) !== undefined) {
throw cannotReplaceOrRemoveInKeyHandlerYet(node, key);
}
}
if (Array.isArray(value)) {
visitArray(visitor, value);
} else {
let result = visitNode(visitor, value);
if (result !== undefined) {
assignKey(node, key, result);
}
}
if (keyExit !== undefined) {
if (keyExit(node, key) !== undefined) {
throw cannotReplaceOrRemoveInKeyHandlerYet(node, key);
}
}
}
function visitArray(visitor, array) {
for (let i = 0; i < array.length; i++) {
let result = visitNode(visitor, array[i]);
if (result !== undefined) {
i += spliceArray(array, i, result) - 1;
}
}
}
function assignKey(node, key, result) {
if (result === null) {
throw cannotRemoveNode(node[key], node, key);
} else if (Array.isArray(result)) {
if (result.length === 1) {
node[key] = result[0];
} else {
if (result.length === 0) {
throw cannotRemoveNode(node[key], node, key);
} else {
throw cannotReplaceNode(node[key], node, key);
}
}
} else {
node[key] = result;
}
}
function spliceArray(array, index, result) {
if (result === null) {
array.splice(index, 1);
return 0;
} else if (Array.isArray(result)) {
array.splice(index, 1, ...result);
return result.length;
} else {
array.splice(index, 1, result);
return 1;
}
}
function traverse(node, visitor) {
visitNode(visitor, node);
}
const ATTR_VALUE_REGEX_TEST = /[\xA0"&]/;
const ATTR_VALUE_REGEX_REPLACE = new RegExp(ATTR_VALUE_REGEX_TEST.source, 'g');
const TEXT_REGEX_TEST = /[\xA0&<>]/;
const TEXT_REGEX_REPLACE = new RegExp(TEXT_REGEX_TEST.source, 'g');
function attrValueReplacer(char) {
switch (char.charCodeAt(0)) {
case 160 /* NBSP */:
return ' ';
case 34 /* QUOT */:
return '"';
case 38 /* AMP */:
return '&';
default:
return char;
}
}
function textReplacer(char) {
switch (char.charCodeAt(0)) {
case 160 /* NBSP */:
return ' ';
case 38 /* AMP */:
return '&';
case 60 /* LT */:
return '<';
case 62 /* GT */:
return '>';
default:
return char;
}
}
function escapeAttrValue(attrValue) {
if (ATTR_VALUE_REGEX_TEST.test(attrValue)) {
return attrValue.replace(ATTR_VALUE_REGEX_REPLACE, attrValueReplacer);
}
return attrValue;
}
function escapeText(text) {
if (TEXT_REGEX_TEST.test(text)) {
return text.replace(TEXT_REGEX_REPLACE, textReplacer);
}
return text;
}
function unreachable() {
throw new Error('unreachable');
}
function build(ast) {
if (!ast) {
return '';
}
const output = [];
switch (ast.type) {
case 'Program':
{
const chainBlock = ast['chained'] && ast.body[0];
if (chainBlock) {
chainBlock['chained'] = true;
}
const body = buildEach(ast.body).join('');
output.push(body);
}
break;
case 'ElementNode':
output.push('<', ast.tag);
if (ast.attributes.length) {
output.push(' ', buildEach(ast.attributes).join(' '));
}
if (ast.modifiers.length) {
output.push(' ', buildEach(ast.modifiers).join(' '));
}
if (ast.comments.length) {
output.push(' ', buildEach(ast.comments).join(' '));
}
if (ast.blockParams.length) {
output.push(' ', 'as', ' ', `|${ast.blockParams.join(' ')}|`);
}
if (voidMap[ast.tag]) {
if (ast.selfClosing) {
output.push(' /');
}
output.push('>');
} else {
output.push('>');
output.push.apply(output, buildEach(ast.children));
output.push('', ast.tag, '>');
}
break;
case 'AttrNode':
if (ast.value.type === 'TextNode') {
if (ast.value.chars !== '') {
output.push(ast.name, '=');
output.push('"', escapeAttrValue(ast.value.chars), '"');
} else {
output.push(ast.name);
}
} else {
output.push(ast.name, '=');
// ast.value is mustache or concat
output.push(build(ast.value));
}
break;
case 'ConcatStatement':
output.push('"');
ast.parts.forEach(node => {
if (node.type === 'TextNode') {
output.push(escapeAttrValue(node.chars));
} else {
output.push(build(node));
}
});
output.push('"');
break;
case 'TextNode':
output.push(escapeText(ast.chars));
break;
case 'MustacheStatement':
{
output.push(compactJoin(['{{', pathParams(ast), '}}']));
}
break;
case 'MustacheCommentStatement':
{
output.push(compactJoin(['{{!--', ast.value, '--}}']));
}
break;
case 'ElementModifierStatement':
{
output.push(compactJoin(['{{', pathParams(ast), '}}']));
}
break;
case 'PathExpression':
output.push(ast.original);
break;
case 'SubExpression':
{
output.push('(', pathParams(ast), ')');
}
break;
case 'BooleanLiteral':
output.push(ast.value ? 'true' : 'false');
break;
case 'BlockStatement':
{
const lines = [];
if (ast['chained']) {
lines.push(['{{else ', pathParams(ast), '}}'].join(''));
} else {
lines.push(openBlock(ast));
}
lines.push(build(ast.program));
if (ast.inverse) {
if (!ast.inverse['chained']) {
lines.push('{{else}}');
}
lines.push(build(ast.inverse));
}
if (!ast['chained']) {
lines.push(closeBlock(ast));
}
output.push(lines.join(''));
}
break;
case 'PartialStatement':
{
output.push(compactJoin(['{{>', pathParams(ast), '}}']));
}
break;
case 'CommentStatement':
{
output.push(compactJoin(['']));
}
break;
case 'StringLiteral':
{
output.push(`"${ast.value}"`);
}
break;
case 'NumberLiteral':
{
output.push(String(ast.value));
}
break;
case 'UndefinedLiteral':
{
output.push('undefined');
}
break;
case 'NullLiteral':
{
output.push('null');
}
break;
case 'Hash':
{
output.push(ast.pairs.map(pair => {
return build(pair);
}).join(' '));
}
break;
case 'HashPair':
{
output.push(`${ast.key}=${build(ast.value)}`);
}
break;
}
return output.join('');
}
function compact(array) {
const newArray = [];
array.forEach(a => {
if (typeof a !== 'undefined' && a !== null && a !== '') {
newArray.push(a);
}
});
return newArray;
}
function buildEach(asts) {
return asts.map(build);
}
function pathParams(ast) {
let path;
switch (ast.type) {
case 'MustacheStatement':
case 'SubExpression':
case 'ElementModifierStatement':
case 'BlockStatement':
if (isLiteral(ast.path)) {
return String(ast.path.value);
}
path = build(ast.path);
break;
case 'PartialStatement':
path = build(ast.name);
break;
default:
return unreachable();
}
return compactJoin([path, buildEach(ast.params).join(' '), build(ast.hash)], ' ');
}
function compactJoin(array, delimiter) {
return compact(array).join(delimiter || '');
}
function blockParams(block) {
const params = block.program.blockParams;
if (params.length) {
return ` as |${params.join(' ')}|`;
}
return null;
}
function openBlock(block) {
return ['{{#', pathParams(block), blockParams(block), '}}'].join('');
}
function closeBlock(block) {
return ['{{/', build(block.path), '}}'].join('');
}
class Walker {
constructor(order) {
this.order = order;
this.stack = [];
}
visit(node, callback) {
if (!node) {
return;
}
this.stack.push(node);
if (this.order === 'post') {
this.children(node, callback);
callback(node, this);
} else {
callback(node, this);
this.children(node, callback);
}
this.stack.pop();
}
children(node, callback) {
let visitor = visitors[node.type];
if (visitor) {
visitor(this, node, callback);
}
}
}
let visitors = {
Program(walker, node, callback) {
for (let i = 0; i < node.body.length; i++) {
walker.visit(node.body[i], callback);
}
},
ElementNode(walker, node, callback) {
for (let i = 0; i < node.children.length; i++) {
walker.visit(node.children[i], callback);
}
},
BlockStatement(walker, node, callback) {
walker.visit(node.program, callback);
walker.visit(node.inverse || null, callback);
}
};
const voidMap = Object.create(null);
let voidTagNames = 'area base br col command embed hr img input keygen link meta param source track wbr';
voidTagNames.split(' ').forEach(tagName => {
voidMap[tagName] = true;
});
class TokenizerEventHandlers extends HandlebarsNodeVisitors {
constructor() {
super(...arguments);
this.tagOpenLine = 0;
this.tagOpenColumn = 0;
}
reset() {
this.currentNode = null;
}
// Comment
beginComment() {
this.currentNode = b.comment('');
this.currentNode.loc = {
source: null,
start: b.pos(this.tagOpenLine, this.tagOpenColumn),
end: null
};
}
appendToCommentData(char) {
this.currentComment.value += char;
}
finishComment() {
this.currentComment.loc.end = b.pos(this.tokenizer.line, this.tokenizer.column);
appendChild(this.currentElement(), this.currentComment);
}
// Data
beginData() {
this.currentNode = b.text();
this.currentNode.loc = {
source: null,
start: b.pos(this.tokenizer.line, this.tokenizer.column),
end: null
};
}
appendToData(char) {
this.currentData.chars += char;
}
finishData() {
this.currentData.loc.end = b.pos(this.tokenizer.line, this.tokenizer.column);
appendChild(this.currentElement(), this.currentData);
}
// Tags - basic
tagOpen() {
this.tagOpenLine = this.tokenizer.line;
this.tagOpenColumn = this.tokenizer.column;
}
beginStartTag() {
this.currentNode = {
type: 'StartTag',
name: '',
attributes: [],
modifiers: [],
comments: [],
selfClosing: false,
loc: SYNTHETIC
};
}
beginEndTag() {
this.currentNode = {
type: 'EndTag',
name: '',
attributes: [],
modifiers: [],
comments: [],
selfClosing: false,
loc: SYNTHETIC
};
}
finishTag() {
let { line, column } = this.tokenizer;
let tag = this.currentTag;
tag.loc = b.loc(this.tagOpenLine, this.tagOpenColumn, line, column);
if (tag.type === 'StartTag') {
this.finishStartTag();
if (voidMap[tag.name] || tag.selfClosing) {
this.finishEndTag(true);
}
} else if (tag.type === 'EndTag') {
this.finishEndTag(false);
}
}
finishStartTag() {
let { name, attributes, modifiers, comments, selfClosing } = this.currentStartTag;
let loc = b.loc(this.tagOpenLine, this.tagOpenColumn);
let element = b.element({ name, selfClosing }, attributes, modifiers, [], comments, [], loc);
this.elementStack.push(element);
}
finishEndTag(isVoid) {
let tag = this.currentTag;
let element = this.elementStack.pop();
let parent = this.currentElement();
validateEndTag(tag, element, isVoid);
element.loc.end.line = this.tokenizer.line;
element.loc.end.column = this.tokenizer.column;
parseElementBlockParams(element);
appendChild(parent, element);
}
markTagAsSelfClosing() {
this.currentTag.selfClosing = true;
}
// Tags - name
appendToTagName(char) {
this.currentTag.name += char;
}
// Tags - attributes
beginAttribute() {
let tag = this.currentTag;
if (tag.type === 'EndTag') {
throw new SyntaxError(`Invalid end tag: closing tag must not have attributes, ` + `in \`${tag.name}\` (on line ${this.tokenizer.line}).`, tag.loc);
}
this.currentAttribute = {
name: '',
parts: [],
isQuoted: false,
isDynamic: false,
start: b.pos(this.tokenizer.line, this.tokenizer.column),
valueStartLine: 0,
valueStartColumn: 0
};
}
appendToAttributeName(char) {
this.currentAttr.name += char;
}
beginAttributeValue(isQuoted) {
this.currentAttr.isQuoted = isQuoted;
this.currentAttr.valueStartLine = this.tokenizer.line;
this.currentAttr.valueStartColumn = this.tokenizer.column;
}
appendToAttributeValue(char) {
let parts = this.currentAttr.parts;
let lastPart = parts[parts.length - 1];
if (lastPart && lastPart.type === 'TextNode') {
lastPart.chars += char;
// update end location for each added char
lastPart.loc.end.line = this.tokenizer.line;
lastPart.loc.end.column = this.tokenizer.column;
} else {
// initially assume the text node is a single char
let loc = b.loc(this.tokenizer.line, this.tokenizer.column, this.tokenizer.line, this.tokenizer.column);
// correct for `\n` as first char
if (char === '\n') {
loc.start.line -= 1;
loc.start.column = lastPart ? lastPart.loc.end.column : this.currentAttr.valueStartColumn;
}
let text = b.text(char, loc);
parts.push(text);
}
}
finishAttributeValue() {
let { name, parts, isQuoted, isDynamic, valueStartLine, valueStartColumn } = this.currentAttr;
let value = assembleAttributeValue(parts, isQuoted, isDynamic, this.tokenizer.line);
value.loc = b.loc(valueStartLine, valueStartColumn, this.tokenizer.line, this.tokenizer.column);
let loc = b.loc(this.currentAttr.start.line, this.currentAttr.start.column, this.tokenizer.line, this.tokenizer.column);
let attribute = b.attr(name, value, loc);
this.currentStartTag.attributes.push(attribute);
}
reportSyntaxError(message) {
throw new SyntaxError(`Syntax error at line ${this.tokenizer.line} col ${this.tokenizer.column}: ${message}`, b.loc(this.tokenizer.line, this.tokenizer.column));
}
}
function assembleAttributeValue(parts, isQuoted, isDynamic, line) {
if (isDynamic) {
if (isQuoted) {
return assembleConcatenatedValue(parts);
} else {
if (parts.length === 1 || parts.length === 2 && parts[1].type === 'TextNode' && parts[1].chars === '/') {
return parts[0];
} else {
throw new SyntaxError(`An unquoted attribute value must be a string or a mustache, ` + `preceeded by whitespace or a '=' character, and ` + `followed by whitespace, a '>' character, or '/>' (on line ${line})`, b.loc(line, 0));
}
}
} else {
return parts.length > 0 ? parts[0] : b.text('');
}
}
function assembleConcatenatedValue(parts) {
for (let i = 0; i < parts.length; i++) {
let part = parts[i];
if (part.type !== 'MustacheStatement' && part.type !== 'TextNode') {
throw new SyntaxError('Unsupported node in quoted attribute value: ' + part['type'], part.loc);
}
}
return b.concat(parts);
}
function validateEndTag(tag, element, selfClosing) {
let error;
if (voidMap[tag.name] && !selfClosing) {
// EngTag is also called by StartTag for void and self-closing tags (i.e.
// or , so we need to check for that here. Otherwise, we would
// throw an error for those cases.
error = 'Invalid end tag ' + formatEndTagInfo(tag) + ' (void elements cannot have end tags).';
} else if (element.tag === undefined) {
error = 'Closing tag ' + formatEndTagInfo(tag) + ' without an open tag.';
} else if (element.tag !== tag.name) {
error = 'Closing tag ' + formatEndTagInfo(tag) + ' did not match last open tag `' + element.tag + '` (on line ' + element.loc.start.line + ').';
}
if (error) {
throw new SyntaxError(error, element.loc);
}
}
function formatEndTagInfo(tag) {
return '`' + tag.name + '` (on line ' + tag.loc.end.line + ')';
}
const syntax = {
parse: preprocess,
builders: b,
print: build,
traverse,
Walker
};
function preprocess(html, options) {
let ast = typeof html === 'object' ? html : (0, _handlebars.parse)(html);
let program = new TokenizerEventHandlers(html).acceptNode(ast);
if (options && options.plugins && options.plugins.ast) {
for (let i = 0, l = options.plugins.ast.length; i < l; i++) {
let transform = options.plugins.ast[i];
let env = (0, _util.assign)({}, options, { syntax }, { plugins: undefined });
let pluginResult = transform(env);
traverse(program, pluginResult.visitor);
}
}
return program;
}
var nodes = /*#__PURE__*/Object.freeze({});
// used by ember-compiler
exports.AST = nodes;
exports.preprocess = preprocess;
exports.builders = b;
exports.TraversalError = TraversalError;
exports.cannotRemoveNode = cannotRemoveNode;
exports.cannotReplaceNode = cannotReplaceNode;
exports.cannotReplaceOrRemoveInKeyHandlerYet = cannotReplaceOrRemoveInKeyHandlerYet;
exports.traverse = traverse;
exports.Walker = Walker;
exports.print = build;
exports.SyntaxError = SyntaxError;
exports.isLiteral = isLiteral;
exports.printLiteral = printLiteral;
});
enifed('@glimmer/util', ['exports'], function (exports) {
'use strict';
function unwrap(val) {
if (val === null || val === undefined) throw new Error(`Expected value to be present`);
return val;
}
function expect(val, message) {
if (val === null || val === undefined) throw new Error(message);
return val;
}
function unreachable(message = 'unreachable') {
return new Error(message);
}
// import Logger from './logger';
// let alreadyWarned = false;
function debugAssert(test, msg) {
// if (!alreadyWarned) {
// alreadyWarned = true;
// Logger.warn("Don't leave debug assertions on in public builds");
// }
if (!test) {
throw new Error(msg || 'assertion failure');
}
}
const { keys: objKeys } = Object;
function assign(obj) {
for (let i = 1; i < arguments.length; i++) {
let assignment = arguments[i];
if (assignment === null || typeof assignment !== 'object') continue;
let keys = objKeys(assignment);
for (let j = 0; j < keys.length; j++) {
let key = keys[j];
obj[key] = assignment[key];
}
}
return obj;
}
function fillNulls(count) {
let arr = new Array(count);
for (let i = 0; i < count; i++) {
arr[i] = null;
}
return arr;
}
let GUID = 0;
function initializeGuid(object) {
return object._guid = ++GUID;
}
function ensureGuid(object) {
return object._guid || initializeGuid(object);
}
const SERIALIZATION_FIRST_NODE_STRING = '%+b:0%';
function isSerializationFirstNode(node) {
return node.nodeValue === SERIALIZATION_FIRST_NODE_STRING;
}
function dict() {
return Object.create(null);
}
class DictSet {
constructor() {
this.dict = dict();
}
add(obj) {
if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[ensureGuid(obj)] = obj;
return this;
}
delete(obj) {
if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid];
}
}
class Stack {
constructor() {
this.stack = [];
this.current = null;
}
get size() {
return this.stack.length;
}
push(item) {
this.current = item;
this.stack.push(item);
}
pop() {
let item = this.stack.pop();
let len = this.stack.length;
this.current = len === 0 ? null : this.stack[len - 1];
return item === undefined ? null : item;
}
isEmpty() {
return this.stack.length === 0;
}
}
class ListNode {
constructor(value) {
this.next = null;
this.prev = null;
this.value = value;
}
}
class LinkedList {
constructor() {
this.clear();
}
head() {
return this._head;
}
tail() {
return this._tail;
}
clear() {
this._head = this._tail = null;
}
toArray() {
let out = [];
this.forEachNode(n => out.push(n));
return out;
}
nextNode(node) {
return node.next;
}
forEachNode(callback) {
let node = this._head;
while (node !== null) {
callback(node);
node = node.next;
}
}
insertBefore(node, reference = null) {
if (reference === null) return this.append(node);
if (reference.prev) reference.prev.next = node;else this._head = node;
node.prev = reference.prev;
node.next = reference;
reference.prev = node;
return node;
}
append(node) {
let tail = this._tail;
if (tail) {
tail.next = node;
node.prev = tail;
node.next = null;
} else {
this._head = node;
}
return this._tail = node;
}
remove(node) {
if (node.prev) node.prev.next = node.next;else this._head = node.next;
if (node.next) node.next.prev = node.prev;else this._tail = node.prev;
return node;
}
}
class ListSlice {
constructor(head, tail) {
this._head = head;
this._tail = tail;
}
forEachNode(callback) {
let node = this._head;
while (node !== null) {
callback(node);
node = this.nextNode(node);
}
}
head() {
return this._head;
}
tail() {
return this._tail;
}
toArray() {
let out = [];
this.forEachNode(n => out.push(n));
return out;
}
nextNode(node) {
if (node === this._tail) return null;
return node.next;
}
}
const EMPTY_SLICE = new ListSlice(null, null);
const EMPTY_ARRAY = Object.freeze([]);
exports.assert = debugAssert;
exports.assign = assign;
exports.fillNulls = fillNulls;
exports.ensureGuid = ensureGuid;
exports.initializeGuid = initializeGuid;
exports.isSerializationFirstNode = isSerializationFirstNode;
exports.SERIALIZATION_FIRST_NODE_STRING = SERIALIZATION_FIRST_NODE_STRING;
exports.Stack = Stack;
exports.DictSet = DictSet;
exports.dict = dict;
exports.EMPTY_SLICE = EMPTY_SLICE;
exports.LinkedList = LinkedList;
exports.ListNode = ListNode;
exports.ListSlice = ListSlice;
exports.EMPTY_ARRAY = EMPTY_ARRAY;
exports.unwrap = unwrap;
exports.expect = expect;
exports.unreachable = unreachable;
});
enifed("@glimmer/wire-format", ["exports"], function (exports) {
"use strict";
var Opcodes;
(function (Opcodes) {
// Statements
Opcodes[Opcodes["Text"] = 0] = "Text";
Opcodes[Opcodes["Append"] = 1] = "Append";
Opcodes[Opcodes["Comment"] = 2] = "Comment";
Opcodes[Opcodes["Modifier"] = 3] = "Modifier";
Opcodes[Opcodes["Block"] = 4] = "Block";
Opcodes[Opcodes["Component"] = 5] = "Component";
Opcodes[Opcodes["DynamicComponent"] = 6] = "DynamicComponent";
Opcodes[Opcodes["OpenElement"] = 7] = "OpenElement";
Opcodes[Opcodes["OpenSplattedElement"] = 8] = "OpenSplattedElement";
Opcodes[Opcodes["FlushElement"] = 9] = "FlushElement";
Opcodes[Opcodes["CloseElement"] = 10] = "CloseElement";
Opcodes[Opcodes["StaticAttr"] = 11] = "StaticAttr";
Opcodes[Opcodes["DynamicAttr"] = 12] = "DynamicAttr";
Opcodes[Opcodes["AttrSplat"] = 13] = "AttrSplat";
Opcodes[Opcodes["Yield"] = 14] = "Yield";
Opcodes[Opcodes["Partial"] = 15] = "Partial";
Opcodes[Opcodes["DynamicArg"] = 16] = "DynamicArg";
Opcodes[Opcodes["StaticArg"] = 17] = "StaticArg";
Opcodes[Opcodes["TrustingAttr"] = 18] = "TrustingAttr";
Opcodes[Opcodes["Debugger"] = 19] = "Debugger";
Opcodes[Opcodes["ClientSideStatement"] = 20] = "ClientSideStatement";
// Expressions
Opcodes[Opcodes["Unknown"] = 21] = "Unknown";
Opcodes[Opcodes["Get"] = 22] = "Get";
Opcodes[Opcodes["MaybeLocal"] = 23] = "MaybeLocal";
Opcodes[Opcodes["HasBlock"] = 24] = "HasBlock";
Opcodes[Opcodes["HasBlockParams"] = 25] = "HasBlockParams";
Opcodes[Opcodes["Undefined"] = 26] = "Undefined";
Opcodes[Opcodes["Helper"] = 27] = "Helper";
Opcodes[Opcodes["Concat"] = 28] = "Concat";
Opcodes[Opcodes["ClientSideExpression"] = 29] = "ClientSideExpression";
})(Opcodes || (exports.Ops = Opcodes = {}));
function is(variant) {
return function (value) {
return Array.isArray(value) && value[0] === variant;
};
}
// Statements
const isFlushElement = is(Opcodes.FlushElement);
const isAttrSplat = is(Opcodes.AttrSplat);
function isAttribute(val) {
return val[0] === Opcodes.StaticAttr || val[0] === Opcodes.DynamicAttr || val[0] === Opcodes.TrustingAttr;
}
function isArgument(val) {
return val[0] === Opcodes.StaticArg || val[0] === Opcodes.DynamicArg;
}
// Expressions
const isGet = is(Opcodes.Get);
const isMaybeLocal = is(Opcodes.MaybeLocal);
exports.is = is;
exports.isFlushElement = isFlushElement;
exports.isAttrSplat = isAttrSplat;
exports.isAttribute = isAttribute;
exports.isArgument = isArgument;
exports.isGet = isGet;
exports.isMaybeLocal = isMaybeLocal;
exports.Ops = Opcodes;
});
enifed('ember-template-compiler/index', ['exports', 'ember-template-compiler/lib/system/precompile', 'ember-template-compiler/lib/system/compile', 'ember-template-compiler/lib/system/compile-options', 'ember-template-compiler/lib/plugins/index', '@ember/-internals/environment', '@ember/canary-features', 'ember/version', 'ember-template-compiler/lib/compat', 'ember-template-compiler/lib/system/bootstrap', 'ember-template-compiler/lib/system/initializer'], function (exports, _precompile, _compile, _compileOptions, _index, _environment, _canaryFeatures, _version, _compat) {
'use strict';
exports.defaultPlugins = exports.unregisterPlugin = exports.registerPlugin = exports.compileOptions = exports.compile = exports.precompile = exports._Ember = undefined;
Object.defineProperty(exports, 'precompile', {
enumerable: true,
get: function () {
return _precompile.default;
}
});
Object.defineProperty(exports, 'compile', {
enumerable: true,
get: function () {
return _compile.default;
}
});
Object.defineProperty(exports, 'compileOptions', {
enumerable: true,
get: function () {
return _compileOptions.default;
}
});
Object.defineProperty(exports, 'registerPlugin', {
enumerable: true,
get: function () {
return _compileOptions.registerPlugin;
}
});
Object.defineProperty(exports, 'unregisterPlugin', {
enumerable: true,
get: function () {
return _compileOptions.unregisterPlugin;
}
});
Object.defineProperty(exports, 'defaultPlugins', {
enumerable: true,
get: function () {
return _index.default;
}
});
const _Ember = exports._Ember = typeof _environment.context.imports.Ember === 'object' && _environment.context.imports.Ember || {};
// private API used by ember-cli-htmlbars to setup ENV and FEATURES
if (!_Ember.ENV) {
_Ember.ENV = _environment.ENV;
}
if (!_Ember.FEATURES) {
_Ember.FEATURES = _canaryFeatures.FEATURES;
}
if (!_Ember.VERSION) {
_Ember.VERSION = _version.default;
}
// used for adding Ember.Handlebars.compile for backwards compat
(0, _compat.default)(_Ember);
// used to bootstrap templates
// add domTemplates initializer (only does something if `ember-template-compiler`
// is loaded already)
});
enifed('ember-template-compiler/lib/compat', ['exports', 'ember-template-compiler/lib/system/compile', 'ember-template-compiler/lib/system/compile-options', 'ember-template-compiler/lib/system/precompile'], function (exports, _compile, _compileOptions, _precompile) {
'use strict';
exports.default = setupGlobal;
function setupGlobal(Ember) {
let EmberHandlebars = Ember.Handlebars;
if (!EmberHandlebars) {
Ember.Handlebars = EmberHandlebars = {};
}
let EmberHTMLBars = Ember.HTMLBars;
if (!EmberHTMLBars) {
Ember.HTMLBars = EmberHTMLBars = {};
}
EmberHTMLBars.precompile = EmberHandlebars.precompile = _precompile.default;
EmberHTMLBars.compile = EmberHandlebars.compile = _compile.default;
EmberHTMLBars.registerPlugin = _compileOptions.registerPlugin;
}
});
enifed('ember-template-compiler/lib/plugins/assert-if-helper-without-arguments', ['exports', '@ember/debug', 'ember-template-compiler/lib/system/calculate-location-display'], function (exports, _debug, _calculateLocationDisplay) {
'use strict';
exports.default = assertIfHelperWithoutArguments;
function assertIfHelperWithoutArguments(env) {
let { moduleName } = env.meta;
return {
name: 'assert-if-helper-without-arguments',
visitor: {
BlockStatement(node) {
if (isInvalidBlockIf(node)) {
true && !false && (0, _debug.assert)(`${blockAssertMessage(node.path.original)} ${(0, _calculateLocationDisplay.default)(moduleName, node.loc)}`);
}
},
MustacheStatement(node) {
if (isInvalidInlineIf(node)) {
true && !false && (0, _debug.assert)(`${inlineAssertMessage(node.path.original)} ${(0, _calculateLocationDisplay.default)(moduleName, node.loc)}`);
}
},
SubExpression(node) {
if (isInvalidInlineIf(node)) {
true && !false && (0, _debug.assert)(`${inlineAssertMessage(node.path.original)} ${(0, _calculateLocationDisplay.default)(moduleName, node.loc)}`);
}
}
}
};
}
function blockAssertMessage(original) {
return `#${original} requires a single argument.`;
}
function inlineAssertMessage(original) {
return `The inline form of the '${original}' helper expects two or three arguments.`;
}
function isInvalidInlineIf(node) {
return node.path.original === 'if' && (!node.params || node.params.length < 2 || node.params.length > 3);
}
function isInvalidBlockIf(node) {
return node.path.original === 'if' && (!node.params || node.params.length !== 1);
}
});
enifed('ember-template-compiler/lib/plugins/assert-input-helper-without-block', ['exports', '@ember/debug', 'ember-template-compiler/lib/system/calculate-location-display'], function (exports, _debug, _calculateLocationDisplay) {
'use strict';
exports.default = errorOnInputWithContent;
function errorOnInputWithContent(env) {
let { moduleName } = env.meta;
return {
name: 'assert-input-helper-without-block',
visitor: {
BlockStatement(node) {
if (node.path.original !== 'input') {
return;
}
true && !false && (0, _debug.assert)(assertMessage(moduleName, node));
}
}
};
}
function assertMessage(moduleName, node) {
let sourceInformation = (0, _calculateLocationDisplay.default)(moduleName, node.loc);
return `The {{input}} helper cannot be used in block form. ${sourceInformation}`;
}
});
enifed('ember-template-compiler/lib/plugins/assert-local-variable-shadowing-helper-invocation', ['exports', '@ember/debug', 'ember-template-compiler/lib/system/calculate-location-display'], function (exports, _debug, _calculateLocationDisplay) {
'use strict';
exports.default = assertLocalVariableShadowingHelperInvocation;
function assertLocalVariableShadowingHelperInvocation(env) {
let { moduleName } = env.meta;
let locals = [];
return {
name: 'assert-local-variable-shadowing-helper-invocation',
visitor: {
BlockStatement: {
enter(node) {
locals.push(node.program.blockParams);
},
exit() {
locals.pop();
}
},
ElementNode: {
enter(node) {
locals.push(node.blockParams);
},
exit() {
locals.pop();
}
},
SubExpression(node) {
true && !!isLocalVariable(node.path, locals) && (0, _debug.assert)(`${messageFor(node)} ${(0, _calculateLocationDisplay.default)(moduleName, node.loc)}`, !isLocalVariable(node.path, locals));
},
ElementModifierStatement(node) {
// The ElementNode get visited first, but modifiers are more of a sibling
// than a child in the lexical scope (we aren't evaluated in its "block")
// so any locals introduced by the last element doesn't count
true && !!isLocalVariable(node.path, locals.slice(0, -1)) && (0, _debug.assert)(`${messageFor(node)} ${(0, _calculateLocationDisplay.default)(moduleName, node.loc)}`, !isLocalVariable(node.path, locals.slice(0, -1)));
}
}
};
}
function isLocalVariable(node, locals) {
return !node.this && hasLocalVariable(node.parts[0], locals);
}
function hasLocalVariable(name, locals) {
return locals.some(names => names.indexOf(name) !== -1);
}
function messageFor(node) {
let type = isSubExpression(node) ? 'helper' : 'modifier';
let name = node.path.parts[0];
return `Cannot invoke the \`${name}\` ${type} because it was shadowed by a local variable (i.e. a block param) with the same name. Please rename the local variable to resolve the conflict.`;
}
function isSubExpression(node) {
return node.type === 'SubExpression';
}
});
enifed('ember-template-compiler/lib/plugins/assert-reserved-named-arguments', ['exports', '@ember/debug', 'ember-template-compiler/lib/system/calculate-location-display'], function (exports, _debug, _calculateLocationDisplay) {
'use strict';
exports.default = assertReservedNamedArguments;
const RESERVED = ['@arguments', '@args', '@block', '@else'];
let isReserved, assertMessage;
function assertReservedNamedArguments(env) {
let { moduleName } = env.meta;
return {
name: 'assert-reserved-named-arguments',
visitor: {
PathExpression({ original, loc }) {
if (isReserved(original)) {
true && !false && (0, _debug.assert)(`${assertMessage(original)} ${(0, _calculateLocationDisplay.default)(moduleName, loc)}`);
}
}
}
};
}
if (true /* EMBER_GLIMMER_NAMED_ARGUMENTS */) {
isReserved = name => RESERVED.indexOf(name) !== -1 || !!name.match(/^@[^a-z]/);
assertMessage = name => `'${name}' is reserved.`;
} else {
isReserved = name => name[0] === '@';
assertMessage = name => `'${name}' is not a valid path.`;
}
});
enifed('ember-template-compiler/lib/plugins/assert-splattribute-expression', ['exports', '@ember/debug', 'ember-template-compiler/lib/system/calculate-location-display'], function (exports, _debug, _calculateLocationDisplay) {
'use strict';
exports.default = assertSplattributeExpressions;
function assertSplattributeExpressions(env) {
let { moduleName } = env.meta;
return {
name: 'assert-splattribute-expressions',
visitor: {
AttrNode({ name, loc }) {
if (!true /* EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION */ && name === '...attributes') {
true && !false && (0, _debug.assert)(`${errorMessage()} ${(0, _calculateLocationDisplay.default)(moduleName, loc)}`);
}
},
PathExpression({ original, loc }) {
if (original === '...attributes') {
true && !false && (0, _debug.assert)(`${errorMessage()} ${(0, _calculateLocationDisplay.default)(moduleName, loc)}`);
}
}
}
};
}
function errorMessage() {
if (true /* EMBER_GLIMMER_ANGLE_BRACKET_INVOCATION */) {
return `Using "...attributes" can only be used in the element position e.g. . It cannot be used as a path.`;
}
return `...attributes is an invalid path`;
}
});
enifed('ember-template-compiler/lib/plugins/deprecate-send-action', ['exports', '@ember/debug', '@ember/deprecated-features', 'ember-template-compiler/lib/system/calculate-location-display'], function (exports, _debug, _deprecatedFeatures, _calculateLocationDisplay) {
'use strict';
exports.default = deprecateSendAction;
const EVENTS = ['insert-newline', 'enter', 'escape-press', 'focus-in', 'focus-out', 'key-press', 'key-up', 'key-down'];
function deprecateSendAction(env) {
if (_deprecatedFeatures.SEND_ACTION) {
let { moduleName } = env.meta;
let deprecationMessage = (node, evName, action) => {
let sourceInformation = (0, _calculateLocationDisplay.default)(moduleName, node.loc);
return `Please refactor \`{{input ${evName}="${action}"}}\` to \`{{input ${evName}=(action "${action}")}}\. ${sourceInformation}`;
};
return {
name: 'deprecate-send-action',
visitor: {
MustacheStatement(node) {
if (node.path.original !== 'input') {
return;
}
node.hash.pairs.forEach(pair => {
if (EVENTS.indexOf(pair.key) > -1 && pair.value.type === 'StringLiteral') {
true && !false && (0, _debug.deprecate)(deprecationMessage(node, pair.key, pair.value.original), false, {
id: 'ember-component.send-action',
until: '4.0.0',
url: 'https://emberjs.com/deprecations/v3.x#toc_ember-component-send-action'
});
}
});
}
}
};
}
return;
}
});
enifed('ember-template-compiler/lib/plugins/index', ['exports', 'ember-template-compiler/lib/plugins/assert-if-helper-without-arguments', 'ember-template-compiler/lib/plugins/assert-input-helper-without-block', 'ember-template-compiler/lib/plugins/assert-local-variable-shadowing-helper-invocation', 'ember-template-compiler/lib/plugins/assert-reserved-named-arguments', 'ember-template-compiler/lib/plugins/assert-splattribute-expression', 'ember-template-compiler/lib/plugins/deprecate-send-action', 'ember-template-compiler/lib/plugins/transform-action-syntax', 'ember-template-compiler/lib/plugins/transform-angle-bracket-components', 'ember-template-compiler/lib/plugins/transform-attrs-into-args', 'ember-template-compiler/lib/plugins/transform-component-invocation', 'ember-template-compiler/lib/plugins/transform-each-in-into-each', 'ember-template-compiler/lib/plugins/transform-has-block-syntax', 'ember-template-compiler/lib/plugins/transform-in-element', 'ember-template-compiler/lib/plugins/transform-inline-link-to', 'ember-template-compiler/lib/plugins/transform-input-type-syntax', 'ember-template-compiler/lib/plugins/transform-old-class-binding-syntax', 'ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings', 'ember-template-compiler/lib/plugins/transform-top-level-components', '@ember/deprecated-features'], function (exports, _assertIfHelperWithoutArguments, _assertInputHelperWithoutBlock, _assertLocalVariableShadowingHelperInvocation, _assertReservedNamedArguments, _assertSplattributeExpression, _deprecateSendAction, _transformActionSyntax, _transformAngleBracketComponents, _transformAttrsIntoArgs, _transformComponentInvocation, _transformEachInIntoEach, _transformHasBlockSyntax, _transformInElement, _transformInlineLinkTo, _transformInputTypeSyntax, _transformOldClassBindingSyntax, _transformQuotedBindingsIntoJustBindings, _transformTopLevelComponents, _deprecatedFeatures) {
'use strict';
const transforms = [_transformComponentInvocation.default, _transformAngleBracketComponents.default, _transformTopLevelComponents.default, _transformInlineLinkTo.default, _transformOldClassBindingSyntax.default, _transformQuotedBindingsIntoJustBindings.default, _assertReservedNamedArguments.default, _transformActionSyntax.default, _transformInputTypeSyntax.default, _transformAttrsIntoArgs.default, _transformEachInIntoEach.default, _transformHasBlockSyntax.default, _assertLocalVariableShadowingHelperInvocation.default, _assertInputHelperWithoutBlock.default, _transformInElement.default, _assertIfHelperWithoutArguments.default, _assertSplattributeExpression.default];
if (_deprecatedFeatures.SEND_ACTION) {
transforms.push(_deprecateSendAction.default);
}
exports.default = Object.freeze(transforms);
});
enifed('ember-template-compiler/lib/plugins/transform-action-syntax', ['exports'], function (exports) {
'use strict';
exports.default = transformActionSyntax;
/**
@module ember
*/
/**
A Glimmer2 AST transformation that replaces all instances of
```handlebars