Untitled diff

Created Diff never expires
/**
/**
* State-based routing for AngularJS 1.x
* State-based routing for AngularJS 1.x
* NOTICE: This monolithic bundle also bundles the @uirouter/core code.
* NOTICE: This monolithic bundle also bundles the @uirouter/core code.
* This causes it to be incompatible with plugins that depend on @uirouter/core.
* This causes it to be incompatible with plugins that depend on @uirouter/core.
* We recommend switching to the ui-router-core.js and ui-router-angularjs.js bundles instead.
* We recommend switching to the ui-router-core.js and ui-router-angularjs.js bundles instead.
* For more information, see http://ui-router.github.io/blog/angular-ui-router-umd-bundles
* For more information, see http://ui-router.github.io/blog/angular-ui-router-umd-bundles
* @version v1.0.3
* @version v1.0.3
* @link https://ui-router.github.io
* @link https://ui-router.github.io
* @license MIT License, http://www.opensource.org/licenses/MIT
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
*/
(function (global, factory) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('angular')) :
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('angular')) :
typeof define === 'function' && define.amd ? define(['exports', 'angular'], factory) :
typeof define === 'function' && define.amd ? define(['exports', 'angular'], factory) :
(factory((global['@uirouter/angularjs'] = global['@uirouter/angularjs'] || {}),global.angular));
(factory((global['@uirouter/angularjs'] = global['@uirouter/angularjs'] || {}),global.angular));
}(this, (function (exports,ng_from_import) { 'use strict';
}(this, (function (exports,ng_from_import) { 'use strict';


/**
/**
* Higher order functions
* Higher order functions
*
*
* These utility functions are exported, but are subject to change without notice.
* These utility functions are exported, but are subject to change without notice.
*
*
* @module common_hof
* @module common_hof
*/ /** */
*/ /** */
/**
/**
* Returns a new function for [Partial Application](https://en.wikipedia.org/wiki/Partial_application) of the original function.
* Returns a new function for [Partial Application](https://en.wikipedia.org/wiki/Partial_application) of the original function.
*
*
* Given a function with N parameters, returns a new function that supports partial application.
* Given a function with N parameters, returns a new function that supports partial application.
* The new function accepts anywhere from 1 to N parameters. When that function is called with M parameters,
* The new function accepts anywhere from 1 to N parameters. When that function is called with M parameters,
* where M is less than N, it returns a new function that accepts the remaining parameters. It continues to
* where M is less than N, it returns a new function that accepts the remaining parameters. It continues to
* accept more parameters until all N parameters have been supplied.
* accept more parameters until all N parameters have been supplied.
*
*
*
*
* This contrived example uses a partially applied function as an predicate, which returns true
* This contrived example uses a partially applied function as an predicate, which returns true
* if an object is found in both arrays.
* if an object is found in both arrays.
* @example
* @example
* ```
* ```
* // returns true if an object is in both of the two arrays
* // returns true if an object is in both of the two arrays
* function inBoth(array1, array2, object) {
* function inBoth(array1, array2, object) {
* return array1.indexOf(object) !== -1 &&
* return array1.indexOf(object) !== -1 &&
* array2.indexOf(object) !== 1;
* array2.indexOf(object) !== 1;
* }
* }
* let obj1, obj2, obj3, obj4, obj5, obj6, obj7
* let obj1, obj2, obj3, obj4, obj5, obj6, obj7
* let foos = [obj1, obj3]
* let foos = [obj1, obj3]
* let bars = [obj3, obj4, obj5]
* let bars = [obj3, obj4, obj5]
*
*
* // A curried "copy" of inBoth
* // A curried "copy" of inBoth
* let curriedInBoth = curry(inBoth);
* let curriedInBoth = curry(inBoth);
* // Partially apply both the array1 and array2
* // Partially apply both the array1 and array2
* let inFoosAndBars = curriedInBoth(foos, bars);
* let inFoosAndBars = curriedInBoth(foos, bars);
*
*
* // Supply the final argument; since all arguments are
* // Supply the final argument; since all arguments are
* // supplied, the original inBoth function is then called.
* // supplied, the original inBoth function is then called.
* let obj1InBoth = inFoosAndBars(obj1); // false
* let obj1InBoth = inFoosAndBars(obj1); // false
*
*
* // Use the inFoosAndBars as a predicate.
* // Use the inFoosAndBars as a predicate.
* // Filter, on each iteration, supplies the final argument
* // Filter, on each iteration, supplies the final argument
* let allObjs = [ obj1, obj2, obj3, obj4, obj5, obj6, obj7 ];
* let allObjs = [ obj1, obj2, obj3, obj4, obj5, obj6, obj7 ];
* let foundInBoth = allObjs.filter(inFoosAndBars); // [ obj3 ]
* let foundInBoth = allObjs.filter(inFoosAndBars); // [ obj3 ]
*
*
* ```
* ```
*
*
* Stolen from: http://stackoverflow.com/questions/4394747/javascript-curry-function
* Stolen from: http://stackoverflow.com/questions/4394747/javascript-curry-function
*
*
* @param fn
* @param fn
* @returns {*|function(): (*|any)}
* @returns {*|function(): (*|any)}
*/
*/
function curry(fn) {
function curry(fn) {
var initial_args = [].slice.apply(arguments, [1]);
var initial_args = [].slice.apply(arguments, [1]);
var func_args_length = fn.length;
var func_args_length = fn.length;
function curried(args) {
function curried(args) {
if (args.length >= func_args_length)
if (args.length >= func_args_length)
return fn.apply(null, args);
return fn.apply(null, args);
return function () {
return function () {
return curried(args.concat([].slice.apply(arguments)));
return curried(args.concat([].slice.apply(arguments)));
};
};
}
}
return curried(initial_args);
return curried(initial_args);
}
}
/**
/**
* Given a varargs list of functions, returns a function that composes the argument functions, right-to-left
* Given a varargs list of functions, returns a function that composes the argument functions, right-to-left
* given: f(x), g(x), h(x)
* given: f(x), g(x), h(x)
* let composed = compose(f,g,h)
* let composed = compose(f,g,h)
* then, composed is: f(g(h(x)))
* then, composed is: f(g(h(x)))
*/
*/
function compose() {
function compose() {
var args = arguments;
var args = arguments;
var start = args.length - 1;
var start = args.length - 1;
return function () {
return function () {
var i = start, result = args[start].apply(this, arguments);
var i = start, result = args[start].apply(this, arguments);
while (i--)
while (i--)
result = args[i].call(this, result);
result = args[i].call(this, result);
return result;
return result;
};
};
}
}
/**
/**
* Given a varargs list of functions, returns a function that is composes the argument functions, left-to-right
* Given a varargs list of functions, returns a function that is composes the argument functions, left-to-right
* given: f(x), g(x), h(x)
* given: f(x), g(x), h(x)
* let piped = pipe(f,g,h);
* let piped = pipe(f,g,h);
* then, piped is: h(g(f(x)))
* then, piped is: h(g(f(x)))
*/
*/
function pipe() {
function pipe() {
var funcs = [];
var funcs = [];
for (var _i = 0; _i < arguments.length; _i++) {
for (var _i = 0; _i < arguments.length; _i++) {
funcs[_i] = arguments[_i];
funcs[_i] = arguments[_i];
}
}
return compose.apply(null, [].slice.call(arguments).reverse());
return compose.apply(null, [].slice.call(arguments).reverse());
}
}
/**
/**
* Given a property name, returns a function that returns that property from an object
* Given a property name, returns a function that returns that property from an object
* let obj = { foo: 1, name: "blarg" };
* let obj = { foo: 1, name: "blarg" };
* let getName = prop("name");
* let getName = prop("name");
* getName(obj) === "blarg"
* getName(obj) === "blarg"
*/
*/
var prop = function (name) {
var prop = function (name) {
return function (obj) { return obj && obj[name]; };
return function (obj) { return obj && obj[name]; };
};
};
/**
/**
* Given a property name and a value, returns a function that returns a boolean based on whether
* Given a property name and a value, returns a function that returns a boolean based on whether
* the passed object has a property that matches the value
* the passed object has a property that matches the value
* let obj = { foo: 1, name: "blarg" };
* let obj = { foo: 1, name: "blarg" };
* let getName = propEq("name", "blarg");
* let getName = propEq("name", "blarg");
* getName(obj) === true
* getName(obj) === true
*/
*/
var propEq = curry(function (name, val, obj) { return obj && obj[name] === val; });
var propEq = curry(function (name, val, obj) { return obj && obj[name] === val; });
/**
/**
* Given a dotted property name, returns a function that returns a nested property from an object, or undefined
* Given a dotted property name, returns a function that returns a nested property from an object, or undefined
* let obj = { id: 1, nestedObj: { foo: 1, name: "blarg" }, };
* let obj = { id: 1, nestedObj: { foo: 1, name: "blarg" }, };
* let getName = prop("nestedObj.name");
* let getName = prop("nestedObj.name");
* getName(obj) === "blarg"
* getName(obj) === "blarg"
* let propNotFound = prop("this.property.doesnt.exist");
* let propNotFound = prop("this.property.doesnt.exist");
* propNotFound(obj) === undefined
* propNotFound(obj) === undefined
*/
*/
var parse = function (name) {
var parse = function (name) {
return pipe.apply(null, name.split(".").map(prop));
return pipe.apply(null, name.split(".").map(prop));
};
};
/**
/**
* Given a function that returns a truthy or falsey value, returns a
* Given a function that returns a truthy or falsey value, returns a
* function that returns the opposite (falsey or truthy) value given the same inputs
* function that returns the opposite (falsey or truthy) value given the same inputs
*/
*/
var not = function (fn) {
var not = function (fn) {
return function () {
return function () {
var args = [];
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
args[_i] = arguments[_i];
}
}
return !fn.apply(null, args);
return !fn.apply(null, args);
};
};
};
};
/**
/**
* Given two functions that return truthy or falsey values, returns a function that returns truthy
* Given two functions that return truthy or falsey values, returns a function that returns truthy
* if both functions return truthy for the given arguments
* if both functions return truthy for the given arguments
*/
*/
function and(fn1, fn2) {
function and(fn1, fn2) {
return function () {
return function () {
var args = [];
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
args[_i] = arguments[_i];
}
}
return fn1.apply(null, args) && fn2.apply(null, args);
return fn1.apply(null, args) && fn2.apply(null, args);
};
};
}
}
/**
/**
* Given two functions that return truthy or falsey values, returns a function that returns truthy
* Given two functions that return truthy or falsey values, returns a function that returns truthy
* if at least one of the functions returns truthy for the given arguments
* if at least one of the functions returns truthy for the given arguments
*/
*/
function or(fn1, fn2) {
function or(fn1, fn2) {
return function () {
return function () {
var args = [];
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
args[_i] = arguments[_i];
}
}
return fn1.apply(null, args) || fn2.apply(null, args);
return fn1.apply(null, args) || fn2.apply(null, args);
};
};
}
}
/**
/**
* Check if all the elements of an array match a predicate function
* Check if all the elements of an array match a predicate function
*
*
* @param fn1 a predicate function `fn1`
* @param fn1 a predicate function `fn1`
* @returns a function which takes an array and returns true if `fn1` is true for all elements of the array
* @returns a function which takes an array and returns true if `fn1` is true for all elements of the array
*/
*/
var all = function (fn1) {
var all = function (fn1) {
return function (arr) { return arr.reduce(function (b, x) { return b && !!fn1(x); }, true); };
return function (arr) { return arr.reduce(function (b, x) { return b && !!fn1(x); }, true); };
};
};
var any = function (fn1) {
var any = function (fn1) {
return function (arr) { return arr.reduce(function (b, x) { return b || !!fn1(x); }, false); };
return function (arr) { return arr.reduce(function (b, x) { return b || !!fn1(x); }, false); };
};
};
/** Given a class, returns a Predicate function that returns true if the object is of that class */
/** Given a class, returns a Predicate function that returns true if the object is of that class */
var is = function (ctor) {
var is = function (ctor) {
return function (obj) {
return function (obj) {
return (obj != null && obj.constructor === ctor || obj instanceof ctor);
return (obj != null && obj.constructor === ctor || obj instanceof ctor);
};
};
};
};
/** Given a value, returns a Predicate function that returns true if another value is === equal to the original value */
/** Given a value, returns a Predicate function that returns true if another value is === equal to the original value */
var eq = function (val) { return function (other) {
var eq = function (val) { return function (other) {
return val === other;
return val === other;
}; };
}; };
/** Given a value, returns a function which returns the value */
/** Given a value, returns a function which returns the value */
var val = function (v) { return function () { return v; }; };
var val = function (v) { return function () { return v; }; };
function invoke(fnName, args) {
function invoke(fnName, args) {
return function (obj) {
return function (obj) {
return obj[fnName].apply(obj, args);
return obj[fnName].apply(obj, args);
};
};
}
}
/**
/**
* Sorta like Pattern Matching (a functional programming conditional construct)
* Sorta like Pattern Matching (a functional programming conditional construct)
*
*
* See http://c2.com/cgi/wiki?PatternMatching
* See http://c2.com/cgi/wiki?PatternMatching
*
*
* This is a conditional construct which allows a series of predicates and output functions
* This is a conditional construct which allows a series of predicates and output functions
* to be checked and then applied. Each predicate receives the input. If the predicate
* to be checked and then applied. Each predicate receives the input. If the predicate
* returns truthy, then its matching output function (mapping function) is provided with
* returns truthy, then its matching output function (mapping function) is provided with
* the input and, then the result is returned.
* the input and, then the result is returned.
*
*
* Each combination (2-tuple) of predicate + output function should be placed in an array
* Each combination (2-tuple) of predicate + output function should be placed in an array
* of size 2: [ predicate, mapFn ]
* of size 2: [ predicate, mapFn ]
*
*
* These 2-tuples should be put in an outer array.
* These 2-tuples should be put in an outer array.
*
*
* @example
* @example
* ```
* ```
*
*
* // Here's a 2-tuple where the first element is the isString predicate
* // Here's a 2-tuple where the first element is the isString predicate
* // and the second element is a function that returns a description of the input
* // and the second element is a function that returns a description of the input
* let firstTuple = [ angular.isString, (input) => `Heres your string ${input}` ];
* let firstTuple = [ angular.isString, (input) => `Heres your string ${input}` ];
*
*
* // Second tuple: predicate "isNumber", mapfn returns a description
* // Second tuple: predicate "isNumber", mapfn returns a description
* let secondTuple = [ angular.isNumber, (input) => `(${input}) That's a number!` ];
* let secondTuple = [ angular.isNumber, (input) => `(${input}) That's a number!` ];
*
*
* let third = [ (input) => input === null, (input) => `Oh, null...` ];
* let third = [ (input) => input === null, (input) => `Oh, null...` ];
*
*
* let fourth = [ (input) => input === undefined, (input) => `notdefined` ];
* let fourth = [ (input) => input === undefined, (input) => `notdefined` ];
*
*
* let descriptionOf = pattern([ firstTuple, secondTuple, third, fourth ]);
* let descriptionOf = pattern([ firstTuple, secondTuple, third, fourth ]);
*
*
* console.log(descriptionOf(undefined)); // 'notdefined'
* console.log(descriptionOf(undefined)); // 'notdefined'
* console.log(descriptionOf(55)); // '(55) That's a number!'
* console.log(descriptionOf(55)); // '(55) That's a number!'
* console.log(descriptionOf("foo")); // 'Here's your string foo'
* console.log(descriptionOf("foo")); // 'Here's your string foo'
* ```
* ```
*
*
* @param struct A 2D array. Each element of the array should be an array, a 2-tuple,
* @param struct A 2D array. Each element of the array should be an array, a 2-tuple,
* with a Predicate and a mapping/output function
* with a Predicate and a mapping/output function
* @returns {function(any): *}
* @returns {function(any): *}
*/
*/
function pattern(struct) {
function pattern(struct) {
return function (x) {
return function (x) {
for (var i = 0; i < struct.length; i++) {
for (var i = 0; i < struct.length; i++) {
if (struct[i][0](x))
if (struct[i][0](x))
return struct[i][1](x);
return struct[i][1](x);
}
}
};
};
}
}


/**
/**
* @coreapi
* @coreapi
* @module core
* @module core
*/
*/
/**
/**
* Matches state names using glob-like pattern strings.
* Matches state names using glob-like pattern strings.
*
*
* Globs can be used in specific APIs including:
* Globs can be used in specific APIs including:
*
*
* - [[StateService.is]]
* - [[StateService.is]]
* - [[StateService.includes]]
* - [[StateService.includes]]
* - The first argument to Hook Registration functions like [[TransitionService.onStart]]
* - The first argument to Hook Registration functions like [[TransitionService.onStart]]
* - [[HookMatchCriteria]] and [[HookMatchCriterion]]
* - [[HookMatchCriteria]] and [[HookMatchCriterion]]
*
*
* A `Glob` string is a pattern which matches state names.
* A `Glob` string is a pattern which matches state names.
* Nested state names are split into segments (separated by a dot) when processing.
* Nested state names are split into segments (separated by a dot) when processing.
* The state named `foo.bar.baz` is split into three segments ['foo', 'bar', 'baz']
* The state named `foo.bar.baz` is split into three segments ['foo', 'bar', 'baz']
*
*
* Globs work according to the following rules:
* Globs work according to the following rules:
*
*
* ### Exact match:
* ### Exact match:
*
*
* The glob `'A.B'` matches the state named exactly `'A.B'`.
* The glob `'A.B'` matches the state named exactly `'A.B'`.
*
*
* | Glob |Matches states named|Does not match state named|
* | Glob |Matches states named|Does not match state named|
* |:------------|:--------------------|:---------------------|
* |:------------|:--------------------|:---------------------|
* | `'A'` | `'A'` | `'B'` , `'A.C'` |
* | `'A'` | `'A'` | `'B'` , `'A.C'` |
* | `'A.B'` | `'A.B'` | `'A'` , `'A.B.C'` |
* | `'A.B'` | `'A.B'` | `'A'` , `'A.B.C'` |
* | `'foo'` | `'foo'` | `'FOO'` , `'foo.bar'`|
* | `'foo'` | `'foo'` | `'FOO'` , `'foo.bar'`|
*
*
* ### Single star (`*`)
* ### Single star (`*`)
*
*
* A single star (`*`) is a wildcard that matches exactly one segment.
* A single star (`*`) is a wildcard that matches exactly one segment.
*
*
* | Glob |Matches states named |Does not match state named |
* | Glob |Matches states named |Does not match state named |
* |:------------|:---------------------|:--------------------------|
* |:------------|:---------------------|:--------------------------|
* | `'*'` | `'A'` , `'Z'` | `'A.B'` , `'Z.Y.X'` |
* | `'*'` | `'A'` , `'Z'` | `'A.B'` , `'Z.Y.X'` |
* | `'A.*'` | `'A.B'` , `'A.C'` | `'A'` , `'A.B.C'` |
* | `'A.*'` | `'A.B'` , `'A.C'` | `'A'` , `'A.B.C'` |
* | `'A.*.*'` | `'A.B.C'` , `'A.X.Y'`| `'A'`, `'A.B'` , `'Z.Y.X'`|
* | `'A.*.*'` | `'A.B.C'` , `'A.X.Y'`| `'A'`, `'A.B'` , `'Z.Y.X'`|
*
*
* ### Double star (`**`)
* ### Double star (`**`)
*
*
* A double star (`'**'`) is a wildcard that matches *zero or more segments*
* A double star (`'**'`) is a wildcard that matches *zero or more segments*
*
*
* | Glob |Matches states named |Does not match state named |
* | Glob |Matches states named |Does not match state named |
* |:------------|:----------------------------------------------|:----------------------------------|
* |:------------|:----------------------------------------------|:----------------------------------|
* | `'**'` | `'A'` , `'A.B'`, `'Z.Y.X'` | (matches all states) |
* | `'**'` | `'A'` , `'A.B'`, `'Z.Y.X'` | (matches all states) |
* | `'A.**'` | `'A'` , `'A.B'` , `'A.C.X'` | `'Z.Y.X'` |
* | `'A.**'` | `'A'` , `'A.B'` , `'A.C.X'` | `'Z.Y.X'` |
* | `'**.X'` | `'X'` , `'A.X'` , `'Z.Y.X'` | `'A'` , `'A.login.Z'` |
* | `'**.X'` | `'X'` , `'A.X'` , `'Z.Y.X'` | `'A'` , `'A.login.Z'` |
* | `'A.**.X'` | `'A.X'` , `'A.B.X'` , `'A.B.C.X'` | `'A'` , `'A.B.C'` |
* | `'A.**.X'` | `'A.X'` , `'A.B.X'` , `'A.B.C.X'` | `'A'` , `'A.B.C'` |
*
*
*/
*/
var Glob = (function () {
var Glob = (function () {
function Glob(text) {
function Glob(text) {
this.text = text;
this.text = text;
this.glob = text.split('.');
this.glob = text.split('.');
var regexpString = this.text.split('.')
var regexpString = this.text.split('.')
.map(function (seg) {
.map(function (seg) {
if (seg === '**')
if (seg === '**')
return '(?:|(?:\\.[^.]*)*)';
return '(?:|(?:\\.[^.]*)*)';
if (seg === '*')
if (seg === '*')
return '\\.[^.]*';
return '\\.[^.]*';
return '\\.' + seg;
return '\\.' + seg;
}).join('');
}).join('');
this.regexp = new RegExp("^" + regexpString + "$");
this.regexp = new RegExp("^" + regexpString + "$");
}
}
Glob.prototype.matches = function (name) {
Glob.prototype.matches = function (name) {
return this.regexp.test('.' + name);
return this.regexp.test('.' + name);
};
};
/** Returns true if the string has glob-like characters in it */
/** Returns true if the string has glob-like characters in it */
Glob.is = function (text) {
Glob.is = function (text) {
return !!/[!,*]+/.exec(text);
return !!/[!,*]+/.exec(text);
};
};
/** Returns a glob from the string, or null if the string isn't Glob-like */
/** Returns a glob from the string, or null if the string isn't Glob-like */
Glob.fromString = function (text) {
Glob.fromString = function (text) {
return Glob.is(text) ? new Glob(text) : null;
return Glob.is(text) ? new Glob(text) : null;
};
};
return Glob;
return Glob;
}());
}());


/**
/**
* Internal representation of a UI-Router state.
* Internal representation of a UI-Router state.
*
*
* Instances of this class are created when a [[StateDeclaration]] is registered with the [[StateRegistry]].
* Instances of this class are created when a [[StateDeclaration]] is registered with the [[StateRegistry]].
*
*
* A registered [[StateDeclaration]] is augmented with a getter ([[StateDeclaration.$$state]]) which returns the corresponding [[StateObject]] object.
* A registered [[StateDeclaration]] is augmented with a getter ([[StateDeclaration.$$state]]) which returns the corresponding [[StateObject]] object.
*
*
* This class prototypally inherits from the corresponding [[StateDeclaration]].
* This class prototypally inherits from the corresponding [[StateDeclaration]].
* Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].
* Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].
*/
*/
var StateObject = (function () {
var StateObject = (function () {
/** @deprecated use State.create() */
/** @deprecated use State.create() */
function StateObject(config) {
function StateObject(config) {
return StateObject.create(config || {});
return StateObject.create(config || {});
}
}
/**
/**
* Create a state object to put the private/internal implementation details onto.
* Create a state object to put the private/internal implementation details onto.
* The object's prototype chain looks like:
* The object's prototype chain looks like:
* (Internal State Object) -> (Copy of State.prototype) -> (State Declaration object) -> (State Declaration's prototype...)
* (Internal State Object) -> (Copy of State.prototype) -> (State Declaration object) -> (State Declaration's prototype...)
*
*
* @param stateDecl the user-supplied State Declaration
* @param stateDecl the user-supplied State Declaration
* @returns {StateObject} an internal State object
* @returns {StateObject} an internal State object
*/
*/
StateObject.create = function (stateDecl) {
StateObject.create = function (stateDecl) {
stateDecl = StateObject.isStateClass(stateDecl) ? new stateDecl() : stateDecl;
stateDecl = StateObject.isStateClass(stateDecl) ? new stateDecl() : stateDecl;
var state = inherit(inherit(stateDecl, StateObject.prototype));
var state = inherit(inherit(stateDecl, StateObject.prototype));
stateDecl.$$state = function () { return state; };
stateDecl.$$state = function () { return state; };
state.self = stateDecl;
state.self = stateDecl;
state.__stateObjectCache = {
state.__stateObjectCache = {
nameGlob: Glob.fromString(state.name) // might return null
nameGlob: Glob.fromString(state.name) // might return null
};
};
return state;
return state;
};
};
/**
/**
* Returns true if the provided parameter is the same state.
* Returns true if the provided parameter is the same state.
*
*
* Compares the identity of the state against the passed value, which is either an object
* Compares the identity of the state against the passed value, which is either an object
* reference to the actual `State` instance, the original definition object passed to
* reference to the actual `State` instance, the original definition object passed to
* `$stateProvider.state()`, or the fully-qualified name.
* `$stateProvider.state()`, or the fully-qualified name.
*
*
* @param ref Can be one of (a) a `State` instance, (b) an object that was passed
* @param ref Can be one of (a) a `State` instance, (b) an object that was passed
* into `$stateProvider.state()`, (c) the fully-qualified name of a state as a string.
* into `$stateProvider.state()`, (c) the fully-qualified name of a state as a string.
* @returns Returns `true` if `ref` matches the current `State` instance.
* @returns Returns `true` if `ref` matches the current `State` instance.
*/
*/
StateObject.prototype.is = function (ref) {
StateObject.prototype.is = function (ref) {
return this === ref || this.self === ref || this.fqn() === ref;
return this === ref || this.self === ref || this.fqn() === ref;
};
};
/**
/**
* @deprecated this does not properly handle dot notation
* @deprecated this does not properly handle dot notation
* @returns Returns a dot-separated name of the state.
* @returns Returns a dot-separated name of the state.
*/
*/
StateObject.prototype.fqn = function () {
StateObject.prototype.fqn = function () {
if (!this.parent || !(this.parent instanceof this.constructor))
if (!this.parent || !(this.parent instanceof this.constructor))
return this.name;
return this.name;
var name = this.parent.fqn();
var name = this.parent.fqn();
return name ? name + "." + this.name : this.name;
return name ? name + "." + this.name : this.name;
};
};
/**
/**
* Returns the root node of this state's tree.
* Returns the root node of this state's tree.
*
*
* @returns The root of this state's tree.
* @returns The root of this state's tree.
*/
*/
StateObject.prototype.root = function () {
StateObject.prototype.root = function () {
return this.parent && this.parent.root() || this;
return this.parent && this.parent.root() || this;
};
};
/**
/**
* Gets the state's `Param` objects
* Gets the state's `Param` objects
*
*
* Gets the list of [[Param]] objects owned by the state.
* Gets the list of [[Param]] objects owned by the state.
* If `opts.inherit` is true, it also includes the ancestor states' [[Param]] objects.
* If `opts.inherit` is true, it also includes the ancestor states' [[Param]] objects.
* If `opts.matchingKeys` exists, returns only `Param`s whose `id` is a key on the `matchingKeys` object
* If `opts.matchingKeys` exists, returns only `Param`s whose `id` is a key on the `matchingKeys` object
*
*
* @param opts options
* @param opts options
*/
*/
StateObject.prototype.parameters = function (opts) {
StateObject.prototype.parameters = function (opts) {
opts = defaults(opts, { inherit: true, matchingKeys: null });
opts = defaults(opts, { inherit: true, matchingKeys: null });
var inherited = opts.inherit && this.parent && this.parent.parameters() || [];
var inherited = opts.inherit && this.parent && this.parent.parameters() || [];
return inherited.concat(values(this.params))
return inherited.concat(values(this.params))
.filter(function (param) { return !opts.matchingKeys || opts.matchingKeys.hasOwnProperty(param.id); });
.filter(function (param) { return !opts.matchingKeys || opts.matchingKeys.hasOwnProperty(param.id); });
};
};
/**
/**
* Returns a single [[Param]] that is owned by the state
* Returns a single [[Param]] that is owned by the state
*
*
* If `opts.inherit` is true, it also searches the ancestor states` [[Param]]s.
* If `opts.inherit` is true, it also searches the ancestor states` [[Param]]s.
* @param id the name of the [[Param]] to return
* @param id the name of the [[Param]] to return
* @param opts options
* @param opts options
*/
*/
StateObject.prototype.parameter = function (id, opts) {
StateObject.prototype.parameter = function (id, opts) {
if (opts === void 0) { opts = {}; }
if (opts === void 0) { opts = {}; }
return (this.url && this.url.parameter(id, opts) ||
return (this.url && this.url.parameter(id, opts) ||
find(values(this.params), propEq('id', id)) ||
find(values(this.params), propEq('id', id)) ||
opts.inherit && this.parent && this.parent.parameter(id));
opts.inherit && this.parent && this.parent.parameter(id));
};
};
StateObject.prototype.toString = function () {
StateObject.prototype.toString = function () {
return this.fqn();
return this.fqn();
};
};
return StateObject;
return StateObject;
}());
}());
/** Predicate which returns true if the object is an class with @State() decorator */
/** Predicate which returns true if the object is an class with @State() decorator */
StateObject.isStateClass = function (stateDecl) {
StateObject.isStateClass = function (stateDecl) {
return isFunction(stateDecl) && stateDecl['__uiRouterState'] === true;
return isFunction(stateDecl) && stateDecl['__uiRouterState'] === true;
};
};
/** Predicate which returns true if the object is an internal [[StateObject]] object */
/** Predicate which returns true if the object is an internal [[StateObject]] object */
StateObject.isState = function (obj) {
StateObject.isState = function (obj) {
return isObject(obj['__stateObjectCache']);
return isObject(obj['__stateObjectCache']);
};
};


/** Predicates
/** Predicates
*
*
* These predicates return true/false based on the input.
* These predicates return true/false based on the input.
* Although these functions are exported, they are subject to change without notice.
* Although these functions are exported, they are subject to change without notice.
*
*
* @module common_predicates
* @module common_predicates
*/
*/
/** */
/** */
var toStr = Object.prototype.toString;
var toStr = Object.prototype.toString;
var tis = function (t) { return function (x) { return typeof (x) === t; }; };
var tis = function (t) { return function (x) { return typeof (x) === t; }; };
var isUndefined = tis('undefined');
var isUndefined = tis('undefined');
var isDefined = not(isUndefined);
var isDefined = not(isUndefined);
var isNull = function (o) { return o === null; };
var isNull = function (o) { return o === null; };
var isNullOrUndefined = or(isNull, isUndefined);
var isNullOrUndefined = or(isNull, isUndefined);
var isFunction = tis('function');
var isFunction = tis('function');
var isNumber = tis('number');
var isNumber = tis('number');
var isString = tis('string');
var isString = tis('string');
var isObject = function (x) { return x !== null && typeof x === 'object'; };
var isObject = function (x) { return x !== null && typeof x === 'object'; };
var isArray = Array.isArray;
var isArray = Array.isArray;
var isDate = (function (x) { return toStr.call(x) === '[object Date]'; });
var isDate = (function (x) { return toStr.call(x) === '[object Date]'; });
var isRegExp = (function (x) { return toStr.call(x) === '[object RegExp]'; });
var isRegExp = (function (x) { return toStr.call(x) === '[object RegExp]'; });
var isState = StateObject.isState;
var isState = StateObject.isState;
/**
/**
* Predicate which checks if a value is injectable
* Predicate which checks if a value is injectable
*
*
* A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array
* A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array
* where all the elements in the array are Strings, except the last one, which is a Function
* where all the elements in the array are Strings, except the last one, which is a Function
*/
*/
function isInjectable(val$$1) {
function isInjectable(val$$1) {
if (isArray(val$$1) && val$$1.length) {
if (isArray(val$$1) && val$$1.length) {
var head = val$$1.slice(0, -1), tail = val$$1.slice(-1);
var head = val$$1.slice(0, -1), tail = val$$1.slice(-1);
return !(head.filter(not(isString)).length || tail.filter(not(isFunction)).length);
return !(head.filter(not(isString)).length || tail.filter(not(isFunction)).length);
}
}
return isFunction(val$$1);
return isFunction(val$$1);
}
}
/**
/**
* Predicate which checks if a value looks like a Promise
* Predicate which checks if a value looks like a Promise
*
*
* It is probably a Promise if it's an object, and it has a `then` property which is a Function
* It is probably a Promise if it's an object, and it has a `then` property which is a Function
*/
*/
var isPromise = and(isObject, pipe(prop('then'), isFunction));
var isPromise = and(isObject, pipe(prop('then'), isFunction));


var notImplemented = function (fnname) { return function () {
var notImplemented = function (fnname) { return function () {
throw new Error(fnname + "(): No coreservices implementation for UI-Router is loaded.");
throw new Error(fnname + "(): No coreservices implementation for UI-Router is loaded.");
}; };
}; };
var services = {
var services = {
$q: undefined,
$q: undefined,
$injector: undefined,
$injector: undefined,
};
};


/**
/**
* Random utility functions used in the UI-Router code
* Random utility functions used in the UI-Router code
*
*
* These functions are exported, but are subject to change without notice.
* These functions are exported, but are subject to change without notice.
*
*
* @preferred
* @preferred
* @module common
* @module common
*/
*/
/** for typedoc */
/** for typedoc */
var w = typeof window === 'undefined' ? {} : window;
var w = typeof window === 'undefined' ? {} : window;
var angular$1 = w.angular || {};
var angular$1 = w.angular || {};
var fromJson = angular$1.fromJson || JSON.parse.bind(JSON);
var fromJson = angular$1.fromJson || JSON.parse.bind(JSON);
var toJson = angular$1.toJson || JSON.stringify.bind(JSON);
var toJson = angular$1.toJson || JSON.stringify.bind(JSON);
var copy = angular$1.copy || _copy;
var copy = angular$1.copy || _copy;
var forEach = angular$1.forEach || _forEach;
var forEach = angular$1.forEach || _forEach;
var extend = Object.assign || _extend;
var extend = Object.assign || _extend;
var equals = angular$1.equals || _equals;
var equals = angular$1.equals || _equals;
function identity(x) { return x; }
function identity(x) { return x; }
function noop$1() { }
function noop$1() { }
/**
/**
* Builds proxy functions on the `to` object which pass through to the `from` object.
* Builds proxy functions on the `to` object which pass through to the `from` object.
*
*
* For each key in `fnNames`, creates a proxy function on the `to` object.
* For each key in `fnNames`, creates a proxy function on the `to` object.
* The proxy function calls the real function on the `from` object.
* The proxy function calls the real function on the `from` object.
*
*
*
*
* #### Example:
* #### Example:
* This example creates an new class instance whose functions are prebound to the new'd object.
* This example creates an new class instance whose functions are prebound to the new'd object.
* ```js
* ```js
* class Foo {
* class Foo {
* constructor(data) {
* constructor(data) {
* // Binds all functions from Foo.prototype to 'this',
* // Binds all functions from Foo.prototype to 'this',
* // then copies them to 'this'
* // then copies them to 'this'
* bindFunctions(Foo.prototype, this, this);
* bindFunctions(Foo.prototype, this, this);
* this.data = data;
* this.data = data;
* }
* }
*
*
* log() {
* log() {
* console.log(this.data);
* console.log(this.data);
* }
* }
* }
* }
*
*
* let myFoo = new Foo([1,2,3]);
* let myFoo = new Foo([1,2,3]);
* var logit = myFoo.log;
* var logit = myFoo.log;
* logit(); // logs [1, 2, 3] from the myFoo 'this' instance
* logit(); // logs [1, 2, 3] from the myFoo 'this' instance
* ```
* ```
*
*
* #### Example:
* #### Example:
* This example creates a bound version of a service function, and copies it to another object
* This example creates a bound version of a service function, and copies it to another object
* ```
* ```
*
*
* var SomeService = {
* var SomeService = {
* this.data = [3, 4, 5];
* this.data = [3, 4, 5];
* this.log = function() {
* this.log = function() {
* console.log(this.data);
* console.log(this.data);
* }
* }
* }
* }
*
*
* // Constructor fn
* // Constructor fn
* function OtherThing() {
* function OtherThing() {
* // Binds all functions from SomeService to SomeService,
* // Binds all functions from SomeService to SomeService,
* // then copies them to 'this'
* // then copies them to 'this'
* bindFunctions(SomeService, this, SomeService);
* bindFunctions(SomeService, this, SomeService);
* }
* }
*
*
* let myOtherThing = new OtherThing();
* let myOtherThing = new OtherThing();
* myOtherThing.log(); // logs [3, 4, 5] from SomeService's 'this'
* myOtherThing.log(); // logs [3, 4, 5] from SomeService's 'this'
* ```
* ```
*
*
* @param source A function that returns the source object which contains the original functions to be bound
* @param source A function that returns the source object which contains the original functions to be bound
* @param target A function that returns the target object which will receive the bound functions
* @param target A function that returns the target object which will receive the bound functions
* @param bind A function that returns the object which the functions will be bound to
* @param bind A function that returns the object which the functions will be bound to
* @param fnNames The function names which will be bound (Defaults to all the functions found on the 'from' object)
* @param fnNames The function names which will be bound (Defaults to all the functions found on the 'from' object)
* @param latebind If true, the binding of the function is delayed until the first time it's invoked
* @param latebind If true, the binding of the function is delayed until the first time it's invoked
*/
*/
function createProxyFunctions(source, target, bind, fnNames, latebind) {
function createProxyFunctions(source, target, bind, fnNames, latebind) {
if (latebind === void 0) { latebind = false; }
if (latebind === void 0) { latebind = false; }
var bindFunction = function (fnName) {
var bindFunction = function (fnName) {
return source()[fnName].bind(bind());
return source()[fnName].bind(bind());
};
};
var makeLateRebindFn = function (fnName) { return function lateRebindFunction() {
var makeLateRebindFn = function (fnName) { return function lateRebindFunction() {
target[fnName] = bindFunction(fnName);
target[fnName] = bindFunction(fnName);
return target[fnName].apply(null, arguments);
return target[fnName].apply(null, arguments);
}; };
}; };
fnNames = fnNames || Object.keys(source());
fnNames = fnNames || Object.keys(source());
return fnNames.reduce(function (acc, name) {
return fnNames.reduce(function (acc, name) {
acc[name] = latebind ? makeLateRebindFn(name) : bindFunction(name);
acc[name] = latebind ? makeLateRebindFn(name) : bindFunction(name);
return acc;
return acc;
}, target);
}, target);
}
}
/**
/**
* prototypal inheritance helper.
* prototypal inheritance helper.
* Creates a new object which has `parent` object as its prototype, and then copies the properties from `extra` onto it
* Creates a new object which has `parent` object as its prototype, and then copies the properties from `extra` onto it
*/
*/
var inherit = function (parent, extra) {
var inherit = function (parent, extra) {
return extend(Object.create(parent), extra);
return extend(Object.create(parent), extra);
};
};
/** Given an array, returns true if the object is found in the array, (using indexOf) */
/** Given an array, returns true if the object is found in the array, (using indexOf) */
var inArray = curry(_inArray);
var inArray = curry(_inArray);
function _inArray(array, obj) {
function _inArray(array, obj) {
return array.indexOf(obj) !== -1;
return array.indexOf(obj) !== -1;
}
}
/**
/**
* Given an array, and an item, if the item is found in the array, it removes it (in-place).
* Given an array, and an item, if the item is found in the array, it removes it (in-place).
* The same array is returned
* The same array is returned
*/
*/
var removeFrom = curry(_removeFrom);
var removeFrom = curry(_removeFrom);
function _removeFrom(array, obj) {
function _removeFrom(array, obj) {
var idx = array.indexOf(obj);
var idx = array.indexOf(obj);
if (idx >= 0)
if (idx >= 0)
array.splice(idx, 1);
array.splice(idx, 1);
return array;
return array;
}
}
/** pushes a values to an array and returns the value */
/** pushes a values to an array and returns the value */
var pushTo = curry(_pushTo);
var pushTo = curry(_pushTo);
function _pushTo(arr, val$$1) {
function _pushTo(arr, val$$1) {
return (arr.push(val$$1), val$$1);
return (arr.push(val$$1), val$$1);
}
}
/** Given an array of (deregistration) functions, calls all functions and removes each one from the source array */
/** Given an array of (deregistration) functions, calls all functions and removes each one from the source array */
var deregAll = function (functions) {
var deregAll = function (functions) {
return functions.slice().forEach(function (fn) {
return functions.slice().forEach(function (fn) {
typeof fn === 'function' && fn();
typeof fn === 'function' && fn();
removeFrom(functions, fn);
removeFrom(functions, fn);
});
});
};
};
/**
/**
* Applies a set of defaults to an options object. The options object is filtered
* Applies a set of defaults to an options object. The options object is filtered
* to only those properties of the objects in the defaultsList.
* to only those properties of the objects in the defaultsList.
* Earlier objects in the defaultsList take precedence when applying defaults.
* Earlier objects in the defaultsList take precedence when applying defaults.
*/
*/
function defaults(opts) {
function defaults(opts) {
var defaultsList = [];
var defaultsList = [];
for (var _i = 1; _i < arguments.length; _i++) {
for (var _i = 1; _i < arguments.length; _i++) {
defaultsList[_i - 1] = arguments[_i];
defaultsList[_i - 1] = arguments[_i];
}
}
var _defaultsList = defaultsList.concat({}).reverse();
var _defaultsList = defaultsList.concat({}).reverse();
var defaultVals = extend.apply(null, _defaultsList);
var defaultVals = extend.apply(null, _defaultsList);
return extend({}, defaultVals, pick(opts || {}, Object.keys(defaultVals)));
return extend({}, defaultVals, pick(opts || {}, Object.keys(defaultVals)));
}
}
/** Reduce function that merges each element of the list into a single object, using extend */
/** Reduce function that merges each element of the list into a single object, using extend */
var mergeR = function (memo, item) { return extend(memo, item); };
var mergeR = function (memo, item) { return extend(memo, item); };
/**
/**
* Finds the common ancestor path between two states.
* Finds the common ancestor path between two states.
*
*
* @param {Object} first The first state.
* @param {Object} first The first state.
* @param {Object} second The second state.
* @param {Object} second The second state.
* @return {Array} Returns an array of state names in descending order, not including the root.
* @return {Array} Returns an array of state names in descending order, not including the root.
*/
*/
function ancestors(first, second) {
function ancestors(first, second) {
var path = [];
var path = [];
for (var n in first.path) {
for (var n in first.path) {
if (first.path[n] !== second.path[n])
if (first.path[n] !== second.path[n])
break;
break;
path.push(first.path[n]);
path.push(first.path[n]);
}
}
return path;
return path;
}
}
/**
/**
* Return a copy of the object only containing the whitelisted properties.
* Return a copy of the object only containing the whitelisted properties.
*
*
* #### Example:
* #### Example:
* ```
* ```
* var foo = { a: 1, b: 2, c: 3 };
* var foo = { a: 1, b: 2, c: 3 };
* var ab = pick(foo, ['a', 'b']); // { a: 1, b: 2 }
* var ab = pick(foo, ['a', 'b']); // { a: 1, b: 2 }
* ```
* ```
* @param obj the source object
* @param obj the source object
* @param propNames an Array of strings, which are the whitelisted property names
* @param propNames an Array of strings, which are the whitelisted property names
*/
*/
function pick(obj, propNames) {
function pick(obj, propNames) {
var objCopy = {};
var objCopy = {};
for (var pro
for (var pro