From 6c89659aa4742404f93fbbcf56bc05ea6f20ddcc Mon Sep 17 00:00:00 2001 From: Nate Abele Date: Thu, 31 Dec 2015 21:30:52 -0500 Subject: [PATCH] release 1.0.0alpha0 --- bower.json | 4 +- component.json | 2 +- package.json | 2 +- release/angular-ui-router.js | 7505 +++++++++++++++--------------- release/angular-ui-router.min.js | 6 +- release/ng1/stateEvents.js | 114 + release/ng1/stateEvents.js.map | 1 + release/ng1/stateEvents.min.js | 7 + 8 files changed, 3982 insertions(+), 3659 deletions(-) create mode 100644 release/ng1/stateEvents.js create mode 100644 release/ng1/stateEvents.js.map create mode 100644 release/ng1/stateEvents.min.js diff --git a/bower.json b/bower.json index 0fed9bb70..7fbed4387 100644 --- a/bower.json +++ b/bower.json @@ -1,10 +1,10 @@ { "name": "angular-ui-router", - "version": "0.2.11", + "version": "1.0.0alpha0", "license" : "MIT", "main": "./release/angular-ui-router.js", "dependencies": { - "angular": ">= 1.0.8" + "angular": ">= 1.3.0" }, "ignore": [ "**/.*", diff --git a/component.json b/component.json index 4a6cd5c95..fd38a4aa6 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "angular-ui-router", - "version": "0.2.10", + "version": "1.0.0alpha0", "description": "State-based routing for AngularJS", "keywords": [ "angular", diff --git a/package.json b/package.json index 1dcba589f..0d67d1193 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-ui-router", "description": "State-based routing for AngularJS", - "version": "0.2.11", + "version": "1.0.0alpha0", "homepage": "http://angular-ui.github.com/", "contributors": [ { diff --git a/release/angular-ui-router.js b/release/angular-ui-router.js index 37d2ae696..78adb1b1f 100644 --- a/release/angular-ui-router.js +++ b/release/angular-ui-router.js @@ -1,3658 +1,3857 @@ /** * State-based routing for AngularJS - * @version v0.2.11 + * @version v1.0.0alpha0 * @link http://angular-ui.github.com/ * @license MIT License, http://www.opensource.org/licenses/MIT */ - -/* commonjs package manager support (eg componentjs) */ -if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){ - module.exports = 'ui.router'; -} - -(function (window, angular, undefined) { -/*jshint globalstrict:true*/ -/*global angular:false*/ -'use strict'; - -var isDefined = angular.isDefined, - isFunction = angular.isFunction, - isString = angular.isString, - isObject = angular.isObject, - isArray = angular.isArray, - forEach = angular.forEach, - extend = angular.extend, - copy = angular.copy; - -function inherit(parent, extra) { - return extend(new (extend(function() {}, { prototype: parent }))(), extra); -} - -function merge(dst) { - forEach(arguments, function(obj) { - if (obj !== dst) { - forEach(obj, function(value, key) { - if (!dst.hasOwnProperty(key)) dst[key] = value; - }); - } - }); - return dst; -} - -/** - * Finds the common ancestor path between two states. - * - * @param {Object} first The first state. - * @param {Object} second The second state. - * @return {Array} Returns an array of state names in descending order, not including the root. - */ -function ancestors(first, second) { - var path = []; - - for (var n in first.path) { - if (first.path[n] !== second.path[n]) break; - path.push(first.path[n]); - } - return path; -} - -/** - * IE8-safe wrapper for `Object.keys()`. - * - * @param {Object} object A JavaScript object. - * @return {Array} Returns the keys of the object as an array. - */ -function objectKeys(object) { - if (Object.keys) { - return Object.keys(object); - } - var result = []; - - angular.forEach(object, function(val, key) { - result.push(key); - }); - return result; -} - -/** - * IE8-safe wrapper for `Array.prototype.indexOf()`. - * - * @param {Array} array A JavaScript array. - * @param {*} value A value to search the array for. - * @return {Number} Returns the array index value of `value`, or `-1` if not present. - */ -function arraySearch(array, value) { - if (Array.prototype.indexOf) { - return array.indexOf(value, Number(arguments[2]) || 0); - } - var len = array.length >>> 0, from = Number(arguments[2]) || 0; - from = (from < 0) ? Math.ceil(from) : Math.floor(from); - - if (from < 0) from += len; - - for (; from < len; from++) { - if (from in array && array[from] === value) return from; - } - return -1; -} - -/** - * Merges a set of parameters with all parameters inherited between the common parents of the - * current state and a given destination state. - * - * @param {Object} currentParams The value of the current state parameters ($stateParams). - * @param {Object} newParams The set of parameters which will be composited with inherited params. - * @param {Object} $current Internal definition of object representing the current state. - * @param {Object} $to Internal definition of object representing state to transition to. - */ -function inheritParams(currentParams, newParams, $current, $to) { - var parents = ancestors($current, $to), parentParams, inherited = {}, inheritList = []; - - for (var i in parents) { - if (!parents[i].params) continue; - parentParams = objectKeys(parents[i].params); - if (!parentParams.length) continue; - - for (var j in parentParams) { - if (arraySearch(inheritList, parentParams[j]) >= 0) continue; - inheritList.push(parentParams[j]); - inherited[parentParams[j]] = currentParams[parentParams[j]]; - } - } - return extend({}, inherited, newParams); -} - -/** - * Performs a non-strict comparison of the subset of two objects, defined by a list of keys. - * - * @param {Object} a The first object. - * @param {Object} b The second object. - * @param {Array} keys The list of keys within each object to compare. If the list is empty or not specified, - * it defaults to the list of keys in `a`. - * @return {Boolean} Returns `true` if the keys match, otherwise `false`. - */ -function equalForKeys(a, b, keys) { - if (!keys) { - keys = []; - for (var n in a) keys.push(n); // Used instead of Object.keys() for IE8 compatibility - } - - for (var i=0; i - * - * - * - * - * - * - * - * - * - * - * - * - */ -angular.module('ui.router', ['ui.router.state']); - -angular.module('ui.router.compat', ['ui.router']); - -/** - * @ngdoc object - * @name ui.router.util.$resolve - * - * @requires $q - * @requires $injector - * - * @description - * Manages resolution of (acyclic) graphs of promises. - */ -$Resolve.$inject = ['$q', '$injector']; -function $Resolve( $q, $injector) { - - var VISIT_IN_PROGRESS = 1, - VISIT_DONE = 2, - NOTHING = {}, - NO_DEPENDENCIES = [], - NO_LOCALS = NOTHING, - NO_PARENT = extend($q.when(NOTHING), { $$promises: NOTHING, $$values: NOTHING }); - - - /** - * @ngdoc function - * @name ui.router.util.$resolve#study - * @methodOf ui.router.util.$resolve - * - * @description - * Studies a set of invocables that are likely to be used multiple times. - *
-   * $resolve.study(invocables)(locals, parent, self)
-   * 
- * is equivalent to - *
-   * $resolve.resolve(invocables, locals, parent, self)
-   * 
- * but the former is more efficient (in fact `resolve` just calls `study` - * internally). - * - * @param {object} invocables Invocable objects - * @return {function} a function to pass in locals, parent and self - */ - this.study = function (invocables) { - if (!isObject(invocables)) throw new Error("'invocables' must be an object"); - - // Perform a topological sort of invocables to build an ordered plan - var plan = [], cycle = [], visited = {}; - function visit(value, key) { - if (visited[key] === VISIT_DONE) return; - - cycle.push(key); - if (visited[key] === VISIT_IN_PROGRESS) { - cycle.splice(0, cycle.indexOf(key)); - throw new Error("Cyclic dependency: " + cycle.join(" -> ")); - } - visited[key] = VISIT_IN_PROGRESS; - - if (isString(value)) { - plan.push(key, [ function() { return $injector.get(value); }], NO_DEPENDENCIES); - } else { - var params = $injector.annotate(value); - forEach(params, function (param) { - if (param !== key && invocables.hasOwnProperty(param)) visit(invocables[param], param); - }); - plan.push(key, value, params); - } - - cycle.pop(); - visited[key] = VISIT_DONE; - } - forEach(invocables, visit); - invocables = cycle = visited = null; // plan is all that's required - - function isResolve(value) { - return isObject(value) && value.then && value.$$promises; - } - - return function (locals, parent, self) { - if (isResolve(locals) && self === undefined) { - self = parent; parent = locals; locals = null; - } - if (!locals) locals = NO_LOCALS; - else if (!isObject(locals)) { - throw new Error("'locals' must be an object"); - } - if (!parent) parent = NO_PARENT; - else if (!isResolve(parent)) { - throw new Error("'parent' must be a promise returned by $resolve.resolve()"); - } - - // To complete the overall resolution, we have to wait for the parent - // promise and for the promise for each invokable in our plan. - var resolution = $q.defer(), - result = resolution.promise, - promises = result.$$promises = {}, - values = extend({}, locals), - wait = 1 + plan.length/3, - merged = false; - - function done() { - // Merge parent values we haven't got yet and publish our own $$values - if (!--wait) { - if (!merged) merge(values, parent.$$values); - result.$$values = values; - result.$$promises = true; // keep for isResolve() - delete result.$$inheritedValues; - resolution.resolve(values); - } - } - - function fail(reason) { - result.$$failure = reason; - resolution.reject(reason); - } - - // Short-circuit if parent has already failed - if (isDefined(parent.$$failure)) { - fail(parent.$$failure); - return result; - } - - if (parent.$$inheritedValues) { - merge(values, parent.$$inheritedValues); - } - - // Merge parent values if the parent has already resolved, or merge - // parent promises and wait if the parent resolve is still in progress. - if (parent.$$values) { - merged = merge(values, parent.$$values); - result.$$inheritedValues = parent.$$values; - done(); - } else { - if (parent.$$inheritedValues) { - result.$$inheritedValues = parent.$$inheritedValues; - } - extend(promises, parent.$$promises); - parent.then(done, fail); - } - - // Process each invocable in the plan, but ignore any where a local of the same name exists. - for (var i=0, ii=plan.length; i} The template html as a string, or a promise - * for that string. - */ - this.fromUrl = function (url, params) { - if (isFunction(url)) url = url(params); - if (url == null) return null; - else return $http - .get(url, { cache: $templateCache }) - .then(function(response) { return response.data; }); - }; - - /** - * @ngdoc function - * @name ui.router.util.$templateFactory#fromProvider - * @methodOf ui.router.util.$templateFactory - * - * @description - * Creates a template by invoking an injectable provider function. - * - * @param {Function} provider Function to invoke via `$injector.invoke` - * @param {Object} params Parameters for the template. - * @param {Object} locals Locals to pass to `invoke`. Defaults to - * `{ params: params }`. - * @return {string|Promise.} The template html as a string, or a promise - * for that string. - */ - this.fromProvider = function (provider, params, locals) { - return $injector.invoke(provider, null, locals || { params: params }); - }; -} - -angular.module('ui.router.util').service('$templateFactory', $TemplateFactory); - -/** - * @ngdoc object - * @name ui.router.util.type:UrlMatcher - * - * @description - * Matches URLs against patterns and extracts named parameters from the path or the search - * part of the URL. A URL pattern consists of a path pattern, optionally followed by '?' and a list - * of search parameters. Multiple search parameter names are separated by '&'. Search parameters - * do not influence whether or not a URL is matched, but their values are passed through into - * the matched parameters returned by {@link ui.router.util.type:UrlMatcher#methods_exec exec}. - * - * Path parameter placeholders can be specified using simple colon/catch-all syntax or curly brace - * syntax, which optionally allows a regular expression for the parameter to be specified: - * - * * `':'` name - colon placeholder - * * `'*'` name - catch-all placeholder - * * `'{' name '}'` - curly placeholder - * * `'{' name ':' regexp '}'` - curly placeholder with regexp. Should the regexp itself contain - * curly braces, they must be in matched pairs or escaped with a backslash. - * - * Parameter names may contain only word characters (latin letters, digits, and underscore) and - * must be unique within the pattern (across both path and search parameters). For colon - * placeholders or curly placeholders without an explicit regexp, a path parameter matches any - * number of characters other than '/'. For catch-all placeholders the path parameter matches - * any number of characters. - * - * Examples: - * - * * `'/hello/'` - Matches only if the path is exactly '/hello/'. There is no special treatment for - * trailing slashes, and patterns have to match the entire path, not just a prefix. - * * `'/user/:id'` - Matches '/user/bob' or '/user/1234!!!' or even '/user/' but not '/user' or - * '/user/bob/details'. The second path segment will be captured as the parameter 'id'. - * * `'/user/{id}'` - Same as the previous example, but using curly brace syntax. - * * `'/user/{id:[^/]*}'` - Same as the previous example. - * * `'/user/{id:[0-9a-fA-F]{1,8}}'` - Similar to the previous example, but only matches if the id - * parameter consists of 1 to 8 hex digits. - * * `'/files/{path:.*}'` - Matches any URL starting with '/files/' and captures the rest of the - * path into the parameter 'path'. - * * `'/files/*path'` - ditto. - * - * @param {string} pattern The pattern to compile into a matcher. - * @param {Object} config A configuration object hash: - * - * * `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`. - * * `strict` - `false` if matching against a URL with a trailing slash should be treated as equivalent to a URL without a trailing slash, the default value is `true`. - * - * @property {string} prefix A static prefix of this pattern. The matcher guarantees that any - * URL matching this matcher (i.e. any string for which {@link ui.router.util.type:UrlMatcher#methods_exec exec()} returns - * non-null) will start with this prefix. - * - * @property {string} source The pattern that was passed into the constructor - * - * @property {string} sourcePath The path portion of the source property - * - * @property {string} sourceSearch The search portion of the source property - * - * @property {string} regex The constructed regex that will be used to match against the url when - * it is time to determine which url will match. - * - * @returns {Object} New `UrlMatcher` object - */ -function UrlMatcher(pattern, config) { - config = angular.isObject(config) ? config : {}; - - // Find all placeholders and create a compiled pattern, using either classic or curly syntax: - // '*' name - // ':' name - // '{' name '}' - // '{' name ':' regexp '}' - // The regular expression is somewhat complicated due to the need to allow curly braces - // inside the regular expression. The placeholder regexp breaks down as follows: - // ([:*])(\w+) classic placeholder ($1 / $2) - // \{(\w+)(?:\:( ... ))?\} curly brace placeholder ($3) with optional regexp ... ($4) - // (?: ... | ... | ... )+ the regexp consists of any number of atoms, an atom being either - // [^{}\\]+ - anything other than curly braces or backslash - // \\. - a backslash escape - // \{(?:[^{}\\]+|\\.)*\} - a matched set of curly braces containing other atoms - var placeholder = /([:*])(\w+)|\{(\w+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g, - compiled = '^', last = 0, m, - segments = this.segments = [], - params = this.params = {}; - - /** - * [Internal] Gets the decoded representation of a value if the value is defined, otherwise, returns the - * default value, which may be the result of an injectable function. - */ - function $value(value) { - /*jshint validthis: true */ - return isDefined(value) ? this.type.decode(value) : $UrlMatcherFactory.$$getDefaultValue(this); - } - - function addParameter(id, type, config) { - if (!/^\w+(-+\w+)*$/.test(id)) throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'"); - if (params[id]) throw new Error("Duplicate parameter name '" + id + "' in pattern '" + pattern + "'"); - params[id] = extend({ type: type || new Type(), $value: $value }, config); - } - - function quoteRegExp(string, pattern, isOptional) { - var result = string.replace(/[\\\[\]\^$*+?.()|{}]/g, "\\$&"); - if (!pattern) return result; - var flag = isOptional ? '?' : ''; - return result + flag + '(' + pattern + ')' + flag; - } - - function paramConfig(param) { - if (!config.params || !config.params[param]) return {}; - var cfg = config.params[param]; - return isObject(cfg) ? cfg : { value: cfg }; - } - - this.source = pattern; - - // Split into static segments separated by path parameter placeholders. - // The number of segments is always 1 more than the number of parameters. - var id, regexp, segment, type, cfg; - - while ((m = placeholder.exec(pattern))) { - id = m[2] || m[3]; // IE[78] returns '' for unmatched groups instead of null - regexp = m[4] || (m[1] == '*' ? '.*' : '[^/]*'); - segment = pattern.substring(last, m.index); - type = this.$types[regexp] || new Type({ pattern: new RegExp(regexp) }); - cfg = paramConfig(id); - - if (segment.indexOf('?') >= 0) break; // we're into the search part - - compiled += quoteRegExp(segment, type.$subPattern(), isDefined(cfg.value)); - addParameter(id, type, cfg); - segments.push(segment); - last = placeholder.lastIndex; - } - segment = pattern.substring(last); - - // Find any search parameter names and remove them from the last segment - var i = segment.indexOf('?'); - - if (i >= 0) { - var search = this.sourceSearch = segment.substring(i); - segment = segment.substring(0, i); - this.sourcePath = pattern.substring(0, last + i); - - // Allow parameters to be separated by '?' as well as '&' to make concat() easier - forEach(search.substring(1).split(/[&?]/), function(key) { - addParameter(key, null, paramConfig(key)); - }); - } else { - this.sourcePath = pattern; - this.sourceSearch = ''; - } - - compiled += quoteRegExp(segment) + (config.strict === false ? '\/?' : '') + '$'; - segments.push(segment); - - this.regexp = new RegExp(compiled, config.caseInsensitive ? 'i' : undefined); - this.prefix = segments[0]; -} - -/** - * @ngdoc function - * @name ui.router.util.type:UrlMatcher#concat - * @methodOf ui.router.util.type:UrlMatcher - * - * @description - * Returns a new matcher for a pattern constructed by appending the path part and adding the - * search parameters of the specified pattern to this pattern. The current pattern is not - * modified. This can be understood as creating a pattern for URLs that are relative to (or - * suffixes of) the current pattern. - * - * @example - * The following two matchers are equivalent: - *
- * new UrlMatcher('/user/{id}?q').concat('/details?date');
- * new UrlMatcher('/user/{id}/details?q&date');
- * 
- * - * @param {string} pattern The pattern to append. - * @param {Object} config An object hash of the configuration for the matcher. - * @returns {UrlMatcher} A matcher for the concatenated pattern. - */ -UrlMatcher.prototype.concat = function (pattern, config) { - // Because order of search parameters is irrelevant, we can add our own search - // parameters to the end of the new pattern. Parse the new pattern by itself - // and then join the bits together, but it's much easier to do this on a string level. - return new UrlMatcher(this.sourcePath + pattern + this.sourceSearch, config); -}; - -UrlMatcher.prototype.toString = function () { - return this.source; -}; - -/** - * @ngdoc function - * @name ui.router.util.type:UrlMatcher#exec - * @methodOf ui.router.util.type:UrlMatcher - * - * @description - * Tests the specified path against this matcher, and returns an object containing the captured - * parameter values, or null if the path does not match. The returned object contains the values - * of any search parameters that are mentioned in the pattern, but their value may be null if - * they are not present in `searchParams`. This means that search parameters are always treated - * as optional. - * - * @example - *
- * new UrlMatcher('/user/{id}?q&r').exec('/user/bob', {
- *   x: '1', q: 'hello'
- * });
- * // returns { id: 'bob', q: 'hello', r: null }
- * 
- * - * @param {string} path The URL path to match, e.g. `$location.path()`. - * @param {Object} searchParams URL search parameters, e.g. `$location.search()`. - * @returns {Object} The captured parameter values. - */ -UrlMatcher.prototype.exec = function (path, searchParams) { - var m = this.regexp.exec(path); - if (!m) return null; - searchParams = searchParams || {}; - - var params = this.parameters(), nTotal = params.length, - nPath = this.segments.length - 1, - values = {}, i, cfg, param; - - if (nPath !== m.length - 1) throw new Error("Unbalanced capture group in route '" + this.source + "'"); - - for (i = 0; i < nPath; i++) { - param = params[i]; - cfg = this.params[param]; - values[param] = cfg.$value(m[i + 1]); - } - for (/**/; i < nTotal; i++) { - param = params[i]; - cfg = this.params[param]; - values[param] = cfg.$value(searchParams[param]); - } - - return values; -}; - -/** - * @ngdoc function - * @name ui.router.util.type:UrlMatcher#parameters - * @methodOf ui.router.util.type:UrlMatcher - * - * @description - * Returns the names of all path and search parameters of this pattern in an unspecified order. - * - * @returns {Array.} An array of parameter names. Must be treated as read-only. If the - * pattern has no parameters, an empty array is returned. - */ -UrlMatcher.prototype.parameters = function (param) { - if (!isDefined(param)) return objectKeys(this.params); - return this.params[param] || null; -}; - -/** - * @ngdoc function - * @name ui.router.util.type:UrlMatcher#validate - * @methodOf ui.router.util.type:UrlMatcher - * - * @description - * Checks an object hash of parameters to validate their correctness according to the parameter - * types of this `UrlMatcher`. - * - * @param {Object} params The object hash of parameters to validate. - * @returns {boolean} Returns `true` if `params` validates, otherwise `false`. - */ -UrlMatcher.prototype.validates = function (params) { - var result = true, isOptional, cfg, self = this; - - forEach(params, function(val, key) { - if (!self.params[key]) return; - cfg = self.params[key]; - isOptional = !val && isDefined(cfg.value); - result = result && (isOptional || cfg.type.is(val)); - }); - return result; -}; - -/** - * @ngdoc function - * @name ui.router.util.type:UrlMatcher#format - * @methodOf ui.router.util.type:UrlMatcher - * - * @description - * Creates a URL that matches this pattern by substituting the specified values - * for the path and search parameters. Null values for path parameters are - * treated as empty strings. - * - * @example - *
- * new UrlMatcher('/user/{id}?q').format({ id:'bob', q:'yes' });
- * // returns '/user/bob?q=yes'
- * 
- * - * @param {Object} values the values to substitute for the parameters in this pattern. - * @returns {string} the formatted URL (path and optionally search part). - */ -UrlMatcher.prototype.format = function (values) { - var segments = this.segments, params = this.parameters(); - - if (!values) return segments.join('').replace('//', '/'); - - var nPath = segments.length - 1, nTotal = params.length, - result = segments[0], i, search, value, param, cfg, array; - - if (!this.validates(values)) return null; - - for (i = 0; i < nPath; i++) { - param = params[i]; - value = values[param]; - cfg = this.params[param]; - - if (!isDefined(value) && (segments[i] === '/' || segments[i + 1] === '/')) continue; - if (value != null) result += encodeURIComponent(cfg.type.encode(value)); - result += segments[i + 1]; - } - - for (/**/; i < nTotal; i++) { - param = params[i]; - value = values[param]; - if (value == null) continue; - array = isArray(value); - - if (array) { - value = value.map(encodeURIComponent).join('&' + param + '='); - } - result += (search ? '&' : '?') + param + '=' + (array ? value : encodeURIComponent(value)); - search = true; - } - return result; -}; - -UrlMatcher.prototype.$types = {}; - -/** - * @ngdoc object - * @name ui.router.util.type:Type - * - * @description - * Implements an interface to define custom parameter types that can be decoded from and encoded to - * string parameters matched in a URL. Used by {@link ui.router.util.type:UrlMatcher `UrlMatcher`} - * objects when matching or formatting URLs, or comparing or validating parameter values. - * - * See {@link ui.router.util.$urlMatcherFactory#methods_type `$urlMatcherFactory#type()`} for more - * information on registering custom types. - * - * @param {Object} config A configuration object hash that includes any method in `Type`'s public - * interface, and/or `pattern`, which should contain a custom regular expression used to match - * string parameters originating from a URL. - * - * @property {RegExp} pattern The regular expression pattern used to match values of this type when - * coming from a substring of a URL. - * - * @returns {Object} Returns a new `Type` object. - */ -function Type(config) { - extend(this, config); -} - -/** - * @ngdoc function - * @name ui.router.util.type:Type#is - * @methodOf ui.router.util.type:Type - * - * @description - * Detects whether a value is of a particular type. Accepts a native (decoded) value - * and determines whether it matches the current `Type` object. - * - * @param {*} val The value to check. - * @param {string} key Optional. If the type check is happening in the context of a specific - * {@link ui.router.util.type:UrlMatcher `UrlMatcher`} object, this is the name of the - * parameter in which `val` is stored. Can be used for meta-programming of `Type` objects. - * @returns {Boolean} Returns `true` if the value matches the type, otherwise `false`. - */ -Type.prototype.is = function(val, key) { - return true; -}; - -/** - * @ngdoc function - * @name ui.router.util.type:Type#encode - * @methodOf ui.router.util.type:Type - * - * @description - * Encodes a custom/native type value to a string that can be embedded in a URL. Note that the - * return value does *not* need to be URL-safe (i.e. passed through `encodeURIComponent()`), it - * only needs to be a representation of `val` that has been coerced to a string. - * - * @param {*} val The value to encode. - * @param {string} key The name of the parameter in which `val` is stored. Can be used for - * meta-programming of `Type` objects. - * @returns {string} Returns a string representation of `val` that can be encoded in a URL. - */ -Type.prototype.encode = function(val, key) { - return val; -}; - -/** - * @ngdoc function - * @name ui.router.util.type:Type#decode - * @methodOf ui.router.util.type:Type - * - * @description - * Converts a string URL parameter value to a custom/native value. - * - * @param {string} val The URL parameter value to decode. - * @param {string} key The name of the parameter in which `val` is stored. Can be used for - * meta-programming of `Type` objects. - * @returns {*} Returns a custom representation of the URL parameter value. - */ -Type.prototype.decode = function(val, key) { - return val; -}; - -/** - * @ngdoc function - * @name ui.router.util.type:Type#equals - * @methodOf ui.router.util.type:Type - * - * @description - * Determines whether two decoded values are equivalent. - * - * @param {*} a A value to compare against. - * @param {*} b A value to compare against. - * @returns {Boolean} Returns `true` if the values are equivalent/equal, otherwise `false`. - */ -Type.prototype.equals = function(a, b) { - return a == b; -}; - -Type.prototype.$subPattern = function() { - var sub = this.pattern.toString(); - return sub.substr(1, sub.length - 2); -}; - -Type.prototype.pattern = /.*/; - -/** - * @ngdoc object - * @name ui.router.util.$urlMatcherFactory - * - * @description - * Factory for {@link ui.router.util.type:UrlMatcher `UrlMatcher`} instances. The factory - * is also available to providers under the name `$urlMatcherFactoryProvider`. - */ -function $UrlMatcherFactory() { - - var isCaseInsensitive = false, isStrictMode = true; - - var enqueue = true, typeQueue = [], injector, defaultTypes = { - int: { - decode: function(val) { - return parseInt(val, 10); - }, - is: function(val) { - if (!isDefined(val)) return false; - return this.decode(val.toString()) === val; - }, - pattern: /\d+/ - }, - bool: { - encode: function(val) { - return val ? 1 : 0; - }, - decode: function(val) { - return parseInt(val, 10) === 0 ? false : true; - }, - is: function(val) { - return val === true || val === false; - }, - pattern: /0|1/ - }, - string: { - pattern: /[^\/]*/ - }, - date: { - equals: function (a, b) { - return a.toISOString() === b.toISOString(); - }, - decode: function (val) { - return new Date(val); - }, - encode: function (val) { - return [ - val.getFullYear(), - ('0' + (val.getMonth() + 1)).slice(-2), - ('0' + val.getDate()).slice(-2) - ].join("-"); - }, - pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/ - } - }; - - function getDefaultConfig() { - return { - strict: isStrictMode, - caseInsensitive: isCaseInsensitive - }; - } - - function isInjectable(value) { - return (isFunction(value) || (isArray(value) && isFunction(value[value.length - 1]))); - } - - /** - * [Internal] Get the default value of a parameter, which may be an injectable function. - */ - $UrlMatcherFactory.$$getDefaultValue = function(config) { - if (!isInjectable(config.value)) return config.value; - if (!injector) throw new Error("Injectable functions cannot be called at configuration time"); - return injector.invoke(config.value); - }; - - /** - * @ngdoc function - * @name ui.router.util.$urlMatcherFactory#caseInsensitive - * @methodOf ui.router.util.$urlMatcherFactory - * - * @description - * Defines whether URL matching should be case sensitive (the default behavior), or not. - * - * @param {boolean} value `false` to match URL in a case sensitive manner; otherwise `true`; - */ - this.caseInsensitive = function(value) { - isCaseInsensitive = value; - }; - - /** - * @ngdoc function - * @name ui.router.util.$urlMatcherFactory#strictMode - * @methodOf ui.router.util.$urlMatcherFactory - * - * @description - * Defines whether URLs should match trailing slashes, or not (the default behavior). - * - * @param {boolean} value `false` to match trailing slashes in URLs, otherwise `true`. - */ - this.strictMode = function(value) { - isStrictMode = value; - }; - - /** - * @ngdoc function - * @name ui.router.util.$urlMatcherFactory#compile - * @methodOf ui.router.util.$urlMatcherFactory - * - * @description - * Creates a {@link ui.router.util.type:UrlMatcher `UrlMatcher`} for the specified pattern. - * - * @param {string} pattern The URL pattern. - * @param {Object} config The config object hash. - * @returns {UrlMatcher} The UrlMatcher. - */ - this.compile = function (pattern, config) { - return new UrlMatcher(pattern, extend(getDefaultConfig(), config)); - }; - - /** - * @ngdoc function - * @name ui.router.util.$urlMatcherFactory#isMatcher - * @methodOf ui.router.util.$urlMatcherFactory - * - * @description - * Returns true if the specified object is a `UrlMatcher`, or false otherwise. - * - * @param {Object} object The object to perform the type check against. - * @returns {Boolean} Returns `true` if the object matches the `UrlMatcher` interface, by - * implementing all the same methods. - */ - this.isMatcher = function (o) { - if (!isObject(o)) return false; - var result = true; - - forEach(UrlMatcher.prototype, function(val, name) { - if (isFunction(val)) { - result = result && (isDefined(o[name]) && isFunction(o[name])); - } - }); - return result; - }; - - /** - * @ngdoc function - * @name ui.router.util.$urlMatcherFactory#type - * @methodOf ui.router.util.$urlMatcherFactory - * - * @description - * Registers a custom {@link ui.router.util.type:Type `Type`} object that can be used to - * generate URLs with typed parameters. - * - * @param {string} name The type name. - * @param {Object|Function} def The type definition. See - * {@link ui.router.util.type:Type `Type`} for information on the values accepted. - * - * @returns {Object} Returns `$urlMatcherFactoryProvider`. - * - * @example - * This is a simple example of a custom type that encodes and decodes items from an - * array, using the array index as the URL-encoded value: - * - *
-   * var list = ['John', 'Paul', 'George', 'Ringo'];
-   *
-   * $urlMatcherFactoryProvider.type('listItem', {
-   *   encode: function(item) {
-   *     // Represent the list item in the URL using its corresponding index
-   *     return list.indexOf(item);
-   *   },
-   *   decode: function(item) {
-   *     // Look up the list item by index
-   *     return list[parseInt(item, 10)];
-   *   },
-   *   is: function(item) {
-   *     // Ensure the item is valid by checking to see that it appears
-   *     // in the list
-   *     return list.indexOf(item) > -1;
-   *   }
-   * });
-   *
-   * $stateProvider.state('list', {
-   *   url: "/list/{item:listItem}",
-   *   controller: function($scope, $stateParams) {
-   *     console.log($stateParams.item);
-   *   }
-   * });
-   *
-   * // ...
-   *
-   * // Changes URL to '/list/3', logs "Ringo" to the console
-   * $state.go('list', { item: "Ringo" });
-   * 
- * - * This is a more complex example of a type that relies on dependency injection to - * interact with services, and uses the parameter name from the URL to infer how to - * handle encoding and decoding parameter values: - * - *
-   * // Defines a custom type that gets a value from a service,
-   * // where each service gets different types of values from
-   * // a backend API:
-   * $urlMatcherFactoryProvider.type('dbObject', function(Users, Posts) {
-   *
-   *   // Matches up services to URL parameter names
-   *   var services = {
-   *     user: Users,
-   *     post: Posts
-   *   };
-   *
-   *   return {
-   *     encode: function(object) {
-   *       // Represent the object in the URL using its unique ID
-   *       return object.id;
-   *     },
-   *     decode: function(value, key) {
-   *       // Look up the object by ID, using the parameter
-   *       // name (key) to call the correct service
-   *       return services[key].findById(value);
-   *     },
-   *     is: function(object, key) {
-   *       // Check that object is a valid dbObject
-   *       return angular.isObject(object) && object.id && services[key];
-   *     }
-   *     equals: function(a, b) {
-   *       // Check the equality of decoded objects by comparing
-   *       // their unique IDs
-   *       return a.id === b.id;
-   *     }
-   *   };
-   * });
-   *
-   * // In a config() block, you can then attach URLs with
-   * // type-annotated parameters:
-   * $stateProvider.state('users', {
-   *   url: "/users",
-   *   // ...
-   * }).state('users.item', {
-   *   url: "/{user:dbObject}",
-   *   controller: function($scope, $stateParams) {
-   *     // $stateParams.user will now be an object returned from
-   *     // the Users service
-   *   },
-   *   // ...
-   * });
-   * 
- */ - this.type = function (name, def) { - if (!isDefined(def)) return UrlMatcher.prototype.$types[name]; - typeQueue.push({ name: name, def: def }); - if (!enqueue) flushTypeQueue(); - return this; - }; - - /* No need to document $get, since it returns this */ - this.$get = ['$injector', function ($injector) { - injector = $injector; - enqueue = false; - UrlMatcher.prototype.$types = {}; - flushTypeQueue(); - - forEach(defaultTypes, function(type, name) { - if (!UrlMatcher.prototype.$types[name]) UrlMatcher.prototype.$types[name] = new Type(type); - }); - return this; - }]; - - // To ensure proper order of operations in object configuration, and to allow internal - // types to be overridden, `flushTypeQueue()` waits until `$urlMatcherFactory` is injected - // before actually wiring up and assigning type definitions - function flushTypeQueue() { - forEach(typeQueue, function(type) { - if (UrlMatcher.prototype.$types[type.name]) { - throw new Error("A type named '" + type.name + "' has already been defined."); - } - var def = new Type(isInjectable(type.def) ? injector.invoke(type.def) : type.def); - UrlMatcher.prototype.$types[type.name] = def; - }); - } -} - -// Register as a provider so it's available to other providers -angular.module('ui.router.util').provider('$urlMatcherFactory', $UrlMatcherFactory); - -/** - * @ngdoc object - * @name ui.router.router.$urlRouterProvider - * - * @requires ui.router.util.$urlMatcherFactoryProvider - * @requires $locationProvider - * - * @description - * `$urlRouterProvider` has the responsibility of watching `$location`. - * When `$location` changes it runs through a list of rules one by one until a - * match is found. `$urlRouterProvider` is used behind the scenes anytime you specify - * a url in a state configuration. All urls are compiled into a UrlMatcher object. - * - * There are several methods on `$urlRouterProvider` that make it useful to use directly - * in your module config. - */ -$UrlRouterProvider.$inject = ['$locationProvider', '$urlMatcherFactoryProvider']; -function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) { - var rules = [], otherwise = null, interceptDeferred = false, listener; - - // Returns a string that is a prefix of all strings matching the RegExp - function regExpPrefix(re) { - var prefix = /^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(re.source); - return (prefix != null) ? prefix[1].replace(/\\(.)/g, "$1") : ''; - } - - // Interpolates matched values into a String.replace()-style pattern - function interpolate(pattern, match) { - return pattern.replace(/\$(\$|\d{1,2})/, function (m, what) { - return match[what === '$' ? 0 : Number(what)]; - }); - } - - /** - * @ngdoc function - * @name ui.router.router.$urlRouterProvider#rule - * @methodOf ui.router.router.$urlRouterProvider - * - * @description - * Defines rules that are used by `$urlRouterProvider` to find matches for - * specific URLs. - * - * @example - *
-   * var app = angular.module('app', ['ui.router.router']);
-   *
-   * app.config(function ($urlRouterProvider) {
-   *   // Here's an example of how you might allow case insensitive urls
-   *   $urlRouterProvider.rule(function ($injector, $location) {
-   *     var path = $location.path(),
-   *         normalized = path.toLowerCase();
-   *
-   *     if (path !== normalized) {
-   *       return normalized;
-   *     }
-   *   });
-   * });
-   * 
- * - * @param {object} rule Handler function that takes `$injector` and `$location` - * services as arguments. You can use them to return a valid path as a string. - * - * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance - */ - this.rule = function (rule) { - if (!isFunction(rule)) throw new Error("'rule' must be a function"); - rules.push(rule); - return this; - }; - - /** - * @ngdoc object - * @name ui.router.router.$urlRouterProvider#otherwise - * @methodOf ui.router.router.$urlRouterProvider - * - * @description - * Defines a path that is used when an invalid route is requested. - * - * @example - *
-   * var app = angular.module('app', ['ui.router.router']);
-   *
-   * app.config(function ($urlRouterProvider) {
-   *   // if the path doesn't match any of the urls you configured
-   *   // otherwise will take care of routing the user to the
-   *   // specified url
-   *   $urlRouterProvider.otherwise('/index');
-   *
-   *   // Example of using function rule as param
-   *   $urlRouterProvider.otherwise(function ($injector, $location) {
-   *     return '/a/valid/url';
-   *   });
-   * });
-   * 
- * - * @param {string|object} rule The url path you want to redirect to or a function - * rule that returns the url path. The function version is passed two params: - * `$injector` and `$location` services, and must return a url string. - * - * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance - */ - this.otherwise = function (rule) { - if (isString(rule)) { - var redirect = rule; - rule = function () { return redirect; }; - } - else if (!isFunction(rule)) throw new Error("'rule' must be a function"); - otherwise = rule; - return this; - }; - - - function handleIfMatch($injector, handler, match) { - if (!match) return false; - var result = $injector.invoke(handler, handler, { $match: match }); - return isDefined(result) ? result : true; - } - - /** - * @ngdoc function - * @name ui.router.router.$urlRouterProvider#when - * @methodOf ui.router.router.$urlRouterProvider - * - * @description - * Registers a handler for a given url matching. if handle is a string, it is - * treated as a redirect, and is interpolated according to the syntax of match - * (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise). - * - * If the handler is a function, it is injectable. It gets invoked if `$location` - * matches. You have the option of inject the match object as `$match`. - * - * The handler can return - * - * - **falsy** to indicate that the rule didn't match after all, then `$urlRouter` - * will continue trying to find another one that matches. - * - **string** which is treated as a redirect and passed to `$location.url()` - * - **void** or any **truthy** value tells `$urlRouter` that the url was handled. - * - * @example - *
-   * var app = angular.module('app', ['ui.router.router']);
-   *
-   * app.config(function ($urlRouterProvider) {
-   *   $urlRouterProvider.when($state.url, function ($match, $stateParams) {
-   *     if ($state.$current.navigable !== state ||
-   *         !equalForKeys($match, $stateParams) {
-   *      $state.transitionTo(state, $match, false);
-   *     }
-   *   });
-   * });
-   * 
- * - * @param {string|object} what The incoming path that you want to redirect. - * @param {string|object} handler The path you want to redirect your user to. - */ - this.when = function (what, handler) { - var redirect, handlerIsString = isString(handler); - if (isString(what)) what = $urlMatcherFactory.compile(what); - - if (!handlerIsString && !isFunction(handler) && !isArray(handler)) - throw new Error("invalid 'handler' in when()"); - - var strategies = { - matcher: function (what, handler) { - if (handlerIsString) { - redirect = $urlMatcherFactory.compile(handler); - handler = ['$match', function ($match) { return redirect.format($match); }]; - } - return extend(function ($injector, $location) { - return handleIfMatch($injector, handler, what.exec($location.path(), $location.search())); - }, { - prefix: isString(what.prefix) ? what.prefix : '' - }); - }, - regex: function (what, handler) { - if (what.global || what.sticky) throw new Error("when() RegExp must not be global or sticky"); - - if (handlerIsString) { - redirect = handler; - handler = ['$match', function ($match) { return interpolate(redirect, $match); }]; - } - return extend(function ($injector, $location) { - return handleIfMatch($injector, handler, what.exec($location.path())); - }, { - prefix: regExpPrefix(what) - }); - } - }; - - var check = { matcher: $urlMatcherFactory.isMatcher(what), regex: what instanceof RegExp }; - - for (var n in check) { - if (check[n]) return this.rule(strategies[n](what, handler)); - } - - throw new Error("invalid 'what' in when()"); - }; - - /** - * @ngdoc function - * @name ui.router.router.$urlRouterProvider#deferIntercept - * @methodOf ui.router.router.$urlRouterProvider - * - * @description - * Disables (or enables) deferring location change interception. - * - * If you wish to customize the behavior of syncing the URL (for example, if you wish to - * defer a transition but maintain the current URL), call this method at configuration time. - * Then, at run time, call `$urlRouter.listen()` after you have configured your own - * `$locationChangeSuccess` event handler. - * - * @example - *
-   * var app = angular.module('app', ['ui.router.router']);
-   *
-   * app.config(function ($urlRouterProvider) {
-   *
-   *   // Prevent $urlRouter from automatically intercepting URL changes;
-   *   // this allows you to configure custom behavior in between
-   *   // location changes and route synchronization:
-   *   $urlRouterProvider.deferIntercept();
-   *
-   * }).run(function ($rootScope, $urlRouter, UserService) {
-   *
-   *   $rootScope.$on('$locationChangeSuccess', function(e) {
-   *     // UserService is an example service for managing user state
-   *     if (UserService.isLoggedIn()) return;
-   *
-   *     // Prevent $urlRouter's default handler from firing
-   *     e.preventDefault();
-   *
-   *     UserService.handleLogin().then(function() {
-   *       // Once the user has logged in, sync the current URL
-   *       // to the router:
-   *       $urlRouter.sync();
-   *     });
-   *   });
-   *
-   *   // Configures $urlRouter's listener *after* your custom listener
-   *   $urlRouter.listen();
-   * });
-   * 
- * - * @param {boolean} defer Indicates whether to defer location change interception. Passing - no parameter is equivalent to `true`. - */ - this.deferIntercept = function (defer) { - if (defer === undefined) defer = true; - interceptDeferred = defer; - }; - - /** - * @ngdoc object - * @name ui.router.router.$urlRouter - * - * @requires $location - * @requires $rootScope - * @requires $injector - * @requires $browser - * - * @description - * - */ - this.$get = $get; - $get.$inject = ['$location', '$rootScope', '$injector', '$browser']; - function $get( $location, $rootScope, $injector, $browser) { - - var baseHref = $browser.baseHref(), location = $location.url(); - - function appendBasePath(url, isHtml5, absolute) { - if (baseHref === '/') return url; - if (isHtml5) return baseHref.slice(0, -1) + url; - if (absolute) return baseHref.slice(1) + url; - return url; - } - - // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree - function update(evt) { - if (evt && evt.defaultPrevented) return; - - function check(rule) { - var handled = rule($injector, $location); - - if (!handled) return false; - if (isString(handled)) $location.replace().url(handled); - return true; - } - var n = rules.length, i; - - for (i = 0; i < n; i++) { - if (check(rules[i])) return; - } - // always check otherwise last to allow dynamic updates to the set of rules - if (otherwise) check(otherwise); - } - - function listen() { - listener = listener || $rootScope.$on('$locationChangeSuccess', update); - return listener; - } - - if (!interceptDeferred) listen(); - - return { - /** - * @ngdoc function - * @name ui.router.router.$urlRouter#sync - * @methodOf ui.router.router.$urlRouter - * - * @description - * Triggers an update; the same update that happens when the address bar url changes, aka `$locationChangeSuccess`. - * This method is useful when you need to use `preventDefault()` on the `$locationChangeSuccess` event, - * perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed - * with the transition by calling `$urlRouter.sync()`. - * - * @example - *
-       * angular.module('app', ['ui.router'])
-       *   .run(function($rootScope, $urlRouter) {
-       *     $rootScope.$on('$locationChangeSuccess', function(evt) {
-       *       // Halt state change from even starting
-       *       evt.preventDefault();
-       *       // Perform custom logic
-       *       var meetsRequirement = ...
-       *       // Continue with the update and state transition if logic allows
-       *       if (meetsRequirement) $urlRouter.sync();
-       *     });
-       * });
-       * 
- */ - sync: function() { - update(); - }, - - listen: function() { - return listen(); - }, - - update: function(read) { - if (read) { - location = $location.url(); - return; - } - if ($location.url() === location) return; - - $location.url(location); - $location.replace(); - }, - - push: function(urlMatcher, params, options) { - $location.url(urlMatcher.format(params || {})); - if (options && options.replace) $location.replace(); - }, - - /** - * @ngdoc function - * @name ui.router.router.$urlRouter#href - * @methodOf ui.router.router.$urlRouter - * - * @description - * A URL generation method that returns the compiled URL for a given - * {@link ui.router.util.type:UrlMatcher `UrlMatcher`}, populated with the provided parameters. - * - * @example - *
-       * $bob = $urlRouter.href(new UrlMatcher("/about/:person"), {
-       *   person: "bob"
-       * });
-       * // $bob == "/about/bob";
-       * 
- * - * @param {UrlMatcher} urlMatcher The `UrlMatcher` object which is used as the template of the URL to generate. - * @param {object=} params An object of parameter values to fill the matcher's required parameters. - * @param {object=} options Options object. The options are: - * - * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl". - * - * @returns {string} Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher` - */ - href: function(urlMatcher, params, options) { - if (!urlMatcher.validates(params)) return null; - - var isHtml5 = $locationProvider.html5Mode(); - var url = urlMatcher.format(params); - options = options || {}; - - if (!isHtml5 && url !== null) { - url = "#" + $locationProvider.hashPrefix() + url; - } - url = appendBasePath(url, isHtml5, options.absolute); - - if (!options.absolute || !url) { - return url; - } - - var slash = (!isHtml5 && url ? '/' : ''), port = $location.port(); - port = (port === 80 || port === 443 ? '' : ':' + port); - - return [$location.protocol(), '://', $location.host(), port, slash, url].join(''); - } - }; - } -} - -angular.module('ui.router.router').provider('$urlRouter', $UrlRouterProvider); - -/** - * @ngdoc object - * @name ui.router.state.$stateProvider - * - * @requires ui.router.router.$urlRouterProvider - * @requires ui.router.util.$urlMatcherFactoryProvider - * - * @description - * The new `$stateProvider` works similar to Angular's v1 router, but it focuses purely - * on state. - * - * A state corresponds to a "place" in the application in terms of the overall UI and - * navigation. A state describes (via the controller / template / view properties) what - * the UI looks like and does at that place. - * - * States often have things in common, and the primary way of factoring out these - * commonalities in this model is via the state hierarchy, i.e. parent/child states aka - * nested states. - * - * The `$stateProvider` provides interfaces to declare these states for your app. - */ -$StateProvider.$inject = ['$urlRouterProvider', '$urlMatcherFactoryProvider']; -function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { - - var root, states = {}, $state, queue = {}, abstractKey = 'abstract'; - - // Builds state properties from definition passed to registerState() - var stateBuilder = { - - // Derive parent state from a hierarchical name only if 'parent' is not explicitly defined. - // state.children = []; - // if (parent) parent.children.push(state); - parent: function(state) { - if (isDefined(state.parent) && state.parent) return findState(state.parent); - // regex matches any valid composite state name - // would match "contact.list" but not "contacts" - var compositeName = /^(.+)\.[^.]+$/.exec(state.name); - return compositeName ? findState(compositeName[1]) : root; - }, - - // inherit 'data' from parent and override by own values (if any) - data: function(state) { - if (state.parent && state.parent.data) { - state.data = state.self.data = extend({}, state.parent.data, state.data); - } - return state.data; - }, - - // Build a URLMatcher if necessary, either via a relative or absolute URL - url: function(state) { - var url = state.url, config = { params: state.params || {} }; - - if (isString(url)) { - if (url.charAt(0) == '^') return $urlMatcherFactory.compile(url.substring(1), config); - return (state.parent.navigable || root).url.concat(url, config); - } - - if (!url || $urlMatcherFactory.isMatcher(url)) return url; - throw new Error("Invalid url '" + url + "' in state '" + state + "'"); - }, - - // Keep track of the closest ancestor state that has a URL (i.e. is navigable) - navigable: function(state) { - return state.url ? state : (state.parent ? state.parent.navigable : null); - }, - - // Derive parameters for this state and ensure they're a super-set of parent's parameters - params: function(state) { - if (!state.params) { - return state.url ? state.url.params : state.parent.params; - } - return state.params; - }, - - // If there is no explicit multi-view configuration, make one up so we don't have - // to handle both cases in the view directive later. Note that having an explicit - // 'views' property will mean the default unnamed view properties are ignored. This - // is also a good time to resolve view names to absolute names, so everything is a - // straight lookup at link time. - views: function(state) { - var views = {}; - - forEach(isDefined(state.views) ? state.views : { '': state }, function (view, name) { - if (name.indexOf('@') < 0) name += '@' + state.parent.name; - views[name] = view; - }); - return views; - }, - - ownParams: function(state) { - state.params = state.params || {}; - - if (!state.parent) { - return objectKeys(state.params); - } - var paramNames = {}; forEach(state.params, function (v, k) { paramNames[k] = true; }); - - forEach(state.parent.params, function (v, k) { - if (!paramNames[k]) { - throw new Error("Missing required parameter '" + k + "' in state '" + state.name + "'"); - } - paramNames[k] = false; - }); - var ownParams = []; - - forEach(paramNames, function (own, p) { - if (own) ownParams.push(p); - }); - return ownParams; - }, - - // Keep a full path from the root down to this state as this is needed for state activation. - path: function(state) { - return state.parent ? state.parent.path.concat(state) : []; // exclude root from path - }, - - // Speed up $state.contains() as it's used a lot - includes: function(state) { - var includes = state.parent ? extend({}, state.parent.includes) : {}; - includes[state.name] = true; - return includes; - }, - - $delegates: {} - }; - - function isRelative(stateName) { - return stateName.indexOf(".") === 0 || stateName.indexOf("^") === 0; - } - - function findState(stateOrName, base) { - if (!stateOrName) return undefined; - - var isStr = isString(stateOrName), - name = isStr ? stateOrName : stateOrName.name, - path = isRelative(name); - - if (path) { - if (!base) throw new Error("No reference point given for path '" + name + "'"); - var rel = name.split("."), i = 0, pathLength = rel.length, current = base; - - for (; i < pathLength; i++) { - if (rel[i] === "" && i === 0) { - current = base; - continue; - } - if (rel[i] === "^") { - if (!current.parent) throw new Error("Path '" + name + "' not valid for state '" + base.name + "'"); - current = current.parent; - continue; - } - break; - } - rel = rel.slice(i).join("."); - name = current.name + (current.name && rel ? "." : "") + rel; - } - var state = states[name]; - - if (state && (isStr || (!isStr && (state === stateOrName || state.self === stateOrName)))) { - return state; - } - return undefined; - } - - function queueState(parentName, state) { - if (!queue[parentName]) { - queue[parentName] = []; - } - queue[parentName].push(state); - } - - function registerState(state) { - // Wrap a new object around the state so we can store our private details easily. - state = inherit(state, { - self: state, - resolve: state.resolve || {}, - toString: function() { return this.name; } - }); - - var name = state.name; - if (!isString(name) || name.indexOf('@') >= 0) throw new Error("State must have a valid name"); - if (states.hasOwnProperty(name)) throw new Error("State '" + name + "'' is already defined"); - - // Get parent name - var parentName = (name.indexOf('.') !== -1) ? name.substring(0, name.lastIndexOf('.')) - : (isString(state.parent)) ? state.parent - : ''; - - // If parent is not registered yet, add state to queue and register later - if (parentName && !states[parentName]) { - return queueState(parentName, state.self); - } - - for (var key in stateBuilder) { - if (isFunction(stateBuilder[key])) state[key] = stateBuilder[key](state, stateBuilder.$delegates[key]); - } - states[name] = state; - - // Register the state in the global state list and with $urlRouter if necessary. - if (!state[abstractKey] && state.url) { - $urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) { - if ($state.$current.navigable != state || !equalForKeys($match, $stateParams)) { - $state.transitionTo(state, $match, { location: false }); - } - }]); - } - - // Register any queued children - if (queue[name]) { - for (var i = 0; i < queue[name].length; i++) { - registerState(queue[name][i]); - } - } - - return state; - } - - // Checks text to see if it looks like a glob. - function isGlob (text) { - return text.indexOf('*') > -1; - } - - // Returns true if glob matches current $state name. - function doesStateMatchGlob (glob) { - var globSegments = glob.split('.'), - segments = $state.$current.name.split('.'); - - //match greedy starts - if (globSegments[0] === '**') { - segments = segments.slice(segments.indexOf(globSegments[1])); - segments.unshift('**'); - } - //match greedy ends - if (globSegments[globSegments.length - 1] === '**') { - segments.splice(segments.indexOf(globSegments[globSegments.length - 2]) + 1, Number.MAX_VALUE); - segments.push('**'); - } - - if (globSegments.length != segments.length) { - return false; - } - - //match single stars - for (var i = 0, l = globSegments.length; i < l; i++) { - if (globSegments[i] === '*') { - segments[i] = '*'; - } - } - - return segments.join('') === globSegments.join(''); - } - - - // Implicit root state that is always active - root = registerState({ - name: '', - url: '^', - views: null, - 'abstract': true - }); - root.navigable = null; - - - /** - * @ngdoc function - * @name ui.router.state.$stateProvider#decorator - * @methodOf ui.router.state.$stateProvider - * - * @description - * Allows you to extend (carefully) or override (at your own peril) the - * `stateBuilder` object used internally by `$stateProvider`. This can be used - * to add custom functionality to ui-router, for example inferring templateUrl - * based on the state name. - * - * When passing only a name, it returns the current (original or decorated) builder - * function that matches `name`. - * - * The builder functions that can be decorated are listed below. Though not all - * necessarily have a good use case for decoration, that is up to you to decide. - * - * In addition, users can attach custom decorators, which will generate new - * properties within the state's internal definition. There is currently no clear - * use-case for this beyond accessing internal states (i.e. $state.$current), - * however, expect this to become increasingly relevant as we introduce additional - * meta-programming features. - * - * **Warning**: Decorators should not be interdependent because the order of - * execution of the builder functions in non-deterministic. Builder functions - * should only be dependent on the state definition object and super function. - * - * - * Existing builder functions and current return values: - * - * - **parent** `{object}` - returns the parent state object. - * - **data** `{object}` - returns state data, including any inherited data that is not - * overridden by own values (if any). - * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher} - * or `null`. - * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is - * navigable). - * - **params** `{object}` - returns an array of state params that are ensured to - * be a super-set of parent's params. - * - **views** `{object}` - returns a views object where each key is an absolute view - * name (i.e. "viewName@stateName") and each value is the config object - * (template, controller) for the view. Even when you don't use the views object - * explicitly on a state config, one is still created for you internally. - * So by decorating this builder function you have access to decorating template - * and controller properties. - * - **ownParams** `{object}` - returns an array of params that belong to the state, - * not including any params defined by ancestor states. - * - **path** `{string}` - returns the full path from the root down to this state. - * Needed for state activation. - * - **includes** `{object}` - returns an object that includes every state that - * would pass a `$state.includes()` test. - * - * @example - *
-   * // Override the internal 'views' builder with a function that takes the state
-   * // definition, and a reference to the internal function being overridden:
-   * $stateProvider.decorator('views', function (state, parent) {
-   *   var result = {},
-   *       views = parent(state);
-   *
-   *   angular.forEach(views, function (config, name) {
-   *     var autoName = (state.name + '.' + name).replace('.', '/');
-   *     config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
-   *     result[name] = config;
-   *   });
-   *   return result;
-   * });
-   *
-   * $stateProvider.state('home', {
-   *   views: {
-   *     'contact.list': { controller: 'ListController' },
-   *     'contact.item': { controller: 'ItemController' }
-   *   }
-   * });
-   *
-   * // ...
-   *
-   * $state.go('home');
-   * // Auto-populates list and item views with /partials/home/contact/list.html,
-   * // and /partials/home/contact/item.html, respectively.
-   * 
- * - * @param {string} name The name of the builder function to decorate. - * @param {object} func A function that is responsible for decorating the original - * builder function. The function receives two parameters: - * - * - `{object}` - state - The state config object. - * - `{object}` - super - The original builder function. - * - * @return {object} $stateProvider - $stateProvider instance - */ - this.decorator = decorator; - function decorator(name, func) { - /*jshint validthis: true */ - if (isString(name) && !isDefined(func)) { - return stateBuilder[name]; - } - if (!isFunction(func) || !isString(name)) { - return this; - } - if (stateBuilder[name] && !stateBuilder.$delegates[name]) { - stateBuilder.$delegates[name] = stateBuilder[name]; - } - stateBuilder[name] = func; - return this; - } - - /** - * @ngdoc function - * @name ui.router.state.$stateProvider#state - * @methodOf ui.router.state.$stateProvider - * - * @description - * Registers a state configuration under a given state name. The stateConfig object - * has the following acceptable properties. - * - * - * - * - **`template`** - {string|function=} - html template as a string or a function that returns - * an html template as a string which should be used by the uiView directives. This property - * takes precedence over templateUrl. - * - * If `template` is a function, it will be called with the following parameters: - * - * - {array.<object>} - state parameters extracted from the current $location.path() by - * applying the current state - * - * - * - * - **`templateUrl`** - {string|function=} - path or function that returns a path to an html - * template that should be used by uiView. - * - * If `templateUrl` is a function, it will be called with the following parameters: - * - * - {array.<object>} - state parameters extracted from the current $location.path() by - * applying the current state - * - * - * - * - **`templateProvider`** - {function=} - Provider function that returns HTML content - * string. - * - * - * - * - **`controller`** - {string|function=} - Controller fn that should be associated with newly - * related scope or the name of a registered controller if passed as a string. - * - * - * - * - **`controllerProvider`** - {function=} - Injectable provider function that returns - * the actual controller or string. - * - * - * - * - **`controllerAs`** – {string=} – A controller alias name. If present the controller will be - * published to scope under the controllerAs name. - * - * - * - * - **`resolve`** - {object.<string, function>=} - An optional map of dependencies which - * should be injected into the controller. If any of these dependencies are promises, - * the router will wait for them all to be resolved or one to be rejected before the - * controller is instantiated. If all the promises are resolved successfully, the values - * of the resolved promises are injected and $stateChangeSuccess event is fired. If any - * of the promises are rejected the $stateChangeError event is fired. The map object is: - * - * - key - {string}: name of dependency to be injected into controller - * - factory - {string|function}: If string then it is alias for service. Otherwise if function, - * it is injected and return value it treated as dependency. If result is a promise, it is - * resolved before its value is injected into controller. - * - * - * - * - **`url`** - {string=} - A url with optional parameters. When a state is navigated or - * transitioned to, the `$stateParams` service will be populated with any - * parameters that were passed. - * - * - * - * - **`params`** - {object=} - An array of parameter names or regular expressions. Only - * use this within a state if you are not using url. Otherwise you can specify your - * parameters within the url. When a state is navigated or transitioned to, the - * $stateParams service will be populated with any parameters that were passed. - * - * - * - * - **`views`** - {object=} - Use the views property to set up multiple views or to target views - * manually/explicitly. - * - * - * - * - **`abstract`** - {boolean=} - An abstract state will never be directly activated, - * but can provide inherited properties to its common children states. - * - * - * - * - **`onEnter`** - {object=} - Callback function for when a state is entered. Good way - * to trigger an action or dispatch an event, such as opening a dialog. - * If minifying your scripts, make sure to use the `['injection1', 'injection2', function(injection1, injection2){}]` syntax. - * - * - * - * - **`onExit`** - {object=} - Callback function for when a state is exited. Good way to - * trigger an action or dispatch an event, such as opening a dialog. - * If minifying your scripts, make sure to use the `['injection1', 'injection2', function(injection1, injection2){}]` syntax. - * - * - * - * - **`reloadOnSearch = true`** - {boolean=} - If `false`, will not retrigger the same state - * just because a search/query parameter has changed (via $location.search() or $location.hash()). - * Useful for when you'd like to modify $location.search() without triggering a reload. - * - * - * - * - **`data`** - {object=} - Arbitrary data object, useful for custom configuration. - * - * @example - *
-   * // Some state name examples
-   *
-   * // stateName can be a single top-level name (must be unique).
-   * $stateProvider.state("home", {});
-   *
-   * // Or it can be a nested state name. This state is a child of the 
-   * // above "home" state.
-   * $stateProvider.state("home.newest", {});
-   *
-   * // Nest states as deeply as needed.
-   * $stateProvider.state("home.newest.abc.xyz.inception", {});
-   *
-   * // state() returns $stateProvider, so you can chain state declarations.
-   * $stateProvider
-   *   .state("home", {})
-   *   .state("about", {})
-   *   .state("contacts", {});
-   * 
- * - * @param {string} name A unique state name, e.g. "home", "about", "contacts". - * To create a parent/child state use a dot, e.g. "about.sales", "home.newest". - * @param {object} definition State configuration object. - */ - this.state = state; - function state(name, definition) { - /*jshint validthis: true */ - if (isObject(name)) definition = name; - else definition.name = name; - registerState(definition); - return this; - } - - /** - * @ngdoc object - * @name ui.router.state.$state - * - * @requires $rootScope - * @requires $q - * @requires ui.router.state.$view - * @requires $injector - * @requires ui.router.util.$resolve - * @requires ui.router.state.$stateParams - * @requires ui.router.router.$urlRouter - * - * @property {object} params A param object, e.g. {sectionId: section.id)}, that - * you'd like to test against the current active state. - * @property {object} current A reference to the state's config object. However - * you passed it in. Useful for accessing custom data. - * @property {object} transition Currently pending transition. A promise that'll - * resolve or reject. - * - * @description - * `$state` service is responsible for representing states as well as transitioning - * between them. It also provides interfaces to ask for current state or even states - * you're coming from. - */ - this.$get = $get; - $get.$inject = ['$rootScope', '$q', '$view', '$injector', '$resolve', '$stateParams', '$urlRouter']; - function $get( $rootScope, $q, $view, $injector, $resolve, $stateParams, $urlRouter) { - - var TransitionSuperseded = $q.reject(new Error('transition superseded')); - var TransitionPrevented = $q.reject(new Error('transition prevented')); - var TransitionAborted = $q.reject(new Error('transition aborted')); - var TransitionFailed = $q.reject(new Error('transition failed')); - - // Handles the case where a state which is the target of a transition is not found, and the user - // can optionally retry or defer the transition - function handleRedirect(redirect, state, params, options) { - /** - * @ngdoc event - * @name ui.router.state.$state#$stateNotFound - * @eventOf ui.router.state.$state - * @eventType broadcast on root scope - * @description - * Fired when a requested state **cannot be found** using the provided state name during transition. - * The event is broadcast allowing any handlers a single chance to deal with the error (usually by - * lazy-loading the unfound state). A special `unfoundState` object is passed to the listener handler, - * you can see its three properties in the example. You can use `event.preventDefault()` to abort the - * transition and the promise returned from `go` will be rejected with a `'transition aborted'` value. - * - * @param {Object} event Event object. - * @param {Object} unfoundState Unfound State information. Contains: `to, toParams, options` properties. - * @param {State} fromState Current state object. - * @param {Object} fromParams Current state params. - * - * @example - * - *
-       * // somewhere, assume lazy.state has not been defined
-       * $state.go("lazy.state", {a:1, b:2}, {inherit:false});
-       *
-       * // somewhere else
-       * $scope.$on('$stateNotFound',
-       * function(event, unfoundState, fromState, fromParams){
-       *     console.log(unfoundState.to); // "lazy.state"
-       *     console.log(unfoundState.toParams); // {a:1, b:2}
-       *     console.log(unfoundState.options); // {inherit:false} + default options
-       * })
-       * 
- */ - var evt = $rootScope.$broadcast('$stateNotFound', redirect, state, params); - - if (evt.defaultPrevented) { - $urlRouter.update(); - return TransitionAborted; - } - - if (!evt.retry) { - return null; - } - - // Allow the handler to return a promise to defer state lookup retry - if (options.$retry) { - $urlRouter.update(); - return TransitionFailed; - } - var retryTransition = $state.transition = $q.when(evt.retry); - - retryTransition.then(function() { - if (retryTransition !== $state.transition) return TransitionSuperseded; - redirect.options.$retry = true; - return $state.transitionTo(redirect.to, redirect.toParams, redirect.options); - }, function() { - return TransitionAborted; - }); - $urlRouter.update(); - - return retryTransition; - } - - root.locals = { resolve: null, globals: { $stateParams: {} } }; - - $state = { - params: {}, - current: root.self, - $current: root, - transition: null - }; - - /** - * @ngdoc function - * @name ui.router.state.$state#reload - * @methodOf ui.router.state.$state - * - * @description - * A method that force reloads the current state. All resolves are re-resolved, events are not re-fired, - * and controllers reinstantiated (bug with controllers reinstantiating right now, fixing soon). - * - * @example - *
-     * var app angular.module('app', ['ui.router']);
-     *
-     * app.controller('ctrl', function ($scope, $state) {
-     *   $scope.reload = function(){
-     *     $state.reload();
-     *   }
-     * });
-     * 
- * - * `reload()` is just an alias for: - *
-     * $state.transitionTo($state.current, $stateParams, { 
-     *   reload: true, inherit: false, notify: false 
-     * });
-     * 
- */ - $state.reload = function reload() { - $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: false }); - }; - - /** - * @ngdoc function - * @name ui.router.state.$state#go - * @methodOf ui.router.state.$state - * - * @description - * Convenience method for transitioning to a new state. `$state.go` calls - * `$state.transitionTo` internally but automatically sets options to - * `{ location: true, inherit: true, relative: $state.$current, notify: true }`. - * This allows you to easily use an absolute or relative to path and specify - * only the parameters you'd like to update (while letting unspecified parameters - * inherit from the currently active ancestor states). - * - * @example - *
-     * var app = angular.module('app', ['ui.router']);
-     *
-     * app.controller('ctrl', function ($scope, $state) {
-     *   $scope.changeState = function () {
-     *     $state.go('contact.detail');
-     *   };
-     * });
-     * 
- * - * - * @param {string} to Absolute state name or relative state path. Some examples: - * - * - `$state.go('contact.detail')` - will go to the `contact.detail` state - * - `$state.go('^')` - will go to a parent state - * - `$state.go('^.sibling')` - will go to a sibling state - * - `$state.go('.child.grandchild')` - will go to grandchild state - * - * @param {object=} params A map of the parameters that will be sent to the state, - * will populate $stateParams. Any parameters that are not specified will be inherited from currently - * defined parameters. This allows, for example, going to a sibling state that shares parameters - * specified in a parent state. Parameter inheritance only works between common ancestor states, I.e. - * transitioning to a sibling will get you the parameters for all parents, transitioning to a child - * will get you all current parameters, etc. - * @param {object=} options Options object. The options are: - * - * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false` - * will not. If string, must be `"replace"`, which will update url and also replace last history record. - * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url. - * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'), - * defines which state to be relative from. - * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events. - * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params - * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd - * use this when you want to force a reload when *everything* is the same, including search params. - * - * @returns {promise} A promise representing the state of the new transition. - * - * Possible success values: - * - * - $state.current - * - *
Possible rejection values: - * - * - 'transition superseded' - when a newer transition has been started after this one - * - 'transition prevented' - when `event.preventDefault()` has been called in a `$stateChangeStart` listener - * - 'transition aborted' - when `event.preventDefault()` has been called in a `$stateNotFound` listener or - * when a `$stateNotFound` `event.retry` promise errors. - * - 'transition failed' - when a state has been unsuccessfully found after 2 tries. - * - *resolve error* - when an error has occurred with a `resolve` - * - */ - $state.go = function go(to, params, options) { - return $state.transitionTo(to, params, extend({ inherit: true, relative: $state.$current }, options)); - }; - - /** - * @ngdoc function - * @name ui.router.state.$state#transitionTo - * @methodOf ui.router.state.$state - * - * @description - * Low-level method for transitioning to a new state. {@link ui.router.state.$state#methods_go $state.go} - * uses `transitionTo` internally. `$state.go` is recommended in most situations. - * - * @example - *
-     * var app = angular.module('app', ['ui.router']);
-     *
-     * app.controller('ctrl', function ($scope, $state) {
-     *   $scope.changeState = function () {
-     *     $state.transitionTo('contact.detail');
-     *   };
-     * });
-     * 
- * - * @param {string} to State name. - * @param {object=} toParams A map of the parameters that will be sent to the state, - * will populate $stateParams. - * @param {object=} options Options object. The options are: - * - * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false` - * will not. If string, must be `"replace"`, which will update url and also replace last history record. - * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url. - * - **`relative`** - {object=}, When transitioning with relative path (e.g '^'), - * defines which state to be relative from. - * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events. - * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params - * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd - * use this when you want to force a reload when *everything* is the same, including search params. - * - * @returns {promise} A promise representing the state of the new transition. See - * {@link ui.router.state.$state#methods_go $state.go}. - */ - $state.transitionTo = function transitionTo(to, toParams, options) { - toParams = toParams || {}; - options = extend({ - location: true, inherit: false, relative: null, notify: true, reload: false, $retry: false - }, options || {}); - - var from = $state.$current, fromParams = $state.params, fromPath = from.path; - var evt, toState = findState(to, options.relative); - - if (!isDefined(toState)) { - var redirect = { to: to, toParams: toParams, options: options }; - var redirectResult = handleRedirect(redirect, from.self, fromParams, options); - - if (redirectResult) { - return redirectResult; - } - - // Always retry once if the $stateNotFound was not prevented - // (handles either redirect changed or state lazy-definition) - to = redirect.to; - toParams = redirect.toParams; - options = redirect.options; - toState = findState(to, options.relative); - - if (!isDefined(toState)) { - if (!options.relative) throw new Error("No such state '" + to + "'"); - throw new Error("Could not resolve '" + to + "' from state '" + options.relative + "'"); - } - } - if (toState[abstractKey]) throw new Error("Cannot transition to abstract state '" + to + "'"); - if (options.inherit) toParams = inheritParams($stateParams, toParams || {}, $state.$current, toState); - to = toState; - - var toPath = to.path; - - // Starting from the root of the path, keep all levels that haven't changed - var keep = 0, state = toPath[keep], locals = root.locals, toLocals = []; - - if (!options.reload) { - while (state && state === fromPath[keep] && equalForKeys(toParams, fromParams, state.ownParams)) { - locals = toLocals[keep] = state.locals; - keep++; - state = toPath[keep]; - } - } - - // If we're going to the same state and all locals are kept, we've got nothing to do. - // But clear 'transition', as we still want to cancel any other pending transitions. - // TODO: We may not want to bump 'transition' if we're called from a location change - // that we've initiated ourselves, because we might accidentally abort a legitimate - // transition initiated from code? - if (shouldTriggerReload(to, from, locals, options)) { - if (to.self.reloadOnSearch !== false) $urlRouter.update(); - $state.transition = null; - return $q.when($state.current); - } - - // Filter parameters before we pass them to event handlers etc. - toParams = filterByKeys(objectKeys(to.params), toParams || {}); - - // Broadcast start event and cancel the transition if requested - if (options.notify) { - /** - * @ngdoc event - * @name ui.router.state.$state#$stateChangeStart - * @eventOf ui.router.state.$state - * @eventType broadcast on root scope - * @description - * Fired when the state transition **begins**. You can use `event.preventDefault()` - * to prevent the transition from happening and then the transition promise will be - * rejected with a `'transition prevented'` value. - * - * @param {Object} event Event object. - * @param {State} toState The state being transitioned to. - * @param {Object} toParams The params supplied to the `toState`. - * @param {State} fromState The current state, pre-transition. - * @param {Object} fromParams The params supplied to the `fromState`. - * - * @example - * - *
-         * $rootScope.$on('$stateChangeStart',
-         * function(event, toState, toParams, fromState, fromParams){
-         *     event.preventDefault();
-         *     // transitionTo() promise will be rejected with
-         *     // a 'transition prevented' error
-         * })
-         * 
- */ - if ($rootScope.$broadcast('$stateChangeStart', to.self, toParams, from.self, fromParams).defaultPrevented) { - $urlRouter.update(); - return TransitionPrevented; - } - } - - // Resolve locals for the remaining states, but don't update any global state just - // yet -- if anything fails to resolve the current state needs to remain untouched. - // We also set up an inheritance chain for the locals here. This allows the view directive - // to quickly look up the correct definition for each view in the current state. Even - // though we create the locals object itself outside resolveState(), it is initially - // empty and gets filled asynchronously. We need to keep track of the promise for the - // (fully resolved) current locals, and pass this down the chain. - var resolved = $q.when(locals); - - for (var l = keep; l < toPath.length; l++, state = toPath[l]) { - locals = toLocals[l] = inherit(locals); - resolved = resolveState(state, toParams, state === to, resolved, locals); - } - - // Once everything is resolved, we are ready to perform the actual transition - // and return a promise for the new state. We also keep track of what the - // current promise is, so that we can detect overlapping transitions and - // keep only the outcome of the last transition. - var transition = $state.transition = resolved.then(function () { - var l, entering, exiting; - - if ($state.transition !== transition) return TransitionSuperseded; - - // Exit 'from' states not kept - for (l = fromPath.length - 1; l >= keep; l--) { - exiting = fromPath[l]; - if (exiting.self.onExit) { - $injector.invoke(exiting.self.onExit, exiting.self, exiting.locals.globals); - } - exiting.locals = null; - } - - // Enter 'to' states not kept - for (l = keep; l < toPath.length; l++) { - entering = toPath[l]; - entering.locals = toLocals[l]; - if (entering.self.onEnter) { - $injector.invoke(entering.self.onEnter, entering.self, entering.locals.globals); - } - } - - // Run it again, to catch any transitions in callbacks - if ($state.transition !== transition) return TransitionSuperseded; - - // Update globals in $state - $state.$current = to; - $state.current = to.self; - $state.params = toParams; - copy($state.params, $stateParams); - $state.transition = null; - - if (options.location && to.navigable) { - $urlRouter.push(to.navigable.url, to.navigable.locals.globals.$stateParams, { - replace: options.location === 'replace' - }); - } - - if (options.notify) { - /** - * @ngdoc event - * @name ui.router.state.$state#$stateChangeSuccess - * @eventOf ui.router.state.$state - * @eventType broadcast on root scope - * @description - * Fired once the state transition is **complete**. - * - * @param {Object} event Event object. - * @param {State} toState The state being transitioned to. - * @param {Object} toParams The params supplied to the `toState`. - * @param {State} fromState The current state, pre-transition. - * @param {Object} fromParams The params supplied to the `fromState`. - */ - $rootScope.$broadcast('$stateChangeSuccess', to.self, toParams, from.self, fromParams); - } - $urlRouter.update(true); - - return $state.current; - }, function (error) { - if ($state.transition !== transition) return TransitionSuperseded; - - $state.transition = null; - /** - * @ngdoc event - * @name ui.router.state.$state#$stateChangeError - * @eventOf ui.router.state.$state - * @eventType broadcast on root scope - * @description - * Fired when an **error occurs** during transition. It's important to note that if you - * have any errors in your resolve functions (javascript errors, non-existent services, etc) - * they will not throw traditionally. You must listen for this $stateChangeError event to - * catch **ALL** errors. - * - * @param {Object} event Event object. - * @param {State} toState The state being transitioned to. - * @param {Object} toParams The params supplied to the `toState`. - * @param {State} fromState The current state, pre-transition. - * @param {Object} fromParams The params supplied to the `fromState`. - * @param {Error} error The resolve error object. - */ - evt = $rootScope.$broadcast('$stateChangeError', to.self, toParams, from.self, fromParams, error); - - if (!evt.defaultPrevented) { - $urlRouter.update(); - } - - return $q.reject(error); - }); - - return transition; - }; - - /** - * @ngdoc function - * @name ui.router.state.$state#is - * @methodOf ui.router.state.$state - * - * @description - * Similar to {@link ui.router.state.$state#methods_includes $state.includes}, - * but only checks for the full state name. If params is supplied then it will be - * tested for strict equality against the current active params object, so all params - * must match with none missing and no extras. - * - * @example - *
-     * $state.$current.name = 'contacts.details.item';
-     *
-     * // absolute name
-     * $state.is('contact.details.item'); // returns true
-     * $state.is(contactDetailItemStateObject); // returns true
-     *
-     * // relative name (. and ^), typically from a template
-     * // E.g. from the 'contacts.details' template
-     * 
Item
- *
- * - * @param {string|object} stateName The state name (absolute or relative) or state object you'd like to check. - * @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like - * to test against the current active state. - * @returns {boolean} Returns true if it is the state. - */ - $state.is = function is(stateOrName, params) { - var state = findState(stateOrName); - - if (!isDefined(state)) { - return undefined; - } - - if ($state.$current !== state) { - return false; - } - - return isDefined(params) && params !== null ? angular.equals($stateParams, params) : true; - }; - - /** - * @ngdoc function - * @name ui.router.state.$state#includes - * @methodOf ui.router.state.$state - * - * @description - * A method to determine if the current active state is equal to or is the child of the - * state stateName. If any params are passed then they will be tested for a match as well. - * Not all the parameters need to be passed, just the ones you'd like to test for equality. - * - * @example - * Partial and relative names - *
-     * $state.$current.name = 'contacts.details.item';
-     *
-     * // Using partial names
-     * $state.includes("contacts"); // returns true
-     * $state.includes("contacts.details"); // returns true
-     * $state.includes("contacts.details.item"); // returns true
-     * $state.includes("contacts.list"); // returns false
-     * $state.includes("about"); // returns false
-     *
-     * // Using relative names (. and ^), typically from a template
-     * // E.g. from the 'contacts.details' template
-     * 
Item
- *
- * - * Basic globbing patterns - *
-     * $state.$current.name = 'contacts.details.item.url';
-     *
-     * $state.includes("*.details.*.*"); // returns true
-     * $state.includes("*.details.**"); // returns true
-     * $state.includes("**.item.**"); // returns true
-     * $state.includes("*.details.item.url"); // returns true
-     * $state.includes("*.details.*.url"); // returns true
-     * $state.includes("*.details.*"); // returns false
-     * $state.includes("item.**"); // returns false
-     * 
- * - * @param {string} stateOrName A partial name, relative name, or glob pattern - * to be searched for within the current state name. - * @param {object} params A param object, e.g. `{sectionId: section.id}`, - * that you'd like to test against the current active state. - * @returns {boolean} Returns true if it does include the state - */ - $state.includes = function includes(stateOrName, params) { - if (isString(stateOrName) && isGlob(stateOrName)) { - if (!doesStateMatchGlob(stateOrName)) { - return false; - } - stateOrName = $state.$current.name; - } - var state = findState(stateOrName); - - if (!isDefined(state)) { - return undefined; - } - if (!isDefined($state.$current.includes[state.name])) { - return false; - } - return equalForKeys(params, $stateParams); - }; - - - /** - * @ngdoc function - * @name ui.router.state.$state#href - * @methodOf ui.router.state.$state - * - * @description - * A url generation method that returns the compiled url for the given state populated with the given params. - * - * @example - *
-     * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
-     * 
- * - * @param {string|object} stateOrName The state name or state object you'd like to generate a url from. - * @param {object=} params An object of parameter values to fill the state's required parameters. - * @param {object=} options Options object. The options are: - * - * - **`lossy`** - {boolean=true} - If true, and if there is no url associated with the state provided in the - * first parameter, then the constructed href url will be built from the first navigable ancestor (aka - * ancestor with a valid url). - * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url. - * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'), - * defines which state to be relative from. - * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl". - * - * @returns {string} compiled state url - */ - $state.href = function href(stateOrName, params, options) { - options = extend({ - lossy: true, - inherit: true, - absolute: false, - relative: $state.$current - }, options || {}); - - var state = findState(stateOrName, options.relative); - - if (!isDefined(state)) return null; - if (options.inherit) params = inheritParams($stateParams, params || {}, $state.$current, state); - - var nav = (state && options.lossy) ? state.navigable : state; - - if (!nav || !nav.url) { - return null; - } - return $urlRouter.href(nav.url, filterByKeys(objectKeys(state.params), params || {}), { - absolute: options.absolute - }); - }; - - /** - * @ngdoc function - * @name ui.router.state.$state#get - * @methodOf ui.router.state.$state - * - * @description - * Returns the state configuration object for any specific state or all states. - * - * @param {string|Sbject=} stateOrName (absolute or relative) If provided, will only get the config for - * the requested state. If not provided, returns an array of ALL state configs. - * @returns {Object|Array} State configuration object or array of all objects. - */ - $state.get = function (stateOrName, context) { - if (arguments.length === 0) return objectKeys(states).map(function(name) { return states[name].self; }); - var state = findState(stateOrName, context); - return (state && state.self) ? state.self : null; - }; - - function resolveState(state, params, paramsAreFiltered, inherited, dst) { - // Make a restricted $stateParams with only the parameters that apply to this state if - // necessary. In addition to being available to the controller and onEnter/onExit callbacks, - // we also need $stateParams to be available for any $injector calls we make during the - // dependency resolution process. - var $stateParams = (paramsAreFiltered) ? params : filterByKeys(objectKeys(state.params), params); - var locals = { $stateParams: $stateParams }; - - // Resolve 'global' dependencies for the state, i.e. those not specific to a view. - // We're also including $stateParams in this; that way the parameters are restricted - // to the set that should be visible to the state, and are independent of when we update - // the global $state and $stateParams values. - dst.resolve = $resolve.resolve(state.resolve, locals, dst.resolve, state); - var promises = [dst.resolve.then(function (globals) { - dst.globals = globals; - })]; - if (inherited) promises.push(inherited); - - // Resolve template and dependencies for all views. - forEach(state.views, function (view, name) { - var injectables = (view.resolve && view.resolve !== state.resolve ? view.resolve : {}); - injectables.$template = [ function () { - return $view.load(name, { view: view, locals: locals, params: $stateParams }) || ''; - }]; - - promises.push($resolve.resolve(injectables, locals, dst.resolve, state).then(function (result) { - // References to the controller (only instantiated at link time) - if (isFunction(view.controllerProvider) || isArray(view.controllerProvider)) { - var injectLocals = angular.extend({}, injectables, locals); - result.$$controller = $injector.invoke(view.controllerProvider, null, injectLocals); - } else { - result.$$controller = view.controller; - } - // Provide access to the state itself for internal use - result.$$state = state; - result.$$controllerAs = view.controllerAs; - dst[name] = result; - })); - }); - - // Wait for all the promises and then return the activation object - return $q.all(promises).then(function (values) { - return dst; - }); - } - - return $state; - } - - function shouldTriggerReload(to, from, locals, options) { - if (to === from && ((locals === from.locals && !options.reload) || (to.self.reloadOnSearch === false))) { - return true; - } - } -} - -angular.module('ui.router.state') - .value('$stateParams', {}) - .provider('$state', $StateProvider); - - -$ViewProvider.$inject = []; -function $ViewProvider() { - - this.$get = $get; - /** - * @ngdoc object - * @name ui.router.state.$view - * - * @requires ui.router.util.$templateFactory - * @requires $rootScope - * - * @description - * - */ - $get.$inject = ['$rootScope', '$templateFactory']; - function $get( $rootScope, $templateFactory) { - return { - // $view.load('full.viewName', { template: ..., controller: ..., resolve: ..., async: false, params: ... }) - /** - * @ngdoc function - * @name ui.router.state.$view#load - * @methodOf ui.router.state.$view - * - * @description - * - * @param {string} name name - * @param {object} options option object. - */ - load: function load(name, options) { - var result, defaults = { - template: null, controller: null, view: null, locals: null, notify: true, async: true, params: {} - }; - options = extend(defaults, options); - - if (options.view) { - result = $templateFactory.fromConfig(options.view, options.params, options.locals); - } - if (result && options.notify) { - /** - * @ngdoc event - * @name ui.router.state.$state#$viewContentLoading - * @eventOf ui.router.state.$view - * @eventType broadcast on root scope - * @description - * - * Fired once the view **begins loading**, *before* the DOM is rendered. - * - * @param {Object} event Event object. - * @param {Object} viewConfig The view config properties (template, controller, etc). - * - * @example - * - *
-         * $scope.$on('$viewContentLoading',
-         * function(event, viewConfig){
-         *     // Access to all the view config properties.
-         *     // and one special property 'targetView'
-         *     // viewConfig.targetView
-         * });
-         * 
- */ - $rootScope.$broadcast('$viewContentLoading', options); - } - return result; - } - }; - } -} - -angular.module('ui.router.state').provider('$view', $ViewProvider); - -/** - * @ngdoc object - * @name ui.router.state.$uiViewScrollProvider - * - * @description - * Provider that returns the {@link ui.router.state.$uiViewScroll} service function. - */ -function $ViewScrollProvider() { - - var useAnchorScroll = false; - - /** - * @ngdoc function - * @name ui.router.state.$uiViewScrollProvider#useAnchorScroll - * @methodOf ui.router.state.$uiViewScrollProvider - * - * @description - * Reverts back to using the core [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll) service for - * scrolling based on the url anchor. - */ - this.useAnchorScroll = function () { - useAnchorScroll = true; - }; - - /** - * @ngdoc object - * @name ui.router.state.$uiViewScroll - * - * @requires $anchorScroll - * @requires $timeout - * - * @description - * When called with a jqLite element, it scrolls the element into view (after a - * `$timeout` so the DOM has time to refresh). - * - * If you prefer to rely on `$anchorScroll` to scroll the view to the anchor, - * this can be enabled by calling {@link ui.router.state.$uiViewScrollProvider#methods_useAnchorScroll `$uiViewScrollProvider.useAnchorScroll()`}. - */ - this.$get = ['$anchorScroll', '$timeout', function ($anchorScroll, $timeout) { - if (useAnchorScroll) { - return $anchorScroll; - } - - return function ($element) { - $timeout(function () { - $element[0].scrollIntoView(); - }, 0, false); - }; - }]; -} - -angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider); - -/** - * @ngdoc directive - * @name ui.router.state.directive:ui-view - * - * @requires ui.router.state.$state - * @requires $compile - * @requires $controller - * @requires $injector - * @requires ui.router.state.$uiViewScroll - * @requires $document - * - * @restrict ECA - * - * @description - * The ui-view directive tells $state where to place your templates. - * - * @param {string=} ui-view A view name. The name should be unique amongst the other views in the - * same state. You can have views of the same name that live in different states. - * - * @param {string=} autoscroll It allows you to set the scroll behavior of the browser window - * when a view is populated. By default, $anchorScroll is overridden by ui-router's custom scroll - * service, {@link ui.router.state.$uiViewScroll}. This custom service let's you - * scroll ui-view elements into view when they are populated during a state activation. - * - * *Note: To revert back to old [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll) - * functionality, call `$uiViewScrollProvider.useAnchorScroll()`.* - * - * @param {string=} onload Expression to evaluate whenever the view updates. - * - * @example - * A view can be unnamed or named. - *
- * 
- * 
- * - * - *
- *
- * - * You can only have one unnamed view within any template (or root html). If you are only using a - * single view and it is unnamed then you can populate it like so: - *
- * 
- * $stateProvider.state("home", { - * template: "

HELLO!

" - * }) - *
- * - * The above is a convenient shortcut equivalent to specifying your view explicitly with the {@link ui.router.state.$stateProvider#views `views`} - * config property, by name, in this case an empty name: - *
- * $stateProvider.state("home", {
- *   views: {
- *     "": {
- *       template: "

HELLO!

" - * } - * } - * }) - *
- * - * But typically you'll only use the views property if you name your view or have more than one view - * in the same template. There's not really a compelling reason to name a view if its the only one, - * but you could if you wanted, like so: - *
- * 
- *
- *
- * $stateProvider.state("home", {
- *   views: {
- *     "main": {
- *       template: "

HELLO!

" - * } - * } - * }) - *
- * - * Really though, you'll use views to set up multiple views: - *
- * 
- *
- *
- *
- * - *
- * $stateProvider.state("home", {
- *   views: {
- *     "": {
- *       template: "

HELLO!

" - * }, - * "chart": { - * template: "" - * }, - * "data": { - * template: "" - * } - * } - * }) - *
- * - * Examples for `autoscroll`: - * - *
- * 
- * 
- *
- * 
- * 
- * 
- * 
- * 
- */ -$ViewDirective.$inject = ['$state', '$injector', '$uiViewScroll']; -function $ViewDirective( $state, $injector, $uiViewScroll) { - - function getService() { - return ($injector.has) ? function(service) { - return $injector.has(service) ? $injector.get(service) : null; - } : function(service) { - try { - return $injector.get(service); - } catch (e) { - return null; - } - }; - } - - var service = getService(), - $animator = service('$animator'), - $animate = service('$animate'); - - // Returns a set of DOM manipulation functions based on which Angular version - // it should use - function getRenderer(attrs, scope) { - var statics = function() { - return { - enter: function (element, target, cb) { target.after(element); cb(); }, - leave: function (element, cb) { element.remove(); cb(); } - }; - }; - - if ($animate) { - return { - enter: function(element, target, cb) { $animate.enter(element, null, target, cb); }, - leave: function(element, cb) { $animate.leave(element, cb); } - }; - } - - if ($animator) { - var animate = $animator && $animator(scope, attrs); - - return { - enter: function(element, target, cb) {animate.enter(element, null, target); cb(); }, - leave: function(element, cb) { animate.leave(element); cb(); } - }; - } - - return statics(); - } - - var directive = { - restrict: 'ECA', - terminal: true, - priority: 400, - transclude: 'element', - compile: function (tElement, tAttrs, $transclude) { - return function (scope, $element, attrs) { - var previousEl, currentEl, currentScope, latestLocals, - onloadExp = attrs.onload || '', - autoScrollExp = attrs.autoscroll, - renderer = getRenderer(attrs, scope); - - scope.$on('$stateChangeSuccess', function() { - updateView(false); - }); - scope.$on('$viewContentLoading', function() { - updateView(false); - }); - - updateView(true); - - function cleanupLastView() { - if (previousEl) { - previousEl.remove(); - previousEl = null; - } - - if (currentScope) { - currentScope.$destroy(); - currentScope = null; - } - - if (currentEl) { - renderer.leave(currentEl, function() { - previousEl = null; - }); - - previousEl = currentEl; - currentEl = null; - } - } - - function updateView(firstTime) { - var newScope, - name = getUiViewName(attrs, $element.inheritedData('$uiView')), - previousLocals = name && $state.$current && $state.$current.locals[name]; - - if (!firstTime && previousLocals === latestLocals) return; // nothing to do - newScope = scope.$new(); - latestLocals = $state.$current.locals[name]; - - var clone = $transclude(newScope, function(clone) { - renderer.enter(clone, $element, function onUiViewEnter() { - if (angular.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) { - $uiViewScroll(clone); - } - }); - cleanupLastView(); - }); - - currentEl = clone; - currentScope = newScope; - /** - * @ngdoc event - * @name ui.router.state.directive:ui-view#$viewContentLoaded - * @eventOf ui.router.state.directive:ui-view - * @eventType emits on ui-view directive scope - * @description * - * Fired once the view is **loaded**, *after* the DOM is rendered. - * - * @param {Object} event Event object. - */ - currentScope.$emit('$viewContentLoaded'); - currentScope.$eval(onloadExp); - } - }; - } - }; - - return directive; -} - -$ViewDirectiveFill.$inject = ['$compile', '$controller', '$state']; -function $ViewDirectiveFill ($compile, $controller, $state) { - return { - restrict: 'ECA', - priority: -400, - compile: function (tElement) { - var initial = tElement.html(); - return function (scope, $element, attrs) { - var current = $state.$current, - name = getUiViewName(attrs, $element.inheritedData('$uiView')), - locals = current && current.locals[name]; - - if (! locals) { - return; - } - - $element.data('$uiView', { name: name, state: locals.$$state }); - $element.html(locals.$template ? locals.$template : initial); - - var link = $compile($element.contents()); - - if (locals.$$controller) { - locals.$scope = scope; - var controller = $controller(locals.$$controller, locals); - if (locals.$$controllerAs) { - scope[locals.$$controllerAs] = controller; - } - $element.data('$ngControllerController', controller); - $element.children().data('$ngControllerController', controller); - } - - link(scope); - }; - } - }; -} - -/** - * Shared ui-view code for both directives: - * Given attributes and inherited $uiView data, return the view's name - */ -function getUiViewName(attrs, inherited) { - var name = attrs.uiView || attrs.name || ''; - return name.indexOf('@') >= 0 ? name : (name + '@' + (inherited ? inherited.state.name : '')); -} - -angular.module('ui.router.state').directive('uiView', $ViewDirective); -angular.module('ui.router.state').directive('uiView', $ViewDirectiveFill); - -function parseStateRef(ref, current) { - var preparsed = ref.match(/^\s*({[^}]*})\s*$/), parsed; - if (preparsed) ref = current + '(' + preparsed[1] + ')'; - parsed = ref.replace(/\n/g, " ").match(/^([^(]+?)\s*(\((.*)\))?$/); - if (!parsed || parsed.length !== 4) throw new Error("Invalid state ref '" + ref + "'"); - return { state: parsed[1], paramExpr: parsed[3] || null }; -} - -function stateContext(el) { - var stateData = el.parent().inheritedData('$uiView'); - - if (stateData && stateData.state && stateData.state.name) { - return stateData.state; - } -} - -/** - * @ngdoc directive - * @name ui.router.state.directive:ui-sref - * - * @requires ui.router.state.$state - * @requires $timeout - * - * @restrict A - * - * @description - * A directive that binds a link (`` tag) to a state. If the state has an associated - * URL, the directive will automatically generate & update the `href` attribute via - * the {@link ui.router.state.$state#methods_href $state.href()} method. Clicking - * the link will trigger a state transition with optional parameters. - * - * Also middle-clicking, right-clicking, and ctrl-clicking on the link will be - * handled natively by the browser. - * - * You can also use relative state paths within ui-sref, just like the relative - * paths passed to `$state.go()`. You just need to be aware that the path is relative - * to the state that the link lives in, in other words the state that loaded the - * template containing the link. - * - * You can specify options to pass to {@link ui.router.state.$state#go $state.go()} - * using the `ui-sref-opts` attribute. Options are restricted to `location`, `inherit`, - * and `reload`. - * - * @example - * Here's an example of how you'd use ui-sref and how it would compile. If you have the - * following template: - *
- * Home | About | Next page
- * 
- * 
- * 
- * - * Then the compiled html would be (assuming Html5Mode is off and current state is contacts): - *
- * Home | About | Next page
- * 
- * 
    - *
  • - * Joe - *
  • - *
  • - * Alice - *
  • - *
  • - * Bob - *
  • - *
- * - * Home - *
- * - * @param {string} ui-sref 'stateName' can be any valid absolute or relative state - * @param {Object} ui-sref-opts options to pass to {@link ui.router.state.$state#go $state.go()} - */ -$StateRefDirective.$inject = ['$state', '$timeout']; -function $StateRefDirective($state, $timeout) { - var allowedOptions = ['location', 'inherit', 'reload']; - - return { - restrict: 'A', - require: ['?^uiSrefActive', '?^uiSrefActiveEq'], - link: function(scope, element, attrs, uiSrefActive) { - var ref = parseStateRef(attrs.uiSref, $state.current.name); - var params = null, url = null, base = stateContext(element) || $state.$current; - var isForm = element[0].nodeName === "FORM"; - var attr = isForm ? "action" : "href", nav = true; - - var options = { relative: base, inherit: true }; - var optionsOverride = scope.$eval(attrs.uiSrefOpts) || {}; - - angular.forEach(allowedOptions, function(option) { - if (option in optionsOverride) { - options[option] = optionsOverride[option]; - } - }); - - var update = function(newVal) { - if (newVal) params = newVal; - if (!nav) return; - - var newHref = $state.href(ref.state, params, options); - - var activeDirective = uiSrefActive[1] || uiSrefActive[0]; - if (activeDirective) { - activeDirective.$$setStateInfo(ref.state, params); - } - if (newHref === null) { - nav = false; - return false; - } - element[0][attr] = newHref; - }; - - if (ref.paramExpr) { - scope.$watch(ref.paramExpr, function(newVal, oldVal) { - if (newVal !== params) update(newVal); - }, true); - params = scope.$eval(ref.paramExpr); - } - update(); - - if (isForm) return; - - element.bind("click", function(e) { - var button = e.which || e.button; - if ( !(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || element.attr('target')) ) { - // HACK: This is to allow ng-clicks to be processed before the transition is initiated: - var transition = $timeout(function() { - $state.go(ref.state, params, options); - }); - e.preventDefault(); - - e.preventDefault = function() { - $timeout.cancel(transition); - }; - } - }); - } - }; -} - -/** - * @ngdoc directive - * @name ui.router.state.directive:ui-sref-active - * - * @requires ui.router.state.$state - * @requires ui.router.state.$stateParams - * @requires $interpolate - * - * @restrict A - * - * @description - * A directive working alongside ui-sref to add classes to an element when the - * related ui-sref directive's state is active, and removing them when it is inactive. - * The primary use-case is to simplify the special appearance of navigation menus - * relying on `ui-sref`, by having the "active" state's menu button appear different, - * distinguishing it from the inactive menu items. - * - * ui-sref-active can live on the same element as ui-sref or on a parent element. The first - * ui-sref-active found at the same level or above the ui-sref will be used. - * - * Will activate when the ui-sref's target state or any child state is active. If you - * need to activate only when the ui-sref target state is active and *not* any of - * it's children, then you will use - * {@link ui.router.state.directive:ui-sref-active-eq ui-sref-active-eq} - * - * @example - * Given the following template: - *
- * 
- * 
- * - * - * When the app state is "app.user" (or any children states), and contains the state parameter "user" with value "bilbobaggins", - * the resulting HTML will appear as (note the 'active' class): - *
- * 
- * 
- * - * The class name is interpolated **once** during the directives link time (any further changes to the - * interpolated value are ignored). - * - * Multiple classes may be specified in a space-separated format: - *
- * 
    - *
  • - * link - *
  • - *
- *
- */ - -/** - * @ngdoc directive - * @name ui.router.state.directive:ui-sref-active-eq - * - * @requires ui.router.state.$state - * @requires ui.router.state.$stateParams - * @requires $interpolate - * - * @restrict A - * - * @description - * The same as {@link ui.router.state.directive:ui-sref-active ui-sref-active} but will will only activate - * when the exact target state used in the `ui-sref` is active; no child states. - * - */ -$StateRefActiveDirective.$inject = ['$state', '$stateParams', '$interpolate']; -function $StateRefActiveDirective($state, $stateParams, $interpolate) { - return { - restrict: "A", - controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { - var state, params, activeClass; - - // There probably isn't much point in $observing this - // uiSrefActive and uiSrefActiveEq share the same directive object with some - // slight difference in logic routing - activeClass = $interpolate($attrs.uiSrefActiveEq || $attrs.uiSrefActive || '', false)($scope); - - // Allow uiSref to communicate with uiSrefActive[Equals] - this.$$setStateInfo = function (newState, newParams) { - state = $state.get(newState, stateContext($element)); - params = newParams; - update(); - }; - - $scope.$on('$stateChangeSuccess', update); - - // Update route state - function update() { - if (isMatch()) { - $element.addClass(activeClass); - } else { - $element.removeClass(activeClass); - } - } - - function isMatch() { - if (typeof $attrs.uiSrefActiveEq !== 'undefined') { - return $state.$current.self === state && matchesParams(); - } else { - return $state.includes(state.name) && matchesParams(); - } - } - - function matchesParams() { - return !params || equalForKeys(params, $stateParams); - } - }] - }; -} - -angular.module('ui.router.state') - .directive('uiSref', $StateRefDirective) - .directive('uiSrefActive', $StateRefActiveDirective) - .directive('uiSrefActiveEq', $StateRefActiveDirective); - -/** - * @ngdoc filter - * @name ui.router.state.filter:isState - * - * @requires ui.router.state.$state - * - * @description - * Translates to {@link ui.router.state.$state#methods_is $state.is("stateName")}. - */ -$IsStateFilter.$inject = ['$state']; -function $IsStateFilter($state) { - return function(state) { - return $state.is(state); - }; -} - -/** - * @ngdoc filter - * @name ui.router.state.filter:includedByState - * - * @requires ui.router.state.$state - * - * @description - * Translates to {@link ui.router.state.$state#methods_includes $state.includes('fullOrPartialStateName')}. - */ -$IncludedByStateFilter.$inject = ['$state']; -function $IncludedByStateFilter($state) { - return function(state) { - return $state.includes(state); - }; -} - -angular.module('ui.router.state') - .filter('isState', $IsStateFilter) - .filter('includedByState', $IncludedByStateFilter); -})(window, window.angular); +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["ui.router"] = factory(); + else + root["ui.router"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(1); + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + var common = __webpack_require__(2); + exports.common = common; + var params = __webpack_require__(36); + exports.params = params; + var path = __webpack_require__(15); + exports.path = path; + var resolve = __webpack_require__(17); + exports.resolve = resolve; + var state = __webpack_require__(12); + exports.state = state; + var transition = __webpack_require__(9); + exports.transition = transition; + var url = __webpack_require__(34); + exports.url = url; + var view = __webpack_require__(49); + exports.view = view; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = "ui.router"; + //# sourceMappingURL=ui-router.js.map + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(__webpack_require__(3)); + __export(__webpack_require__(4)); + __export(__webpack_require__(5)); + __export(__webpack_require__(6)); + //# sourceMappingURL=module.js.map + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + var isDefined = angular.isDefined, isFunction = angular.isFunction, isNumber = angular.isNumber, isString = angular.isString, isObject = angular.isObject, isArray = angular.isArray, forEach = angular.forEach, extend = angular.extend, copy = angular.copy, noop = angular.noop, toJson = angular.toJson, fromJson = angular.fromJson, equals = angular.equals, identity = angular.identity; + exports.isDefined = isDefined; + exports.isFunction = isFunction; + exports.isNumber = isNumber; + exports.isString = isString; + exports.isObject = isObject; + exports.isArray = isArray; + exports.forEach = forEach; + exports.extend = extend; + exports.copy = copy; + exports.noop = noop; + exports.toJson = toJson; + exports.fromJson = fromJson; + exports.equals = equals; + exports.identity = identity; + exports.abstractKey = 'abstract'; + function curry(fn) { + var initial_args = [].slice.apply(arguments, [1]); + var func_args_length = fn.length; + function curried(args) { + if (args.length >= func_args_length) + return fn.apply(null, args); + return function () { + return curried(args.concat([].slice.apply(arguments))); + }; + } + return curried(initial_args); + } + exports.curry = curry; + function compose() { + var args = arguments; + var start = args.length - 1; + return function () { + var i = start, result = args[start].apply(this, arguments); + while (i--) + result = args[i].call(this, result); + return result; + }; + } + exports.compose = compose; + function pipe() { + var funcs = []; + for (var _i = 0; _i < arguments.length; _i++) { + funcs[_i - 0] = arguments[_i]; + } + return compose.apply(null, [].slice.call(arguments).reverse()); + } + exports.pipe = pipe; + exports.prop = function (name) { return function (obj) { return obj && obj[name]; }; }; + exports.propEq = curry(function (name, val, obj) { return obj && obj[name] === val; }); + exports.parse = function (name) { return pipe.apply(null, name.split(".").map(exports.prop)); }; + exports.not = function (fn) { return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return !fn.apply(null, args); + }; }; + function and(fn1, fn2) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return fn1.apply(null, args) && fn2.apply(null, args); + }; + } + exports.and = and; + function or(fn1, fn2) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + return fn1.apply(null, args) || fn2.apply(null, args); + }; + } + exports.or = or; + exports.is = function (ctor) { return function (obj) { return (obj != null && obj.constructor === ctor || obj instanceof ctor); }; }; + exports.eq = function (val) { return function (other) { return val === other; }; }; + exports.val = function (v) { return function () { return v; }; }; + function invoke(fnName, args) { + return function (obj) { return obj[fnName].apply(obj, args); }; + } + exports.invoke = invoke; + function pattern(struct) { + return function (val) { + for (var i = 0; i < struct.length; i++) { + if (struct[i][0](val)) + return struct[i][1](val); + } + }; + } + exports.pattern = pattern; + exports.inherit = function (parent, extra) { return extend(new (extend(function () { }, { prototype: parent }))(), extra); }; + var restArgs = function (args, idx) { + if (idx === void 0) { idx = 0; } + return Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(args, idx)); + }; + var inArray = function (array, obj) { return array.indexOf(obj) !== -1; }; + exports.removeFrom = function (array) { return function (obj) { + var idx = array.indexOf(obj); + if (idx >= 0) + array.splice(idx, 1); + return array; + }; }; + function defaults(opts) { + if (opts === void 0) { opts = {}; } + var defaultsList = []; + for (var _i = 1; _i < arguments.length; _i++) { + defaultsList[_i - 1] = arguments[_i]; + } + var defaults = merge.apply(null, [{}].concat(defaultsList)); + return extend({}, defaults, pick(opts || {}, Object.keys(defaults))); + } + exports.defaults = defaults; + function merge(dst) { + var objs = []; + for (var _i = 1; _i < arguments.length; _i++) { + objs[_i - 1] = arguments[_i]; + } + forEach(objs, function (obj) { + forEach(obj, function (value, key) { + if (!dst.hasOwnProperty(key)) + dst[key] = value; + }); + }); + return dst; + } + exports.merge = merge; + exports.mergeR = function (memo, item) { return extend(memo, item); }; + function ancestors(first, second) { + var path = []; + for (var n in first.path) { + if (first.path[n] !== second.path[n]) + break; + path.push(first.path[n]); + } + return path; + } + exports.ancestors = ancestors; + function equalForKeys(a, b, keys) { + if (keys === void 0) { keys = Object.keys(a); } + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + if (a[k] != b[k]) + return false; + } + return true; + } + exports.equalForKeys = equalForKeys; + function pickOmitImpl(predicate, obj) { + var objCopy = {}, keys = restArgs(arguments, 2); + for (var key in obj) { + if (predicate(keys, key)) + objCopy[key] = obj[key]; + } + return objCopy; + } + function pick(obj) { return pickOmitImpl.apply(null, [inArray].concat(restArgs(arguments))); } + exports.pick = pick; + function omit(obj) { return pickOmitImpl.apply(null, [exports.not(inArray)].concat(restArgs(arguments))); } + exports.omit = omit; + function pluck(collection, propName) { + return map(collection, exports.prop(propName)); + } + exports.pluck = pluck; + function filter(collection, callback) { + var arr = isArray(collection), result = arr ? [] : {}; + var accept = arr ? function (x) { return result.push(x); } : function (x, key) { return result[key] = x; }; + forEach(collection, function (item, i) { + if (callback(item, i)) + accept(item, i); + }); + return result; + } + exports.filter = filter; + function find(collection, callback) { + var result; + forEach(collection, function (item, i) { + if (result) + return; + if (callback(item, i)) + result = item; + }); + return result; + } + exports.find = find; + function map(collection, callback) { + var result = isArray(collection) ? [] : {}; + forEach(collection, function (item, i) { return result[i] = callback(item, i); }); + return result; + } + exports.map = map; + exports.values = function (obj) { return Object.keys(obj).map(function (key) { return obj[key]; }); }; + exports.allTrueR = function (memo, elem) { return memo && elem; }; + exports.anyTrueR = function (memo, elem) { return memo || elem; }; + exports.pushR = function (arr, obj) { arr.push(obj); return arr; }; + exports.unnestR = function (memo, elem) { return memo.concat(elem); }; + exports.flattenR = function (memo, elem) { return isArray(elem) ? memo.concat(elem.reduce(exports.flattenR, [])) : exports.pushR(memo, elem); }; + exports.unnest = function (arr) { return arr.reduce(exports.unnestR, []); }; + exports.flatten = function (arr) { return arr.reduce(exports.flattenR, []); }; + function assertPredicate(fn, errMsg) { + if (errMsg === void 0) { errMsg = "assert failure"; } + return function (obj) { + if (!fn(obj)) + throw new Error(errMsg); + return true; + }; + } + exports.assertPredicate = assertPredicate; + exports.pairs = function (object) { return Object.keys(object).map(function (key) { return [key, object[key]]; }); }; + function arrayTuples() { + var arrayArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + arrayArgs[_i - 0] = arguments[_i]; + } + if (arrayArgs.length === 0) + return []; + var length = arrayArgs.reduce(function (min, arr) { return Math.min(arr.length, min); }, 9007199254740991); + return Array.apply(null, Array(length)).map(function (ignored, idx) { return arrayArgs.map(function (arr) { return arr[idx]; }).reduce(exports.pushR, []); }); + } + exports.arrayTuples = arrayTuples; + function applyPairs(memo, keyValTuple) { + var key, value; + if (isArray(keyValTuple)) + key = keyValTuple[0], value = keyValTuple[1]; + if (!isString(key)) + throw new Error("invalid parameters to applyPairs"); + memo[key] = value; + return memo; + } + exports.applyPairs = applyPairs; + function isInjectable(val) { + if (isArray(val) && val.length) { + var head = val.slice(0, -1), tail_1 = val.slice(-1); + if (head.filter(exports.not(isString)).length || tail_1.filter(exports.not(isFunction)).length) + return false; + } + return isFunction(val); + } + exports.isInjectable = isInjectable; + exports.isNull = function (o) { return o === null; }; + exports.isPromise = and(isObject, pipe(exports.prop('then'), isFunction)); + function fnToString(fn) { + var _fn = pattern([ + [isArray, function (arr) { return arr.slice(-1)[0]; }], + [exports.val(true), identity] + ])(fn); + return _fn && _fn.toString() || "undefined"; + } + exports.fnToString = fnToString; + function maxLength(max, str) { + if (str.length <= max) + return str; + return str.substr(0, max - 3) + "..."; + } + exports.maxLength = maxLength; + function padString(length, str) { + while (str.length < length) + str += " "; + return str; + } + exports.padString = padString; + function tail(collection) { + return collection.length && collection[collection.length - 1] || undefined; + } + exports.tail = tail; + angular.module('ui.router.util', ['ng', 'ui.router.init']); + angular.module('ui.router.router', ['ui.router.util']); + angular.module('ui.router.state', ['ui.router.router', 'ui.router.util', 'ui.router.angular1']); + angular.module('ui.router', ['ui.router.init', 'ui.router.state', 'ui.router.angular1']); + angular.module('ui.router.compat', ['ui.router']); + //# sourceMappingURL=common.js.map + +/***/ }, +/* 4 */ +/***/ function(module, exports) { + + var notImplemented = function (fnname) { return function () { + throw new Error(fnname + "(): No coreservices implementation for UI-Router is loaded. You should include one of: ['angular1.js']"); + }; }; + var services = { + $q: undefined, + $injector: undefined, + location: {}, + locationConfig: {} + }; + exports.services = services; + ["replace", "url", "path", "search", "hash"] + .forEach(function (key) { return services.location[key] = notImplemented(key); }); + ["port", "protocol", "host", "baseHref", "html5Mode", "hashPrefix"] + .forEach(function (key) { return services.locationConfig[key] = notImplemented(key); }); + //# sourceMappingURL=coreservices.js.map + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + + var Queue = (function () { + function Queue(_items) { + if (_items === void 0) { _items = []; } + this._items = _items; + } + Queue.prototype.enqueue = function (item) { + this._items.push(item); + return item; + }; + Queue.prototype.dequeue = function () { + if (this.size()) + return this._items.splice(0, 1)[0]; + }; + Queue.prototype.clear = function () { + var current = this._items; + this._items = []; + return current; + }; + Queue.prototype.size = function () { + return this._items.length; + }; + Queue.prototype.remove = function (item) { + var idx = this._items.indexOf(item); + return idx > -1 && this._items.splice(idx, 1)[0]; + }; + Queue.prototype.peekTail = function () { + return this._items[this._items.length - 1]; + }; + Queue.prototype.peekHead = function () { + if (this.size()) + return this._items[0]; + }; + return Queue; + })(); + exports.Queue = Queue; + //# sourceMappingURL=queue.js.map + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var resolvable_1 = __webpack_require__(7); + var transition_1 = __webpack_require__(8); + var rejectFactory_1 = __webpack_require__(28); + function promiseToString(p) { + if (common_1.is(rejectFactory_1.TransitionRejection)(p.reason)) + return p.reason.toString(); + return "Promise(" + JSON.stringify(p) + ")"; + } + function functionToString(fn) { + var fnStr = common_1.fnToString(fn); + var namedFunctionMatch = fnStr.match(/^(function [^ ]+\([^)]*\))/); + return namedFunctionMatch ? namedFunctionMatch[1] : fnStr; + } + var uiViewString = function (viewData) { + return ("ui-view id#" + viewData.id + ", contextual name '" + viewData.name + "@" + viewData.creationContext + "', fqn: '" + viewData.fqn + "'"); + }; + var viewConfigString = function (viewConfig) { + return ("ViewConfig targeting ui-view: '" + viewConfig.uiViewName + "@" + viewConfig.uiViewContextAnchor + "', context: '" + viewConfig.context.name + "'"); + }; + function normalizedCat(input) { + return common_1.isNumber(input) ? Category[input] : Category[Category[input]]; + } + function stringify(o) { + var format = common_1.pattern([ + [common_1.not(common_1.isDefined), common_1.val("undefined")], + [common_1.isNull, common_1.val("null")], + [common_1.isPromise, promiseToString], + [common_1.is(transition_1.Transition), common_1.invoke("toString")], + [common_1.is(resolvable_1.Resolvable), common_1.invoke("toString")], + [common_1.isInjectable, functionToString], + [common_1.val(true), common_1.identity] + ]); + return JSON.stringify(o, function (key, val) { return format(val); }).replace(/\\"/g, '"'); + } + var Category; + (function (Category) { + Category[Category["RESOLVE"] = 0] = "RESOLVE"; + Category[Category["TRANSITION"] = 1] = "TRANSITION"; + Category[Category["HOOK"] = 2] = "HOOK"; + Category[Category["INVOKE"] = 3] = "INVOKE"; + Category[Category["UIVIEW"] = 4] = "UIVIEW"; + Category[Category["VIEWCONFIG"] = 5] = "VIEWCONFIG"; + })(Category || (Category = {})); + var Trace = (function () { + function Trace() { + var _this = this; + this._enabled = {}; + this.enable = function () { + var categories = []; + for (var _i = 0; _i < arguments.length; _i++) { + categories[_i - 0] = arguments[_i]; + } + return _this._set(true, categories); + }; + this.disable = function () { + var categories = []; + for (var _i = 0; _i < arguments.length; _i++) { + categories[_i - 0] = arguments[_i]; + } + return _this._set(false, categories); + }; + this.approximateDigests = 0; + } + Trace.prototype._set = function (enabled, categories) { + var _this = this; + if (!categories.length) { + categories = Object.keys(Category) + .filter(function (k) { return isNaN(parseInt(k, 10)); }) + .map(function (key) { return Category[key]; }); + } + categories.map(normalizedCat).forEach(function (category) { return _this._enabled[category] = enabled; }); + }; + Trace.prototype.enabled = function (category) { + return !!this._enabled[normalizedCat(category)]; + }; + Trace.prototype.traceTransitionStart = function (transition) { + if (!this.enabled(Category.TRANSITION)) + return; + var tid = transition.$id, digest = this.approximateDigests, transitionStr = stringify(transition); + console.log("Transition #" + tid + " Digest #" + digest + ": Started -> " + transitionStr); + }; + Trace.prototype.traceTransitionIgnored = function (transition) { + if (!this.enabled(Category.TRANSITION)) + return; + var tid = transition.$id, digest = this.approximateDigests, transitionStr = stringify(transition); + console.log("Transition #" + tid + " Digest #" + digest + ": Ignored <> " + transitionStr); + }; + Trace.prototype.traceHookInvocation = function (step, options) { + if (!this.enabled(Category.HOOK)) + return; + var tid = common_1.parse("transition.$id")(options), digest = this.approximateDigests, event = common_1.parse("traceData.hookType")(options) || "internal", context = common_1.parse("traceData.context.state.name")(options) || common_1.parse("traceData.context")(options) || "unknown", name = functionToString(step.fn); + console.log("Transition #" + tid + " Digest #" + digest + ": Hook -> " + event + " context: " + context + ", " + common_1.maxLength(200, name)); + }; + Trace.prototype.traceHookResult = function (hookResult, transitionResult, transitionOptions) { + if (!this.enabled(Category.HOOK)) + return; + var tid = common_1.parse("transition.$id")(transitionOptions), digest = this.approximateDigests, hookResultStr = stringify(hookResult), transitionResultStr = stringify(transitionResult); + console.log("Transition #" + tid + " Digest #" + digest + ": <- Hook returned: " + common_1.maxLength(200, hookResultStr) + ", transition result: " + common_1.maxLength(200, transitionResultStr)); + }; + Trace.prototype.traceResolvePath = function (path, options) { + if (!this.enabled(Category.RESOLVE)) + return; + var tid = common_1.parse("transition.$id")(options), digest = this.approximateDigests, pathStr = path && path.toString(), policyStr = options && options.resolvePolicy; + console.log("Transition #" + tid + " Digest #" + digest + ": Resolving " + pathStr + " (" + policyStr + ")"); + }; + Trace.prototype.traceResolvePathElement = function (pathElement, resolvablePromises, options) { + if (!this.enabled(Category.RESOLVE)) + return; + if (!resolvablePromises.length) + return; + var tid = common_1.parse("transition.$id")(options), digest = this.approximateDigests, resolvablePromisesStr = Object.keys(resolvablePromises).join(", "), pathElementStr = pathElement && pathElement.toString(), policyStr = options && options.resolvePolicy; + console.log("Transition #" + tid + " Digest #" + digest + ": Resolve " + pathElementStr + " resolvables: [" + resolvablePromisesStr + "] (" + policyStr + ")"); + }; + Trace.prototype.traceResolveResolvable = function (resolvable, options) { + if (!this.enabled(Category.RESOLVE)) + return; + var tid = common_1.parse("transition.$id")(options), digest = this.approximateDigests, resolvableStr = resolvable && resolvable.toString(); + console.log("Transition #" + tid + " Digest #" + digest + ": Resolving -> " + resolvableStr); + }; + Trace.prototype.traceResolvableResolved = function (resolvable, options) { + if (!this.enabled(Category.RESOLVE)) + return; + var tid = common_1.parse("transition.$id")(options), digest = this.approximateDigests, resolvableStr = resolvable && resolvable.toString(), result = stringify(resolvable.data); + console.log("Transition #" + tid + " Digest #" + digest + ": <- Resolved " + resolvableStr + " to: " + common_1.maxLength(200, result)); + }; + Trace.prototype.tracePathElementInvoke = function (node, fn, deps, options) { + if (!this.enabled(Category.INVOKE)) + return; + var tid = common_1.parse("transition.$id")(options), digest = this.approximateDigests, stateName = node && node.state && node.state.toString(), fnName = functionToString(fn); + console.log("Transition #" + tid + " Digest #" + digest + ": Invoke " + options.when + ": context: " + stateName + " " + common_1.maxLength(200, fnName)); + }; + Trace.prototype.traceError = function (error, transition) { + if (!this.enabled(Category.TRANSITION)) + return; + var tid = transition.$id, digest = this.approximateDigests, transitionStr = stringify(transition); + console.log("Transition #" + tid + " Digest #" + digest + ": <- Rejected " + transitionStr + ", reason: " + error); + }; + Trace.prototype.traceSuccess = function (finalState, transition) { + if (!this.enabled(Category.TRANSITION)) + return; + var tid = transition.$id, digest = this.approximateDigests, state = finalState.name, transitionStr = stringify(transition); + console.log("Transition #" + tid + " Digest #" + digest + ": <- Success " + transitionStr + ", final state: " + state); + }; + Trace.prototype.traceUiViewEvent = function (event, viewData, extra) { + if (extra === void 0) { extra = ""; } + if (!this.enabled(Category.UIVIEW)) + return; + console.log("ui-view: " + common_1.padString(30, event) + " " + uiViewString(viewData) + extra); + }; + Trace.prototype.traceUiViewConfigUpdated = function (viewData, context) { + if (!this.enabled(Category.UIVIEW)) + return; + this.traceUiViewEvent("Updating", viewData, " with ViewConfig from context='" + context + "'"); + }; + Trace.prototype.traceUiViewScopeCreated = function (viewData, newScope) { + if (!this.enabled(Category.UIVIEW)) + return; + this.traceUiViewEvent("Created scope for", viewData, ", scope #" + newScope.$id); + }; + Trace.prototype.traceUiViewFill = function (viewData, html) { + if (!this.enabled(Category.UIVIEW)) + return; + this.traceUiViewEvent("Fill", viewData, " with: " + common_1.maxLength(200, html)); + }; + Trace.prototype.traceViewServiceEvent = function (event, viewConfig) { + if (!this.enabled(Category.VIEWCONFIG)) + return; + console.log("$view.ViewConfig: " + event + " " + viewConfigString(viewConfig)); + }; + Trace.prototype.traceViewServiceUiViewEvent = function (event, viewData) { + if (!this.enabled(Category.VIEWCONFIG)) + return; + console.log("$view.ViewConfig: " + event + " " + uiViewString(viewData)); + }; + return Trace; + })(); + var trace = new Trace(); + exports.trace = trace; + watchDigests.$inject = ['$rootScope']; + function watchDigests($rootScope) { + $rootScope.$watch(function () { trace.approximateDigests++; }); + } + angular.module("ui.router").run(watchDigests); + angular.module("ui.router").service("$trace", function () { return trace; }); + //# sourceMappingURL=trace.js.map + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var coreservices_1 = __webpack_require__(4); + var trace_1 = __webpack_require__(6); + var Resolvable = (function () { + function Resolvable(name, resolveFn, preResolvedData) { + this.promise = undefined; + common_1.extend(this, { name: name, resolveFn: resolveFn, deps: coreservices_1.services.$injector.annotate(resolveFn), data: preResolvedData }); + } + Resolvable.prototype.resolveResolvable = function (resolveContext, options) { + var _this = this; + if (options === void 0) { options = {}; } + var _a = this, name = _a.name, deps = _a.deps, resolveFn = _a.resolveFn; + trace_1.trace.traceResolveResolvable(this, options); + var deferred = coreservices_1.services.$q.defer(); + this.promise = deferred.promise; + var ancestorsByName = resolveContext.getResolvables(null, { omitOwnLocals: [name] }); + var depResolvables = common_1.pick(ancestorsByName, deps); + var depPromises = common_1.map(depResolvables, function (resolvable) { return resolvable.get(resolveContext, options); }); + return coreservices_1.services.$q.all(depPromises).then(function (locals) { + try { + var result = coreservices_1.services.$injector.invoke(resolveFn, null, locals); + deferred.resolve(result); + } + catch (error) { + deferred.reject(error); + } + return _this.promise; + }).then(function (data) { + _this.data = data; + trace_1.trace.traceResolvableResolved(_this, options); + return _this.promise; + }); + }; + Resolvable.prototype.get = function (resolveContext, options) { + return this.promise || this.resolveResolvable(resolveContext, options); + }; + Resolvable.prototype.toString = function () { + return "Resolvable(name: " + this.name + ", requires: [" + this.deps + "])"; + }; + Resolvable.makeResolvables = function (resolves) { + var invalid = common_1.filter(resolves, common_1.not(common_1.isFunction)), keys = Object.keys(invalid); + if (keys.length) + throw new Error("Invalid resolve key/value: " + keys[0] + "/" + invalid[keys[0]]); + return common_1.map(resolves, function (fn, name) { return new Resolvable(name, fn); }); + }; + return Resolvable; + })(); + exports.Resolvable = Resolvable; + //# sourceMappingURL=resolvable.js.map + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + var trace_1 = __webpack_require__(6); + var coreservices_1 = __webpack_require__(4); + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(9); + var module_2 = __webpack_require__(15); + var module_3 = __webpack_require__(12); + var module_4 = __webpack_require__(36); + var module_5 = __webpack_require__(17); + var transitionCount = 0, REJECT = new module_1.RejectFactory(); + var stateSelf = common_1.prop("self"); + var Transition = (function () { + function Transition(fromPath, targetState) { + var _this = this; + this._deferred = coreservices_1.services.$q.defer(); + this.promise = this._deferred.promise; + this.treeChanges = function () { return _this._treeChanges; }; + this.isActive = function () { return _this === _this._options.current(); }; + if (!targetState.valid()) { + throw new Error(targetState.error()); + } + module_1.HookRegistry.mixin(new module_1.HookRegistry(), this); + this._options = common_1.extend({ current: common_1.val(this) }, targetState.options()); + this.$id = transitionCount++; + var toPath = module_2.PathFactory.buildToPath(fromPath, targetState); + this._treeChanges = module_2.PathFactory.treeChanges(fromPath, toPath, this._options.reloadState); + module_2.PathFactory.bindTransitionResolve(this._treeChanges, this); + } + Transition.prototype.$from = function () { + return common_1.tail(this._treeChanges.from).state; + }; + Transition.prototype.$to = function () { + return common_1.tail(this._treeChanges.to).state; + }; + Transition.prototype.from = function () { + return this.$from().self; + }; + Transition.prototype.to = function () { + return this.$to().self; + }; + Transition.prototype.is = function (compare) { + if (compare instanceof Transition) { + return this.is({ to: compare.$to().name, from: compare.$from().name }); + } + return !((compare.to && !module_1.matchState(this.$to(), compare.to)) || + (compare.from && !module_1.matchState(this.$from(), compare.from))); + }; + Transition.prototype.params = function (pathname) { + if (pathname === void 0) { pathname = "to"; } + return this._treeChanges[pathname].map(common_1.prop("values")).reduce(common_1.mergeR, {}); + }; + Transition.prototype.resolves = function () { + return common_1.map(common_1.tail(this._treeChanges.to).resolveContext.getResolvables(), function (res) { return res.data; }); + }; + Transition.prototype.addResolves = function (resolves, state) { + if (state === void 0) { state = ""; } + var stateName = (typeof state === "string") ? state : state.name; + var topath = this._treeChanges.to; + var targetNode = common_1.find(topath, function (node) { return node.state.name === stateName; }); + common_1.tail(topath).resolveContext.addResolvables(module_5.Resolvable.makeResolvables(resolves), targetNode.state); + }; + Transition.prototype.previous = function () { + return this._options.previous || null; + }; + Transition.prototype.options = function () { + return this._options; + }; + Transition.prototype.entering = function () { + return common_1.map(this._treeChanges.entering, common_1.prop('state')).map(stateSelf); + }; + Transition.prototype.exiting = function () { + return common_1.map(this._treeChanges.exiting, common_1.prop('state')).map(stateSelf).reverse(); + }; + Transition.prototype.retained = function () { + return common_1.map(this._treeChanges.retained, common_1.prop('state')).map(stateSelf); + }; + Transition.prototype.views = function (pathname, state) { + if (pathname === void 0) { pathname = "entering"; } + var path = this._treeChanges[pathname]; + return state ? common_1.find(path, common_1.propEq('state', state)).views : common_1.unnest(path.map(common_1.prop("views"))); + }; + Transition.prototype.redirect = function (targetState) { + var newOptions = common_1.extend({}, this.options(), targetState.options(), { previous: this }); + targetState = new module_3.TargetState(targetState.identifier(), targetState.$state(), targetState.params(), newOptions); + var redirectTo = new Transition(this._treeChanges.from, targetState); + var redirectedPath = this.treeChanges().to; + var matching = module_2.Node.matching(redirectTo.treeChanges().to, redirectedPath); + var includeResolve = function (resolve, key) { return ['$stateParams', '$transition$'].indexOf(key) === -1; }; + matching.forEach(function (node, idx) { return common_1.extend(node.resolves, common_1.filter(redirectedPath[idx].resolves, includeResolve)); }); + return redirectTo; + }; + Transition.prototype.ignored = function () { + var _a = this._treeChanges, to = _a.to, from = _a.from; + if (this._options.reload || common_1.tail(to).state !== common_1.tail(from).state) + return false; + var nodeSchemas = to.map(function (node) { return node.schema.filter(common_1.not(common_1.prop('dynamic'))); }); + var _b = [to, from].map(function (path) { return path.map(common_1.prop('values')); }), toValues = _b[0], fromValues = _b[1]; + var tuples = common_1.arrayTuples(nodeSchemas, toValues, fromValues); + return tuples.map(function (_a) { + var schema = _a[0], toVals = _a[1], fromVals = _a[2]; + return module_4.Param.equals(schema, toVals, fromVals); + }).reduce(common_1.allTrueR, true); + }; + Transition.prototype.hookBuilder = function () { + return new module_1.HookBuilder(module_1.$transitions, this, { + transition: this, + current: this._options.current + }); + }; + Transition.prototype.run = function () { + var _this = this; + var hookBuilder = this.hookBuilder(); + var runSynchronousHooks = module_1.TransitionHook.runSynchronousHooks; + var runSuccessHooks = function () { return runSynchronousHooks(hookBuilder.getOnSuccessHooks(), {}, true); }; + var runErrorHooks = function ($error$) { return runSynchronousHooks(hookBuilder.getOnErrorHooks(), { $error$: $error$ }, true); }; + this.promise.then(runSuccessHooks, runErrorHooks); + var syncResult = runSynchronousHooks(hookBuilder.getOnBeforeHooks()); + if (module_1.TransitionHook.isRejection(syncResult)) { + var rejectReason = syncResult.reason; + this._deferred.reject(rejectReason); + return this.promise; + } + if (!this.valid()) { + var error = new Error(this.error()); + this._deferred.reject(error); + return this.promise; + } + if (this.ignored()) { + trace_1.trace.traceTransitionIgnored(this); + var ignored = REJECT.ignored(); + this._deferred.reject(ignored.reason); + return this.promise; + } + var resolve = function () { + _this._deferred.resolve(_this); + trace_1.trace.traceSuccess(_this.$to(), _this); + }; + var reject = function (error) { + _this._deferred.reject(error); + trace_1.trace.traceError(error, _this); + return coreservices_1.services.$q.reject(error); + }; + trace_1.trace.traceTransitionStart(this); + var chain = hookBuilder.asyncHooks().reduce(function (_chain, step) { return _chain.then(step.invokeStep); }, syncResult); + chain.then(resolve, reject); + return this.promise; + }; + Transition.prototype.valid = function () { + return !this.error(); + }; + Transition.prototype.error = function () { + var state = this.$to(); + if (state.self[common_1.abstractKey]) + return "Cannot transition to abstract state '" + state.name + "'"; + if (!module_4.Param.validates(state.parameters(), this.params())) + return "Param values not valid for state '" + state.name + "'"; + }; + Transition.prototype.toString = function () { + var fromStateOrName = this.from(); + var toStateOrName = this.to(); + var avoidEmptyHash = function (params) { + return (params["#"] !== null && params["#"] !== undefined) ? params : common_1.omit(params, "#"); + }; + var id = this.$id, from = common_1.isObject(fromStateOrName) ? fromStateOrName.name : fromStateOrName, fromParams = common_1.toJson(avoidEmptyHash(this._treeChanges.from.map(common_1.prop('values')).reduce(common_1.mergeR, {}))), toValid = this.valid() ? "" : "(X) ", to = common_1.isObject(toStateOrName) ? toStateOrName.name : toStateOrName, toParams = common_1.toJson(avoidEmptyHash(this.params())); + return "Transition#" + id + "( '" + from + "'" + fromParams + " -> " + toValid + "'" + to + "'" + toParams + " )"; + }; + return Transition; + })(); + exports.Transition = Transition; + //# sourceMappingURL=transition.js.map + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(__webpack_require__(10)); + __export(__webpack_require__(11)); + __export(__webpack_require__(28)); + __export(__webpack_require__(8)); + __export(__webpack_require__(47)); + __export(__webpack_require__(48)); + //# sourceMappingURL=module.js.map + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(9); + var successErrorOptions = { + async: false, + rejectIfSuperseded: false + }; + var HookBuilder = (function () { + function HookBuilder($transitions, transition, baseHookOptions) { + var _this = this; + this.$transitions = $transitions; + this.transition = transition; + this.baseHookOptions = baseHookOptions; + this.getOnBeforeHooks = function () { return _this._buildTransitionHooks("onBefore", {}, { async: false }); }; + this.getOnStartHooks = function () { return _this._buildTransitionHooks("onStart"); }; + this.getOnExitHooks = function () { return _this._buildNodeHooks("onExit", _this.treeChanges.exiting.reverse(), function (node) { return _this._toFrom({ from: node.state }); }); }; + this.getOnRetainHooks = function () { return _this._buildNodeHooks("onRetain", _this.treeChanges.retained, function (node) { return _this._toFrom(); }); }; + this.getOnEnterHooks = function () { return _this._buildNodeHooks("onEnter", _this.treeChanges.entering, function (node) { return _this._toFrom({ to: node.state }); }); }; + this.getOnFinishHooks = function () { return _this._buildTransitionHooks("onFinish", { $treeChanges$: _this.treeChanges }); }; + this.getOnSuccessHooks = function () { return _this._buildTransitionHooks("onSuccess", {}, { async: false, rejectIfSuperseded: false }); }; + this.getOnErrorHooks = function () { return _this._buildTransitionHooks("onError", {}, { async: false, rejectIfSuperseded: false }); }; + this.treeChanges = transition.treeChanges(); + this.toState = common_1.tail(this.treeChanges.to).state; + this.fromState = common_1.tail(this.treeChanges.from).state; + this.transitionOptions = transition.options(); + } + HookBuilder.prototype.asyncHooks = function () { + var onStartHooks = this.getOnStartHooks(); + var onExitHooks = this.getOnExitHooks(); + var onRetainHooks = this.getOnRetainHooks(); + var onEnterHooks = this.getOnEnterHooks(); + var onFinishHooks = this.getOnFinishHooks(); + return common_1.flatten([onStartHooks, onExitHooks, onRetainHooks, onEnterHooks, onFinishHooks]).filter(common_1.identity); + }; + HookBuilder.prototype._toFrom = function (toFromOverride) { + return common_1.extend({ to: this.toState, from: this.fromState }, toFromOverride); + }; + HookBuilder.prototype._buildTransitionHooks = function (hookType, locals, options) { + var _this = this; + if (locals === void 0) { locals = {}; } + if (options === void 0) { options = {}; } + var context = this.treeChanges.to, node = common_1.tail(context); + options.traceData = { hookType: hookType, context: context }; + var transitionHook = function (eventHook) { return _this.buildHook(node, eventHook.callback, locals, options); }; + return this._matchingHooks(hookType, this._toFrom()).map(transitionHook); + }; + HookBuilder.prototype._buildNodeHooks = function (hookType, path, toFromFn, locals, options) { + var _this = this; + if (locals === void 0) { locals = {}; } + if (options === void 0) { options = {}; } + var hooksForNode = function (node) { + var toFrom = toFromFn(node); + options.traceData = { hookType: hookType, context: node }; + locals.$state$ = node.state; + var transitionHook = function (eventHook) { return _this.buildHook(node, eventHook.callback, locals, options); }; + return _this._matchingHooks(hookType, toFrom).map(transitionHook); + }; + return path.map(hooksForNode); + }; + HookBuilder.prototype.buildHook = function (node, fn, locals, options) { + if (options === void 0) { options = {}; } + var _options = common_1.extend({}, this.baseHookOptions, options); + return new module_1.TransitionHook(fn, common_1.extend({}, locals), node.resolveContext, _options); + }; + HookBuilder.prototype._matchingHooks = function (hookName, matchCriteria) { + var matchFilter = function (hook) { return hook.matches(matchCriteria.to, matchCriteria.from); }; + var prioritySort = function (l, r) { return r.priority - l.priority; }; + return [this.transition, this.$transitions] + .map(function (reg) { return reg.getHooks(hookName); }) + .filter(common_1.assertPredicate(common_1.isArray, "broken event named: " + hookName)) + .reduce(common_1.unnestR) + .filter(matchFilter) + .sort(prioritySort); + }; + return HookBuilder; + })(); + exports.HookBuilder = HookBuilder; + //# sourceMappingURL=hookBuilder.js.map + +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(12); + function matchState(state, matchCriteria) { + var toMatch = common_1.isString(matchCriteria) ? [matchCriteria] : matchCriteria; + function matchGlobs(_state) { + for (var i = 0; i < toMatch.length; i++) { + var glob = module_1.Glob.fromString(toMatch[i]); + if ((glob && glob.matches(_state.name)) || (!glob && toMatch[i] === _state.name)) { + return true; + } + } + return false; + } + var matchFn = (common_1.isFunction(toMatch) ? toMatch : matchGlobs); + return !!matchFn(state); + } + exports.matchState = matchState; + var EventHook = (function () { + function EventHook(matchCriteria, callback, options) { + if (options === void 0) { options = {}; } + this.callback = callback; + this.matchCriteria = common_1.extend({ to: common_1.val(true), from: common_1.val(true) }, matchCriteria); + this.priority = options.priority || 0; + } + EventHook.prototype.matches = function (to, from) { + return matchState(to, this.matchCriteria.to) && matchState(from, this.matchCriteria.from); + }; + return EventHook; + })(); + exports.EventHook = EventHook; + function makeHookRegistrationFn(hooks, name) { + return function (matchObject, callback, options) { + if (options === void 0) { options = {}; } + var eventHook = new EventHook(matchObject, callback, options); + hooks[name].push(eventHook); + return function deregisterEventHook() { + common_1.removeFrom(hooks[name])(eventHook); + }; + }; + } + var HookRegistry = (function () { + function HookRegistry() { + var _this = this; + this._transitionEvents = { + onBefore: [], onStart: [], onEnter: [], onRetain: [], onExit: [], onFinish: [], onSuccess: [], onError: [] + }; + this.getHooks = function (name) { return _this._transitionEvents[name]; }; + this.onBefore = makeHookRegistrationFn(this._transitionEvents, "onBefore"); + this.onStart = makeHookRegistrationFn(this._transitionEvents, "onStart"); + this.onEnter = makeHookRegistrationFn(this._transitionEvents, "onEnter"); + this.onRetain = makeHookRegistrationFn(this._transitionEvents, "onRetain"); + this.onExit = makeHookRegistrationFn(this._transitionEvents, "onExit"); + this.onFinish = makeHookRegistrationFn(this._transitionEvents, "onFinish"); + this.onSuccess = makeHookRegistrationFn(this._transitionEvents, "onSuccess"); + this.onError = makeHookRegistrationFn(this._transitionEvents, "onError"); + } + HookRegistry.mixin = function (source, target) { + Object.keys(source._transitionEvents).concat(["getHooks"]).forEach(function (key) { return target[key] = source[key]; }); + }; + return HookRegistry; + })(); + exports.HookRegistry = HookRegistry; + //# sourceMappingURL=hookRegistry.js.map + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(__webpack_require__(13)); + __export(__webpack_require__(14)); + __export(__webpack_require__(41)); + __export(__webpack_require__(42)); + __export(__webpack_require__(43)); + __export(__webpack_require__(23)); + __export(__webpack_require__(44)); + __export(__webpack_require__(45)); + __export(__webpack_require__(46)); + __export(__webpack_require__(29)); + //# sourceMappingURL=module.js.map + +/***/ }, +/* 13 */ +/***/ function(module, exports) { + + var Glob = (function () { + function Glob(text) { + this.text = text; + this.glob = text.split('.'); + } + Glob.prototype.matches = function (name) { + var segments = name.split('.'); + for (var i = 0, l = this.glob.length; i < l; i++) { + if (this.glob[i] === '*') + segments[i] = '*'; + } + if (this.glob[0] === '**') { + segments = segments.slice(segments.indexOf(this.glob[1])); + segments.unshift('**'); + } + if (this.glob[this.glob.length - 1] === '**') { + segments.splice(segments.indexOf(this.glob[this.glob.length - 2]) + 1, Number.MAX_VALUE); + segments.push('**'); + } + if (this.glob.length != segments.length) + return false; + return segments.join('') === this.glob.join(''); + }; + Glob.is = function (text) { + return text.indexOf('*') > -1; + }; + Glob.fromString = function (text) { + if (!this.is(text)) + return null; + return new Glob(text); + }; + return Glob; + })(); + exports.Glob = Glob; + //# sourceMappingURL=glob.js.map + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var queue_1 = __webpack_require__(5); + var module_1 = __webpack_require__(12); + var module_2 = __webpack_require__(9); + var module_3 = __webpack_require__(15); + var transitionManager_1 = __webpack_require__(23); + var module_4 = __webpack_require__(36); + function $StateProvider($urlRouterProvider, $urlMatcherFactoryProvider) { + var root, states = {}; + var $state = function $state() { }; + var matcher = new module_1.StateMatcher(states); + var builder = new module_1.StateBuilder(function () { return root; }, matcher, $urlMatcherFactoryProvider); + var stateQueue = new module_1.StateQueueManager(states, builder, $urlRouterProvider, $state); + var transQueue = new queue_1.Queue(); + var treeChangesQueue = new queue_1.Queue(); + var rejectFactory = new module_2.RejectFactory(); + this.decorator = decorator; + function decorator(name, func) { + return builder.builder(name, func) || this; + } + this.state = state; + function state(name, definition) { + if (common_1.isObject(name)) { + definition = name; + } + else { + definition.name = name; + } + stateQueue.register(definition); + return this; + } + var invalidCallbacks = []; + this.onInvalid = onInvalid; + function onInvalid(callback) { + invalidCallbacks.push(callback); + } + this.$get = $get; + $get.$inject = ['$q', '$injector', '$view', '$stateParams', '$urlRouter', '$transitions']; + function $get($q, $injector, $view, $stateParams, $urlRouter, _$transition) { + function handleInvalidTargetState(fromPath, $to$) { + var latestThing = function () { return transQueue.peekTail() || treeChangesQueue.peekTail(); }; + var latest = latestThing(); + var $from$ = module_3.PathFactory.makeTargetState(fromPath); + var callbackQueue = new queue_1.Queue([].concat(invalidCallbacks)); + var invokeCallback = function (callback) { return $q.when($injector.invoke(callback, null, { $to$: $to$, $from$: $from$ })); }; + function checkForRedirect(result) { + if (!(result instanceof module_1.TargetState)) { + return; + } + var target = result; + target = $state.target(target.identifier(), target.params(), target.options()); + if (!target.valid()) + return rejectFactory.invalid(target.error()); + if (latestThing() !== latest) + return rejectFactory.superseded(); + return $state.transitionTo(target.identifier(), target.params(), target.options()); + } + function invokeNextCallback() { + var nextCallback = callbackQueue.dequeue(); + if (nextCallback === undefined) + return rejectFactory.invalid($to$.error()); + return invokeCallback(nextCallback).then(checkForRedirect).then(function (result) { return result || invokeNextCallback(); }); + } + return invokeNextCallback(); + } + var $transitions = _$transition; + var rootStateDef = { + name: '', + url: '^', + views: null, + params: { + '#': { value: null, type: 'hash' } + }, + abstract: true + }; + root = stateQueue.register(rootStateDef, true); + root.navigable = null; + var rootPath = function () { return module_3.PathFactory.bindTransNodesToPath([new module_3.Node(root, {})]); }; + $view.rootContext(root); + common_1.extend($state, { + params: new module_4.StateParams(), + current: root.self, + $current: root, + transition: null + }); + stateQueue.flush($state); + stateQueue.autoFlush = true; + $state.reload = function reload(reloadState) { + return $state.transitionTo($state.current, $stateParams, { + reload: common_1.isDefined(reloadState) ? reloadState : true, + inherit: false, + notify: false + }); + }; + $state.go = function go(to, params, options) { + var defautGoOpts = { relative: $state.$current, inherit: true }; + var transOpts = common_1.defaults(options, defautGoOpts, module_2.defaultTransOpts); + return $state.transitionTo(to, params, transOpts); + }; + $state.target = function target(identifier, params, options) { + if (options === void 0) { options = {}; } + var stateDefinition = matcher.find(identifier, options.relative); + return new module_1.TargetState(identifier, stateDefinition, params, options); + }; + $state.transitionTo = function transitionTo(to, toParams, options) { + if (toParams === void 0) { toParams = {}; } + if (options === void 0) { options = {}; } + options = common_1.defaults(options, module_2.defaultTransOpts); + options = common_1.extend(options, { current: transQueue.peekTail.bind(transQueue) }); + if (common_1.isObject(options.reload) && !options.reload.name) + throw new Error('Invalid reload state object'); + options.reloadState = options.reload === true ? $state.$current.path[0] : matcher.find(options.reload, options.relative); + if (options.reload && !options.reloadState) + throw new Error("No such reload state '" + (common_1.isString(options.reload) ? options.reload : options.reload.name) + "'"); + var ref = $state.target(to, toParams, options); + var latestTreeChanges = treeChangesQueue.peekTail(); + var currentPath = latestTreeChanges ? latestTreeChanges.to : rootPath(); + if (!ref.exists()) + return handleInvalidTargetState(currentPath, ref); + if (!ref.valid()) + return $q.reject(ref.error()); + var transition = $transitions.create(currentPath, ref); + var tMgr = new transitionManager_1.TransitionManager(transition, $transitions, $urlRouter, $view, $state, $stateParams, $q, transQueue, treeChangesQueue); + var transitionPromise = tMgr.runTransition(); + return common_1.extend(transitionPromise, { transition: transition }); + }; + $state.is = function is(stateOrName, params, options) { + options = common_1.defaults(options, { relative: $state.$current }); + var state = matcher.find(stateOrName, options.relative); + if (!common_1.isDefined(state)) + return undefined; + if ($state.$current !== state) + return false; + return common_1.isDefined(params) && params !== null ? module_4.Param.equals(state.parameters(), $stateParams, params) : true; + }; + $state.includes = function includes(stateOrName, params, options) { + options = common_1.defaults(options, { relative: $state.$current }); + var glob = common_1.isString(stateOrName) && module_1.Glob.fromString(stateOrName); + if (glob) { + if (!glob.matches($state.$current.name)) + return false; + stateOrName = $state.$current.name; + } + var state = matcher.find(stateOrName, options.relative), include = $state.$current.includes; + if (!common_1.isDefined(state)) + return undefined; + if (!common_1.isDefined(include[state.name])) + return false; + return params ? common_1.equalForKeys(module_4.Param.values(state.parameters(), params), $stateParams, Object.keys(params)) : true; + }; + $state.href = function href(stateOrName, params, options) { + var defaultHrefOpts = { + lossy: true, + inherit: true, + absolute: false, + relative: $state.$current + }; + options = common_1.defaults(options, defaultHrefOpts); + var state = matcher.find(stateOrName, options.relative); + if (!common_1.isDefined(state)) + return null; + if (options.inherit) + params = $stateParams.$inherit(params || {}, $state.$current, state); + var nav = (state && options.lossy) ? state.navigable : state; + if (!nav || nav.url === undefined || nav.url === null) { + return null; + } + return $urlRouter.href(nav.url, module_4.Param.values(state.parameters(), params), { + absolute: options.absolute + }); + }; + $state.get = function (stateOrName, base) { + if (arguments.length === 0) + return Object.keys(states).map(function (name) { return states[name].self; }); + var found = matcher.find(stateOrName, base || $state.$current); + return found && found.self || null; + }; + return $state; + } + } + exports.$StateProvider = $StateProvider; + //# sourceMappingURL=state.js.map + +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(__webpack_require__(16)); + __export(__webpack_require__(22)); + //# sourceMappingURL=module.js.map + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(17); + var view_1 = __webpack_require__(21); + var Node = (function () { + function Node(state, params, resolves) { + if (resolves === void 0) { resolves = {}; } + this.state = state; + this.schema = state.parameters({ inherit: false }); + var getParamVal = function (paramDef) { return [paramDef.id, paramDef.value(params[paramDef.id])]; }; + this.values = this.schema.reduce(function (memo, pDef) { return common_1.applyPairs(memo, getParamVal(pDef)); }, {}); + this.resolves = common_1.extend(common_1.map(state.resolve, function (fn, name) { return new module_1.Resolvable(name, fn); }), resolves); + var makeViewConfig = function (viewDeclarationObj, rawViewName) { + return new view_1.ViewConfig({ rawViewName: rawViewName, viewDeclarationObj: viewDeclarationObj, context: state, params: params }); + }; + this.views = common_1.values(common_1.map(state.views, makeViewConfig)); + } + Node.prototype.parameter = function (name) { + return common_1.find(this.schema, common_1.propEq("id", name)); + }; + Node.prototype.equals = function (node, keys) { + var _this = this; + if (keys === void 0) { keys = this.schema.map(common_1.prop('id')); } + var paramValsEq = function (key) { return _this.parameter(key).type.equals(_this.values[key], node.values[key]); }; + return this.state === node.state && keys.map(paramValsEq).reduce(common_1.allTrueR, true); + }; + Node.clone = function (node, update) { + if (update === void 0) { update = {}; } + return new Node(node.state, (update.values || node.values), (update.resolves || node.resolves)); + }; + Node.matching = function (first, second) { + var matchedCount = first.reduce(function (prev, node, i) { + return prev === i && i < second.length && node.state === second[i].state ? i + 1 : prev; + }, 0); + return first.slice(0, matchedCount); + }; + return Node; + })(); + exports.Node = Node; + //# sourceMappingURL=node.js.map + +/***/ }, +/* 17 */ +/***/ function(module, exports, __webpack_require__) { + + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(__webpack_require__(7)); + __export(__webpack_require__(18)); + __export(__webpack_require__(20)); + //# sourceMappingURL=module.js.map + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var trace_1 = __webpack_require__(6); + var coreservices_1 = __webpack_require__(4); + var interface_1 = __webpack_require__(19); + var defaultResolvePolicy = interface_1.ResolvePolicy[interface_1.ResolvePolicy.LAZY]; + var ResolveContext = (function () { + function ResolveContext(_path) { + this._path = _path; + common_1.extend(this, { + _nodeFor: function (state) { + return common_1.find(this._path, common_1.propEq('state', state)); + }, + _pathTo: function (state) { + var node = this._nodeFor(state); + var elementIdx = this._path.indexOf(node); + if (elementIdx === -1) + throw new Error("This path does not contain the state"); + return this._path.slice(0, elementIdx + 1); + } + }); + } + ResolveContext.prototype.getResolvables = function (state, options) { + options = common_1.defaults(options, { omitOwnLocals: [] }); + var offset = common_1.find(this._path, common_1.propEq('')); + var path = (state ? this._pathTo(state) : this._path); + var last = common_1.tail(path); + return path.reduce(function (memo, node) { + var omitProps = (node === last) ? options.omitOwnLocals : []; + var filteredResolvables = common_1.omit(node.resolves, omitProps); + return common_1.extend(memo, filteredResolvables); + }, {}); + }; + ResolveContext.prototype.getResolvablesForFn = function (fn) { + var deps = coreservices_1.services.$injector.annotate(fn); + return common_1.pick(this.getResolvables(), deps); + }; + ResolveContext.prototype.isolateRootTo = function (state) { + return new ResolveContext(this._pathTo(state)); + }; + ResolveContext.prototype.addResolvables = function (resolvables, state) { + common_1.extend(this._nodeFor(state).resolves, resolvables); + }; + ResolveContext.prototype.getOwnResolvables = function (state) { + return common_1.extend({}, this._nodeFor(state).resolves); + }; + ResolveContext.prototype.resolvePath = function (options) { + var _this = this; + if (options === void 0) { options = {}; } + trace_1.trace.traceResolvePath(this._path, options); + var promiseForNode = function (node) { return _this.resolvePathElement(node.state, options); }; + return coreservices_1.services.$q.all(common_1.map(this._path, promiseForNode)).then(common_1.noop); + }; + ResolveContext.prototype.resolvePathElement = function (state, options) { + var _this = this; + if (options === void 0) { options = {}; } + var policy = options && options.resolvePolicy; + var policyOrdinal = interface_1.ResolvePolicy[policy || defaultResolvePolicy]; + var resolvables = this.getOwnResolvables(state); + var matchesRequestedPolicy = function (resolvable) { return getPolicy(state.resolvePolicy, resolvable) >= policyOrdinal; }; + var matchingResolves = common_1.filter(resolvables, matchesRequestedPolicy); + var getResolvePromise = function (resolvable) { return resolvable.get(_this.isolateRootTo(state), options); }; + var resolvablePromises = common_1.map(matchingResolves, getResolvePromise); + trace_1.trace.traceResolvePathElement(this, matchingResolves, options); + return coreservices_1.services.$q.all(resolvablePromises).then(common_1.noop); + }; + ResolveContext.prototype.invokeLater = function (fn, locals, options) { + var _this = this; + if (locals === void 0) { locals = {}; } + if (options === void 0) { options = {}; } + var resolvables = this.getResolvablesForFn(fn); + trace_1.trace.tracePathElementInvoke(common_1.tail(this._path), fn, Object.keys(resolvables), common_1.extend({ when: "Later" }, options)); + var getPromise = function (resolvable) { return resolvable.get(_this, options); }; + var promises = common_1.map(resolvables, getPromise); + return coreservices_1.services.$q.all(promises).then(function () { + try { + return _this.invokeNow(fn, locals, options); + } + catch (error) { + return coreservices_1.services.$q.reject(error); + } + }); + }; + ResolveContext.prototype.invokeNow = function (fn, locals, options) { + if (options === void 0) { options = {}; } + var resolvables = this.getResolvablesForFn(fn); + trace_1.trace.tracePathElementInvoke(common_1.tail(this._path), fn, Object.keys(resolvables), common_1.extend({ when: "Now " }, options)); + var resolvedLocals = common_1.map(resolvables, common_1.prop("data")); + return coreservices_1.services.$injector.invoke(fn, null, common_1.extend({}, locals, resolvedLocals)); + }; + return ResolveContext; + })(); + exports.ResolveContext = ResolveContext; + function getPolicy(stateResolvePolicyConf, resolvable) { + var stateLevelPolicy = (common_1.isString(stateResolvePolicyConf) ? stateResolvePolicyConf : null); + var resolveLevelPolicies = (common_1.isObject(stateResolvePolicyConf) ? stateResolvePolicyConf : {}); + var policyName = resolveLevelPolicies[resolvable.name] || stateLevelPolicy || defaultResolvePolicy; + return interface_1.ResolvePolicy[policyName]; + } + //# sourceMappingURL=resolveContext.js.map + +/***/ }, +/* 19 */ +/***/ function(module, exports) { + + (function (ResolvePolicy) { + ResolvePolicy[ResolvePolicy["JIT"] = 0] = "JIT"; + ResolvePolicy[ResolvePolicy["LAZY"] = 1] = "LAZY"; + ResolvePolicy[ResolvePolicy["EAGER"] = 2] = "EAGER"; + })(exports.ResolvePolicy || (exports.ResolvePolicy = {})); + var ResolvePolicy = exports.ResolvePolicy; + //# sourceMappingURL=interface.js.map + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var ResolveInjector = (function () { + function ResolveInjector(_resolveContext, _state) { + this._resolveContext = _resolveContext; + this._state = _state; + } + ResolveInjector.prototype.invokeLater = function (injectedFn, locals) { + return this._resolveContext.invokeLater(injectedFn, locals); + }; + ResolveInjector.prototype.invokeNow = function (injectedFn, locals) { + return this._resolveContext.invokeNow(null, injectedFn, locals); + }; + ResolveInjector.prototype.getLocals = function (injectedFn) { + var _this = this; + var resolve = function (r) { return r.get(_this._resolveContext); }; + return common_1.map(this._resolveContext.getResolvablesForFn(injectedFn), resolve); + }; + return ResolveInjector; + })(); + exports.ResolveInjector = ResolveInjector; + //# sourceMappingURL=resolveInjector.js.map + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(2); + function normalizeUiViewTarget(rawViewName) { + if (rawViewName === void 0) { rawViewName = ""; } + var viewAtContext = rawViewName.split("@"); + var uiViewName = viewAtContext[0] || "$default"; + var uiViewContextAnchor = common_1.isString(viewAtContext[1]) ? viewAtContext[1] : "^"; + var relativeViewNameSugar = /^(\^(?:\.\^)*)\.(.*$)/.exec(uiViewName); + if (relativeViewNameSugar) { + uiViewContextAnchor = relativeViewNameSugar[1]; + uiViewName = relativeViewNameSugar[2]; + } + if (uiViewName.charAt(0) === '!') { + uiViewName = uiViewName.substr(1); + uiViewContextAnchor = ""; + } + return { uiViewName: uiViewName, uiViewContextAnchor: uiViewContextAnchor }; + } + var ViewConfig = (function () { + function ViewConfig(stateViewConfig) { + var _a = normalizeUiViewTarget(stateViewConfig.rawViewName), uiViewName = _a.uiViewName, uiViewContextAnchor = _a.uiViewContextAnchor; + var relativeMatch = /^(\^(?:\.\^)*)$/; + if (relativeMatch.exec(uiViewContextAnchor)) { + var anchor = uiViewContextAnchor.split(".").reduce((function (anchor, x) { return anchor.parent; }), stateViewConfig.context); + uiViewContextAnchor = anchor.name; + } + common_1.extend(this, common_1.pick(stateViewConfig, "viewDeclarationObj", "params", "context", "locals"), { uiViewName: uiViewName, uiViewContextAnchor: uiViewContextAnchor }); + this.controllerAs = stateViewConfig.viewDeclarationObj.controllerAs; + } + ViewConfig.prototype.hasTemplate = function () { + var viewDef = this.viewDeclarationObj; + return !!(viewDef.template || viewDef.templateUrl || viewDef.templateProvider); + }; + ViewConfig.prototype.getTemplate = function ($factory, injector) { + return $factory.fromConfig(this.viewDeclarationObj, this.params, injector.invokeLater.bind(injector)); + }; + ViewConfig.prototype.getController = function (injector) { + var provider = this.viewDeclarationObj.controllerProvider; + return common_1.isInjectable(provider) ? injector.invokeLater(provider, {}) : this.viewDeclarationObj.controller; + }; + return ViewConfig; + })(); + exports.ViewConfig = ViewConfig; + $View.$inject = ['$rootScope', '$templateFactory', '$q', '$timeout']; + function $View($rootScope, $templateFactory, $q, $timeout) { + var uiViews = []; + var viewConfigs = []; + var match = function (obj1) { + var keys = []; + for (var _i = 1; _i < arguments.length; _i++) { + keys[_i - 1] = arguments[_i]; + } + return function (obj2) { return keys.reduce((function (memo, key) { return memo && obj1[key] === obj2[key]; }), true); }; + }; + this.rootContext = function (context) { + return context ? this._rootContext = context : this._rootContext; + }; + this.load = function load(viewConfig, injector) { + if (!viewConfig.hasTemplate()) + throw new Error("No template configuration specified for '" + viewConfig.uiViewName + "@" + viewConfig.uiViewContextAnchor + "'"); + var promises = { + template: $q.when(viewConfig.getTemplate($templateFactory, injector)), + controller: $q.when(viewConfig.getController(injector)) + }; + return $q.all(promises).then(function (results) { + module_1.trace.traceViewServiceEvent("Loaded", viewConfig); + return common_1.extend(viewConfig, results); + }); + }; + this.reset = function reset(viewConfig) { + module_1.trace.traceViewServiceEvent("<- Removing", viewConfig); + viewConfigs.filter(match(viewConfig, "uiViewName", "context")).forEach(common_1.removeFrom(viewConfigs)); + }; + this.registerStateViewConfig = function (viewConfig) { + module_1.trace.traceViewServiceEvent("-> Registering", viewConfig); + viewConfigs.push(viewConfig); + }; + this.sync = function () { + var uiViewsByFqn = uiViews.map(function (uiv) { return [uiv.fqn, uiv]; }).reduce(common_1.applyPairs, {}); + var matches = common_1.curry(function (uiView, viewConfig) { + var vcSegments = viewConfig.uiViewName.split("."); + var uivSegments = uiView.fqn.split("."); + if (!angular.equals(vcSegments, uivSegments.slice(0 - vcSegments.length))) + return false; + var negOffset = (1 - vcSegments.length) || undefined; + var fqnToFirstSegment = uivSegments.slice(0, negOffset).join("."); + var uiViewContext = uiViewsByFqn[fqnToFirstSegment].creationContext; + return viewConfig.uiViewContextAnchor === (uiViewContext && uiViewContext.name); + }); + function uiViewDepth(uiView) { + return uiView.fqn.split(".").length; + } + function viewConfigDepth(config) { + var context = config.context, count = 0; + while (++count && context.parent) + context = context.parent; + return count; + } + var depthCompare = common_1.curry(function (depthFn, posNeg, left, right) { return posNeg * (depthFn(left) - depthFn(right)); }); + var matchingConfigPair = function (uiView) { + var matchingConfigs = viewConfigs.filter(matches(uiView)); + if (matchingConfigs.length > 1) + matchingConfigs.sort(depthCompare(viewConfigDepth, -1)); + return [uiView, matchingConfigs[0]]; + }; + var configureUiView = function (_a) { + var uiView = _a[0], viewConfig = _a[1]; + if (uiViews.indexOf(uiView) !== -1) + uiView.configUpdated(viewConfig); + }; + uiViews.sort(depthCompare(uiViewDepth, 1)).map(matchingConfigPair).forEach(configureUiView); + }; + this.registerUiView = function register(uiView) { + module_1.trace.traceViewServiceUiViewEvent("-> Registering", uiView); + var fqnMatches = function (uiv) { return uiv.fqn === uiView.fqn; }; + if (uiViews.filter(fqnMatches).length) + module_1.trace.traceViewServiceUiViewEvent("!!!! duplicate uiView named:", uiView); + uiViews.push(uiView); + this.sync(); + return function () { + var idx = uiViews.indexOf(uiView); + if (idx <= 0) { + module_1.trace.traceViewServiceUiViewEvent("Tried removing non-registered uiView", uiView); + return; + } + module_1.trace.traceViewServiceUiViewEvent("<- Deregistering", uiView); + common_1.removeFrom(uiViews)(uiView); + }; + }; + this.available = function () { return uiViews.map(common_1.prop("fqn")); }; + this.active = function () { return uiViews.filter(common_1.prop("$config")).map(common_1.prop("name")); }; + } + angular.module('ui.router.state').service('$view', $View); + //# sourceMappingURL=view.js.map + +/***/ }, +/* 22 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(12); + var module_2 = __webpack_require__(15); + var module_3 = __webpack_require__(17); + var PathFactory = (function () { + function PathFactory() { + } + PathFactory.makeTargetState = function (path) { + var state = common_1.tail(path).state; + return new module_1.TargetState(state, state, path.map(common_1.prop("values")).reduce(common_1.mergeR, {})); + }; + PathFactory.buildToPath = function (fromPath, targetState) { + var toParams = targetState.params(); + var toParamsNodeFn = PathFactory.makeParamsNode(toParams); + var toPath = targetState.$state().path.map(toParamsNodeFn); + if (targetState.options().inherit) + toPath = PathFactory.inheritParams(fromPath, toPath, Object.keys(toParams)); + return toPath; + }; + PathFactory.inheritParams = function (fromPath, toPath, toKeys) { + if (toKeys === void 0) { toKeys = []; } + function nodeParamVals(path, state) { + var node = common_1.find(path, common_1.propEq('state', state)); + return common_1.extend({}, node && node.values); + } + var makeInheritedParamsNode = common_1.curry(function (_fromPath, _toKeys, toNode) { + var toParamVals = common_1.extend({}, toNode && toNode.values); + var incomingParamVals = common_1.pick(toParamVals, _toKeys); + toParamVals = common_1.omit(toParamVals, _toKeys); + var fromParamVals = nodeParamVals(_fromPath, toNode.state) || {}; + var ownParamVals = common_1.extend(toParamVals, fromParamVals, incomingParamVals); + return new module_2.Node(toNode.state, ownParamVals); + }); + return toPath.map(makeInheritedParamsNode(fromPath, toKeys)); + }; + PathFactory.bindTransNodesToPath = function (resolvePath) { + var resolveContext = new module_3.ResolveContext(resolvePath); + resolvePath.forEach(function (node) { + node.resolveContext = resolveContext.isolateRootTo(node.state); + node.resolveInjector = new module_3.ResolveInjector(node.resolveContext, node.state); + node.resolves.$stateParams = new module_3.Resolvable("$stateParams", function () { return node.values; }, node.values); + }); + return resolvePath; + }; + PathFactory.treeChanges = function (fromPath, toPath, reloadState) { + var keep = 0, max = Math.min(fromPath.length, toPath.length); + var staticParams = function (state) { return state.parameters({ inherit: false }).filter(common_1.not(common_1.prop('dynamic'))).map(common_1.prop('id')); }; + var nodesMatch = function (node1, node2) { return node1.equals(node2, staticParams(node1.state)); }; + while (keep < max && fromPath[keep].state !== reloadState && nodesMatch(fromPath[keep], toPath[keep])) { + keep++; + } + function applyToParams(retainedNode, idx) { + return module_2.Node.clone(retainedNode, { values: toPath[idx].values }); + } + var from, retained, exiting, entering, to; + var retainedWithToParams, enteringResolvePath, toResolvePath; + from = fromPath; + retained = from.slice(0, keep); + exiting = from.slice(keep); + retainedWithToParams = retained.map(applyToParams); + enteringResolvePath = toPath.slice(keep); + toResolvePath = (retainedWithToParams).concat(enteringResolvePath); + to = PathFactory.bindTransNodesToPath(toResolvePath); + entering = to.slice(keep); + return { from: from, to: to, retained: retained, exiting: exiting, entering: entering }; + }; + PathFactory.bindTransitionResolve = function (treeChanges, transition) { + var rootNode = treeChanges.to[0]; + rootNode.resolves.$transition$ = new module_3.Resolvable('$transition$', function () { return transition; }, transition); + }; + PathFactory.makeParamsNode = common_1.curry(function (params, state) { return new module_2.Node(state, params); }); + return PathFactory; + })(); + exports.PathFactory = PathFactory; + //# sourceMappingURL=pathFactory.js.map + +/***/ }, +/* 23 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var param_1 = __webpack_require__(24); + var rejectFactory_1 = __webpack_require__(28); + var targetState_1 = __webpack_require__(29); + var viewHooks_1 = __webpack_require__(30); + var enterExitHooks_1 = __webpack_require__(39); + var resolveHooks_1 = __webpack_require__(40); + var TransitionManager = (function () { + function TransitionManager(transition, $transitions, $urlRouter, $view, $state, $stateParams, $q, activeTransQ, changeHistory) { + this.transition = transition; + this.$transitions = $transitions; + this.$urlRouter = $urlRouter; + this.$view = $view; + this.$state = $state; + this.$stateParams = $stateParams; + this.$q = $q; + this.activeTransQ = activeTransQ; + this.changeHistory = changeHistory; + this.viewHooks = new viewHooks_1.ViewHooks(transition, $view); + this.enterExitHooks = new enterExitHooks_1.EnterExitHooks(transition); + this.resolveHooks = new resolveHooks_1.ResolveHooks(transition); + this.treeChanges = transition.treeChanges(); + this.registerUpdateGlobalState(); + this.viewHooks.registerHooks(); + this.enterExitHooks.registerHooks(); + this.resolveHooks.registerHooks(); + } + TransitionManager.prototype.runTransition = function () { + var _this = this; + this.activeTransQ.clear(); + this.activeTransQ.enqueue(this.transition); + return this.transition.run() + .then(function (trans) { return trans.to(); }) + .catch(function (error) { return _this.transRejected(error); }) + .finally(function () { return _this.activeTransQ.remove(_this.transition); }); + }; + TransitionManager.prototype.registerUpdateGlobalState = function () { + this.transition.onFinish({}, this.updateGlobalState.bind(this), { priority: -10000 }); + }; + TransitionManager.prototype.updateGlobalState = function () { + var _a = this, treeChanges = _a.treeChanges, transition = _a.transition, $state = _a.$state, changeHistory = _a.changeHistory; + $state.$current = transition.$to(); + $state.current = $state.$current.self; + changeHistory.enqueue(treeChanges); + this.updateStateParams(); + }; + TransitionManager.prototype.transRejected = function (error) { + var _a = this, transition = _a.transition, $state = _a.$state, $stateParams = _a.$stateParams, $q = _a.$q; + if (error instanceof rejectFactory_1.TransitionRejection) { + if (error.type === rejectFactory_1.RejectType.IGNORED) { + var dynamic = $state.$current.parameters().filter(common_1.prop('dynamic')); + if (!param_1.Param.equals(dynamic, $stateParams, transition.params())) { + this.updateStateParams(); + } + return $state.current; + } + if (error.type === rejectFactory_1.RejectType.SUPERSEDED && error.redirected && error.detail instanceof targetState_1.TargetState) { + return this._redirectMgr(transition.redirect(error.detail)).runTransition(); + } + } + this.$transitions.defaultErrorHandler()(error); + return $q.reject(error); + }; + TransitionManager.prototype.updateStateParams = function () { + var _a = this, transition = _a.transition, $urlRouter = _a.$urlRouter, $state = _a.$state, $stateParams = _a.$stateParams; + var options = transition.options(); + $state.params = transition.params(); + common_1.copy($state.params, $stateParams); + $stateParams.$sync().$off(); + if (options.location && $state.$current.navigable) { + $urlRouter.push($state.$current.navigable.url, $stateParams, { replace: options.location === 'replace' }); + } + $urlRouter.update(true); + }; + TransitionManager.prototype._redirectMgr = function (redirect) { + var _a = this, $transitions = _a.$transitions, $urlRouter = _a.$urlRouter, $view = _a.$view, $state = _a.$state, $stateParams = _a.$stateParams, $q = _a.$q, activeTransQ = _a.activeTransQ, changeHistory = _a.changeHistory; + return new TransitionManager(redirect, $transitions, $urlRouter, $view, $state, $stateParams, $q, activeTransQ, changeHistory); + }; + return TransitionManager; + })(); + exports.TransitionManager = TransitionManager; + //# sourceMappingURL=transitionManager.js.map + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var coreservices_1 = __webpack_require__(4); + var urlMatcherConfig_1 = __webpack_require__(25); + var type_1 = __webpack_require__(26); + var paramTypes_1 = __webpack_require__(27); + var hasOwn = Object.prototype.hasOwnProperty; + var isShorthand = function (cfg) { return ["value", "type", "squash", "array", "dynamic"].filter(hasOwn.bind(cfg || {})).length === 0; }; + var DefType; + (function (DefType) { + DefType[DefType["PATH"] = 0] = "PATH"; + DefType[DefType["SEARCH"] = 1] = "SEARCH"; + DefType[DefType["CONFIG"] = 2] = "CONFIG"; + })(DefType || (DefType = {})); + var Param = (function () { + function Param(id, type, config, location) { + config = unwrapShorthand(config); + type = getType(config, type, location); + var arrayMode = getArrayMode(); + type = arrayMode ? type.$asArray(arrayMode, location === DefType.SEARCH) : type; + var isOptional = config.value !== undefined; + var dynamic = config.dynamic === true; + var squash = getSquashPolicy(config, isOptional); + var replace = getReplace(config, arrayMode, isOptional, squash); + function unwrapShorthand(config) { + config = isShorthand(config) && { value: config } || config; + return common_1.extend(config, { + $$fn: common_1.isInjectable(config.value) ? config.value : function () { return config.value; } + }); + } + function getType(config, urlType, location) { + if (config.type && urlType && urlType.name !== 'string') + throw new Error("Param '" + id + "' has two type configurations."); + if (config.type && urlType && urlType.name === 'string' && paramTypes_1.paramTypes.type(config.type)) + return paramTypes_1.paramTypes.type(config.type); + if (urlType) + return urlType; + if (!config.type) + return (location === DefType.CONFIG ? paramTypes_1.paramTypes.type("any") : paramTypes_1.paramTypes.type("string")); + return config.type instanceof type_1.Type ? config.type : paramTypes_1.paramTypes.type(config.type); + } + function getArrayMode() { + var arrayDefaults = { array: (location === DefType.SEARCH ? "auto" : false) }; + var arrayParamNomenclature = id.match(/\[\]$/) ? { array: true } : {}; + return common_1.extend(arrayDefaults, arrayParamNomenclature, config).array; + } + function getSquashPolicy(config, isOptional) { + var squash = config.squash; + if (!isOptional || squash === false) + return false; + if (!common_1.isDefined(squash) || squash == null) + return urlMatcherConfig_1.matcherConfig.defaultSquashPolicy(); + if (squash === true || common_1.isString(squash)) + return squash; + throw new Error("Invalid squash policy: '" + squash + "'. Valid policies: false, true, or arbitrary string"); + } + function getReplace(config, arrayMode, isOptional, squash) { + var replace, configuredKeys, defaultPolicy = [ + { from: "", to: (isOptional || arrayMode ? undefined : "") }, + { from: null, to: (isOptional || arrayMode ? undefined : "") } + ]; + replace = common_1.isArray(config.replace) ? config.replace : []; + if (common_1.isString(squash)) + replace.push({ from: squash, to: undefined }); + configuredKeys = common_1.map(replace, common_1.prop("from")); + return common_1.filter(defaultPolicy, function (item) { return configuredKeys.indexOf(item.from) === -1; }).concat(replace); + } + common_1.extend(this, { id: id, type: type, location: location, squash: squash, replace: replace, isOptional: isOptional, dynamic: dynamic, config: config, array: arrayMode }); + } + Param.prototype.isDefaultValue = function (value) { + return this.isOptional && this.type.equals(this.value(), value); + }; + Param.prototype.value = function (value) { + var _this = this; + var $$getDefaultValue = function () { + if (!coreservices_1.services.$injector) + throw new Error("Injectable functions cannot be called at configuration time"); + var defaultValue = coreservices_1.services.$injector.invoke(_this.config.$$fn); + if (defaultValue !== null && defaultValue !== undefined && !_this.type.is(defaultValue)) + throw new Error("Default value (" + defaultValue + ") for parameter '" + _this.id + "' is not an instance of Type (" + _this.type.name + ")"); + return defaultValue; + }; + var $replace = function (value) { + var replacement = common_1.map(common_1.filter(_this.replace, common_1.propEq('from', value)), common_1.prop("to")); + return replacement.length ? replacement[0] : value; + }; + value = $replace(value); + return !common_1.isDefined(value) ? $$getDefaultValue() : this.type.$normalize(value); + }; + Param.prototype.isSearch = function () { + return this.location === DefType.SEARCH; + }; + Param.prototype.validates = function (value) { + if ((!common_1.isDefined(value) || value === null) && this.isOptional) + return true; + var normalized = this.type.$normalize(value); + if (!this.type.is(normalized)) + return false; + var encoded = this.type.encode(normalized); + if (common_1.isString(encoded) && !this.type.pattern.exec(encoded)) + return false; + return true; + }; + Param.prototype.toString = function () { + return "{Param:" + this.id + " " + this.type + " squash: '" + this.squash + "' optional: " + this.isOptional + "}"; + }; + Param.fromConfig = function (id, type, config) { + return new Param(id, type, config, DefType.CONFIG); + }; + Param.fromPath = function (id, type, config) { + return new Param(id, type, config, DefType.PATH); + }; + Param.fromSearch = function (id, type, config) { + return new Param(id, type, config, DefType.SEARCH); + }; + Param.values = function (params, values) { + values = values || {}; + return params.map(function (param) { return [param.id, param.value(values[param.id])]; }).reduce(common_1.applyPairs, {}); + }; + Param.equals = function (params, values1, values2) { + values1 = values1 || {}; + values2 = values2 || {}; + return params.map(function (param) { return param.type.equals(values1[param.id], values2[param.id]); }).indexOf(false) === -1; + }; + Param.validates = function (params, values) { + values = values || {}; + return params.map(function (param) { return param.validates(values[param.id]); }).indexOf(false) === -1; + }; + return Param; + })(); + exports.Param = Param; + //# sourceMappingURL=param.js.map + +/***/ }, +/* 25 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var MatcherConfig = (function () { + function MatcherConfig() { + this._isCaseInsensitive = false; + this._isStrictMode = true; + this._defaultSquashPolicy = false; + } + MatcherConfig.prototype.caseInsensitive = function (value) { + return this._isCaseInsensitive = common_1.isDefined(value) ? value : this._isCaseInsensitive; + }; + MatcherConfig.prototype.strictMode = function (value) { + return this._isStrictMode = common_1.isDefined(value) ? value : this._isStrictMode; + }; + MatcherConfig.prototype.defaultSquashPolicy = function (value) { + if (common_1.isDefined(value) && value !== true && value !== false && !common_1.isString(value)) + throw new Error("Invalid squash policy: " + value + ". Valid policies: false, true, arbitrary-string"); + return this._defaultSquashPolicy = common_1.isDefined(value) ? value : this._defaultSquashPolicy; + }; + return MatcherConfig; + })(); + exports.matcherConfig = new MatcherConfig(); + //# sourceMappingURL=urlMatcherConfig.js.map + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + function ArrayType(type, mode) { + var _this = this; + function arrayWrap(val) { return common_1.isArray(val) ? val : (common_1.isDefined(val) ? [val] : []); } + function arrayUnwrap(val) { + switch (val.length) { + case 0: return undefined; + case 1: return mode === "auto" ? val[0] : val; + default: return val; + } + } + function arrayHandler(callback, allTruthyMode) { + return function handleArray(val) { + var arr = arrayWrap(val); + var result = common_1.map(arr, callback); + return (allTruthyMode === true) ? common_1.filter(result, function (val) { return !val; }).length === 0 : arrayUnwrap(result); + }; + } + function arrayEqualsHandler(callback) { + return function handleArray(val1, val2) { + var left = arrayWrap(val1), right = arrayWrap(val2); + if (left.length !== right.length) + return false; + for (var i = 0; i < left.length; i++) { + if (!callback(left[i], right[i])) + return false; + } + return true; + }; + } + ['encode', 'decode', 'equals', '$normalize'].map(function (name) { + _this[name] = (name === 'equals' ? arrayEqualsHandler : arrayHandler)(type[name].bind(type)); + }); + common_1.extend(this, { + name: type.name, + pattern: type.pattern, + is: arrayHandler(type.is.bind(type), true), + $arrayMode: mode + }); + } + var Type = (function () { + function Type(def) { + this.pattern = /.*/; + common_1.extend(this, def); + } + Type.prototype.is = function (val, key) { return true; }; + Type.prototype.encode = function (val, key) { return val; }; + Type.prototype.decode = function (val, key) { return val; }; + Type.prototype.equals = function (a, b) { return a == b; }; + Type.prototype.$subPattern = function () { + var sub = this.pattern.toString(); + return sub.substr(1, sub.length - 2); + }; + Type.prototype.toString = function () { + return "{Type:" + this.name + "}"; + }; + Type.prototype.$normalize = function (val) { + return this.is(val) ? val : this.decode(val); + }; + Type.prototype.$asArray = function (mode, isSearch) { + if (!mode) + return this; + if (mode === "auto" && !isSearch) + throw new Error("'auto' array mode is for query parameters only"); + return new ArrayType(this, mode); + }; + return Type; + })(); + exports.Type = Type; + //# sourceMappingURL=type.js.map + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var coreservices_1 = __webpack_require__(4); + var type_1 = __webpack_require__(26); + var swapString = function (search, replace) { return function (val) { return val != null ? val.toString().replace(search, replace) : val; }; }; + var valToString = swapString(/\//g, "%2F"); + var valFromString = swapString(/%2F/g, "/"); + var ParamTypes = (function () { + function ParamTypes() { + this.enqueue = true; + this.typeQueue = []; + this.defaultTypes = { + hash: { + encode: valToString, + decode: valFromString, + is: common_1.is(String), + pattern: /.*/, + equals: common_1.val(true) + }, + string: { + encode: valToString, + decode: valFromString, + is: common_1.is(String), + pattern: /[^/]*/ + }, + int: { + encode: valToString, + decode: function (val) { return parseInt(val, 10); }, + is: function (val) { return common_1.isDefined(val) && this.decode(val.toString()) === val; }, + pattern: /-?\d+/ + }, + bool: { + encode: function (val) { return val && 1 || 0; }, + decode: function (val) { return parseInt(val, 10) !== 0; }, + is: common_1.is(Boolean), + pattern: /0|1/ + }, + date: { + encode: function (val) { + return !this.is(val) ? undefined : [ + val.getFullYear(), + ('0' + (val.getMonth() + 1)).slice(-2), + ('0' + val.getDate()).slice(-2) + ].join("-"); + }, + decode: function (val) { + if (this.is(val)) + return val; + var match = this.capture.exec(val); + return match ? new Date(match[1], match[2] - 1, match[3]) : undefined; + }, + is: function (val) { return val instanceof Date && !isNaN(val.valueOf()); }, + equals: function (a, b) { return this.is(a) && this.is(b) && a.toISOString() === b.toISOString(); }, + pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/, + capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/ + }, + json: { + encode: common_1.toJson, + decode: common_1.fromJson, + is: common_1.is(Object), + equals: common_1.equals, + pattern: /[^/]*/ + }, + any: { + encode: common_1.identity, + decode: common_1.identity, + equals: common_1.equals, + pattern: /.*/ + } + }; + var makeType = function (definition, name) { return new type_1.Type(common_1.extend({ name: name }, definition)); }; + this.types = common_1.inherit(common_1.map(this.defaultTypes, makeType), {}); + } + ParamTypes.prototype.type = function (name, definition, definitionFn) { + if (!common_1.isDefined(definition)) + return this.types[name]; + if (this.types.hasOwnProperty(name)) + throw new Error("A type named '" + name + "' has already been defined."); + this.types[name] = new type_1.Type(common_1.extend({ name: name }, definition)); + if (definitionFn) { + this.typeQueue.push({ name: name, def: definitionFn }); + if (!this.enqueue) + this._flushTypeQueue(); + } + return this; + }; + ParamTypes.prototype._flushTypeQueue = function () { + while (this.typeQueue.length) { + var type = this.typeQueue.shift(); + if (type.pattern) + throw new Error("You cannot override a type's .pattern at runtime."); + common_1.extend(this.types[type.name], coreservices_1.services.$injector.invoke(type.def)); + } + }; + return ParamTypes; + })(); + exports.paramTypes = new ParamTypes(); + //# sourceMappingURL=paramTypes.js.map + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var common_1 = __webpack_require__(3); + var coreservices_1 = __webpack_require__(4); + (function (RejectType) { + RejectType[RejectType["SUPERSEDED"] = 2] = "SUPERSEDED"; + RejectType[RejectType["ABORTED"] = 3] = "ABORTED"; + RejectType[RejectType["INVALID"] = 4] = "INVALID"; + RejectType[RejectType["IGNORED"] = 5] = "IGNORED"; + })(exports.RejectType || (exports.RejectType = {})); + var RejectType = exports.RejectType; + var TransitionRejection = (function () { + function TransitionRejection(type, message, detail) { + common_1.extend(this, { + type: type, + message: message, + detail: detail + }); + } + TransitionRejection.prototype.toString = function () { + var detailString = function (d) { return d && d.toString !== Object.prototype.toString ? d.toString() : JSON.stringify(d); }; + var type = this.type, message = this.message, detail = detailString(this.detail); + return "TransitionRejection(type: " + type + ", message: " + message + ", detail: " + detail + ")"; + }; + return TransitionRejection; + })(); + exports.TransitionRejection = TransitionRejection; + var RejectFactory = (function () { + function RejectFactory() { + } + RejectFactory.prototype.superseded = function (detail, options) { + var message = "The transition has been superseded by a different transition (see detail)."; + var reason = new TransitionRejection(RejectType.SUPERSEDED, message, detail); + if (options && options.redirected) { + reason.redirected = true; + } + return common_1.extend(coreservices_1.services.$q.reject(reason), { reason: reason }); + }; + RejectFactory.prototype.redirected = function (detail) { + return this.superseded(detail, { redirected: true }); + }; + RejectFactory.prototype.invalid = function (detail) { + var message = "This transition is invalid (see detail)"; + var reason = new TransitionRejection(RejectType.INVALID, message, detail); + return common_1.extend(coreservices_1.services.$q.reject(reason), { reason: reason }); + }; + RejectFactory.prototype.ignored = function (detail) { + var message = "The transition was ignored."; + var reason = new TransitionRejection(RejectType.IGNORED, message, detail); + return common_1.extend(coreservices_1.services.$q.reject(reason), { reason: reason }); + }; + RejectFactory.prototype.aborted = function (detail) { + var message = "The transition has been aborted."; + var reason = new TransitionRejection(RejectType.ABORTED, message, detail); + return common_1.extend(coreservices_1.services.$q.reject(reason), { reason: reason }); + }; + return RejectFactory; + })(); + exports.RejectFactory = RejectFactory; + //# sourceMappingURL=rejectFactory.js.map + +/***/ }, +/* 29 */ +/***/ function(module, exports) { + + var TargetState = (function () { + function TargetState(_identifier, _definition, _params, _options) { + if (_params === void 0) { _params = {}; } + if (_options === void 0) { _options = {}; } + this._identifier = _identifier; + this._definition = _definition; + this._options = _options; + this._params = _params || {}; + } + TargetState.prototype.name = function () { + return this._definition && this._definition.name || this._identifier; + }; + TargetState.prototype.identifier = function () { + return this._identifier; + }; + TargetState.prototype.params = function () { + return this._params; + }; + TargetState.prototype.$state = function () { + return this._definition; + }; + TargetState.prototype.state = function () { + return this._definition && this._definition.self; + }; + TargetState.prototype.options = function () { + return this._options; + }; + TargetState.prototype.exists = function () { + return !!(this._definition && this._definition.self); + }; + TargetState.prototype.valid = function () { + return !this.error(); + }; + TargetState.prototype.error = function () { + var base = this.options().relative; + if (!this._definition && !!base) { + var stateName = base.name ? base.name : base; + return "Could not resolve '" + this.name() + "' from state '" + stateName + "'"; + } + if (!this._definition) + return "No such state '" + this.name() + "'"; + if (!this._definition.self) + return "State '" + this.name() + "' has an invalid definition"; + }; + return TargetState; + })(); + exports.TargetState = TargetState; + //# sourceMappingURL=targetState.js.map + +/***/ }, +/* 30 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var coreservices_1 = __webpack_require__(4); + var angular1_1 = __webpack_require__(31); + var ViewHooks = (function () { + function ViewHooks(transition, $view) { + this.transition = transition; + this.$view = $view; + this.treeChanges = transition.treeChanges(); + this.enteringViews = transition.views("entering"); + this.exitingViews = transition.views("exiting"); + } + ViewHooks.prototype.loadAllEnteringViews = function () { + var _this = this; + var loadView = function (vc) { + var resolveInjector = common_1.find(_this.treeChanges.to, common_1.propEq('state', vc.context)).resolveInjector; + return _this.$view.load(vc, resolveInjector); + }; + return coreservices_1.services.$q.all(this.enteringViews.map(loadView)).then(common_1.noop); + }; + ViewHooks.prototype.loadAllControllerLocals = function () { + var _this = this; + var loadLocals = function (vc) { + var deps = angular1_1.annotateController(vc.controller); + var resolveInjector = common_1.find(_this.treeChanges.to, common_1.propEq('state', vc.context)).resolveInjector; + function $loadControllerLocals() { } + $loadControllerLocals.$inject = deps; + return coreservices_1.services.$q.all(resolveInjector.getLocals($loadControllerLocals)).then(function (locals) { return vc.locals = locals; }); + }; + var loadAllLocals = this.enteringViews.filter(function (vc) { return !!vc.controller; }).map(loadLocals); + return coreservices_1.services.$q.all(loadAllLocals).then(common_1.noop); + }; + ViewHooks.prototype.updateViews = function () { + var $view = this.$view; + this.exitingViews.forEach(function (viewConfig) { return $view.reset(viewConfig); }); + this.enteringViews.forEach(function (viewConfig) { return $view.registerStateViewConfig(viewConfig); }); + $view.sync(); + }; + ViewHooks.prototype.registerHooks = function () { + if (this.enteringViews.length) { + this.transition.onStart({}, this.loadAllEnteringViews.bind(this)); + this.transition.onFinish({}, this.loadAllControllerLocals.bind(this)); + } + if (this.exitingViews.length || this.enteringViews.length) + this.transition.onSuccess({}, this.updateViews.bind(this)); + }; + return ViewHooks; + })(); + exports.ViewHooks = ViewHooks; + //# sourceMappingURL=viewHooks.js.map + +/***/ }, +/* 31 */ +/***/ function(module, exports, __webpack_require__) { + + var router_1 = __webpack_require__(32); + var coreservices_1 = __webpack_require__(4); + var common_1 = __webpack_require__(3); + var app = angular.module("ui.router.angular1", []); + function annotateController(controllerExpression) { + var $injector = coreservices_1.services.$injector; + var $controller = $injector.get("$controller"); + var oldInstantiate = $injector.instantiate; + try { + var deps; + $injector.instantiate = function fakeInstantiate(constructorFunction) { + $injector.instantiate = oldInstantiate; + deps = $injector.annotate(constructorFunction); + }; + $controller(controllerExpression, { $scope: {} }); + return deps; + } + finally { + $injector.instantiate = oldInstantiate; + } + } + exports.annotateController = annotateController; + runBlock.$inject = ['$injector', '$q']; + function runBlock($injector, $q) { + coreservices_1.services.$injector = $injector; + coreservices_1.services.$q = $q; + } + app.run(runBlock); + var bindFunctions = function (fnNames, from, to) { + return fnNames.forEach(function (name) { return to[name] = from[name].bind(from); }); + }; + var router = null; + ng1UIRouter.$inject = ['$locationProvider']; + function ng1UIRouter($locationProvider) { + router = new router_1.Router(); + bindFunctions(['hashPrefix'], $locationProvider, coreservices_1.services.locationConfig); + this.$get = $get; + $get.$inject = ['$location', '$browser', '$sniffer']; + function $get($location, $browser, $sniffer) { + coreservices_1.services.locationConfig.html5Mode = function () { + var html5Mode = $locationProvider.html5Mode(); + html5Mode = common_1.isObject(html5Mode) ? html5Mode.enabled : html5Mode; + return html5Mode && $sniffer.history; + }; + bindFunctions(["replace", "url", "path", "search", "hash"], $location, coreservices_1.services.location); + bindFunctions(['port', 'protocol', 'host'], $location, coreservices_1.services.locationConfig); + bindFunctions(['baseHref'], $browser, coreservices_1.services.locationConfig); + return router; + } + } + angular.module('ui.router.init', []).provider("ng1UIRouter", ng1UIRouter); + angular.module('ui.router.util').provider('$urlMatcherFactory', ['ng1UIRouterProvider', function () { return router.urlMatcherFactory; }]); + angular.module('ui.router.router').provider('$urlRouter', ['ng1UIRouterProvider', function () { return router.urlRouterProvider; }]); + angular.module('ui.router.state').provider('$state', ['ng1UIRouterProvider', function () { return router.stateProvider; }]); + angular.module('ui.router.init').run(['ng1UIRouter', function (ng1UIRouter) { }]); + angular.module('ui.router.state').run(['$state', function ($state) { }]); + angular.module('ui.router.util').run(['$urlMatcherFactory', function ($urlMatcherFactory) { }]); + //# sourceMappingURL=angular1.js.map + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + var urlMatcherFactory_1 = __webpack_require__(33); + var urlRouter_1 = __webpack_require__(38); + var state_1 = __webpack_require__(14); + var Router = (function () { + function Router() { + this.urlMatcherFactory = new urlMatcherFactory_1.UrlMatcherFactory(); + this.urlRouterProvider = new urlRouter_1.$UrlRouterProvider(this.urlMatcherFactory); + this.stateProvider = new state_1.$StateProvider(this.urlRouterProvider, this.urlMatcherFactory); + } + return Router; + })(); + exports.Router = Router; + //# sourceMappingURL=router.js.map + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(34); + var module_2 = __webpack_require__(36); + function getDefaultConfig() { + return { + strict: module_1.matcherConfig.strictMode(), + caseInsensitive: module_1.matcherConfig.caseInsensitive() + }; + } + var UrlMatcherFactory = (function () { + function UrlMatcherFactory() { + common_1.extend(this, { UrlMatcher: module_1.UrlMatcher, Param: module_2.Param }); + } + UrlMatcherFactory.prototype.caseInsensitive = function (value) { + return module_1.matcherConfig.caseInsensitive(value); + }; + UrlMatcherFactory.prototype.strictMode = function (value) { + return module_1.matcherConfig.strictMode(value); + }; + UrlMatcherFactory.prototype.defaultSquashPolicy = function (value) { + return module_1.matcherConfig.defaultSquashPolicy(value); + }; + UrlMatcherFactory.prototype.compile = function (pattern, config) { + return new module_1.UrlMatcher(pattern, common_1.extend(getDefaultConfig(), config)); + }; + UrlMatcherFactory.prototype.isMatcher = function (object) { + if (!common_1.isObject(object)) + return false; + var result = true; + common_1.forEach(module_1.UrlMatcher.prototype, function (val, name) { + if (common_1.isFunction(val)) + result = result && (common_1.isDefined(object[name]) && common_1.isFunction(object[name])); + }); + return result; + }; + ; + UrlMatcherFactory.prototype.type = function (name, definition, definitionFn) { + var type = module_2.paramTypes.type(name, definition, definitionFn); + return !common_1.isDefined(definition) ? type : this; + }; + ; + UrlMatcherFactory.prototype.$get = function () { + module_2.paramTypes.enqueue = false; + module_2.paramTypes._flushTypeQueue(); + return this; + }; + ; + return UrlMatcherFactory; + })(); + exports.UrlMatcherFactory = UrlMatcherFactory; + //# sourceMappingURL=urlMatcherFactory.js.map + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(__webpack_require__(35)); + __export(__webpack_require__(25)); + __export(__webpack_require__(33)); + __export(__webpack_require__(38)); + //# sourceMappingURL=module.js.map + +/***/ }, +/* 35 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(36); + function quoteRegExp(string, param) { + var surroundPattern = ['', ''], result = string.replace(/[\\\[\]\^$*+?.()|{}]/g, "\\$&"); + if (!param) + return result; + switch (param.squash) { + case false: + surroundPattern = ['(', ')' + (param.isOptional ? '?' : '')]; + break; + case true: + surroundPattern = ['?(', ')?']; + break; + default: + surroundPattern = [("(" + param.squash + "|"), ')?']; + break; + } + return result + surroundPattern[0] + param.type.pattern.source + surroundPattern[1]; + } + var memoizeTo = function (obj, prop, fn) { return obj[prop] = obj[prop] || fn(); }; + var UrlMatcher = (function () { + function UrlMatcher(pattern, config) { + var _this = this; + this.pattern = pattern; + this.config = config; + this._cache = { path: [], pattern: null }; + this._children = []; + this._params = []; + this._segments = []; + this._compiled = []; + this.config = common_1.defaults(this.config, { + params: {}, + strict: true, + caseInsensitive: false, + paramMap: common_1.identity + }); + var placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g, searchPlaceholder = /([:]?)([\w\[\]-]+)|\{([\w\[\]-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g, last = 0, m, patterns = []; + var checkParamErrors = function (id) { + if (!UrlMatcher.nameValidator.test(id)) + throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'"); + if (common_1.find(_this._params, common_1.propEq('id', id))) + throw new Error("Duplicate parameter name '" + id + "' in pattern '" + pattern + "'"); + }; + var matchDetails = function (m, isSearch) { + var id = m[2] || m[3], regexp = isSearch ? m[4] : m[4] || (m[1] === '*' ? '.*' : null); + return { + id: id, + regexp: regexp, + cfg: _this.config.params[id], + segment: pattern.substring(last, m.index), + type: !regexp ? null : module_1.paramTypes.type(regexp || "string") || common_1.inherit(module_1.paramTypes.type("string"), { + pattern: new RegExp(regexp, _this.config.caseInsensitive ? 'i' : undefined) + }) + }; + }; + var p, param, segment; + while ((m = placeholder.exec(pattern))) { + p = matchDetails(m, false); + if (p.segment.indexOf('?') >= 0) + break; + checkParamErrors(p.id); + this._params.push(module_1.Param.fromPath(p.id, p.type, this.config.paramMap(p.cfg, false))); + this._segments.push(p.segment); + patterns.push([p.segment, common_1.tail(this._params)]); + last = placeholder.lastIndex; + } + segment = pattern.substring(last); + var i = segment.indexOf('?'); + if (i >= 0) { + var search = segment.substring(i); + segment = segment.substring(0, i); + if (search.length > 0) { + last = 0; + while ((m = searchPlaceholder.exec(search))) { + p = matchDetails(m, true); + checkParamErrors(p.id); + this._params.push(module_1.Param.fromSearch(p.id, p.type, this.config.paramMap(p.cfg, true))); + last = placeholder.lastIndex; + } + } + } + this._segments.push(segment); + common_1.extend(this, { + _compiled: patterns.map(function (pattern) { return quoteRegExp.apply(null, pattern); }).concat(quoteRegExp(segment)), + prefix: this._segments[0] + }); + Object.freeze(this); + } + UrlMatcher.prototype.append = function (url) { + this._children.push(url); + common_1.forEach(url._cache, function (val, key) { return url._cache[key] = common_1.isArray(val) ? [] : null; }); + url._cache.path = this._cache.path.concat(this); + return url; + }; + UrlMatcher.prototype.isRoot = function () { + return this._cache.path.length === 0; + }; + UrlMatcher.prototype.toString = function () { + return this.pattern; + }; + UrlMatcher.prototype.exec = function (path, search, hash, options) { + var _this = this; + if (search === void 0) { search = {}; } + if (options === void 0) { options = {}; } + var match = memoizeTo(this._cache, 'pattern', function () { + return new RegExp([ + '^', + common_1.unnest(_this._cache.path.concat(_this).map(common_1.prop('_compiled'))).join(''), + _this.config.strict === false ? '\/?' : '', + '$' + ].join(''), _this.config.caseInsensitive ? 'i' : undefined); + }).exec(path); + if (!match) + return null; + var allParams = this.parameters(), pathParams = allParams.filter(function (param) { return !param.isSearch(); }), searchParams = allParams.filter(function (param) { return param.isSearch(); }), nPathSegments = this._cache.path.concat(this).map(function (urlm) { return urlm._segments.length - 1; }).reduce(function (a, x) { return a + x; }), values = {}; + if (nPathSegments !== match.length - 1) + throw new Error("Unbalanced capture group in route '" + this.pattern + "'"); + function decodePathArray(string) { + var reverseString = function (str) { return str.split("").reverse().join(""); }; + var unquoteDashes = function (str) { return str.replace(/\\-/g, "-"); }; + var split = reverseString(string).split(/-(?!\\)/); + var allReversed = common_1.map(split, reverseString); + return common_1.map(allReversed, unquoteDashes).reverse(); + } + for (var i = 0; i < nPathSegments; i++) { + var param = pathParams[i]; + var value = match[i + 1]; + for (var j = 0; j < param.replace; j++) { + if (param.replace[j].from === value) + value = param.replace[j].to; + } + if (value && param.array === true) + value = decodePathArray(value); + values[param.id] = param.value(value); + } + common_1.forEach(searchParams, function (param) { + values[param.id] = param.value(search[param.id]); + }); + if (hash) + values["#"] = hash; + return values; + }; + UrlMatcher.prototype.parameters = function (opts) { + if (opts === void 0) { opts = {}; } + if (opts.inherit === false) + return this._params; + return common_1.unnest(this._cache.path.concat(this).map(common_1.prop('_params'))); + }; + UrlMatcher.prototype.parameter = function (id, opts) { + if (opts === void 0) { opts = {}; } + var parent = common_1.tail(this._cache.path); + return (common_1.find(this._params, common_1.propEq('id', id)) || + (opts.inherit !== false && parent && parent.parameter(id)) || + null); + }; + UrlMatcher.prototype.validates = function (params) { + var _this = this; + var validParamVal = function (param, val) { return !param || param.validates(val); }; + return common_1.pairs(params || {}).map(function (_a) { + var key = _a[0], val = _a[1]; + return validParamVal(_this.parameter(key), val); + }).reduce(common_1.allTrueR, true); + }; + UrlMatcher.prototype.format = function (values) { + if (values === void 0) { values = {}; } + var segments = this._segments, result = segments[0], search = false, params = this.parameters({ inherit: false }), parent = common_1.tail(this._cache.path); + if (!this.validates(values)) + return null; + function encodeDashes(str) { + return encodeURIComponent(str).replace(/-/g, function (c) { return ("%5C%" + c.charCodeAt(0).toString(16).toUpperCase()); }); + } + params.map(function (param, i) { + var isPathParam = i < segments.length - 1; + var value = param.value(values[param.id]); + var isDefaultValue = param.isDefaultValue(value); + var squash = isDefaultValue ? param.squash : false; + var encoded = param.type.encode(value); + if (!isPathParam) { + if (encoded == null || (isDefaultValue && squash !== false)) + return; + if (!common_1.isArray(encoded)) + encoded = [encoded]; + encoded = common_1.map(encoded, encodeURIComponent).join("&" + param.id + "="); + result += (search ? '&' : '?') + (param.id + "=" + encoded); + search = true; + return; + } + result += (function (segment, result) { + if (squash === true) + return segment.match(result.match(/\/$/) ? /\/?(.*)/ : /(.*)/)[1]; + if (common_1.isString(squash)) + return squash + segment; + if (squash !== false) + return ""; + if (encoded == null) + return segment; + if (common_1.isArray(encoded)) + return common_1.map(encoded, encodeDashes).join("-") + segment; + if (param.type.raw) + return encoded + segment; + return encodeURIComponent(encoded) + segment; + })(segments[i + 1], result); + }); + if (values["#"]) + result += "#" + values["#"]; + var processedParams = ['#'].concat(params.map(common_1.prop('id'))); + return (parent && parent.format(common_1.omit(values, processedParams)) || '') + result; + }; + UrlMatcher.nameValidator = /^\w+(-+\w+)*(?:\[\])?$/; + return UrlMatcher; + })(); + exports.UrlMatcher = UrlMatcher; + //# sourceMappingURL=urlMatcher.js.map + +/***/ }, +/* 36 */ +/***/ function(module, exports, __webpack_require__) { + + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(__webpack_require__(24)); + __export(__webpack_require__(27)); + __export(__webpack_require__(37)); + __export(__webpack_require__(26)); + //# sourceMappingURL=module.js.map + +/***/ }, +/* 37 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var StateParams = (function () { + function StateParams(params) { + if (params === void 0) { params = {}; } + common_1.extend(this, params); + } + StateParams.prototype.$digest = function () { }; + StateParams.prototype.$inherit = function (newParams, $current, $to) { }; + StateParams.prototype.$set = function (params, url) { }; + StateParams.prototype.$sync = function () { }; + StateParams.prototype.$off = function () { }; + StateParams.prototype.$raw = function () { }; + StateParams.prototype.$localize = function (state, params) { }; + StateParams.prototype.$observe = function (key, fn) { }; + return StateParams; + })(); + exports.StateParams = StateParams; + $StateParamsProvider.$inject = []; + function $StateParamsProvider() { + function stateParamsFactory() { + var observers = {}, current = {}; + function unhook(key, func) { + return function () { + common_1.forEach(key.split(" "), function (k) { return observers[k].splice(observers[k].indexOf(func), 1); }); + }; + } + function observeChange(key, val) { + if (!observers[key] || !observers[key].length) + return; + common_1.forEach(observers[key], function (func) { return func(val); }); + } + StateParams.prototype.$digest = function () { + var _this = this; + common_1.forEach(this, function (val, key) { + if (val === current[key] || !_this.hasOwnProperty(key)) + return; + current[key] = val; + observeChange(key, val); + }); + }; + StateParams.prototype.$inherit = function (newParams, $current, $to) { + var parents = common_1.ancestors($current, $to), parentParams, inherited = {}, inheritList = []; + for (var i in parents) { + if (!parents[i].params) + continue; + parentParams = Object.keys(parents[i].params); + if (!parentParams.length) + continue; + for (var j in parentParams) { + if (inheritList.indexOf(parentParams[j]) >= 0) + continue; + inheritList.push(parentParams[j]); + inherited[parentParams[j]] = this[parentParams[j]]; + } + } + return common_1.extend({}, inherited, newParams); + }; + StateParams.prototype.$set = function (params, url) { + var _this = this; + var hasChanged = false, abort = false; + if (url) { + common_1.forEach(params, function (val, key) { + if ((url.parameter(key) || {}).dynamic !== true) + abort = true; + }); + } + if (abort) + return false; + common_1.forEach(params, function (val, key) { + if (val !== _this[key]) { + _this[key] = val; + observeChange(key); + hasChanged = true; + } + }); + this.$sync(); + return hasChanged; + }; + StateParams.prototype.$sync = function () { + common_1.copy(this, current); + return this; + }; + StateParams.prototype.$off = function () { + observers = {}; + return this; + }; + StateParams.prototype.$raw = function () { + return common_1.omit(this, Object.keys(this).filter(StateParams.prototype.hasOwnProperty.bind(StateParams.prototype))); + }; + StateParams.prototype.$localize = function (state, params) { + return new StateParams(common_1.pick(params || this, Object.keys(state.params))); + }; + StateParams.prototype.$observe = function (key, fn) { + common_1.forEach(key.split(" "), function (k) { return (observers[k] || (observers[k] = [])).push(fn); }); + return unhook(key, fn); + }; + return new StateParams(); + } + var global = stateParamsFactory(); + this.$get = $get; + $get.$inject = ['$rootScope']; + function $get($rootScope) { + $rootScope.$watch(function () { + global.$digest(); + }); + return global; + } + } + angular.module('ui.router.state') + .provider('$stateParams', $StateParamsProvider); + //# sourceMappingURL=stateParams.js.map + +/***/ }, +/* 38 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var coreservices_1 = __webpack_require__(4); + var $location = coreservices_1.services.location; + function $UrlRouterProvider($urlMatcherFactory) { + var rules = [], otherwise = null, interceptDeferred = false, listener; + function regExpPrefix(re) { + var prefix = /^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(re.source); + return (prefix != null) ? prefix[1].replace(/\\(.)/g, "$1") : ''; + } + function interpolate(pattern, match) { + return pattern.replace(/\$(\$|\d{1,2})/, function (m, what) { + return match[what === '$' ? 0 : Number(what)]; + }); + } + this.rule = function (rule) { + if (!common_1.isFunction(rule)) + throw new Error("'rule' must be a function"); + rules.push(rule); + return this; + }; + this.otherwise = function (rule) { + if (!common_1.isFunction(rule) && !common_1.isString(rule)) + throw new Error("'rule' must be a string or function"); + otherwise = common_1.isString(rule) ? function () { return rule; } : rule; + return this; + }; + function handleIfMatch($injector, handler, match) { + if (!match) + return false; + var result = $injector.invoke(handler, handler, { $match: match }); + return common_1.isDefined(result) ? result : true; + } + this.when = function (what, handler) { + var redirect, handlerIsString = common_1.isString(handler); + if (common_1.isString(what)) + what = $urlMatcherFactory.compile(what); + if (!handlerIsString && !common_1.isFunction(handler) && !common_1.isArray(handler)) + throw new Error("invalid 'handler' in when()"); + var strategies = { + matcher: function (what, handler) { + if (handlerIsString) { + redirect = $urlMatcherFactory.compile(handler); + handler = ['$match', redirect.format.bind(redirect)]; + } + return common_1.extend(function () { + return handleIfMatch(coreservices_1.services.$injector, handler, what.exec($location.path(), $location.search(), $location.hash())); + }, { + prefix: common_1.isString(what.prefix) ? what.prefix : '' + }); + }, + regex: function (what, handler) { + if (what.global || what.sticky) + throw new Error("when() RegExp must not be global or sticky"); + if (handlerIsString) { + redirect = handler; + handler = ['$match', function ($match) { return interpolate(redirect, $match); }]; + } + return common_1.extend(function () { + return handleIfMatch(coreservices_1.services.$injector, handler, what.exec($location.path())); + }, { + prefix: regExpPrefix(what) + }); + } + }; + var check = { + matcher: $urlMatcherFactory.isMatcher(what), + regex: what instanceof RegExp + }; + for (var n in check) { + if (check[n]) + return this.rule(strategies[n](what, handler)); + } + throw new Error("invalid 'what' in when()"); + }; + this.deferIntercept = function (defer) { + if (defer === undefined) + defer = true; + interceptDeferred = defer; + }; + this.$get = $get; + $get.$inject = ['$rootScope']; + function $get($rootScope) { + var location = $location.url(); + function appendBasePath(url, isHtml5, absolute) { + var baseHref = coreservices_1.services.locationConfig.baseHref(); + if (baseHref === '/') + return url; + if (isHtml5) + return baseHref.slice(0, -1) + url; + if (absolute) + return baseHref.slice(1) + url; + return url; + } + function update(evt) { + if (evt && evt.defaultPrevented) + return; + function check(rule) { + var handled = rule(coreservices_1.services.$injector, $location); + if (!handled) + return false; + if (common_1.isString(handled)) { + $location.replace(); + $location.url(handled); + } + return true; + } + var n = rules.length, i; + for (i = 0; i < n; i++) { + if (check(rules[i])) + return; + } + if (otherwise) + check(otherwise); + } + function listen() { + listener = listener || $rootScope.$on('$locationChangeSuccess', update); + return listener; + } + if (!interceptDeferred) + listen(); + return { + sync: function () { + update(); + }, + listen: function () { + return listen(); + }, + update: function (read) { + if (read) { + location = $location.url(); + return; + } + if ($location.url() === location) + return; + $location.url(location); + $location.replace(); + }, + push: function (urlMatcher, params, options) { + $location.url(urlMatcher.format(params || {})); + if (options && options.replace) + $location.replace(); + }, + href: function (urlMatcher, params, options) { + if (!urlMatcher.validates(params)) + return null; + var url = urlMatcher.format(params); + options = options || {}; + var cfg = coreservices_1.services.locationConfig; + var isHtml5 = cfg.html5Mode(); + if (!isHtml5 && url !== null) { + url = "#" + cfg.hashPrefix() + url; + } + url = appendBasePath(url, isHtml5, options.absolute); + if (!options.absolute || !url) { + return url; + } + var slash = (!isHtml5 && url ? '/' : ''), port = cfg.port(); + port = (port === 80 || port === 443 ? '' : ':' + port); + return [cfg.protocol(), '://', cfg.host(), port, slash, url].join(''); + } + }; + } + } + exports.$UrlRouterProvider = $UrlRouterProvider; + //# sourceMappingURL=urlRouter.js.map + +/***/ }, +/* 39 */ +/***/ function(module, exports) { + + var EnterExitHooks = (function () { + function EnterExitHooks(transition) { + this.transition = transition; + } + EnterExitHooks.prototype.registerHooks = function () { + this.registerOnEnterHooks(); + this.registerOnRetainHooks(); + this.registerOnExitHooks(); + }; + EnterExitHooks.prototype.registerOnEnterHooks = function () { + var _this = this; + var onEnterRegistration = function (state) { return _this.transition.onEnter({ to: state.name }, state.onEnter); }; + this.transition.entering().filter(function (state) { return !!state.onEnter; }).forEach(onEnterRegistration); + }; + EnterExitHooks.prototype.registerOnRetainHooks = function () { + var _this = this; + var onRetainRegistration = function (state) { return _this.transition.onRetain({}, state.onRetain); }; + this.transition.retained().filter(function (state) { return !!state.onRetain; }).forEach(onRetainRegistration); + }; + EnterExitHooks.prototype.registerOnExitHooks = function () { + var _this = this; + var onExitRegistration = function (state) { return _this.transition.onExit({ from: state.name }, state.onExit); }; + this.transition.exiting().filter(function (state) { return !!state.onExit; }).forEach(onExitRegistration); + }; + return EnterExitHooks; + })(); + exports.EnterExitHooks = EnterExitHooks; + //# sourceMappingURL=enterExitHooks.js.map + +/***/ }, +/* 40 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var interface_1 = __webpack_require__(19); + var LAZY = interface_1.ResolvePolicy[interface_1.ResolvePolicy.LAZY]; + var EAGER = interface_1.ResolvePolicy[interface_1.ResolvePolicy.EAGER]; + var ResolveHooks = (function () { + function ResolveHooks(transition) { + this.transition = transition; + } + ResolveHooks.prototype.registerHooks = function () { + var treeChanges = this.transition.treeChanges(); + $eagerResolvePath.$inject = ['$transition$']; + function $eagerResolvePath($transition$) { + return common_1.tail(treeChanges.to).resolveContext.resolvePath(common_1.extend({ transition: $transition$ }, { resolvePolicy: EAGER })); + } + $lazyResolveEnteringState.$inject = ['$state$', '$transition$']; + function $lazyResolveEnteringState($state$, $transition$) { + var node = common_1.find(treeChanges.entering, common_1.propEq('state', $state$)); + return node.resolveContext.resolvePathElement(node.state, common_1.extend({ transition: $transition$ }, { resolvePolicy: LAZY })); + } + this.transition.onStart({}, $eagerResolvePath, { priority: 1000 }); + this.transition.onEnter({}, $lazyResolveEnteringState, { priority: 1000 }); + }; + return ResolveHooks; + })(); + exports.ResolveHooks = ResolveHooks; + //# sourceMappingURL=resolveHooks.js.map + +/***/ }, +/* 41 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(36); + var parseUrl = function (url) { + if (!common_1.isString(url)) + return false; + var root = url.charAt(0) === '^'; + return { val: root ? url.substring(1) : url, root: root }; + }; + var StateBuilder = (function () { + function StateBuilder(root, matcher, $urlMatcherFactoryProvider) { + this.matcher = matcher; + var self = this; + this.builders = { + parent: [function (state) { + if (state === root()) + return null; + return matcher.find(self.parentName(state)) || root(); + }], + data: [function (state) { + if (state.parent && state.parent.data) { + state.data = state.self.data = common_1.extend({}, state.parent.data, state.data); + } + return state.data; + }], + url: [function (state) { + var stateDec = state; + var parsed = parseUrl(stateDec.url), parent = state.parent; + var url = !parsed ? stateDec.url : $urlMatcherFactoryProvider.compile(parsed.val, { + params: state.params || {}, + paramMap: function (paramConfig, isSearch) { + if (stateDec.reloadOnSearch === false && isSearch) + paramConfig = common_1.extend(paramConfig || {}, { dynamic: true }); + return paramConfig; + } + }); + if (!url) + return null; + if (!$urlMatcherFactoryProvider.isMatcher(url)) + throw new Error("Invalid url '" + url + "' in state '" + state + "'"); + return (parsed && parsed.root) ? url : ((parent && parent.navigable) || root()).url.append(url); + }], + navigable: [function (state) { + return (state !== root()) && state.url ? state : (state.parent ? state.parent.navigable : null); + }], + params: [function (state) { + var makeConfigParam = function (config, id) { return module_1.Param.fromConfig(id, null, config); }; + var urlParams = (state.url && state.url.parameters({ inherit: false })) || []; + var nonUrlParams = common_1.values(common_1.map(common_1.omit(state.params || {}, urlParams.map(common_1.prop('id'))), makeConfigParam)); + return urlParams.concat(nonUrlParams).map(function (p) { return [p.id, p]; }).reduce(common_1.applyPairs, {}); + }], + views: [function (state) { + var views = {}, tplKeys = ['templateProvider', 'templateUrl', 'template', 'notify', 'async'], ctrlKeys = ['controller', 'controllerProvider', 'controllerAs']; + var allKeys = tplKeys.concat(ctrlKeys); + common_1.forEach(state.views || { "$default": common_1.pick(state, allKeys) }, function (config, name) { + name = name || "$default"; + common_1.forEach(ctrlKeys, function (key) { + if (state[key] && !config[key]) + config[key] = state[key]; + }); + if (Object.keys(config).length > 0) + views[name] = config; + }); + return views; + }], + path: [function (state) { + return state.parent ? state.parent.path.concat(state) : [state]; + }], + includes: [function (state) { + var includes = state.parent ? common_1.extend({}, state.parent.includes) : {}; + includes[state.name] = true; + return includes; + }] + }; + } + StateBuilder.prototype.builder = function (name, fn) { + var builders = this.builders; + var array = builders[name] || []; + if (common_1.isString(name) && !common_1.isDefined(fn)) + return array.length > 1 ? array : array[0]; + if (!common_1.isString(name) || !common_1.isFunction(fn)) + return; + builders[name] = array; + builders[name].push(fn); + return function () { return builders[name].splice(builders[name].indexOf(fn, 1)) && null; }; + }; + StateBuilder.prototype.build = function (state) { + var _a = this, matcher = _a.matcher, builders = _a.builders; + var parent = this.parentName(state); + if (parent && !matcher.find(parent)) + return null; + for (var key in builders) { + if (!builders.hasOwnProperty(key)) + continue; + var chain = builders[key].reduce(function (parentFn, step) { return function (state) { return step(state, parentFn); }; }, common_1.noop); + state[key] = chain(state); + } + return state; + }; + StateBuilder.prototype.parentName = function (state) { + var name = state.name || ""; + if (name.indexOf('.') !== -1) + return name.substring(0, name.lastIndexOf('.')); + if (!state.parent) + return ""; + return common_1.isString(state.parent) ? state.parent : state.parent.name; + }; + StateBuilder.prototype.name = function (state) { + var name = state.name; + if (name.indexOf('.') !== -1 || !state.parent) + return name; + var parentName = common_1.isString(state.parent) ? state.parent : state.parent.name; + return parentName ? parentName + "." + name : name; + }; + return StateBuilder; + })(); + exports.StateBuilder = StateBuilder; + //# sourceMappingURL=stateBuilder.js.map + +/***/ }, +/* 42 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(9); + function parseStateRef(ref, current) { + var preparsed = ref.match(/^\s*({[^}]*})\s*$/), parsed; + if (preparsed) + ref = current + '(' + preparsed[1] + ')'; + parsed = ref.replace(/\n/g, " ").match(/^([^(]+?)\s*(\((.*)\))?$/); + if (!parsed || parsed.length !== 4) + throw new Error("Invalid state ref '" + ref + "'"); + return { state: parsed[1], paramExpr: parsed[3] || null }; + } + function stateContext(el) { + var stateData = el.parent().inheritedData('$uiView'); + if (stateData && stateData.context && stateData.context.name) { + return stateData.context; + } + } + $StateRefDirective.$inject = ['$state', '$timeout']; + function $StateRefDirective($state, $timeout) { + return { + restrict: 'A', + require: ['?^uiSrefActive', '?^uiSrefActiveEq'], + link: function (scope, element, attrs, uiSrefActive) { + var ref = parseStateRef(attrs.uiSref, $state.current.name); + var params = null, base = stateContext(element) || $state.$current; + var newHref = null, isAnchor = element.prop("tagName") === "A"; + var isForm = element[0].nodeName === "FORM"; + var attr = isForm ? "action" : "href", nav = true; + var srefOpts = scope.$eval(attrs.uiSrefOpts); + var defaultSrefOpts = { relative: base, inherit: true }; + var options = common_1.defaults(srefOpts, defaultSrefOpts, module_1.defaultTransOpts); + var update = function (newVal) { + if (newVal) + params = common_1.copy(newVal); + if (!nav) + return; + newHref = $state.href(ref.state, params, options); + var activeDirective = uiSrefActive[1] || uiSrefActive[0]; + if (activeDirective) { + activeDirective.$$addStateInfo(ref.state, params); + } + if (newHref === null) { + nav = false; + return false; + } + attrs.$set(attr, newHref); + }; + if (ref.paramExpr) { + scope.$watch(ref.paramExpr, function (newVal) { if (newVal !== params) + update(newVal); }, true); + params = common_1.copy(scope.$eval(ref.paramExpr)); + } + update(); + if (isForm) + return; + element.bind("click", function (e) { + var button = e.which || e.button; + if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || element.attr('target'))) { + var transition = $timeout(function () { + $state.go(ref.state, params, options); + }); + e.preventDefault(); + var ignorePreventDefaultCount = isAnchor && !newHref ? 1 : 0; + e.preventDefault = function () { + if (ignorePreventDefaultCount-- <= 0) + $timeout.cancel(transition); + }; + } + }); + } + }; + } + $StateRefActiveDirective.$inject = ['$state', '$stateParams', '$interpolate']; + function $StateRefActiveDirective($state, $stateParams, $interpolate) { + return { + restrict: "A", + controller: ['$scope', '$element', '$attrs', '$timeout', '$transitions', function ($scope, $element, $attrs, $timeout, $transitions) { + var states = [], activeClasses = {}, activeEqClass; + activeEqClass = $interpolate($attrs.uiSrefActiveEq || '', false)($scope); + var uiSrefActive = $scope.$eval($attrs.uiSrefActive) || $interpolate($attrs.uiSrefActive || '', false)($scope); + if (common_1.isObject(uiSrefActive)) { + common_1.forEach(uiSrefActive, function (stateOrName, activeClass) { + if (common_1.isString(stateOrName)) { + var ref = parseStateRef(stateOrName, $state.current.name); + addState(ref.state, $scope.$eval(ref.paramExpr), activeClass); + } + }); + } + this.$$addStateInfo = function (newState, newParams) { + if (common_1.isObject(uiSrefActive) && states.length > 0) { + return; + } + addState(newState, newParams, uiSrefActive); + update(); + }; + $scope.$on('$stateChangeSuccess', update); + function addState(stateName, stateParams, activeClass) { + var state = $state.get(stateName, stateContext($element)); + var stateHash = createStateHash(stateName, stateParams); + states.push({ + state: state || { name: stateName }, + params: stateParams, + hash: stateHash + }); + activeClasses[stateHash] = activeClass; + } + updateAfterTransition.$inject = ['$transition$']; + function updateAfterTransition($transition$) { $transition$.promise.then(update); } + ; + var deregisterFn = $transitions.onStart({}, updateAfterTransition); + $scope.$on('$destroy', deregisterFn); + function createStateHash(state, params) { + if (!common_1.isString(state)) { + throw new Error('state should be a string'); + } + if (common_1.isObject(params)) { + return state + common_1.toJson(params); + } + params = $scope.$eval(params); + if (common_1.isObject(params)) { + return state + common_1.toJson(params); + } + return state; + } + function update() { + for (var i = 0; i < states.length; i++) { + if (anyMatch(states[i].state, states[i].params)) { + addClass($element, activeClasses[states[i].hash]); + } + else { + removeClass($element, activeClasses[states[i].hash]); + } + if (exactMatch(states[i].state, states[i].params)) { + addClass($element, activeEqClass); + } + else { + removeClass($element, activeEqClass); + } + } + } + function addClass(el, className) { $timeout(function () { el.addClass(className); }); } + function removeClass(el, className) { el.removeClass(className); } + function anyMatch(state, params) { return $state.includes(state.name, params); } + function exactMatch(state, params) { return $state.is(state.name, params); } + }] + }; + } + angular.module('ui.router.state') + .directive('uiSref', $StateRefDirective) + .directive('uiSrefActive', $StateRefActiveDirective) + .directive('uiSrefActiveEq', $StateRefActiveDirective); + //# sourceMappingURL=stateDirectives.js.map + +/***/ }, +/* 43 */ +/***/ function(module, exports) { + + $IsStateFilter.$inject = ['$state']; + function $IsStateFilter($state) { + return function (state) { + return $state.is(state); + }; + } + exports.$IsStateFilter = $IsStateFilter; + $IncludedByStateFilter.$inject = ['$state']; + function $IncludedByStateFilter($state) { + return function (state, params, options) { + return $state.includes(state, params, options); + }; + } + exports.$IncludedByStateFilter = $IncludedByStateFilter; + angular.module('ui.router.state') + .filter('isState', $IsStateFilter) + .filter('includedByState', $IncludedByStateFilter); + //# sourceMappingURL=stateFilters.js.map + +/***/ }, +/* 44 */ +/***/ function(module, exports, __webpack_require__) { + + var module_1 = __webpack_require__(2); + var State = (function () { + function State(config) { + module_1.extend(this, config); + } + State.prototype.is = function (ref) { + return this === ref || this.self === ref || this.fqn() === ref; + }; + State.prototype.fqn = function () { + if (!this.parent || !(this.parent instanceof this.constructor)) + return this.name; + var name = this.parent.fqn(); + return name ? name + "." + this.name : this.name; + }; + State.prototype.root = function () { + return this.parent && this.parent.root() || this; + }; + State.prototype.parameters = function (opts) { + opts = module_1.defaults(opts, { inherit: true }); + var inherited = opts.inherit && this.parent && this.parent.parameters() || []; + return inherited.concat(module_1.values(this.params)); + }; + State.prototype.parameter = function (id, opts) { + if (opts === void 0) { opts = {}; } + return (this.url && this.url.parameter(id, opts) || + module_1.find(module_1.values(this.params), module_1.propEq('id', id)) || + opts.inherit && this.parent && this.parent.parameter(id)); + }; + State.prototype.toString = function () { + return this.fqn(); + }; + return State; + })(); + exports.State = State; + //# sourceMappingURL=stateObject.js.map + +/***/ }, +/* 45 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var StateMatcher = (function () { + function StateMatcher(_states) { + this._states = _states; + } + StateMatcher.prototype.isRelative = function (stateName) { + stateName = stateName || ""; + return stateName.indexOf(".") === 0 || stateName.indexOf("^") === 0; + }; + StateMatcher.prototype.find = function (stateOrName, base) { + if (!stateOrName && stateOrName !== "") + return undefined; + var isStr = common_1.isString(stateOrName); + var name = isStr ? stateOrName : stateOrName.name; + if (this.isRelative(name)) + name = this.resolvePath(name, base); + var state = this._states[name]; + if (state && (isStr || (!isStr && (state === stateOrName || state.self === stateOrName)))) { + return state; + } + return undefined; + }; + StateMatcher.prototype.resolvePath = function (name, base) { + if (!base) + throw new Error("No reference point given for path '" + name + "'"); + var baseState = this.find(base); + var splitName = name.split("."), i = 0, pathLength = splitName.length, current = baseState; + for (; i < pathLength; i++) { + if (splitName[i] === "" && i === 0) { + current = baseState; + continue; + } + if (splitName[i] === "^") { + if (!current.parent) + throw new Error("Path '" + name + "' not valid for state '" + baseState.name + "'"); + current = current.parent; + continue; + } + break; + } + var relName = splitName.slice(i).join("."); + return current.name + (current.name && relName ? "." : "") + relName; + }; + return StateMatcher; + })(); + exports.StateMatcher = StateMatcher; + //# sourceMappingURL=stateMatcher.js.map + +/***/ }, +/* 46 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var module_1 = __webpack_require__(12); + var StateQueueManager = (function () { + function StateQueueManager(states, builder, $urlRouterProvider, $state) { + this.states = states; + this.builder = builder; + this.$urlRouterProvider = $urlRouterProvider; + this.$state = $state; + this.autoFlush = false; + this.queue = []; + } + StateQueueManager.prototype.register = function (config, pre) { + var _a = this, states = _a.states, queue = _a.queue, $state = _a.$state; + var state = common_1.inherit(new module_1.State(), common_1.extend({}, config, { + self: config, + resolve: config.resolve || {}, + toString: function () { return config.name; } + })); + if (!common_1.isString(state.name)) + throw new Error("State must have a valid name"); + if (states.hasOwnProperty(state.name) || common_1.pluck(queue, 'name').indexOf(state.name) !== -1) + throw new Error("State '" + state.name + "' is already defined"); + queue[pre ? "unshift" : "push"](state); + if (this.autoFlush) { + this.flush($state); + } + return state; + }; + StateQueueManager.prototype.flush = function ($state) { + var _a = this, queue = _a.queue, states = _a.states, builder = _a.builder; + var result, state, orphans = [], orphanIdx, previousQueueLength = {}; + while (queue.length > 0) { + state = queue.shift(); + result = builder.build(state); + orphanIdx = orphans.indexOf(state); + if (result) { + if (states.hasOwnProperty(state.name)) + throw new Error("State '" + name + "' is already defined"); + states[state.name] = state; + this.attachRoute($state, state); + if (orphanIdx >= 0) + orphans.splice(orphanIdx, 1); + continue; + } + var prev = previousQueueLength[state.name]; + previousQueueLength[state.name] = queue.length; + if (orphanIdx >= 0 && prev === queue.length) { + throw new Error("Cannot register orphaned state '" + state.name + "'"); + } + else if (orphanIdx < 0) { + orphans.push(state); + } + queue.push(state); + } + return states; + }; + StateQueueManager.prototype.attachRoute = function ($state, state) { + var $urlRouterProvider = this.$urlRouterProvider; + if (state[common_1.abstractKey] || !state.url) + return; + $urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) { + if ($state.$current.navigable !== state || !common_1.equalForKeys($match, $stateParams)) { + $state.transitionTo(state, $match, { inherit: true, location: false }); + } + }]); + }; + return StateQueueManager; + })(); + exports.StateQueueManager = StateQueueManager; + //# sourceMappingURL=stateQueueManager.js.map + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var trace_1 = __webpack_require__(6); + var coreservices_1 = __webpack_require__(4); + var rejectFactory_1 = __webpack_require__(28); + var module_1 = __webpack_require__(12); + var REJECT = new rejectFactory_1.RejectFactory(); + var defaultOptions = { + async: true, + rejectIfSuperseded: true, + current: common_1.noop, + transition: null, + traceData: {} + }; + var TransitionHook = (function () { + function TransitionHook(fn, locals, resolveContext, options) { + var _this = this; + this.fn = fn; + this.locals = locals; + this.resolveContext = resolveContext; + this.options = options; + this.isSuperseded = function () { return _this.options.current() !== _this.options.transition; }; + this.mapHookResult = common_1.pattern([ + [this.isSuperseded, function () { return REJECT.superseded(_this.options.current()); }], + [common_1.eq(false), common_1.val(REJECT.aborted("Hook aborted transition"))], + [common_1.is(module_1.TargetState), function (target) { return REJECT.redirected(target); }], + [common_1.isPromise, function (promise) { return promise.then(_this.handleHookResult.bind(_this)); }] + ]); + this.invokeStep = function (moreLocals) { + var _a = _this, options = _a.options, fn = _a.fn, resolveContext = _a.resolveContext; + var locals = common_1.extend({}, _this.locals, moreLocals); + trace_1.trace.traceHookInvocation(_this, options); + if (options.rejectIfSuperseded && _this.isSuperseded()) { + return REJECT.superseded(options.current()); + } + if (!options.async) { + var hookResult = resolveContext.invokeNow(fn, locals, options); + return _this.handleHookResult(hookResult); + } + return resolveContext.invokeLater(fn, locals, options).then(_this.handleHookResult.bind(_this)); + }; + this.options = common_1.defaults(options, defaultOptions); + } + TransitionHook.prototype.handleHookResult = function (hookResult) { + if (!common_1.isDefined(hookResult)) + return undefined; + trace_1.trace.traceHookResult(hookResult, undefined, this.options); + var transitionResult = this.mapHookResult(hookResult); + if (transitionResult) + trace_1.trace.traceHookResult(hookResult, transitionResult, this.options); + return transitionResult; + }; + TransitionHook.prototype.toString = function () { + var _a = this, options = _a.options, fn = _a.fn; + var event = common_1.parse("traceData.hookType")(options) || "internal", context = common_1.parse("traceData.context.state.name")(options) || common_1.parse("traceData.context")(options) || "unknown", name = common_1.fnToString(fn); + return event + " context: " + context + ", " + common_1.maxLength(200, name); + }; + TransitionHook.runSynchronousHooks = function (hooks, locals, swallowExceptions) { + if (locals === void 0) { locals = {}; } + if (swallowExceptions === void 0) { swallowExceptions = false; } + var results = []; + for (var i = 0; i < hooks.length; i++) { + try { + results.push(hooks[i].invokeStep(locals)); + } + catch (exception) { + if (!swallowExceptions) + throw exception; + console.log("Swallowed exception during synchronous hook handler: " + exception); + } + } + var rejections = results.filter(TransitionHook.isRejection); + if (rejections.length) + return rejections[0]; + return results + .filter(common_1.not(TransitionHook.isRejection)) + .filter(common_1.isPromise) + .reduce(function (chain, promise) { return chain.then(common_1.val(promise)); }, coreservices_1.services.$q.when()); + }; + TransitionHook.isRejection = function (hookResult) { + return hookResult && hookResult.reason instanceof rejectFactory_1.TransitionRejection && hookResult; + }; + return TransitionHook; + })(); + exports.TransitionHook = TransitionHook; + //# sourceMappingURL=transitionHook.js.map + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + var transition_1 = __webpack_require__(8); + var hookRegistry_1 = __webpack_require__(11); + exports.defaultTransOpts = { + location: true, + relative: null, + inherit: false, + notify: true, + reload: false, + custom: {}, + current: function () { return null; } + }; + var TransitionService = (function () { + function TransitionService() { + this._defaultErrorHandler = function $defaultErrorHandler($error$) { + if ($error$ instanceof Error) + console.log($error$); + }; + this._reinit(); + } + TransitionService.prototype.defaultErrorHandler = function (handler) { + return this._defaultErrorHandler = handler || this._defaultErrorHandler; + }; + TransitionService.prototype._reinit = function () { + hookRegistry_1.HookRegistry.mixin(new hookRegistry_1.HookRegistry(), this); + }; + TransitionService.prototype.create = function (fromPath, targetState) { + return new transition_1.Transition(fromPath, targetState); + }; + return TransitionService; + })(); + exports.$transitions = new TransitionService(); + $TransitionProvider.prototype = exports.$transitions; + function $TransitionProvider() { + this._reinit.bind(exports.$transitions)(); + this.$get = function $get() { + return exports.$transitions; + }; + } + exports.$transitionsProvider = $TransitionProvider; + angular.module('ui.router.state') + .provider('$transitions', exports.$transitionsProvider); + //# sourceMappingURL=transitionService.js.map + +/***/ }, +/* 49 */ +/***/ function(module, exports, __webpack_require__) { + + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + __export(__webpack_require__(50)); + __export(__webpack_require__(21)); + __export(__webpack_require__(51)); + __export(__webpack_require__(52)); + //# sourceMappingURL=module.js.map + +/***/ }, +/* 50 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + $TemplateFactory.$inject = ['$http', '$templateCache']; + function $TemplateFactory($http, $templateCache) { + this.fromConfig = function (config, params, injectFn) { + return (common_1.isDefined(config.template) ? this.fromString(config.template, params) : + common_1.isDefined(config.templateUrl) ? this.fromUrl(config.templateUrl, params) : + common_1.isDefined(config.templateProvider) ? this.fromProvider(config.templateProvider, params, injectFn) : + null); + }; + this.fromString = function (template, params) { + return common_1.isFunction(template) ? template(params) : template; + }; + this.fromUrl = function (url, params) { + if (common_1.isFunction(url)) + url = url(params); + if (url == null) + return null; + return $http.get(url, { cache: $templateCache, headers: { Accept: 'text/html' } }).then(common_1.prop("data")); + }; + this.fromProvider = function (provider, params, injectFn) { + return injectFn(provider); + }; + } + angular.module('ui.router.util').service('$templateFactory', $TemplateFactory); + //# sourceMappingURL=templateFactory.js.map + +/***/ }, +/* 51 */ +/***/ function(module, exports, __webpack_require__) { + + var common_1 = __webpack_require__(3); + var trace_1 = __webpack_require__(6); + $ViewDirective.$inject = ['$view', '$animate', '$uiViewScroll', '$interpolate', '$q']; + function $ViewDirective($view, $animate, $uiViewScroll, $interpolate, $q) { + function getRenderer(attrs, scope) { + return { + enter: function (element, target, cb) { + if (angular.version.minor > 2) { + $animate.enter(element, null, target).then(cb); + } + else { + $animate.enter(element, null, target, cb); + } + }, + leave: function (element, cb) { + if (angular.version.minor > 2) { + $animate.leave(element).then(cb); + } + else { + $animate.leave(element, cb); + } + } + }; + } + function configsEqual(config1, config2) { + return config1 === config2; + } + var rootData = { + context: $view.rootContext() + }; + var directive = { + count: 0, + restrict: 'ECA', + terminal: true, + priority: 400, + transclude: 'element', + compile: function (tElement, tAttrs, $transclude) { + return function (scope, $element, attrs) { + var previousEl, currentEl, currentScope, unregister, onloadExp = attrs.onload || '', autoScrollExp = attrs.autoscroll, renderer = getRenderer(attrs, scope), viewConfig = undefined, inherited = $element.inheritedData('$uiView') || rootData, name = $interpolate(attrs.uiView || attrs.name || '')(scope) || '$default'; + var viewData = { + id: directive.count++, + name: name, + fqn: inherited.name ? inherited.fqn + "." + name : name, + config: null, + configUpdated: configUpdatedCallback, + get creationContext() { return inherited.context; } + }; + trace_1.trace.traceUiViewEvent("Linking", viewData); + function configUpdatedCallback(config) { + if (configsEqual(viewConfig, config)) + return; + trace_1.trace.traceUiViewConfigUpdated(viewData, config && config.context); + viewConfig = config; + updateView(config); + } + $element.data('$uiView', viewData); + updateView(); + unregister = $view.registerUiView(viewData); + scope.$on("$destroy", function () { + trace_1.trace.traceUiViewEvent("Destroying/Unregistering", viewData); + unregister(); + }); + function cleanupLastView() { + if (previousEl) { + trace_1.trace.traceUiViewEvent("Removing (previous) el", viewData); + previousEl.remove(); + previousEl = null; + } + if (currentScope) { + trace_1.trace.traceUiViewEvent("Destroying (previous) scope", viewData); + currentScope.$destroy(); + currentScope = null; + } + if (currentEl) { + trace_1.trace.traceUiViewEvent("Animate out (previous)", viewData); + renderer.leave(currentEl, function () { + previousEl = null; + }); + previousEl = currentEl; + currentEl = null; + } + } + function updateView(config) { + config = config || {}; + var newScope = scope.$new(); + trace_1.trace.traceUiViewScopeCreated(viewData, newScope); + common_1.extend(viewData, { + context: config.context, + $template: config.template, + $controller: config.controller, + $controllerAs: config.controllerAs, + $locals: config.locals + }); + var cloned = $transclude(newScope, function (clone) { + renderer.enter(clone.data('$uiView', viewData), $element, function onUiViewEnter() { + if (currentScope) { + currentScope.$emit('$viewContentAnimationEnded'); + } + if (common_1.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) { + $uiViewScroll(clone); + } + }); + cleanupLastView(); + }); + currentEl = cloned; + currentScope = newScope; + currentScope.$emit('$viewContentLoaded', config || viewConfig); + currentScope.$eval(onloadExp); + } + }; + } + }; + return directive; + } + $ViewDirectiveFill.$inject = ['$compile', '$controller', '$interpolate', '$injector', '$q']; + function $ViewDirectiveFill($compile, $controller, $interpolate, $injector, $q) { + return { + restrict: 'ECA', + priority: -400, + compile: function (tElement) { + var initial = tElement.html(); + return function (scope, $element) { + var data = $element.data('$uiView'); + if (!data) + return; + $element.html(data.$template || initial); + trace_1.trace.traceUiViewFill(data, $element.html()); + var link = $compile($element.contents()); + var controller = data.$controller; + var controllerAs = data.$controllerAs; + if (controller) { + var locals = data.$locals; + var controllerInstance = $controller(controller, common_1.extend(locals, { $scope: scope })); + if (controllerAs) + scope[controllerAs] = controllerInstance; + $element.data('$ngControllerController', controllerInstance); + $element.children().data('$ngControllerController', controllerInstance); + } + link(scope); + }; + } + }; + } + angular.module('ui.router.state').directive('uiView', $ViewDirective); + angular.module('ui.router.state').directive('uiView', $ViewDirectiveFill); + //# sourceMappingURL=viewDirective.js.map + +/***/ }, +/* 52 */ +/***/ function(module, exports) { + + function $ViewScrollProvider() { + var useAnchorScroll = false; + this.useAnchorScroll = function () { + useAnchorScroll = true; + }; + this.$get = ['$anchorScroll', '$timeout', function ($anchorScroll, $timeout) { + if (useAnchorScroll) { + return $anchorScroll; + } + return function ($element) { + return $timeout(function () { + $element[0].scrollIntoView(); + }, 0, false); + }; + }]; + } + angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider); + //# sourceMappingURL=viewScroll.js.map + +/***/ } +/******/ ]) +}); +; \ No newline at end of file diff --git a/release/angular-ui-router.min.js b/release/angular-ui-router.min.js index 129b3000a..8f76c7ede 100644 --- a/release/angular-ui-router.min.js +++ b/release/angular-ui-router.min.js @@ -1,7 +1,9 @@ /** * State-based routing for AngularJS - * @version v0.2.11 + * @version v1.0.0alpha0 * @link http://angular-ui.github.com/ * @license MIT License, http://www.opensource.org/licenses/MIT */ -"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(a,b,c){"use strict";function d(a,b){return J(new(J(function(){},{prototype:a})),b)}function e(a){return I(arguments,function(b){b!==a&&I(b,function(b,c){a.hasOwnProperty(c)||(a[c]=b)})}),a}function f(a,b){var c=[];for(var d in a.path){if(a.path[d]!==b.path[d])break;c.push(a.path[d])}return c}function g(a){if(Object.keys)return Object.keys(a);var c=[];return b.forEach(a,function(a,b){c.push(b)}),c}function h(a,b){if(Array.prototype.indexOf)return a.indexOf(b,Number(arguments[2])||0);var c=a.length>>>0,d=Number(arguments[2])||0;for(d=0>d?Math.ceil(d):Math.floor(d),0>d&&(d+=c);c>d;d++)if(d in a&&a[d]===b)return d;return-1}function i(a,b,c,d){var e,i=f(c,d),j={},k=[];for(var l in i)if(i[l].params&&(e=g(i[l].params),e.length))for(var m in e)h(k,e[m])>=0||(k.push(e[m]),j[e[m]]=a[e[m]]);return J({},j,b)}function j(a,b,c){if(!c){c=[];for(var d in a)c.push(d)}for(var e=0;e "));if(o[c]=d,F(a))m.push(c,[function(){return b.get(a)}],h);else{var e=b.annotate(a);I(e,function(a){a!==c&&g.hasOwnProperty(a)&&k(g[a],a)}),m.push(c,a,e)}n.pop(),o[c]=f}}function l(a){return G(a)&&a.then&&a.$$promises}if(!G(g))throw new Error("'invocables' must be an object");var m=[],n=[],o={};return I(g,k),g=n=o=null,function(d,f,g){function h(){--s||(t||e(r,f.$$values),p.$$values=r,p.$$promises=!0,delete p.$$inheritedValues,o.resolve(r))}function k(a){p.$$failure=a,o.reject(a)}function n(c,e,f){function i(a){l.reject(a),k(a)}function j(){if(!D(p.$$failure))try{l.resolve(b.invoke(e,g,r)),l.promise.then(function(a){r[c]=a,h()},i)}catch(a){i(a)}}var l=a.defer(),m=0;I(f,function(a){q.hasOwnProperty(a)&&!d.hasOwnProperty(a)&&(m++,q[a].then(function(b){r[a]=b,--m||j()},i))}),m||j(),q[c]=l.promise}if(l(d)&&g===c&&(g=f,f=d,d=null),d){if(!G(d))throw new Error("'locals' must be an object")}else d=i;if(f){if(!l(f))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else f=j;var o=a.defer(),p=o.promise,q=p.$$promises={},r=J({},d),s=1+m.length/3,t=!1;if(D(f.$$failure))return k(f.$$failure),p;f.$$inheritedValues&&e(r,f.$$inheritedValues),f.$$values?(t=e(r,f.$$values),p.$$inheritedValues=f.$$values,h()):(f.$$inheritedValues&&(p.$$inheritedValues=f.$$inheritedValues),J(q,f.$$promises),f.then(h,k));for(var u=0,v=m.length;v>u;u+=3)d.hasOwnProperty(m[u])?h():n(m[u],m[u+1],m[u+2]);return p}},this.resolve=function(a,b,c,d){return this.study(a)(b,c,d)}}function m(a,b,c){this.fromConfig=function(a,b,c){return D(a.template)?this.fromString(a.template,b):D(a.templateUrl)?this.fromUrl(a.templateUrl,b):D(a.templateProvider)?this.fromProvider(a.templateProvider,b,c):null},this.fromString=function(a,b){return E(a)?a(b):a},this.fromUrl=function(c,d){return E(c)&&(c=c(d)),null==c?null:a.get(c,{cache:b}).then(function(a){return a.data})},this.fromProvider=function(a,b,d){return c.invoke(a,null,d||{params:b})}}function n(a,d){function e(a){return D(a)?this.type.decode(a):p.$$getDefaultValue(this)}function f(b,c,d){if(!/^\w+(-+\w+)*$/.test(b))throw new Error("Invalid parameter name '"+b+"' in pattern '"+a+"'");if(n[b])throw new Error("Duplicate parameter name '"+b+"' in pattern '"+a+"'");n[b]=J({type:c||new o,$value:e},d)}function g(a,b,c){var d=a.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!b)return d;var e=c?"?":"";return d+e+"("+b+")"+e}function h(a){if(!d.params||!d.params[a])return{};var b=d.params[a];return G(b)?b:{value:b}}d=b.isObject(d)?d:{};var i,j=/([:*])(\w+)|\{(\w+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,k="^",l=0,m=this.segments=[],n=this.params={};this.source=a;for(var q,r,s,t,u;(i=j.exec(a))&&(q=i[2]||i[3],r=i[4]||("*"==i[1]?".*":"[^/]*"),s=a.substring(l,i.index),t=this.$types[r]||new o({pattern:new RegExp(r)}),u=h(q),!(s.indexOf("?")>=0));)k+=g(s,t.$subPattern(),D(u.value)),f(q,t,u),m.push(s),l=j.lastIndex;s=a.substring(l);var v=s.indexOf("?");if(v>=0){var w=this.sourceSearch=s.substring(v);s=s.substring(0,v),this.sourcePath=a.substring(0,l+v),I(w.substring(1).split(/[&?]/),function(a){f(a,null,h(a))})}else this.sourcePath=a,this.sourceSearch="";k+=g(s)+(d.strict===!1?"/?":"")+"$",m.push(s),this.regexp=new RegExp(k,d.caseInsensitive?"i":c),this.prefix=m[0]}function o(a){J(this,a)}function p(){function a(){return{strict:f,caseInsensitive:e}}function b(a){return E(a)||H(a)&&E(a[a.length-1])}function c(){I(h,function(a){if(n.prototype.$types[a.name])throw new Error("A type named '"+a.name+"' has already been defined.");var c=new o(b(a.def)?d.invoke(a.def):a.def);n.prototype.$types[a.name]=c})}var d,e=!1,f=!0,g=!0,h=[],i={"int":{decode:function(a){return parseInt(a,10)},is:function(a){return D(a)?this.decode(a.toString())===a:!1},pattern:/\d+/},bool:{encode:function(a){return a?1:0},decode:function(a){return 0===parseInt(a,10)?!1:!0},is:function(a){return a===!0||a===!1},pattern:/0|1/},string:{pattern:/[^\/]*/},date:{equals:function(a,b){return a.toISOString()===b.toISOString()},decode:function(a){return new Date(a)},encode:function(a){return[a.getFullYear(),("0"+(a.getMonth()+1)).slice(-2),("0"+a.getDate()).slice(-2)].join("-")},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/}};p.$$getDefaultValue=function(a){if(!b(a.value))return a.value;if(!d)throw new Error("Injectable functions cannot be called at configuration time");return d.invoke(a.value)},this.caseInsensitive=function(a){e=a},this.strictMode=function(a){f=a},this.compile=function(b,c){return new n(b,J(a(),c))},this.isMatcher=function(a){if(!G(a))return!1;var b=!0;return I(n.prototype,function(c,d){E(c)&&(b=b&&D(a[d])&&E(a[d]))}),b},this.type=function(a,b){return D(b)?(h.push({name:a,def:b}),g||c(),this):n.prototype.$types[a]},this.$get=["$injector",function(a){return d=a,g=!1,n.prototype.$types={},c(),I(i,function(a,b){n.prototype.$types[b]||(n.prototype.$types[b]=new o(a))}),this}]}function q(a,b){function d(a){var b=/^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(a.source);return null!=b?b[1].replace(/\\(.)/g,"$1"):""}function e(a,b){return a.replace(/\$(\$|\d{1,2})/,function(a,c){return b["$"===c?0:Number(c)]})}function f(a,b,c){if(!c)return!1;var d=a.invoke(b,b,{$match:c});return D(d)?d:!0}function g(b,c,d,e){function f(a,b,c){return"/"===m?a:b?m.slice(0,-1)+a:c?m.slice(1)+a:a}function g(a){function c(a){var c=a(d,b);return c?(F(c)&&b.replace().url(c),!0):!1}if(!a||!a.defaultPrevented){var e,f=i.length;for(e=0;f>e;e++)if(c(i[e]))return;j&&c(j)}}function l(){return h=h||c.$on("$locationChangeSuccess",g)}var m=e.baseHref(),n=b.url();return k||l(),{sync:function(){g()},listen:function(){return l()},update:function(a){return a?void(n=b.url()):void(b.url()!==n&&(b.url(n),b.replace()))},push:function(a,c,d){b.url(a.format(c||{})),d&&d.replace&&b.replace()},href:function(c,d,e){if(!c.validates(d))return null;var g=a.html5Mode(),h=c.format(d);if(e=e||{},g||null===h||(h="#"+a.hashPrefix()+h),h=f(h,g,e.absolute),!e.absolute||!h)return h;var i=!g&&h?"/":"",j=b.port();return j=80===j||443===j?"":":"+j,[b.protocol(),"://",b.host(),j,i,h].join("")}}}var h,i=[],j=null,k=!1;this.rule=function(a){if(!E(a))throw new Error("'rule' must be a function");return i.push(a),this},this.otherwise=function(a){if(F(a)){var b=a;a=function(){return b}}else if(!E(a))throw new Error("'rule' must be a function");return j=a,this},this.when=function(a,c){var g,h=F(c);if(F(a)&&(a=b.compile(a)),!h&&!E(c)&&!H(c))throw new Error("invalid 'handler' in when()");var i={matcher:function(a,c){return h&&(g=b.compile(c),c=["$match",function(a){return g.format(a)}]),J(function(b,d){return f(b,c,a.exec(d.path(),d.search()))},{prefix:F(a.prefix)?a.prefix:""})},regex:function(a,b){if(a.global||a.sticky)throw new Error("when() RegExp must not be global or sticky");return h&&(g=b,b=["$match",function(a){return e(g,a)}]),J(function(c,d){return f(c,b,a.exec(d.path()))},{prefix:d(a)})}},j={matcher:b.isMatcher(a),regex:a instanceof RegExp};for(var k in j)if(j[k])return this.rule(i[k](a,c));throw new Error("invalid 'what' in when()")},this.deferIntercept=function(a){a===c&&(a=!0),k=a},this.$get=g,g.$inject=["$location","$rootScope","$injector","$browser"]}function r(a,e){function f(a){return 0===a.indexOf(".")||0===a.indexOf("^")}function h(a,b){if(!a)return c;var d=F(a),e=d?a:a.name,g=f(e);if(g){if(!b)throw new Error("No reference point given for path '"+e+"'");for(var h=e.split("."),i=0,j=h.length,k=b;j>i;i++)if(""!==h[i]||0!==i){if("^"!==h[i])break;if(!k.parent)throw new Error("Path '"+e+"' not valid for state '"+b.name+"'");k=k.parent}else k=b;h=h.slice(i).join("."),e=k.name+(k.name&&h?".":"")+h}var l=v[e];return!l||!d&&(d||l!==a&&l.self!==a)?c:l}function l(a,b){w[a]||(w[a]=[]),w[a].push(b)}function m(b){b=d(b,{self:b,resolve:b.resolve||{},toString:function(){return this.name}});var c=b.name;if(!F(c)||c.indexOf("@")>=0)throw new Error("State must have a valid name");if(v.hasOwnProperty(c))throw new Error("State '"+c+"'' is already defined");var e=-1!==c.indexOf(".")?c.substring(0,c.lastIndexOf(".")):F(b.parent)?b.parent:"";if(e&&!v[e])return l(e,b.self);for(var f in y)E(y[f])&&(b[f]=y[f](b,y.$delegates[f]));if(v[c]=b,!b[x]&&b.url&&a.when(b.url,["$match","$stateParams",function(a,c){u.$current.navigable==b&&j(a,c)||u.transitionTo(b,a,{location:!1})}]),w[c])for(var g=0;g-1}function o(a){var b=a.split("."),c=u.$current.name.split(".");if("**"===b[0]&&(c=c.slice(c.indexOf(b[1])),c.unshift("**")),"**"===b[b.length-1]&&(c.splice(c.indexOf(b[b.length-2])+1,Number.MAX_VALUE),c.push("**")),b.length!=c.length)return!1;for(var d=0,e=b.length;e>d;d++)"*"===b[d]&&(c[d]="*");return c.join("")===b.join("")}function p(a,b){return F(a)&&!D(b)?y[a]:E(b)&&F(a)?(y[a]&&!y.$delegates[a]&&(y.$delegates[a]=y[a]),y[a]=b,this):this}function q(a,b){return G(a)?b=a:b.name=a,m(b),this}function r(a,e,f,l,m,p,q){function r(b,c,d,f){var g=a.$broadcast("$stateNotFound",b,c,d);if(g.defaultPrevented)return q.update(),A;if(!g.retry)return null;if(f.$retry)return q.update(),B;var h=u.transition=e.when(g.retry);return h.then(function(){return h!==u.transition?y:(b.options.$retry=!0,u.transitionTo(b.to,b.toParams,b.options))},function(){return A}),q.update(),h}function w(a,c,d,h,i){var j=d?c:k(g(a.params),c),n={$stateParams:j};i.resolve=m.resolve(a.resolve,n,i.resolve,a);var o=[i.resolve.then(function(a){i.globals=a})];return h&&o.push(h),I(a.views,function(c,d){var e=c.resolve&&c.resolve!==a.resolve?c.resolve:{};e.$template=[function(){return f.load(d,{view:c,locals:n,params:j})||""}],o.push(m.resolve(e,n,i.resolve,a).then(function(f){if(E(c.controllerProvider)||H(c.controllerProvider)){var g=b.extend({},e,n);f.$$controller=l.invoke(c.controllerProvider,null,g)}else f.$$controller=c.controller;f.$$state=a,f.$$controllerAs=c.controllerAs,i[d]=f}))}),e.all(o).then(function(){return i})}var y=e.reject(new Error("transition superseded")),z=e.reject(new Error("transition prevented")),A=e.reject(new Error("transition aborted")),B=e.reject(new Error("transition failed"));return t.locals={resolve:null,globals:{$stateParams:{}}},u={params:{},current:t.self,$current:t,transition:null},u.reload=function(){u.transitionTo(u.current,p,{reload:!0,inherit:!1,notify:!1})},u.go=function(a,b,c){return u.transitionTo(a,b,J({inherit:!0,relative:u.$current},c))},u.transitionTo=function(b,c,f){c=c||{},f=J({location:!0,inherit:!1,relative:null,notify:!0,reload:!1,$retry:!1},f||{});var m,n=u.$current,o=u.params,v=n.path,A=h(b,f.relative);if(!D(A)){var B={to:b,toParams:c,options:f},C=r(B,n.self,o,f);if(C)return C;if(b=B.to,c=B.toParams,f=B.options,A=h(b,f.relative),!D(A)){if(!f.relative)throw new Error("No such state '"+b+"'");throw new Error("Could not resolve '"+b+"' from state '"+f.relative+"'")}}if(A[x])throw new Error("Cannot transition to abstract state '"+b+"'");f.inherit&&(c=i(p,c||{},u.$current,A)),b=A;var E=b.path,F=0,G=E[F],H=t.locals,I=[];if(!f.reload)for(;G&&G===v[F]&&j(c,o,G.ownParams);)H=I[F]=G.locals,F++,G=E[F];if(s(b,n,H,f))return b.self.reloadOnSearch!==!1&&q.update(),u.transition=null,e.when(u.current);if(c=k(g(b.params),c||{}),f.notify&&a.$broadcast("$stateChangeStart",b.self,c,n.self,o).defaultPrevented)return q.update(),z;for(var L=e.when(H),M=F;M=F;d--)g=v[d],g.self.onExit&&l.invoke(g.self.onExit,g.self,g.locals.globals),g.locals=null;for(d=F;d=0?c:c+"@"+(b?b.state.name:"")}function x(a,b){var c,d=a.match(/^\s*({[^}]*})\s*$/);if(d&&(a=b+"("+d[1]+")"),c=a.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/),!c||4!==c.length)throw new Error("Invalid state ref '"+a+"'");return{state:c[1],paramExpr:c[3]||null}}function y(a){var b=a.parent().inheritedData("$uiView");return b&&b.state&&b.state.name?b.state:void 0}function z(a,c){var d=["location","inherit","reload"];return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(e,f,g,h){var i=x(g.uiSref,a.current.name),j=null,k=y(f)||a.$current,l="FORM"===f[0].nodeName,m=l?"action":"href",n=!0,o={relative:k,inherit:!0},p=e.$eval(g.uiSrefOpts)||{};b.forEach(d,function(a){a in p&&(o[a]=p[a])});var q=function(b){if(b&&(j=b),n){var c=a.href(i.state,j,o),d=h[1]||h[0];return d&&d.$$setStateInfo(i.state,j),null===c?(n=!1,!1):void(f[0][m]=c)}};i.paramExpr&&(e.$watch(i.paramExpr,function(a){a!==j&&q(a)},!0),j=e.$eval(i.paramExpr)),q(),l||f.bind("click",function(b){var d=b.which||b.button;if(!(d>1||b.ctrlKey||b.metaKey||b.shiftKey||f.attr("target"))){var e=c(function(){a.go(i.state,j,o)});b.preventDefault(),b.preventDefault=function(){c.cancel(e)}}})}}}function A(a,b,c){return{restrict:"A",controller:["$scope","$element","$attrs",function(d,e,f){function g(){h()?e.addClass(m):e.removeClass(m)}function h(){return"undefined"!=typeof f.uiSrefActiveEq?a.$current.self===k&&i():a.includes(k.name)&&i()}function i(){return!l||j(l,b)}var k,l,m;m=c(f.uiSrefActiveEq||f.uiSrefActive||"",!1)(d),this.$$setStateInfo=function(b,c){k=a.get(b,y(e)),l=c,g()},d.$on("$stateChangeSuccess",g)}]}}function B(a){return function(b){return a.is(b)}}function C(a){return function(b){return a.includes(b)}}var D=b.isDefined,E=b.isFunction,F=b.isString,G=b.isObject,H=b.isArray,I=b.forEach,J=b.extend,K=b.copy;b.module("ui.router.util",["ng"]),b.module("ui.router.router",["ui.router.util"]),b.module("ui.router.state",["ui.router.router","ui.router.util"]),b.module("ui.router",["ui.router.state"]),b.module("ui.router.compat",["ui.router"]),l.$inject=["$q","$injector"],b.module("ui.router.util").service("$resolve",l),m.$inject=["$http","$templateCache","$injector"],b.module("ui.router.util").service("$templateFactory",m),n.prototype.concat=function(a,b){return new n(this.sourcePath+a+this.sourceSearch,b)},n.prototype.toString=function(){return this.source},n.prototype.exec=function(a,b){var c=this.regexp.exec(a);if(!c)return null;b=b||{};var d,e,f,g=this.parameters(),h=g.length,i=this.segments.length-1,j={};if(i!==c.length-1)throw new Error("Unbalanced capture group in route '"+this.source+"'");for(d=0;i>d;d++)f=g[d],e=this.params[f],j[f]=e.$value(c[d+1]);for(;h>d;d++)f=g[d],e=this.params[f],j[f]=e.$value(b[f]);return j},n.prototype.parameters=function(a){return D(a)?this.params[a]||null:g(this.params)},n.prototype.validates=function(a){var b,c,d=!0,e=this;return I(a,function(a,f){e.params[f]&&(c=e.params[f],b=!a&&D(c.value),d=d&&(b||c.type.is(a)))}),d},n.prototype.format=function(a){var b=this.segments,c=this.parameters();if(!a)return b.join("").replace("//","/");var d,e,f,g,h,i,j=b.length-1,k=c.length,l=b[0];if(!this.validates(a))return null;for(d=0;j>d;d++)g=c[d],f=a[g],h=this.params[g],(D(f)||"/"!==b[d]&&"/"!==b[d+1])&&(null!=f&&(l+=encodeURIComponent(h.type.encode(f))),l+=b[d+1]);for(;k>d;d++)g=c[d],f=a[g],null!=f&&(i=H(f),i&&(f=f.map(encodeURIComponent).join("&"+g+"=")),l+=(e?"&":"?")+g+"="+(i?f:encodeURIComponent(f)),e=!0);return l},n.prototype.$types={},o.prototype.is=function(){return!0},o.prototype.encode=function(a){return a},o.prototype.decode=function(a){return a},o.prototype.equals=function(a,b){return a==b},o.prototype.$subPattern=function(){var a=this.pattern.toString();return a.substr(1,a.length-2)},o.prototype.pattern=/.*/,b.module("ui.router.util").provider("$urlMatcherFactory",p),q.$inject=["$locationProvider","$urlMatcherFactoryProvider"],b.module("ui.router.router").provider("$urlRouter",q),r.$inject=["$urlRouterProvider","$urlMatcherFactoryProvider"],b.module("ui.router.state").value("$stateParams",{}).provider("$state",r),s.$inject=[],b.module("ui.router.state").provider("$view",s),b.module("ui.router.state").provider("$uiViewScroll",t),u.$inject=["$state","$injector","$uiViewScroll"],v.$inject=["$compile","$controller","$state"],b.module("ui.router.state").directive("uiView",u),b.module("ui.router.state").directive("uiView",v),z.$inject=["$state","$timeout"],A.$inject=["$state","$stateParams","$interpolate"],b.module("ui.router.state").directive("uiSref",z).directive("uiSrefActive",A).directive("uiSrefActiveEq",A),B.$inject=["$state"],C.$inject=["$state"],b.module("ui.router.state").filter("isState",B).filter("includedByState",C)}(window,window.angular); +!function(a,b){"object"==typeof exports&&"object"==typeof module?module.exports=b():"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?exports["ui.router"]=b():a["ui.router"]=b()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){a.exports=c(1)},function(a,b,c){var d=c(2);b.common=d;var e=c(36);b.params=e;var f=c(15);b.path=f;var g=c(17);b.resolve=g;var h=c(12);b.state=h;var i=c(9);b.transition=i;var j=c(34);b.url=j;var k=c(49);b.view=k,Object.defineProperty(b,"__esModule",{value:!0}),b["default"]="ui.router"},function(a,b,c){function d(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}d(c(3)),d(c(4)),d(c(5)),d(c(6))},function(a,b){function c(a){function b(c){return c.length>=d?a.apply(null,c):function(){return b(c.concat([].slice.apply(arguments)))}}var c=[].slice.apply(arguments,[1]),d=a.length;return b(c)}function d(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}}function e(){for(var a=[],b=0;b=0&&a.splice(c,1),a}},b.defaults=j,b.merge=k,b.mergeR=function(a,b){return J(a,b)},b.ancestors=l,b.equalForKeys=m,b.pick=o,b.omit=p,b.pluck=q,b.filter=r,b.find=s,b.map=t,b.values=function(a){return Object.keys(a).map(function(b){return a[b]})},b.allTrueR=function(a,b){return a&&b},b.anyTrueR=function(a,b){return a||b},b.pushR=function(a,b){return a.push(b),a},b.unnestR=function(a,b){return a.concat(b)},b.flattenR=function(a,c){return H(c)?a.concat(c.reduce(b.flattenR,[])):b.pushR(a,c)},b.unnest=function(a){return a.reduce(b.unnestR,[])},b.flatten=function(a){return a.reduce(b.flattenR,[])},b.assertPredicate=u,b.pairs=function(a){return Object.keys(a).map(function(b){return[b,a[b]]})},b.arrayTuples=v,b.applyPairs=w,b.isInjectable=x,b.isNull=function(a){return null===a},b.isPromise=f(G,e(b.prop("then"),D)),b.fnToString=y,b.maxLength=z,b.padString=A,b.tail=B,angular.module("ui.router.util",["ng","ui.router.init"]),angular.module("ui.router.router",["ui.router.util"]),angular.module("ui.router.state",["ui.router.router","ui.router.util","ui.router.angular1"]),angular.module("ui.router",["ui.router.init","ui.router.state","ui.router.angular1"]),angular.module("ui.router.compat",["ui.router"])},function(a,b){var c=function(a){return function(){throw new Error(a+"(): No coreservices implementation for UI-Router is loaded. You should include one of: ['angular1.js']")}},d={$q:void 0,$injector:void 0,location:{},locationConfig:{}};b.services=d,["replace","url","path","search","hash"].forEach(function(a){return d.location[a]=c(a)}),["port","protocol","host","baseHref","html5Mode","hashPrefix"].forEach(function(a){return d.locationConfig[a]=c(a)})},function(a,b){var c=function(){function a(a){void 0===a&&(a=[]),this._items=a}return a.prototype.enqueue=function(a){return this._items.push(a),a},a.prototype.dequeue=function(){return this.size()?this._items.splice(0,1)[0]:void 0},a.prototype.clear=function(){var a=this._items;return this._items=[],a},a.prototype.size=function(){return this._items.length},a.prototype.remove=function(a){var b=this._items.indexOf(a);return b>-1&&this._items.splice(b,1)[0]},a.prototype.peekTail=function(){return this._items[this._items.length-1]},a.prototype.peekHead=function(){return this.size()?this._items[0]:void 0},a}();b.Queue=c},function(a,b,c){function d(a){return j.is(m.TransitionRejection)(a.reason)?a.reason.toString():"Promise("+JSON.stringify(a)+")"}function e(a){var b=j.fnToString(a),c=b.match(/^(function [^ ]+\([^)]*\))/);return c?c[1]:b}function f(a){return j.isNumber(a)?i[a]:i[i[a]]}function g(a){var b=j.pattern([[j.not(j.isDefined),j.val("undefined")],[j.isNull,j.val("null")],[j.isPromise,d],[j.is(l.Transition),j.invoke("toString")],[j.is(k.Resolvable),j.invoke("toString")],[j.isInjectable,e],[j.val(!0),j.identity]]);return JSON.stringify(a,function(a,c){return b(c)}).replace(/\\"/g,'"')}function h(a){a.$watch(function(){q.approximateDigests++})}var i,j=c(3),k=c(7),l=c(8),m=c(28),n=function(a){return"ui-view id#"+a.id+", contextual name '"+a.name+"@"+a.creationContext+"', fqn: '"+a.fqn+"'"},o=function(a){return"ViewConfig targeting ui-view: '"+a.uiViewName+"@"+a.uiViewContextAnchor+"', context: '"+a.context.name+"'"};!function(a){a[a.RESOLVE=0]="RESOLVE",a[a.TRANSITION=1]="TRANSITION",a[a.HOOK=2]="HOOK",a[a.INVOKE=3]="INVOKE",a[a.UIVIEW=4]="UIVIEW",a[a.VIEWCONFIG=5]="VIEWCONFIG"}(i||(i={}));var p=function(){function a(){var a=this;this._enabled={},this.enable=function(){for(var b=[],c=0;c "+d)}},a.prototype.traceTransitionIgnored=function(a){if(this.enabled(i.TRANSITION)){var b=a.$id,c=this.approximateDigests,d=g(a);console.log("Transition #"+b+" Digest #"+c+": Ignored <> "+d)}},a.prototype.traceHookInvocation=function(a,b){if(this.enabled(i.HOOK)){var c=j.parse("transition.$id")(b),d=this.approximateDigests,f=j.parse("traceData.hookType")(b)||"internal",g=j.parse("traceData.context.state.name")(b)||j.parse("traceData.context")(b)||"unknown",h=e(a.fn);console.log("Transition #"+c+" Digest #"+d+": Hook -> "+f+" context: "+g+", "+j.maxLength(200,h))}},a.prototype.traceHookResult=function(a,b,c){if(this.enabled(i.HOOK)){var d=j.parse("transition.$id")(c),e=this.approximateDigests,f=g(a),h=g(b);console.log("Transition #"+d+" Digest #"+e+": <- Hook returned: "+j.maxLength(200,f)+", transition result: "+j.maxLength(200,h))}},a.prototype.traceResolvePath=function(a,b){if(this.enabled(i.RESOLVE)){var c=j.parse("transition.$id")(b),d=this.approximateDigests,e=a&&a.toString(),f=b&&b.resolvePolicy;console.log("Transition #"+c+" Digest #"+d+": Resolving "+e+" ("+f+")")}},a.prototype.traceResolvePathElement=function(a,b,c){if(this.enabled(i.RESOLVE)&&b.length){var d=j.parse("transition.$id")(c),e=this.approximateDigests,f=Object.keys(b).join(", "),g=a&&a.toString(),h=c&&c.resolvePolicy;console.log("Transition #"+d+" Digest #"+e+": Resolve "+g+" resolvables: ["+f+"] ("+h+")")}},a.prototype.traceResolveResolvable=function(a,b){if(this.enabled(i.RESOLVE)){var c=j.parse("transition.$id")(b),d=this.approximateDigests,e=a&&a.toString();console.log("Transition #"+c+" Digest #"+d+": Resolving -> "+e)}},a.prototype.traceResolvableResolved=function(a,b){if(this.enabled(i.RESOLVE)){var c=j.parse("transition.$id")(b),d=this.approximateDigests,e=a&&a.toString(),f=g(a.data);console.log("Transition #"+c+" Digest #"+d+": <- Resolved "+e+" to: "+j.maxLength(200,f))}},a.prototype.tracePathElementInvoke=function(a,b,c,d){if(this.enabled(i.INVOKE)){var f=j.parse("transition.$id")(d),g=this.approximateDigests,h=a&&a.state&&a.state.toString(),k=e(b);console.log("Transition #"+f+" Digest #"+g+": Invoke "+d.when+": context: "+h+" "+j.maxLength(200,k))}},a.prototype.traceError=function(a,b){if(this.enabled(i.TRANSITION)){var c=b.$id,d=this.approximateDigests,e=g(b);console.log("Transition #"+c+" Digest #"+d+": <- Rejected "+e+", reason: "+a)}},a.prototype.traceSuccess=function(a,b){if(this.enabled(i.TRANSITION)){var c=b.$id,d=this.approximateDigests,e=a.name,f=g(b);console.log("Transition #"+c+" Digest #"+d+": <- Success "+f+", final state: "+e)}},a.prototype.traceUiViewEvent=function(a,b,c){void 0===c&&(c=""),this.enabled(i.UIVIEW)&&console.log("ui-view: "+j.padString(30,a)+" "+n(b)+c)},a.prototype.traceUiViewConfigUpdated=function(a,b){this.enabled(i.UIVIEW)&&this.traceUiViewEvent("Updating",a," with ViewConfig from context='"+b+"'")},a.prototype.traceUiViewScopeCreated=function(a,b){this.enabled(i.UIVIEW)&&this.traceUiViewEvent("Created scope for",a,", scope #"+b.$id)},a.prototype.traceUiViewFill=function(a,b){this.enabled(i.UIVIEW)&&this.traceUiViewEvent("Fill",a," with: "+j.maxLength(200,b))},a.prototype.traceViewServiceEvent=function(a,b){this.enabled(i.VIEWCONFIG)&&console.log("$view.ViewConfig: "+a+" "+o(b))},a.prototype.traceViewServiceUiViewEvent=function(a,b){this.enabled(i.VIEWCONFIG)&&console.log("$view.ViewConfig: "+a+" "+n(b))},a}(),q=new p;b.trace=q,h.$inject=["$rootScope"],angular.module("ui.router").run(h),angular.module("ui.router").service("$trace",function(){return q})},function(a,b,c){var d=c(3),e=c(4),f=c(6),g=function(){function a(a,b,c){this.promise=void 0,d.extend(this,{name:a,resolveFn:b,deps:e.services.$injector.annotate(b),data:c})}return a.prototype.resolveResolvable=function(a,b){var c=this;void 0===b&&(b={});var g=this,h=g.name,i=g.deps,j=g.resolveFn;f.trace.traceResolveResolvable(this,b);var k=e.services.$q.defer();this.promise=k.promise;var l=a.getResolvables(null,{omitOwnLocals:[h]}),m=d.pick(l,i),n=d.map(m,function(c){return c.get(a,b)});return e.services.$q.all(n).then(function(a){try{var b=e.services.$injector.invoke(j,null,a);k.resolve(b)}catch(d){k.reject(d)}return c.promise}).then(function(a){return c.data=a,f.trace.traceResolvableResolved(c,b),c.promise})},a.prototype.get=function(a,b){return this.promise||this.resolveResolvable(a,b)},a.prototype.toString=function(){return"Resolvable(name: "+this.name+", requires: ["+this.deps+"])"},a.makeResolvables=function(b){var c=d.filter(b,d.not(d.isFunction)),e=Object.keys(c);if(e.length)throw new Error("Invalid resolve key/value: "+e[0]+"/"+c[e[0]]);return d.map(b,function(b,c){return new a(c,b)})},a}();b.Resolvable=g},function(a,b,c){var d=c(6),e=c(4),f=c(3),g=c(9),h=c(15),i=c(12),j=c(36),k=c(17),l=0,m=new g.RejectFactory,n=f.prop("self"),o=function(){function a(a,b){var c=this;if(this._deferred=e.services.$q.defer(),this.promise=this._deferred.promise,this.treeChanges=function(){return c._treeChanges},this.isActive=function(){return c===c._options.current()},!b.valid())throw new Error(b.error());g.HookRegistry.mixin(new g.HookRegistry,this),this._options=f.extend({current:f.val(this)},b.options()),this.$id=l++;var d=h.PathFactory.buildToPath(a,b);this._treeChanges=h.PathFactory.treeChanges(a,d,this._options.reloadState),h.PathFactory.bindTransitionResolve(this._treeChanges,this)}return a.prototype.$from=function(){return f.tail(this._treeChanges.from).state},a.prototype.$to=function(){return f.tail(this._treeChanges.to).state},a.prototype.from=function(){return this.$from().self},a.prototype.to=function(){return this.$to().self},a.prototype.is=function(b){return b instanceof a?this.is({to:b.$to().name,from:b.$from().name}):!(b.to&&!g.matchState(this.$to(),b.to)||b.from&&!g.matchState(this.$from(),b.from))},a.prototype.params=function(a){return void 0===a&&(a="to"),this._treeChanges[a].map(f.prop("values")).reduce(f.mergeR,{})},a.prototype.resolves=function(){return f.map(f.tail(this._treeChanges.to).resolveContext.getResolvables(),function(a){return a.data})},a.prototype.addResolves=function(a,b){void 0===b&&(b="");var c="string"==typeof b?b:b.name,d=this._treeChanges.to,e=f.find(d,function(a){return a.state.name===c});f.tail(d).resolveContext.addResolvables(k.Resolvable.makeResolvables(a),e.state)},a.prototype.previous=function(){return this._options.previous||null},a.prototype.options=function(){return this._options},a.prototype.entering=function(){return f.map(this._treeChanges.entering,f.prop("state")).map(n)},a.prototype.exiting=function(){return f.map(this._treeChanges.exiting,f.prop("state")).map(n).reverse()},a.prototype.retained=function(){return f.map(this._treeChanges.retained,f.prop("state")).map(n)},a.prototype.views=function(a,b){void 0===a&&(a="entering");var c=this._treeChanges[a];return b?f.find(c,f.propEq("state",b)).views:f.unnest(c.map(f.prop("views")))},a.prototype.redirect=function(b){var c=f.extend({},this.options(),b.options(),{previous:this});b=new i.TargetState(b.identifier(),b.$state(),b.params(),c);var d=new a(this._treeChanges.from,b),e=this.treeChanges().to,g=h.Node.matching(d.treeChanges().to,e),j=function(a,b){return-1===["$stateParams","$transition$"].indexOf(b)};return g.forEach(function(a,b){return f.extend(a.resolves,f.filter(e[b].resolves,j))}),d},a.prototype.ignored=function(){var a=this._treeChanges,b=a.to,c=a.from;if(this._options.reload||f.tail(b).state!==f.tail(c).state)return!1;var d=b.map(function(a){return a.schema.filter(f.not(f.prop("dynamic")))}),e=[b,c].map(function(a){return a.map(f.prop("values"))}),g=e[0],h=e[1],i=f.arrayTuples(d,g,h);return i.map(function(a){var b=a[0],c=a[1],d=a[2];return j.Param.equals(b,c,d)}).reduce(f.allTrueR,!0)},a.prototype.hookBuilder=function(){return new g.HookBuilder(g.$transitions,this,{transition:this,current:this._options.current})},a.prototype.run=function(){var a=this,b=this.hookBuilder(),c=g.TransitionHook.runSynchronousHooks,f=function(){return c(b.getOnSuccessHooks(),{},!0)},h=function(a){return c(b.getOnErrorHooks(),{$error$:a},!0)};this.promise.then(f,h);var i=c(b.getOnBeforeHooks());if(g.TransitionHook.isRejection(i)){var j=i.reason;return this._deferred.reject(j),this.promise}if(!this.valid()){var k=new Error(this.error());return this._deferred.reject(k),this.promise}if(this.ignored()){d.trace.traceTransitionIgnored(this);var l=m.ignored();return this._deferred.reject(l.reason),this.promise}var n=function(){a._deferred.resolve(a),d.trace.traceSuccess(a.$to(),a)},o=function(b){return a._deferred.reject(b),d.trace.traceError(b,a),e.services.$q.reject(b)};d.trace.traceTransitionStart(this);var p=b.asyncHooks().reduce(function(a,b){return a.then(b.invokeStep)},i);return p.then(n,o),this.promise},a.prototype.valid=function(){return!this.error()},a.prototype.error=function(){var a=this.$to();return a.self[f.abstractKey]?"Cannot transition to abstract state '"+a.name+"'":j.Param.validates(a.parameters(),this.params())?void 0:"Param values not valid for state '"+a.name+"'"},a.prototype.toString=function(){var a=this.from(),b=this.to(),c=function(a){return null!==a["#"]&&void 0!==a["#"]?a:f.omit(a,"#")},d=this.$id,e=f.isObject(a)?a.name:a,g=f.toJson(c(this._treeChanges.from.map(f.prop("values")).reduce(f.mergeR,{}))),h=this.valid()?"":"(X) ",i=f.isObject(b)?b.name:b,j=f.toJson(c(this.params()));return"Transition#"+d+"( '"+e+"'"+g+" -> "+h+"'"+i+"'"+j+" )"},a}();b.Transition=o},function(a,b,c){function d(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}d(c(10)),d(c(11)),d(c(28)),d(c(8)),d(c(47)),d(c(48))},function(a,b,c){var d=c(3),e=c(9),f=function(){function a(a,b,c){var e=this;this.$transitions=a,this.transition=b,this.baseHookOptions=c,this.getOnBeforeHooks=function(){return e._buildTransitionHooks("onBefore",{},{async:!1})},this.getOnStartHooks=function(){return e._buildTransitionHooks("onStart")},this.getOnExitHooks=function(){return e._buildNodeHooks("onExit",e.treeChanges.exiting.reverse(),function(a){return e._toFrom({from:a.state})})},this.getOnRetainHooks=function(){return e._buildNodeHooks("onRetain",e.treeChanges.retained,function(a){return e._toFrom()})},this.getOnEnterHooks=function(){return e._buildNodeHooks("onEnter",e.treeChanges.entering,function(a){return e._toFrom({to:a.state})})},this.getOnFinishHooks=function(){return e._buildTransitionHooks("onFinish",{$treeChanges$:e.treeChanges})},this.getOnSuccessHooks=function(){return e._buildTransitionHooks("onSuccess",{},{async:!1,rejectIfSuperseded:!1})},this.getOnErrorHooks=function(){return e._buildTransitionHooks("onError",{},{async:!1,rejectIfSuperseded:!1})},this.treeChanges=b.treeChanges(),this.toState=d.tail(this.treeChanges.to).state,this.fromState=d.tail(this.treeChanges.from).state,this.transitionOptions=b.options()}return a.prototype.asyncHooks=function(){var a=this.getOnStartHooks(),b=this.getOnExitHooks(),c=this.getOnRetainHooks(),e=this.getOnEnterHooks(),f=this.getOnFinishHooks();return d.flatten([a,b,c,e,f]).filter(d.identity)},a.prototype._toFrom=function(a){return d.extend({to:this.toState,from:this.fromState},a)},a.prototype._buildTransitionHooks=function(a,b,c){var e=this;void 0===b&&(b={}),void 0===c&&(c={});var f=this.treeChanges.to,g=d.tail(f);c.traceData={hookType:a,context:f};var h=function(a){return e.buildHook(g,a.callback,b,c)};return this._matchingHooks(a,this._toFrom()).map(h)},a.prototype._buildNodeHooks=function(a,b,c,d,e){var f=this;void 0===d&&(d={}),void 0===e&&(e={});var g=function(b){var g=c(b);e.traceData={hookType:a,context:b},d.$state$=b.state;var h=function(a){return f.buildHook(b,a.callback,d,e)};return f._matchingHooks(a,g).map(h)};return b.map(g)},a.prototype.buildHook=function(a,b,c,f){void 0===f&&(f={});var g=d.extend({},this.baseHookOptions,f);return new e.TransitionHook(b,d.extend({},c),a.resolveContext,g)},a.prototype._matchingHooks=function(a,b){var c=function(a){return a.matches(b.to,b.from)},e=function(a,b){return b.priority-a.priority};return[this.transition,this.$transitions].map(function(b){return b.getHooks(a)}).filter(d.assertPredicate(d.isArray,"broken event named: "+a)).reduce(d.unnestR).filter(c).sort(e)},a}();b.HookBuilder=f},function(a,b,c){function d(a,b){function c(a){for(var b=0;bc;c++)"*"===this.glob[c]&&(b[c]="*");return"**"===this.glob[0]&&(b=b.slice(b.indexOf(this.glob[1])),b.unshift("**")),"**"===this.glob[this.glob.length-1]&&(b.splice(b.indexOf(this.glob[this.glob.length-2])+1,Number.MAX_VALUE),b.push("**")),this.glob.length!=b.length?!1:b.join("")===this.glob.join("")},a.is=function(a){return a.indexOf("*")>-1},a.fromString=function(b){return this.is(b)?new a(b):null},a}();b.Glob=c},function(a,b,c){function d(a,b){function c(a,b){return r.builder(a,b)||this}function d(a,b){return e.isObject(a)?b=a:b.name=a,s.register(b),this}function l(a){w.push(a)}function m(a,b,c,d,l,m){function r(c,d){function e(a){if(a instanceof g.TargetState){var b=a;return b=p.target(b.identifier(),b.params(),b.options()),b.valid()?j()!==k?v.superseded():p.transitionTo(b.identifier(),b.params(),b.options()):v.invalid(b.error())}}function h(){var a=m.dequeue();return void 0===a?v.invalid(d.error()):n(a).then(e).then(function(a){return a||h()})}var j=function(){return t.peekTail()||u.peekTail()},k=j(),l=i.PathFactory.makeTargetState(c),m=new f.Queue([].concat(w)),n=function(c){return a.when(b.invoke(c,null,{$to$:d,$from$:l}))};return h()}var x=m,y={name:"",url:"^",views:null,params:{"#":{value:null,type:"hash"}},"abstract":!0};n=s.register(y,!0),n.navigable=null;var z=function(){return i.PathFactory.bindTransNodesToPath([new i.Node(n,{})])};return c.rootContext(n),e.extend(p,{params:new k.StateParams,current:n.self,$current:n,transition:null}),s.flush(p),s.autoFlush=!0,p.reload=function(a){return p.transitionTo(p.current,d,{reload:e.isDefined(a)?a:!0,inherit:!1,notify:!1})},p.go=function(a,b,c){var d={relative:p.$current,inherit:!0},f=e.defaults(c,d,h.defaultTransOpts);return p.transitionTo(a,b,f)},p.target=function(a,b,c){void 0===c&&(c={});var d=q.find(a,c.relative);return new g.TargetState(a,d,b,c)},p.transitionTo=function(b,f,g){if(void 0===f&&(f={}),void 0===g&&(g={}),g=e.defaults(g,h.defaultTransOpts),g=e.extend(g,{current:t.peekTail.bind(t)}),e.isObject(g.reload)&&!g.reload.name)throw new Error("Invalid reload state object");if(g.reloadState=g.reload===!0?p.$current.path[0]:q.find(g.reload,g.relative),g.reload&&!g.reloadState)throw new Error("No such reload state '"+(e.isString(g.reload)?g.reload:g.reload.name)+"'");var i=p.target(b,f,g),k=u.peekTail(),m=k?k.to:z();if(!i.exists())return r(m,i);if(!i.valid())return a.reject(i.error());var n=x.create(m,i),o=new j.TransitionManager(n,x,l,c,p,d,a,t,u),s=o.runTransition();return e.extend(s,{transition:n})},p.is=function(a,b,c){c=e.defaults(c,{relative:p.$current});var f=q.find(a,c.relative);return e.isDefined(f)?p.$current!==f?!1:e.isDefined(b)&&null!==b?k.Param.equals(f.parameters(),d,b):!0:void 0},p.includes=function(a,b,c){c=e.defaults(c,{relative:p.$current});var f=e.isString(a)&&g.Glob.fromString(a);if(f){if(!f.matches(p.$current.name))return!1;a=p.$current.name}var h=q.find(a,c.relative),i=p.$current.includes;return e.isDefined(h)?e.isDefined(i[h.name])?b?e.equalForKeys(k.Param.values(h.parameters(),b),d,Object.keys(b)):!0:!1:void 0},p.href=function(a,b,c){var f={lossy:!0,inherit:!0,absolute:!1,relative:p.$current};c=e.defaults(c,f);var g=q.find(a,c.relative);if(!e.isDefined(g))return null;c.inherit&&(b=d.$inherit(b||{},p.$current,g));var h=g&&c.lossy?g.navigable:g;return h&&void 0!==h.url&&null!==h.url?l.href(h.url,k.Param.values(g.parameters(),b),{absolute:c.absolute}):null},p.get=function(a,b){if(0===arguments.length)return Object.keys(o).map(function(a){return o[a].self});var c=q.find(a,b||p.$current);return c&&c.self||null},p}var n,o={},p=function(){},q=new g.StateMatcher(o),r=new g.StateBuilder(function(){return n},q,b),s=new g.StateQueueManager(o,r,a,p),t=new f.Queue,u=new f.Queue,v=new h.RejectFactory;this.decorator=c,this.state=d;var w=[];this.onInvalid=l,this.$get=m,m.$inject=["$q","$injector","$view","$stateParams","$urlRouter","$transitions"]}var e=c(3),f=c(5),g=c(12),h=c(9),i=c(15),j=c(23),k=c(36);b.$StateProvider=d},function(a,b,c){function d(a){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}d(c(16)),d(c(22))},function(a,b,c){var d=c(3),e=c(17),f=c(21),g=function(){function a(a,b,c){void 0===c&&(c={}),this.state=a,this.schema=a.parameters({inherit:!1});var g=function(a){return[a.id,a.value(b[a.id])]};this.values=this.schema.reduce(function(a,b){return d.applyPairs(a,g(b))},{}),this.resolves=d.extend(d.map(a.resolve,function(a,b){return new e.Resolvable(b,a)}),c);var h=function(c,d){return new f.ViewConfig({rawViewName:d,viewDeclarationObj:c,context:a,params:b})};this.views=d.values(d.map(a.views,h))}return a.prototype.parameter=function(a){return d.find(this.schema,d.propEq("id",a))},a.prototype.equals=function(a,b){var c=this;void 0===b&&(b=this.schema.map(d.prop("id")));var e=function(b){return c.parameter(b).type.equals(c.values[b],a.values[b])};return this.state===a.state&&b.map(e).reduce(d.allTrueR,!0)},a.clone=function(b,c){return void 0===c&&(c={}),new a(b.state,c.values||b.values,c.resolves||b.resolves)},a.matching=function(a,b){var c=a.reduce(function(a,c,d){return a===d&&d=k},n=e.filter(l,m),o=function(d){return d.get(c.isolateRootTo(a),b)},p=e.map(n,o);return f.trace.traceResolvePathElement(this,n,b),g.services.$q.all(p).then(e.noop)},a.prototype.invokeLater=function(a,b,c){var d=this;void 0===b&&(b={}),void 0===c&&(c={});var h=this.getResolvablesForFn(a);f.trace.tracePathElementInvoke(e.tail(this._path),a,Object.keys(h),e.extend({when:"Later"},c));var i=function(a){return a.get(d,c)},j=e.map(h,i);return g.services.$q.all(j).then(function(){try{return d.invokeNow(a,b,c)}catch(e){return g.services.$q.reject(e)}})},a.prototype.invokeNow=function(a,b,c){void 0===c&&(c={});var d=this.getResolvablesForFn(a);f.trace.tracePathElementInvoke(e.tail(this._path),a,Object.keys(d),e.extend({when:"Now "},c));var h=e.map(d,e.prop("data"));return g.services.$injector.invoke(a,null,e.extend({},b,h))},a}();b.ResolveContext=j},function(a,b){!function(a){a[a.JIT=0]="JIT",a[a.LAZY=1]="LAZY",a[a.EAGER=2]="EAGER"}(b.ResolvePolicy||(b.ResolvePolicy={}));b.ResolvePolicy},function(a,b,c){var d=c(3),e=function(){function a(a,b){this._resolveContext=a,this._state=b}return a.prototype.invokeLater=function(a,b){return this._resolveContext.invokeLater(a,b)},a.prototype.invokeNow=function(a,b){return this._resolveContext.invokeNow(null,a,b)},a.prototype.getLocals=function(a){var b=this,c=function(a){return a.get(b._resolveContext)};return d.map(this._resolveContext.getResolvablesForFn(a),c)},a}();b.ResolveInjector=e},function(a,b,c){"use strict";function d(a){void 0===a&&(a="");var b=a.split("@"),c=b[0]||"$default",d=f.isString(b[1])?b[1]:"^",e=/^(\^(?:\.\^)*)\.(.*$)/.exec(c);return e&&(d=e[1],c=e[2]),"!"===c.charAt(0)&&(c=c.substr(1),d=""),{uiViewName:c,uiViewContextAnchor:d}}function e(a,b,c,d){var e=[],h=[],i=function(a){for(var b=[],c=1;c Registering",a),h.push(a)},this.sync=function(){function a(a){return a.fqn.split(".").length}function b(a){for(var b=a.context,c=0;++c&&b.parent;)b=b.parent;return c}var c=e.map(function(a){return[a.fqn,a]}).reduce(f.applyPairs,{}),d=f.curry(function(a,b){var d=b.uiViewName.split("."),e=a.fqn.split(".");if(!angular.equals(d,e.slice(0-d.length)))return!1;var f=1-d.length||void 0,g=e.slice(0,f).join("."),h=c[g].creationContext;return b.uiViewContextAnchor===(h&&h.name)}),g=f.curry(function(a,b,c,d){return b*(a(c)-a(d))}),i=function(a){var c=h.filter(d(a));return c.length>1&&c.sort(g(b,-1)),[a,c[0]]},j=function(a){var b=a[0],c=a[1];-1!==e.indexOf(b)&&b.configUpdated(c)};e.sort(g(a,1)).map(i).forEach(j)},this.registerUiView=function(a){g.trace.traceViewServiceUiViewEvent("-> Registering",a);var b=function(b){return b.fqn===a.fqn};return e.filter(b).length&&g.trace.traceViewServiceUiViewEvent("!!!! duplicate uiView named:",a),e.push(a),this.sync(),function(){var b=e.indexOf(a);return 0>=b?void g.trace.traceViewServiceUiViewEvent("Tried removing non-registered uiView",a):(g.trace.traceViewServiceUiViewEvent("<- Deregistering",a),void f.removeFrom(e)(a))}},this.available=function(){return e.map(f.prop("fqn"))},this.active=function(){return e.filter(f.prop("$config")).map(f.prop("name"))}}var f=c(3),g=c(2),h=function(){function a(a){var b=d(a.rawViewName),c=b.uiViewName,e=b.uiViewContextAnchor,g=/^(\^(?:\.\^)*)$/;if(g.exec(e)){var h=e.split(".").reduce(function(a,b){return a.parent},a.context);e=h.name}f.extend(this,f.pick(a,"viewDeclarationObj","params","context","locals"),{uiViewName:c,uiViewContextAnchor:e}),this.controllerAs=a.viewDeclarationObj.controllerAs}return a.prototype.hasTemplate=function(){var a=this.viewDeclarationObj;return!!(a.template||a.templateUrl||a.templateProvider)},a.prototype.getTemplate=function(a,b){return a.fromConfig(this.viewDeclarationObj,this.params,b.invokeLater.bind(b))},a.prototype.getController=function(a){var b=this.viewDeclarationObj.controllerProvider;return f.isInjectable(b)?a.invokeLater(b,{}):this.viewDeclarationObj.controller},a}();b.ViewConfig=h,e.$inject=["$rootScope","$templateFactory","$q","$timeout"],angular.module("ui.router.state").service("$view",e)},function(a,b,c){var d=c(3),e=c(12),f=c(15),g=c(17),h=function(){function a(){}return a.makeTargetState=function(a){var b=d.tail(a).state;return new e.TargetState(b,b,a.map(d.prop("values")).reduce(d.mergeR,{}))},a.buildToPath=function(b,c){var d=c.params(),e=a.makeParamsNode(d),f=c.$state().path.map(e);return c.options().inherit&&(f=a.inheritParams(b,f,Object.keys(d))),f},a.inheritParams=function(a,b,c){function e(a,b){var c=d.find(a,d.propEq("state",b));return d.extend({},c&&c.values)}void 0===c&&(c=[]);var g=d.curry(function(a,b,c){var g=d.extend({},c&&c.values),h=d.pick(g,b);g=d.omit(g,b);var i=e(a,c.state)||{},j=d.extend(g,i,h);return new f.Node(c.state,j)});return b.map(g(a,c))},a.bindTransNodesToPath=function(a){var b=new g.ResolveContext(a);return a.forEach(function(a){a.resolveContext=b.isolateRootTo(a.state),a.resolveInjector=new g.ResolveInjector(a.resolveContext,a.state),a.resolves.$stateParams=new g.Resolvable("$stateParams",function(){return a.values},a.values)}),a},a.treeChanges=function(b,c,e){function g(a,b){return f.Node.clone(a,{values:c[b].values})}for(var h=0,i=Math.min(b.length,c.length),j=function(a){return a.parameters({inherit:!1}).filter(d.not(d.prop("dynamic"))).map(d.prop("id"))},k=function(a,b){return a.equals(b,j(a.state))};i>h&&b[h].state!==e&&k(b[h],c[h]);)h++;var l,m,n,o,p,q,r,s;return l=b,m=l.slice(0,h),n=l.slice(h),q=m.map(g),r=c.slice(h),s=q.concat(r),p=a.bindTransNodesToPath(s),o=p.slice(h),{from:l,to:p,retained:m,exiting:n,entering:o}},a.bindTransitionResolve=function(a,b){var c=a.to[0];c.resolves.$transition$=new g.Resolvable("$transition$",function(){return b},b)},a.makeParamsNode=d.curry(function(a,b){return new f.Node(b,a)}),a}();b.PathFactory=h},function(a,b,c){var d=c(3),e=c(24),f=c(28),g=c(29),h=c(30),i=c(39),j=c(40),k=function(){function a(a,b,c,d,e,f,g,k,l){this.transition=a,this.$transitions=b,this.$urlRouter=c,this.$view=d,this.$state=e,this.$stateParams=f,this.$q=g,this.activeTransQ=k,this.changeHistory=l,this.viewHooks=new h.ViewHooks(a,d),this.enterExitHooks=new i.EnterExitHooks(a),this.resolveHooks=new j.ResolveHooks(a),this.treeChanges=a.treeChanges(),this.registerUpdateGlobalState(),this.viewHooks.registerHooks(),this.enterExitHooks.registerHooks(),this.resolveHooks.registerHooks()}return a.prototype.runTransition=function(){var a=this;return this.activeTransQ.clear(),this.activeTransQ.enqueue(this.transition),this.transition.run().then(function(a){return a.to()})["catch"](function(b){return a.transRejected(b)})["finally"](function(){return a.activeTransQ.remove(a.transition)})},a.prototype.registerUpdateGlobalState=function(){this.transition.onFinish({},this.updateGlobalState.bind(this),{priority:-1e4})},a.prototype.updateGlobalState=function(){var a=this,b=a.treeChanges,c=a.transition,d=a.$state,e=a.changeHistory;d.$current=c.$to(),d.current=d.$current.self,e.enqueue(b),this.updateStateParams()},a.prototype.transRejected=function(a){var b=this,c=b.transition,h=b.$state,i=b.$stateParams,j=b.$q;if(a instanceof f.TransitionRejection){if(a.type===f.RejectType.IGNORED){var k=h.$current.parameters().filter(d.prop("dynamic"));return e.Param.equals(k,i,c.params())||this.updateStateParams(),h.current}if(a.type===f.RejectType.SUPERSEDED&&a.redirected&&a.detail instanceof g.TargetState)return this._redirectMgr(c.redirect(a.detail)).runTransition()}return this.$transitions.defaultErrorHandler()(a),j.reject(a)},a.prototype.updateStateParams=function(){var a=this,b=a.transition,c=a.$urlRouter,e=a.$state,f=a.$stateParams,g=b.options();e.params=b.params(),d.copy(e.params,f),f.$sync().$off(),g.location&&e.$current.navigable&&c.push(e.$current.navigable.url,f,{replace:"replace"===g.location}),c.update(!0)},a.prototype._redirectMgr=function(b){var c=this,d=c.$transitions,e=c.$urlRouter,f=c.$view,g=c.$state,h=c.$stateParams,i=c.$q,j=c.activeTransQ,k=c.changeHistory;return new a(b,d,e,f,g,h,i,j,k)},a}();b.TransitionManager=k},function(a,b,c){var d,e=c(3),f=c(4),g=c(25),h=c(26),i=c(27),j=Object.prototype.hasOwnProperty,k=function(a){return 0===["value","type","squash","array","dynamic"].filter(j.bind(a||{})).length};!function(a){a[a.PATH=0]="PATH",a[a.SEARCH=1]="SEARCH",a[a.CONFIG=2]="CONFIG"}(d||(d={}));var l=function(){function a(a,b,c,f){function j(a){return a=k(a)&&{value:a}||a,e.extend(a,{$$fn:e.isInjectable(a.value)?a.value:function(){return a.value}})}function l(b,c,e){if(b.type&&c&&"string"!==c.name)throw new Error("Param '"+a+"' has two type configurations.");return b.type&&c&&"string"===c.name&&i.paramTypes.type(b.type)?i.paramTypes.type(b.type):c?c:b.type?b.type instanceof h.Type?b.type:i.paramTypes.type(b.type):e===d.CONFIG?i.paramTypes.type("any"):i.paramTypes.type("string")}function m(){var b={array:f===d.SEARCH?"auto":!1},g=a.match(/\[\]$/)?{array:!0}:{};return e.extend(b,g,c).array}function n(a,b){var c=a.squash;if(!b||c===!1)return!1;if(!e.isDefined(c)||null==c)return g.matcherConfig.defaultSquashPolicy();if(c===!0||e.isString(c))return c;throw new Error("Invalid squash policy: '"+c+"'. Valid policies: false, true, or arbitrary string")}function o(a,b,c,d){var f,g,h=[{from:"",to:c||b?void 0:""},{from:null,to:c||b?void 0:""}];return f=e.isArray(a.replace)?a.replace:[],e.isString(d)&&f.push({from:d,to:void 0}),g=e.map(f,e.prop("from")),e.filter(h,function(a){return-1===g.indexOf(a.from)}).concat(f)}c=j(c),b=l(c,b,f);var p=m();b=p?b.$asArray(p,f===d.SEARCH):b;var q=void 0!==c.value,r=c.dynamic===!0,s=n(c,q),t=o(c,p,q,s);e.extend(this,{id:a,type:b,location:f,squash:s,replace:t,isOptional:q,dynamic:r,config:c,array:p})}return a.prototype.isDefaultValue=function(a){return this.isOptional&&this.type.equals(this.value(),a)},a.prototype.value=function(a){var b=this,c=function(){if(!f.services.$injector)throw new Error("Injectable functions cannot be called at configuration time");var a=f.services.$injector.invoke(b.config.$$fn);if(null!==a&&void 0!==a&&!b.type.is(a))throw new Error("Default value ("+a+") for parameter '"+b.id+"' is not an instance of Type ("+b.type.name+")");return a},d=function(a){var c=e.map(e.filter(b.replace,e.propEq("from",a)),e.prop("to"));return c.length?c[0]:a};return a=d(a),e.isDefined(a)?this.type.$normalize(a):c()},a.prototype.isSearch=function(){return this.location===d.SEARCH},a.prototype.validates=function(a){if((!e.isDefined(a)||null===a)&&this.isOptional)return!0;var b=this.type.$normalize(a);if(!this.type.is(b))return!1;var c=this.type.encode(b);return e.isString(c)&&!this.type.pattern.exec(c)?!1:!0},a.prototype.toString=function(){return"{Param:"+this.id+" "+this.type+" squash: '"+this.squash+"' optional: "+this.isOptional+"}"},a.fromConfig=function(b,c,e){return new a(b,c,e,d.CONFIG)},a.fromPath=function(b,c,e){return new a(b,c,e,d.PATH)},a.fromSearch=function(b,c,e){return new a(b,c,e,d.SEARCH)},a.values=function(a,b){return b=b||{},a.map(function(a){return[a.id,a.value(b[a.id])]}).reduce(e.applyPairs,{})},a.equals=function(a,b,c){return b=b||{},c=c||{},-1===a.map(function(a){return a.type.equals(b[a.id],c[a.id])}).indexOf(!1)},a.validates=function(a,b){return b=b||{},-1===a.map(function(a){return a.validates(b[a.id])}).indexOf(!1)},a}();b.Param=l},function(a,b,c){var d=c(3),e=function(){function a(){this._isCaseInsensitive=!1,this._isStrictMode=!0,this._defaultSquashPolicy=!1}return a.prototype.caseInsensitive=function(a){return this._isCaseInsensitive=d.isDefined(a)?a:this._isCaseInsensitive},a.prototype.strictMode=function(a){return this._isStrictMode=d.isDefined(a)?a:this._isStrictMode},a.prototype.defaultSquashPolicy=function(a){if(d.isDefined(a)&&a!==!0&&a!==!1&&!d.isString(a))throw new Error("Invalid squash policy: "+a+". Valid policies: false, true, arbitrary-string");return this._defaultSquashPolicy=d.isDefined(a)?a:this._defaultSquashPolicy},a}();b.matcherConfig=new e},function(a,b,c){function d(a,b){function c(a){return e.isArray(a)?a:e.isDefined(a)?[a]:[]}function d(a){switch(a.length){case 0:return void 0;case 1:return"auto"===b?a[0]:a;default:return a}}function f(a,b){return function(f){var g=c(f),h=e.map(g,a);return b===!0?0===e.filter(h,function(a){return!a}).length:d(h)}}function g(a){return function(b,d){var e=c(b),f=c(d);if(e.length!==f.length)return!1;for(var g=0;g=0));)o(i.id),this._params.push(f.Param.fromPath(i.id,i.type,this.config.paramMap(i.cfg,!1))),this._segments.push(i.segment),n.push([i.segment,e.tail(this._params)]),m=k.lastIndex;j=b.substring(m);var q=j.indexOf("?");if(q>=0){var r=j.substring(q);if(j=j.substring(0,q),r.length>0)for(m=0;h=l.exec(r);)i=p(h,!0),o(i.id),this._params.push(f.Param.fromSearch(i.id,i.type,this.config.paramMap(i.cfg,!0))),m=k.lastIndex}this._segments.push(j),e.extend(this,{_compiled:n.map(function(a){return d.apply(null,a)}).concat(d(j)),prefix:this._segments[0]}),Object.freeze(this)}return a.prototype.append=function(a){return this._children.push(a),e.forEach(a._cache,function(b,c){return a._cache[c]=e.isArray(b)?[]:null}),a._cache.path=this._cache.path.concat(this),a},a.prototype.isRoot=function(){return 0===this._cache.path.length},a.prototype.toString=function(){return this.pattern},a.prototype.exec=function(a,b,c,d){function f(a){var b=function(a){return a.split("").reverse().join("")},c=function(a){return a.replace(/\\-/g,"-")},d=b(a).split(/-(?!\\)/),f=e.map(d,b);return e.map(f,c).reverse()}var h=this;void 0===b&&(b={}),void 0===d&&(d={});var i=g(this._cache,"pattern",function(){return new RegExp(["^",e.unnest(h._cache.path.concat(h).map(e.prop("_compiled"))).join(""),h.config.strict===!1?"/?":"","$"].join(""),h.config.caseInsensitive?"i":void 0)}).exec(a);if(!i)return null;var j=this.parameters(),k=j.filter(function(a){return!a.isSearch()}),l=j.filter(function(a){return a.isSearch()}),m=this._cache.path.concat(this).map(function(a){return a._segments.length-1}).reduce(function(a,b){return a+b}),n={};if(m!==i.length-1)throw new Error("Unbalanced capture group in route '"+this.pattern+"'");for(var o=0;m>o;o++){for(var p=k[o],q=i[o+1],r=0;r=0||(h.push(d[j]),g[d[j]]=this[d[j]]);return e.extend({},g,a)},f.prototype.$set=function(a,c){var d=this,f=!1,g=!1;return c&&e.forEach(a,function(a,b){(c.parameter(b)||{}).dynamic!==!0&&(g=!0)}),g?!1:(e.forEach(a,function(a,c){a!==d[c]&&(d[c]=a,b(c),f=!0)}),this.$sync(),f)},f.prototype.$sync=function(){return e.copy(this,d),this},f.prototype.$off=function(){return c={},this},f.prototype.$raw=function(){return e.omit(this,Object.keys(this).filter(f.prototype.hasOwnProperty.bind(f.prototype)))},f.prototype.$localize=function(a,b){return new f(e.pick(b||this,Object.keys(a.params)))},f.prototype.$observe=function(b,d){return e.forEach(b.split(" "),function(a){return(c[a]||(c[a]=[])).push(d)}),a(b,d)},new f}function b(a){return a.$watch(function(){c.$digest()}),c}var c=a();this.$get=b,b.$inject=["$rootScope"]}var e=c(3),f=function(){function a(a){void 0===a&&(a={}),e.extend(this,a)}return a.prototype.$digest=function(){},a.prototype.$inherit=function(a,b,c){},a.prototype.$set=function(a,b){},a.prototype.$sync=function(){},a.prototype.$off=function(){},a.prototype.$raw=function(){},a.prototype.$localize=function(a,b){},a.prototype.$observe=function(a,b){},a}();b.StateParams=f,d.$inject=[],angular.module("ui.router.state").provider("$stateParams",d)},function(a,b,c){function d(a){function b(a){var b=/^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(a.source);return null!=b?b[1].replace(/\\(.)/g,"$1"):""}function c(a,b){return a.replace(/\$(\$|\d{1,2})/,function(a,c){return b["$"===c?0:Number(c)]})}function d(a,b,c){if(!c)return!1;var d=a.invoke(b,b,{$match:c});return e.isDefined(d)?d:!0}function h(a){function b(a,b,c){var d=f.services.locationConfig.baseHref();return"/"===d?a:b?d.slice(0,-1)+a:c?d.slice(1)+a:a}function c(a){function b(a){var b=a(f.services.$injector,g);return b?(e.isString(b)&&(g.replace(),g.url(b)),!0):!1}if(!a||!a.defaultPrevented){var c,d=j.length;for(c=0;d>c;c++)if(b(j[c]))return;k&&b(k)}}function d(){return i=i||a.$on("$locationChangeSuccess",c)}var h=g.url();return l||d(),{sync:function(){c()},listen:function(){return d()},update:function(a){return a?void(h=g.url()):void(g.url()!==h&&(g.url(h),g.replace()))},push:function(a,b,c){g.url(a.format(b||{})),c&&c.replace&&g.replace()},href:function(a,c,d){if(!a.validates(c))return null;var e=a.format(c);d=d||{};var g=f.services.locationConfig,h=g.html5Mode();if(h||null===e||(e="#"+g.hashPrefix()+e),e=b(e,h,d.absolute),!d.absolute||!e)return e;var i=!h&&e?"/":"",j=g.port();return j=80===j||443===j?"":":"+j,[g.protocol(),"://",g.host(),j,i,e].join("")}}}var i,j=[],k=null,l=!1;this.rule=function(a){if(!e.isFunction(a))throw new Error("'rule' must be a function");return j.push(a),this},this.otherwise=function(a){if(!e.isFunction(a)&&!e.isString(a))throw new Error("'rule' must be a string or function");return k=e.isString(a)?function(){return a}:a,this},this.when=function(h,i){var j,k=e.isString(i);if(e.isString(h)&&(h=a.compile(h)),!k&&!e.isFunction(i)&&!e.isArray(i))throw new Error("invalid 'handler' in when()");var l={matcher:function(b,c){return k&&(j=a.compile(c),c=["$match",j.format.bind(j)]),e.extend(function(){return d(f.services.$injector,c,b.exec(g.path(),g.search(),g.hash()))},{prefix:e.isString(b.prefix)?b.prefix:""})},regex:function(a,h){if(a.global||a.sticky)throw new Error("when() RegExp must not be global or sticky");return k&&(j=h,h=["$match",function(a){return c(j,a)}]),e.extend(function(){return d(f.services.$injector,h,a.exec(g.path()))},{prefix:b(a)})}},m={matcher:a.isMatcher(h),regex:h instanceof RegExp};for(var n in m)if(m[n])return this.rule(l[n](h,i));throw new Error("invalid 'what' in when()")},this.deferIntercept=function(a){void 0===a&&(a=!0),l=a},this.$get=h,h.$inject=["$rootScope"]}var e=c(3),f=c(4),g=f.services.location;b.$UrlRouterProvider=d},function(a,b){var c=function(){function a(a){this.transition=a}return a.prototype.registerHooks=function(){this.registerOnEnterHooks(),this.registerOnRetainHooks(),this.registerOnExitHooks()},a.prototype.registerOnEnterHooks=function(){var a=this,b=function(b){return a.transition.onEnter({to:b.name},b.onEnter)};this.transition.entering().filter(function(a){return!!a.onEnter}).forEach(b)},a.prototype.registerOnRetainHooks=function(){var a=this,b=function(b){return a.transition.onRetain({},b.onRetain)};this.transition.retained().filter(function(a){return!!a.onRetain}).forEach(b)},a.prototype.registerOnExitHooks=function(){var a=this,b=function(b){return a.transition.onExit({from:b.name},b.onExit)};this.transition.exiting().filter(function(a){return!!a.onExit}).forEach(b)},a}();b.EnterExitHooks=c},function(a,b,c){var d=c(3),e=c(19),f=e.ResolvePolicy[e.ResolvePolicy.LAZY],g=e.ResolvePolicy[e.ResolvePolicy.EAGER],h=function(){function a(a){this.transition=a}return a.prototype.registerHooks=function(){function a(a){return d.tail(c.to).resolveContext.resolvePath(d.extend({transition:a},{resolvePolicy:g}))}function b(a,b){var e=d.find(c.entering,d.propEq("state",a));return e.resolveContext.resolvePathElement(e.state,d.extend({transition:b},{resolvePolicy:f}))}var c=this.transition.treeChanges();a.$inject=["$transition$"],b.$inject=["$state$","$transition$"],this.transition.onStart({},a,{priority:1e3}),this.transition.onEnter({},b,{priority:1e3})},a}();b.ResolveHooks=h},function(a,b,c){var d=c(3),e=c(36),f=function(a){if(!d.isString(a))return!1;var b="^"===a.charAt(0);return{val:b?a.substring(1):a,root:b}},g=function(){function a(a,b,c){this.matcher=b;var g=this;this.builders={parent:[function(c){return c===a()?null:b.find(g.parentName(c))||a()}],data:[function(a){return a.parent&&a.parent.data&&(a.data=a.self.data=d.extend({},a.parent.data,a.data)),a.data}],url:[function(b){var e=b,g=f(e.url),h=b.parent,i=g?c.compile(g.val,{params:b.params||{},paramMap:function(a,b){return e.reloadOnSearch===!1&&b&&(a=d.extend(a||{},{dynamic:!0})),a}}):e.url;if(!i)return null;if(!c.isMatcher(i))throw new Error("Invalid url '"+i+"' in state '"+b+"'");return g&&g.root?i:(h&&h.navigable||a()).url.append(i)}],navigable:[function(b){ +return b!==a()&&b.url?b:b.parent?b.parent.navigable:null}],params:[function(a){var b=function(a,b){return e.Param.fromConfig(b,null,a)},c=a.url&&a.url.parameters({inherit:!1})||[],f=d.values(d.map(d.omit(a.params||{},c.map(d.prop("id"))),b));return c.concat(f).map(function(a){return[a.id,a]}).reduce(d.applyPairs,{})}],views:[function(a){var b={},c=["templateProvider","templateUrl","template","notify","async"],e=["controller","controllerProvider","controllerAs"],f=c.concat(e);return d.forEach(a.views||{$default:d.pick(a,f)},function(c,f){f=f||"$default",d.forEach(e,function(b){a[b]&&!c[b]&&(c[b]=a[b])}),Object.keys(c).length>0&&(b[f]=c)}),b}],path:[function(a){return a.parent?a.parent.path.concat(a):[a]}],includes:[function(a){var b=a.parent?d.extend({},a.parent.includes):{};return b[a.name]=!0,b}]}}return a.prototype.builder=function(a,b){var c=this.builders,e=c[a]||[];return d.isString(a)&&!d.isDefined(b)?e.length>1?e:e[0]:d.isString(a)&&d.isFunction(b)?(c[a]=e,c[a].push(b),function(){return c[a].splice(c[a].indexOf(b,1))&&null}):void 0},a.prototype.build=function(a){var b=this,c=b.matcher,e=b.builders,f=this.parentName(a);if(f&&!c.find(f))return null;for(var g in e)if(e.hasOwnProperty(g)){var h=e[g].reduce(function(a,b){return function(c){return b(c,a)}},d.noop);a[g]=h(a)}return a},a.prototype.parentName=function(a){var b=a.name||"";return-1!==b.indexOf(".")?b.substring(0,b.lastIndexOf(".")):a.parent?d.isString(a.parent)?a.parent:a.parent.name:""},a.prototype.name=function(a){var b=a.name;if(-1!==b.indexOf(".")||!a.parent)return b;var c=d.isString(a.parent)?a.parent:a.parent.name;return c?c+"."+b:b},a}();b.StateBuilder=g},function(a,b,c){function d(a,b){var c,d=a.match(/^\s*({[^}]*})\s*$/);if(d&&(a=b+"("+d[1]+")"),c=a.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/),!c||4!==c.length)throw new Error("Invalid state ref '"+a+"'");return{state:c[1],paramExpr:c[3]||null}}function e(a){var b=a.parent().inheritedData("$uiView");return b&&b.context&&b.context.name?b.context:void 0}function f(a,b){return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(c,f,g,j){var k=d(g.uiSref,a.current.name),l=null,m=e(f)||a.$current,n=null,o="A"===f.prop("tagName"),p="FORM"===f[0].nodeName,q=p?"action":"href",r=!0,s=c.$eval(g.uiSrefOpts),t={relative:m,inherit:!0},u=h.defaults(s,t,i.defaultTransOpts),v=function(b){if(b&&(l=h.copy(b)),r){n=a.href(k.state,l,u);var c=j[1]||j[0];return c&&c.$$addStateInfo(k.state,l),null===n?(r=!1,!1):void g.$set(q,n)}};k.paramExpr&&(c.$watch(k.paramExpr,function(a){a!==l&&v(a)},!0),l=h.copy(c.$eval(k.paramExpr))),v(),p||f.bind("click",function(c){var d=c.which||c.button;if(!(d>1||c.ctrlKey||c.metaKey||c.shiftKey||f.attr("target"))){var e=b(function(){a.go(k.state,l,u)});c.preventDefault();var g=o&&!n?1:0;c.preventDefault=function(){g--<=0&&b.cancel(e)}}})}}}function g(a,b,c){return{restrict:"A",controller:["$scope","$element","$attrs","$timeout","$transitions",function(b,f,g,i,j){function k(b,c,d){var g=a.get(b,e(f)),h=m(b,c);t.push({state:g||{name:b},params:c,hash:h}),u[h]=d}function l(a){a.promise.then(n)}function m(a,c){if(!h.isString(a))throw new Error("state should be a string");return h.isObject(c)?a+h.toJson(c):(c=b.$eval(c),h.isObject(c)?a+h.toJson(c):a)}function n(){for(var a=0;a0||(k(a,b,v),n())},b.$on("$stateChangeSuccess",n),l.$inject=["$transition$"];var w=j.onStart({},l);b.$on("$destroy",w)}]}}var h=c(3),i=c(9);f.$inject=["$state","$timeout"],g.$inject=["$state","$stateParams","$interpolate"],angular.module("ui.router.state").directive("uiSref",f).directive("uiSrefActive",g).directive("uiSrefActiveEq",g)},function(a,b){function c(a){return function(b){return a.is(b)}}function d(a){return function(b,c,d){return a.includes(b,c,d)}}c.$inject=["$state"],b.$IsStateFilter=c,d.$inject=["$state"],b.$IncludedByStateFilter=d,angular.module("ui.router.state").filter("isState",c).filter("includedByState",d)},function(a,b,c){var d=c(2),e=function(){function a(a){d.extend(this,a)}return a.prototype.is=function(a){return this===a||this.self===a||this.fqn()===a},a.prototype.fqn=function(){if(!(this.parent&&this.parent instanceof this.constructor))return this.name;var a=this.parent.fqn();return a?a+"."+this.name:this.name},a.prototype.root=function(){return this.parent&&this.parent.root()||this},a.prototype.parameters=function(a){a=d.defaults(a,{inherit:!0});var b=a.inherit&&this.parent&&this.parent.parameters()||[];return b.concat(d.values(this.params))},a.prototype.parameter=function(a,b){return void 0===b&&(b={}),this.url&&this.url.parameter(a,b)||d.find(d.values(this.params),d.propEq("id",a))||b.inherit&&this.parent&&this.parent.parameter(a)},a.prototype.toString=function(){return this.fqn()},a}();b.State=e},function(a,b,c){var d=c(3),e=function(){function a(a){this._states=a}return a.prototype.isRelative=function(a){return a=a||"",0===a.indexOf(".")||0===a.indexOf("^")},a.prototype.find=function(a,b){if(!a&&""!==a)return void 0;var c=d.isString(a),e=c?a:a.name;this.isRelative(e)&&(e=this.resolvePath(e,b));var f=this._states[e];return!f||!c&&(c||f!==a&&f.self!==a)?void 0:f},a.prototype.resolvePath=function(a,b){if(!b)throw new Error("No reference point given for path '"+a+"'");for(var c=this.find(b),d=a.split("."),e=0,f=d.length,g=c;f>e;e++)if(""!==d[e]||0!==e){if("^"!==d[e])break;if(!g.parent)throw new Error("Path '"+a+"' not valid for state '"+c.name+"'");g=g.parent}else g=c;var h=d.slice(e).join(".");return g.name+(g.name&&h?".":"")+h},a}();b.StateMatcher=e},function(a,b,c){var d=c(3),e=c(12),f=function(){function a(a,b,c,d){this.states=a,this.builder=b,this.$urlRouterProvider=c,this.$state=d,this.autoFlush=!1,this.queue=[]}return a.prototype.register=function(a,b){var c=this,f=c.states,g=c.queue,h=c.$state,i=d.inherit(new e.State,d.extend({},a,{self:a,resolve:a.resolve||{},toString:function(){return a.name}}));if(!d.isString(i.name))throw new Error("State must have a valid name");if(f.hasOwnProperty(i.name)||-1!==d.pluck(g,"name").indexOf(i.name))throw new Error("State '"+i.name+"' is already defined");return g[b?"unshift":"push"](i),this.autoFlush&&this.flush(h),i},a.prototype.flush=function(a){for(var b,c,d,e=this,f=e.queue,g=e.states,h=e.builder,i=[],j={};f.length>0;)if(c=f.shift(),b=h.build(c),d=i.indexOf(c),b){if(g.hasOwnProperty(c.name))throw new Error("State '"+name+"' is already defined");g[c.name]=c,this.attachRoute(a,c),d>=0&&i.splice(d,1)}else{var k=j[c.name];if(j[c.name]=f.length,d>=0&&k===f.length)throw new Error("Cannot register orphaned state '"+c.name+"'");0>d&&i.push(c),f.push(c)}return g},a.prototype.attachRoute=function(a,b){var c=this.$urlRouterProvider;!b[d.abstractKey]&&b.url&&c.when(b.url,["$match","$stateParams",function(c,e){a.$current.navigable===b&&d.equalForKeys(c,e)||a.transitionTo(b,c,{inherit:!0,location:!1})}])},a}();b.StateQueueManager=f},function(a,b,c){var d=c(3),e=c(6),f=c(4),g=c(28),h=c(12),i=new g.RejectFactory,j={async:!0,rejectIfSuperseded:!0,current:d.noop,transition:null,traceData:{}},k=function(){function a(a,b,c,f){var g=this;this.fn=a,this.locals=b,this.resolveContext=c,this.options=f,this.isSuperseded=function(){return g.options.current()!==g.options.transition},this.mapHookResult=d.pattern([[this.isSuperseded,function(){return i.superseded(g.options.current())}],[d.eq(!1),d.val(i.aborted("Hook aborted transition"))],[d.is(h.TargetState),function(a){return i.redirected(a)}],[d.isPromise,function(a){return a.then(g.handleHookResult.bind(g))}]]),this.invokeStep=function(a){var b=g,c=b.options,f=b.fn,h=b.resolveContext,j=d.extend({},g.locals,a);if(e.trace.traceHookInvocation(g,c),c.rejectIfSuperseded&&g.isSuperseded())return i.superseded(c.current());if(!c.async){var k=h.invokeNow(f,j,c);return g.handleHookResult(k)}return h.invokeLater(f,j,c).then(g.handleHookResult.bind(g))},this.options=d.defaults(f,j)}return a.prototype.handleHookResult=function(a){if(!d.isDefined(a))return void 0;e.trace.traceHookResult(a,void 0,this.options);var b=this.mapHookResult(a);return b&&e.trace.traceHookResult(a,b,this.options),b},a.prototype.toString=function(){var a=this,b=a.options,c=a.fn,e=d.parse("traceData.hookType")(b)||"internal",f=d.parse("traceData.context.state.name")(b)||d.parse("traceData.context")(b)||"unknown",g=d.fnToString(c);return e+" context: "+f+", "+d.maxLength(200,g)},a.runSynchronousHooks=function(b,c,e){void 0===c&&(c={}),void 0===e&&(e=!1);for(var g=[],h=0;h2?b.enter(a,null,c).then(d):b.enter(a,null,c,d)},leave:function(a,c){angular.version.minor>2?b.leave(a).then(c):b.leave(a,c)}}}function i(a,b){return a===b}var j={context:a.rootContext()},k={count:0,restrict:"ECA",terminal:!0,priority:400,transclude:"element",compile:function(b,e,l){return function(b,e,m){function n(a){i(x,a)||(g.trace.traceUiViewConfigUpdated(A,a&&a.context),x=a,p(a))}function o(){q&&(g.trace.traceUiViewEvent("Removing (previous) el",A),q.remove(),q=null),s&&(g.trace.traceUiViewEvent("Destroying (previous) scope",A),s.$destroy(),s=null),r&&(g.trace.traceUiViewEvent("Animate out (previous)",A),w.leave(r,function(){q=null}),q=r,r=null)}function p(a){a=a||{};var d=b.$new();g.trace.traceUiViewScopeCreated(A,d),f.extend(A,{context:a.context,$template:a.template,$controller:a.controller,$controllerAs:a.controllerAs,$locals:a.locals});var h=l(d,function(a){w.enter(a.data("$uiView",A),e,function(){s&&s.$emit("$viewContentAnimationEnded"),(f.isDefined(v)&&!v||b.$eval(v))&&c(a)}),o()});r=h,s=d,s.$emit("$viewContentLoaded",a||x),s.$eval(u)}var q,r,s,t,u=m.onload||"",v=m.autoscroll,w=h(m,b),x=void 0,y=e.inheritedData("$uiView")||j,z=d(m.uiView||m.name||"")(b)||"$default",A={id:k.count++,name:z,fqn:y.name?y.fqn+"."+z:z,config:null,configUpdated:n,get creationContext(){return y.context}};g.trace.traceUiViewEvent("Linking",A),e.data("$uiView",A),p(),t=a.registerUiView(A),b.$on("$destroy",function(){g.trace.traceUiViewEvent("Destroying/Unregistering",A),t()})}}};return k}function e(a,b,c,d,e){return{restrict:"ECA",priority:-400,compile:function(c){var d=c.html();return function(c,e){var h=e.data("$uiView");if(h){e.html(h.$template||d),g.trace.traceUiViewFill(h,e.html());var i=a(e.contents()),j=h.$controller,k=h.$controllerAs;if(j){var l=h.$locals,m=b(j,f.extend(l,{$scope:c}));k&&(c[k]=m),e.data("$ngControllerController",m),e.children().data("$ngControllerController",m)}i(c)}}}}}var f=c(3),g=c(6);d.$inject=["$view","$animate","$uiViewScroll","$interpolate","$q"],e.$inject=["$compile","$controller","$interpolate","$injector","$q"],angular.module("ui.router.state").directive("uiView",d),angular.module("ui.router.state").directive("uiView",e)},function(a,b){function c(){var a=!1;this.useAnchorScroll=function(){a=!0},this.$get=["$anchorScroll","$timeout",function(b,c){return a?b:function(a){return c(function(){a[0].scrollIntoView()},0,!1)}}]}angular.module("ui.router.state").provider("$uiViewScroll",c)}])}); \ No newline at end of file diff --git a/release/ng1/stateEvents.js b/release/ng1/stateEvents.js new file mode 100644 index 000000000..03273a586 --- /dev/null +++ b/release/ng1/stateEvents.js @@ -0,0 +1,114 @@ +/** + * State-based routing for AngularJS + * @version v1.0.0alpha0 + * @link http://angular-ui.github.com/ + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +(function () { + var extend = angular.extend, isFunction = angular.isFunction, isString = angular.isString; + function applyPairs(memo, keyValTuple) { + var key, value; + if (Array.isArray(keyValTuple)) + key = keyValTuple[0], value = keyValTuple[1]; + if (!isString(key)) + throw new Error("invalid parameters to applyPairs"); + memo[key] = value; + return memo; + } + stateChangeStartHandler.$inject = ['$transition$', '$stateEvents', '$rootScope', '$urlRouter']; + function stateChangeStartHandler($transition$, $stateEvents, $rootScope, $urlRouter) { + if (!$transition$.options().notify || !$transition$.valid() || $transition$.ignored()) + return; + var enabledEvents = $stateEvents.provider.enabled(); + var toParams = $transition$.params("to"); + var fromParams = $transition$.params("from"); + if (enabledEvents.$stateChangeSuccess) { + var startEvent = $rootScope.$broadcast('$stateChangeStart', $transition$.to(), toParams, $transition$.from(), fromParams, $transition$); + if (startEvent.defaultPrevented) { + if (enabledEvents.$stateChangeCancel) { + $rootScope.$broadcast('$stateChangeCancel', $transition$.to(), toParams, $transition$.from(), fromParams, $transition$); + } + $urlRouter.update(); + return false; + } + $transition$.promise.then(function () { + $rootScope.$broadcast('$stateChangeSuccess', $transition$.to(), toParams, $transition$.from(), fromParams); + }); + } + if (enabledEvents.$stateChangeError) { + $transition$.promise["catch"](function (error) { + if (error && (error.type === 2 || error.type === 3)) + return; + var evt = $rootScope.$broadcast('$stateChangeError', $transition$.to(), toParams, $transition$.from(), fromParams, error); + if (!evt.defaultPrevented) { + $urlRouter.update(); + } + }); + } + } + stateNotFoundHandler.$inject = ['$to$', '$from$', '$state', '$rootScope', '$urlRouter']; + function stateNotFoundHandler($to$, $from$, $state, $rootScope, $urlRouter) { + var redirect = { to: $to$.identifier(), toParams: $to$.params(), options: $to$.options() }; + var e = $rootScope.$broadcast('$stateNotFound', redirect, $from$.state(), $from$.params()); + if (e.defaultPrevented || e.retry) + $urlRouter.update(); + function redirectFn() { + return $state.target(redirect.to, redirect.toParams, redirect.options); + } + if (e.defaultPrevented) { + return false; + } + else if (e.retry || $state.get(redirect.to)) { + return e.retry && isFunction(e.retry.then) ? e.retry.then(redirectFn) : redirectFn(); + } + } + $StateEventsProvider.$inject = ['$stateProvider']; + function $StateEventsProvider($stateProvider) { + $StateEventsProvider.prototype.instance = this; + var runtime = false; + var allEvents = ['$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError']; + var enabledStateEvents = allEvents.map(function (e) { return [e, true]; }).reduce(applyPairs, {}); + function assertNotRuntime() { + if (runtime) + throw new Error("Cannot enable events at runtime (use $stateEventsProvider"); + } + this.enable = function () { + var events = []; + for (var _i = 0; _i < arguments.length; _i++) { + events[_i - 0] = arguments[_i]; + } + assertNotRuntime(); + if (!events || !events.length) + events = allEvents; + events.forEach(function (event) { return enabledStateEvents[event] = true; }); + }; + this.disable = function () { + var events = []; + for (var _i = 0; _i < arguments.length; _i++) { + events[_i - 0] = arguments[_i]; + } + assertNotRuntime(); + if (!events || !events.length) + events = allEvents; + events.forEach(function (event) { return delete enabledStateEvents[event]; }); + }; + this.enabled = function () { return enabledStateEvents; }; + this.$get = $get; + $get.$inject = ['$transitions']; + function $get($transitions) { + runtime = true; + if (enabledStateEvents["$stateNotFound"]) + $stateProvider.onInvalid(stateNotFoundHandler); + if (enabledStateEvents.$stateChangeStart) + $transitions.onBefore({}, stateChangeStartHandler, { priority: 1000 }); + return { + provider: $StateEventsProvider.prototype.instance + }; + } + } + angular.module('ui.router.state.events', ['ui.router.state']) + .provider("$stateEvents", $StateEventsProvider) + .run(['$stateEvents', function ($stateEvents) { + }]); +})(); +//# sourceMappingURL=stateEvents.js.map \ No newline at end of file diff --git a/release/ng1/stateEvents.js.map b/release/ng1/stateEvents.js.map new file mode 100644 index 000000000..47ce19895 --- /dev/null +++ b/release/ng1/stateEvents.js.map @@ -0,0 +1 @@ +{"version":3,"file":"stateEvents.js","sourceRoot":"","sources":["../../../src/ng1/stateEvents.ts"],"names":["applyPairs","stateChangeStartHandler","stateNotFoundHandler","stateNotFoundHandler.redirectFn","$StateEventsProvider","$StateEventsProvider.assertNotRuntime","$StateEventsProvider.$get"],"mappings":"AAmBA,CAAC;IACC,IAAK,MAAM,GAA0B,OAAO,SAA/B,UAAU,GAAc,OAAO,aAAnB,QAAQ,GAAI,OAAO,SAAA,CAAC;IAE7C,oBAAoB,IAAI,EAAE,WAAiB;QACzCA,IAAIA,GAAGA,EAAEA,KAAKA,CAACA;QACfA,EAAEA,CAACA,CAACA,KAAKA,CAACA,OAAOA,CAACA,WAAWA,CAACA,CAACA;YAAEA,GAAGA,GAAWA,WAAWA,KAApBA,KAAKA,GAAIA,WAAWA,GAAAA,CAACA;QAC3DA,EAAEA,CAACA,CAACA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA;YAACA,MAAMA,IAAIA,KAAKA,CAACA,kCAAkCA,CAACA,CAACA;QACxEA,IAAIA,CAACA,GAAGA,CAACA,GAAGA,KAAKA,CAACA;QAClBA,MAAMA,CAACA,IAAIA,CAACA;IACdA,CAACA;IAED,uBAAuB,CAAC,OAAO,GAAG,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IAC/F,iCAAiC,YAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU;QAC5FC,EAAEA,CAACA,CAACA,CAACA,YAAYA,CAACA,OAAOA,EAAEA,CAACA,MAAMA,IAAIA,CAACA,YAAYA,CAACA,KAAKA,EAAEA,IAAIA,YAAYA,CAACA,OAAOA,EAAEA,CAACA;YACpFA,MAAMA,CAACA;QAETA,IAAIA,aAAaA,GAAGA,YAAYA,CAACA,QAAQA,CAACA,OAAOA,EAAEA,CAACA;QA2BpDA,IAAIA,QAAQA,GAAGA,YAAYA,CAACA,MAAMA,CAACA,IAAIA,CAACA,CAACA;QACzCA,IAAIA,UAAUA,GAAGA,YAAYA,CAACA,MAAMA,CAACA,MAAMA,CAACA,CAACA;QAE7CA,EAAEA,CAACA,CAACA,aAAaA,CAACA,mBAAmBA,CAACA,CAACA,CAACA;YACtCA,IAAIA,UAAUA,GAAGA,UAAUA,CAACA,UAAUA,CAACA,mBAAmBA,EAAEA,YAAYA,CAACA,EAAEA,EAAEA,EAAEA,QAAQA,EAAEA,YAAYA,CAACA,IAAIA,EAAEA,EAAEA,UAAUA,EAAEA,YAAYA,CAACA,CAACA;YAExIA,EAAEA,CAACA,CAACA,UAAUA,CAACA,gBAAgBA,CAACA,CAACA,CAACA;gBAChCA,EAAEA,CAACA,CAACA,aAAaA,CAACA,kBAAkBA,CAACA,CAACA,CAACA;oBACrCA,UAAUA,CAACA,UAAUA,CAACA,oBAAoBA,EAAEA,YAAYA,CAACA,EAAEA,EAAEA,EAAEA,QAAQA,EAAEA,YAAYA,CAACA,IAAIA,EAAEA,EAAEA,UAAUA,EAAEA,YAAYA,CAACA,CAACA;gBAC1HA,CAACA;gBACDA,UAAUA,CAACA,MAAMA,EAAEA,CAACA;gBACpBA,MAAMA,CAACA,KAAKA,CAACA;YACfA,CAACA;YAEDA,YAAYA,CAACA,OAAOA,CAACA,IAAIA,CAACA;gBAexB,UAAU,CAAC,UAAU,CAAC,qBAAqB,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC;YAC7G,CAAC,CAACA,CAACA;QACLA,CAACA;QAEDA,EAAEA,CAACA,CAACA,aAAaA,CAACA,iBAAiBA,CAACA,CAACA,CAACA;YACpCA,YAAYA,CAACA,OAAOA,CAACA,OAAOA,CAACA,CAACA,UAAUA,KAAKA;gBAC3C,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAgC,KAAK,CAAC,IAAI,KAAK,CAAC,CAA0B,CAAC;oBACvG,MAAM,CAAC;gBAoBT,IAAI,GAAG,GAAG,UAAU,CAAC,UAAU,CAAC,mBAAmB,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;gBAE1H,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;oBAC1B,UAAU,CAAC,MAAM,EAAE,CAAC;gBACtB,CAAC;YACH,CAAC,CAACA,CAACA;QACLA,CAACA;IACHA,CAACA;IAED,oBAAoB,CAAC,OAAO,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IACxF,8BAA8B,IAAgB,EAAE,MAAkB,EAAE,MAAmB,EAAE,UAAU,EAAE,UAAU;QAiC7GC,IAAIA,QAAQA,GAAGA,EAACA,EAAEA,EAAEA,IAAIA,CAACA,UAAUA,EAAEA,EAAEA,QAAQA,EAAEA,IAAIA,CAACA,MAAMA,EAAEA,EAAEA,OAAOA,EAAEA,IAAIA,CAACA,OAAOA,EAAEA,EAACA,CAACA;QACzFA,IAAIA,CAACA,GAAGA,UAAUA,CAACA,UAAUA,CAACA,gBAAgBA,EAAEA,QAAQA,EAAEA,MAAMA,CAACA,KAAKA,EAAEA,EAAEA,MAAMA,CAACA,MAAMA,EAAEA,CAACA,CAACA;QAE3FA,EAAEA,CAACA,CAACA,CAACA,CAACA,gBAAgBA,IAAIA,CAACA,CAACA,KAAKA,CAACA;YAChCA,UAAUA,CAACA,MAAMA,EAAEA,CAACA;QAEtBA;YACEC,MAAMA,CAACA,MAAMA,CAACA,MAAMA,CAACA,QAAQA,CAACA,EAAEA,EAAEA,QAAQA,CAACA,QAAQA,EAAEA,QAAQA,CAACA,OAAOA,CAACA,CAACA;QACzEA,CAACA;QAEDD,EAAEA,CAACA,CAACA,CAACA,CAACA,gBAAgBA,CAACA,CAACA,CAACA;YACvBA,MAAMA,CAACA,KAAKA,CAACA;QACfA,CAACA;QAACA,IAAIA,CAACA,EAAEA,CAACA,CAACA,CAACA,CAACA,KAAKA,IAAIA,MAAMA,CAACA,GAAGA,CAACA,QAAQA,CAACA,EAAEA,CAACA,CAACA,CAACA,CAACA;YAC9CA,MAAMA,CAACA,CAACA,CAACA,KAAKA,IAAIA,UAAUA,CAACA,CAACA,CAACA,KAAKA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,KAAKA,CAACA,IAAIA,CAACA,UAAUA,CAACA,GAAGA,UAAUA,EAAEA,CAACA;QACvFA,CAACA;IACHA,CAACA;IAED,oBAAoB,CAAC,OAAO,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClD,8BAA8B,cAA4B;QACxDE,oBAAoBA,CAACA,SAASA,CAACA,QAAQA,GAAGA,IAAIA,CAACA;QAS/CA,IAAIA,OAAOA,GAAGA,KAAKA,CAACA;QACpBA,IAAIA,SAASA,GAAGA,CAACA,mBAAmBA,EAAEA,gBAAgBA,EAAEA,qBAAqBA,EAAEA,mBAAmBA,CAACA,CAACA;QACpGA,IAAIA,kBAAkBA,GAAiCA,SAASA,CAACA,GAAGA,CAACA,UAAAA,CAACA,IAAIA,OAAAA,CAACA,CAACA,EAAEA,IAAIA,CAACA,EAATA,CAASA,CAACA,CAACA,MAAMA,CAACA,UAAUA,EAAEA,EAAEA,CAACA,CAACA;QAE5GA;YACEC,EAAEA,CAACA,CAACA,OAAOA,CAACA;gBAACA,MAAMA,IAAIA,KAAKA,CAACA,2DAA2DA,CAACA,CAACA;QAC5FA,CAACA;QAMDD,IAAIA,CAACA,MAAMA,GAAGA;YAAU,gBAAkB;iBAAlB,WAAkB,CAAlB,sBAAkB,CAAlB,IAAkB;gBAAlB,+BAAkB;;YACxC,gBAAgB,EAAE,CAAC;YACnB,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;gBAAC,MAAM,GAAG,SAAS,CAAC;YAClD,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK,IAAI,OAAA,kBAAkB,CAAC,KAAK,CAAC,GAAG,IAAI,EAAhC,CAAgC,CAAC,CAAC;QAC5D,CAAC,CAACA;QAMFA,IAAIA,CAACA,OAAOA,GAAGA;YAAU,gBAAkB;iBAAlB,WAAkB,CAAlB,sBAAkB,CAAlB,IAAkB;gBAAlB,+BAAkB;;YACzC,gBAAgB,EAAE,CAAC;YACnB,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;gBAAC,MAAM,GAAG,SAAS,CAAC;YAClD,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK,IAAI,OAAA,OAAO,kBAAkB,CAAC,KAAK,CAAC,EAAhC,CAAgC,CAAC,CAAC;QAC5D,CAAC,CAACA;QAEFA,IAAIA,CAACA,OAAOA,GAAGA,cAAMA,OAAAA,kBAAkBA,EAAlBA,CAAkBA,CAACA;QAExCA,IAAIA,CAACA,IAAIA,GAAGA,IAAIA,CAACA;QACjBA,IAAIA,CAACA,OAAOA,GAAGA,CAACA,cAAcA,CAACA,CAACA;QAChCA,cAAcA,YAAYA;YACxBE,OAAOA,GAAGA,IAAIA,CAACA;YAEfA,EAAEA,CAACA,CAACA,kBAAkBA,CAACA,gBAAgBA,CAACA,CAACA;gBACvCA,cAAcA,CAACA,SAASA,CAACA,oBAAoBA,CAACA,CAACA;YACjDA,EAAEA,CAACA,CAACA,kBAAkBA,CAACA,iBAAiBA,CAACA;gBACvCA,YAAYA,CAACA,QAAQA,CAACA,EAAEA,EAAEA,uBAAuBA,EAAEA,EAACA,QAAQA,EAAEA,IAAIA,EAACA,CAACA,CAACA;YAEvEA,MAAMA,CAACA;gBACLA,QAAQA,EAAEA,oBAAoBA,CAACA,SAASA,CAACA,QAAQA;aAClDA,CAACA;QACJA,CAACA;IACHF,CAACA;IAGD,OAAO,CAAC,MAAM,CAAC,wBAAwB,EAAE,CAAC,iBAAiB,CAAC,CAAC;SACxD,QAAQ,CAAC,cAAc,EAA4B,oBAAoB,CAAC;SACxE,GAAG,CAAC,CAAC,cAAc,EAAE,UAAU,YAAY;QAC5C,CAAC,CAAC,CAAC,CAAC;AACV,CAAC,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/release/ng1/stateEvents.min.js b/release/ng1/stateEvents.min.js new file mode 100644 index 000000000..35c2a8207 --- /dev/null +++ b/release/ng1/stateEvents.min.js @@ -0,0 +1,7 @@ +/** + * State-based routing for AngularJS + * @version v1.0.0alpha0 + * @link http://angular-ui.github.com/ + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +!function(){function a(a,b){var c,d;if(Array.isArray(b)&&(c=b[0],d=b[1]),!f(c))throw new Error("invalid parameters to applyPairs");return a[c]=d,a}function b(a,b,c,d){if(a.options().notify&&a.valid()&&!a.ignored()){var e=b.provider.enabled(),f=a.params("to"),g=a.params("from");if(e.$stateChangeSuccess){var h=c.$broadcast("$stateChangeStart",a.to(),f,a.from(),g,a);if(h.defaultPrevented)return e.$stateChangeCancel&&c.$broadcast("$stateChangeCancel",a.to(),f,a.from(),g,a),d.update(),!1;a.promise.then(function(){c.$broadcast("$stateChangeSuccess",a.to(),f,a.from(),g)})}e.$stateChangeError&&a.promise["catch"](function(b){if(!b||2!==b.type&&3!==b.type){var e=c.$broadcast("$stateChangeError",a.to(),f,a.from(),g,b);e.defaultPrevented||d.update()}})}}function c(a,b,c,d,f){function g(){return c.target(h.to,h.toParams,h.options)}var h={to:a.identifier(),toParams:a.params(),options:a.options()},i=d.$broadcast("$stateNotFound",h,b.state(),b.params());return(i.defaultPrevented||i.retry)&&f.update(),i.defaultPrevented?!1:i.retry||c.get(h.to)?i.retry&&e(i.retry.then)?i.retry.then(g):g():void 0}function d(e){function f(){if(h)throw new Error("Cannot enable events at runtime (use $stateEventsProvider")}function g(a){return h=!0,j.$stateNotFound&&e.onInvalid(c),j.$stateChangeStart&&a.onBefore({},b,{priority:1e3}),{provider:d.prototype.instance}}d.prototype.instance=this;var h=!1,i=["$stateChangeStart","$stateNotFound","$stateChangeSuccess","$stateChangeError"],j=i.map(function(a){return[a,!0]}).reduce(a,{});this.enable=function(){for(var a=[],b=0;b