\n Snippet:
\n
\n \n Filter | \n Source | \n Rendered | \n
\n \n linky filter | \n \n <div ng-bind-html=\"snippet | linky\"> </div> \n | \n \n \n | \n
\n \n linky target | \n \n <div ng-bind-html=\"snippetWithTarget | linky:'_blank'\"> </div> \n | \n \n \n | \n
\n \n no filter | \n <div ng-bind=\"snippet\"> </div> | \n | \n
\n
\n \n
\n it('should linkify the snippet with urls', function() {\n expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()).\n toBe('Pretty text with some links: http://angularjs.org/, us@somewhere.org, ' +\n 'another@somewhere.org, and one more: ftp://127.0.0.1/.');\n expect(element.all(by.css('#linky-filter a')).count()).toEqual(4);\n });\n\n it('should not linkify snippet without the linky filter', function() {\n expect(element(by.id('escaped-html')).element(by.binding('snippet')).getText()).\n toBe('Pretty text with some links: http://angularjs.org/, mailto:us@somewhere.org, ' +\n 'another@somewhere.org, and one more: ftp://127.0.0.1/.');\n expect(element.all(by.css('#escaped-html a')).count()).toEqual(0);\n });\n\n it('should update', function() {\n element(by.model('snippet')).clear();\n element(by.model('snippet')).sendKeys('new http://link.');\n expect(element(by.id('linky-filter')).element(by.binding('snippet | linky')).getText()).\n toBe('new http://link.');\n expect(element.all(by.css('#linky-filter a')).count()).toEqual(1);\n expect(element(by.id('escaped-html')).element(by.binding('snippet')).getText())\n .toBe('new http://link.');\n });\n\n it('should work with the target property', function() {\n expect(element(by.id('linky-target')).\n element(by.binding(\"snippetWithTarget | linky:'_blank'\")).getText()).\n toBe('http://angularjs.org/');\n expect(element(by.css('#linky-target a')).getAttribute('target')).toEqual('_blank');\n });\n \n \n */\nangular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {\n var LINKY_URL_REGEXP =\n /((ftp|https?):\\/\\/|(www\\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\\S*[^\\s.;,(){}<>\"\\u201d\\u2019]/i,\n MAILTO_REGEXP = /^mailto:/i;\n\n return function(text, target) {\n if (!text) return text;\n var match;\n var raw = text;\n var html = [];\n var url;\n var i;\n while ((match = raw.match(LINKY_URL_REGEXP))) {\n // We can not end in these as they are sometimes found at the end of the sentence\n url = match[0];\n // if we did not match ftp/http/www/mailto then assume mailto\n if (!match[2] && !match[4]) {\n url = (match[3] ? 'http://' : 'mailto:') + url;\n }\n i = match.index;\n addText(raw.substr(0, i));\n addLink(url, match[0].replace(MAILTO_REGEXP, ''));\n raw = raw.substring(i + match[0].length);\n }\n addText(raw);\n return $sanitize(html.join(''));\n\n function addText(text) {\n if (!text) {\n return;\n }\n html.push(sanitizeText(text));\n }\n\n function addLink(url, text) {\n html.push('
');\n addText(text);\n html.push('');\n }\n };\n}]);\n\n\n})(window, window.angular);\n\n/**\n * @license AngularJS v1.4.14\n * (c) 2010-2015 Google, Inc. http://angularjs.org\n * License: MIT\n */\n(function(window, angular, undefined) {'use strict';\n\n/**\n * @ngdoc module\n * @name ngTouch\n * @description\n *\n * # ngTouch\n *\n * The `ngTouch` module provides touch events and other helpers for touch-enabled devices.\n * The implementation is based on jQuery Mobile touch event handling\n * ([jquerymobile.com](http://jquerymobile.com/)).\n *\n *\n * See {@link ngTouch.$swipe `$swipe`} for usage.\n *\n *
\n *\n */\n\n// define ngTouch module\n/* global -ngTouch */\nvar ngTouch = angular.module('ngTouch', []);\n\nfunction nodeName_(element) {\n return angular.lowercase(element.nodeName || (element[0] && element[0].nodeName));\n}\n\n/* global ngTouch: false */\n\n /**\n * @ngdoc service\n * @name $swipe\n *\n * @description\n * The `$swipe` service is a service that abstracts the messier details of hold-and-drag swipe\n * behavior, to make implementing swipe-related directives more convenient.\n *\n * Requires the {@link ngTouch `ngTouch`} module to be installed.\n *\n * `$swipe` is used by the `ngSwipeLeft` and `ngSwipeRight` directives in `ngTouch`.\n *\n * # Usage\n * The `$swipe` service is an object with a single method: `bind`. `bind` takes an element\n * which is to be watched for swipes, and an object with four handler functions. See the\n * documentation for `bind` below.\n */\n\nngTouch.factory('$swipe', [function() {\n // The total distance in any direction before we make the call on swipe vs. scroll.\n var MOVE_BUFFER_RADIUS = 10;\n\n var POINTER_EVENTS = {\n 'mouse': {\n start: 'mousedown',\n move: 'mousemove',\n end: 'mouseup'\n },\n 'touch': {\n start: 'touchstart',\n move: 'touchmove',\n end: 'touchend',\n cancel: 'touchcancel'\n }\n };\n\n function getCoordinates(event) {\n var originalEvent = event.originalEvent || event;\n var touches = originalEvent.touches && originalEvent.touches.length ? originalEvent.touches : [originalEvent];\n var e = (originalEvent.changedTouches && originalEvent.changedTouches[0]) || touches[0];\n\n return {\n x: e.clientX,\n y: e.clientY\n };\n }\n\n function getEvents(pointerTypes, eventType) {\n var res = [];\n angular.forEach(pointerTypes, function(pointerType) {\n var eventName = POINTER_EVENTS[pointerType][eventType];\n if (eventName) {\n res.push(eventName);\n }\n });\n return res.join(' ');\n }\n\n return {\n /**\n * @ngdoc method\n * @name $swipe#bind\n *\n * @description\n * The main method of `$swipe`. It takes an element to be watched for swipe motions, and an\n * object containing event handlers.\n * The pointer types that should be used can be specified via the optional\n * third argument, which is an array of strings `'mouse'` and `'touch'`. By default,\n * `$swipe` will listen for `mouse` and `touch` events.\n *\n * The four events are `start`, `move`, `end`, and `cancel`. `start`, `move`, and `end`\n * receive as a parameter a coordinates object of the form `{ x: 150, y: 310 }` and the raw\n * `event`. `cancel` receives the raw `event` as its single parameter.\n *\n * `start` is called on either `mousedown` or `touchstart`. After this event, `$swipe` is\n * watching for `touchmove` or `mousemove` events. These events are ignored until the total\n * distance moved in either dimension exceeds a small threshold.\n *\n * Once this threshold is exceeded, either the horizontal or vertical delta is greater.\n * - If the horizontal distance is greater, this is a swipe and `move` and `end` events follow.\n * - If the vertical distance is greater, this is a scroll, and we let the browser take over.\n * A `cancel` event is sent.\n *\n * `move` is called on `mousemove` and `touchmove` after the above logic has determined that\n * a swipe is in progress.\n *\n * `end` is called when a swipe is successfully completed with a `touchend` or `mouseup`.\n *\n * `cancel` is called either on a `touchcancel` from the browser, or when we begin scrolling\n * as described above.\n *\n */\n bind: function(element, eventHandlers, pointerTypes) {\n // Absolute total movement, used to control swipe vs. scroll.\n var totalX, totalY;\n // Coordinates of the start position.\n var startCoords;\n // Last event's position.\n var lastPos;\n // Whether a swipe is active.\n var active = false;\n\n pointerTypes = pointerTypes || ['mouse', 'touch'];\n element.on(getEvents(pointerTypes, 'start'), function(event) {\n startCoords = getCoordinates(event);\n active = true;\n totalX = 0;\n totalY = 0;\n lastPos = startCoords;\n eventHandlers['start'] && eventHandlers['start'](startCoords, event);\n });\n var events = getEvents(pointerTypes, 'cancel');\n if (events) {\n element.on(events, function(event) {\n active = false;\n eventHandlers['cancel'] && eventHandlers['cancel'](event);\n });\n }\n\n element.on(getEvents(pointerTypes, 'move'), function(event) {\n if (!active) return;\n\n // Android will send a touchcancel if it thinks we're starting to scroll.\n // So when the total distance (+ or - or both) exceeds 10px in either direction,\n // we either:\n // - On totalX > totalY, we send preventDefault() and treat this as a swipe.\n // - On totalY > totalX, we let the browser handle it as a scroll.\n\n if (!startCoords) return;\n var coords = getCoordinates(event);\n\n totalX += Math.abs(coords.x - lastPos.x);\n totalY += Math.abs(coords.y - lastPos.y);\n\n lastPos = coords;\n\n if (totalX < MOVE_BUFFER_RADIUS && totalY < MOVE_BUFFER_RADIUS) {\n return;\n }\n\n // One of totalX or totalY has exceeded the buffer, so decide on swipe vs. scroll.\n if (totalY > totalX) {\n // Allow native scrolling to take over.\n active = false;\n eventHandlers['cancel'] && eventHandlers['cancel'](event);\n return;\n } else {\n // Prevent the browser from scrolling.\n event.preventDefault();\n eventHandlers['move'] && eventHandlers['move'](coords, event);\n }\n });\n\n element.on(getEvents(pointerTypes, 'end'), function(event) {\n if (!active) return;\n active = false;\n eventHandlers['end'] && eventHandlers['end'](getCoordinates(event), event);\n });\n }\n };\n}]);\n\n/* global ngTouch: false,\n nodeName_: false\n*/\n\n/**\n * @ngdoc directive\n * @name ngClick\n *\n * @description\n * A more powerful replacement for the default ngClick designed to be used on touchscreen\n * devices. Most mobile browsers wait about 300ms after a tap-and-release before sending\n * the click event. This version handles them immediately, and then prevents the\n * following click event from propagating.\n *\n * Requires the {@link ngTouch `ngTouch`} module to be installed.\n *\n * This directive can fall back to using an ordinary click event, and so works on desktop\n * browsers as well as mobile.\n *\n * This directive also sets the CSS class `ng-click-active` while the element is being held\n * down (by a mouse click or touch) so you can restyle the depressed element if you wish.\n *\n * @element ANY\n * @param {expression} ngClick {@link guide/expression Expression} to evaluate\n * upon tap. (Event object is available as `$event`)\n *\n * @example\n
\n \n \n count: {{ count }}\n \n \n angular.module('ngClickExample', ['ngTouch']);\n \n \n */\n\nngTouch.config(['$provide', function($provide) {\n $provide.decorator('ngClickDirective', ['$delegate', function($delegate) {\n // drop the default ngClick directive\n $delegate.shift();\n return $delegate;\n }]);\n}]);\n\nngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',\n function($parse, $timeout, $rootElement) {\n var TAP_DURATION = 750; // Shorter than 750ms is a tap, longer is a taphold or drag.\n var MOVE_TOLERANCE = 12; // 12px seems to work in most mobile browsers.\n var PREVENT_DURATION = 2500; // 2.5 seconds maximum from preventGhostClick call to click\n var CLICKBUSTER_THRESHOLD = 25; // 25 pixels in any dimension is the limit for busting clicks.\n\n var ACTIVE_CLASS_NAME = 'ng-click-active';\n var lastPreventedTime;\n var touchCoordinates;\n var lastLabelClickCoordinates;\n\n\n // TAP EVENTS AND GHOST CLICKS\n //\n // Why tap events?\n // Mobile browsers detect a tap, then wait a moment (usually ~300ms) to see if you're\n // double-tapping, and then fire a click event.\n //\n // This delay sucks and makes mobile apps feel unresponsive.\n // So we detect touchstart, touchcancel and touchend ourselves and determine when\n // the user has tapped on something.\n //\n // What happens when the browser then generates a click event?\n // The browser, of course, also detects the tap and fires a click after a delay. This results in\n // tapping/clicking twice. We do \"clickbusting\" to prevent it.\n //\n // How does it work?\n // We attach global touchstart and click handlers, that run during the capture (early) phase.\n // So the sequence for a tap is:\n // - global touchstart: Sets an \"allowable region\" at the point touched.\n // - element's touchstart: Starts a touch\n // (- touchcancel ends the touch, no click follows)\n // - element's touchend: Determines if the tap is valid (didn't move too far away, didn't hold\n // too long) and fires the user's tap handler. The touchend also calls preventGhostClick().\n // - preventGhostClick() removes the allowable region the global touchstart created.\n // - The browser generates a click event.\n // - The global click handler catches the click, and checks whether it was in an allowable region.\n // - If preventGhostClick was called, the region will have been removed, the click is busted.\n // - If the region is still there, the click proceeds normally. Therefore clicks on links and\n // other elements without ngTap on them work normally.\n //\n // This is an ugly, terrible hack!\n // Yeah, tell me about it. The alternatives are using the slow click events, or making our users\n // deal with the ghost clicks, so I consider this the least of evils. Fortunately Angular\n // encapsulates this ugly logic away from the user.\n //\n // Why not just put click handlers on the element?\n // We do that too, just to be sure. If the tap event caused the DOM to change,\n // it is possible another element is now in that position. To take account for these possibly\n // distinct elements, the handlers are global and care only about coordinates.\n\n // Checks if the coordinates are close enough to be within the region.\n function hit(x1, y1, x2, y2) {\n return Math.abs(x1 - x2) < CLICKBUSTER_THRESHOLD && Math.abs(y1 - y2) < CLICKBUSTER_THRESHOLD;\n }\n\n // Checks a list of allowable regions against a click location.\n // Returns true if the click should be allowed.\n // Splices out the allowable region from the list after it has been used.\n function checkAllowableRegions(touchCoordinates, x, y) {\n for (var i = 0; i < touchCoordinates.length; i += 2) {\n if (hit(touchCoordinates[i], touchCoordinates[i + 1], x, y)) {\n touchCoordinates.splice(i, i + 2);\n return true; // allowable region\n }\n }\n return false; // No allowable region; bust it.\n }\n\n // Global click handler that prevents the click if it's in a bustable zone and preventGhostClick\n // was called recently.\n function onClick(event) {\n if (Date.now() - lastPreventedTime > PREVENT_DURATION) {\n return; // Too old.\n }\n\n var touches = event.touches && event.touches.length ? event.touches : [event];\n var x = touches[0].clientX;\n var y = touches[0].clientY;\n // Work around desktop Webkit quirk where clicking a label will fire two clicks (on the label\n // and on the input element). Depending on the exact browser, this second click we don't want\n // to bust has either (0,0), negative coordinates, or coordinates equal to triggering label\n // click event\n if (x < 1 && y < 1) {\n return; // offscreen\n }\n if (lastLabelClickCoordinates &&\n lastLabelClickCoordinates[0] === x && lastLabelClickCoordinates[1] === y) {\n return; // input click triggered by label click\n }\n // reset label click coordinates on first subsequent click\n if (lastLabelClickCoordinates) {\n lastLabelClickCoordinates = null;\n }\n // remember label click coordinates to prevent click busting of trigger click event on input\n if (nodeName_(event.target) === 'label') {\n lastLabelClickCoordinates = [x, y];\n }\n\n // Look for an allowable region containing this click.\n // If we find one, that means it was created by touchstart and not removed by\n // preventGhostClick, so we don't bust it.\n if (checkAllowableRegions(touchCoordinates, x, y)) {\n return;\n }\n\n // If we didn't find an allowable region, bust the click.\n event.stopPropagation();\n event.preventDefault();\n\n // Blur focused form elements\n event.target && event.target.blur && event.target.blur();\n }\n\n\n // Global touchstart handler that creates an allowable region for a click event.\n // This allowable region can be removed by preventGhostClick if we want to bust it.\n function onTouchStart(event) {\n var touches = event.touches && event.touches.length ? event.touches : [event];\n var x = touches[0].clientX;\n var y = touches[0].clientY;\n touchCoordinates.push(x, y);\n\n $timeout(function() {\n // Remove the allowable region.\n for (var i = 0; i < touchCoordinates.length; i += 2) {\n if (touchCoordinates[i] == x && touchCoordinates[i + 1] == y) {\n touchCoordinates.splice(i, i + 2);\n return;\n }\n }\n }, PREVENT_DURATION, false);\n }\n\n // On the first call, attaches some event handlers. Then whenever it gets called, it creates a\n // zone around the touchstart where clicks will get busted.\n function preventGhostClick(x, y) {\n if (!touchCoordinates) {\n $rootElement[0].addEventListener('click', onClick, true);\n $rootElement[0].addEventListener('touchstart', onTouchStart, true);\n touchCoordinates = [];\n }\n\n lastPreventedTime = Date.now();\n\n checkAllowableRegions(touchCoordinates, x, y);\n }\n\n // Actual linking function.\n return function(scope, element, attr) {\n var clickHandler = $parse(attr.ngClick),\n tapping = false,\n tapElement, // Used to blur the element after a tap.\n startTime, // Used to check if the tap was held too long.\n touchStartX,\n touchStartY;\n\n function resetState() {\n tapping = false;\n element.removeClass(ACTIVE_CLASS_NAME);\n }\n\n element.on('touchstart', function(event) {\n tapping = true;\n tapElement = event.target ? event.target : event.srcElement; // IE uses srcElement.\n // Hack for Safari, which can target text nodes instead of containers.\n if (tapElement.nodeType == 3) {\n tapElement = tapElement.parentNode;\n }\n\n element.addClass(ACTIVE_CLASS_NAME);\n\n startTime = Date.now();\n\n // Use jQuery originalEvent\n var originalEvent = event.originalEvent || event;\n var touches = originalEvent.touches && originalEvent.touches.length ? originalEvent.touches : [originalEvent];\n var e = touches[0];\n touchStartX = e.clientX;\n touchStartY = e.clientY;\n });\n\n element.on('touchcancel', function(event) {\n resetState();\n });\n\n element.on('touchend', function(event) {\n var diff = Date.now() - startTime;\n\n // Use jQuery originalEvent\n var originalEvent = event.originalEvent || event;\n var touches = (originalEvent.changedTouches && originalEvent.changedTouches.length) ?\n originalEvent.changedTouches :\n ((originalEvent.touches && originalEvent.touches.length) ? originalEvent.touches : [originalEvent]);\n var e = touches[0];\n var x = e.clientX;\n var y = e.clientY;\n var dist = Math.sqrt(Math.pow(x - touchStartX, 2) + Math.pow(y - touchStartY, 2));\n\n if (tapping && diff < TAP_DURATION && dist < MOVE_TOLERANCE) {\n // Call preventGhostClick so the clickbuster will catch the corresponding click.\n preventGhostClick(x, y);\n\n // Blur the focused element (the button, probably) before firing the callback.\n // This doesn't work perfectly on Android Chrome, but seems to work elsewhere.\n // I couldn't get anything to work reliably on Android Chrome.\n if (tapElement) {\n tapElement.blur();\n }\n\n if (!angular.isDefined(attr.disabled) || attr.disabled === false) {\n element.triggerHandler('click', [event]);\n }\n }\n\n resetState();\n });\n\n // Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click\n // something else nearby.\n element.onclick = function(event) { };\n\n // Actual click handler.\n // There are three different kinds of clicks, only two of which reach this point.\n // - On desktop browsers without touch events, their clicks will always come here.\n // - On mobile browsers, the simulated \"fast\" click will call this.\n // - But the browser's follow-up slow click will be \"busted\" before it reaches this handler.\n // Therefore it's safe to use this directive on both mobile and desktop.\n element.on('click', function(event, touchend) {\n scope.$apply(function() {\n clickHandler(scope, {$event: (touchend || event)});\n });\n });\n\n element.on('mousedown', function(event) {\n element.addClass(ACTIVE_CLASS_NAME);\n });\n\n element.on('mousemove mouseup', function(event) {\n element.removeClass(ACTIVE_CLASS_NAME);\n });\n\n };\n}]);\n\n/* global ngTouch: false */\n\n/**\n * @ngdoc directive\n * @name ngSwipeLeft\n *\n * @description\n * Specify custom behavior when an element is swiped to the left on a touchscreen device.\n * A leftward swipe is a quick, right-to-left slide of the finger.\n * Though ngSwipeLeft is designed for touch-based devices, it will work with a mouse click and drag\n * too.\n *\n * To disable the mouse click and drag functionality, add `ng-swipe-disable-mouse` to\n * the `ng-swipe-left` or `ng-swipe-right` DOM Element.\n *\n * Requires the {@link ngTouch `ngTouch`} module to be installed.\n *\n * @element ANY\n * @param {expression} ngSwipeLeft {@link guide/expression Expression} to evaluate\n * upon left swipe. (Event object is available as `$event`)\n *\n * @example\n
\n \n \n Some list content, like an email in the inbox\n
\n \n \n \n
\n \n \n angular.module('ngSwipeLeftExample', ['ngTouch']);\n \n \n */\n\n/**\n * @ngdoc directive\n * @name ngSwipeRight\n *\n * @description\n * Specify custom behavior when an element is swiped to the right on a touchscreen device.\n * A rightward swipe is a quick, left-to-right slide of the finger.\n * Though ngSwipeRight is designed for touch-based devices, it will work with a mouse click and drag\n * too.\n *\n * Requires the {@link ngTouch `ngTouch`} module to be installed.\n *\n * @element ANY\n * @param {expression} ngSwipeRight {@link guide/expression Expression} to evaluate\n * upon right swipe. (Event object is available as `$event`)\n *\n * @example\n
\n \n \n Some list content, like an email in the inbox\n
\n \n \n \n
\n \n \n angular.module('ngSwipeRightExample', ['ngTouch']);\n \n \n */\n\nfunction makeSwipeDirective(directiveName, direction, eventName) {\n ngTouch.directive(directiveName, ['$parse', '$swipe', function($parse, $swipe) {\n // The maximum vertical delta for a swipe should be less than 75px.\n var MAX_VERTICAL_DISTANCE = 75;\n // Vertical distance should not be more than a fraction of the horizontal distance.\n var MAX_VERTICAL_RATIO = 0.3;\n // At least a 30px lateral motion is necessary for a swipe.\n var MIN_HORIZONTAL_DISTANCE = 30;\n\n return function(scope, element, attr) {\n var swipeHandler = $parse(attr[directiveName]);\n\n var startCoords, valid;\n\n function validSwipe(coords) {\n // Check that it's within the coordinates.\n // Absolute vertical distance must be within tolerances.\n // Horizontal distance, we take the current X - the starting X.\n // This is negative for leftward swipes and positive for rightward swipes.\n // After multiplying by the direction (-1 for left, +1 for right), legal swipes\n // (ie. same direction as the directive wants) will have a positive delta and\n // illegal ones a negative delta.\n // Therefore this delta must be positive, and larger than the minimum.\n if (!startCoords) return false;\n var deltaY = Math.abs(coords.y - startCoords.y);\n var deltaX = (coords.x - startCoords.x) * direction;\n return valid && // Short circuit for already-invalidated swipes.\n deltaY < MAX_VERTICAL_DISTANCE &&\n deltaX > 0 &&\n deltaX > MIN_HORIZONTAL_DISTANCE &&\n deltaY / deltaX < MAX_VERTICAL_RATIO;\n }\n\n var pointerTypes = ['touch'];\n if (!angular.isDefined(attr['ngSwipeDisableMouse'])) {\n pointerTypes.push('mouse');\n }\n $swipe.bind(element, {\n 'start': function(coords, event) {\n startCoords = coords;\n valid = true;\n },\n 'cancel': function(event) {\n valid = false;\n },\n 'end': function(coords, event) {\n if (validSwipe(coords)) {\n scope.$apply(function() {\n element.triggerHandler(eventName);\n swipeHandler(scope, {$event: event});\n });\n }\n }\n }, pointerTypes);\n };\n }]);\n}\n\n// Left is negative X-coordinate, right is positive.\nmakeSwipeDirective('ngSwipeLeft', -1, 'swipeleft');\nmakeSwipeDirective('ngSwipeRight', 1, 'swiperight');\n\n\n\n})(window, window.angular);\n\n/**\n * @license AngularJS v1.4.14\n * (c) 2010-2015 Google, Inc. http://angularjs.org\n * License: MIT\n */\n(function(window, angular, undefined) {'use strict';\n\n/* jshint ignore:start */\n// this code is in the core, but not in angular-messages.js\nvar isArray = angular.isArray;\nvar forEach = angular.forEach;\nvar isString = angular.isString;\nvar jqLite = angular.element;\n/* jshint ignore:end */\n\n/**\n * @ngdoc module\n * @name ngMessages\n * @description\n *\n * The `ngMessages` module provides enhanced support for displaying messages within templates\n * (typically within forms or when rendering message objects that return key/value data).\n * Instead of relying on JavaScript code and/or complex ng-if statements within your form template to\n * show and hide error messages specific to the state of an input field, the `ngMessages` and\n * `ngMessage` directives are designed to handle the complexity, inheritance and priority\n * sequencing based on the order of how the messages are defined in the template.\n *\n * Currently, the ngMessages module only contains the code for the `ngMessages`, `ngMessagesInclude`\n * `ngMessage` and `ngMessageExp` directives.\n *\n * # Usage\n * The `ngMessages` directive allows keys in a key/value collection to be associated with a child element\n * (or 'message') that will show or hide based on the truthiness of that key's value in the collection. A common use\n * case for `ngMessages` is to display error messages for inputs using the `$error` object exposed by the\n * {@link ngModel ngModel} directive.\n *\n * The child elements of the `ngMessages` directive are matched to the collection keys by a `ngMessage` or\n * `ngMessageExp` directive. The value of these attributes must match a key in the collection that is provided by\n * the `ngMessages` directive.\n *\n * Consider the following example, which illustrates a typical use case of `ngMessages`. Within the form `myForm` we\n * have a text input named `myField` which is bound to the scope variable `field` using the {@link ngModel ngModel}\n * directive.\n *\n * The `myField` field is a required input of type `email` with a maximum length of 15 characters.\n *\n * ```html\n *
\n * ```\n *\n * In order to show error messages corresponding to `myField` we first create an element with an `ngMessages` attribute\n * set to the `$error` object owned by the `myField` input in our `myForm` form.\n *\n * Within this element we then create separate elements for each of the possible errors that `myField` could have.\n * The `ngMessage` attribute is used to declare which element(s) will appear for which error - for example,\n * setting `ng-message=\"required\"` specifies that this particular element should be displayed when there\n * is no value present for the required field `myField` (because the key `required` will be `true` in the object\n * `myForm.myField.$error`).\n *\n * ### Message order\n *\n * By default, `ngMessages` will only display one message for a particular key/value collection at any time. If more\n * than one message (or error) key is currently true, then which message is shown is determined by the order of messages\n * in the HTML template code (messages declared first are prioritised). This mechanism means the developer does not have\n * to prioritise messages using custom JavaScript code.\n *\n * Given the following error object for our example (which informs us that the field `myField` currently has both the\n * `required` and `email` errors):\n *\n * ```javascript\n * \n * myField.$error = { required : true, email: true, maxlength: false };\n * ```\n * The `required` message will be displayed to the user since it appears before the `email` message in the DOM.\n * Once the user types a single character, the `required` message will disappear (since the field now has a value)\n * but the `email` message will be visible because it is still applicable.\n *\n * ### Displaying multiple messages at the same time\n *\n * While `ngMessages` will by default only display one error element at a time, the `ng-messages-multiple` attribute can\n * be applied to the `ngMessages` container element to cause it to display all applicable error messages at once:\n *\n * ```html\n * \n *
...
\n *\n * \n *
...\n * ```\n *\n * ## Reusing and Overriding Messages\n * In addition to prioritization, ngMessages also allows for including messages from a remote or an inline\n * template. This allows for generic collection of messages to be reused across multiple parts of an\n * application.\n *\n * ```html\n * \n *\n *
\n * ```\n *\n * However, including generic messages may not be useful enough to match all input fields, therefore,\n * `ngMessages` provides the ability to override messages defined in the remote template by redefining\n * them within the directive container.\n *\n * ```html\n * \n * \n *\n *
\n * ```\n *\n * In the example HTML code above the message that is set on required will override the corresponding\n * required message defined within the remote template. Therefore, with particular input fields (such\n * email addresses, date fields, autocomplete inputs, etc...), specialized error messages can be applied\n * while more generic messages can be used to handle other, more general input errors.\n *\n * ## Dynamic Messaging\n * ngMessages also supports using expressions to dynamically change key values. Using arrays and\n * repeaters to list messages is also supported. This means that the code below will be able to\n * fully adapt itself and display the appropriate message when any of the expression data changes:\n *\n * ```html\n *
\n * ```\n *\n * The `errorMessage.type` expression can be a string value or it can be an array so\n * that multiple errors can be associated with a single error message:\n *\n * ```html\n *
\n *
\n *
You did not enter your email address
\n *
\n * Your email must be between 5 and 100 characters long\n *
\n *
\n * ```\n *\n * Feel free to use other structural directives such as ng-if and ng-switch to further control\n * what messages are active and when. Be careful, if you place ng-message on the same element\n * as these structural directives, Angular may not be able to determine if a message is active\n * or not. Therefore it is best to place the ng-message on a child element of the structural\n * directive.\n *\n * ```html\n *
\n *
\n *
Please enter something
\n *
\n *
\n * ```\n *\n * ## Animations\n * If the `ngAnimate` module is active within the application then the `ngMessages`, `ngMessage` and\n * `ngMessageExp` directives will trigger animations whenever any messages are added and removed from\n * the DOM by the `ngMessages` directive.\n *\n * Whenever the `ngMessages` directive contains one or more visible messages then the `.ng-active` CSS\n * class will be added to the element. The `.ng-inactive` CSS class will be applied when there are no\n * messages present. Therefore, CSS transitions and keyframes as well as JavaScript animations can\n * hook into the animations whenever these classes are added/removed.\n *\n * Let's say that our HTML code for our messages container looks like so:\n *\n * ```html\n *
\n * ```\n *\n * Then the CSS animation code for the message container looks like so:\n *\n * ```css\n * .my-messages {\n * transition:1s linear all;\n * }\n * .my-messages.ng-active {\n * // messages are visible\n * }\n * .my-messages.ng-inactive {\n * // messages are hidden\n * }\n * ```\n *\n * Whenever an inner message is attached (becomes visible) or removed (becomes hidden) then the enter\n * and leave animation is triggered for each particular element bound to the `ngMessage` directive.\n *\n * Therefore, the CSS code for the inner messages looks like so:\n *\n * ```css\n * .some-message {\n * transition:1s linear all;\n * }\n *\n * .some-message.ng-enter {}\n * .some-message.ng-enter.ng-enter-active {}\n *\n * .some-message.ng-leave {}\n * .some-message.ng-leave.ng-leave-active {}\n * ```\n *\n * {@link ngAnimate Click here} to learn how to use JavaScript animations or to learn more about ngAnimate.\n */\nangular.module('ngMessages', [])\n\n /**\n * @ngdoc directive\n * @module ngMessages\n * @name ngMessages\n * @restrict AE\n *\n * @description\n * `ngMessages` is a directive that is designed to show and hide messages based on the state\n * of a key/value object that it listens on. The directive itself complements error message\n * reporting with the `ngModel` $error object (which stores a key/value state of validation errors).\n *\n * `ngMessages` manages the state of internal messages within its container element. The internal\n * messages use the `ngMessage` directive and will be inserted/removed from the page depending\n * on if they're present within the key/value object. By default, only one message will be displayed\n * at a time and this depends on the prioritization of the messages within the template. (This can\n * be changed by using the `ng-messages-multiple` or `multiple` attribute on the directive container.)\n *\n * A remote template can also be used to promote message reusability and messages can also be\n * overridden.\n *\n * {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`.\n *\n * @usage\n * ```html\n * \n *
\n * ...\n * ...\n * ...\n * \n *\n * \n *
\n * ...\n * ...\n * ...\n * \n * ```\n *\n * @param {string} ngMessages an angular expression evaluating to a key/value object\n * (this is typically the $error object on an ngModel instance).\n * @param {string=} ngMessagesMultiple|multiple when set, all messages will be displayed with true\n *\n * @example\n *
\n * \n * \n * \n * \n * angular.module('ngMessagesExample', ['ngMessages']);\n * \n * \n */\n .directive('ngMessages', ['$animate', function($animate) {\n var ACTIVE_CLASS = 'ng-active';\n var INACTIVE_CLASS = 'ng-inactive';\n\n return {\n require: 'ngMessages',\n restrict: 'AE',\n controller: ['$element', '$scope', '$attrs', function($element, $scope, $attrs) {\n var ctrl = this;\n var latestKey = 0;\n var nextAttachId = 0;\n\n this.getAttachId = function getAttachId() { return nextAttachId++; };\n\n var messages = this.messages = {};\n var renderLater, cachedCollection;\n\n this.render = function(collection) {\n collection = collection || {};\n\n renderLater = false;\n cachedCollection = collection;\n\n // this is true if the attribute is empty or if the attribute value is truthy\n var multiple = isAttrTruthy($scope, $attrs.ngMessagesMultiple) ||\n isAttrTruthy($scope, $attrs.multiple);\n\n var unmatchedMessages = [];\n var matchedKeys = {};\n var messageItem = ctrl.head;\n var messageFound = false;\n var totalMessages = 0;\n\n // we use != instead of !== to allow for both undefined and null values\n while (messageItem != null) {\n totalMessages++;\n var messageCtrl = messageItem.message;\n\n var messageUsed = false;\n if (!messageFound) {\n forEach(collection, function(value, key) {\n if (!messageUsed && truthy(value) && messageCtrl.test(key)) {\n // this is to prevent the same error name from showing up twice\n if (matchedKeys[key]) return;\n matchedKeys[key] = true;\n\n messageUsed = true;\n messageCtrl.attach();\n }\n });\n }\n\n if (messageUsed) {\n // unless we want to display multiple messages then we should\n // set a flag here to avoid displaying the next message in the list\n messageFound = !multiple;\n } else {\n unmatchedMessages.push(messageCtrl);\n }\n\n messageItem = messageItem.next;\n }\n\n forEach(unmatchedMessages, function(messageCtrl) {\n messageCtrl.detach();\n });\n\n unmatchedMessages.length !== totalMessages\n ? $animate.setClass($element, ACTIVE_CLASS, INACTIVE_CLASS)\n : $animate.setClass($element, INACTIVE_CLASS, ACTIVE_CLASS);\n };\n\n $scope.$watchCollection($attrs.ngMessages || $attrs['for'], ctrl.render);\n\n // If the element is destroyed, proactively destroy all the currently visible messages\n $element.on('$destroy', function() {\n forEach(messages, function(item) {\n item.message.detach();\n });\n });\n\n this.reRender = function() {\n if (!renderLater) {\n renderLater = true;\n $scope.$evalAsync(function() {\n if (renderLater) {\n cachedCollection && ctrl.render(cachedCollection);\n }\n });\n }\n };\n\n this.register = function(comment, messageCtrl) {\n var nextKey = latestKey.toString();\n messages[nextKey] = {\n message: messageCtrl\n };\n insertMessageNode($element[0], comment, nextKey);\n comment.$$ngMessageNode = nextKey;\n latestKey++;\n\n ctrl.reRender();\n };\n\n this.deregister = function(comment) {\n var key = comment.$$ngMessageNode;\n delete comment.$$ngMessageNode;\n removeMessageNode($element[0], comment, key);\n delete messages[key];\n ctrl.reRender();\n };\n\n function findPreviousMessage(parent, comment) {\n var prevNode = comment;\n var parentLookup = [];\n\n while (prevNode && prevNode !== parent) {\n var prevKey = prevNode.$$ngMessageNode;\n if (prevKey && prevKey.length) {\n return messages[prevKey];\n }\n\n // dive deeper into the DOM and examine its children for any ngMessage\n // comments that may be in an element that appears deeper in the list\n if (prevNode.childNodes.length && parentLookup.indexOf(prevNode) == -1) {\n parentLookup.push(prevNode);\n prevNode = prevNode.childNodes[prevNode.childNodes.length - 1];\n } else if (prevNode.previousSibling) {\n prevNode = prevNode.previousSibling;\n } else {\n prevNode = prevNode.parentNode;\n parentLookup.push(prevNode);\n }\n }\n }\n\n function insertMessageNode(parent, comment, key) {\n var messageNode = messages[key];\n if (!ctrl.head) {\n ctrl.head = messageNode;\n } else {\n var match = findPreviousMessage(parent, comment);\n if (match) {\n messageNode.next = match.next;\n match.next = messageNode;\n } else {\n messageNode.next = ctrl.head;\n ctrl.head = messageNode;\n }\n }\n }\n\n function removeMessageNode(parent, comment, key) {\n var messageNode = messages[key];\n\n var match = findPreviousMessage(parent, comment);\n if (match) {\n match.next = messageNode.next;\n } else {\n ctrl.head = messageNode.next;\n }\n }\n }]\n };\n\n function isAttrTruthy(scope, attr) {\n return (isString(attr) && attr.length === 0) || //empty attribute\n truthy(scope.$eval(attr));\n }\n\n function truthy(val) {\n return isString(val) ? val.length : !!val;\n }\n }])\n\n /**\n * @ngdoc directive\n * @name ngMessagesInclude\n * @restrict AE\n * @scope\n *\n * @description\n * `ngMessagesInclude` is a directive with the purpose to import existing ngMessage template\n * code from a remote template and place the downloaded template code into the exact spot\n * that the ngMessagesInclude directive is placed within the ngMessages container. This allows\n * for a series of pre-defined messages to be reused and also allows for the developer to\n * determine what messages are overridden due to the placement of the ngMessagesInclude directive.\n *\n * @usage\n * ```html\n * \n *
\n * ...\n * \n *\n * \n *
\n * ...\n * \n * ```\n *\n * {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`.\n *\n * @param {string} ngMessagesInclude|src a string value corresponding to the remote template.\n */\n .directive('ngMessagesInclude',\n ['$templateRequest', '$document', '$compile', function($templateRequest, $document, $compile) {\n\n return {\n restrict: 'AE',\n require: '^^ngMessages', // we only require this for validation sake\n link: function($scope, element, attrs) {\n var src = attrs.ngMessagesInclude || attrs.src;\n $templateRequest(src).then(function(html) {\n $compile(html)($scope, function(contents) {\n element.after(contents);\n\n // the anchor is placed for debugging purposes\n var anchor = jqLite($document[0].createComment(' ngMessagesInclude: ' + src + ' '));\n element.after(anchor);\n\n // we don't want to pollute the DOM anymore by keeping an empty directive element\n element.remove();\n });\n });\n }\n };\n }])\n\n /**\n * @ngdoc directive\n * @name ngMessage\n * @restrict AE\n * @scope\n *\n * @description\n * `ngMessage` is a directive with the purpose to show and hide a particular message.\n * For `ngMessage` to operate, a parent `ngMessages` directive on a parent DOM element\n * must be situated since it determines which messages are visible based on the state\n * of the provided key/value map that `ngMessages` listens on.\n *\n * More information about using `ngMessage` can be found in the\n * {@link module:ngMessages `ngMessages` module documentation}.\n *\n * @usage\n * ```html\n * \n *
\n * ...\n * ...\n * \n *\n * \n *
\n * ...\n * ...\n * \n * ```\n *\n * @param {expression} ngMessage|when a string value corresponding to the message key.\n */\n .directive('ngMessage', ngMessageDirectiveFactory('AE'))\n\n\n /**\n * @ngdoc directive\n * @name ngMessageExp\n * @restrict AE\n * @scope\n *\n * @description\n * `ngMessageExp` is a directive with the purpose to show and hide a particular message.\n * For `ngMessageExp` to operate, a parent `ngMessages` directive on a parent DOM element\n * must be situated since it determines which messages are visible based on the state\n * of the provided key/value map that `ngMessages` listens on.\n *\n * @usage\n * ```html\n * \n *
\n * ...\n * \n *\n * \n *
\n * ...\n * \n * ```\n *\n * {@link module:ngMessages Click here} to learn more about `ngMessages` and `ngMessage`.\n *\n * @param {expression} ngMessageExp|whenExp an expression value corresponding to the message key.\n */\n .directive('ngMessageExp', ngMessageDirectiveFactory('A'));\n\nfunction ngMessageDirectiveFactory(restrict) {\n return ['$animate', function($animate) {\n return {\n restrict: 'AE',\n transclude: 'element',\n terminal: true,\n require: '^^ngMessages',\n link: function(scope, element, attrs, ngMessagesCtrl, $transclude) {\n var commentNode = element[0];\n\n var records;\n var staticExp = attrs.ngMessage || attrs.when;\n var dynamicExp = attrs.ngMessageExp || attrs.whenExp;\n var assignRecords = function(items) {\n records = items\n ? (isArray(items)\n ? items\n : items.split(/[\\s,]+/))\n : null;\n ngMessagesCtrl.reRender();\n };\n\n if (dynamicExp) {\n assignRecords(scope.$eval(dynamicExp));\n scope.$watchCollection(dynamicExp, assignRecords);\n } else {\n assignRecords(staticExp);\n }\n\n var currentElement, messageCtrl;\n ngMessagesCtrl.register(commentNode, messageCtrl = {\n test: function(name) {\n return contains(records, name);\n },\n attach: function() {\n if (!currentElement) {\n $transclude(scope, function(elm) {\n $animate.enter(elm, null, element);\n currentElement = elm;\n\n // Each time we attach this node to a message we get a new id that we can match\n // when we are destroying the node later.\n var $$attachId = currentElement.$$attachId = ngMessagesCtrl.getAttachId();\n\n // in the event that the element or a parent element is destroyed\n // by another structural directive then it's time\n // to deregister the message from the controller\n currentElement.on('$destroy', function() {\n if (currentElement && currentElement.$$attachId === $$attachId) {\n ngMessagesCtrl.deregister(commentNode);\n messageCtrl.detach();\n }\n });\n });\n }\n },\n detach: function() {\n if (currentElement) {\n var elm = currentElement;\n currentElement = null;\n $animate.leave(elm);\n }\n }\n });\n }\n };\n }];\n\n function contains(collection, key) {\n if (collection) {\n return isArray(collection)\n ? collection.indexOf(key) >= 0\n : collection.hasOwnProperty(key);\n }\n }\n}\n\n\n})(window, window.angular);\n\n/*\n * angular-ui-bootstrap\n * http://angular-ui.github.io/bootstrap/\n\n * Version: 2.2.0 - 2016-10-10\n * License: MIT\n */angular.module(\"ui.bootstrap\", [\"ui.bootstrap.tpls\", \"ui.bootstrap.collapse\",\"ui.bootstrap.tabindex\",\"ui.bootstrap.accordion\",\"ui.bootstrap.alert\",\"ui.bootstrap.buttons\",\"ui.bootstrap.carousel\",\"ui.bootstrap.dateparser\",\"ui.bootstrap.isClass\",\"ui.bootstrap.datepicker\",\"ui.bootstrap.position\",\"ui.bootstrap.datepickerPopup\",\"ui.bootstrap.debounce\",\"ui.bootstrap.dropdown\",\"ui.bootstrap.stackedMap\",\"ui.bootstrap.modal\",\"ui.bootstrap.paging\",\"ui.bootstrap.pager\",\"ui.bootstrap.pagination\",\"ui.bootstrap.tooltip\",\"ui.bootstrap.popover\",\"ui.bootstrap.progressbar\",\"ui.bootstrap.rating\",\"ui.bootstrap.tabs\",\"ui.bootstrap.timepicker\",\"ui.bootstrap.typeahead\"]);\nangular.module(\"ui.bootstrap.tpls\", [\"uib/template/accordion/accordion-group.html\",\"uib/template/accordion/accordion.html\",\"uib/template/alert/alert.html\",\"uib/template/carousel/carousel.html\",\"uib/template/carousel/slide.html\",\"uib/template/datepicker/datepicker.html\",\"uib/template/datepicker/day.html\",\"uib/template/datepicker/month.html\",\"uib/template/datepicker/year.html\",\"uib/template/datepickerPopup/popup.html\",\"uib/template/modal/window.html\",\"uib/template/pager/pager.html\",\"uib/template/pagination/pagination.html\",\"uib/template/tooltip/tooltip-html-popup.html\",\"uib/template/tooltip/tooltip-popup.html\",\"uib/template/tooltip/tooltip-template-popup.html\",\"uib/template/popover/popover-html.html\",\"uib/template/popover/popover-template.html\",\"uib/template/popover/popover.html\",\"uib/template/progressbar/bar.html\",\"uib/template/progressbar/progress.html\",\"uib/template/progressbar/progressbar.html\",\"uib/template/rating/rating.html\",\"uib/template/tabs/tab.html\",\"uib/template/tabs/tabset.html\",\"uib/template/timepicker/timepicker.html\",\"uib/template/typeahead/typeahead-match.html\",\"uib/template/typeahead/typeahead-popup.html\"]);\nangular.module('ui.bootstrap.collapse', [])\n\n .directive('uibCollapse', ['$animate', '$q', '$parse', '$injector', function($animate, $q, $parse, $injector) {\n var $animateCss = $injector.has('$animateCss') ? $injector.get('$animateCss') : null;\n return {\n link: function(scope, element, attrs) {\n var expandingExpr = $parse(attrs.expanding),\n expandedExpr = $parse(attrs.expanded),\n collapsingExpr = $parse(attrs.collapsing),\n collapsedExpr = $parse(attrs.collapsed),\n horizontal = false,\n css = {},\n cssTo = {};\n\n init();\n\n function init() {\n horizontal = !!('horizontal' in attrs);\n if (horizontal) {\n css = {\n width: ''\n };\n cssTo = {width: '0'};\n } else {\n css = {\n height: ''\n };\n cssTo = {height: '0'};\n }\n if (!scope.$eval(attrs.uibCollapse)) {\n element.addClass('in')\n .addClass('collapse')\n .attr('aria-expanded', true)\n .attr('aria-hidden', false)\n .css(css);\n }\n }\n\n function getScrollFromElement(element) {\n if (horizontal) {\n return {width: element.scrollWidth + 'px'};\n }\n return {height: element.scrollHeight + 'px'};\n }\n\n function expand() {\n if (element.hasClass('collapse') && element.hasClass('in')) {\n return;\n }\n\n $q.resolve(expandingExpr(scope))\n .then(function() {\n element.removeClass('collapse')\n .addClass('collapsing')\n .attr('aria-expanded', true)\n .attr('aria-hidden', false);\n\n if ($animateCss) {\n $animateCss(element, {\n addClass: 'in',\n easing: 'ease',\n css: {\n overflow: 'hidden'\n },\n to: getScrollFromElement(element[0])\n }).start()['finally'](expandDone);\n } else {\n $animate.addClass(element, 'in', {\n css: {\n overflow: 'hidden'\n },\n to: getScrollFromElement(element[0])\n }).then(expandDone);\n }\n });\n }\n\n function expandDone() {\n element.removeClass('collapsing')\n .addClass('collapse')\n .css(css);\n expandedExpr(scope);\n }\n\n function collapse() {\n if (!element.hasClass('collapse') && !element.hasClass('in')) {\n return collapseDone();\n }\n\n $q.resolve(collapsingExpr(scope))\n .then(function() {\n element\n // IMPORTANT: The width must be set before adding \"collapsing\" class.\n // Otherwise, the browser attempts to animate from width 0 (in\n // collapsing class) to the given width here.\n .css(getScrollFromElement(element[0]))\n // initially all panel collapse have the collapse class, this removal\n // prevents the animation from jumping to collapsed state\n .removeClass('collapse')\n .addClass('collapsing')\n .attr('aria-expanded', false)\n .attr('aria-hidden', true);\n\n if ($animateCss) {\n $animateCss(element, {\n removeClass: 'in',\n to: cssTo\n }).start()['finally'](collapseDone);\n } else {\n $animate.removeClass(element, 'in', {\n to: cssTo\n }).then(collapseDone);\n }\n });\n }\n\n function collapseDone() {\n element.css(cssTo); // Required so that collapse works when animation is disabled\n element.removeClass('collapsing')\n .addClass('collapse');\n collapsedExpr(scope);\n }\n\n scope.$watch(attrs.uibCollapse, function(shouldCollapse) {\n if (shouldCollapse) {\n collapse();\n } else {\n expand();\n }\n });\n }\n };\n }]);\n\nangular.module('ui.bootstrap.tabindex', [])\n\n.directive('uibTabindexToggle', function() {\n return {\n restrict: 'A',\n link: function(scope, elem, attrs) {\n attrs.$observe('disabled', function(disabled) {\n attrs.$set('tabindex', disabled ? -1 : null);\n });\n }\n };\n});\n\nangular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse', 'ui.bootstrap.tabindex'])\n\n.constant('uibAccordionConfig', {\n closeOthers: true\n})\n\n.controller('UibAccordionController', ['$scope', '$attrs', 'uibAccordionConfig', function($scope, $attrs, accordionConfig) {\n // This array keeps track of the accordion groups\n this.groups = [];\n\n // Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to\n this.closeOthers = function(openGroup) {\n var closeOthers = angular.isDefined($attrs.closeOthers) ?\n $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers;\n if (closeOthers) {\n angular.forEach(this.groups, function(group) {\n if (group !== openGroup) {\n group.isOpen = false;\n }\n });\n }\n };\n\n // This is called from the accordion-group directive to add itself to the accordion\n this.addGroup = function(groupScope) {\n var that = this;\n this.groups.push(groupScope);\n\n groupScope.$on('$destroy', function(event) {\n that.removeGroup(groupScope);\n });\n };\n\n // This is called from the accordion-group directive when to remove itself\n this.removeGroup = function(group) {\n var index = this.groups.indexOf(group);\n if (index !== -1) {\n this.groups.splice(index, 1);\n }\n };\n}])\n\n// The accordion directive simply sets up the directive controller\n// and adds an accordion CSS class to itself element.\n.directive('uibAccordion', function() {\n return {\n controller: 'UibAccordionController',\n controllerAs: 'accordion',\n transclude: true,\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/accordion/accordion.html';\n }\n };\n})\n\n// The accordion-group directive indicates a block of html that will expand and collapse in an accordion\n.directive('uibAccordionGroup', function() {\n return {\n require: '^uibAccordion', // We need this directive to be inside an accordion\n transclude: true, // It transcludes the contents of the directive into the template\n restrict: 'A',\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/accordion/accordion-group.html';\n },\n scope: {\n heading: '@', // Interpolate the heading attribute onto this scope\n panelClass: '@?', // Ditto with panelClass\n isOpen: '=?',\n isDisabled: '=?'\n },\n controller: function() {\n this.setHeading = function(element) {\n this.heading = element;\n };\n },\n link: function(scope, element, attrs, accordionCtrl) {\n element.addClass('panel');\n accordionCtrl.addGroup(scope);\n\n scope.openClass = attrs.openClass || 'panel-open';\n scope.panelClass = attrs.panelClass || 'panel-default';\n scope.$watch('isOpen', function(value) {\n element.toggleClass(scope.openClass, !!value);\n if (value) {\n accordionCtrl.closeOthers(scope);\n }\n });\n\n scope.toggleOpen = function($event) {\n if (!scope.isDisabled) {\n if (!$event || $event.which === 32) {\n scope.isOpen = !scope.isOpen;\n }\n }\n };\n\n var id = 'accordiongroup-' + scope.$id + '-' + Math.floor(Math.random() * 10000);\n scope.headingId = id + '-tab';\n scope.panelId = id + '-panel';\n }\n };\n})\n\n// Use accordion-heading below an accordion-group to provide a heading containing HTML\n.directive('uibAccordionHeading', function() {\n return {\n transclude: true, // Grab the contents to be used as the heading\n template: '', // In effect remove this element!\n replace: true,\n require: '^uibAccordionGroup',\n link: function(scope, element, attrs, accordionGroupCtrl, transclude) {\n // Pass the heading to the accordion-group controller\n // so that it can be transcluded into the right place in the template\n // [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]\n accordionGroupCtrl.setHeading(transclude(scope, angular.noop));\n }\n };\n})\n\n// Use in the accordion-group template to indicate where you want the heading to be transcluded\n// You must provide the property on the accordion-group controller that will hold the transcluded element\n.directive('uibAccordionTransclude', function() {\n return {\n require: '^uibAccordionGroup',\n link: function(scope, element, attrs, controller) {\n scope.$watch(function() { return controller[attrs.uibAccordionTransclude]; }, function(heading) {\n if (heading) {\n var elem = angular.element(element[0].querySelector(getHeaderSelectors()));\n elem.html('');\n elem.append(heading);\n }\n });\n }\n };\n\n function getHeaderSelectors() {\n return 'uib-accordion-header,' +\n 'data-uib-accordion-header,' +\n 'x-uib-accordion-header,' +\n 'uib\\\\:accordion-header,' +\n '[uib-accordion-header],' +\n '[data-uib-accordion-header],' +\n '[x-uib-accordion-header]';\n }\n});\n\nangular.module('ui.bootstrap.alert', [])\n\n.controller('UibAlertController', ['$scope', '$element', '$attrs', '$interpolate', '$timeout', function($scope, $element, $attrs, $interpolate, $timeout) {\n $scope.closeable = !!$attrs.close;\n $element.addClass('alert');\n $attrs.$set('role', 'alert');\n if ($scope.closeable) {\n $element.addClass('alert-dismissible');\n }\n\n var dismissOnTimeout = angular.isDefined($attrs.dismissOnTimeout) ?\n $interpolate($attrs.dismissOnTimeout)($scope.$parent) : null;\n\n if (dismissOnTimeout) {\n $timeout(function() {\n $scope.close();\n }, parseInt(dismissOnTimeout, 10));\n }\n}])\n\n.directive('uibAlert', function() {\n return {\n controller: 'UibAlertController',\n controllerAs: 'alert',\n restrict: 'A',\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/alert/alert.html';\n },\n transclude: true,\n scope: {\n close: '&'\n }\n };\n});\n\nangular.module('ui.bootstrap.buttons', [])\n\n.constant('uibButtonConfig', {\n activeClass: 'active',\n toggleEvent: 'click'\n})\n\n.controller('UibButtonsController', ['uibButtonConfig', function(buttonConfig) {\n this.activeClass = buttonConfig.activeClass || 'active';\n this.toggleEvent = buttonConfig.toggleEvent || 'click';\n}])\n\n.directive('uibBtnRadio', ['$parse', function($parse) {\n return {\n require: ['uibBtnRadio', 'ngModel'],\n controller: 'UibButtonsController',\n controllerAs: 'buttons',\n link: function(scope, element, attrs, ctrls) {\n var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n var uncheckableExpr = $parse(attrs.uibUncheckable);\n\n element.find('input').css({display: 'none'});\n\n //model -> UI\n ngModelCtrl.$render = function() {\n element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, scope.$eval(attrs.uibBtnRadio)));\n };\n\n //ui->model\n element.on(buttonsCtrl.toggleEvent, function() {\n if (attrs.disabled) {\n return;\n }\n\n var isActive = element.hasClass(buttonsCtrl.activeClass);\n\n if (!isActive || angular.isDefined(attrs.uncheckable)) {\n scope.$apply(function() {\n ngModelCtrl.$setViewValue(isActive ? null : scope.$eval(attrs.uibBtnRadio));\n ngModelCtrl.$render();\n });\n }\n });\n\n if (attrs.uibUncheckable) {\n scope.$watch(uncheckableExpr, function(uncheckable) {\n attrs.$set('uncheckable', uncheckable ? '' : undefined);\n });\n }\n }\n };\n}])\n\n.directive('uibBtnCheckbox', function() {\n return {\n require: ['uibBtnCheckbox', 'ngModel'],\n controller: 'UibButtonsController',\n controllerAs: 'button',\n link: function(scope, element, attrs, ctrls) {\n var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n element.find('input').css({display: 'none'});\n\n function getTrueValue() {\n return getCheckboxValue(attrs.btnCheckboxTrue, true);\n }\n\n function getFalseValue() {\n return getCheckboxValue(attrs.btnCheckboxFalse, false);\n }\n\n function getCheckboxValue(attribute, defaultValue) {\n return angular.isDefined(attribute) ? scope.$eval(attribute) : defaultValue;\n }\n\n //model -> UI\n ngModelCtrl.$render = function() {\n element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, getTrueValue()));\n };\n\n //ui->model\n element.on(buttonsCtrl.toggleEvent, function() {\n if (attrs.disabled) {\n return;\n }\n\n scope.$apply(function() {\n ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue());\n ngModelCtrl.$render();\n });\n });\n }\n };\n});\n\nangular.module('ui.bootstrap.carousel', [])\n\n.controller('UibCarouselController', ['$scope', '$element', '$interval', '$timeout', '$animate', function($scope, $element, $interval, $timeout, $animate) {\n var self = this,\n slides = self.slides = $scope.slides = [],\n SLIDE_DIRECTION = 'uib-slideDirection',\n currentIndex = $scope.active,\n currentInterval, isPlaying, bufferedTransitions = [];\n\n var destroyed = false;\n $element.addClass('carousel');\n\n self.addSlide = function(slide, element) {\n slides.push({\n slide: slide,\n element: element\n });\n slides.sort(function(a, b) {\n return +a.slide.index - +b.slide.index;\n });\n //if this is the first slide or the slide is set to active, select it\n if (slide.index === $scope.active || slides.length === 1 && !angular.isNumber($scope.active)) {\n if ($scope.$currentTransition) {\n $scope.$currentTransition = null;\n }\n\n currentIndex = slide.index;\n $scope.active = slide.index;\n setActive(currentIndex);\n self.select(slides[findSlideIndex(slide)]);\n if (slides.length === 1) {\n $scope.play();\n }\n }\n };\n\n self.getCurrentIndex = function() {\n for (var i = 0; i < slides.length; i++) {\n if (slides[i].slide.index === currentIndex) {\n return i;\n }\n }\n };\n\n self.next = $scope.next = function() {\n var newIndex = (self.getCurrentIndex() + 1) % slides.length;\n\n if (newIndex === 0 && $scope.noWrap()) {\n $scope.pause();\n return;\n }\n\n return self.select(slides[newIndex], 'next');\n };\n\n self.prev = $scope.prev = function() {\n var newIndex = self.getCurrentIndex() - 1 < 0 ? slides.length - 1 : self.getCurrentIndex() - 1;\n\n if ($scope.noWrap() && newIndex === slides.length - 1) {\n $scope.pause();\n return;\n }\n\n return self.select(slides[newIndex], 'prev');\n };\n\n self.removeSlide = function(slide) {\n var index = findSlideIndex(slide);\n\n var bufferedIndex = bufferedTransitions.indexOf(slides[index]);\n if (bufferedIndex !== -1) {\n bufferedTransitions.splice(bufferedIndex, 1);\n }\n\n //get the index of the slide inside the carousel\n slides.splice(index, 1);\n if (slides.length > 0 && currentIndex === index) {\n if (index >= slides.length) {\n currentIndex = slides.length - 1;\n $scope.active = currentIndex;\n setActive(currentIndex);\n self.select(slides[slides.length - 1]);\n } else {\n currentIndex = index;\n $scope.active = currentIndex;\n setActive(currentIndex);\n self.select(slides[index]);\n }\n } else if (currentIndex > index) {\n currentIndex--;\n $scope.active = currentIndex;\n }\n\n //clean the active value when no more slide\n if (slides.length === 0) {\n currentIndex = null;\n $scope.active = null;\n clearBufferedTransitions();\n }\n };\n\n /* direction: \"prev\" or \"next\" */\n self.select = $scope.select = function(nextSlide, direction) {\n var nextIndex = findSlideIndex(nextSlide.slide);\n //Decide direction if it's not given\n if (direction === undefined) {\n direction = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';\n }\n //Prevent this user-triggered transition from occurring if there is already one in progress\n if (nextSlide.slide.index !== currentIndex &&\n !$scope.$currentTransition) {\n goNext(nextSlide.slide, nextIndex, direction);\n } else if (nextSlide && nextSlide.slide.index !== currentIndex && $scope.$currentTransition) {\n bufferedTransitions.push(slides[nextIndex]);\n }\n };\n\n /* Allow outside people to call indexOf on slides array */\n $scope.indexOfSlide = function(slide) {\n return +slide.slide.index;\n };\n\n $scope.isActive = function(slide) {\n return $scope.active === slide.slide.index;\n };\n\n $scope.isPrevDisabled = function() {\n return $scope.active === 0 && $scope.noWrap();\n };\n\n $scope.isNextDisabled = function() {\n return $scope.active === slides.length - 1 && $scope.noWrap();\n };\n\n $scope.pause = function() {\n if (!$scope.noPause) {\n isPlaying = false;\n resetTimer();\n }\n };\n\n $scope.play = function() {\n if (!isPlaying) {\n isPlaying = true;\n restartTimer();\n }\n };\n\n $element.on('mouseenter', $scope.pause);\n $element.on('mouseleave', $scope.play);\n\n $scope.$on('$destroy', function() {\n destroyed = true;\n resetTimer();\n });\n\n $scope.$watch('noTransition', function(noTransition) {\n $animate.enabled($element, !noTransition);\n });\n\n $scope.$watch('interval', restartTimer);\n\n $scope.$watchCollection('slides', resetTransition);\n\n $scope.$watch('active', function(index) {\n if (angular.isNumber(index) && currentIndex !== index) {\n for (var i = 0; i < slides.length; i++) {\n if (slides[i].slide.index === index) {\n index = i;\n break;\n }\n }\n\n var slide = slides[index];\n if (slide) {\n setActive(index);\n self.select(slides[index]);\n currentIndex = index;\n }\n }\n });\n\n function clearBufferedTransitions() {\n while (bufferedTransitions.length) {\n bufferedTransitions.shift();\n }\n }\n\n function getSlideByIndex(index) {\n for (var i = 0, l = slides.length; i < l; ++i) {\n if (slides[i].index === index) {\n return slides[i];\n }\n }\n }\n\n function setActive(index) {\n for (var i = 0; i < slides.length; i++) {\n slides[i].slide.active = i === index;\n }\n }\n\n function goNext(slide, index, direction) {\n if (destroyed) {\n return;\n }\n\n angular.extend(slide, {direction: direction});\n angular.extend(slides[currentIndex].slide || {}, {direction: direction});\n if ($animate.enabled($element) && !$scope.$currentTransition &&\n slides[index].element && self.slides.length > 1) {\n slides[index].element.data(SLIDE_DIRECTION, slide.direction);\n var currentIdx = self.getCurrentIndex();\n\n if (angular.isNumber(currentIdx) && slides[currentIdx].element) {\n slides[currentIdx].element.data(SLIDE_DIRECTION, slide.direction);\n }\n\n $scope.$currentTransition = true;\n $animate.on('addClass', slides[index].element, function(element, phase) {\n if (phase === 'close') {\n $scope.$currentTransition = null;\n $animate.off('addClass', element);\n if (bufferedTransitions.length) {\n var nextSlide = bufferedTransitions.pop().slide;\n var nextIndex = nextSlide.index;\n var nextDirection = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';\n clearBufferedTransitions();\n\n goNext(nextSlide, nextIndex, nextDirection);\n }\n }\n });\n }\n\n $scope.active = slide.index;\n currentIndex = slide.index;\n setActive(index);\n\n //every time you change slides, reset the timer\n restartTimer();\n }\n\n function findSlideIndex(slide) {\n for (var i = 0; i < slides.length; i++) {\n if (slides[i].slide === slide) {\n return i;\n }\n }\n }\n\n function resetTimer() {\n if (currentInterval) {\n $interval.cancel(currentInterval);\n currentInterval = null;\n }\n }\n\n function resetTransition(slides) {\n if (!slides.length) {\n $scope.$currentTransition = null;\n clearBufferedTransitions();\n }\n }\n\n function restartTimer() {\n resetTimer();\n var interval = +$scope.interval;\n if (!isNaN(interval) && interval > 0) {\n currentInterval = $interval(timerFn, interval);\n }\n }\n\n function timerFn() {\n var interval = +$scope.interval;\n if (isPlaying && !isNaN(interval) && interval > 0 && slides.length) {\n $scope.next();\n } else {\n $scope.pause();\n }\n }\n}])\n\n.directive('uibCarousel', function() {\n return {\n transclude: true,\n controller: 'UibCarouselController',\n controllerAs: 'carousel',\n restrict: 'A',\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/carousel/carousel.html';\n },\n scope: {\n active: '=',\n interval: '=',\n noTransition: '=',\n noPause: '=',\n noWrap: '&'\n }\n };\n})\n\n.directive('uibSlide', ['$animate', function($animate) {\n return {\n require: '^uibCarousel',\n restrict: 'A',\n transclude: true,\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/carousel/slide.html';\n },\n scope: {\n actual: '=?',\n index: '=?'\n },\n link: function (scope, element, attrs, carouselCtrl) {\n element.addClass('item');\n carouselCtrl.addSlide(scope, element);\n //when the scope is destroyed then remove the slide from the current slides array\n scope.$on('$destroy', function() {\n carouselCtrl.removeSlide(scope);\n });\n\n scope.$watch('active', function(active) {\n $animate[active ? 'addClass' : 'removeClass'](element, 'active');\n });\n }\n };\n}])\n\n.animation('.item', ['$animateCss',\nfunction($animateCss) {\n var SLIDE_DIRECTION = 'uib-slideDirection';\n\n function removeClass(element, className, callback) {\n element.removeClass(className);\n if (callback) {\n callback();\n }\n }\n\n return {\n beforeAddClass: function(element, className, done) {\n if (className === 'active') {\n var stopped = false;\n var direction = element.data(SLIDE_DIRECTION);\n var directionClass = direction === 'next' ? 'left' : 'right';\n var removeClassFn = removeClass.bind(this, element,\n directionClass + ' ' + direction, done);\n element.addClass(direction);\n\n $animateCss(element, {addClass: directionClass})\n .start()\n .done(removeClassFn);\n\n return function() {\n stopped = true;\n };\n }\n done();\n },\n beforeRemoveClass: function (element, className, done) {\n if (className === 'active') {\n var stopped = false;\n var direction = element.data(SLIDE_DIRECTION);\n var directionClass = direction === 'next' ? 'left' : 'right';\n var removeClassFn = removeClass.bind(this, element, directionClass, done);\n\n $animateCss(element, {addClass: directionClass})\n .start()\n .done(removeClassFn);\n\n return function() {\n stopped = true;\n };\n }\n done();\n }\n };\n}]);\n\nangular.module('ui.bootstrap.dateparser', [])\n\n.service('uibDateParser', ['$log', '$locale', 'dateFilter', 'orderByFilter', function($log, $locale, dateFilter, orderByFilter) {\n // Pulled from https://github.com/mbostock/d3/blob/master/src/format/requote.js\n var SPECIAL_CHARACTERS_REGEXP = /[\\\\\\^\\$\\*\\+\\?\\|\\[\\]\\(\\)\\.\\{\\}]/g;\n\n var localeId;\n var formatCodeToRegex;\n\n this.init = function() {\n localeId = $locale.id;\n\n this.parsers = {};\n this.formatters = {};\n\n formatCodeToRegex = [\n {\n key: 'yyyy',\n regex: '\\\\d{4}',\n apply: function(value) { this.year = +value; },\n formatter: function(date) {\n var _date = new Date();\n _date.setFullYear(Math.abs(date.getFullYear()));\n return dateFilter(_date, 'yyyy');\n }\n },\n {\n key: 'yy',\n regex: '\\\\d{2}',\n apply: function(value) { value = +value; this.year = value < 69 ? value + 2000 : value + 1900; },\n formatter: function(date) {\n var _date = new Date();\n _date.setFullYear(Math.abs(date.getFullYear()));\n return dateFilter(_date, 'yy');\n }\n },\n {\n key: 'y',\n regex: '\\\\d{1,4}',\n apply: function(value) { this.year = +value; },\n formatter: function(date) {\n var _date = new Date();\n _date.setFullYear(Math.abs(date.getFullYear()));\n return dateFilter(_date, 'y');\n }\n },\n {\n key: 'M!',\n regex: '0?[1-9]|1[0-2]',\n apply: function(value) { this.month = value - 1; },\n formatter: function(date) {\n var value = date.getMonth();\n if (/^[0-9]$/.test(value)) {\n return dateFilter(date, 'MM');\n }\n\n return dateFilter(date, 'M');\n }\n },\n {\n key: 'MMMM',\n regex: $locale.DATETIME_FORMATS.MONTH.join('|'),\n apply: function(value) { this.month = $locale.DATETIME_FORMATS.MONTH.indexOf(value); },\n formatter: function(date) { return dateFilter(date, 'MMMM'); }\n },\n {\n key: 'MMM',\n regex: $locale.DATETIME_FORMATS.SHORTMONTH.join('|'),\n apply: function(value) { this.month = $locale.DATETIME_FORMATS.SHORTMONTH.indexOf(value); },\n formatter: function(date) { return dateFilter(date, 'MMM'); }\n },\n {\n key: 'MM',\n regex: '0[1-9]|1[0-2]',\n apply: function(value) { this.month = value - 1; },\n formatter: function(date) { return dateFilter(date, 'MM'); }\n },\n {\n key: 'M',\n regex: '[1-9]|1[0-2]',\n apply: function(value) { this.month = value - 1; },\n formatter: function(date) { return dateFilter(date, 'M'); }\n },\n {\n key: 'd!',\n regex: '[0-2]?[0-9]{1}|3[0-1]{1}',\n apply: function(value) { this.date = +value; },\n formatter: function(date) {\n var value = date.getDate();\n if (/^[1-9]$/.test(value)) {\n return dateFilter(date, 'dd');\n }\n\n return dateFilter(date, 'd');\n }\n },\n {\n key: 'dd',\n regex: '[0-2][0-9]{1}|3[0-1]{1}',\n apply: function(value) { this.date = +value; },\n formatter: function(date) { return dateFilter(date, 'dd'); }\n },\n {\n key: 'd',\n regex: '[1-2]?[0-9]{1}|3[0-1]{1}',\n apply: function(value) { this.date = +value; },\n formatter: function(date) { return dateFilter(date, 'd'); }\n },\n {\n key: 'EEEE',\n regex: $locale.DATETIME_FORMATS.DAY.join('|'),\n formatter: function(date) { return dateFilter(date, 'EEEE'); }\n },\n {\n key: 'EEE',\n regex: $locale.DATETIME_FORMATS.SHORTDAY.join('|'),\n formatter: function(date) { return dateFilter(date, 'EEE'); }\n },\n {\n key: 'HH',\n regex: '(?:0|1)[0-9]|2[0-3]',\n apply: function(value) { this.hours = +value; },\n formatter: function(date) { return dateFilter(date, 'HH'); }\n },\n {\n key: 'hh',\n regex: '0[0-9]|1[0-2]',\n apply: function(value) { this.hours = +value; },\n formatter: function(date) { return dateFilter(date, 'hh'); }\n },\n {\n key: 'H',\n regex: '1?[0-9]|2[0-3]',\n apply: function(value) { this.hours = +value; },\n formatter: function(date) { return dateFilter(date, 'H'); }\n },\n {\n key: 'h',\n regex: '[0-9]|1[0-2]',\n apply: function(value) { this.hours = +value; },\n formatter: function(date) { return dateFilter(date, 'h'); }\n },\n {\n key: 'mm',\n regex: '[0-5][0-9]',\n apply: function(value) { this.minutes = +value; },\n formatter: function(date) { return dateFilter(date, 'mm'); }\n },\n {\n key: 'm',\n regex: '[0-9]|[1-5][0-9]',\n apply: function(value) { this.minutes = +value; },\n formatter: function(date) { return dateFilter(date, 'm'); }\n },\n {\n key: 'sss',\n regex: '[0-9][0-9][0-9]',\n apply: function(value) { this.milliseconds = +value; },\n formatter: function(date) { return dateFilter(date, 'sss'); }\n },\n {\n key: 'ss',\n regex: '[0-5][0-9]',\n apply: function(value) { this.seconds = +value; },\n formatter: function(date) { return dateFilter(date, 'ss'); }\n },\n {\n key: 's',\n regex: '[0-9]|[1-5][0-9]',\n apply: function(value) { this.seconds = +value; },\n formatter: function(date) { return dateFilter(date, 's'); }\n },\n {\n key: 'a',\n regex: $locale.DATETIME_FORMATS.AMPMS.join('|'),\n apply: function(value) {\n if (this.hours === 12) {\n this.hours = 0;\n }\n\n if (value === 'PM') {\n this.hours += 12;\n }\n },\n formatter: function(date) { return dateFilter(date, 'a'); }\n },\n {\n key: 'Z',\n regex: '[+-]\\\\d{4}',\n apply: function(value) {\n var matches = value.match(/([+-])(\\d{2})(\\d{2})/),\n sign = matches[1],\n hours = matches[2],\n minutes = matches[3];\n this.hours += toInt(sign + hours);\n this.minutes += toInt(sign + minutes);\n },\n formatter: function(date) {\n return dateFilter(date, 'Z');\n }\n },\n {\n key: 'ww',\n regex: '[0-4][0-9]|5[0-3]',\n formatter: function(date) { return dateFilter(date, 'ww'); }\n },\n {\n key: 'w',\n regex: '[0-9]|[1-4][0-9]|5[0-3]',\n formatter: function(date) { return dateFilter(date, 'w'); }\n },\n {\n key: 'GGGG',\n regex: $locale.DATETIME_FORMATS.ERANAMES.join('|').replace(/\\s/g, '\\\\s'),\n formatter: function(date) { return dateFilter(date, 'GGGG'); }\n },\n {\n key: 'GGG',\n regex: $locale.DATETIME_FORMATS.ERAS.join('|'),\n formatter: function(date) { return dateFilter(date, 'GGG'); }\n },\n {\n key: 'GG',\n regex: $locale.DATETIME_FORMATS.ERAS.join('|'),\n formatter: function(date) { return dateFilter(date, 'GG'); }\n },\n {\n key: 'G',\n regex: $locale.DATETIME_FORMATS.ERAS.join('|'),\n formatter: function(date) { return dateFilter(date, 'G'); }\n }\n ];\n };\n\n this.init();\n\n function createParser(format) {\n var map = [], regex = format.split('');\n\n // check for literal values\n var quoteIndex = format.indexOf('\\'');\n if (quoteIndex > -1) {\n var inLiteral = false;\n format = format.split('');\n for (var i = quoteIndex; i < format.length; i++) {\n if (inLiteral) {\n if (format[i] === '\\'') {\n if (i + 1 < format.length && format[i+1] === '\\'') { // escaped single quote\n format[i+1] = '$';\n regex[i+1] = '';\n } else { // end of literal\n regex[i] = '';\n inLiteral = false;\n }\n }\n format[i] = '$';\n } else {\n if (format[i] === '\\'') { // start of literal\n format[i] = '$';\n regex[i] = '';\n inLiteral = true;\n }\n }\n }\n\n format = format.join('');\n }\n\n angular.forEach(formatCodeToRegex, function(data) {\n var index = format.indexOf(data.key);\n\n if (index > -1) {\n format = format.split('');\n\n regex[index] = '(' + data.regex + ')';\n format[index] = '$'; // Custom symbol to define consumed part of format\n for (var i = index + 1, n = index + data.key.length; i < n; i++) {\n regex[i] = '';\n format[i] = '$';\n }\n format = format.join('');\n\n map.push({\n index: index,\n key: data.key,\n apply: data.apply,\n matcher: data.regex\n });\n }\n });\n\n return {\n regex: new RegExp('^' + regex.join('') + '$'),\n map: orderByFilter(map, 'index')\n };\n }\n\n function createFormatter(format) {\n var formatters = [];\n var i = 0;\n var formatter, literalIdx;\n while (i < format.length) {\n if (angular.isNumber(literalIdx)) {\n if (format.charAt(i) === '\\'') {\n if (i + 1 >= format.length || format.charAt(i + 1) !== '\\'') {\n formatters.push(constructLiteralFormatter(format, literalIdx, i));\n literalIdx = null;\n }\n } else if (i === format.length) {\n while (literalIdx < format.length) {\n formatter = constructFormatterFromIdx(format, literalIdx);\n formatters.push(formatter);\n literalIdx = formatter.endIdx;\n }\n }\n\n i++;\n continue;\n }\n\n if (format.charAt(i) === '\\'') {\n literalIdx = i;\n i++;\n continue;\n }\n\n formatter = constructFormatterFromIdx(format, i);\n\n formatters.push(formatter.parser);\n i = formatter.endIdx;\n }\n\n return formatters;\n }\n\n function constructLiteralFormatter(format, literalIdx, endIdx) {\n return function() {\n return format.substr(literalIdx + 1, endIdx - literalIdx - 1);\n };\n }\n\n function constructFormatterFromIdx(format, i) {\n var currentPosStr = format.substr(i);\n for (var j = 0; j < formatCodeToRegex.length; j++) {\n if (new RegExp('^' + formatCodeToRegex[j].key).test(currentPosStr)) {\n var data = formatCodeToRegex[j];\n return {\n endIdx: i + data.key.length,\n parser: data.formatter\n };\n }\n }\n\n return {\n endIdx: i + 1,\n parser: function() {\n return currentPosStr.charAt(0);\n }\n };\n }\n\n this.filter = function(date, format) {\n if (!angular.isDate(date) || isNaN(date) || !format) {\n return '';\n }\n\n format = $locale.DATETIME_FORMATS[format] || format;\n\n if ($locale.id !== localeId) {\n this.init();\n }\n\n if (!this.formatters[format]) {\n this.formatters[format] = createFormatter(format);\n }\n\n var formatters = this.formatters[format];\n\n return formatters.reduce(function(str, formatter) {\n return str + formatter(date);\n }, '');\n };\n\n this.parse = function(input, format, baseDate) {\n if (!angular.isString(input) || !format) {\n return input;\n }\n\n format = $locale.DATETIME_FORMATS[format] || format;\n format = format.replace(SPECIAL_CHARACTERS_REGEXP, '\\\\$&');\n\n if ($locale.id !== localeId) {\n this.init();\n }\n\n if (!this.parsers[format]) {\n this.parsers[format] = createParser(format, 'apply');\n }\n\n var parser = this.parsers[format],\n regex = parser.regex,\n map = parser.map,\n results = input.match(regex),\n tzOffset = false;\n if (results && results.length) {\n var fields, dt;\n if (angular.isDate(baseDate) && !isNaN(baseDate.getTime())) {\n fields = {\n year: baseDate.getFullYear(),\n month: baseDate.getMonth(),\n date: baseDate.getDate(),\n hours: baseDate.getHours(),\n minutes: baseDate.getMinutes(),\n seconds: baseDate.getSeconds(),\n milliseconds: baseDate.getMilliseconds()\n };\n } else {\n if (baseDate) {\n $log.warn('dateparser:', 'baseDate is not a valid date');\n }\n fields = { year: 1900, month: 0, date: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 };\n }\n\n for (var i = 1, n = results.length; i < n; i++) {\n var mapper = map[i - 1];\n if (mapper.matcher === 'Z') {\n tzOffset = true;\n }\n\n if (mapper.apply) {\n mapper.apply.call(fields, results[i]);\n }\n }\n\n var datesetter = tzOffset ? Date.prototype.setUTCFullYear :\n Date.prototype.setFullYear;\n var timesetter = tzOffset ? Date.prototype.setUTCHours :\n Date.prototype.setHours;\n\n if (isValid(fields.year, fields.month, fields.date)) {\n if (angular.isDate(baseDate) && !isNaN(baseDate.getTime()) && !tzOffset) {\n dt = new Date(baseDate);\n datesetter.call(dt, fields.year, fields.month, fields.date);\n timesetter.call(dt, fields.hours, fields.minutes,\n fields.seconds, fields.milliseconds);\n } else {\n dt = new Date(0);\n datesetter.call(dt, fields.year, fields.month, fields.date);\n timesetter.call(dt, fields.hours || 0, fields.minutes || 0,\n fields.seconds || 0, fields.milliseconds || 0);\n }\n }\n\n return dt;\n }\n };\n\n // Check if date is valid for specific month (and year for February).\n // Month: 0 = Jan, 1 = Feb, etc\n function isValid(year, month, date) {\n if (date < 1) {\n return false;\n }\n\n if (month === 1 && date > 28) {\n return date === 29 && (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0);\n }\n\n if (month === 3 || month === 5 || month === 8 || month === 10) {\n return date < 31;\n }\n\n return true;\n }\n\n function toInt(str) {\n return parseInt(str, 10);\n }\n\n this.toTimezone = toTimezone;\n this.fromTimezone = fromTimezone;\n this.timezoneToOffset = timezoneToOffset;\n this.addDateMinutes = addDateMinutes;\n this.convertTimezoneToLocal = convertTimezoneToLocal;\n\n function toTimezone(date, timezone) {\n return date && timezone ? convertTimezoneToLocal(date, timezone) : date;\n }\n\n function fromTimezone(date, timezone) {\n return date && timezone ? convertTimezoneToLocal(date, timezone, true) : date;\n }\n\n //https://github.com/angular/angular.js/blob/622c42169699ec07fc6daaa19fe6d224e5d2f70e/src/Angular.js#L1207\n function timezoneToOffset(timezone, fallback) {\n timezone = timezone.replace(/:/g, '');\n var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;\n return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;\n }\n\n function addDateMinutes(date, minutes) {\n date = new Date(date.getTime());\n date.setMinutes(date.getMinutes() + minutes);\n return date;\n }\n\n function convertTimezoneToLocal(date, timezone, reverse) {\n reverse = reverse ? -1 : 1;\n var dateTimezoneOffset = date.getTimezoneOffset();\n var timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);\n return addDateMinutes(date, reverse * (timezoneOffset - dateTimezoneOffset));\n }\n}]);\n\n// Avoiding use of ng-class as it creates a lot of watchers when a class is to be applied to\n// at most one element.\nangular.module('ui.bootstrap.isClass', [])\n.directive('uibIsClass', [\n '$animate',\nfunction ($animate) {\n // 11111111 22222222\n var ON_REGEXP = /^\\s*([\\s\\S]+?)\\s+on\\s+([\\s\\S]+?)\\s*$/;\n // 11111111 22222222\n var IS_REGEXP = /^\\s*([\\s\\S]+?)\\s+for\\s+([\\s\\S]+?)\\s*$/;\n\n var dataPerTracked = {};\n\n return {\n restrict: 'A',\n compile: function(tElement, tAttrs) {\n var linkedScopes = [];\n var instances = [];\n var expToData = {};\n var lastActivated = null;\n var onExpMatches = tAttrs.uibIsClass.match(ON_REGEXP);\n var onExp = onExpMatches[2];\n var expsStr = onExpMatches[1];\n var exps = expsStr.split(',');\n\n return linkFn;\n\n function linkFn(scope, element, attrs) {\n linkedScopes.push(scope);\n instances.push({\n scope: scope,\n element: element\n });\n\n exps.forEach(function(exp, k) {\n addForExp(exp, scope);\n });\n\n scope.$on('$destroy', removeScope);\n }\n\n function addForExp(exp, scope) {\n var matches = exp.match(IS_REGEXP);\n var clazz = scope.$eval(matches[1]);\n var compareWithExp = matches[2];\n var data = expToData[exp];\n if (!data) {\n var watchFn = function(compareWithVal) {\n var newActivated = null;\n instances.some(function(instance) {\n var thisVal = instance.scope.$eval(onExp);\n if (thisVal === compareWithVal) {\n newActivated = instance;\n return true;\n }\n });\n if (data.lastActivated !== newActivated) {\n if (data.lastActivated) {\n $animate.removeClass(data.lastActivated.element, clazz);\n }\n if (newActivated) {\n $animate.addClass(newActivated.element, clazz);\n }\n data.lastActivated = newActivated;\n }\n };\n expToData[exp] = data = {\n lastActivated: null,\n scope: scope,\n watchFn: watchFn,\n compareWithExp: compareWithExp,\n watcher: scope.$watch(compareWithExp, watchFn)\n };\n }\n data.watchFn(scope.$eval(compareWithExp));\n }\n\n function removeScope(e) {\n var removedScope = e.targetScope;\n var index = linkedScopes.indexOf(removedScope);\n linkedScopes.splice(index, 1);\n instances.splice(index, 1);\n if (linkedScopes.length) {\n var newWatchScope = linkedScopes[0];\n angular.forEach(expToData, function(data) {\n if (data.scope === removedScope) {\n data.watcher = newWatchScope.$watch(data.compareWithExp, data.watchFn);\n data.scope = newWatchScope;\n }\n });\n } else {\n expToData = {};\n }\n }\n }\n };\n}]);\nangular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.isClass'])\n\n.value('$datepickerSuppressError', false)\n\n.value('$datepickerLiteralWarning', true)\n\n.constant('uibDatepickerConfig', {\n datepickerMode: 'day',\n formatDay: 'dd',\n formatMonth: 'MMMM',\n formatYear: 'yyyy',\n formatDayHeader: 'EEE',\n formatDayTitle: 'MMMM yyyy',\n formatMonthTitle: 'yyyy',\n maxDate: null,\n maxMode: 'year',\n minDate: null,\n minMode: 'day',\n monthColumns: 3,\n ngModelOptions: {},\n shortcutPropagation: false,\n showWeeks: true,\n yearColumns: 5,\n yearRows: 4\n})\n\n.controller('UibDatepickerController', ['$scope', '$element', '$attrs', '$parse', '$interpolate', '$locale', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerLiteralWarning', '$datepickerSuppressError', 'uibDateParser',\n function($scope, $element, $attrs, $parse, $interpolate, $locale, $log, dateFilter, datepickerConfig, $datepickerLiteralWarning, $datepickerSuppressError, dateParser) {\n var self = this,\n ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl;\n ngModelOptions = {},\n watchListeners = [];\n\n $element.addClass('uib-datepicker');\n $attrs.$set('role', 'application');\n\n if (!$scope.datepickerOptions) {\n $scope.datepickerOptions = {};\n }\n\n // Modes chain\n this.modes = ['day', 'month', 'year'];\n\n [\n 'customClass',\n 'dateDisabled',\n 'datepickerMode',\n 'formatDay',\n 'formatDayHeader',\n 'formatDayTitle',\n 'formatMonth',\n 'formatMonthTitle',\n 'formatYear',\n 'maxDate',\n 'maxMode',\n 'minDate',\n 'minMode',\n 'monthColumns',\n 'showWeeks',\n 'shortcutPropagation',\n 'startingDay',\n 'yearColumns',\n 'yearRows'\n ].forEach(function(key) {\n switch (key) {\n case 'customClass':\n case 'dateDisabled':\n $scope[key] = $scope.datepickerOptions[key] || angular.noop;\n break;\n case 'datepickerMode':\n $scope.datepickerMode = angular.isDefined($scope.datepickerOptions.datepickerMode) ?\n $scope.datepickerOptions.datepickerMode : datepickerConfig.datepickerMode;\n break;\n case 'formatDay':\n case 'formatDayHeader':\n case 'formatDayTitle':\n case 'formatMonth':\n case 'formatMonthTitle':\n case 'formatYear':\n self[key] = angular.isDefined($scope.datepickerOptions[key]) ?\n $interpolate($scope.datepickerOptions[key])($scope.$parent) :\n datepickerConfig[key];\n break;\n case 'monthColumns':\n case 'showWeeks':\n case 'shortcutPropagation':\n case 'yearColumns':\n case 'yearRows':\n self[key] = angular.isDefined($scope.datepickerOptions[key]) ?\n $scope.datepickerOptions[key] : datepickerConfig[key];\n break;\n case 'startingDay':\n if (angular.isDefined($scope.datepickerOptions.startingDay)) {\n self.startingDay = $scope.datepickerOptions.startingDay;\n } else if (angular.isNumber(datepickerConfig.startingDay)) {\n self.startingDay = datepickerConfig.startingDay;\n } else {\n self.startingDay = ($locale.DATETIME_FORMATS.FIRSTDAYOFWEEK + 8) % 7;\n }\n\n break;\n case 'maxDate':\n case 'minDate':\n $scope.$watch('datepickerOptions.' + key, function(value) {\n if (value) {\n if (angular.isDate(value)) {\n self[key] = dateParser.fromTimezone(new Date(value), ngModelOptions.timezone);\n } else {\n if ($datepickerLiteralWarning) {\n $log.warn('Literal date support has been deprecated, please switch to date object usage');\n }\n\n self[key] = new Date(dateFilter(value, 'medium'));\n }\n } else {\n self[key] = datepickerConfig[key] ?\n dateParser.fromTimezone(new Date(datepickerConfig[key]), ngModelOptions.timezone) :\n null;\n }\n\n self.refreshView();\n });\n\n break;\n case 'maxMode':\n case 'minMode':\n if ($scope.datepickerOptions[key]) {\n $scope.$watch(function() { return $scope.datepickerOptions[key]; }, function(value) {\n self[key] = $scope[key] = angular.isDefined(value) ? value : $scope.datepickerOptions[key];\n if (key === 'minMode' && self.modes.indexOf($scope.datepickerOptions.datepickerMode) < self.modes.indexOf(self[key]) ||\n key === 'maxMode' && self.modes.indexOf($scope.datepickerOptions.datepickerMode) > self.modes.indexOf(self[key])) {\n $scope.datepickerMode = self[key];\n $scope.datepickerOptions.datepickerMode = self[key];\n }\n });\n } else {\n self[key] = $scope[key] = datepickerConfig[key] || null;\n }\n\n break;\n }\n });\n\n $scope.uniqueId = 'datepicker-' + $scope.$id + '-' + Math.floor(Math.random() * 10000);\n\n $scope.disabled = angular.isDefined($attrs.disabled) || false;\n if (angular.isDefined($attrs.ngDisabled)) {\n watchListeners.push($scope.$parent.$watch($attrs.ngDisabled, function(disabled) {\n $scope.disabled = disabled;\n self.refreshView();\n }));\n }\n\n $scope.isActive = function(dateObject) {\n if (self.compare(dateObject.date, self.activeDate) === 0) {\n $scope.activeDateId = dateObject.uid;\n return true;\n }\n return false;\n };\n\n this.init = function(ngModelCtrl_) {\n ngModelCtrl = ngModelCtrl_;\n ngModelOptions = ngModelCtrl_.$options ||\n $scope.datepickerOptions.ngModelOptions ||\n datepickerConfig.ngModelOptions;\n if ($scope.datepickerOptions.initDate) {\n self.activeDate = dateParser.fromTimezone($scope.datepickerOptions.initDate, ngModelOptions.timezone) || new Date();\n $scope.$watch('datepickerOptions.initDate', function(initDate) {\n if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) {\n self.activeDate = dateParser.fromTimezone(initDate, ngModelOptions.timezone);\n self.refreshView();\n }\n });\n } else {\n self.activeDate = new Date();\n }\n\n var date = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : new Date();\n this.activeDate = !isNaN(date) ?\n dateParser.fromTimezone(date, ngModelOptions.timezone) :\n dateParser.fromTimezone(new Date(), ngModelOptions.timezone);\n\n ngModelCtrl.$render = function() {\n self.render();\n };\n };\n\n this.render = function() {\n if (ngModelCtrl.$viewValue) {\n var date = new Date(ngModelCtrl.$viewValue),\n isValid = !isNaN(date);\n\n if (isValid) {\n this.activeDate = dateParser.fromTimezone(date, ngModelOptions.timezone);\n } else if (!$datepickerSuppressError) {\n $log.error('Datepicker directive: \"ng-model\" value must be a Date object');\n }\n }\n this.refreshView();\n };\n\n this.refreshView = function() {\n if (this.element) {\n $scope.selectedDt = null;\n this._refreshView();\n if ($scope.activeDt) {\n $scope.activeDateId = $scope.activeDt.uid;\n }\n\n var date = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;\n date = dateParser.fromTimezone(date, ngModelOptions.timezone);\n ngModelCtrl.$setValidity('dateDisabled', !date ||\n this.element && !this.isDisabled(date));\n }\n };\n\n this.createDateObject = function(date, format) {\n var model = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;\n model = dateParser.fromTimezone(model, ngModelOptions.timezone);\n var today = new Date();\n today = dateParser.fromTimezone(today, ngModelOptions.timezone);\n var time = this.compare(date, today);\n var dt = {\n date: date,\n label: dateParser.filter(date, format),\n selected: model && this.compare(date, model) === 0,\n disabled: this.isDisabled(date),\n past: time < 0,\n current: time === 0,\n future: time > 0,\n customClass: this.customClass(date) || null\n };\n\n if (model && this.compare(date, model) === 0) {\n $scope.selectedDt = dt;\n }\n\n if (self.activeDate && this.compare(dt.date, self.activeDate) === 0) {\n $scope.activeDt = dt;\n }\n\n return dt;\n };\n\n this.isDisabled = function(date) {\n return $scope.disabled ||\n this.minDate && this.compare(date, this.minDate) < 0 ||\n this.maxDate && this.compare(date, this.maxDate) > 0 ||\n $scope.dateDisabled && $scope.dateDisabled({date: date, mode: $scope.datepickerMode});\n };\n\n this.customClass = function(date) {\n return $scope.customClass({date: date, mode: $scope.datepickerMode});\n };\n\n // Split array into smaller arrays\n this.split = function(arr, size) {\n var arrays = [];\n while (arr.length > 0) {\n arrays.push(arr.splice(0, size));\n }\n return arrays;\n };\n\n $scope.select = function(date) {\n if ($scope.datepickerMode === self.minMode) {\n var dt = ngModelCtrl.$viewValue ? dateParser.fromTimezone(new Date(ngModelCtrl.$viewValue), ngModelOptions.timezone) : new Date(0, 0, 0, 0, 0, 0, 0);\n dt.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());\n dt = dateParser.toTimezone(dt, ngModelOptions.timezone);\n ngModelCtrl.$setViewValue(dt);\n ngModelCtrl.$render();\n } else {\n self.activeDate = date;\n setMode(self.modes[self.modes.indexOf($scope.datepickerMode) - 1]);\n\n $scope.$emit('uib:datepicker.mode');\n }\n\n $scope.$broadcast('uib:datepicker.focus');\n };\n\n $scope.move = function(direction) {\n var year = self.activeDate.getFullYear() + direction * (self.step.years || 0),\n month = self.activeDate.getMonth() + direction * (self.step.months || 0);\n self.activeDate.setFullYear(year, month, 1);\n self.refreshView();\n };\n\n $scope.toggleMode = function(direction) {\n direction = direction || 1;\n\n if ($scope.datepickerMode === self.maxMode && direction === 1 ||\n $scope.datepickerMode === self.minMode && direction === -1) {\n return;\n }\n\n setMode(self.modes[self.modes.indexOf($scope.datepickerMode) + direction]);\n\n $scope.$emit('uib:datepicker.mode');\n };\n\n // Key event mapper\n $scope.keys = { 13: 'enter', 32: 'space', 33: 'pageup', 34: 'pagedown', 35: 'end', 36: 'home', 37: 'left', 38: 'up', 39: 'right', 40: 'down' };\n\n var focusElement = function() {\n self.element[0].focus();\n };\n\n // Listen for focus requests from popup directive\n $scope.$on('uib:datepicker.focus', focusElement);\n\n $scope.keydown = function(evt) {\n var key = $scope.keys[evt.which];\n\n if (!key || evt.shiftKey || evt.altKey || $scope.disabled) {\n return;\n }\n\n evt.preventDefault();\n if (!self.shortcutPropagation) {\n evt.stopPropagation();\n }\n\n if (key === 'enter' || key === 'space') {\n if (self.isDisabled(self.activeDate)) {\n return; // do nothing\n }\n $scope.select(self.activeDate);\n } else if (evt.ctrlKey && (key === 'up' || key === 'down')) {\n $scope.toggleMode(key === 'up' ? 1 : -1);\n } else {\n self.handleKeyDown(key, evt);\n self.refreshView();\n }\n };\n\n $element.on('keydown', function(evt) {\n $scope.$apply(function() {\n $scope.keydown(evt);\n });\n });\n\n $scope.$on('$destroy', function() {\n //Clear all watch listeners on destroy\n while (watchListeners.length) {\n watchListeners.shift()();\n }\n });\n\n function setMode(mode) {\n $scope.datepickerMode = mode;\n $scope.datepickerOptions.datepickerMode = mode;\n }\n}])\n\n.controller('UibDaypickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {\n var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\n this.step = { months: 1 };\n this.element = $element;\n function getDaysInMonth(year, month) {\n return month === 1 && year % 4 === 0 &&\n (year % 100 !== 0 || year % 400 === 0) ? 29 : DAYS_IN_MONTH[month];\n }\n\n this.init = function(ctrl) {\n angular.extend(ctrl, this);\n scope.showWeeks = ctrl.showWeeks;\n ctrl.refreshView();\n };\n\n this.getDates = function(startDate, n) {\n var dates = new Array(n), current = new Date(startDate), i = 0, date;\n while (i < n) {\n date = new Date(current);\n dates[i++] = date;\n current.setDate(current.getDate() + 1);\n }\n return dates;\n };\n\n this._refreshView = function() {\n var year = this.activeDate.getFullYear(),\n month = this.activeDate.getMonth(),\n firstDayOfMonth = new Date(this.activeDate);\n\n firstDayOfMonth.setFullYear(year, month, 1);\n\n var difference = this.startingDay - firstDayOfMonth.getDay(),\n numDisplayedFromPreviousMonth = difference > 0 ?\n 7 - difference : - difference,\n firstDate = new Date(firstDayOfMonth);\n\n if (numDisplayedFromPreviousMonth > 0) {\n firstDate.setDate(-numDisplayedFromPreviousMonth + 1);\n }\n\n // 42 is the number of days on a six-week calendar\n var days = this.getDates(firstDate, 42);\n for (var i = 0; i < 42; i ++) {\n days[i] = angular.extend(this.createDateObject(days[i], this.formatDay), {\n secondary: days[i].getMonth() !== month,\n uid: scope.uniqueId + '-' + i\n });\n }\n\n scope.labels = new Array(7);\n for (var j = 0; j < 7; j++) {\n scope.labels[j] = {\n abbr: dateFilter(days[j].date, this.formatDayHeader),\n full: dateFilter(days[j].date, 'EEEE')\n };\n }\n\n scope.title = dateFilter(this.activeDate, this.formatDayTitle);\n scope.rows = this.split(days, 7);\n\n if (scope.showWeeks) {\n scope.weekNumbers = [];\n var thursdayIndex = (4 + 7 - this.startingDay) % 7,\n numWeeks = scope.rows.length;\n for (var curWeek = 0; curWeek < numWeeks; curWeek++) {\n scope.weekNumbers.push(\n getISO8601WeekNumber(scope.rows[curWeek][thursdayIndex].date));\n }\n }\n };\n\n this.compare = function(date1, date2) {\n var _date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());\n var _date2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());\n _date1.setFullYear(date1.getFullYear());\n _date2.setFullYear(date2.getFullYear());\n return _date1 - _date2;\n };\n\n function getISO8601WeekNumber(date) {\n var checkDate = new Date(date);\n checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); // Thursday\n var time = checkDate.getTime();\n checkDate.setMonth(0); // Compare with Jan 1\n checkDate.setDate(1);\n return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;\n }\n\n this.handleKeyDown = function(key, evt) {\n var date = this.activeDate.getDate();\n\n if (key === 'left') {\n date = date - 1;\n } else if (key === 'up') {\n date = date - 7;\n } else if (key === 'right') {\n date = date + 1;\n } else if (key === 'down') {\n date = date + 7;\n } else if (key === 'pageup' || key === 'pagedown') {\n var month = this.activeDate.getMonth() + (key === 'pageup' ? - 1 : 1);\n this.activeDate.setMonth(month, 1);\n date = Math.min(getDaysInMonth(this.activeDate.getFullYear(), this.activeDate.getMonth()), date);\n } else if (key === 'home') {\n date = 1;\n } else if (key === 'end') {\n date = getDaysInMonth(this.activeDate.getFullYear(), this.activeDate.getMonth());\n }\n this.activeDate.setDate(date);\n };\n}])\n\n.controller('UibMonthpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {\n this.step = { years: 1 };\n this.element = $element;\n\n this.init = function(ctrl) {\n angular.extend(ctrl, this);\n ctrl.refreshView();\n };\n\n this._refreshView = function() {\n var months = new Array(12),\n year = this.activeDate.getFullYear(),\n date;\n\n for (var i = 0; i < 12; i++) {\n date = new Date(this.activeDate);\n date.setFullYear(year, i, 1);\n months[i] = angular.extend(this.createDateObject(date, this.formatMonth), {\n uid: scope.uniqueId + '-' + i\n });\n }\n\n scope.title = dateFilter(this.activeDate, this.formatMonthTitle);\n scope.rows = this.split(months, this.monthColumns);\n scope.yearHeaderColspan = this.monthColumns > 3 ? this.monthColumns - 2 : 1;\n };\n\n this.compare = function(date1, date2) {\n var _date1 = new Date(date1.getFullYear(), date1.getMonth());\n var _date2 = new Date(date2.getFullYear(), date2.getMonth());\n _date1.setFullYear(date1.getFullYear());\n _date2.setFullYear(date2.getFullYear());\n return _date1 - _date2;\n };\n\n this.handleKeyDown = function(key, evt) {\n var date = this.activeDate.getMonth();\n\n if (key === 'left') {\n date = date - 1;\n } else if (key === 'up') {\n date = date - this.monthColumns;\n } else if (key === 'right') {\n date = date + 1;\n } else if (key === 'down') {\n date = date + this.monthColumns;\n } else if (key === 'pageup' || key === 'pagedown') {\n var year = this.activeDate.getFullYear() + (key === 'pageup' ? - 1 : 1);\n this.activeDate.setFullYear(year);\n } else if (key === 'home') {\n date = 0;\n } else if (key === 'end') {\n date = 11;\n }\n this.activeDate.setMonth(date);\n };\n}])\n\n.controller('UibYearpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {\n var columns, range;\n this.element = $element;\n\n function getStartingYear(year) {\n return parseInt((year - 1) / range, 10) * range + 1;\n }\n\n this.yearpickerInit = function() {\n columns = this.yearColumns;\n range = this.yearRows * columns;\n this.step = { years: range };\n };\n\n this._refreshView = function() {\n var years = new Array(range), date;\n\n for (var i = 0, start = getStartingYear(this.activeDate.getFullYear()); i < range; i++) {\n date = new Date(this.activeDate);\n date.setFullYear(start + i, 0, 1);\n years[i] = angular.extend(this.createDateObject(date, this.formatYear), {\n uid: scope.uniqueId + '-' + i\n });\n }\n\n scope.title = [years[0].label, years[range - 1].label].join(' - ');\n scope.rows = this.split(years, columns);\n scope.columns = columns;\n };\n\n this.compare = function(date1, date2) {\n return date1.getFullYear() - date2.getFullYear();\n };\n\n this.handleKeyDown = function(key, evt) {\n var date = this.activeDate.getFullYear();\n\n if (key === 'left') {\n date = date - 1;\n } else if (key === 'up') {\n date = date - columns;\n } else if (key === 'right') {\n date = date + 1;\n } else if (key === 'down') {\n date = date + columns;\n } else if (key === 'pageup' || key === 'pagedown') {\n date += (key === 'pageup' ? - 1 : 1) * range;\n } else if (key === 'home') {\n date = getStartingYear(this.activeDate.getFullYear());\n } else if (key === 'end') {\n date = getStartingYear(this.activeDate.getFullYear()) + range - 1;\n }\n this.activeDate.setFullYear(date);\n };\n}])\n\n.directive('uibDatepicker', function() {\n return {\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/datepicker/datepicker.html';\n },\n scope: {\n datepickerOptions: '=?'\n },\n require: ['uibDatepicker', '^ngModel'],\n restrict: 'A',\n controller: 'UibDatepickerController',\n controllerAs: 'datepicker',\n link: function(scope, element, attrs, ctrls) {\n var datepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n datepickerCtrl.init(ngModelCtrl);\n }\n };\n})\n\n.directive('uibDaypicker', function() {\n return {\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/datepicker/day.html';\n },\n require: ['^uibDatepicker', 'uibDaypicker'],\n restrict: 'A',\n controller: 'UibDaypickerController',\n link: function(scope, element, attrs, ctrls) {\n var datepickerCtrl = ctrls[0],\n daypickerCtrl = ctrls[1];\n\n daypickerCtrl.init(datepickerCtrl);\n }\n };\n})\n\n.directive('uibMonthpicker', function() {\n return {\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/datepicker/month.html';\n },\n require: ['^uibDatepicker', 'uibMonthpicker'],\n restrict: 'A',\n controller: 'UibMonthpickerController',\n link: function(scope, element, attrs, ctrls) {\n var datepickerCtrl = ctrls[0],\n monthpickerCtrl = ctrls[1];\n\n monthpickerCtrl.init(datepickerCtrl);\n }\n };\n})\n\n.directive('uibYearpicker', function() {\n return {\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/datepicker/year.html';\n },\n require: ['^uibDatepicker', 'uibYearpicker'],\n restrict: 'A',\n controller: 'UibYearpickerController',\n link: function(scope, element, attrs, ctrls) {\n var ctrl = ctrls[0];\n angular.extend(ctrl, ctrls[1]);\n ctrl.yearpickerInit();\n\n ctrl.refreshView();\n }\n };\n});\n\nangular.module('ui.bootstrap.position', [])\n\n/**\n * A set of utility methods for working with the DOM.\n * It is meant to be used where we need to absolute-position elements in\n * relation to another element (this is the case for tooltips, popovers,\n * typeahead suggestions etc.).\n */\n .factory('$uibPosition', ['$document', '$window', function($document, $window) {\n /**\n * Used by scrollbarWidth() function to cache scrollbar's width.\n * Do not access this variable directly, use scrollbarWidth() instead.\n */\n var SCROLLBAR_WIDTH;\n /**\n * scrollbar on body and html element in IE and Edge overlay\n * content and should be considered 0 width.\n */\n var BODY_SCROLLBAR_WIDTH;\n var OVERFLOW_REGEX = {\n normal: /(auto|scroll)/,\n hidden: /(auto|scroll|hidden)/\n };\n var PLACEMENT_REGEX = {\n auto: /\\s?auto?\\s?/i,\n primary: /^(top|bottom|left|right)$/,\n secondary: /^(top|bottom|left|right|center)$/,\n vertical: /^(top|bottom)$/\n };\n var BODY_REGEX = /(HTML|BODY)/;\n\n return {\n\n /**\n * Provides a raw DOM element from a jQuery/jQLite element.\n *\n * @param {element} elem - The element to convert.\n *\n * @returns {element} A HTML element.\n */\n getRawNode: function(elem) {\n return elem.nodeName ? elem : elem[0] || elem;\n },\n\n /**\n * Provides a parsed number for a style property. Strips\n * units and casts invalid numbers to 0.\n *\n * @param {string} value - The style value to parse.\n *\n * @returns {number} A valid number.\n */\n parseStyle: function(value) {\n value = parseFloat(value);\n return isFinite(value) ? value : 0;\n },\n\n /**\n * Provides the closest positioned ancestor.\n *\n * @param {element} element - The element to get the offest parent for.\n *\n * @returns {element} The closest positioned ancestor.\n */\n offsetParent: function(elem) {\n elem = this.getRawNode(elem);\n\n var offsetParent = elem.offsetParent || $document[0].documentElement;\n\n function isStaticPositioned(el) {\n return ($window.getComputedStyle(el).position || 'static') === 'static';\n }\n\n while (offsetParent && offsetParent !== $document[0].documentElement && isStaticPositioned(offsetParent)) {\n offsetParent = offsetParent.offsetParent;\n }\n\n return offsetParent || $document[0].documentElement;\n },\n\n /**\n * Provides the scrollbar width, concept from TWBS measureScrollbar()\n * function in https://github.com/twbs/bootstrap/blob/master/js/modal.js\n * In IE and Edge, scollbar on body and html element overlay and should\n * return a width of 0.\n *\n * @returns {number} The width of the browser scollbar.\n */\n scrollbarWidth: function(isBody) {\n if (isBody) {\n if (angular.isUndefined(BODY_SCROLLBAR_WIDTH)) {\n var bodyElem = $document.find('body');\n bodyElem.addClass('uib-position-body-scrollbar-measure');\n BODY_SCROLLBAR_WIDTH = $window.innerWidth - bodyElem[0].clientWidth;\n BODY_SCROLLBAR_WIDTH = isFinite(BODY_SCROLLBAR_WIDTH) ? BODY_SCROLLBAR_WIDTH : 0;\n bodyElem.removeClass('uib-position-body-scrollbar-measure');\n }\n return BODY_SCROLLBAR_WIDTH;\n }\n\n if (angular.isUndefined(SCROLLBAR_WIDTH)) {\n var scrollElem = angular.element('
');\n $document.find('body').append(scrollElem);\n SCROLLBAR_WIDTH = scrollElem[0].offsetWidth - scrollElem[0].clientWidth;\n SCROLLBAR_WIDTH = isFinite(SCROLLBAR_WIDTH) ? SCROLLBAR_WIDTH : 0;\n scrollElem.remove();\n }\n\n return SCROLLBAR_WIDTH;\n },\n\n /**\n * Provides the padding required on an element to replace the scrollbar.\n *\n * @returns {object} An object with the following properties:\n *
\n * - **scrollbarWidth**: the width of the scrollbar
\n * - **widthOverflow**: whether the the width is overflowing
\n * - **right**: the amount of right padding on the element needed to replace the scrollbar
\n * - **rightOriginal**: the amount of right padding currently on the element
\n * - **heightOverflow**: whether the the height is overflowing
\n * - **bottom**: the amount of bottom padding on the element needed to replace the scrollbar
\n * - **bottomOriginal**: the amount of bottom padding currently on the element
\n *
\n */\n scrollbarPadding: function(elem) {\n elem = this.getRawNode(elem);\n\n var elemStyle = $window.getComputedStyle(elem);\n var paddingRight = this.parseStyle(elemStyle.paddingRight);\n var paddingBottom = this.parseStyle(elemStyle.paddingBottom);\n var scrollParent = this.scrollParent(elem, false, true);\n var scrollbarWidth = this.scrollbarWidth(BODY_REGEX.test(scrollParent.tagName));\n\n return {\n scrollbarWidth: scrollbarWidth,\n widthOverflow: scrollParent.scrollWidth > scrollParent.clientWidth,\n right: paddingRight + scrollbarWidth,\n originalRight: paddingRight,\n heightOverflow: scrollParent.scrollHeight > scrollParent.clientHeight,\n bottom: paddingBottom + scrollbarWidth,\n originalBottom: paddingBottom\n };\n },\n\n /**\n * Checks to see if the element is scrollable.\n *\n * @param {element} elem - The element to check.\n * @param {boolean=} [includeHidden=false] - Should scroll style of 'hidden' be considered,\n * default is false.\n *\n * @returns {boolean} Whether the element is scrollable.\n */\n isScrollable: function(elem, includeHidden) {\n elem = this.getRawNode(elem);\n\n var overflowRegex = includeHidden ? OVERFLOW_REGEX.hidden : OVERFLOW_REGEX.normal;\n var elemStyle = $window.getComputedStyle(elem);\n return overflowRegex.test(elemStyle.overflow + elemStyle.overflowY + elemStyle.overflowX);\n },\n\n /**\n * Provides the closest scrollable ancestor.\n * A port of the jQuery UI scrollParent method:\n * https://github.com/jquery/jquery-ui/blob/master/ui/scroll-parent.js\n *\n * @param {element} elem - The element to find the scroll parent of.\n * @param {boolean=} [includeHidden=false] - Should scroll style of 'hidden' be considered,\n * default is false.\n * @param {boolean=} [includeSelf=false] - Should the element being passed be\n * included in the scrollable llokup.\n *\n * @returns {element} A HTML element.\n */\n scrollParent: function(elem, includeHidden, includeSelf) {\n elem = this.getRawNode(elem);\n\n var overflowRegex = includeHidden ? OVERFLOW_REGEX.hidden : OVERFLOW_REGEX.normal;\n var documentEl = $document[0].documentElement;\n var elemStyle = $window.getComputedStyle(elem);\n if (includeSelf && overflowRegex.test(elemStyle.overflow + elemStyle.overflowY + elemStyle.overflowX)) {\n return elem;\n }\n var excludeStatic = elemStyle.position === 'absolute';\n var scrollParent = elem.parentElement || documentEl;\n\n if (scrollParent === documentEl || elemStyle.position === 'fixed') {\n return documentEl;\n }\n\n while (scrollParent.parentElement && scrollParent !== documentEl) {\n var spStyle = $window.getComputedStyle(scrollParent);\n if (excludeStatic && spStyle.position !== 'static') {\n excludeStatic = false;\n }\n\n if (!excludeStatic && overflowRegex.test(spStyle.overflow + spStyle.overflowY + spStyle.overflowX)) {\n break;\n }\n scrollParent = scrollParent.parentElement;\n }\n\n return scrollParent;\n },\n\n /**\n * Provides read-only equivalent of jQuery's position function:\n * http://api.jquery.com/position/ - distance to closest positioned\n * ancestor. Does not account for margins by default like jQuery position.\n *\n * @param {element} elem - The element to caclulate the position on.\n * @param {boolean=} [includeMargins=false] - Should margins be accounted\n * for, default is false.\n *\n * @returns {object} An object with the following properties:\n *
\n * - **width**: the width of the element
\n * - **height**: the height of the element
\n * - **top**: distance to top edge of offset parent
\n * - **left**: distance to left edge of offset parent
\n *
\n */\n position: function(elem, includeMagins) {\n elem = this.getRawNode(elem);\n\n var elemOffset = this.offset(elem);\n if (includeMagins) {\n var elemStyle = $window.getComputedStyle(elem);\n elemOffset.top -= this.parseStyle(elemStyle.marginTop);\n elemOffset.left -= this.parseStyle(elemStyle.marginLeft);\n }\n var parent = this.offsetParent(elem);\n var parentOffset = {top: 0, left: 0};\n\n if (parent !== $document[0].documentElement) {\n parentOffset = this.offset(parent);\n parentOffset.top += parent.clientTop - parent.scrollTop;\n parentOffset.left += parent.clientLeft - parent.scrollLeft;\n }\n\n return {\n width: Math.round(angular.isNumber(elemOffset.width) ? elemOffset.width : elem.offsetWidth),\n height: Math.round(angular.isNumber(elemOffset.height) ? elemOffset.height : elem.offsetHeight),\n top: Math.round(elemOffset.top - parentOffset.top),\n left: Math.round(elemOffset.left - parentOffset.left)\n };\n },\n\n /**\n * Provides read-only equivalent of jQuery's offset function:\n * http://api.jquery.com/offset/ - distance to viewport. Does\n * not account for borders, margins, or padding on the body\n * element.\n *\n * @param {element} elem - The element to calculate the offset on.\n *\n * @returns {object} An object with the following properties:\n *
\n * - **width**: the width of the element
\n * - **height**: the height of the element
\n * - **top**: distance to top edge of viewport
\n * - **right**: distance to bottom edge of viewport
\n *
\n */\n offset: function(elem) {\n elem = this.getRawNode(elem);\n\n var elemBCR = elem.getBoundingClientRect();\n return {\n width: Math.round(angular.isNumber(elemBCR.width) ? elemBCR.width : elem.offsetWidth),\n height: Math.round(angular.isNumber(elemBCR.height) ? elemBCR.height : elem.offsetHeight),\n top: Math.round(elemBCR.top + ($window.pageYOffset || $document[0].documentElement.scrollTop)),\n left: Math.round(elemBCR.left + ($window.pageXOffset || $document[0].documentElement.scrollLeft))\n };\n },\n\n /**\n * Provides offset distance to the closest scrollable ancestor\n * or viewport. Accounts for border and scrollbar width.\n *\n * Right and bottom dimensions represent the distance to the\n * respective edge of the viewport element. If the element\n * edge extends beyond the viewport, a negative value will be\n * reported.\n *\n * @param {element} elem - The element to get the viewport offset for.\n * @param {boolean=} [useDocument=false] - Should the viewport be the document element instead\n * of the first scrollable element, default is false.\n * @param {boolean=} [includePadding=true] - Should the padding on the offset parent element\n * be accounted for, default is true.\n *\n * @returns {object} An object with the following properties:\n *
\n * - **top**: distance to the top content edge of viewport element
\n * - **bottom**: distance to the bottom content edge of viewport element
\n * - **left**: distance to the left content edge of viewport element
\n * - **right**: distance to the right content edge of viewport element
\n *
\n */\n viewportOffset: function(elem, useDocument, includePadding) {\n elem = this.getRawNode(elem);\n includePadding = includePadding !== false ? true : false;\n\n var elemBCR = elem.getBoundingClientRect();\n var offsetBCR = {top: 0, left: 0, bottom: 0, right: 0};\n\n var offsetParent = useDocument ? $document[0].documentElement : this.scrollParent(elem);\n var offsetParentBCR = offsetParent.getBoundingClientRect();\n\n offsetBCR.top = offsetParentBCR.top + offsetParent.clientTop;\n offsetBCR.left = offsetParentBCR.left + offsetParent.clientLeft;\n if (offsetParent === $document[0].documentElement) {\n offsetBCR.top += $window.pageYOffset;\n offsetBCR.left += $window.pageXOffset;\n }\n offsetBCR.bottom = offsetBCR.top + offsetParent.clientHeight;\n offsetBCR.right = offsetBCR.left + offsetParent.clientWidth;\n\n if (includePadding) {\n var offsetParentStyle = $window.getComputedStyle(offsetParent);\n offsetBCR.top += this.parseStyle(offsetParentStyle.paddingTop);\n offsetBCR.bottom -= this.parseStyle(offsetParentStyle.paddingBottom);\n offsetBCR.left += this.parseStyle(offsetParentStyle.paddingLeft);\n offsetBCR.right -= this.parseStyle(offsetParentStyle.paddingRight);\n }\n\n return {\n top: Math.round(elemBCR.top - offsetBCR.top),\n bottom: Math.round(offsetBCR.bottom - elemBCR.bottom),\n left: Math.round(elemBCR.left - offsetBCR.left),\n right: Math.round(offsetBCR.right - elemBCR.right)\n };\n },\n\n /**\n * Provides an array of placement values parsed from a placement string.\n * Along with the 'auto' indicator, supported placement strings are:\n *
\n * - top: element on top, horizontally centered on host element.
\n * - top-left: element on top, left edge aligned with host element left edge.
\n * - top-right: element on top, lerightft edge aligned with host element right edge.
\n * - bottom: element on bottom, horizontally centered on host element.
\n * - bottom-left: element on bottom, left edge aligned with host element left edge.
\n * - bottom-right: element on bottom, right edge aligned with host element right edge.
\n * - left: element on left, vertically centered on host element.
\n * - left-top: element on left, top edge aligned with host element top edge.
\n * - left-bottom: element on left, bottom edge aligned with host element bottom edge.
\n * - right: element on right, vertically centered on host element.
\n * - right-top: element on right, top edge aligned with host element top edge.
\n * - right-bottom: element on right, bottom edge aligned with host element bottom edge.
\n *
\n * A placement string with an 'auto' indicator is expected to be\n * space separated from the placement, i.e: 'auto bottom-left' If\n * the primary and secondary placement values do not match 'top,\n * bottom, left, right' then 'top' will be the primary placement and\n * 'center' will be the secondary placement. If 'auto' is passed, true\n * will be returned as the 3rd value of the array.\n *\n * @param {string} placement - The placement string to parse.\n *\n * @returns {array} An array with the following values\n *
\n * - **[0]**: The primary placement.
\n * - **[1]**: The secondary placement.
\n * - **[2]**: If auto is passed: true, else undefined.
\n *
\n */\n parsePlacement: function(placement) {\n var autoPlace = PLACEMENT_REGEX.auto.test(placement);\n if (autoPlace) {\n placement = placement.replace(PLACEMENT_REGEX.auto, '');\n }\n\n placement = placement.split('-');\n\n placement[0] = placement[0] || 'top';\n if (!PLACEMENT_REGEX.primary.test(placement[0])) {\n placement[0] = 'top';\n }\n\n placement[1] = placement[1] || 'center';\n if (!PLACEMENT_REGEX.secondary.test(placement[1])) {\n placement[1] = 'center';\n }\n\n if (autoPlace) {\n placement[2] = true;\n } else {\n placement[2] = false;\n }\n\n return placement;\n },\n\n /**\n * Provides coordinates for an element to be positioned relative to\n * another element. Passing 'auto' as part of the placement parameter\n * will enable smart placement - where the element fits. i.e:\n * 'auto left-top' will check to see if there is enough space to the left\n * of the hostElem to fit the targetElem, if not place right (same for secondary\n * top placement). Available space is calculated using the viewportOffset\n * function.\n *\n * @param {element} hostElem - The element to position against.\n * @param {element} targetElem - The element to position.\n * @param {string=} [placement=top] - The placement for the targetElem,\n * default is 'top'. 'center' is assumed as secondary placement for\n * 'top', 'left', 'right', and 'bottom' placements. Available placements are:\n *
\n * - top
\n * - top-right
\n * - top-left
\n * - bottom
\n * - bottom-left
\n * - bottom-right
\n * - left
\n * - left-top
\n * - left-bottom
\n * - right
\n * - right-top
\n * - right-bottom
\n *
\n * @param {boolean=} [appendToBody=false] - Should the top and left values returned\n * be calculated from the body element, default is false.\n *\n * @returns {object} An object with the following properties:\n *
\n * - **top**: Value for targetElem top.
\n * - **left**: Value for targetElem left.
\n * - **placement**: The resolved placement.
\n *
\n */\n positionElements: function(hostElem, targetElem, placement, appendToBody) {\n hostElem = this.getRawNode(hostElem);\n targetElem = this.getRawNode(targetElem);\n\n // need to read from prop to support tests.\n var targetWidth = angular.isDefined(targetElem.offsetWidth) ? targetElem.offsetWidth : targetElem.prop('offsetWidth');\n var targetHeight = angular.isDefined(targetElem.offsetHeight) ? targetElem.offsetHeight : targetElem.prop('offsetHeight');\n\n placement = this.parsePlacement(placement);\n\n var hostElemPos = appendToBody ? this.offset(hostElem) : this.position(hostElem);\n var targetElemPos = {top: 0, left: 0, placement: ''};\n\n if (placement[2]) {\n var viewportOffset = this.viewportOffset(hostElem, appendToBody);\n\n var targetElemStyle = $window.getComputedStyle(targetElem);\n var adjustedSize = {\n width: targetWidth + Math.round(Math.abs(this.parseStyle(targetElemStyle.marginLeft) + this.parseStyle(targetElemStyle.marginRight))),\n height: targetHeight + Math.round(Math.abs(this.parseStyle(targetElemStyle.marginTop) + this.parseStyle(targetElemStyle.marginBottom)))\n };\n\n placement[0] = placement[0] === 'top' && adjustedSize.height > viewportOffset.top && adjustedSize.height <= viewportOffset.bottom ? 'bottom' :\n placement[0] === 'bottom' && adjustedSize.height > viewportOffset.bottom && adjustedSize.height <= viewportOffset.top ? 'top' :\n placement[0] === 'left' && adjustedSize.width > viewportOffset.left && adjustedSize.width <= viewportOffset.right ? 'right' :\n placement[0] === 'right' && adjustedSize.width > viewportOffset.right && adjustedSize.width <= viewportOffset.left ? 'left' :\n placement[0];\n\n placement[1] = placement[1] === 'top' && adjustedSize.height - hostElemPos.height > viewportOffset.bottom && adjustedSize.height - hostElemPos.height <= viewportOffset.top ? 'bottom' :\n placement[1] === 'bottom' && adjustedSize.height - hostElemPos.height > viewportOffset.top && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom ? 'top' :\n placement[1] === 'left' && adjustedSize.width - hostElemPos.width > viewportOffset.right && adjustedSize.width - hostElemPos.width <= viewportOffset.left ? 'right' :\n placement[1] === 'right' && adjustedSize.width - hostElemPos.width > viewportOffset.left && adjustedSize.width - hostElemPos.width <= viewportOffset.right ? 'left' :\n placement[1];\n\n if (placement[1] === 'center') {\n if (PLACEMENT_REGEX.vertical.test(placement[0])) {\n var xOverflow = hostElemPos.width / 2 - targetWidth / 2;\n if (viewportOffset.left + xOverflow < 0 && adjustedSize.width - hostElemPos.width <= viewportOffset.right) {\n placement[1] = 'left';\n } else if (viewportOffset.right + xOverflow < 0 && adjustedSize.width - hostElemPos.width <= viewportOffset.left) {\n placement[1] = 'right';\n }\n } else {\n var yOverflow = hostElemPos.height / 2 - adjustedSize.height / 2;\n if (viewportOffset.top + yOverflow < 0 && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom) {\n placement[1] = 'top';\n } else if (viewportOffset.bottom + yOverflow < 0 && adjustedSize.height - hostElemPos.height <= viewportOffset.top) {\n placement[1] = 'bottom';\n }\n }\n }\n }\n\n switch (placement[0]) {\n case 'top':\n targetElemPos.top = hostElemPos.top - targetHeight;\n break;\n case 'bottom':\n targetElemPos.top = hostElemPos.top + hostElemPos.height;\n break;\n case 'left':\n targetElemPos.left = hostElemPos.left - targetWidth;\n break;\n case 'right':\n targetElemPos.left = hostElemPos.left + hostElemPos.width;\n break;\n }\n\n switch (placement[1]) {\n case 'top':\n targetElemPos.top = hostElemPos.top;\n break;\n case 'bottom':\n targetElemPos.top = hostElemPos.top + hostElemPos.height - targetHeight;\n break;\n case 'left':\n targetElemPos.left = hostElemPos.left;\n break;\n case 'right':\n targetElemPos.left = hostElemPos.left + hostElemPos.width - targetWidth;\n break;\n case 'center':\n if (PLACEMENT_REGEX.vertical.test(placement[0])) {\n targetElemPos.left = hostElemPos.left + hostElemPos.width / 2 - targetWidth / 2;\n } else {\n targetElemPos.top = hostElemPos.top + hostElemPos.height / 2 - targetHeight / 2;\n }\n break;\n }\n\n targetElemPos.top = Math.round(targetElemPos.top);\n targetElemPos.left = Math.round(targetElemPos.left);\n targetElemPos.placement = placement[1] === 'center' ? placement[0] : placement[0] + '-' + placement[1];\n\n return targetElemPos;\n },\n\n /**\n * Provides a way to adjust the top positioning after first\n * render to correctly align element to top after content\n * rendering causes resized element height\n *\n * @param {array} placementClasses - The array of strings of classes\n * element should have.\n * @param {object} containerPosition - The object with container\n * position information\n * @param {number} initialHeight - The initial height for the elem.\n * @param {number} currentHeight - The current height for the elem.\n */\n adjustTop: function(placementClasses, containerPosition, initialHeight, currentHeight) {\n if (placementClasses.indexOf('top') !== -1 && initialHeight !== currentHeight) {\n return {\n top: containerPosition.top - currentHeight + 'px'\n };\n }\n },\n\n /**\n * Provides a way for positioning tooltip & dropdown\n * arrows when using placement options beyond the standard\n * left, right, top, or bottom.\n *\n * @param {element} elem - The tooltip/dropdown element.\n * @param {string} placement - The placement for the elem.\n */\n positionArrow: function(elem, placement) {\n elem = this.getRawNode(elem);\n\n var innerElem = elem.querySelector('.tooltip-inner, .popover-inner');\n if (!innerElem) {\n return;\n }\n\n var isTooltip = angular.element(innerElem).hasClass('tooltip-inner');\n\n var arrowElem = isTooltip ? elem.querySelector('.tooltip-arrow') : elem.querySelector('.arrow');\n if (!arrowElem) {\n return;\n }\n\n var arrowCss = {\n top: '',\n bottom: '',\n left: '',\n right: ''\n };\n\n placement = this.parsePlacement(placement);\n if (placement[1] === 'center') {\n // no adjustment necessary - just reset styles\n angular.element(arrowElem).css(arrowCss);\n return;\n }\n\n var borderProp = 'border-' + placement[0] + '-width';\n var borderWidth = $window.getComputedStyle(arrowElem)[borderProp];\n\n var borderRadiusProp = 'border-';\n if (PLACEMENT_REGEX.vertical.test(placement[0])) {\n borderRadiusProp += placement[0] + '-' + placement[1];\n } else {\n borderRadiusProp += placement[1] + '-' + placement[0];\n }\n borderRadiusProp += '-radius';\n var borderRadius = $window.getComputedStyle(isTooltip ? innerElem : elem)[borderRadiusProp];\n\n switch (placement[0]) {\n case 'top':\n arrowCss.bottom = isTooltip ? '0' : '-' + borderWidth;\n break;\n case 'bottom':\n arrowCss.top = isTooltip ? '0' : '-' + borderWidth;\n break;\n case 'left':\n arrowCss.right = isTooltip ? '0' : '-' + borderWidth;\n break;\n case 'right':\n arrowCss.left = isTooltip ? '0' : '-' + borderWidth;\n break;\n }\n\n arrowCss[placement[1]] = borderRadius;\n\n angular.element(arrowElem).css(arrowCss);\n }\n };\n }]);\n\nangular.module('ui.bootstrap.datepickerPopup', ['ui.bootstrap.datepicker', 'ui.bootstrap.position'])\n\n.value('$datepickerPopupLiteralWarning', true)\n\n.constant('uibDatepickerPopupConfig', {\n altInputFormats: [],\n appendToBody: false,\n clearText: 'Clear',\n closeOnDateSelection: true,\n closeText: 'Done',\n currentText: 'Today',\n datepickerPopup: 'yyyy-MM-dd',\n datepickerPopupTemplateUrl: 'uib/template/datepickerPopup/popup.html',\n datepickerTemplateUrl: 'uib/template/datepicker/datepicker.html',\n html5Types: {\n date: 'yyyy-MM-dd',\n 'datetime-local': 'yyyy-MM-ddTHH:mm:ss.sss',\n 'month': 'yyyy-MM'\n },\n onOpenFocus: true,\n showButtonBar: true,\n placement: 'auto bottom-left'\n})\n\n.controller('UibDatepickerPopupController', ['$scope', '$element', '$attrs', '$compile', '$log', '$parse', '$window', '$document', '$rootScope', '$uibPosition', 'dateFilter', 'uibDateParser', 'uibDatepickerPopupConfig', '$timeout', 'uibDatepickerConfig', '$datepickerPopupLiteralWarning',\nfunction($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $rootScope, $position, dateFilter, dateParser, datepickerPopupConfig, $timeout, datepickerConfig, $datepickerPopupLiteralWarning) {\n var cache = {},\n isHtml5DateInput = false;\n var dateFormat, closeOnDateSelection, appendToBody, onOpenFocus,\n datepickerPopupTemplateUrl, datepickerTemplateUrl, popupEl, datepickerEl, scrollParentEl,\n ngModel, ngModelOptions, $popup, altInputFormats, watchListeners = [];\n\n this.init = function(_ngModel_) {\n ngModel = _ngModel_;\n ngModelOptions = angular.isObject(_ngModel_.$options) ?\n _ngModel_.$options :\n {\n timezone: null\n };\n closeOnDateSelection = angular.isDefined($attrs.closeOnDateSelection) ?\n $scope.$parent.$eval($attrs.closeOnDateSelection) :\n datepickerPopupConfig.closeOnDateSelection;\n appendToBody = angular.isDefined($attrs.datepickerAppendToBody) ?\n $scope.$parent.$eval($attrs.datepickerAppendToBody) :\n datepickerPopupConfig.appendToBody;\n onOpenFocus = angular.isDefined($attrs.onOpenFocus) ?\n $scope.$parent.$eval($attrs.onOpenFocus) : datepickerPopupConfig.onOpenFocus;\n datepickerPopupTemplateUrl = angular.isDefined($attrs.datepickerPopupTemplateUrl) ?\n $attrs.datepickerPopupTemplateUrl :\n datepickerPopupConfig.datepickerPopupTemplateUrl;\n datepickerTemplateUrl = angular.isDefined($attrs.datepickerTemplateUrl) ?\n $attrs.datepickerTemplateUrl : datepickerPopupConfig.datepickerTemplateUrl;\n altInputFormats = angular.isDefined($attrs.altInputFormats) ?\n $scope.$parent.$eval($attrs.altInputFormats) :\n datepickerPopupConfig.altInputFormats;\n\n $scope.showButtonBar = angular.isDefined($attrs.showButtonBar) ?\n $scope.$parent.$eval($attrs.showButtonBar) :\n datepickerPopupConfig.showButtonBar;\n\n if (datepickerPopupConfig.html5Types[$attrs.type]) {\n dateFormat = datepickerPopupConfig.html5Types[$attrs.type];\n isHtml5DateInput = true;\n } else {\n dateFormat = $attrs.uibDatepickerPopup || datepickerPopupConfig.datepickerPopup;\n $attrs.$observe('uibDatepickerPopup', function(value, oldValue) {\n var newDateFormat = value || datepickerPopupConfig.datepickerPopup;\n // Invalidate the $modelValue to ensure that formatters re-run\n // FIXME: Refactor when PR is merged: https://github.com/angular/angular.js/pull/10764\n if (newDateFormat !== dateFormat) {\n dateFormat = newDateFormat;\n ngModel.$modelValue = null;\n\n if (!dateFormat) {\n throw new Error('uibDatepickerPopup must have a date format specified.');\n }\n }\n });\n }\n\n if (!dateFormat) {\n throw new Error('uibDatepickerPopup must have a date format specified.');\n }\n\n if (isHtml5DateInput && $attrs.uibDatepickerPopup) {\n throw new Error('HTML5 date input types do not support custom formats.');\n }\n\n // popup element used to display calendar\n popupEl = angular.element('
');\n\n popupEl.attr({\n 'ng-model': 'date',\n 'ng-change': 'dateSelection(date)',\n 'template-url': datepickerPopupTemplateUrl\n });\n\n // datepicker element\n datepickerEl = angular.element(popupEl.children()[0]);\n datepickerEl.attr('template-url', datepickerTemplateUrl);\n\n if (!$scope.datepickerOptions) {\n $scope.datepickerOptions = {};\n }\n\n if (isHtml5DateInput) {\n if ($attrs.type === 'month') {\n $scope.datepickerOptions.datepickerMode = 'month';\n $scope.datepickerOptions.minMode = 'month';\n }\n }\n\n datepickerEl.attr('datepicker-options', 'datepickerOptions');\n\n if (!isHtml5DateInput) {\n // Internal API to maintain the correct ng-invalid-[key] class\n ngModel.$$parserName = 'date';\n ngModel.$validators.date = validator;\n ngModel.$parsers.unshift(parseDate);\n ngModel.$formatters.push(function(value) {\n if (ngModel.$isEmpty(value)) {\n $scope.date = value;\n return value;\n }\n\n if (angular.isNumber(value)) {\n value = new Date(value);\n }\n\n $scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone);\n\n return dateParser.filter($scope.date, dateFormat);\n });\n } else {\n ngModel.$formatters.push(function(value) {\n $scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone);\n return value;\n });\n }\n\n // Detect changes in the view from the text box\n ngModel.$viewChangeListeners.push(function() {\n $scope.date = parseDateString(ngModel.$viewValue);\n });\n\n $element.on('keydown', inputKeydownBind);\n\n $popup = $compile(popupEl)($scope);\n // Prevent jQuery cache memory leak (template is now redundant after linking)\n popupEl.remove();\n\n if (appendToBody) {\n $document.find('body').append($popup);\n } else {\n $element.after($popup);\n }\n\n $scope.$on('$destroy', function() {\n if ($scope.isOpen === true) {\n if (!$rootScope.$$phase) {\n $scope.$apply(function() {\n $scope.isOpen = false;\n });\n }\n }\n\n $popup.remove();\n $element.off('keydown', inputKeydownBind);\n $document.off('click', documentClickBind);\n if (scrollParentEl) {\n scrollParentEl.off('scroll', positionPopup);\n }\n angular.element($window).off('resize', positionPopup);\n\n //Clear all watch listeners on destroy\n while (watchListeners.length) {\n watchListeners.shift()();\n }\n });\n };\n\n $scope.getText = function(key) {\n return $scope[key + 'Text'] || datepickerPopupConfig[key + 'Text'];\n };\n\n $scope.isDisabled = function(date) {\n if (date === 'today') {\n date = dateParser.fromTimezone(new Date(), ngModelOptions.timezone);\n }\n\n var dates = {};\n angular.forEach(['minDate', 'maxDate'], function(key) {\n if (!$scope.datepickerOptions[key]) {\n dates[key] = null;\n } else if (angular.isDate($scope.datepickerOptions[key])) {\n dates[key] = new Date($scope.datepickerOptions[key]);\n } else {\n if ($datepickerPopupLiteralWarning) {\n $log.warn('Literal date support has been deprecated, please switch to date object usage');\n }\n\n dates[key] = new Date(dateFilter($scope.datepickerOptions[key], 'medium'));\n }\n });\n\n return $scope.datepickerOptions &&\n dates.minDate && $scope.compare(date, dates.minDate) < 0 ||\n dates.maxDate && $scope.compare(date, dates.maxDate) > 0;\n };\n\n $scope.compare = function(date1, date2) {\n return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()) - new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());\n };\n\n // Inner change\n $scope.dateSelection = function(dt) {\n $scope.date = dt;\n var date = $scope.date ? dateParser.filter($scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function\n $element.val(date);\n ngModel.$setViewValue(date);\n\n if (closeOnDateSelection) {\n $scope.isOpen = false;\n $element[0].focus();\n }\n };\n\n $scope.keydown = function(evt) {\n if (evt.which === 27) {\n evt.stopPropagation();\n $scope.isOpen = false;\n $element[0].focus();\n }\n };\n\n $scope.select = function(date, evt) {\n evt.stopPropagation();\n\n if (date === 'today') {\n var today = new Date();\n if (angular.isDate($scope.date)) {\n date = new Date($scope.date);\n date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());\n } else {\n date = dateParser.fromTimezone(today, ngModelOptions.timezone);\n date.setHours(0, 0, 0, 0);\n }\n }\n $scope.dateSelection(date);\n };\n\n $scope.close = function(evt) {\n evt.stopPropagation();\n\n $scope.isOpen = false;\n $element[0].focus();\n };\n\n $scope.disabled = angular.isDefined($attrs.disabled) || false;\n if ($attrs.ngDisabled) {\n watchListeners.push($scope.$parent.$watch($parse($attrs.ngDisabled), function(disabled) {\n $scope.disabled = disabled;\n }));\n }\n\n $scope.$watch('isOpen', function(value) {\n if (value) {\n if (!$scope.disabled) {\n $timeout(function() {\n positionPopup();\n\n if (onOpenFocus) {\n $scope.$broadcast('uib:datepicker.focus');\n }\n\n $document.on('click', documentClickBind);\n\n var placement = $attrs.popupPlacement ? $attrs.popupPlacement : datepickerPopupConfig.placement;\n if (appendToBody || $position.parsePlacement(placement)[2]) {\n scrollParentEl = scrollParentEl || angular.element($position.scrollParent($element));\n if (scrollParentEl) {\n scrollParentEl.on('scroll', positionPopup);\n }\n } else {\n scrollParentEl = null;\n }\n\n angular.element($window).on('resize', positionPopup);\n }, 0, false);\n } else {\n $scope.isOpen = false;\n }\n } else {\n $document.off('click', documentClickBind);\n if (scrollParentEl) {\n scrollParentEl.off('scroll', positionPopup);\n }\n angular.element($window).off('resize', positionPopup);\n }\n });\n\n function cameltoDash(string) {\n return string.replace(/([A-Z])/g, function($1) { return '-' + $1.toLowerCase(); });\n }\n\n function parseDateString(viewValue) {\n var date = dateParser.parse(viewValue, dateFormat, $scope.date);\n if (isNaN(date)) {\n for (var i = 0; i < altInputFormats.length; i++) {\n date = dateParser.parse(viewValue, altInputFormats[i], $scope.date);\n if (!isNaN(date)) {\n return date;\n }\n }\n }\n return date;\n }\n\n function parseDate(viewValue) {\n if (angular.isNumber(viewValue)) {\n // presumably timestamp to date object\n viewValue = new Date(viewValue);\n }\n\n if (!viewValue) {\n return null;\n }\n\n if (angular.isDate(viewValue) && !isNaN(viewValue)) {\n return viewValue;\n }\n\n if (angular.isString(viewValue)) {\n var date = parseDateString(viewValue);\n if (!isNaN(date)) {\n return dateParser.fromTimezone(date, ngModelOptions.timezone);\n }\n }\n\n return ngModel.$options && ngModel.$options.allowInvalid ? viewValue : undefined;\n }\n\n function validator(modelValue, viewValue) {\n var value = modelValue || viewValue;\n\n if (!$attrs.ngRequired && !value) {\n return true;\n }\n\n if (angular.isNumber(value)) {\n value = new Date(value);\n }\n\n if (!value) {\n return true;\n }\n\n if (angular.isDate(value) && !isNaN(value)) {\n return true;\n }\n\n if (angular.isString(value)) {\n return !isNaN(parseDateString(value));\n }\n\n return false;\n }\n\n function documentClickBind(event) {\n if (!$scope.isOpen && $scope.disabled) {\n return;\n }\n\n var popup = $popup[0];\n var dpContainsTarget = $element[0].contains(event.target);\n // The popup node may not be an element node\n // In some browsers (IE) only element nodes have the 'contains' function\n var popupContainsTarget = popup.contains !== undefined && popup.contains(event.target);\n if ($scope.isOpen && !(dpContainsTarget || popupContainsTarget)) {\n $scope.$apply(function() {\n $scope.isOpen = false;\n });\n }\n }\n\n function inputKeydownBind(evt) {\n if (evt.which === 27 && $scope.isOpen) {\n evt.preventDefault();\n evt.stopPropagation();\n $scope.$apply(function() {\n $scope.isOpen = false;\n });\n $element[0].focus();\n } else if (evt.which === 40 && !$scope.isOpen) {\n evt.preventDefault();\n evt.stopPropagation();\n $scope.$apply(function() {\n $scope.isOpen = true;\n });\n }\n }\n\n function positionPopup() {\n if ($scope.isOpen) {\n var dpElement = angular.element($popup[0].querySelector('.uib-datepicker-popup'));\n var placement = $attrs.popupPlacement ? $attrs.popupPlacement : datepickerPopupConfig.placement;\n var position = $position.positionElements($element, dpElement, placement, appendToBody);\n dpElement.css({top: position.top + 'px', left: position.left + 'px'});\n if (dpElement.hasClass('uib-position-measure')) {\n dpElement.removeClass('uib-position-measure');\n }\n }\n }\n\n $scope.$on('uib:datepicker.mode', function() {\n $timeout(positionPopup, 0, false);\n });\n}])\n\n.directive('uibDatepickerPopup', function() {\n return {\n require: ['ngModel', 'uibDatepickerPopup'],\n controller: 'UibDatepickerPopupController',\n scope: {\n datepickerOptions: '=?',\n isOpen: '=?',\n currentText: '@',\n clearText: '@',\n closeText: '@'\n },\n link: function(scope, element, attrs, ctrls) {\n var ngModel = ctrls[0],\n ctrl = ctrls[1];\n\n ctrl.init(ngModel);\n }\n };\n})\n\n.directive('uibDatepickerPopupWrap', function() {\n return {\n restrict: 'A',\n transclude: true,\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/datepickerPopup/popup.html';\n }\n };\n});\n\nangular.module('ui.bootstrap.debounce', [])\n/**\n * A helper, internal service that debounces a function\n */\n .factory('$$debounce', ['$timeout', function($timeout) {\n return function(callback, debounceTime) {\n var timeoutPromise;\n\n return function() {\n var self = this;\n var args = Array.prototype.slice.call(arguments);\n if (timeoutPromise) {\n $timeout.cancel(timeoutPromise);\n }\n\n timeoutPromise = $timeout(function() {\n callback.apply(self, args);\n }, debounceTime);\n };\n };\n }]);\n\nangular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])\n\n.constant('uibDropdownConfig', {\n appendToOpenClass: 'uib-dropdown-open',\n openClass: 'open'\n})\n\n.service('uibDropdownService', ['$document', '$rootScope', function($document, $rootScope) {\n var openScope = null;\n\n this.open = function(dropdownScope, element) {\n if (!openScope) {\n $document.on('click', closeDropdown);\n }\n\n if (openScope && openScope !== dropdownScope) {\n openScope.isOpen = false;\n }\n\n openScope = dropdownScope;\n };\n\n this.close = function(dropdownScope, element) {\n if (openScope === dropdownScope) {\n $document.off('click', closeDropdown);\n $document.off('keydown', this.keybindFilter);\n openScope = null;\n }\n };\n\n var closeDropdown = function(evt) {\n // This method may still be called during the same mouse event that\n // unbound this event handler. So check openScope before proceeding.\n if (!openScope) { return; }\n\n if (evt && openScope.getAutoClose() === 'disabled') { return; }\n\n if (evt && evt.which === 3) { return; }\n\n var toggleElement = openScope.getToggleElement();\n if (evt && toggleElement && toggleElement[0].contains(evt.target)) {\n return;\n }\n\n var dropdownElement = openScope.getDropdownElement();\n if (evt && openScope.getAutoClose() === 'outsideClick' &&\n dropdownElement && dropdownElement[0].contains(evt.target)) {\n return;\n }\n\n openScope.focusToggleElement();\n openScope.isOpen = false;\n\n if (!$rootScope.$$phase) {\n openScope.$apply();\n }\n };\n\n this.keybindFilter = function(evt) {\n if (!openScope) {\n // see this.close as ESC could have been pressed which kills the scope so we can not proceed\n return;\n }\n\n var dropdownElement = openScope.getDropdownElement();\n var toggleElement = openScope.getToggleElement();\n var dropdownElementTargeted = dropdownElement && dropdownElement[0].contains(evt.target);\n var toggleElementTargeted = toggleElement && toggleElement[0].contains(evt.target);\n if (evt.which === 27) {\n evt.stopPropagation();\n openScope.focusToggleElement();\n closeDropdown();\n } else if (openScope.isKeynavEnabled() && [38, 40].indexOf(evt.which) !== -1 && openScope.isOpen && (dropdownElementTargeted || toggleElementTargeted)) {\n evt.preventDefault();\n evt.stopPropagation();\n openScope.focusDropdownEntry(evt.which);\n }\n };\n}])\n\n.controller('UibDropdownController', ['$scope', '$element', '$attrs', '$parse', 'uibDropdownConfig', 'uibDropdownService', '$animate', '$uibPosition', '$document', '$compile', '$templateRequest', function($scope, $element, $attrs, $parse, dropdownConfig, uibDropdownService, $animate, $position, $document, $compile, $templateRequest) {\n var self = this,\n scope = $scope.$new(), // create a child scope so we are not polluting original one\n templateScope,\n appendToOpenClass = dropdownConfig.appendToOpenClass,\n openClass = dropdownConfig.openClass,\n getIsOpen,\n setIsOpen = angular.noop,\n toggleInvoker = $attrs.onToggle ? $parse($attrs.onToggle) : angular.noop,\n appendToBody = false,\n appendTo = null,\n keynavEnabled = false,\n selectedOption = null,\n body = $document.find('body');\n\n $element.addClass('dropdown');\n\n this.init = function() {\n if ($attrs.isOpen) {\n getIsOpen = $parse($attrs.isOpen);\n setIsOpen = getIsOpen.assign;\n\n $scope.$watch(getIsOpen, function(value) {\n scope.isOpen = !!value;\n });\n }\n\n if (angular.isDefined($attrs.dropdownAppendTo)) {\n var appendToEl = $parse($attrs.dropdownAppendTo)(scope);\n if (appendToEl) {\n appendTo = angular.element(appendToEl);\n }\n }\n\n appendToBody = angular.isDefined($attrs.dropdownAppendToBody);\n keynavEnabled = angular.isDefined($attrs.keyboardNav);\n\n if (appendToBody && !appendTo) {\n appendTo = body;\n }\n\n if (appendTo && self.dropdownMenu) {\n appendTo.append(self.dropdownMenu);\n $element.on('$destroy', function handleDestroyEvent() {\n self.dropdownMenu.remove();\n });\n }\n };\n\n this.toggle = function(open) {\n scope.isOpen = arguments.length ? !!open : !scope.isOpen;\n if (angular.isFunction(setIsOpen)) {\n setIsOpen(scope, scope.isOpen);\n }\n\n return scope.isOpen;\n };\n\n // Allow other directives to watch status\n this.isOpen = function() {\n return scope.isOpen;\n };\n\n scope.getToggleElement = function() {\n return self.toggleElement;\n };\n\n scope.getAutoClose = function() {\n return $attrs.autoClose || 'always'; //or 'outsideClick' or 'disabled'\n };\n\n scope.getElement = function() {\n return $element;\n };\n\n scope.isKeynavEnabled = function() {\n return keynavEnabled;\n };\n\n scope.focusDropdownEntry = function(keyCode) {\n var elems = self.dropdownMenu ? //If append to body is used.\n angular.element(self.dropdownMenu).find('a') :\n $element.find('ul').eq(0).find('a');\n\n switch (keyCode) {\n case 40: {\n if (!angular.isNumber(self.selectedOption)) {\n self.selectedOption = 0;\n } else {\n self.selectedOption = self.selectedOption === elems.length - 1 ?\n self.selectedOption :\n self.selectedOption + 1;\n }\n break;\n }\n case 38: {\n if (!angular.isNumber(self.selectedOption)) {\n self.selectedOption = elems.length - 1;\n } else {\n self.selectedOption = self.selectedOption === 0 ?\n 0 : self.selectedOption - 1;\n }\n break;\n }\n }\n elems[self.selectedOption].focus();\n };\n\n scope.getDropdownElement = function() {\n return self.dropdownMenu;\n };\n\n scope.focusToggleElement = function() {\n if (self.toggleElement) {\n self.toggleElement[0].focus();\n }\n };\n\n scope.$watch('isOpen', function(isOpen, wasOpen) {\n if (appendTo && self.dropdownMenu) {\n var pos = $position.positionElements($element, self.dropdownMenu, 'bottom-left', true),\n css,\n rightalign,\n scrollbarPadding,\n scrollbarWidth = 0;\n\n css = {\n top: pos.top + 'px',\n display: isOpen ? 'block' : 'none'\n };\n\n rightalign = self.dropdownMenu.hasClass('dropdown-menu-right');\n if (!rightalign) {\n css.left = pos.left + 'px';\n css.right = 'auto';\n } else {\n css.left = 'auto';\n scrollbarPadding = $position.scrollbarPadding(appendTo);\n\n if (scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {\n scrollbarWidth = scrollbarPadding.scrollbarWidth;\n }\n\n css.right = window.innerWidth - scrollbarWidth -\n (pos.left + $element.prop('offsetWidth')) + 'px';\n }\n\n // Need to adjust our positioning to be relative to the appendTo container\n // if it's not the body element\n if (!appendToBody) {\n var appendOffset = $position.offset(appendTo);\n\n css.top = pos.top - appendOffset.top + 'px';\n\n if (!rightalign) {\n css.left = pos.left - appendOffset.left + 'px';\n } else {\n css.right = window.innerWidth -\n (pos.left - appendOffset.left + $element.prop('offsetWidth')) + 'px';\n }\n }\n\n self.dropdownMenu.css(css);\n }\n\n var openContainer = appendTo ? appendTo : $element;\n var hasOpenClass = openContainer.hasClass(appendTo ? appendToOpenClass : openClass);\n\n if (hasOpenClass === !isOpen) {\n $animate[isOpen ? 'addClass' : 'removeClass'](openContainer, appendTo ? appendToOpenClass : openClass).then(function() {\n if (angular.isDefined(isOpen) && isOpen !== wasOpen) {\n toggleInvoker($scope, { open: !!isOpen });\n }\n });\n }\n\n if (isOpen) {\n if (self.dropdownMenuTemplateUrl) {\n $templateRequest(self.dropdownMenuTemplateUrl).then(function(tplContent) {\n templateScope = scope.$new();\n $compile(tplContent.trim())(templateScope, function(dropdownElement) {\n var newEl = dropdownElement;\n self.dropdownMenu.replaceWith(newEl);\n self.dropdownMenu = newEl;\n $document.on('keydown', uibDropdownService.keybindFilter);\n });\n });\n } else {\n $document.on('keydown', uibDropdownService.keybindFilter);\n }\n\n scope.focusToggleElement();\n uibDropdownService.open(scope, $element);\n } else {\n uibDropdownService.close(scope, $element);\n if (self.dropdownMenuTemplateUrl) {\n if (templateScope) {\n templateScope.$destroy();\n }\n var newEl = angular.element('');\n self.dropdownMenu.replaceWith(newEl);\n self.dropdownMenu = newEl;\n }\n\n self.selectedOption = null;\n }\n\n if (angular.isFunction(setIsOpen)) {\n setIsOpen($scope, isOpen);\n }\n });\n}])\n\n.directive('uibDropdown', function() {\n return {\n controller: 'UibDropdownController',\n link: function(scope, element, attrs, dropdownCtrl) {\n dropdownCtrl.init();\n }\n };\n})\n\n.directive('uibDropdownMenu', function() {\n return {\n restrict: 'A',\n require: '?^uibDropdown',\n link: function(scope, element, attrs, dropdownCtrl) {\n if (!dropdownCtrl || angular.isDefined(attrs.dropdownNested)) {\n return;\n }\n\n element.addClass('dropdown-menu');\n\n var tplUrl = attrs.templateUrl;\n if (tplUrl) {\n dropdownCtrl.dropdownMenuTemplateUrl = tplUrl;\n }\n\n if (!dropdownCtrl.dropdownMenu) {\n dropdownCtrl.dropdownMenu = element;\n }\n }\n };\n})\n\n.directive('uibDropdownToggle', function() {\n return {\n require: '?^uibDropdown',\n link: function(scope, element, attrs, dropdownCtrl) {\n if (!dropdownCtrl) {\n return;\n }\n\n element.addClass('dropdown-toggle');\n\n dropdownCtrl.toggleElement = element;\n\n var toggleDropdown = function(event) {\n event.preventDefault();\n\n if (!element.hasClass('disabled') && !attrs.disabled) {\n scope.$apply(function() {\n dropdownCtrl.toggle();\n });\n }\n };\n\n element.bind('click', toggleDropdown);\n\n // WAI-ARIA\n element.attr({ 'aria-haspopup': true, 'aria-expanded': false });\n scope.$watch(dropdownCtrl.isOpen, function(isOpen) {\n element.attr('aria-expanded', !!isOpen);\n });\n\n scope.$on('$destroy', function() {\n element.unbind('click', toggleDropdown);\n });\n }\n };\n});\n\nangular.module('ui.bootstrap.stackedMap', [])\n/**\n * A helper, internal data structure that acts as a map but also allows getting / removing\n * elements in the LIFO order\n */\n .factory('$$stackedMap', function() {\n return {\n createNew: function() {\n var stack = [];\n\n return {\n add: function(key, value) {\n stack.push({\n key: key,\n value: value\n });\n },\n get: function(key) {\n for (var i = 0; i < stack.length; i++) {\n if (key === stack[i].key) {\n return stack[i];\n }\n }\n },\n keys: function() {\n var keys = [];\n for (var i = 0; i < stack.length; i++) {\n keys.push(stack[i].key);\n }\n return keys;\n },\n top: function() {\n return stack[stack.length - 1];\n },\n remove: function(key) {\n var idx = -1;\n for (var i = 0; i < stack.length; i++) {\n if (key === stack[i].key) {\n idx = i;\n break;\n }\n }\n return stack.splice(idx, 1)[0];\n },\n removeTop: function() {\n return stack.pop();\n },\n length: function() {\n return stack.length;\n }\n };\n }\n };\n });\nangular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.position'])\n/**\n * A helper, internal data structure that stores all references attached to key\n */\n .factory('$$multiMap', function() {\n return {\n createNew: function() {\n var map = {};\n\n return {\n entries: function() {\n return Object.keys(map).map(function(key) {\n return {\n key: key,\n value: map[key]\n };\n });\n },\n get: function(key) {\n return map[key];\n },\n hasKey: function(key) {\n return !!map[key];\n },\n keys: function() {\n return Object.keys(map);\n },\n put: function(key, value) {\n if (!map[key]) {\n map[key] = [];\n }\n\n map[key].push(value);\n },\n remove: function(key, value) {\n var values = map[key];\n\n if (!values) {\n return;\n }\n\n var idx = values.indexOf(value);\n\n if (idx !== -1) {\n values.splice(idx, 1);\n }\n\n if (!values.length) {\n delete map[key];\n }\n }\n };\n }\n };\n })\n\n/**\n * Pluggable resolve mechanism for the modal resolve resolution\n * Supports UI Router's $resolve service\n */\n .provider('$uibResolve', function() {\n var resolve = this;\n this.resolver = null;\n\n this.setResolver = function(resolver) {\n this.resolver = resolver;\n };\n\n this.$get = ['$injector', '$q', function($injector, $q) {\n var resolver = resolve.resolver ? $injector.get(resolve.resolver) : null;\n return {\n resolve: function(invocables, locals, parent, self) {\n if (resolver) {\n return resolver.resolve(invocables, locals, parent, self);\n }\n\n var promises = [];\n\n angular.forEach(invocables, function(value) {\n if (angular.isFunction(value) || angular.isArray(value)) {\n promises.push($q.resolve($injector.invoke(value)));\n } else if (angular.isString(value)) {\n promises.push($q.resolve($injector.get(value)));\n } else {\n promises.push($q.resolve(value));\n }\n });\n\n return $q.all(promises).then(function(resolves) {\n var resolveObj = {};\n var resolveIter = 0;\n angular.forEach(invocables, function(value, key) {\n resolveObj[key] = resolves[resolveIter++];\n });\n\n return resolveObj;\n });\n }\n };\n }];\n })\n\n/**\n * A helper directive for the $modal service. It creates a backdrop element.\n */\n .directive('uibModalBackdrop', ['$animate', '$injector', '$uibModalStack',\n function($animate, $injector, $modalStack) {\n return {\n restrict: 'A',\n compile: function(tElement, tAttrs) {\n tElement.addClass(tAttrs.backdropClass);\n return linkFn;\n }\n };\n\n function linkFn(scope, element, attrs) {\n if (attrs.modalInClass) {\n $animate.addClass(element, attrs.modalInClass);\n\n scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {\n var done = setIsAsync();\n if (scope.modalOptions.animation) {\n $animate.removeClass(element, attrs.modalInClass).then(done);\n } else {\n done();\n }\n });\n }\n }\n }])\n\n .directive('uibModalWindow', ['$uibModalStack', '$q', '$animateCss', '$document',\n function($modalStack, $q, $animateCss, $document) {\n return {\n scope: {\n index: '@'\n },\n restrict: 'A',\n transclude: true,\n templateUrl: function(tElement, tAttrs) {\n return tAttrs.templateUrl || 'uib/template/modal/window.html';\n },\n link: function(scope, element, attrs) {\n element.addClass(attrs.windowTopClass || '');\n scope.size = attrs.size;\n\n scope.close = function(evt) {\n var modal = $modalStack.getTop();\n if (modal && modal.value.backdrop &&\n modal.value.backdrop !== 'static' &&\n evt.target === evt.currentTarget) {\n evt.preventDefault();\n evt.stopPropagation();\n $modalStack.dismiss(modal.key, 'backdrop click');\n }\n };\n\n // moved from template to fix issue #2280\n element.on('click', scope.close);\n\n // This property is only added to the scope for the purpose of detecting when this directive is rendered.\n // We can detect that by using this property in the template associated with this directive and then use\n // {@link Attribute#$observe} on it. For more details please see {@link TableColumnResize}.\n scope.$isRendered = true;\n\n // Deferred object that will be resolved when this modal is rendered.\n var modalRenderDeferObj = $q.defer();\n // Resolve render promise post-digest\n scope.$$postDigest(function() {\n modalRenderDeferObj.resolve();\n });\n\n modalRenderDeferObj.promise.then(function() {\n var animationPromise = null;\n\n if (attrs.modalInClass) {\n animationPromise = $animateCss(element, {\n addClass: attrs.modalInClass\n }).start();\n\n scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {\n var done = setIsAsync();\n $animateCss(element, {\n removeClass: attrs.modalInClass\n }).start().then(done);\n });\n }\n\n\n $q.when(animationPromise).then(function() {\n // Notify {@link $modalStack} that modal is rendered.\n var modal = $modalStack.getTop();\n if (modal) {\n $modalStack.modalRendered(modal.key);\n }\n\n /**\n * If something within the freshly-opened modal already has focus (perhaps via a\n * directive that causes focus) then there's no need to try to focus anything.\n */\n if (!($document[0].activeElement && element[0].contains($document[0].activeElement))) {\n var inputWithAutofocus = element[0].querySelector('[autofocus]');\n /**\n * Auto-focusing of a freshly-opened modal element causes any child elements\n * with the autofocus attribute to lose focus. This is an issue on touch\n * based devices which will show and then hide the onscreen keyboard.\n * Attempts to refocus the autofocus element via JavaScript will not reopen\n * the onscreen keyboard. Fixed by updated the focusing logic to only autofocus\n * the modal element if the modal does not contain an autofocus element.\n */\n if (inputWithAutofocus) {\n inputWithAutofocus.focus();\n } else {\n element[0].focus();\n }\n }\n });\n });\n }\n };\n }])\n\n .directive('uibModalAnimationClass', function() {\n return {\n compile: function(tElement, tAttrs) {\n if (tAttrs.modalAnimation) {\n tElement.addClass(tAttrs.uibModalAnimationClass);\n }\n }\n };\n })\n\n .directive('uibModalTransclude', ['$animate', function($animate) {\n return {\n link: function(scope, element, attrs, controller, transclude) {\n transclude(scope.$parent, function(clone) {\n element.empty();\n $animate.enter(clone, element);\n });\n }\n };\n }])\n\n .factory('$uibModalStack', ['$animate', '$animateCss', '$document',\n '$compile', '$rootScope', '$q', '$$multiMap', '$$stackedMap', '$uibPosition',\n function($animate, $animateCss, $document, $compile, $rootScope, $q, $$multiMap, $$stackedMap, $uibPosition) {\n var OPENED_MODAL_CLASS = 'modal-open';\n\n var backdropDomEl, backdropScope;\n var openedWindows = $$stackedMap.createNew();\n var openedClasses = $$multiMap.createNew();\n var $modalStack = {\n NOW_CLOSING_EVENT: 'modal.stack.now-closing'\n };\n var topModalIndex = 0;\n var previousTopOpenedModal = null;\n var ARIA_HIDDEN_ATTRIBUTE_NAME = 'data-bootstrap-modal-aria-hidden-count';\n\n //Modal focus behavior\n var tabbableSelector = 'a[href], area[href], input:not([disabled]):not([tabindex=\\'-1\\']), ' +\n 'button:not([disabled]):not([tabindex=\\'-1\\']),select:not([disabled]):not([tabindex=\\'-1\\']), textarea:not([disabled]):not([tabindex=\\'-1\\']), ' +\n 'iframe, object, embed, *[tabindex]:not([tabindex=\\'-1\\']), *[contenteditable=true]';\n var scrollbarPadding;\n var SNAKE_CASE_REGEXP = /[A-Z]/g;\n\n // TODO: extract into common dependency with tooltip\n function snake_case(name) {\n var separator = '-';\n return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) {\n return (pos ? separator : '') + letter.toLowerCase();\n });\n }\n\n function isVisible(element) {\n return !!(element.offsetWidth ||\n element.offsetHeight ||\n element.getClientRects().length);\n }\n\n function backdropIndex() {\n var topBackdropIndex = -1;\n var opened = openedWindows.keys();\n for (var i = 0; i < opened.length; i++) {\n if (openedWindows.get(opened[i]).value.backdrop) {\n topBackdropIndex = i;\n }\n }\n\n // If any backdrop exist, ensure that it's index is always\n // right below the top modal\n if (topBackdropIndex > -1 && topBackdropIndex < topModalIndex) {\n topBackdropIndex = topModalIndex;\n }\n return topBackdropIndex;\n }\n\n $rootScope.$watch(backdropIndex, function(newBackdropIndex) {\n if (backdropScope) {\n backdropScope.index = newBackdropIndex;\n }\n });\n\n function removeModalWindow(modalInstance, elementToReceiveFocus) {\n var modalWindow = openedWindows.get(modalInstance).value;\n var appendToElement = modalWindow.appendTo;\n\n //clean up the stack\n openedWindows.remove(modalInstance);\n previousTopOpenedModal = openedWindows.top();\n if (previousTopOpenedModal) {\n topModalIndex = parseInt(previousTopOpenedModal.value.modalDomEl.attr('index'), 10);\n }\n\n removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, function() {\n var modalBodyClass = modalWindow.openedClass || OPENED_MODAL_CLASS;\n openedClasses.remove(modalBodyClass, modalInstance);\n var areAnyOpen = openedClasses.hasKey(modalBodyClass);\n appendToElement.toggleClass(modalBodyClass, areAnyOpen);\n if (!areAnyOpen && scrollbarPadding && scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {\n if (scrollbarPadding.originalRight) {\n appendToElement.css({paddingRight: scrollbarPadding.originalRight + 'px'});\n } else {\n appendToElement.css({paddingRight: ''});\n }\n scrollbarPadding = null;\n }\n toggleTopWindowClass(true);\n }, modalWindow.closedDeferred);\n checkRemoveBackdrop();\n\n //move focus to specified element if available, or else to body\n if (elementToReceiveFocus && elementToReceiveFocus.focus) {\n elementToReceiveFocus.focus();\n } else if (appendToElement.focus) {\n appendToElement.focus();\n }\n }\n\n // Add or remove \"windowTopClass\" from the top window in the stack\n function toggleTopWindowClass(toggleSwitch) {\n var modalWindow;\n\n if (openedWindows.length() > 0) {\n modalWindow = openedWindows.top().value;\n modalWindow.modalDomEl.toggleClass(modalWindow.windowTopClass || '', toggleSwitch);\n }\n }\n\n function checkRemoveBackdrop() {\n //remove backdrop if no longer needed\n if (backdropDomEl && backdropIndex() === -1) {\n var backdropScopeRef = backdropScope;\n removeAfterAnimate(backdropDomEl, backdropScope, function() {\n backdropScopeRef = null;\n });\n backdropDomEl = undefined;\n backdropScope = undefined;\n }\n }\n\n function removeAfterAnimate(domEl, scope, done, closedDeferred) {\n var asyncDeferred;\n var asyncPromise = null;\n var setIsAsync = function() {\n if (!asyncDeferred) {\n asyncDeferred = $q.defer();\n asyncPromise = asyncDeferred.promise;\n }\n\n return function asyncDone() {\n asyncDeferred.resolve();\n };\n };\n scope.$broadcast($modalStack.NOW_CLOSING_EVENT, setIsAsync);\n\n // Note that it's intentional that asyncPromise might be null.\n // That's when setIsAsync has not been called during the\n // NOW_CLOSING_EVENT broadcast.\n return $q.when(asyncPromise).then(afterAnimating);\n\n function afterAnimating() {\n if (afterAnimating.done) {\n return;\n }\n afterAnimating.done = true;\n\n $animate.leave(domEl).then(function() {\n if (done) {\n done();\n }\n\n domEl.remove();\n if (closedDeferred) {\n closedDeferred.resolve();\n }\n });\n\n scope.$destroy();\n }\n }\n\n $document.on('keydown', keydownListener);\n\n $rootScope.$on('$destroy', function() {\n $document.off('keydown', keydownListener);\n });\n\n function keydownListener(evt) {\n if (evt.isDefaultPrevented()) {\n return evt;\n }\n\n var modal = openedWindows.top();\n if (modal) {\n switch (evt.which) {\n case 27: {\n if (modal.value.keyboard) {\n evt.preventDefault();\n $rootScope.$apply(function() {\n $modalStack.dismiss(modal.key, 'escape key press');\n });\n }\n break;\n }\n case 9: {\n var list = $modalStack.loadFocusElementList(modal);\n var focusChanged = false;\n if (evt.shiftKey) {\n if ($modalStack.isFocusInFirstItem(evt, list) || $modalStack.isModalFocused(evt, modal)) {\n focusChanged = $modalStack.focusLastFocusableElement(list);\n }\n } else {\n if ($modalStack.isFocusInLastItem(evt, list)) {\n focusChanged = $modalStack.focusFirstFocusableElement(list);\n }\n }\n\n if (focusChanged) {\n evt.preventDefault();\n evt.stopPropagation();\n }\n\n break;\n }\n }\n }\n }\n\n $modalStack.open = function(modalInstance, modal) {\n var modalOpener = $document[0].activeElement,\n modalBodyClass = modal.openedClass || OPENED_MODAL_CLASS;\n\n toggleTopWindowClass(false);\n\n // Store the current top first, to determine what index we ought to use\n // for the current top modal\n previousTopOpenedModal = openedWindows.top();\n\n openedWindows.add(modalInstance, {\n deferred: modal.deferred,\n renderDeferred: modal.renderDeferred,\n closedDeferred: modal.closedDeferred,\n modalScope: modal.scope,\n backdrop: modal.backdrop,\n keyboard: modal.keyboard,\n openedClass: modal.openedClass,\n windowTopClass: modal.windowTopClass,\n animation: modal.animation,\n appendTo: modal.appendTo\n });\n\n openedClasses.put(modalBodyClass, modalInstance);\n\n var appendToElement = modal.appendTo,\n currBackdropIndex = backdropIndex();\n\n if (!appendToElement.length) {\n throw new Error('appendTo element not found. Make sure that the element passed is in DOM.');\n }\n\n if (currBackdropIndex >= 0 && !backdropDomEl) {\n backdropScope = $rootScope.$new(true);\n backdropScope.modalOptions = modal;\n backdropScope.index = currBackdropIndex;\n backdropDomEl = angular.element('
');\n backdropDomEl.attr({\n 'class': 'modal-backdrop',\n 'ng-style': '{\\'z-index\\': 1040 + (index && 1 || 0) + index*10}',\n 'uib-modal-animation-class': 'fade',\n 'modal-in-class': 'in'\n });\n if (modal.backdropClass) {\n backdropDomEl.addClass(modal.backdropClass);\n }\n\n if (modal.animation) {\n backdropDomEl.attr('modal-animation', 'true');\n }\n $compile(backdropDomEl)(backdropScope);\n $animate.enter(backdropDomEl, appendToElement);\n if ($uibPosition.isScrollable(appendToElement)) {\n scrollbarPadding = $uibPosition.scrollbarPadding(appendToElement);\n if (scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {\n appendToElement.css({paddingRight: scrollbarPadding.right + 'px'});\n }\n }\n }\n\n var content;\n if (modal.component) {\n content = document.createElement(snake_case(modal.component.name));\n content = angular.element(content);\n content.attr({\n resolve: '$resolve',\n 'modal-instance': '$uibModalInstance',\n close: '$close($value)',\n dismiss: '$dismiss($value)'\n });\n } else {\n content = modal.content;\n }\n\n // Set the top modal index based on the index of the previous top modal\n topModalIndex = previousTopOpenedModal ? parseInt(previousTopOpenedModal.value.modalDomEl.attr('index'), 10) + 1 : 0;\n var angularDomEl = angular.element('
');\n angularDomEl.attr({\n 'class': 'modal',\n 'template-url': modal.windowTemplateUrl,\n 'window-top-class': modal.windowTopClass,\n 'role': 'dialog',\n 'aria-labelledby': modal.ariaLabelledBy,\n 'aria-describedby': modal.ariaDescribedBy,\n 'size': modal.size,\n 'index': topModalIndex,\n 'animate': 'animate',\n 'ng-style': '{\\'z-index\\': 1050 + $$topModalIndex*10, display: \\'block\\'}',\n 'tabindex': -1,\n 'uib-modal-animation-class': 'fade',\n 'modal-in-class': 'in'\n }).append(content);\n if (modal.windowClass) {\n angularDomEl.addClass(modal.windowClass);\n }\n\n if (modal.animation) {\n angularDomEl.attr('modal-animation', 'true');\n }\n\n appendToElement.addClass(modalBodyClass);\n if (modal.scope) {\n // we need to explicitly add the modal index to the modal scope\n // because it is needed by ngStyle to compute the zIndex property.\n modal.scope.$$topModalIndex = topModalIndex;\n }\n $animate.enter($compile(angularDomEl)(modal.scope), appendToElement);\n\n openedWindows.top().value.modalDomEl = angularDomEl;\n openedWindows.top().value.modalOpener = modalOpener;\n\n applyAriaHidden(angularDomEl);\n\n function applyAriaHidden(el) {\n if (!el || el[0].tagName === 'BODY') {\n return;\n }\n\n getSiblings(el).forEach(function(sibling) {\n var elemIsAlreadyHidden = sibling.getAttribute('aria-hidden') === 'true',\n ariaHiddenCount = parseInt(sibling.getAttribute(ARIA_HIDDEN_ATTRIBUTE_NAME), 10);\n\n if (!ariaHiddenCount) {\n ariaHiddenCount = elemIsAlreadyHidden ? 1 : 0; \n }\n\n sibling.setAttribute(ARIA_HIDDEN_ATTRIBUTE_NAME, ariaHiddenCount + 1);\n sibling.setAttribute('aria-hidden', 'true');\n });\n\n return applyAriaHidden(el.parent());\n\n function getSiblings(el) {\n var children = el.parent() ? el.parent().children() : [];\n\n return Array.prototype.filter.call(children, function(child) {\n return child !== el[0];\n });\n }\n }\n };\n\n function broadcastClosing(modalWindow, resultOrReason, closing) {\n return !modalWindow.value.modalScope.$broadcast('modal.closing', resultOrReason, closing).defaultPrevented;\n }\n\n function unhideBackgroundElements() {\n Array.prototype.forEach.call(\n document.querySelectorAll('[' + ARIA_HIDDEN_ATTRIBUTE_NAME + ']'),\n function(hiddenEl) {\n var ariaHiddenCount = parseInt(hiddenEl.getAttribute(ARIA_HIDDEN_ATTRIBUTE_NAME), 10),\n newHiddenCount = ariaHiddenCount - 1;\n hiddenEl.setAttribute(ARIA_HIDDEN_ATTRIBUTE_NAME, newHiddenCount);\n\n if (!newHiddenCount) {\n hiddenEl.removeAttribute(ARIA_HIDDEN_ATTRIBUTE_NAME);\n hiddenEl.removeAttribute('aria-hidden');\n }\n }\n );\n }\n \n $modalStack.close = function(modalInstance, result) {\n var modalWindow = openedWindows.get(modalInstance);\n unhideBackgroundElements();\n if (modalWindow && broadcastClosing(modalWindow, result, true)) {\n modalWindow.value.modalScope.$$uibDestructionScheduled = true;\n modalWindow.value.deferred.resolve(result);\n removeModalWindow(modalInstance, modalWindow.value.modalOpener);\n return true;\n }\n\n return !modalWindow;\n };\n\n $modalStack.dismiss = function(modalInstance, reason) {\n var modalWindow = openedWindows.get(modalInstance);\n unhideBackgroundElements();\n if (modalWindow && broadcastClosing(modalWindow, reason, false)) {\n modalWindow.value.modalScope.$$uibDestructionScheduled = true;\n modalWindow.value.deferred.reject(reason);\n removeModalWindow(modalInstance, modalWindow.value.modalOpener);\n return true;\n }\n return !modalWindow;\n };\n\n $modalStack.dismissAll = function(reason) {\n var topModal = this.getTop();\n while (topModal && this.dismiss(topModal.key, reason)) {\n topModal = this.getTop();\n }\n };\n\n $modalStack.getTop = function() {\n return openedWindows.top();\n };\n\n $modalStack.modalRendered = function(modalInstance) {\n var modalWindow = openedWindows.get(modalInstance);\n $modalStack.focusFirstFocusableElement($modalStack.loadFocusElementList(modalWindow));\n if (modalWindow) {\n modalWindow.value.renderDeferred.resolve();\n }\n };\n\n $modalStack.focusFirstFocusableElement = function(list) {\n if (list.length > 0) {\n list[0].focus();\n return true;\n }\n return false;\n };\n\n $modalStack.focusLastFocusableElement = function(list) {\n if (list.length > 0) {\n list[list.length - 1].focus();\n return true;\n }\n return false;\n };\n\n $modalStack.isModalFocused = function(evt, modalWindow) {\n if (evt && modalWindow) {\n var modalDomEl = modalWindow.value.modalDomEl;\n if (modalDomEl && modalDomEl.length) {\n return (evt.target || evt.srcElement) === modalDomEl[0];\n }\n }\n return false;\n };\n\n $modalStack.isFocusInFirstItem = function(evt, list) {\n if (list.length > 0) {\n return (evt.target || evt.srcElement) === list[0];\n }\n return false;\n };\n\n $modalStack.isFocusInLastItem = function(evt, list) {\n if (list.length > 0) {\n return (evt.target || evt.srcElement) === list[list.length - 1];\n }\n return false;\n };\n\n $modalStack.loadFocusElementList = function(modalWindow) {\n if (modalWindow) {\n var modalDomE1 = modalWindow.value.modalDomEl;\n if (modalDomE1 && modalDomE1.length) {\n var elements = modalDomE1[0].querySelectorAll(tabbableSelector);\n return elements ?\n Array.prototype.filter.call(elements, function(element) {\n return isVisible(element);\n }) : elements;\n }\n }\n };\n\n return $modalStack;\n }])\n\n .provider('$uibModal', function() {\n var $modalProvider = {\n options: {\n animation: true,\n backdrop: true, //can also be false or 'static'\n keyboard: true\n },\n $get: ['$rootScope', '$q', '$document', '$templateRequest', '$controller', '$uibResolve', '$uibModalStack',\n function ($rootScope, $q, $document, $templateRequest, $controller, $uibResolve, $modalStack) {\n var $modal = {};\n\n function getTemplatePromise(options) {\n return options.template ? $q.when(options.template) :\n $templateRequest(angular.isFunction(options.templateUrl) ?\n options.templateUrl() : options.templateUrl);\n }\n\n var promiseChain = null;\n $modal.getPromiseChain = function() {\n return promiseChain;\n };\n\n $modal.open = function(modalOptions) {\n var modalResultDeferred = $q.defer();\n var modalOpenedDeferred = $q.defer();\n var modalClosedDeferred = $q.defer();\n var modalRenderDeferred = $q.defer();\n\n //prepare an instance of a modal to be injected into controllers and returned to a caller\n var modalInstance = {\n result: modalResultDeferred.promise,\n opened: modalOpenedDeferred.promise,\n closed: modalClosedDeferred.promise,\n rendered: modalRenderDeferred.promise,\n close: function (result) {\n return $modalStack.close(modalInstance, result);\n },\n dismiss: function (reason) {\n return $modalStack.dismiss(modalInstance, reason);\n }\n };\n\n //merge and clean up options\n modalOptions = angular.extend({}, $modalProvider.options, modalOptions);\n modalOptions.resolve = modalOptions.resolve || {};\n modalOptions.appendTo = modalOptions.appendTo || $document.find('body').eq(0);\n\n //verify options\n if (!modalOptions.component && !modalOptions.template && !modalOptions.templateUrl) {\n throw new Error('One of component or template or templateUrl options is required.');\n }\n\n var templateAndResolvePromise;\n if (modalOptions.component) {\n templateAndResolvePromise = $q.when($uibResolve.resolve(modalOptions.resolve, {}, null, null));\n } else {\n templateAndResolvePromise =\n $q.all([getTemplatePromise(modalOptions), $uibResolve.resolve(modalOptions.resolve, {}, null, null)]);\n }\n\n function resolveWithTemplate() {\n return templateAndResolvePromise;\n }\n\n // Wait for the resolution of the existing promise chain.\n // Then switch to our own combined promise dependency (regardless of how the previous modal fared).\n // Then add to $modalStack and resolve opened.\n // Finally clean up the chain variable if no subsequent modal has overwritten it.\n var samePromise;\n samePromise = promiseChain = $q.all([promiseChain])\n .then(resolveWithTemplate, resolveWithTemplate)\n .then(function resolveSuccess(tplAndVars) {\n var providedScope = modalOptions.scope || $rootScope;\n\n var modalScope = providedScope.$new();\n modalScope.$close = modalInstance.close;\n modalScope.$dismiss = modalInstance.dismiss;\n\n modalScope.$on('$destroy', function() {\n if (!modalScope.$$uibDestructionScheduled) {\n modalScope.$dismiss('$uibUnscheduledDestruction');\n }\n });\n\n var modal = {\n scope: modalScope,\n deferred: modalResultDeferred,\n renderDeferred: modalRenderDeferred,\n closedDeferred: modalClosedDeferred,\n animation: modalOptions.animation,\n backdrop: modalOptions.backdrop,\n keyboard: modalOptions.keyboard,\n backdropClass: modalOptions.backdropClass,\n windowTopClass: modalOptions.windowTopClass,\n windowClass: modalOptions.windowClass,\n windowTemplateUrl: modalOptions.windowTemplateUrl,\n ariaLabelledBy: modalOptions.ariaLabelledBy,\n ariaDescribedBy: modalOptions.ariaDescribedBy,\n size: modalOptions.size,\n openedClass: modalOptions.openedClass,\n appendTo: modalOptions.appendTo\n };\n\n var component = {};\n var ctrlInstance, ctrlInstantiate, ctrlLocals = {};\n\n if (modalOptions.component) {\n constructLocals(component, false, true, false);\n component.name = modalOptions.component;\n modal.component = component;\n } else if (modalOptions.controller) {\n constructLocals(ctrlLocals, true, false, true);\n\n // the third param will make the controller instantiate later,private api\n // @see https://github.com/angular/angular.js/blob/master/src/ng/controller.js#L126\n ctrlInstantiate = $controller(modalOptions.controller, ctrlLocals, true, modalOptions.controllerAs);\n if (modalOptions.controllerAs && modalOptions.bindToController) {\n ctrlInstance = ctrlInstantiate.instance;\n ctrlInstance.$close = modalScope.$close;\n ctrlInstance.$dismiss = modalScope.$dismiss;\n angular.extend(ctrlInstance, {\n $resolve: ctrlLocals.$scope.$resolve\n }, providedScope);\n }\n\n ctrlInstance = ctrlInstantiate();\n\n if (angular.isFunction(ctrlInstance.$onInit)) {\n ctrlInstance.$onInit();\n }\n }\n\n if (!modalOptions.component) {\n modal.content = tplAndVars[0];\n }\n\n $modalStack.open(modalInstance, modal);\n modalOpenedDeferred.resolve(true);\n\n function constructLocals(obj, template, instanceOnScope, injectable) {\n obj.$scope = modalScope;\n obj.$scope.$resolve = {};\n if (instanceOnScope) {\n obj.$scope.$uibModalInstance = modalInstance;\n } else {\n obj.$uibModalInstance = modalInstance;\n }\n\n var resolves = template ? tplAndVars[1] : tplAndVars;\n angular.forEach(resolves, function(value, key) {\n if (injectable) {\n obj[key] = value;\n }\n\n obj.$scope.$resolve[key] = value;\n });\n }\n }, function resolveError(reason) {\n modalOpenedDeferred.reject(reason);\n modalResultDeferred.reject(reason);\n })['finally'](function() {\n if (promiseChain === samePromise) {\n promiseChain = null;\n }\n });\n\n return modalInstance;\n };\n\n return $modal;\n }\n ]\n };\n\n return $modalProvider;\n });\n\nangular.module('ui.bootstrap.paging', [])\n/**\n * Helper internal service for generating common controller code between the\n * pager and pagination components\n */\n.factory('uibPaging', ['$parse', function($parse) {\n return {\n create: function(ctrl, $scope, $attrs) {\n ctrl.setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;\n ctrl.ngModelCtrl = { $setViewValue: angular.noop }; // nullModelCtrl\n ctrl._watchers = [];\n\n ctrl.init = function(ngModelCtrl, config) {\n ctrl.ngModelCtrl = ngModelCtrl;\n ctrl.config = config;\n\n ngModelCtrl.$render = function() {\n ctrl.render();\n };\n\n if ($attrs.itemsPerPage) {\n ctrl._watchers.push($scope.$parent.$watch($attrs.itemsPerPage, function(value) {\n ctrl.itemsPerPage = parseInt(value, 10);\n $scope.totalPages = ctrl.calculateTotalPages();\n ctrl.updatePage();\n }));\n } else {\n ctrl.itemsPerPage = config.itemsPerPage;\n }\n\n $scope.$watch('totalItems', function(newTotal, oldTotal) {\n if (angular.isDefined(newTotal) || newTotal !== oldTotal) {\n $scope.totalPages = ctrl.calculateTotalPages();\n ctrl.updatePage();\n }\n });\n };\n\n ctrl.calculateTotalPages = function() {\n var totalPages = ctrl.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / ctrl.itemsPerPage);\n return Math.max(totalPages || 0, 1);\n };\n\n ctrl.render = function() {\n $scope.page = parseInt(ctrl.ngModelCtrl.$viewValue, 10) || 1;\n };\n\n $scope.selectPage = function(page, evt) {\n if (evt) {\n evt.preventDefault();\n }\n\n var clickAllowed = !$scope.ngDisabled || !evt;\n if (clickAllowed && $scope.page !== page && page > 0 && page <= $scope.totalPages) {\n if (evt && evt.target) {\n evt.target.blur();\n }\n ctrl.ngModelCtrl.$setViewValue(page);\n ctrl.ngModelCtrl.$render();\n }\n };\n\n $scope.getText = function(key) {\n return $scope[key + 'Text'] || ctrl.config[key + 'Text'];\n };\n\n $scope.noPrevious = function() {\n return $scope.page === 1;\n };\n\n $scope.noNext = function() {\n return $scope.page === $scope.totalPages;\n };\n\n ctrl.updatePage = function() {\n ctrl.setNumPages($scope.$parent, $scope.totalPages); // Readonly variable\n\n if ($scope.page > $scope.totalPages) {\n $scope.selectPage($scope.totalPages);\n } else {\n ctrl.ngModelCtrl.$render();\n }\n };\n\n $scope.$on('$destroy', function() {\n while (ctrl._watchers.length) {\n ctrl._watchers.shift()();\n }\n });\n }\n };\n}]);\n\nangular.module('ui.bootstrap.pager', ['ui.bootstrap.paging', 'ui.bootstrap.tabindex'])\n\n.controller('UibPagerController', ['$scope', '$attrs', 'uibPaging', 'uibPagerConfig', function($scope, $attrs, uibPaging, uibPagerConfig) {\n $scope.align = angular.isDefined($attrs.align) ? $scope.$parent.$eval($attrs.align) : uibPagerConfig.align;\n\n uibPaging.create(this, $scope, $attrs);\n}])\n\n.constant('uibPagerConfig', {\n itemsPerPage: 10,\n previousText: '« Previous',\n nextText: 'Next »',\n align: true\n})\n\n.directive('uibPager', ['uibPagerConfig', function(uibPagerConfig) {\n return {\n scope: {\n totalItems: '=',\n previousText: '@',\n nextText: '@',\n ngDisabled: '='\n },\n require: ['uibPager', '?ngModel'],\n restrict: 'A',\n controller: 'UibPagerController',\n controllerAs: 'pager',\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/pager/pager.html';\n },\n link: function(scope, element, attrs, ctrls) {\n element.addClass('pager');\n var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n if (!ngModelCtrl) {\n return; // do nothing if no ng-model\n }\n\n paginationCtrl.init(ngModelCtrl, uibPagerConfig);\n }\n };\n}]);\n\nangular.module('ui.bootstrap.pagination', ['ui.bootstrap.paging', 'ui.bootstrap.tabindex'])\n.controller('UibPaginationController', ['$scope', '$attrs', '$parse', 'uibPaging', 'uibPaginationConfig', function($scope, $attrs, $parse, uibPaging, uibPaginationConfig) {\n var ctrl = this;\n // Setup configuration parameters\n var maxSize = angular.isDefined($attrs.maxSize) ? $scope.$parent.$eval($attrs.maxSize) : uibPaginationConfig.maxSize,\n rotate = angular.isDefined($attrs.rotate) ? $scope.$parent.$eval($attrs.rotate) : uibPaginationConfig.rotate,\n forceEllipses = angular.isDefined($attrs.forceEllipses) ? $scope.$parent.$eval($attrs.forceEllipses) : uibPaginationConfig.forceEllipses,\n boundaryLinkNumbers = angular.isDefined($attrs.boundaryLinkNumbers) ? $scope.$parent.$eval($attrs.boundaryLinkNumbers) : uibPaginationConfig.boundaryLinkNumbers,\n pageLabel = angular.isDefined($attrs.pageLabel) ? function(idx) { return $scope.$parent.$eval($attrs.pageLabel, {$page: idx}); } : angular.identity;\n $scope.boundaryLinks = angular.isDefined($attrs.boundaryLinks) ? $scope.$parent.$eval($attrs.boundaryLinks) : uibPaginationConfig.boundaryLinks;\n $scope.directionLinks = angular.isDefined($attrs.directionLinks) ? $scope.$parent.$eval($attrs.directionLinks) : uibPaginationConfig.directionLinks;\n\n uibPaging.create(this, $scope, $attrs);\n\n if ($attrs.maxSize) {\n ctrl._watchers.push($scope.$parent.$watch($parse($attrs.maxSize), function(value) {\n maxSize = parseInt(value, 10);\n ctrl.render();\n }));\n }\n\n // Create page object used in template\n function makePage(number, text, isActive) {\n return {\n number: number,\n text: text,\n active: isActive\n };\n }\n\n function getPages(currentPage, totalPages) {\n var pages = [];\n\n // Default page limits\n var startPage = 1, endPage = totalPages;\n var isMaxSized = angular.isDefined(maxSize) && maxSize < totalPages;\n\n // recompute if maxSize\n if (isMaxSized) {\n if (rotate) {\n // Current page is displayed in the middle of the visible ones\n startPage = Math.max(currentPage - Math.floor(maxSize / 2), 1);\n endPage = startPage + maxSize - 1;\n\n // Adjust if limit is exceeded\n if (endPage > totalPages) {\n endPage = totalPages;\n startPage = endPage - maxSize + 1;\n }\n } else {\n // Visible pages are paginated with maxSize\n startPage = (Math.ceil(currentPage / maxSize) - 1) * maxSize + 1;\n\n // Adjust last page if limit is exceeded\n endPage = Math.min(startPage + maxSize - 1, totalPages);\n }\n }\n\n // Add page number links\n for (var number = startPage; number <= endPage; number++) {\n var page = makePage(number, pageLabel(number), number === currentPage);\n pages.push(page);\n }\n\n // Add links to move between page sets\n if (isMaxSized && maxSize > 0 && (!rotate || forceEllipses || boundaryLinkNumbers)) {\n if (startPage > 1) {\n if (!boundaryLinkNumbers || startPage > 3) { //need ellipsis for all options unless range is too close to beginning\n var previousPageSet = makePage(startPage - 1, '...', false);\n pages.unshift(previousPageSet);\n }\n if (boundaryLinkNumbers) {\n if (startPage === 3) { //need to replace ellipsis when the buttons would be sequential\n var secondPageLink = makePage(2, '2', false);\n pages.unshift(secondPageLink);\n }\n //add the first page\n var firstPageLink = makePage(1, '1', false);\n pages.unshift(firstPageLink);\n }\n }\n\n if (endPage < totalPages) {\n if (!boundaryLinkNumbers || endPage < totalPages - 2) { //need ellipsis for all options unless range is too close to end\n var nextPageSet = makePage(endPage + 1, '...', false);\n pages.push(nextPageSet);\n }\n if (boundaryLinkNumbers) {\n if (endPage === totalPages - 2) { //need to replace ellipsis when the buttons would be sequential\n var secondToLastPageLink = makePage(totalPages - 1, totalPages - 1, false);\n pages.push(secondToLastPageLink);\n }\n //add the last page\n var lastPageLink = makePage(totalPages, totalPages, false);\n pages.push(lastPageLink);\n }\n }\n }\n return pages;\n }\n\n var originalRender = this.render;\n this.render = function() {\n originalRender();\n if ($scope.page > 0 && $scope.page <= $scope.totalPages) {\n $scope.pages = getPages($scope.page, $scope.totalPages);\n }\n };\n}])\n\n.constant('uibPaginationConfig', {\n itemsPerPage: 10,\n boundaryLinks: false,\n boundaryLinkNumbers: false,\n directionLinks: true,\n firstText: 'First',\n previousText: 'Previous',\n nextText: 'Next',\n lastText: 'Last',\n rotate: true,\n forceEllipses: false\n})\n\n.directive('uibPagination', ['$parse', 'uibPaginationConfig', function($parse, uibPaginationConfig) {\n return {\n scope: {\n totalItems: '=',\n firstText: '@',\n previousText: '@',\n nextText: '@',\n lastText: '@',\n ngDisabled:'='\n },\n require: ['uibPagination', '?ngModel'],\n restrict: 'A',\n controller: 'UibPaginationController',\n controllerAs: 'pagination',\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/pagination/pagination.html';\n },\n link: function(scope, element, attrs, ctrls) {\n element.addClass('pagination');\n var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n if (!ngModelCtrl) {\n return; // do nothing if no ng-model\n }\n\n paginationCtrl.init(ngModelCtrl, uibPaginationConfig);\n }\n };\n}]);\n\n/**\n * The following features are still outstanding: animation as a\n * function, placement as a function, inside, support for more triggers than\n * just mouse enter/leave, html tooltips, and selector delegation.\n */\nangular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.stackedMap'])\n\n/**\n * The $tooltip service creates tooltip- and popover-like directives as well as\n * houses global options for them.\n */\n.provider('$uibTooltip', function() {\n // The default options tooltip and popover.\n var defaultOptions = {\n placement: 'top',\n placementClassPrefix: '',\n animation: true,\n popupDelay: 0,\n popupCloseDelay: 0,\n useContentExp: false\n };\n\n // Default hide triggers for each show trigger\n var triggerMap = {\n 'mouseenter': 'mouseleave',\n 'click': 'click',\n 'outsideClick': 'outsideClick',\n 'focus': 'blur',\n 'none': ''\n };\n\n // The options specified to the provider globally.\n var globalOptions = {};\n\n /**\n * `options({})` allows global configuration of all tooltips in the\n * application.\n *\n * var app = angular.module( 'App', ['ui.bootstrap.tooltip'], function( $tooltipProvider ) {\n * // place tooltips left instead of top by default\n * $tooltipProvider.options( { placement: 'left' } );\n * });\n */\n\tthis.options = function(value) {\n\t\tangular.extend(globalOptions, value);\n\t};\n\n /**\n * This allows you to extend the set of trigger mappings available. E.g.:\n *\n * $tooltipProvider.setTriggers( { 'openTrigger': 'closeTrigger' } );\n */\n this.setTriggers = function setTriggers(triggers) {\n angular.extend(triggerMap, triggers);\n };\n\n /**\n * This is a helper function for translating camel-case to snake_case.\n */\n function snake_case(name) {\n var regexp = /[A-Z]/g;\n var separator = '-';\n return name.replace(regexp, function(letter, pos) {\n return (pos ? separator : '') + letter.toLowerCase();\n });\n }\n\n /**\n * Returns the actual instance of the $tooltip service.\n * TODO support multiple triggers\n */\n this.$get = ['$window', '$compile', '$timeout', '$document', '$uibPosition', '$interpolate', '$rootScope', '$parse', '$$stackedMap', function($window, $compile, $timeout, $document, $position, $interpolate, $rootScope, $parse, $$stackedMap) {\n var openedTooltips = $$stackedMap.createNew();\n $document.on('keyup', keypressListener);\n\n $rootScope.$on('$destroy', function() {\n $document.off('keyup', keypressListener);\n });\n\n function keypressListener(e) {\n if (e.which === 27) {\n var last = openedTooltips.top();\n if (last) {\n last.value.close();\n last = null;\n }\n }\n }\n\n return function $tooltip(ttType, prefix, defaultTriggerShow, options) {\n options = angular.extend({}, defaultOptions, globalOptions, options);\n\n /**\n * Returns an object of show and hide triggers.\n *\n * If a trigger is supplied,\n * it is used to show the tooltip; otherwise, it will use the `trigger`\n * option passed to the `$tooltipProvider.options` method; else it will\n * default to the trigger supplied to this directive factory.\n *\n * The hide trigger is based on the show trigger. If the `trigger` option\n * was passed to the `$tooltipProvider.options` method, it will use the\n * mapped trigger from `triggerMap` or the passed trigger if the map is\n * undefined; otherwise, it uses the `triggerMap` value of the show\n * trigger; else it will just use the show trigger.\n */\n function getTriggers(trigger) {\n var show = (trigger || options.trigger || defaultTriggerShow).split(' ');\n var hide = show.map(function(trigger) {\n return triggerMap[trigger] || trigger;\n });\n return {\n show: show,\n hide: hide\n };\n }\n\n var directiveName = snake_case(ttType);\n\n var startSym = $interpolate.startSymbol();\n var endSym = $interpolate.endSymbol();\n var template =\n '
' +\n '
';\n\n return {\n compile: function(tElem, tAttrs) {\n var tooltipLinker = $compile(template);\n\n return function link(scope, element, attrs, tooltipCtrl) {\n var tooltip;\n var tooltipLinkedScope;\n var transitionTimeout;\n var showTimeout;\n var hideTimeout;\n var positionTimeout;\n var adjustmentTimeout;\n var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false;\n var triggers = getTriggers(undefined);\n var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']);\n var ttScope = scope.$new(true);\n var repositionScheduled = false;\n var isOpenParse = angular.isDefined(attrs[prefix + 'IsOpen']) ? $parse(attrs[prefix + 'IsOpen']) : false;\n var contentParse = options.useContentExp ? $parse(attrs[ttType]) : false;\n var observers = [];\n var lastPlacement;\n\n var positionTooltip = function() {\n // check if tooltip exists and is not empty\n if (!tooltip || !tooltip.html()) { return; }\n\n if (!positionTimeout) {\n positionTimeout = $timeout(function() {\n var ttPosition = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);\n var initialHeight = angular.isDefined(tooltip.offsetHeight) ? tooltip.offsetHeight : tooltip.prop('offsetHeight');\n var elementPos = appendToBody ? $position.offset(element) : $position.position(element);\n tooltip.css({ top: ttPosition.top + 'px', left: ttPosition.left + 'px' });\n var placementClasses = ttPosition.placement.split('-');\n\n if (!tooltip.hasClass(placementClasses[0])) {\n tooltip.removeClass(lastPlacement.split('-')[0]);\n tooltip.addClass(placementClasses[0]);\n }\n\n if (!tooltip.hasClass(options.placementClassPrefix + ttPosition.placement)) {\n tooltip.removeClass(options.placementClassPrefix + lastPlacement);\n tooltip.addClass(options.placementClassPrefix + ttPosition.placement);\n }\n\n adjustmentTimeout = $timeout(function() {\n var currentHeight = angular.isDefined(tooltip.offsetHeight) ? tooltip.offsetHeight : tooltip.prop('offsetHeight');\n var adjustment = $position.adjustTop(placementClasses, elementPos, initialHeight, currentHeight);\n if (adjustment) {\n tooltip.css(adjustment);\n }\n adjustmentTimeout = null;\n }, 0, false);\n\n // first time through tt element will have the\n // uib-position-measure class or if the placement\n // has changed we need to position the arrow.\n if (tooltip.hasClass('uib-position-measure')) {\n $position.positionArrow(tooltip, ttPosition.placement);\n tooltip.removeClass('uib-position-measure');\n } else if (lastPlacement !== ttPosition.placement) {\n $position.positionArrow(tooltip, ttPosition.placement);\n }\n lastPlacement = ttPosition.placement;\n\n positionTimeout = null;\n }, 0, false);\n }\n };\n\n // Set up the correct scope to allow transclusion later\n ttScope.origScope = scope;\n\n // By default, the tooltip is not open.\n // TODO add ability to start tooltip opened\n ttScope.isOpen = false;\n\n function toggleTooltipBind() {\n if (!ttScope.isOpen) {\n showTooltipBind();\n } else {\n hideTooltipBind();\n }\n }\n\n // Show the tooltip with delay if specified, otherwise show it immediately\n function showTooltipBind() {\n if (hasEnableExp && !scope.$eval(attrs[prefix + 'Enable'])) {\n return;\n }\n\n cancelHide();\n prepareTooltip();\n\n if (ttScope.popupDelay) {\n // Do nothing if the tooltip was already scheduled to pop-up.\n // This happens if show is triggered multiple times before any hide is triggered.\n if (!showTimeout) {\n showTimeout = $timeout(show, ttScope.popupDelay, false);\n }\n } else {\n show();\n }\n }\n\n function hideTooltipBind() {\n cancelShow();\n\n if (ttScope.popupCloseDelay) {\n if (!hideTimeout) {\n hideTimeout = $timeout(hide, ttScope.popupCloseDelay, false);\n }\n } else {\n hide();\n }\n }\n\n // Show the tooltip popup element.\n function show() {\n cancelShow();\n cancelHide();\n\n // Don't show empty tooltips.\n if (!ttScope.content) {\n return angular.noop;\n }\n\n createTooltip();\n\n // And show the tooltip.\n ttScope.$evalAsync(function() {\n ttScope.isOpen = true;\n assignIsOpen(true);\n positionTooltip();\n });\n }\n\n function cancelShow() {\n if (showTimeout) {\n $timeout.cancel(showTimeout);\n showTimeout = null;\n }\n\n if (positionTimeout) {\n $timeout.cancel(positionTimeout);\n positionTimeout = null;\n }\n }\n\n // Hide the tooltip popup element.\n function hide() {\n if (!ttScope) {\n return;\n }\n\n // First things first: we don't show it anymore.\n ttScope.$evalAsync(function() {\n if (ttScope) {\n ttScope.isOpen = false;\n assignIsOpen(false);\n // And now we remove it from the DOM. However, if we have animation, we\n // need to wait for it to expire beforehand.\n // FIXME: this is a placeholder for a port of the transitions library.\n // The fade transition in TWBS is 150ms.\n if (ttScope.animation) {\n if (!transitionTimeout) {\n transitionTimeout = $timeout(removeTooltip, 150, false);\n }\n } else {\n removeTooltip();\n }\n }\n });\n }\n\n function cancelHide() {\n if (hideTimeout) {\n $timeout.cancel(hideTimeout);\n hideTimeout = null;\n }\n\n if (transitionTimeout) {\n $timeout.cancel(transitionTimeout);\n transitionTimeout = null;\n }\n }\n\n function createTooltip() {\n // There can only be one tooltip element per directive shown at once.\n if (tooltip) {\n return;\n }\n\n tooltipLinkedScope = ttScope.$new();\n tooltip = tooltipLinker(tooltipLinkedScope, function(tooltip) {\n if (appendToBody) {\n $document.find('body').append(tooltip);\n } else {\n element.after(tooltip);\n }\n });\n\n openedTooltips.add(ttScope, {\n close: hide\n });\n\n prepObservers();\n }\n\n function removeTooltip() {\n cancelShow();\n cancelHide();\n unregisterObservers();\n\n if (tooltip) {\n tooltip.remove();\n \n tooltip = null;\n if (adjustmentTimeout) {\n $timeout.cancel(adjustmentTimeout);\n }\n }\n\n openedTooltips.remove(ttScope);\n \n if (tooltipLinkedScope) {\n tooltipLinkedScope.$destroy();\n tooltipLinkedScope = null;\n }\n }\n\n /**\n * Set the initial scope values. Once\n * the tooltip is created, the observers\n * will be added to keep things in sync.\n */\n function prepareTooltip() {\n ttScope.title = attrs[prefix + 'Title'];\n if (contentParse) {\n ttScope.content = contentParse(scope);\n } else {\n ttScope.content = attrs[ttType];\n }\n\n ttScope.popupClass = attrs[prefix + 'Class'];\n ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;\n var placement = $position.parsePlacement(ttScope.placement);\n lastPlacement = placement[1] ? placement[0] + '-' + placement[1] : placement[0];\n\n var delay = parseInt(attrs[prefix + 'PopupDelay'], 10);\n var closeDelay = parseInt(attrs[prefix + 'PopupCloseDelay'], 10);\n ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;\n ttScope.popupCloseDelay = !isNaN(closeDelay) ? closeDelay : options.popupCloseDelay;\n }\n\n function assignIsOpen(isOpen) {\n if (isOpenParse && angular.isFunction(isOpenParse.assign)) {\n isOpenParse.assign(scope, isOpen);\n }\n }\n\n ttScope.contentExp = function() {\n return ttScope.content;\n };\n\n /**\n * Observe the relevant attributes.\n */\n attrs.$observe('disabled', function(val) {\n if (val) {\n cancelShow();\n }\n\n if (val && ttScope.isOpen) {\n hide();\n }\n });\n\n if (isOpenParse) {\n scope.$watch(isOpenParse, function(val) {\n if (ttScope && !val === ttScope.isOpen) {\n toggleTooltipBind();\n }\n });\n }\n\n function prepObservers() {\n observers.length = 0;\n\n if (contentParse) {\n observers.push(\n scope.$watch(contentParse, function(val) {\n ttScope.content = val;\n if (!val && ttScope.isOpen) {\n hide();\n }\n })\n );\n\n observers.push(\n tooltipLinkedScope.$watch(function() {\n if (!repositionScheduled) {\n repositionScheduled = true;\n tooltipLinkedScope.$$postDigest(function() {\n repositionScheduled = false;\n if (ttScope && ttScope.isOpen) {\n positionTooltip();\n }\n });\n }\n })\n );\n } else {\n observers.push(\n attrs.$observe(ttType, function(val) {\n ttScope.content = val;\n if (!val && ttScope.isOpen) {\n hide();\n } else {\n positionTooltip();\n }\n })\n );\n }\n\n observers.push(\n attrs.$observe(prefix + 'Title', function(val) {\n ttScope.title = val;\n if (ttScope.isOpen) {\n positionTooltip();\n }\n })\n );\n\n observers.push(\n attrs.$observe(prefix + 'Placement', function(val) {\n ttScope.placement = val ? val : options.placement;\n if (ttScope.isOpen) {\n positionTooltip();\n }\n })\n );\n }\n\n function unregisterObservers() {\n if (observers.length) {\n angular.forEach(observers, function(observer) {\n observer();\n });\n observers.length = 0;\n }\n }\n\n // hide tooltips/popovers for outsideClick trigger\n function bodyHideTooltipBind(e) {\n if (!ttScope || !ttScope.isOpen || !tooltip) {\n return;\n }\n // make sure the tooltip/popover link or tool tooltip/popover itself were not clicked\n if (!element[0].contains(e.target) && !tooltip[0].contains(e.target)) {\n hideTooltipBind();\n }\n }\n\n var unregisterTriggers = function() {\n triggers.show.forEach(function(trigger) {\n if (trigger === 'outsideClick') {\n element.off('click', toggleTooltipBind);\n } else {\n element.off(trigger, showTooltipBind);\n element.off(trigger, toggleTooltipBind);\n }\n });\n triggers.hide.forEach(function(trigger) {\n if (trigger === 'outsideClick') {\n $document.off('click', bodyHideTooltipBind);\n } else {\n element.off(trigger, hideTooltipBind);\n }\n });\n };\n\n function prepTriggers() {\n var showTriggers = [], hideTriggers = [];\n var val = scope.$eval(attrs[prefix + 'Trigger']);\n unregisterTriggers();\n\n if (angular.isObject(val)) {\n Object.keys(val).forEach(function(key) {\n showTriggers.push(key);\n hideTriggers.push(val[key]);\n });\n triggers = {\n show: showTriggers,\n hide: hideTriggers\n };\n } else {\n triggers = getTriggers(val);\n }\n\n if (triggers.show !== 'none') {\n triggers.show.forEach(function(trigger, idx) {\n if (trigger === 'outsideClick') {\n element.on('click', toggleTooltipBind);\n $document.on('click', bodyHideTooltipBind);\n } else if (trigger === triggers.hide[idx]) {\n element.on(trigger, toggleTooltipBind);\n } else if (trigger) {\n element.on(trigger, showTooltipBind);\n element.on(triggers.hide[idx], hideTooltipBind);\n }\n\n element.on('keypress', function(e) {\n if (e.which === 27) {\n hideTooltipBind();\n }\n });\n });\n }\n }\n\n prepTriggers();\n\n var animation = scope.$eval(attrs[prefix + 'Animation']);\n ttScope.animation = angular.isDefined(animation) ? !!animation : options.animation;\n\n var appendToBodyVal;\n var appendKey = prefix + 'AppendToBody';\n if (appendKey in attrs && attrs[appendKey] === undefined) {\n appendToBodyVal = true;\n } else {\n appendToBodyVal = scope.$eval(attrs[appendKey]);\n }\n\n appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody;\n\n // Make sure tooltip is destroyed and removed.\n scope.$on('$destroy', function onDestroyTooltip() {\n unregisterTriggers();\n removeTooltip();\n ttScope = null;\n });\n };\n }\n };\n };\n }];\n})\n\n// This is mostly ngInclude code but with a custom scope\n.directive('uibTooltipTemplateTransclude', [\n '$animate', '$sce', '$compile', '$templateRequest',\nfunction ($animate, $sce, $compile, $templateRequest) {\n return {\n link: function(scope, elem, attrs) {\n var origScope = scope.$eval(attrs.tooltipTemplateTranscludeScope);\n\n var changeCounter = 0,\n currentScope,\n previousElement,\n currentElement;\n\n var cleanupLastIncludeContent = function() {\n if (previousElement) {\n previousElement.remove();\n previousElement = null;\n }\n\n if (currentScope) {\n currentScope.$destroy();\n currentScope = null;\n }\n\n if (currentElement) {\n $animate.leave(currentElement).then(function() {\n previousElement = null;\n });\n previousElement = currentElement;\n currentElement = null;\n }\n };\n\n scope.$watch($sce.parseAsResourceUrl(attrs.uibTooltipTemplateTransclude), function(src) {\n var thisChangeId = ++changeCounter;\n\n if (src) {\n //set the 2nd param to true to ignore the template request error so that the inner\n //contents and scope can be cleaned up.\n $templateRequest(src, true).then(function(response) {\n if (thisChangeId !== changeCounter) { return; }\n var newScope = origScope.$new();\n var template = response;\n\n var clone = $compile(template)(newScope, function(clone) {\n cleanupLastIncludeContent();\n $animate.enter(clone, elem);\n });\n\n currentScope = newScope;\n currentElement = clone;\n\n currentScope.$emit('$includeContentLoaded', src);\n }, function() {\n if (thisChangeId === changeCounter) {\n cleanupLastIncludeContent();\n scope.$emit('$includeContentError', src);\n }\n });\n scope.$emit('$includeContentRequested', src);\n } else {\n cleanupLastIncludeContent();\n }\n });\n\n scope.$on('$destroy', cleanupLastIncludeContent);\n }\n };\n}])\n\n/**\n * Note that it's intentional that these classes are *not* applied through $animate.\n * They must not be animated as they're expected to be present on the tooltip on\n * initialization.\n */\n.directive('uibTooltipClasses', ['$uibPosition', function($uibPosition) {\n return {\n restrict: 'A',\n link: function(scope, element, attrs) {\n // need to set the primary position so the\n // arrow has space during position measure.\n // tooltip.positionTooltip()\n if (scope.placement) {\n // // There are no top-left etc... classes\n // // in TWBS, so we need the primary position.\n var position = $uibPosition.parsePlacement(scope.placement);\n element.addClass(position[0]);\n }\n\n if (scope.popupClass) {\n element.addClass(scope.popupClass);\n }\n\n if (scope.animation) {\n element.addClass(attrs.tooltipAnimationClass);\n }\n }\n };\n}])\n\n.directive('uibTooltipPopup', function() {\n return {\n restrict: 'A',\n scope: { content: '@' },\n templateUrl: 'uib/template/tooltip/tooltip-popup.html'\n };\n})\n\n.directive('uibTooltip', [ '$uibTooltip', function($uibTooltip) {\n return $uibTooltip('uibTooltip', 'tooltip', 'mouseenter');\n}])\n\n.directive('uibTooltipTemplatePopup', function() {\n return {\n restrict: 'A',\n scope: { contentExp: '&', originScope: '&' },\n templateUrl: 'uib/template/tooltip/tooltip-template-popup.html'\n };\n})\n\n.directive('uibTooltipTemplate', ['$uibTooltip', function($uibTooltip) {\n return $uibTooltip('uibTooltipTemplate', 'tooltip', 'mouseenter', {\n useContentExp: true\n });\n}])\n\n.directive('uibTooltipHtmlPopup', function() {\n return {\n restrict: 'A',\n scope: { contentExp: '&' },\n templateUrl: 'uib/template/tooltip/tooltip-html-popup.html'\n };\n})\n\n.directive('uibTooltipHtml', ['$uibTooltip', function($uibTooltip) {\n return $uibTooltip('uibTooltipHtml', 'tooltip', 'mouseenter', {\n useContentExp: true\n });\n}]);\n\n/**\n * The following features are still outstanding: popup delay, animation as a\n * function, placement as a function, inside, support for more triggers than\n * just mouse enter/leave, and selector delegatation.\n */\nangular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])\n\n.directive('uibPopoverTemplatePopup', function() {\n return {\n restrict: 'A',\n scope: { uibTitle: '@', contentExp: '&', originScope: '&' },\n templateUrl: 'uib/template/popover/popover-template.html'\n };\n})\n\n.directive('uibPopoverTemplate', ['$uibTooltip', function($uibTooltip) {\n return $uibTooltip('uibPopoverTemplate', 'popover', 'click', {\n useContentExp: true\n });\n}])\n\n.directive('uibPopoverHtmlPopup', function() {\n return {\n restrict: 'A',\n scope: { contentExp: '&', uibTitle: '@' },\n templateUrl: 'uib/template/popover/popover-html.html'\n };\n})\n\n.directive('uibPopoverHtml', ['$uibTooltip', function($uibTooltip) {\n return $uibTooltip('uibPopoverHtml', 'popover', 'click', {\n useContentExp: true\n });\n}])\n\n.directive('uibPopoverPopup', function() {\n return {\n restrict: 'A',\n scope: { uibTitle: '@', content: '@' },\n templateUrl: 'uib/template/popover/popover.html'\n };\n})\n\n.directive('uibPopover', ['$uibTooltip', function($uibTooltip) {\n return $uibTooltip('uibPopover', 'popover', 'click');\n}]);\n\nangular.module('ui.bootstrap.progressbar', [])\n\n.constant('uibProgressConfig', {\n animate: true,\n max: 100\n})\n\n.controller('UibProgressController', ['$scope', '$attrs', 'uibProgressConfig', function($scope, $attrs, progressConfig) {\n var self = this,\n animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;\n\n this.bars = [];\n $scope.max = getMaxOrDefault();\n\n this.addBar = function(bar, element, attrs) {\n if (!animate) {\n element.css({'transition': 'none'});\n }\n\n this.bars.push(bar);\n\n bar.max = getMaxOrDefault();\n bar.title = attrs && angular.isDefined(attrs.title) ? attrs.title : 'progressbar';\n\n bar.$watch('value', function(value) {\n bar.recalculatePercentage();\n });\n\n bar.recalculatePercentage = function() {\n var totalPercentage = self.bars.reduce(function(total, bar) {\n bar.percent = +(100 * bar.value / bar.max).toFixed(2);\n return total + bar.percent;\n }, 0);\n\n if (totalPercentage > 100) {\n bar.percent -= totalPercentage - 100;\n }\n };\n\n bar.$on('$destroy', function() {\n element = null;\n self.removeBar(bar);\n });\n };\n\n this.removeBar = function(bar) {\n this.bars.splice(this.bars.indexOf(bar), 1);\n this.bars.forEach(function (bar) {\n bar.recalculatePercentage();\n });\n };\n\n //$attrs.$observe('maxParam', function(maxParam) {\n $scope.$watch('maxParam', function(maxParam) {\n self.bars.forEach(function(bar) {\n bar.max = getMaxOrDefault();\n bar.recalculatePercentage();\n });\n });\n\n function getMaxOrDefault () {\n return angular.isDefined($scope.maxParam) ? $scope.maxParam : progressConfig.max;\n }\n}])\n\n.directive('uibProgress', function() {\n return {\n replace: true,\n transclude: true,\n controller: 'UibProgressController',\n require: 'uibProgress',\n scope: {\n maxParam: '=?max'\n },\n templateUrl: 'uib/template/progressbar/progress.html'\n };\n})\n\n.directive('uibBar', function() {\n return {\n replace: true,\n transclude: true,\n require: '^uibProgress',\n scope: {\n value: '=',\n type: '@'\n },\n templateUrl: 'uib/template/progressbar/bar.html',\n link: function(scope, element, attrs, progressCtrl) {\n progressCtrl.addBar(scope, element, attrs);\n }\n };\n})\n\n.directive('uibProgressbar', function() {\n return {\n replace: true,\n transclude: true,\n controller: 'UibProgressController',\n scope: {\n value: '=',\n maxParam: '=?max',\n type: '@'\n },\n templateUrl: 'uib/template/progressbar/progressbar.html',\n link: function(scope, element, attrs, progressCtrl) {\n progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title});\n }\n };\n});\n\nangular.module('ui.bootstrap.rating', [])\n\n.constant('uibRatingConfig', {\n max: 5,\n stateOn: null,\n stateOff: null,\n enableReset: true,\n titles: ['one', 'two', 'three', 'four', 'five']\n})\n\n.controller('UibRatingController', ['$scope', '$attrs', 'uibRatingConfig', function($scope, $attrs, ratingConfig) {\n var ngModelCtrl = { $setViewValue: angular.noop },\n self = this;\n\n this.init = function(ngModelCtrl_) {\n ngModelCtrl = ngModelCtrl_;\n ngModelCtrl.$render = this.render;\n\n ngModelCtrl.$formatters.push(function(value) {\n if (angular.isNumber(value) && value << 0 !== value) {\n value = Math.round(value);\n }\n\n return value;\n });\n\n this.stateOn = angular.isDefined($attrs.stateOn) ? $scope.$parent.$eval($attrs.stateOn) : ratingConfig.stateOn;\n this.stateOff = angular.isDefined($attrs.stateOff) ? $scope.$parent.$eval($attrs.stateOff) : ratingConfig.stateOff;\n this.enableReset = angular.isDefined($attrs.enableReset) ?\n $scope.$parent.$eval($attrs.enableReset) : ratingConfig.enableReset;\n var tmpTitles = angular.isDefined($attrs.titles) ? $scope.$parent.$eval($attrs.titles) : ratingConfig.titles;\n this.titles = angular.isArray(tmpTitles) && tmpTitles.length > 0 ?\n tmpTitles : ratingConfig.titles;\n\n var ratingStates = angular.isDefined($attrs.ratingStates) ?\n $scope.$parent.$eval($attrs.ratingStates) :\n new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max);\n $scope.range = this.buildTemplateObjects(ratingStates);\n };\n\n this.buildTemplateObjects = function(states) {\n for (var i = 0, n = states.length; i < n; i++) {\n states[i] = angular.extend({ index: i }, { stateOn: this.stateOn, stateOff: this.stateOff, title: this.getTitle(i) }, states[i]);\n }\n return states;\n };\n\n this.getTitle = function(index) {\n if (index >= this.titles.length) {\n return index + 1;\n }\n\n return this.titles[index];\n };\n\n $scope.rate = function(value) {\n if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {\n var newViewValue = self.enableReset && ngModelCtrl.$viewValue === value ? 0 : value;\n ngModelCtrl.$setViewValue(newViewValue);\n ngModelCtrl.$render();\n }\n };\n\n $scope.enter = function(value) {\n if (!$scope.readonly) {\n $scope.value = value;\n }\n $scope.onHover({value: value});\n };\n\n $scope.reset = function() {\n $scope.value = ngModelCtrl.$viewValue;\n $scope.onLeave();\n };\n\n $scope.onKeydown = function(evt) {\n if (/(37|38|39|40)/.test(evt.which)) {\n evt.preventDefault();\n evt.stopPropagation();\n $scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1));\n }\n };\n\n this.render = function() {\n $scope.value = ngModelCtrl.$viewValue;\n $scope.title = self.getTitle($scope.value - 1);\n };\n}])\n\n.directive('uibRating', function() {\n return {\n require: ['uibRating', 'ngModel'],\n restrict: 'A',\n scope: {\n readonly: '=?readOnly',\n onHover: '&',\n onLeave: '&'\n },\n controller: 'UibRatingController',\n templateUrl: 'uib/template/rating/rating.html',\n link: function(scope, element, attrs, ctrls) {\n var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n ratingCtrl.init(ngModelCtrl);\n }\n };\n});\n\nangular.module('ui.bootstrap.tabs', [])\n\n.controller('UibTabsetController', ['$scope', function ($scope) {\n var ctrl = this,\n oldIndex;\n ctrl.tabs = [];\n\n ctrl.select = function(index, evt) {\n if (!destroyed) {\n var previousIndex = findTabIndex(oldIndex);\n var previousSelected = ctrl.tabs[previousIndex];\n if (previousSelected) {\n previousSelected.tab.onDeselect({\n $event: evt,\n $selectedIndex: index\n });\n if (evt && evt.isDefaultPrevented()) {\n return;\n }\n previousSelected.tab.active = false;\n }\n\n var selected = ctrl.tabs[index];\n if (selected) {\n selected.tab.onSelect({\n $event: evt\n });\n selected.tab.active = true;\n ctrl.active = selected.index;\n oldIndex = selected.index;\n } else if (!selected && angular.isDefined(oldIndex)) {\n ctrl.active = null;\n oldIndex = null;\n }\n }\n };\n\n ctrl.addTab = function addTab(tab) {\n ctrl.tabs.push({\n tab: tab,\n index: tab.index\n });\n ctrl.tabs.sort(function(t1, t2) {\n if (t1.index > t2.index) {\n return 1;\n }\n\n if (t1.index < t2.index) {\n return -1;\n }\n\n return 0;\n });\n\n if (tab.index === ctrl.active || !angular.isDefined(ctrl.active) && ctrl.tabs.length === 1) {\n var newActiveIndex = findTabIndex(tab.index);\n ctrl.select(newActiveIndex);\n }\n };\n\n ctrl.removeTab = function removeTab(tab) {\n var index;\n for (var i = 0; i < ctrl.tabs.length; i++) {\n if (ctrl.tabs[i].tab === tab) {\n index = i;\n break;\n }\n }\n\n if (ctrl.tabs[index].index === ctrl.active) {\n var newActiveTabIndex = index === ctrl.tabs.length - 1 ?\n index - 1 : index + 1 % ctrl.tabs.length;\n ctrl.select(newActiveTabIndex);\n }\n\n ctrl.tabs.splice(index, 1);\n };\n\n $scope.$watch('tabset.active', function(val) {\n if (angular.isDefined(val) && val !== oldIndex) {\n ctrl.select(findTabIndex(val));\n }\n });\n\n var destroyed;\n $scope.$on('$destroy', function() {\n destroyed = true;\n });\n\n function findTabIndex(index) {\n for (var i = 0; i < ctrl.tabs.length; i++) {\n if (ctrl.tabs[i].index === index) {\n return i;\n }\n }\n }\n}])\n\n.directive('uibTabset', function() {\n return {\n transclude: true,\n replace: true,\n scope: {},\n bindToController: {\n active: '=?',\n type: '@'\n },\n controller: 'UibTabsetController',\n controllerAs: 'tabset',\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/tabs/tabset.html';\n },\n link: function(scope, element, attrs) {\n scope.vertical = angular.isDefined(attrs.vertical) ?\n scope.$parent.$eval(attrs.vertical) : false;\n scope.justified = angular.isDefined(attrs.justified) ?\n scope.$parent.$eval(attrs.justified) : false;\n }\n };\n})\n\n.directive('uibTab', ['$parse', function($parse) {\n return {\n require: '^uibTabset',\n replace: true,\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || 'uib/template/tabs/tab.html';\n },\n transclude: true,\n scope: {\n heading: '@',\n index: '=?',\n classes: '@?',\n onSelect: '&select', //This callback is called in contentHeadingTransclude\n //once it inserts the tab's content into the dom\n onDeselect: '&deselect'\n },\n controller: function() {\n //Empty controller so other directives can require being 'under' a tab\n },\n controllerAs: 'tab',\n link: function(scope, elm, attrs, tabsetCtrl, transclude) {\n scope.disabled = false;\n if (attrs.disable) {\n scope.$parent.$watch($parse(attrs.disable), function(value) {\n scope.disabled = !! value;\n });\n }\n\n if (angular.isUndefined(attrs.index)) {\n if (tabsetCtrl.tabs && tabsetCtrl.tabs.length) {\n scope.index = Math.max.apply(null, tabsetCtrl.tabs.map(function(t) { return t.index; })) + 1;\n } else {\n scope.index = 0;\n }\n }\n\n if (angular.isUndefined(attrs.classes)) {\n scope.classes = '';\n }\n\n scope.select = function(evt) {\n if (!scope.disabled) {\n var index;\n for (var i = 0; i < tabsetCtrl.tabs.length; i++) {\n if (tabsetCtrl.tabs[i].tab === scope) {\n index = i;\n break;\n }\n }\n\n tabsetCtrl.select(index, evt);\n }\n };\n\n tabsetCtrl.addTab(scope);\n scope.$on('$destroy', function() {\n tabsetCtrl.removeTab(scope);\n });\n\n //We need to transclude later, once the content container is ready.\n //when this link happens, we're inside a tab heading.\n scope.$transcludeFn = transclude;\n }\n };\n}])\n\n.directive('uibTabHeadingTransclude', function() {\n return {\n restrict: 'A',\n require: '^uibTab',\n link: function(scope, elm) {\n scope.$watch('headingElement', function updateHeadingElement(heading) {\n if (heading) {\n elm.html('');\n elm.append(heading);\n }\n });\n }\n };\n})\n\n.directive('uibTabContentTransclude', function() {\n return {\n restrict: 'A',\n require: '^uibTabset',\n link: function(scope, elm, attrs) {\n var tab = scope.$eval(attrs.uibTabContentTransclude).tab;\n\n //Now our tab is ready to be transcluded: both the tab heading area\n //and the tab content area are loaded. Transclude 'em both.\n tab.$transcludeFn(tab.$parent, function(contents) {\n angular.forEach(contents, function(node) {\n if (isTabHeading(node)) {\n //Let tabHeadingTransclude know.\n tab.headingElement = node;\n } else {\n elm.append(node);\n }\n });\n });\n }\n };\n\n function isTabHeading(node) {\n return node.tagName && (\n node.hasAttribute('uib-tab-heading') ||\n node.hasAttribute('data-uib-tab-heading') ||\n node.hasAttribute('x-uib-tab-heading') ||\n node.tagName.toLowerCase() === 'uib-tab-heading' ||\n node.tagName.toLowerCase() === 'data-uib-tab-heading' ||\n node.tagName.toLowerCase() === 'x-uib-tab-heading' ||\n node.tagName.toLowerCase() === 'uib:tab-heading'\n );\n }\n});\n\nangular.module('ui.bootstrap.timepicker', [])\n\n.constant('uibTimepickerConfig', {\n hourStep: 1,\n minuteStep: 1,\n secondStep: 1,\n showMeridian: true,\n showSeconds: false,\n meridians: null,\n readonlyInput: false,\n mousewheel: true,\n arrowkeys: true,\n showSpinners: true,\n templateUrl: 'uib/template/timepicker/timepicker.html'\n})\n\n.controller('UibTimepickerController', ['$scope', '$element', '$attrs', '$parse', '$log', '$locale', 'uibTimepickerConfig', function($scope, $element, $attrs, $parse, $log, $locale, timepickerConfig) {\n var hoursModelCtrl, minutesModelCtrl, secondsModelCtrl;\n var selected = new Date(),\n watchers = [],\n ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl\n meridians = angular.isDefined($attrs.meridians) ? $scope.$parent.$eval($attrs.meridians) : timepickerConfig.meridians || $locale.DATETIME_FORMATS.AMPMS,\n padHours = angular.isDefined($attrs.padHours) ? $scope.$parent.$eval($attrs.padHours) : true;\n\n $scope.tabindex = angular.isDefined($attrs.tabindex) ? $attrs.tabindex : 0;\n $element.removeAttr('tabindex');\n\n this.init = function(ngModelCtrl_, inputs) {\n ngModelCtrl = ngModelCtrl_;\n ngModelCtrl.$render = this.render;\n\n ngModelCtrl.$formatters.unshift(function(modelValue) {\n return modelValue ? new Date(modelValue) : null;\n });\n\n var hoursInputEl = inputs.eq(0),\n minutesInputEl = inputs.eq(1),\n secondsInputEl = inputs.eq(2);\n\n hoursModelCtrl = hoursInputEl.controller('ngModel');\n minutesModelCtrl = minutesInputEl.controller('ngModel');\n secondsModelCtrl = secondsInputEl.controller('ngModel');\n\n var mousewheel = angular.isDefined($attrs.mousewheel) ? $scope.$parent.$eval($attrs.mousewheel) : timepickerConfig.mousewheel;\n\n if (mousewheel) {\n this.setupMousewheelEvents(hoursInputEl, minutesInputEl, secondsInputEl);\n }\n\n var arrowkeys = angular.isDefined($attrs.arrowkeys) ? $scope.$parent.$eval($attrs.arrowkeys) : timepickerConfig.arrowkeys;\n if (arrowkeys) {\n this.setupArrowkeyEvents(hoursInputEl, minutesInputEl, secondsInputEl);\n }\n\n $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;\n this.setupInputEvents(hoursInputEl, minutesInputEl, secondsInputEl);\n };\n\n var hourStep = timepickerConfig.hourStep;\n if ($attrs.hourStep) {\n watchers.push($scope.$parent.$watch($parse($attrs.hourStep), function(value) {\n hourStep = +value;\n }));\n }\n\n var minuteStep = timepickerConfig.minuteStep;\n if ($attrs.minuteStep) {\n watchers.push($scope.$parent.$watch($parse($attrs.minuteStep), function(value) {\n minuteStep = +value;\n }));\n }\n\n var min;\n watchers.push($scope.$parent.$watch($parse($attrs.min), function(value) {\n var dt = new Date(value);\n min = isNaN(dt) ? undefined : dt;\n }));\n\n var max;\n watchers.push($scope.$parent.$watch($parse($attrs.max), function(value) {\n var dt = new Date(value);\n max = isNaN(dt) ? undefined : dt;\n }));\n\n var disabled = false;\n if ($attrs.ngDisabled) {\n watchers.push($scope.$parent.$watch($parse($attrs.ngDisabled), function(value) {\n disabled = value;\n }));\n }\n\n $scope.noIncrementHours = function() {\n var incrementedSelected = addMinutes(selected, hourStep * 60);\n return disabled || incrementedSelected > max ||\n incrementedSelected < selected && incrementedSelected < min;\n };\n\n $scope.noDecrementHours = function() {\n var decrementedSelected = addMinutes(selected, -hourStep * 60);\n return disabled || decrementedSelected < min ||\n decrementedSelected > selected && decrementedSelected > max;\n };\n\n $scope.noIncrementMinutes = function() {\n var incrementedSelected = addMinutes(selected, minuteStep);\n return disabled || incrementedSelected > max ||\n incrementedSelected < selected && incrementedSelected < min;\n };\n\n $scope.noDecrementMinutes = function() {\n var decrementedSelected = addMinutes(selected, -minuteStep);\n return disabled || decrementedSelected < min ||\n decrementedSelected > selected && decrementedSelected > max;\n };\n\n $scope.noIncrementSeconds = function() {\n var incrementedSelected = addSeconds(selected, secondStep);\n return disabled || incrementedSelected > max ||\n incrementedSelected < selected && incrementedSelected < min;\n };\n\n $scope.noDecrementSeconds = function() {\n var decrementedSelected = addSeconds(selected, -secondStep);\n return disabled || decrementedSelected < min ||\n decrementedSelected > selected && decrementedSelected > max;\n };\n\n $scope.noToggleMeridian = function() {\n if (selected.getHours() < 12) {\n return disabled || addMinutes(selected, 12 * 60) > max;\n }\n\n return disabled || addMinutes(selected, -12 * 60) < min;\n };\n\n var secondStep = timepickerConfig.secondStep;\n if ($attrs.secondStep) {\n watchers.push($scope.$parent.$watch($parse($attrs.secondStep), function(value) {\n secondStep = +value;\n }));\n }\n\n $scope.showSeconds = timepickerConfig.showSeconds;\n if ($attrs.showSeconds) {\n watchers.push($scope.$parent.$watch($parse($attrs.showSeconds), function(value) {\n $scope.showSeconds = !!value;\n }));\n }\n\n // 12H / 24H mode\n $scope.showMeridian = timepickerConfig.showMeridian;\n if ($attrs.showMeridian) {\n watchers.push($scope.$parent.$watch($parse($attrs.showMeridian), function(value) {\n $scope.showMeridian = !!value;\n\n if (ngModelCtrl.$error.time) {\n // Evaluate from template\n var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate();\n if (angular.isDefined(hours) && angular.isDefined(minutes)) {\n selected.setHours(hours);\n refresh();\n }\n } else {\n updateTemplate();\n }\n }));\n }\n\n // Get $scope.hours in 24H mode if valid\n function getHoursFromTemplate() {\n var hours = +$scope.hours;\n var valid = $scope.showMeridian ? hours > 0 && hours < 13 :\n hours >= 0 && hours < 24;\n if (!valid || $scope.hours === '') {\n return undefined;\n }\n\n if ($scope.showMeridian) {\n if (hours === 12) {\n hours = 0;\n }\n if ($scope.meridian === meridians[1]) {\n hours = hours + 12;\n }\n }\n return hours;\n }\n\n function getMinutesFromTemplate() {\n var minutes = +$scope.minutes;\n var valid = minutes >= 0 && minutes < 60;\n if (!valid || $scope.minutes === '') {\n return undefined;\n }\n return minutes;\n }\n\n function getSecondsFromTemplate() {\n var seconds = +$scope.seconds;\n return seconds >= 0 && seconds < 60 ? seconds : undefined;\n }\n\n function pad(value, noPad) {\n if (value === null) {\n return '';\n }\n\n return angular.isDefined(value) && value.toString().length < 2 && !noPad ?\n '0' + value : value.toString();\n }\n\n // Respond on mousewheel spin\n this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {\n var isScrollingUp = function(e) {\n if (e.originalEvent) {\n e = e.originalEvent;\n }\n //pick correct delta variable depending on event\n var delta = e.wheelDelta ? e.wheelDelta : -e.deltaY;\n return e.detail || delta > 0;\n };\n\n hoursInputEl.bind('mousewheel wheel', function(e) {\n if (!disabled) {\n $scope.$apply(isScrollingUp(e) ? $scope.incrementHours() : $scope.decrementHours());\n }\n e.preventDefault();\n });\n\n minutesInputEl.bind('mousewheel wheel', function(e) {\n if (!disabled) {\n $scope.$apply(isScrollingUp(e) ? $scope.incrementMinutes() : $scope.decrementMinutes());\n }\n e.preventDefault();\n });\n\n secondsInputEl.bind('mousewheel wheel', function(e) {\n if (!disabled) {\n $scope.$apply(isScrollingUp(e) ? $scope.incrementSeconds() : $scope.decrementSeconds());\n }\n e.preventDefault();\n });\n };\n\n // Respond on up/down arrowkeys\n this.setupArrowkeyEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {\n hoursInputEl.bind('keydown', function(e) {\n if (!disabled) {\n if (e.which === 38) { // up\n e.preventDefault();\n $scope.incrementHours();\n $scope.$apply();\n } else if (e.which === 40) { // down\n e.preventDefault();\n $scope.decrementHours();\n $scope.$apply();\n }\n }\n });\n\n minutesInputEl.bind('keydown', function(e) {\n if (!disabled) {\n if (e.which === 38) { // up\n e.preventDefault();\n $scope.incrementMinutes();\n $scope.$apply();\n } else if (e.which === 40) { // down\n e.preventDefault();\n $scope.decrementMinutes();\n $scope.$apply();\n }\n }\n });\n\n secondsInputEl.bind('keydown', function(e) {\n if (!disabled) {\n if (e.which === 38) { // up\n e.preventDefault();\n $scope.incrementSeconds();\n $scope.$apply();\n } else if (e.which === 40) { // down\n e.preventDefault();\n $scope.decrementSeconds();\n $scope.$apply();\n }\n }\n });\n };\n\n this.setupInputEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {\n if ($scope.readonlyInput) {\n $scope.updateHours = angular.noop;\n $scope.updateMinutes = angular.noop;\n $scope.updateSeconds = angular.noop;\n return;\n }\n\n var invalidate = function(invalidHours, invalidMinutes, invalidSeconds) {\n ngModelCtrl.$setViewValue(null);\n ngModelCtrl.$setValidity('time', false);\n if (angular.isDefined(invalidHours)) {\n $scope.invalidHours = invalidHours;\n if (hoursModelCtrl) {\n hoursModelCtrl.$setValidity('hours', false);\n }\n }\n\n if (angular.isDefined(invalidMinutes)) {\n $scope.invalidMinutes = invalidMinutes;\n if (minutesModelCtrl) {\n minutesModelCtrl.$setValidity('minutes', false);\n }\n }\n\n if (angular.isDefined(invalidSeconds)) {\n $scope.invalidSeconds = invalidSeconds;\n if (secondsModelCtrl) {\n secondsModelCtrl.$setValidity('seconds', false);\n }\n }\n };\n\n $scope.updateHours = function() {\n var hours = getHoursFromTemplate(),\n minutes = getMinutesFromTemplate();\n\n ngModelCtrl.$setDirty();\n\n if (angular.isDefined(hours) && angular.isDefined(minutes)) {\n selected.setHours(hours);\n selected.setMinutes(minutes);\n if (selected < min || selected > max) {\n invalidate(true);\n } else {\n refresh('h');\n }\n } else {\n invalidate(true);\n }\n };\n\n hoursInputEl.bind('blur', function(e) {\n ngModelCtrl.$setTouched();\n if (modelIsEmpty()) {\n makeValid();\n } else if ($scope.hours === null || $scope.hours === '') {\n invalidate(true);\n } else if (!$scope.invalidHours && $scope.hours < 10) {\n $scope.$apply(function() {\n $scope.hours = pad($scope.hours, !padHours);\n });\n }\n });\n\n $scope.updateMinutes = function() {\n var minutes = getMinutesFromTemplate(),\n hours = getHoursFromTemplate();\n\n ngModelCtrl.$setDirty();\n\n if (angular.isDefined(minutes) && angular.isDefined(hours)) {\n selected.setHours(hours);\n selected.setMinutes(minutes);\n if (selected < min || selected > max) {\n invalidate(undefined, true);\n } else {\n refresh('m');\n }\n } else {\n invalidate(undefined, true);\n }\n };\n\n minutesInputEl.bind('blur', function(e) {\n ngModelCtrl.$setTouched();\n if (modelIsEmpty()) {\n makeValid();\n } else if ($scope.minutes === null) {\n invalidate(undefined, true);\n } else if (!$scope.invalidMinutes && $scope.minutes < 10) {\n $scope.$apply(function() {\n $scope.minutes = pad($scope.minutes);\n });\n }\n });\n\n $scope.updateSeconds = function() {\n var seconds = getSecondsFromTemplate();\n\n ngModelCtrl.$setDirty();\n\n if (angular.isDefined(seconds)) {\n selected.setSeconds(seconds);\n refresh('s');\n } else {\n invalidate(undefined, undefined, true);\n }\n };\n\n secondsInputEl.bind('blur', function(e) {\n if (modelIsEmpty()) {\n makeValid();\n } else if (!$scope.invalidSeconds && $scope.seconds < 10) {\n $scope.$apply( function() {\n $scope.seconds = pad($scope.seconds);\n });\n }\n });\n\n };\n\n this.render = function() {\n var date = ngModelCtrl.$viewValue;\n\n if (isNaN(date)) {\n ngModelCtrl.$setValidity('time', false);\n $log.error('Timepicker directive: \"ng-model\" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.');\n } else {\n if (date) {\n selected = date;\n }\n\n if (selected < min || selected > max) {\n ngModelCtrl.$setValidity('time', false);\n $scope.invalidHours = true;\n $scope.invalidMinutes = true;\n } else {\n makeValid();\n }\n updateTemplate();\n }\n };\n\n // Call internally when we know that model is valid.\n function refresh(keyboardChange) {\n makeValid();\n ngModelCtrl.$setViewValue(new Date(selected));\n updateTemplate(keyboardChange);\n }\n\n function makeValid() {\n if (hoursModelCtrl) {\n hoursModelCtrl.$setValidity('hours', true);\n }\n\n if (minutesModelCtrl) {\n minutesModelCtrl.$setValidity('minutes', true);\n }\n\n if (secondsModelCtrl) {\n secondsModelCtrl.$setValidity('seconds', true);\n }\n\n ngModelCtrl.$setValidity('time', true);\n $scope.invalidHours = false;\n $scope.invalidMinutes = false;\n $scope.invalidSeconds = false;\n }\n\n function updateTemplate(keyboardChange) {\n if (!ngModelCtrl.$modelValue) {\n $scope.hours = null;\n $scope.minutes = null;\n $scope.seconds = null;\n $scope.meridian = meridians[0];\n } else {\n var hours = selected.getHours(),\n minutes = selected.getMinutes(),\n seconds = selected.getSeconds();\n\n if ($scope.showMeridian) {\n hours = hours === 0 || hours === 12 ? 12 : hours % 12; // Convert 24 to 12 hour system\n }\n\n $scope.hours = keyboardChange === 'h' ? hours : pad(hours, !padHours);\n if (keyboardChange !== 'm') {\n $scope.minutes = pad(minutes);\n }\n $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];\n\n if (keyboardChange !== 's') {\n $scope.seconds = pad(seconds);\n }\n $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];\n }\n }\n\n function addSecondsToSelected(seconds) {\n selected = addSeconds(selected, seconds);\n refresh();\n }\n\n function addMinutes(selected, minutes) {\n return addSeconds(selected, minutes*60);\n }\n\n function addSeconds(date, seconds) {\n var dt = new Date(date.getTime() + seconds * 1000);\n var newDate = new Date(date);\n newDate.setHours(dt.getHours(), dt.getMinutes(), dt.getSeconds());\n return newDate;\n }\n\n function modelIsEmpty() {\n return ($scope.hours === null || $scope.hours === '') &&\n ($scope.minutes === null || $scope.minutes === '') &&\n (!$scope.showSeconds || $scope.showSeconds && ($scope.seconds === null || $scope.seconds === ''));\n }\n\n $scope.showSpinners = angular.isDefined($attrs.showSpinners) ?\n $scope.$parent.$eval($attrs.showSpinners) : timepickerConfig.showSpinners;\n\n $scope.incrementHours = function() {\n if (!$scope.noIncrementHours()) {\n addSecondsToSelected(hourStep * 60 * 60);\n }\n };\n\n $scope.decrementHours = function() {\n if (!$scope.noDecrementHours()) {\n addSecondsToSelected(-hourStep * 60 * 60);\n }\n };\n\n $scope.incrementMinutes = function() {\n if (!$scope.noIncrementMinutes()) {\n addSecondsToSelected(minuteStep * 60);\n }\n };\n\n $scope.decrementMinutes = function() {\n if (!$scope.noDecrementMinutes()) {\n addSecondsToSelected(-minuteStep * 60);\n }\n };\n\n $scope.incrementSeconds = function() {\n if (!$scope.noIncrementSeconds()) {\n addSecondsToSelected(secondStep);\n }\n };\n\n $scope.decrementSeconds = function() {\n if (!$scope.noDecrementSeconds()) {\n addSecondsToSelected(-secondStep);\n }\n };\n\n $scope.toggleMeridian = function() {\n var minutes = getMinutesFromTemplate(),\n hours = getHoursFromTemplate();\n\n if (!$scope.noToggleMeridian()) {\n if (angular.isDefined(minutes) && angular.isDefined(hours)) {\n addSecondsToSelected(12 * 60 * (selected.getHours() < 12 ? 60 : -60));\n } else {\n $scope.meridian = $scope.meridian === meridians[0] ? meridians[1] : meridians[0];\n }\n }\n };\n\n $scope.blur = function() {\n ngModelCtrl.$setTouched();\n };\n\n $scope.$on('$destroy', function() {\n while (watchers.length) {\n watchers.shift()();\n }\n });\n}])\n\n.directive('uibTimepicker', ['uibTimepickerConfig', function(uibTimepickerConfig) {\n return {\n require: ['uibTimepicker', '?^ngModel'],\n restrict: 'A',\n controller: 'UibTimepickerController',\n controllerAs: 'timepicker',\n scope: {},\n templateUrl: function(element, attrs) {\n return attrs.templateUrl || uibTimepickerConfig.templateUrl;\n },\n link: function(scope, element, attrs, ctrls) {\n var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];\n\n if (ngModelCtrl) {\n timepickerCtrl.init(ngModelCtrl, element.find('input'));\n }\n }\n };\n}]);\n\nangular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap.position'])\n\n/**\n * A helper service that can parse typeahead's syntax (string provided by users)\n * Extracted to a separate service for ease of unit testing\n */\n .factory('uibTypeaheadParser', ['$parse', function($parse) {\n // 000001111111100000000000002222222200000000000000003333333333333330000000000044444444000\n var TYPEAHEAD_REGEXP = /^\\s*([\\s\\S]+?)(?:\\s+as\\s+([\\s\\S]+?))?\\s+for\\s+(?:([\\$\\w][\\$\\w\\d]*))\\s+in\\s+([\\s\\S]+?)$/;\n return {\n parse: function(input) {\n var match = input.match(TYPEAHEAD_REGEXP);\n if (!match) {\n throw new Error(\n 'Expected typeahead specification in form of \"_modelValue_ (as _label_)? for _item_ in _collection_\"' +\n ' but got \"' + input + '\".');\n }\n\n return {\n itemName: match[3],\n source: $parse(match[4]),\n viewMapper: $parse(match[2] || match[1]),\n modelMapper: $parse(match[1])\n };\n }\n };\n }])\n\n .controller('UibTypeaheadController', ['$scope', '$element', '$attrs', '$compile', '$parse', '$q', '$timeout', '$document', '$window', '$rootScope', '$$debounce', '$uibPosition', 'uibTypeaheadParser',\n function(originalScope, element, attrs, $compile, $parse, $q, $timeout, $document, $window, $rootScope, $$debounce, $position, typeaheadParser) {\n var HOT_KEYS = [9, 13, 27, 38, 40];\n var eventDebounceTime = 200;\n var modelCtrl, ngModelOptions;\n //SUPPORTED ATTRIBUTES (OPTIONS)\n\n //minimal no of characters that needs to be entered before typeahead kicks-in\n var minLength = originalScope.$eval(attrs.typeaheadMinLength);\n if (!minLength && minLength !== 0) {\n minLength = 1;\n }\n\n originalScope.$watch(attrs.typeaheadMinLength, function (newVal) {\n minLength = !newVal && newVal !== 0 ? 1 : newVal;\n });\n\n //minimal wait time after last character typed before typeahead kicks-in\n var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0;\n\n //should it restrict model values to the ones selected from the popup only?\n var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false;\n originalScope.$watch(attrs.typeaheadEditable, function (newVal) {\n isEditable = newVal !== false;\n });\n\n //binding to a variable that indicates if matches are being retrieved asynchronously\n var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop;\n\n //a function to determine if an event should cause selection\n var isSelectEvent = attrs.typeaheadShouldSelect ? $parse(attrs.typeaheadShouldSelect) : function(scope, vals) {\n var evt = vals.$event;\n return evt.which === 13 || evt.which === 9;\n };\n\n //a callback executed when a match is selected\n var onSelectCallback = $parse(attrs.typeaheadOnSelect);\n\n //should it select highlighted popup value when losing focus?\n var isSelectOnBlur = angular.isDefined(attrs.typeaheadSelectOnBlur) ? originalScope.$eval(attrs.typeaheadSelectOnBlur) : false;\n\n //binding to a variable that indicates if there were no results after the query is completed\n var isNoResultsSetter = $parse(attrs.typeaheadNoResults).assign || angular.noop;\n\n var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined;\n\n var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false;\n\n var appendTo = attrs.typeaheadAppendTo ?\n originalScope.$eval(attrs.typeaheadAppendTo) : null;\n\n var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;\n\n //If input matches an item of the list exactly, select it automatically\n var selectOnExact = attrs.typeaheadSelectOnExact ? originalScope.$eval(attrs.typeaheadSelectOnExact) : false;\n\n //binding to a variable that indicates if dropdown is open\n var isOpenSetter = $parse(attrs.typeaheadIsOpen).assign || angular.noop;\n\n var showHint = originalScope.$eval(attrs.typeaheadShowHint) || false;\n\n //INTERNAL VARIABLES\n\n //model setter executed upon match selection\n var parsedModel = $parse(attrs.ngModel);\n var invokeModelSetter = $parse(attrs.ngModel + '($$$p)');\n var $setModelValue = function(scope, newValue) {\n if (angular.isFunction(parsedModel(originalScope)) &&\n ngModelOptions && ngModelOptions.$options && ngModelOptions.$options.getterSetter) {\n return invokeModelSetter(scope, {$$$p: newValue});\n }\n\n return parsedModel.assign(scope, newValue);\n };\n\n //expressions used by typeahead\n var parserResult = typeaheadParser.parse(attrs.uibTypeahead);\n\n var hasFocus;\n\n //Used to avoid bug in iOS webview where iOS keyboard does not fire\n //mousedown & mouseup events\n //Issue #3699\n var selected;\n\n //create a child scope for the typeahead directive so we are not polluting original scope\n //with typeahead-specific data (matches, query etc.)\n var scope = originalScope.$new();\n var offDestroy = originalScope.$on('$destroy', function() {\n scope.$destroy();\n });\n scope.$on('$destroy', offDestroy);\n\n // WAI-ARIA\n var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);\n element.attr({\n 'aria-autocomplete': 'list',\n 'aria-expanded': false,\n 'aria-owns': popupId\n });\n\n var inputsContainer, hintInputElem;\n //add read-only input to show hint\n if (showHint) {\n inputsContainer = angular.element('
');\n inputsContainer.css('position', 'relative');\n element.after(inputsContainer);\n hintInputElem = element.clone();\n hintInputElem.attr('placeholder', '');\n hintInputElem.attr('tabindex', '-1');\n hintInputElem.val('');\n hintInputElem.css({\n 'position': 'absolute',\n 'top': '0px',\n 'left': '0px',\n 'border-color': 'transparent',\n 'box-shadow': 'none',\n 'opacity': 1,\n 'background': 'none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255)',\n 'color': '#999'\n });\n element.css({\n 'position': 'relative',\n 'vertical-align': 'top',\n 'background-color': 'transparent'\n });\n\n if (hintInputElem.attr('id')) {\n hintInputElem.removeAttr('id'); // remove duplicate id if present.\n }\n inputsContainer.append(hintInputElem);\n hintInputElem.after(element);\n }\n\n //pop-up element used to display matches\n var popUpEl = angular.element('
');\n popUpEl.attr({\n id: popupId,\n matches: 'matches',\n active: 'activeIdx',\n select: 'select(activeIdx, evt)',\n 'move-in-progress': 'moveInProgress',\n query: 'query',\n position: 'position',\n 'assign-is-open': 'assignIsOpen(isOpen)',\n debounce: 'debounceUpdate'\n });\n //custom item template\n if (angular.isDefined(attrs.typeaheadTemplateUrl)) {\n popUpEl.attr('template-url', attrs.typeaheadTemplateUrl);\n }\n\n if (angular.isDefined(attrs.typeaheadPopupTemplateUrl)) {\n popUpEl.attr('popup-template-url', attrs.typeaheadPopupTemplateUrl);\n }\n\n var resetHint = function() {\n if (showHint) {\n hintInputElem.val('');\n }\n };\n\n var resetMatches = function() {\n scope.matches = [];\n scope.activeIdx = -1;\n element.attr('aria-expanded', false);\n resetHint();\n };\n\n var getMatchId = function(index) {\n return popupId + '-option-' + index;\n };\n\n // Indicate that the specified match is the active (pre-selected) item in the list owned by this typeahead.\n // This attribute is added or removed automatically when the `activeIdx` changes.\n scope.$watch('activeIdx', function(index) {\n if (index < 0) {\n element.removeAttr('aria-activedescendant');\n } else {\n element.attr('aria-activedescendant', getMatchId(index));\n }\n });\n\n var inputIsExactMatch = function(inputValue, index) {\n if (scope.matches.length > index && inputValue) {\n return inputValue.toUpperCase() === scope.matches[index].label.toUpperCase();\n }\n\n return false;\n };\n\n var getMatchesAsync = function(inputValue, evt) {\n var locals = {$viewValue: inputValue};\n isLoadingSetter(originalScope, true);\n isNoResultsSetter(originalScope, false);\n $q.when(parserResult.source(originalScope, locals)).then(function(matches) {\n //it might happen that several async queries were in progress if a user were typing fast\n //but we are interested only in responses that correspond to the current view value\n var onCurrentRequest = inputValue === modelCtrl.$viewValue;\n if (onCurrentRequest && hasFocus) {\n if (matches && matches.length > 0) {\n scope.activeIdx = focusFirst ? 0 : -1;\n isNoResultsSetter(originalScope, false);\n scope.matches.length = 0;\n\n //transform labels\n for (var i = 0; i < matches.length; i++) {\n locals[parserResult.itemName] = matches[i];\n scope.matches.push({\n id: getMatchId(i),\n label: parserResult.viewMapper(scope, locals),\n model: matches[i]\n });\n }\n\n scope.query = inputValue;\n //position pop-up with matches - we need to re-calculate its position each time we are opening a window\n //with matches as a pop-up might be absolute-positioned and position of an input might have changed on a page\n //due to other elements being rendered\n recalculatePosition();\n\n element.attr('aria-expanded', true);\n\n //Select the single remaining option if user input matches\n if (selectOnExact && scope.matches.length === 1 && inputIsExactMatch(inputValue, 0)) {\n if (angular.isNumber(scope.debounceUpdate) || angular.isObject(scope.debounceUpdate)) {\n $$debounce(function() {\n scope.select(0, evt);\n }, angular.isNumber(scope.debounceUpdate) ? scope.debounceUpdate : scope.debounceUpdate['default']);\n } else {\n scope.select(0, evt);\n }\n }\n\n if (showHint) {\n var firstLabel = scope.matches[0].label;\n if (angular.isString(inputValue) &&\n inputValue.length > 0 &&\n firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) {\n hintInputElem.val(inputValue + firstLabel.slice(inputValue.length));\n } else {\n hintInputElem.val('');\n }\n }\n } else {\n resetMatches();\n isNoResultsSetter(originalScope, true);\n }\n }\n if (onCurrentRequest) {\n isLoadingSetter(originalScope, false);\n }\n }, function() {\n resetMatches();\n isLoadingSetter(originalScope, false);\n isNoResultsSetter(originalScope, true);\n });\n };\n\n // bind events only if appendToBody params exist - performance feature\n if (appendToBody) {\n angular.element($window).on('resize', fireRecalculating);\n $document.find('body').on('scroll', fireRecalculating);\n }\n\n // Declare the debounced function outside recalculating for\n // proper debouncing\n var debouncedRecalculate = $$debounce(function() {\n // if popup is visible\n if (scope.matches.length) {\n recalculatePosition();\n }\n\n scope.moveInProgress = false;\n }, eventDebounceTime);\n\n // Default progress type\n scope.moveInProgress = false;\n\n function fireRecalculating() {\n if (!scope.moveInProgress) {\n scope.moveInProgress = true;\n scope.$digest();\n }\n\n debouncedRecalculate();\n }\n\n // recalculate actual position and set new values to scope\n // after digest loop is popup in right position\n function recalculatePosition() {\n scope.position = appendToBody ? $position.offset(element) : $position.position(element);\n scope.position.top += element.prop('offsetHeight');\n }\n\n //we need to propagate user's query so we can higlight matches\n scope.query = undefined;\n\n //Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later\n var timeoutPromise;\n\n var scheduleSearchWithTimeout = function(inputValue) {\n timeoutPromise = $timeout(function() {\n getMatchesAsync(inputValue);\n }, waitTime);\n };\n\n var cancelPreviousTimeout = function() {\n if (timeoutPromise) {\n $timeout.cancel(timeoutPromise);\n }\n };\n\n resetMatches();\n\n scope.assignIsOpen = function (isOpen) {\n isOpenSetter(originalScope, isOpen);\n };\n\n scope.select = function(activeIdx, evt) {\n //called from within the $digest() cycle\n var locals = {};\n var model, item;\n\n selected = true;\n locals[parserResult.itemName] = item = scope.matches[activeIdx].model;\n model = parserResult.modelMapper(originalScope, locals);\n $setModelValue(originalScope, model);\n modelCtrl.$setValidity('editable', true);\n modelCtrl.$setValidity('parse', true);\n\n onSelectCallback(originalScope, {\n $item: item,\n $model: model,\n $label: parserResult.viewMapper(originalScope, locals),\n $event: evt\n });\n\n resetMatches();\n\n //return focus to the input element if a match was selected via a mouse click event\n // use timeout to avoid $rootScope:inprog error\n if (scope.$eval(attrs.typeaheadFocusOnSelect) !== false) {\n $timeout(function() { element[0].focus(); }, 0, false);\n }\n };\n\n //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27)\n element.on('keydown', function(evt) {\n //typeahead is open and an \"interesting\" key was pressed\n if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) {\n return;\n }\n\n var shouldSelect = isSelectEvent(originalScope, {$event: evt});\n\n /**\n * if there's nothing selected (i.e. focusFirst) and enter or tab is hit\n * or\n * shift + tab is pressed to bring focus to the previous element\n * then clear the results\n */\n if (scope.activeIdx === -1 && shouldSelect || evt.which === 9 && !!evt.shiftKey) {\n resetMatches();\n scope.$digest();\n return;\n }\n\n evt.preventDefault();\n var target;\n switch (evt.which) {\n case 27: // escape\n evt.stopPropagation();\n\n resetMatches();\n originalScope.$digest();\n break;\n case 38: // up arrow\n scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;\n scope.$digest();\n target = popUpEl[0].querySelectorAll('.uib-typeahead-match')[scope.activeIdx];\n target.parentNode.scrollTop = target.offsetTop;\n break;\n case 40: // down arrow\n scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;\n scope.$digest();\n target = popUpEl[0].querySelectorAll('.uib-typeahead-match')[scope.activeIdx];\n target.parentNode.scrollTop = target.offsetTop;\n break;\n default:\n if (shouldSelect) {\n scope.$apply(function() {\n if (angular.isNumber(scope.debounceUpdate) || angular.isObject(scope.debounceUpdate)) {\n $$debounce(function() {\n scope.select(scope.activeIdx, evt);\n }, angular.isNumber(scope.debounceUpdate) ? scope.debounceUpdate : scope.debounceUpdate['default']);\n } else {\n scope.select(scope.activeIdx, evt);\n }\n });\n }\n }\n });\n\n element.bind('focus', function (evt) {\n hasFocus = true;\n if (minLength === 0 && !modelCtrl.$viewValue) {\n $timeout(function() {\n getMatchesAsync(modelCtrl.$viewValue, evt);\n }, 0);\n }\n });\n\n element.bind('blur', function(evt) {\n if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) {\n selected = true;\n scope.$apply(function() {\n if (angular.isObject(scope.debounceUpdate) && angular.isNumber(scope.debounceUpdate.blur)) {\n $$debounce(function() {\n scope.select(scope.activeIdx, evt);\n }, scope.debounceUpdate.blur);\n } else {\n scope.select(scope.activeIdx, evt);\n }\n });\n }\n if (!isEditable && modelCtrl.$error.editable) {\n modelCtrl.$setViewValue();\n scope.$apply(function() {\n // Reset validity as we are clearing\n modelCtrl.$setValidity('editable', true);\n modelCtrl.$setValidity('parse', true);\n });\n element.val('');\n }\n hasFocus = false;\n selected = false;\n });\n\n // Keep reference to click handler to unbind it.\n var dismissClickHandler = function(evt) {\n // Issue #3973\n // Firefox treats right click as a click on document\n if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) {\n resetMatches();\n if (!$rootScope.$$phase) {\n originalScope.$digest();\n }\n }\n };\n\n $document.on('click', dismissClickHandler);\n\n originalScope.$on('$destroy', function() {\n $document.off('click', dismissClickHandler);\n if (appendToBody || appendTo) {\n $popup.remove();\n }\n\n if (appendToBody) {\n angular.element($window).off('resize', fireRecalculating);\n $document.find('body').off('scroll', fireRecalculating);\n }\n // Prevent jQuery cache memory leak\n popUpEl.remove();\n\n if (showHint) {\n inputsContainer.remove();\n }\n });\n\n var $popup = $compile(popUpEl)(scope);\n\n if (appendToBody) {\n $document.find('body').append($popup);\n } else if (appendTo) {\n angular.element(appendTo).eq(0).append($popup);\n } else {\n element.after($popup);\n }\n\n this.init = function(_modelCtrl, _ngModelOptions) {\n modelCtrl = _modelCtrl;\n ngModelOptions = _ngModelOptions;\n\n scope.debounceUpdate = modelCtrl.$options && $parse(modelCtrl.$options.debounce)(originalScope);\n\n //plug into $parsers pipeline to open a typeahead on view changes initiated from DOM\n //$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue\n modelCtrl.$parsers.unshift(function(inputValue) {\n hasFocus = true;\n\n if (minLength === 0 || inputValue && inputValue.length >= minLength) {\n if (waitTime > 0) {\n cancelPreviousTimeout();\n scheduleSearchWithTimeout(inputValue);\n } else {\n getMatchesAsync(inputValue);\n }\n } else {\n isLoadingSetter(originalScope, false);\n cancelPreviousTimeout();\n resetMatches();\n }\n\n if (isEditable) {\n return inputValue;\n }\n\n if (!inputValue) {\n // Reset in case user had typed something previously.\n modelCtrl.$setValidity('editable', true);\n return null;\n }\n\n modelCtrl.$setValidity('editable', false);\n return undefined;\n });\n\n modelCtrl.$formatters.push(function(modelValue) {\n var candidateViewValue, emptyViewValue;\n var locals = {};\n\n // The validity may be set to false via $parsers (see above) if\n // the model is restricted to selected values. If the model\n // is set manually it is considered to be valid.\n if (!isEditable) {\n modelCtrl.$setValidity('editable', true);\n }\n\n if (inputFormatter) {\n locals.$model = modelValue;\n return inputFormatter(originalScope, locals);\n }\n\n //it might happen that we don't have enough info to properly render input value\n //we need to check for this situation and simply return model value if we can't apply custom formatting\n locals[parserResult.itemName] = modelValue;\n candidateViewValue = parserResult.viewMapper(originalScope, locals);\n locals[parserResult.itemName] = undefined;\n emptyViewValue = parserResult.viewMapper(originalScope, locals);\n\n return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue;\n });\n };\n }])\n\n .directive('uibTypeahead', function() {\n return {\n controller: 'UibTypeaheadController',\n require: ['ngModel', '^?ngModelOptions', 'uibTypeahead'],\n link: function(originalScope, element, attrs, ctrls) {\n ctrls[2].init(ctrls[0], ctrls[1]);\n }\n };\n })\n\n .directive('uibTypeaheadPopup', ['$$debounce', function($$debounce) {\n return {\n scope: {\n matches: '=',\n query: '=',\n active: '=',\n position: '&',\n moveInProgress: '=',\n select: '&',\n assignIsOpen: '&',\n debounce: '&'\n },\n replace: true,\n templateUrl: function(element, attrs) {\n return attrs.popupTemplateUrl || 'uib/template/typeahead/typeahead-popup.html';\n },\n link: function(scope, element, attrs) {\n scope.templateUrl = attrs.templateUrl;\n\n scope.isOpen = function() {\n var isDropdownOpen = scope.matches.length > 0;\n scope.assignIsOpen({ isOpen: isDropdownOpen });\n return isDropdownOpen;\n };\n\n scope.isActive = function(matchIdx) {\n return scope.active === matchIdx;\n };\n\n scope.selectActive = function(matchIdx) {\n scope.active = matchIdx;\n };\n\n scope.selectMatch = function(activeIdx, evt) {\n var debounce = scope.debounce();\n if (angular.isNumber(debounce) || angular.isObject(debounce)) {\n $$debounce(function() {\n scope.select({activeIdx: activeIdx, evt: evt});\n }, angular.isNumber(debounce) ? debounce : debounce['default']);\n } else {\n scope.select({activeIdx: activeIdx, evt: evt});\n }\n };\n }\n };\n }])\n\n .directive('uibTypeaheadMatch', ['$templateRequest', '$compile', '$parse', function($templateRequest, $compile, $parse) {\n return {\n scope: {\n index: '=',\n match: '=',\n query: '='\n },\n link: function(scope, element, attrs) {\n var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || 'uib/template/typeahead/typeahead-match.html';\n $templateRequest(tplUrl).then(function(tplContent) {\n var tplEl = angular.element(tplContent.trim());\n element.replaceWith(tplEl);\n $compile(tplEl)(scope);\n });\n }\n };\n }])\n\n .filter('uibTypeaheadHighlight', ['$sce', '$injector', '$log', function($sce, $injector, $log) {\n var isSanitizePresent;\n isSanitizePresent = $injector.has('$sanitize');\n\n function escapeRegexp(queryToEscape) {\n // Regex: capture the whole query string and replace it with the string that will be used to match\n // the results, for example if the capture is \"a\" the result will be \\a\n return queryToEscape.replace(/([.?*+^$[\\]\\\\(){}|-])/g, '\\\\$1');\n }\n\n function containsHtml(matchItem) {\n return /<.*>/g.test(matchItem);\n }\n\n return function(matchItem, query) {\n if (!isSanitizePresent && containsHtml(matchItem)) {\n $log.warn('Unsafe use of typeahead please use ngSanitize'); // Warn the user about the danger\n }\n matchItem = query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '
$&') : matchItem; // Replaces the capture string with a the same string inside of a \"strong\" tag\n if (!isSanitizePresent) {\n matchItem = $sce.trustAsHtml(matchItem); // If $sanitize is not present we pack the string in a $sce object for the ng-bind-html directive\n }\n return matchItem;\n };\n }]);\n\nangular.module(\"uib/template/accordion/accordion-group.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/accordion/accordion-group.html\",\n \"
\\n\" +\n \"
\\n\" +\n \" {{heading}}\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/accordion/accordion.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/accordion/accordion.html\",\n \"
\");\n}]);\n\nangular.module(\"uib/template/alert/alert.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/alert/alert.html\",\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/carousel/carousel.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/carousel/carousel.html\",\n \"
\\n\" +\n \"
1\\\">\\n\" +\n \" \\n\" +\n \" previous\\n\" +\n \"\\n\" +\n \"
1\\\">\\n\" +\n \" \\n\" +\n \" next\\n\" +\n \"\\n\" +\n \"
1\\\">\\n\" +\n \" - \\n\" +\n \" slide {{ $index + 1 }} of {{ slides.length }}, currently active\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/carousel/slide.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/carousel/slide.html\",\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/datepicker/datepicker.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/datepicker/datepicker.html\",\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/datepicker/day.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/datepicker/day.html\",\n \"
\\n\" +\n \" \\n\" +\n \" \\n\" +\n \" | \\n\" +\n \" | \\n\" +\n \" | \\n\" +\n \"
\\n\" +\n \" \\n\" +\n \" | \\n\" +\n \" {{::label.abbr}} | \\n\" +\n \"
\\n\" +\n \" \\n\" +\n \" \\n\" +\n \" \\n\" +\n \" {{ weekNumbers[$index] }} | \\n\" +\n \" \\n\" +\n \" \\n\" +\n \" | \\n\" +\n \"
\\n\" +\n \" \\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/datepicker/month.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/datepicker/month.html\",\n \"
\\n\" +\n \" \\n\" +\n \" \\n\" +\n \" | \\n\" +\n \" | \\n\" +\n \" | \\n\" +\n \"
\\n\" +\n \" \\n\" +\n \" \\n\" +\n \" \\n\" +\n \" \\n\" +\n \" \\n\" +\n \" | \\n\" +\n \"
\\n\" +\n \" \\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/datepicker/year.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/datepicker/year.html\",\n \"
\\n\" +\n \" \\n\" +\n \" \\n\" +\n \" | \\n\" +\n \" | \\n\" +\n \" | \\n\" +\n \"
\\n\" +\n \" \\n\" +\n \" \\n\" +\n \" \\n\" +\n \" \\n\" +\n \" \\n\" +\n \" | \\n\" +\n \"
\\n\" +\n \" \\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/datepickerPopup/popup.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/datepickerPopup/popup.html\",\n \"\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/modal/window.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/modal/window.html\",\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/pager/pager.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/pager/pager.html\",\n \"
{{::getText('previous')}}\\n\" +\n \"
{{::getText('next')}}\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/pagination/pagination.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/pagination/pagination.html\",\n \"\\n\" +\n \"\\n\" +\n \"\\n\" +\n \"\\n\" +\n \"\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/tooltip/tooltip-html-popup.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/tooltip/tooltip-html-popup.html\",\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/tooltip/tooltip-popup.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/tooltip/tooltip-popup.html\",\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/tooltip/tooltip-template-popup.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/tooltip/tooltip-template-popup.html\",\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/popover/popover-html.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/popover/popover-html.html\",\n \"
\\n\" +\n \"\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/popover/popover-template.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/popover/popover-template.html\",\n \"
\\n\" +\n \"\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/popover/popover.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/popover/popover.html\",\n \"
\\n\" +\n \"\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/progressbar/bar.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/progressbar/bar.html\",\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/progressbar/progress.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/progressbar/progress.html\",\n \"
\");\n}]);\n\nangular.module(\"uib/template/progressbar/progressbar.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/progressbar/progressbar.html\",\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/rating/rating.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/rating/rating.html\",\n \"
\\n\" +\n \" ({{ $index < value ? '*' : ' ' }})\\n\" +\n \" \\n\" +\n \"\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/tabs/tab.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/tabs/tab.html\",\n \"
\\n\" +\n \" {{heading}}\\n\" +\n \"\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/tabs/tabset.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/tabs/tabset.html\",\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/timepicker/timepicker.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/timepicker/timepicker.html\",\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/typeahead/typeahead-match.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/typeahead/typeahead-match.html\",\n \"
\\n\" +\n \"\");\n}]);\n\nangular.module(\"uib/template/typeahead/typeahead-popup.html\", []).run([\"$templateCache\", function($templateCache) {\n $templateCache.put(\"uib/template/typeahead/typeahead-popup.html\",\n \"\\n\" +\n \"\");\n}]);\nangular.module('ui.bootstrap.carousel').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibCarouselCss && angular.element(document).find('head').prepend(''); angular.$$uibCarouselCss = true; });\nangular.module('ui.bootstrap.datepicker').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibDatepickerCss && angular.element(document).find('head').prepend(''); angular.$$uibDatepickerCss = true; });\nangular.module('ui.bootstrap.position').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibPositionCss && angular.element(document).find('head').prepend(''); angular.$$uibPositionCss = true; });\nangular.module('ui.bootstrap.datepickerPopup').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibDatepickerpopupCss && angular.element(document).find('head').prepend(''); angular.$$uibDatepickerpopupCss = true; });\nangular.module('ui.bootstrap.tooltip').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTooltipCss && angular.element(document).find('head').prepend(''); angular.$$uibTooltipCss = true; });\nangular.module('ui.bootstrap.timepicker').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTimepickerCss && angular.element(document).find('head').prepend(''); angular.$$uibTimepickerCss = true; });\nangular.module('ui.bootstrap.typeahead').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTypeaheadCss && angular.element(document).find('head').prepend(''); angular.$$uibTypeaheadCss = true; });\nangular.module('cgBusy',[]);\n\n//loosely modeled after angular-promise-tracker\nangular.module('cgBusy').factory('_cgBusyTrackerFactory',['$timeout','$q',function($timeout,$q){\n\n return function(){\n\n var tracker = {};\n tracker.promises = [];\n tracker.delayPromise = null;\n tracker.durationPromise = null;\n tracker.delayJustFinished = false;\n\n tracker.reset = function(options){\n tracker.minDuration = options.minDuration;\n\n tracker.promises = [];\n angular.forEach(options.promises,function(p){\n if (!p || p.$cgBusyFulfilled) {\n return;\n }\n addPromiseLikeThing(p);\n });\n\n if (tracker.promises.length === 0) {\n //if we have no promises then dont do the delay or duration stuff\n return;\n }\n\n tracker.delayJustFinished = false;\n if (options.delay) {\n tracker.delayPromise = $timeout(function(){\n tracker.delayPromise = null;\n tracker.delayJustFinished = true;\n },parseInt(options.delay,10));\n }\n if (options.minDuration) {\n tracker.durationPromise = $timeout(function(){\n tracker.durationPromise = null;\n },parseInt(options.minDuration,10) + (options.delay ? parseInt(options.delay,10) : 0));\n } \n };\n\n tracker.isPromise = function(promiseThing){\n var then = promiseThing && (promiseThing.then || promiseThing.$then ||\n (promiseThing.$promise && promiseThing.$promise.then));\n\n return typeof then !== 'undefined'; \n };\n\n tracker.callThen = function(promiseThing,success,error){\n var promise;\n if (promiseThing.then || promiseThing.$then){\n promise = promiseThing;\n } else if (promiseThing.$promise){\n promise = promiseThing.$promise;\n } else if (promiseThing.denodeify){\n promise = $q.when(promiseThing);\n }\n \n var then = (promise.then || promise.$then);\n\n then.call(promise,success,error);\n };\n\n var addPromiseLikeThing = function(promise){\n\n if (!tracker.isPromise(promise)) {\n throw new Error('cgBusy expects a promise (or something that has a .promise or .$promise');\n }\n\n if (tracker.promises.indexOf(promise) !== -1){\n return;\n }\n tracker.promises.push(promise);\n\n tracker.callThen(promise, function(){\n promise.$cgBusyFulfilled = true;\n if (tracker.promises.indexOf(promise) === -1) {\n return;\n }\n tracker.promises.splice(tracker.promises.indexOf(promise),1);\n },function(){\n promise.$cgBusyFulfilled = true;\n if (tracker.promises.indexOf(promise) === -1) {\n return;\n }\n tracker.promises.splice(tracker.promises.indexOf(promise),1);\n });\n };\n\n tracker.active = function(){\n if (tracker.delayPromise){\n return false;\n }\n\n if (!tracker.delayJustFinished){\n if (tracker.durationPromise){\n return true;\n }\n return tracker.promises.length > 0;\n } else {\n //if both delay and min duration are set, \n //we don't want to initiate the min duration if the \n //promise finished before the delay was complete\n tracker.delayJustFinished = false;\n if (tracker.promises.length === 0) {\n tracker.durationPromise = null;\n }\n return tracker.promises.length > 0;\n }\n };\n\n return tracker;\n\n };\n}]);\n\nangular.module('cgBusy').value('cgBusyDefaults',{});\n\nangular.module('cgBusy').directive('cgBusy',['$compile','$templateCache','cgBusyDefaults','$http','_cgBusyTrackerFactory',\n function($compile,$templateCache,cgBusyDefaults,$http,_cgBusyTrackerFactory){\n return {\n restrict: 'A',\n link: function(scope, element, attrs, fn) {\n\n //Apply position:relative to parent element if necessary\n var position = element.css('position');\n if (position === 'static' || position === '' || typeof position === 'undefined'){\n element.css('position','relative');\n }\n\n var templateElement;\n var backdropElement;\n var currentTemplate;\n var templateScope;\n var backdrop;\n var tracker = _cgBusyTrackerFactory();\n\n var defaults = {\n templateUrl: 'angular-busy.html',\n delay:0,\n minDuration:0,\n backdrop: true,\n message:'Please Wait...',\n wrapperClass: 'cg-busy cg-busy-animation'\n };\n\n angular.extend(defaults,cgBusyDefaults);\n\n scope.$watchCollection(attrs.cgBusy,function(options){\n\n if (!options) {\n options = {promise:null};\n }\n\n if (angular.isString(options)) {\n throw new Error('Invalid value for cg-busy. cgBusy no longer accepts string ids to represent promises/trackers.');\n }\n\n //is it an array (of promises) or one promise\n if (angular.isArray(options) || tracker.isPromise(options)) {\n options = {promise:options};\n }\n\n options = angular.extend(angular.copy(defaults),options);\n\n if (!options.templateUrl){\n options.templateUrl = defaults.templateUrl;\n }\n\n if (!angular.isArray(options.promise)){\n options.promise = [options.promise];\n }\n\n // options.promise = angular.isArray(options.promise) ? options.promise : [options.promise];\n // options.message = options.message ? options.message : 'Please Wait...';\n // options.template = options.template ? options.template : cgBusyTemplateName;\n // options.minDuration = options.minDuration ? options.minDuration : 0;\n // options.delay = options.delay ? options.delay : 0;\n\n if (!templateScope) {\n templateScope = scope.$new();\n }\n\n templateScope.$message = options.message;\n\n if (!angular.equals(tracker.promises,options.promise)) {\n tracker.reset({\n promises:options.promise,\n delay:options.delay,\n minDuration: options.minDuration\n });\n }\n\n templateScope.$cgBusyIsActive = function() {\n return tracker.active();\n };\n\n\n if (!templateElement || currentTemplate !== options.templateUrl || backdrop !== options.backdrop) {\n\n if (templateElement) {\n templateElement.remove();\n }\n if (backdropElement){\n backdropElement.remove();\n }\n\n currentTemplate = options.templateUrl;\n backdrop = options.backdrop;\n\n $http.get(currentTemplate,{cache: $templateCache}).success(function(indicatorTemplate){\n\n options.backdrop = typeof options.backdrop === 'undefined' ? true : options.backdrop;\n\n if (options.backdrop){\n var backdrop = '
';\n backdropElement = $compile(backdrop)(templateScope);\n element.append(backdropElement);\n }\n\n var template = '
' + indicatorTemplate + '
';\n templateElement = $compile(template)(templateScope);\n\n angular.element(templateElement.children()[0])\n .css('position','absolute')\n .css('top',0)\n .css('left',0)\n .css('right',0)\n .css('bottom',0);\n element.append(templateElement);\n\n }).error(function(data){\n throw new Error('Template specified for cgBusy ('+options.templateUrl+') could not be loaded. ' + data);\n });\n }\n\n },true);\n }\n };\n }\n]);\n\n\nangular.module('cgBusy').run(['$templateCache', function($templateCache) {\n 'use strict';\n\n $templateCache.put('angular-busy.html',\n \"
\\n\" +\n \"\\n\" +\n \"
\\n\" +\n \"\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"
\\n\" +\n \"\\n\" +\n \"
{{$message}}
\\n\" +\n \"\\n\" +\n \"
\\n\" +\n \"\\n\" +\n \"
\"\n );\n\n}]);\n\n/*! \n * angular-loading-bar v0.6.0\n * https://chieffancypants.github.io/angular-loading-bar\n * Copyright (c) 2014 Wes Cruver\n * License: MIT\n */\n/*\n * angular-loading-bar\n *\n * intercepts XHR requests and creates a loading bar.\n * Based on the excellent nprogress work by rstacruz (more info in readme)\n *\n * (c) 2013 Wes Cruver\n * License: MIT\n */\n\n\n(function() {\n\n'use strict';\n\n// Alias the loading bar for various backwards compatibilities since the project has matured:\nangular.module('angular-loading-bar', ['cfp.loadingBarInterceptor']);\nangular.module('chieffancypants.loadingBar', ['cfp.loadingBarInterceptor']);\n\n\n/**\n * loadingBarInterceptor service\n *\n * Registers itself as an Angular interceptor and listens for XHR requests.\n */\nangular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])\n .config(['$httpProvider', function ($httpProvider) {\n\n var interceptor = ['$q', '$cacheFactory', '$timeout', '$rootScope', 'cfpLoadingBar', function ($q, $cacheFactory, $timeout, $rootScope, cfpLoadingBar) {\n\n /**\n * The total number of requests made\n */\n var reqsTotal = 0;\n\n /**\n * The number of requests completed (either successfully or not)\n */\n var reqsCompleted = 0;\n\n /**\n * The amount of time spent fetching before showing the loading bar\n */\n var latencyThreshold = cfpLoadingBar.latencyThreshold;\n\n /**\n * $timeout handle for latencyThreshold\n */\n var startTimeout;\n\n\n /**\n * calls cfpLoadingBar.complete() which removes the\n * loading bar from the DOM.\n */\n function setComplete() {\n $timeout.cancel(startTimeout);\n cfpLoadingBar.complete();\n reqsCompleted = 0;\n reqsTotal = 0;\n }\n\n /**\n * Determine if the response has already been cached\n * @param {Object} config the config option from the request\n * @return {Boolean} retrns true if cached, otherwise false\n */\n function isCached(config) {\n var cache;\n var defaultCache = $cacheFactory.get('$http');\n var defaults = $httpProvider.defaults;\n\n // Choose the proper cache source. Borrowed from angular: $http service\n if ((config.cache || defaults.cache) && config.cache !== false &&\n (config.method === 'GET' || config.method === 'JSONP')) {\n cache = angular.isObject(config.cache) ? config.cache\n : angular.isObject(defaults.cache) ? defaults.cache\n : defaultCache;\n }\n\n var cached = cache !== undefined ?\n cache.get(config.url) !== undefined : false;\n\n if (config.cached !== undefined && cached !== config.cached) {\n return config.cached;\n }\n config.cached = cached;\n return cached;\n }\n\n\n return {\n 'request': function(config) {\n // Check to make sure this request hasn't already been cached and that\n // the requester didn't explicitly ask us to ignore this request:\n if (!config.ignoreLoadingBar && !isCached(config)) {\n $rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});\n if (reqsTotal === 0) {\n startTimeout = $timeout(function() {\n cfpLoadingBar.start();\n }, latencyThreshold);\n }\n reqsTotal++;\n cfpLoadingBar.set(reqsCompleted / reqsTotal);\n }\n return config;\n },\n\n 'response': function(response) {\n if (!response.config.ignoreLoadingBar && !isCached(response.config)) {\n reqsCompleted++;\n $rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url});\n if (reqsCompleted >= reqsTotal) {\n setComplete();\n } else {\n cfpLoadingBar.set(reqsCompleted / reqsTotal);\n }\n }\n return response;\n },\n\n 'responseError': function(rejection) {\n if (!rejection.config.ignoreLoadingBar && !isCached(rejection.config)) {\n reqsCompleted++;\n $rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url});\n if (reqsCompleted >= reqsTotal) {\n setComplete();\n } else {\n cfpLoadingBar.set(reqsCompleted / reqsTotal);\n }\n }\n return $q.reject(rejection);\n }\n };\n }];\n\n $httpProvider.interceptors.push(interceptor);\n }]);\n\n\n/**\n * Loading Bar\n *\n * This service handles adding and removing the actual element in the DOM.\n * Generally, best practices for DOM manipulation is to take place in a\n * directive, but because the element itself is injected in the DOM only upon\n * XHR requests, and it's likely needed on every view, the best option is to\n * use a service.\n */\nangular.module('cfp.loadingBar', [])\n .provider('cfpLoadingBar', function() {\n\n this.includeSpinner = true;\n this.includeBar = true;\n this.latencyThreshold = 100;\n this.startSize = 0.02;\n this.parentSelector = 'body';\n this.spinnerTemplate = '
';\n this.loadingBarTemplate = '
';\n\n this.$get = ['$injector', '$document', '$timeout', '$rootScope', function ($injector, $document, $timeout, $rootScope) {\n var $animate;\n var $parentSelector = this.parentSelector,\n loadingBarContainer = angular.element(this.loadingBarTemplate),\n loadingBar = loadingBarContainer.find('div').eq(0),\n spinner = angular.element(this.spinnerTemplate);\n\n var incTimeout,\n completeTimeout,\n started = false,\n status = 0;\n\n var includeSpinner = this.includeSpinner;\n var includeBar = this.includeBar;\n var startSize = this.startSize;\n\n /**\n * Inserts the loading bar element into the dom, and sets it to 2%\n */\n function _start() {\n if (!$animate) {\n $animate = $injector.get('$animate');\n }\n\n var $parent = $document.find($parentSelector).eq(0);\n $timeout.cancel(completeTimeout);\n\n // do not continually broadcast the started event:\n if (started) {\n return;\n }\n\n $rootScope.$broadcast('cfpLoadingBar:started');\n started = true;\n\n if (includeBar) {\n $animate.enter(loadingBarContainer, $parent);\n }\n\n if (includeSpinner) {\n $animate.enter(spinner, $parent);\n }\n\n _set(startSize);\n }\n\n /**\n * Set the loading bar's width to a certain percent.\n *\n * @param n any value between 0 and 1\n */\n function _set(n) {\n if (!started) {\n return;\n }\n var pct = (n * 100) + '%';\n loadingBar.css('width', pct);\n status = n;\n\n // increment loadingbar to give the illusion that there is always\n // progress but make sure to cancel the previous timeouts so we don't\n // have multiple incs running at the same time.\n $timeout.cancel(incTimeout);\n incTimeout = $timeout(function() {\n _inc();\n }, 250);\n }\n\n /**\n * Increments the loading bar by a random amount\n * but slows down as it progresses\n */\n function _inc() {\n if (_status() >= 1) {\n return;\n }\n\n var rnd = 0;\n\n // TODO: do this mathmatically instead of through conditions\n\n var stat = _status();\n if (stat >= 0 && stat < 0.25) {\n // Start out between 3 - 6% increments\n rnd = (Math.random() * (5 - 3 + 1) + 3) / 100;\n } else if (stat >= 0.25 && stat < 0.65) {\n // increment between 0 - 3%\n rnd = (Math.random() * 3) / 100;\n } else if (stat >= 0.65 && stat < 0.9) {\n // increment between 0 - 2%\n rnd = (Math.random() * 2) / 100;\n } else if (stat >= 0.9 && stat < 0.99) {\n // finally, increment it .5 %\n rnd = 0.005;\n } else {\n // after 99%, don't increment:\n rnd = 0;\n }\n\n var pct = _status() + rnd;\n _set(pct);\n }\n\n function _status() {\n return status;\n }\n\n function _completeAnimation() {\n status = 0;\n started = false;\n }\n\n function _complete() {\n if (!$animate) {\n $animate = $injector.get('$animate');\n }\n\n $rootScope.$broadcast('cfpLoadingBar:completed');\n _set(1);\n\n $timeout.cancel(completeTimeout);\n\n // Attempt to aggregate any start/complete calls within 500ms:\n completeTimeout = $timeout(function() {\n var promise = $animate.leave(loadingBarContainer, _completeAnimation);\n if (promise && promise.then) {\n promise.then(_completeAnimation);\n }\n $animate.leave(spinner);\n }, 500);\n }\n\n return {\n start : _start,\n set : _set,\n status : _status,\n inc : _inc,\n complete : _complete,\n includeSpinner : this.includeSpinner,\n latencyThreshold : this.latencyThreshold,\n parentSelector : this.parentSelector,\n startSize : this.startSize\n };\n\n\n }]; //\n }); // wtf javascript. srsly\n})(); //\n\n/**\n * An Angular module that gives you access to the browsers local storage\n * @version v0.1.5 - 2014-11-04\n * @link https://github.com/grevory/angular-local-storage\n * @author grevory
\n * @license MIT License, http://www.opensource.org/licenses/MIT\n */\n(function ( window, angular, undefined ) {\n/*jshint globalstrict:true*/\n'use strict';\n\nvar isDefined = angular.isDefined,\n isUndefined = angular.isUndefined,\n isNumber = angular.isNumber,\n isObject = angular.isObject,\n isArray = angular.isArray,\n extend = angular.extend,\n toJson = angular.toJson,\n fromJson = angular.fromJson;\n\n\n// Test if string is only contains numbers\n// e.g '1' => true, \"'1'\" => true\nfunction isStringNumber(num) {\n return /^-?\\d+\\.?\\d*$/.test(num.replace(/[\"']/g, ''));\n}\n\nvar angularLocalStorage = angular.module('LocalStorageModule', []);\n\nangularLocalStorage.provider('localStorageService', function() {\n\n // You should set a prefix to avoid overwriting any local storage variables from the rest of your app\n // e.g. localStorageServiceProvider.setPrefix('youAppName');\n // With provider you can use config as this:\n // myApp.config(function (localStorageServiceProvider) {\n // localStorageServiceProvider.prefix = 'yourAppName';\n // });\n this.prefix = 'ls';\n\n // You could change web storage type localstorage or sessionStorage\n this.storageType = 'localStorage';\n\n // Cookie options (usually in case of fallback)\n // expiry = Number of days before cookies expire // 0 = Does not expire\n // path = The web path the cookie represents\n this.cookie = {\n expiry: 30,\n path: '/'\n };\n\n // Send signals for each of the following actions?\n this.notify = {\n setItem: true,\n removeItem: false\n };\n\n // Setter for the prefix\n this.setPrefix = function(prefix) {\n this.prefix = prefix;\n return this;\n };\n\n // Setter for the storageType\n this.setStorageType = function(storageType) {\n this.storageType = storageType;\n return this;\n };\n\n // Setter for cookie config\n this.setStorageCookie = function(exp, path) {\n this.cookie = {\n expiry: exp,\n path: path\n };\n return this;\n };\n\n // Setter for cookie domain\n this.setStorageCookieDomain = function(domain) {\n this.cookie.domain = domain;\n return this;\n };\n\n // Setter for notification config\n // itemSet & itemRemove should be booleans\n this.setNotify = function(itemSet, itemRemove) {\n this.notify = {\n setItem: itemSet,\n removeItem: itemRemove\n };\n return this;\n };\n\n this.$get = ['$rootScope', '$window', '$document', '$parse', function($rootScope, $window, $document, $parse) {\n var self = this;\n var prefix = self.prefix;\n var cookie = self.cookie;\n var notify = self.notify;\n var storageType = self.storageType;\n var webStorage;\n\n // When Angular's $document is not available\n if (!$document) {\n $document = document;\n } else if ($document[0]) {\n $document = $document[0];\n }\n\n // If there is a prefix set in the config lets use that with an appended period for readability\n if (prefix.substr(-1) !== '.') {\n prefix = !!prefix ? prefix + '.' : '';\n }\n var deriveQualifiedKey = function(key) {\n return prefix + key;\n };\n // Checks the browser to see if local storage is supported\n var browserSupportsLocalStorage = (function () {\n try {\n var supported = (storageType in $window && $window[storageType] !== null);\n\n // When Safari (OS X or iOS) is in private browsing mode, it appears as though localStorage\n // is available, but trying to call .setItem throws an exception.\n //\n // \"QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to add something to storage\n // that exceeded the quota.\"\n var key = deriveQualifiedKey('__' + Math.round(Math.random() * 1e7));\n if (supported) {\n webStorage = $window[storageType];\n webStorage.setItem(key, '');\n webStorage.removeItem(key);\n }\n\n return supported;\n } catch (e) {\n storageType = 'cookie';\n $rootScope.$broadcast('LocalStorageModule.notification.error', e.message);\n return false;\n }\n }());\n\n\n\n // Directly adds a value to local storage\n // If local storage is not available in the browser use cookies\n // Example use: localStorageService.add('library','angular');\n var addToLocalStorage = function (key, value) {\n // Let's convert undefined values to null to get the value consistent\n if (isUndefined(value)) {\n value = null;\n } else if (isObject(value) || isArray(value) || isNumber(+value || value)) {\n value = toJson(value);\n }\n\n // If this browser does not support local storage use cookies\n if (!browserSupportsLocalStorage || self.storageType === 'cookie') {\n if (!browserSupportsLocalStorage) {\n $rootScope.$broadcast('LocalStorageModule.notification.warning', 'LOCAL_STORAGE_NOT_SUPPORTED');\n }\n\n if (notify.setItem) {\n $rootScope.$broadcast('LocalStorageModule.notification.setitem', {key: key, newvalue: value, storageType: 'cookie'});\n }\n return addToCookies(key, value);\n }\n\n try {\n if (isObject(value) || isArray(value)) {\n value = toJson(value);\n }\n if (webStorage) {webStorage.setItem(deriveQualifiedKey(key), value)};\n if (notify.setItem) {\n $rootScope.$broadcast('LocalStorageModule.notification.setitem', {key: key, newvalue: value, storageType: self.storageType});\n }\n } catch (e) {\n $rootScope.$broadcast('LocalStorageModule.notification.error', e.message);\n return addToCookies(key, value);\n }\n return true;\n };\n\n // Directly get a value from local storage\n // Example use: localStorageService.get('library'); // returns 'angular'\n var getFromLocalStorage = function (key) {\n\n if (!browserSupportsLocalStorage || self.storageType === 'cookie') {\n if (!browserSupportsLocalStorage) {\n $rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');\n }\n\n return getFromCookies(key);\n }\n\n var item = webStorage ? webStorage.getItem(deriveQualifiedKey(key)) : null;\n // angular.toJson will convert null to 'null', so a proper conversion is needed\n // FIXME not a perfect solution, since a valid 'null' string can't be stored\n if (!item || item === 'null') {\n return null;\n }\n\n if (item.charAt(0) === \"{\" || item.charAt(0) === \"[\" || isStringNumber(item)) {\n return fromJson(item);\n }\n\n return item;\n };\n\n // Remove an item from local storage\n // Example use: localStorageService.remove('library'); // removes the key/value pair of library='angular'\n var removeFromLocalStorage = function (key) {\n if (!browserSupportsLocalStorage || self.storageType === 'cookie') {\n if (!browserSupportsLocalStorage) {\n $rootScope.$broadcast('LocalStorageModule.notification.warning', 'LOCAL_STORAGE_NOT_SUPPORTED');\n }\n\n if (notify.removeItem) {\n $rootScope.$broadcast('LocalStorageModule.notification.removeitem', {key: key, storageType: 'cookie'});\n }\n return removeFromCookies(key);\n }\n\n try {\n webStorage.removeItem(deriveQualifiedKey(key));\n if (notify.removeItem) {\n $rootScope.$broadcast('LocalStorageModule.notification.removeitem', {key: key, storageType: self.storageType});\n }\n } catch (e) {\n $rootScope.$broadcast('LocalStorageModule.notification.error', e.message);\n return removeFromCookies(key);\n }\n return true;\n };\n\n // Return array of keys for local storage\n // Example use: var keys = localStorageService.keys()\n var getKeysForLocalStorage = function () {\n\n if (!browserSupportsLocalStorage) {\n $rootScope.$broadcast('LocalStorageModule.notification.warning', 'LOCAL_STORAGE_NOT_SUPPORTED');\n return false;\n }\n\n var prefixLength = prefix.length;\n var keys = [];\n for (var key in webStorage) {\n // Only return keys that are for this app\n if (key.substr(0,prefixLength) === prefix) {\n try {\n keys.push(key.substr(prefixLength));\n } catch (e) {\n $rootScope.$broadcast('LocalStorageModule.notification.error', e.Description);\n return [];\n }\n }\n }\n return keys;\n };\n\n // Remove all data for this app from local storage\n // Also optionally takes a regular expression string and removes the matching key-value pairs\n // Example use: localStorageService.clearAll();\n // Should be used mostly for development purposes\n var clearAllFromLocalStorage = function (regularExpression) {\n\n regularExpression = regularExpression || \"\";\n //accounting for the '.' in the prefix when creating a regex\n var tempPrefix = prefix.slice(0, -1);\n var testRegex = new RegExp(tempPrefix + '.' + regularExpression);\n\n if (!browserSupportsLocalStorage || self.storageType === 'cookie') {\n if (!browserSupportsLocalStorage) {\n $rootScope.$broadcast('LocalStorageModule.notification.warning', 'LOCAL_STORAGE_NOT_SUPPORTED');\n }\n\n return clearAllFromCookies();\n }\n\n var prefixLength = prefix.length;\n\n for (var key in webStorage) {\n // Only remove items that are for this app and match the regular expression\n if (testRegex.test(key)) {\n try {\n removeFromLocalStorage(key.substr(prefixLength));\n } catch (e) {\n $rootScope.$broadcast('LocalStorageModule.notification.error',e.message);\n return clearAllFromCookies();\n }\n }\n }\n return true;\n };\n\n // Checks the browser to see if cookies are supported\n var browserSupportsCookies = (function() {\n try {\n return $window.navigator.cookieEnabled ||\n (\"cookie\" in $document && ($document.cookie.length > 0 ||\n ($document.cookie = \"test\").indexOf.call($document.cookie, \"test\") > -1));\n } catch (e) {\n $rootScope.$broadcast('LocalStorageModule.notification.error', e.message);\n return false;\n }\n }());\n\n // Directly adds a value to cookies\n // Typically used as a fallback is local storage is not available in the browser\n // Example use: localStorageService.cookie.add('library','angular');\n var addToCookies = function (key, value) {\n\n if (isUndefined(value)) {\n return false;\n } else if(isArray(value) || isObject(value)) {\n value = toJson(value);\n }\n\n if (!browserSupportsCookies) {\n $rootScope.$broadcast('LocalStorageModule.notification.error', 'COOKIES_NOT_SUPPORTED');\n return false;\n }\n\n try {\n var expiry = '',\n expiryDate = new Date(),\n cookieDomain = '';\n\n if (value === null) {\n // Mark that the cookie has expired one day ago\n expiryDate.setTime(expiryDate.getTime() + (-1 * 24 * 60 * 60 * 1000));\n expiry = \"; expires=\" + expiryDate.toGMTString();\n value = '';\n } else if (cookie.expiry !== 0) {\n expiryDate.setTime(expiryDate.getTime() + (cookie.expiry * 24 * 60 * 60 * 1000));\n expiry = \"; expires=\" + expiryDate.toGMTString();\n }\n if (!!key) {\n var cookiePath = \"; path=\" + cookie.path;\n if(cookie.domain){\n cookieDomain = \"; domain=\" + cookie.domain;\n }\n $document.cookie = deriveQualifiedKey(key) + \"=\" + encodeURIComponent(value) + expiry + cookiePath + cookieDomain;\n }\n } catch (e) {\n $rootScope.$broadcast('LocalStorageModule.notification.error',e.message);\n return false;\n }\n return true;\n };\n\n // Directly get a value from a cookie\n // Example use: localStorageService.cookie.get('library'); // returns 'angular'\n var getFromCookies = function (key) {\n if (!browserSupportsCookies) {\n $rootScope.$broadcast('LocalStorageModule.notification.error', 'COOKIES_NOT_SUPPORTED');\n return false;\n }\n\n var cookies = $document.cookie && $document.cookie.split(';') || [];\n for(var i=0; i < cookies.length; i++) {\n var thisCookie = cookies[i];\n while (thisCookie.charAt(0) === ' ') {\n thisCookie = thisCookie.substring(1,thisCookie.length);\n }\n if (thisCookie.indexOf(deriveQualifiedKey(key) + '=') === 0) {\n var storedValues = decodeURIComponent(thisCookie.substring(prefix.length + key.length + 1, thisCookie.length))\n try{\n var obj = JSON.parse(storedValues);\n return fromJson(obj)\n }catch(e){\n return storedValues\n }\n }\n }\n return null;\n };\n\n var removeFromCookies = function (key) {\n addToCookies(key,null);\n };\n\n var clearAllFromCookies = function () {\n var thisCookie = null, thisKey = null;\n var prefixLength = prefix.length;\n var cookies = $document.cookie.split(';');\n for(var i = 0; i < cookies.length; i++) {\n thisCookie = cookies[i];\n\n while (thisCookie.charAt(0) === ' ') {\n thisCookie = thisCookie.substring(1, thisCookie.length);\n }\n\n var key = thisCookie.substring(prefixLength, thisCookie.indexOf('='));\n removeFromCookies(key);\n }\n };\n\n var getStorageType = function() {\n return storageType;\n };\n\n // Add a listener on scope variable to save its changes to local storage\n // Return a function which when called cancels binding\n var bindToScope = function(scope, key, def, lsKey) {\n lsKey = lsKey || key;\n var value = getFromLocalStorage(lsKey);\n\n if (value === null && isDefined(def)) {\n value = def;\n } else if (isObject(value) && isObject(def)) {\n value = extend(def, value);\n }\n\n $parse(key).assign(scope, value);\n\n return scope.$watch(key, function(newVal) {\n addToLocalStorage(lsKey, newVal);\n }, isObject(scope[key]));\n };\n\n // Return localStorageService.length\n // ignore keys that not owned\n var lengthOfLocalStorage = function() {\n var count = 0;\n var storage = $window[storageType];\n for(var i = 0; i < storage.length; i++) {\n if(storage.key(i).indexOf(prefix) === 0 ) {\n count++;\n }\n }\n return count;\n };\n\n return {\n isSupported: browserSupportsLocalStorage,\n getStorageType: getStorageType,\n set: addToLocalStorage,\n add: addToLocalStorage, //DEPRECATED\n get: getFromLocalStorage,\n keys: getKeysForLocalStorage,\n remove: removeFromLocalStorage,\n clearAll: clearAllFromLocalStorage,\n bind: bindToScope,\n deriveKey: deriveQualifiedKey,\n length: lengthOfLocalStorage,\n cookie: {\n isSupported: browserSupportsCookies,\n set: addToCookies,\n add: addToCookies, //DEPRECATED\n get: getFromCookies,\n remove: removeFromCookies,\n clearAll: clearAllFromCookies\n }\n };\n }];\n});\n})( window, window.angular );\n/**\n * State-based routing for AngularJS\n * @version v0.2.15\n * @link http://angular-ui.github.com/\n * @license MIT License, http://www.opensource.org/licenses/MIT\n */\n\n/* commonjs package manager support (eg componentjs) */\nif (typeof module !== \"undefined\" && typeof exports !== \"undefined\" && module.exports === exports){\n module.exports = 'ui.router';\n}\n\n(function (window, angular, undefined) {\n/*jshint globalstrict:true*/\n/*global angular:false*/\n'use strict';\n\nvar isDefined = angular.isDefined,\n isFunction = angular.isFunction,\n isString = angular.isString,\n isObject = angular.isObject,\n isArray = angular.isArray,\n forEach = angular.forEach,\n extend = angular.extend,\n copy = angular.copy;\n\nfunction inherit(parent, extra) {\n return extend(new (extend(function() {}, { prototype: parent }))(), extra);\n}\n\nfunction merge(dst) {\n forEach(arguments, function(obj) {\n if (obj !== dst) {\n forEach(obj, function(value, key) {\n if (!dst.hasOwnProperty(key)) dst[key] = value;\n });\n }\n });\n return dst;\n}\n\n/**\n * Finds the common ancestor path between two states.\n *\n * @param {Object} first The first state.\n * @param {Object} second The second state.\n * @return {Array} Returns an array of state names in descending order, not including the root.\n */\nfunction ancestors(first, second) {\n var path = [];\n\n for (var n in first.path) {\n if (first.path[n] !== second.path[n]) break;\n path.push(first.path[n]);\n }\n return path;\n}\n\n/**\n * IE8-safe wrapper for `Object.keys()`.\n *\n * @param {Object} object A JavaScript object.\n * @return {Array} Returns the keys of the object as an array.\n */\nfunction objectKeys(object) {\n if (Object.keys) {\n return Object.keys(object);\n }\n var result = [];\n\n forEach(object, function(val, key) {\n result.push(key);\n });\n return result;\n}\n\n/**\n * IE8-safe wrapper for `Array.prototype.indexOf()`.\n *\n * @param {Array} array A JavaScript array.\n * @param {*} value A value to search the array for.\n * @return {Number} Returns the array index value of `value`, or `-1` if not present.\n */\nfunction indexOf(array, value) {\n if (Array.prototype.indexOf) {\n return array.indexOf(value, Number(arguments[2]) || 0);\n }\n var len = array.length >>> 0, from = Number(arguments[2]) || 0;\n from = (from < 0) ? Math.ceil(from) : Math.floor(from);\n\n if (from < 0) from += len;\n\n for (; from < len; from++) {\n if (from in array && array[from] === value) return from;\n }\n return -1;\n}\n\n/**\n * Merges a set of parameters with all parameters inherited between the common parents of the\n * current state and a given destination state.\n *\n * @param {Object} currentParams The value of the current state parameters ($stateParams).\n * @param {Object} newParams The set of parameters which will be composited with inherited params.\n * @param {Object} $current Internal definition of object representing the current state.\n * @param {Object} $to Internal definition of object representing state to transition to.\n */\nfunction inheritParams(currentParams, newParams, $current, $to) {\n var parents = ancestors($current, $to), parentParams, inherited = {}, inheritList = [];\n\n for (var i in parents) {\n if (!parents[i].params) continue;\n parentParams = objectKeys(parents[i].params);\n if (!parentParams.length) continue;\n\n for (var j in parentParams) {\n if (indexOf(inheritList, parentParams[j]) >= 0) continue;\n inheritList.push(parentParams[j]);\n inherited[parentParams[j]] = currentParams[parentParams[j]];\n }\n }\n return extend({}, inherited, newParams);\n}\n\n/**\n * Performs a non-strict comparison of the subset of two objects, defined by a list of keys.\n *\n * @param {Object} a The first object.\n * @param {Object} b The second object.\n * @param {Array} keys The list of keys within each object to compare. If the list is empty or not specified,\n * it defaults to the list of keys in `a`.\n * @return {Boolean} Returns `true` if the keys match, otherwise `false`.\n */\nfunction equalForKeys(a, b, keys) {\n if (!keys) {\n keys = [];\n for (var n in a) keys.push(n); // Used instead of Object.keys() for IE8 compatibility\n }\n\n for (var i=0; i\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n */\nangular.module('ui.router', ['ui.router.state']);\n\nangular.module('ui.router.compat', ['ui.router']);\n\n/**\n * @ngdoc object\n * @name ui.router.util.$resolve\n *\n * @requires $q\n * @requires $injector\n *\n * @description\n * Manages resolution of (acyclic) graphs of promises.\n */\n$Resolve.$inject = ['$q', '$injector'];\nfunction $Resolve( $q, $injector) {\n \n var VISIT_IN_PROGRESS = 1,\n VISIT_DONE = 2,\n NOTHING = {},\n NO_DEPENDENCIES = [],\n NO_LOCALS = NOTHING,\n NO_PARENT = extend($q.when(NOTHING), { $$promises: NOTHING, $$values: NOTHING });\n \n\n /**\n * @ngdoc function\n * @name ui.router.util.$resolve#study\n * @methodOf ui.router.util.$resolve\n *\n * @description\n * Studies a set of invocables that are likely to be used multiple times.\n * \n * $resolve.study(invocables)(locals, parent, self)\n *
\n * is equivalent to\n * \n * $resolve.resolve(invocables, locals, parent, self)\n *
\n * but the former is more efficient (in fact `resolve` just calls `study` \n * internally).\n *\n * @param {object} invocables Invocable objects\n * @return {function} a function to pass in locals, parent and self\n */\n this.study = function (invocables) {\n if (!isObject(invocables)) throw new Error(\"'invocables' must be an object\");\n var invocableKeys = objectKeys(invocables || {});\n \n // Perform a topological sort of invocables to build an ordered plan\n var plan = [], cycle = [], visited = {};\n function visit(value, key) {\n if (visited[key] === VISIT_DONE) return;\n \n cycle.push(key);\n if (visited[key] === VISIT_IN_PROGRESS) {\n cycle.splice(0, indexOf(cycle, key));\n throw new Error(\"Cyclic dependency: \" + cycle.join(\" -> \"));\n }\n visited[key] = VISIT_IN_PROGRESS;\n \n if (isString(value)) {\n plan.push(key, [ function() { return $injector.get(value); }], NO_DEPENDENCIES);\n } else {\n var params = $injector.annotate(value);\n forEach(params, function (param) {\n if (param !== key && invocables.hasOwnProperty(param)) visit(invocables[param], param);\n });\n plan.push(key, value, params);\n }\n \n cycle.pop();\n visited[key] = VISIT_DONE;\n }\n forEach(invocables, visit);\n invocables = cycle = visited = null; // plan is all that's required\n \n function isResolve(value) {\n return isObject(value) && value.then && value.$$promises;\n }\n \n return function (locals, parent, self) {\n if (isResolve(locals) && self === undefined) {\n self = parent; parent = locals; locals = null;\n }\n if (!locals) locals = NO_LOCALS;\n else if (!isObject(locals)) {\n throw new Error(\"'locals' must be an object\");\n } \n if (!parent) parent = NO_PARENT;\n else if (!isResolve(parent)) {\n throw new Error(\"'parent' must be a promise returned by $resolve.resolve()\");\n }\n \n // To complete the overall resolution, we have to wait for the parent\n // promise and for the promise for each invokable in our plan.\n var resolution = $q.defer(),\n result = resolution.promise,\n promises = result.$$promises = {},\n values = extend({}, locals),\n wait = 1 + plan.length/3,\n merged = false;\n \n function done() {\n // Merge parent values we haven't got yet and publish our own $$values\n if (!--wait) {\n if (!merged) merge(values, parent.$$values); \n result.$$values = values;\n result.$$promises = result.$$promises || true; // keep for isResolve()\n delete result.$$inheritedValues;\n resolution.resolve(values);\n }\n }\n \n function fail(reason) {\n result.$$failure = reason;\n resolution.reject(reason);\n }\n\n // Short-circuit if parent has already failed\n if (isDefined(parent.$$failure)) {\n fail(parent.$$failure);\n return result;\n }\n \n if (parent.$$inheritedValues) {\n merge(values, omit(parent.$$inheritedValues, invocableKeys));\n }\n\n // Merge parent values if the parent has already resolved, or merge\n // parent promises and wait if the parent resolve is still in progress.\n extend(promises, parent.$$promises);\n if (parent.$$values) {\n merged = merge(values, omit(parent.$$values, invocableKeys));\n result.$$inheritedValues = omit(parent.$$values, invocableKeys);\n done();\n } else {\n if (parent.$$inheritedValues) {\n result.$$inheritedValues = omit(parent.$$inheritedValues, invocableKeys);\n } \n parent.then(done, fail);\n }\n \n // Process each invocable in the plan, but ignore any where a local of the same name exists.\n for (var i=0, ii=plan.length; i} The template html as a string, or a promise \n * for that string.\n */\n this.fromUrl = function (url, params) {\n if (isFunction(url)) url = url(params);\n if (url == null) return null;\n else return $http\n .get(url, { cache: $templateCache, headers: { Accept: 'text/html' }})\n .then(function(response) { return response.data; });\n };\n\n /**\n * @ngdoc function\n * @name ui.router.util.$templateFactory#fromProvider\n * @methodOf ui.router.util.$templateFactory\n *\n * @description\n * Creates a template by invoking an injectable provider function.\n *\n * @param {Function} provider Function to invoke via `$injector.invoke`\n * @param {Object} params Parameters for the template.\n * @param {Object} locals Locals to pass to `invoke`. Defaults to \n * `{ params: params }`.\n * @return {string|Promise.} The template html as a string, or a promise \n * for that string.\n */\n this.fromProvider = function (provider, params, locals) {\n return $injector.invoke(provider, null, locals || { params: params });\n };\n}\n\nangular.module('ui.router.util').service('$templateFactory', $TemplateFactory);\n\nvar $$UMFP; // reference to $UrlMatcherFactoryProvider\n\n/**\n * @ngdoc object\n * @name ui.router.util.type:UrlMatcher\n *\n * @description\n * Matches URLs against patterns and extracts named parameters from the path or the search\n * part of the URL. A URL pattern consists of a path pattern, optionally followed by '?' and a list\n * of search parameters. Multiple search parameter names are separated by '&'. Search parameters\n * do not influence whether or not a URL is matched, but their values are passed through into\n * the matched parameters returned by {@link ui.router.util.type:UrlMatcher#methods_exec exec}.\n *\n * Path parameter placeholders can be specified using simple colon/catch-all syntax or curly brace\n * syntax, which optionally allows a regular expression for the parameter to be specified:\n *\n * * `':'` name - colon placeholder\n * * `'*'` name - catch-all placeholder\n * * `'{' name '}'` - curly placeholder\n * * `'{' name ':' regexp|type '}'` - curly placeholder with regexp or type name. Should the\n * regexp itself contain curly braces, they must be in matched pairs or escaped with a backslash.\n *\n * Parameter names may contain only word characters (latin letters, digits, and underscore) and\n * must be unique within the pattern (across both path and search parameters). For colon\n * placeholders or curly placeholders without an explicit regexp, a path parameter matches any\n * number of characters other than '/'. For catch-all placeholders the path parameter matches\n * any number of characters.\n *\n * Examples:\n *\n * * `'/hello/'` - Matches only if the path is exactly '/hello/'. There is no special treatment for\n * trailing slashes, and patterns have to match the entire path, not just a prefix.\n * * `'/user/:id'` - Matches '/user/bob' or '/user/1234!!!' or even '/user/' but not '/user' or\n * '/user/bob/details'. The second path segment will be captured as the parameter 'id'.\n * * `'/user/{id}'` - Same as the previous example, but using curly brace syntax.\n * * `'/user/{id:[^/]*}'` - Same as the previous example.\n * * `'/user/{id:[0-9a-fA-F]{1,8}}'` - Similar to the previous example, but only matches if the id\n * parameter consists of 1 to 8 hex digits.\n * * `'/files/{path:.*}'` - Matches any URL starting with '/files/' and captures the rest of the\n * path into the parameter 'path'.\n * * `'/files/*path'` - ditto.\n * * `'/calendar/{start:date}'` - Matches \"/calendar/2014-11-12\" (because the pattern defined\n * in the built-in `date` Type matches `2014-11-12`) and provides a Date object in $stateParams.start\n *\n * @param {string} pattern The pattern to compile into a matcher.\n * @param {Object} config A configuration object hash:\n * @param {Object=} parentMatcher Used to concatenate the pattern/config onto\n * an existing UrlMatcher\n *\n * * `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`.\n * * `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`.\n *\n * @property {string} prefix A static prefix of this pattern. The matcher guarantees that any\n * URL matching this matcher (i.e. any string for which {@link ui.router.util.type:UrlMatcher#methods_exec exec()} returns\n * non-null) will start with this prefix.\n *\n * @property {string} source The pattern that was passed into the constructor\n *\n * @property {string} sourcePath The path portion of the source property\n *\n * @property {string} sourceSearch The search portion of the source property\n *\n * @property {string} regex The constructed regex that will be used to match against the url when\n * it is time to determine which url will match.\n *\n * @returns {Object} New `UrlMatcher` object\n */\nfunction UrlMatcher(pattern, config, parentMatcher) {\n config = extend({ params: {} }, isObject(config) ? config : {});\n\n // Find all placeholders and create a compiled pattern, using either classic or curly syntax:\n // '*' name\n // ':' name\n // '{' name '}'\n // '{' name ':' regexp '}'\n // The regular expression is somewhat complicated due to the need to allow curly braces\n // inside the regular expression. The placeholder regexp breaks down as follows:\n // ([:*])([\\w\\[\\]]+) - classic placeholder ($1 / $2) (search version has - for snake-case)\n // \\{([\\w\\[\\]]+)(?:\\:( ... ))?\\} - curly brace placeholder ($3) with optional regexp/type ... ($4) (search version has - for snake-case\n // (?: ... | ... | ... )+ - the regexp consists of any number of atoms, an atom being either\n // [^{}\\\\]+ - anything other than curly braces or backslash\n // \\\\. - a backslash escape\n // \\{(?:[^{}\\\\]+|\\\\.)*\\} - a matched set of curly braces containing other atoms\n var placeholder = /([:*])([\\w\\[\\]]+)|\\{([\\w\\[\\]]+)(?:\\:((?:[^{}\\\\]+|\\\\.|\\{(?:[^{}\\\\]+|\\\\.)*\\})+))?\\}/g,\n searchPlaceholder = /([:]?)([\\w\\[\\]-]+)|\\{([\\w\\[\\]-]+)(?:\\:((?:[^{}\\\\]+|\\\\.|\\{(?:[^{}\\\\]+|\\\\.)*\\})+))?\\}/g,\n compiled = '^', last = 0, m,\n segments = this.segments = [],\n parentParams = parentMatcher ? parentMatcher.params : {},\n params = this.params = parentMatcher ? parentMatcher.params.$$new() : new $$UMFP.ParamSet(),\n paramNames = [];\n\n function addParameter(id, type, config, location) {\n paramNames.push(id);\n if (parentParams[id]) return parentParams[id];\n if (!/^\\w+(-+\\w+)*(?:\\[\\])?$/.test(id)) throw new Error(\"Invalid parameter name '\" + id + \"' in pattern '\" + pattern + \"'\");\n if (params[id]) throw new Error(\"Duplicate parameter name '\" + id + \"' in pattern '\" + pattern + \"'\");\n params[id] = new $$UMFP.Param(id, type, config, location);\n return params[id];\n }\n\n function quoteRegExp(string, pattern, squash, optional) {\n var surroundPattern = ['',''], result = string.replace(/[\\\\\\[\\]\\^$*+?.()|{}]/g, \"\\\\$&\");\n if (!pattern) return result;\n switch(squash) {\n case false: surroundPattern = ['(', ')' + (optional ? \"?\" : \"\")]; break;\n case true: surroundPattern = ['?(', ')?']; break;\n default: surroundPattern = ['(' + squash + \"|\", ')?']; break;\n }\n return result + surroundPattern[0] + pattern + surroundPattern[1];\n }\n\n this.source = pattern;\n\n // Split into static segments separated by path parameter placeholders.\n // The number of segments is always 1 more than the number of parameters.\n function matchDetails(m, isSearch) {\n var id, regexp, segment, type, cfg, arrayMode;\n id = m[2] || m[3]; // IE[78] returns '' for unmatched groups instead of null\n cfg = config.params[id];\n segment = pattern.substring(last, m.index);\n regexp = isSearch ? m[4] : m[4] || (m[1] == '*' ? '.*' : null);\n type = $$UMFP.type(regexp || \"string\") || inherit($$UMFP.type(\"string\"), { pattern: new RegExp(regexp, config.caseInsensitive ? 'i' : undefined) });\n return {\n id: id, regexp: regexp, segment: segment, type: type, cfg: cfg\n };\n }\n\n var p, param, segment;\n while ((m = placeholder.exec(pattern))) {\n p = matchDetails(m, false);\n if (p.segment.indexOf('?') >= 0) break; // we're into the search part\n\n param = addParameter(p.id, p.type, p.cfg, \"path\");\n compiled += quoteRegExp(p.segment, param.type.pattern.source, param.squash, param.isOptional);\n segments.push(p.segment);\n last = placeholder.lastIndex;\n }\n segment = pattern.substring(last);\n\n // Find any search parameter names and remove them from the last segment\n var i = segment.indexOf('?');\n\n if (i >= 0) {\n var search = this.sourceSearch = segment.substring(i);\n segment = segment.substring(0, i);\n this.sourcePath = pattern.substring(0, last + i);\n\n if (search.length > 0) {\n last = 0;\n while ((m = searchPlaceholder.exec(search))) {\n p = matchDetails(m, true);\n param = addParameter(p.id, p.type, p.cfg, \"search\");\n last = placeholder.lastIndex;\n // check if ?&\n }\n }\n } else {\n this.sourcePath = pattern;\n this.sourceSearch = '';\n }\n\n compiled += quoteRegExp(segment) + (config.strict === false ? '\\/?' : '') + '$';\n segments.push(segment);\n\n this.regexp = new RegExp(compiled, config.caseInsensitive ? 'i' : undefined);\n this.prefix = segments[0];\n this.$$paramNames = paramNames;\n}\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:UrlMatcher#concat\n * @methodOf ui.router.util.type:UrlMatcher\n *\n * @description\n * Returns a new matcher for a pattern constructed by appending the path part and adding the\n * search parameters of the specified pattern to this pattern. The current pattern is not\n * modified. This can be understood as creating a pattern for URLs that are relative to (or\n * suffixes of) the current pattern.\n *\n * @example\n * The following two matchers are equivalent:\n * \n * new UrlMatcher('/user/{id}?q').concat('/details?date');\n * new UrlMatcher('/user/{id}/details?q&date');\n *
\n *\n * @param {string} pattern The pattern to append.\n * @param {Object} config An object hash of the configuration for the matcher.\n * @returns {UrlMatcher} A matcher for the concatenated pattern.\n */\nUrlMatcher.prototype.concat = function (pattern, config) {\n // Because order of search parameters is irrelevant, we can add our own search\n // parameters to the end of the new pattern. Parse the new pattern by itself\n // and then join the bits together, but it's much easier to do this on a string level.\n var defaultConfig = {\n caseInsensitive: $$UMFP.caseInsensitive(),\n strict: $$UMFP.strictMode(),\n squash: $$UMFP.defaultSquashPolicy()\n };\n return new UrlMatcher(this.sourcePath + pattern + this.sourceSearch, extend(defaultConfig, config), this);\n};\n\nUrlMatcher.prototype.toString = function () {\n return this.source;\n};\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:UrlMatcher#exec\n * @methodOf ui.router.util.type:UrlMatcher\n *\n * @description\n * Tests the specified path against this matcher, and returns an object containing the captured\n * parameter values, or null if the path does not match. The returned object contains the values\n * of any search parameters that are mentioned in the pattern, but their value may be null if\n * they are not present in `searchParams`. This means that search parameters are always treated\n * as optional.\n *\n * @example\n * \n * new UrlMatcher('/user/{id}?q&r').exec('/user/bob', {\n * x: '1', q: 'hello'\n * });\n * // returns { id: 'bob', q: 'hello', r: null }\n *
\n *\n * @param {string} path The URL path to match, e.g. `$location.path()`.\n * @param {Object} searchParams URL search parameters, e.g. `$location.search()`.\n * @returns {Object} The captured parameter values.\n */\nUrlMatcher.prototype.exec = function (path, searchParams) {\n var m = this.regexp.exec(path);\n if (!m) return null;\n searchParams = searchParams || {};\n\n var paramNames = this.parameters(), nTotal = paramNames.length,\n nPath = this.segments.length - 1,\n values = {}, i, j, cfg, paramName;\n\n if (nPath !== m.length - 1) throw new Error(\"Unbalanced capture group in route '\" + this.source + \"'\");\n\n function decodePathArray(string) {\n function reverseString(str) { return str.split(\"\").reverse().join(\"\"); }\n function unquoteDashes(str) { return str.replace(/\\\\-/g, \"-\"); }\n\n var split = reverseString(string).split(/-(?!\\\\)/);\n var allReversed = map(split, reverseString);\n return map(allReversed, unquoteDashes).reverse();\n }\n\n for (i = 0; i < nPath; i++) {\n paramName = paramNames[i];\n var param = this.params[paramName];\n var paramVal = m[i+1];\n // if the param value matches a pre-replace pair, replace the value before decoding.\n for (j = 0; j < param.replace; j++) {\n if (param.replace[j].from === paramVal) paramVal = param.replace[j].to;\n }\n if (paramVal && param.array === true) paramVal = decodePathArray(paramVal);\n values[paramName] = param.value(paramVal);\n }\n for (/**/; i < nTotal; i++) {\n paramName = paramNames[i];\n values[paramName] = this.params[paramName].value(searchParams[paramName]);\n }\n\n return values;\n};\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:UrlMatcher#parameters\n * @methodOf ui.router.util.type:UrlMatcher\n *\n * @description\n * Returns the names of all path and search parameters of this pattern in an unspecified order.\n *\n * @returns {Array.} An array of parameter names. Must be treated as read-only. If the\n * pattern has no parameters, an empty array is returned.\n */\nUrlMatcher.prototype.parameters = function (param) {\n if (!isDefined(param)) return this.$$paramNames;\n return this.params[param] || null;\n};\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:UrlMatcher#validate\n * @methodOf ui.router.util.type:UrlMatcher\n *\n * @description\n * Checks an object hash of parameters to validate their correctness according to the parameter\n * types of this `UrlMatcher`.\n *\n * @param {Object} params The object hash of parameters to validate.\n * @returns {boolean} Returns `true` if `params` validates, otherwise `false`.\n */\nUrlMatcher.prototype.validates = function (params) {\n return this.params.$$validates(params);\n};\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:UrlMatcher#format\n * @methodOf ui.router.util.type:UrlMatcher\n *\n * @description\n * Creates a URL that matches this pattern by substituting the specified values\n * for the path and search parameters. Null values for path parameters are\n * treated as empty strings.\n *\n * @example\n * \n * new UrlMatcher('/user/{id}?q').format({ id:'bob', q:'yes' });\n * // returns '/user/bob?q=yes'\n *
\n *\n * @param {Object} values the values to substitute for the parameters in this pattern.\n * @returns {string} the formatted URL (path and optionally search part).\n */\nUrlMatcher.prototype.format = function (values) {\n values = values || {};\n var segments = this.segments, params = this.parameters(), paramset = this.params;\n if (!this.validates(values)) return null;\n\n var i, search = false, nPath = segments.length - 1, nTotal = params.length, result = segments[0];\n\n function encodeDashes(str) { // Replace dashes with encoded \"\\-\"\n return encodeURIComponent(str).replace(/-/g, function(c) { return '%5C%' + c.charCodeAt(0).toString(16).toUpperCase(); });\n }\n\n for (i = 0; i < nTotal; i++) {\n var isPathParam = i < nPath;\n var name = params[i], param = paramset[name], value = param.value(values[name]);\n var isDefaultValue = param.isOptional && param.type.equals(param.value(), value);\n var squash = isDefaultValue ? param.squash : false;\n var encoded = param.type.encode(value);\n\n if (isPathParam) {\n var nextSegment = segments[i + 1];\n if (squash === false) {\n if (encoded != null) {\n if (isArray(encoded)) {\n result += map(encoded, encodeDashes).join(\"-\");\n } else {\n result += encodeURIComponent(encoded);\n }\n }\n result += nextSegment;\n } else if (squash === true) {\n var capture = result.match(/\\/$/) ? /\\/?(.*)/ : /(.*)/;\n result += nextSegment.match(capture)[1];\n } else if (isString(squash)) {\n result += squash + nextSegment;\n }\n } else {\n if (encoded == null || (isDefaultValue && squash !== false)) continue;\n if (!isArray(encoded)) encoded = [ encoded ];\n encoded = map(encoded, encodeURIComponent).join('&' + name + '=');\n result += (search ? '&' : '?') + (name + '=' + encoded);\n search = true;\n }\n }\n\n return result;\n};\n\n/**\n * @ngdoc object\n * @name ui.router.util.type:Type\n *\n * @description\n * Implements an interface to define custom parameter types that can be decoded from and encoded to\n * string parameters matched in a URL. Used by {@link ui.router.util.type:UrlMatcher `UrlMatcher`}\n * objects when matching or formatting URLs, or comparing or validating parameter values.\n *\n * See {@link ui.router.util.$urlMatcherFactory#methods_type `$urlMatcherFactory#type()`} for more\n * information on registering custom types.\n *\n * @param {Object} config A configuration object which contains the custom type definition. The object's\n * properties will override the default methods and/or pattern in `Type`'s public interface.\n * @example\n * \n * {\n * decode: function(val) { return parseInt(val, 10); },\n * encode: function(val) { return val && val.toString(); },\n * equals: function(a, b) { return this.is(a) && a === b; },\n * is: function(val) { return angular.isNumber(val) isFinite(val) && val % 1 === 0; },\n * pattern: /\\d+/\n * }\n *
\n *\n * @property {RegExp} pattern The regular expression pattern used to match values of this type when\n * coming from a substring of a URL.\n *\n * @returns {Object} Returns a new `Type` object.\n */\nfunction Type(config) {\n extend(this, config);\n}\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:Type#is\n * @methodOf ui.router.util.type:Type\n *\n * @description\n * Detects whether a value is of a particular type. Accepts a native (decoded) value\n * and determines whether it matches the current `Type` object.\n *\n * @param {*} val The value to check.\n * @param {string} key Optional. If the type check is happening in the context of a specific\n * {@link ui.router.util.type:UrlMatcher `UrlMatcher`} object, this is the name of the\n * parameter in which `val` is stored. Can be used for meta-programming of `Type` objects.\n * @returns {Boolean} Returns `true` if the value matches the type, otherwise `false`.\n */\nType.prototype.is = function(val, key) {\n return true;\n};\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:Type#encode\n * @methodOf ui.router.util.type:Type\n *\n * @description\n * Encodes a custom/native type value to a string that can be embedded in a URL. Note that the\n * return value does *not* need to be URL-safe (i.e. passed through `encodeURIComponent()`), it\n * only needs to be a representation of `val` that has been coerced to a string.\n *\n * @param {*} val The value to encode.\n * @param {string} key The name of the parameter in which `val` is stored. Can be used for\n * meta-programming of `Type` objects.\n * @returns {string} Returns a string representation of `val` that can be encoded in a URL.\n */\nType.prototype.encode = function(val, key) {\n return val;\n};\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:Type#decode\n * @methodOf ui.router.util.type:Type\n *\n * @description\n * Converts a parameter value (from URL string or transition param) to a custom/native value.\n *\n * @param {string} val The URL parameter value to decode.\n * @param {string} key The name of the parameter in which `val` is stored. Can be used for\n * meta-programming of `Type` objects.\n * @returns {*} Returns a custom representation of the URL parameter value.\n */\nType.prototype.decode = function(val, key) {\n return val;\n};\n\n/**\n * @ngdoc function\n * @name ui.router.util.type:Type#equals\n * @methodOf ui.router.util.type:Type\n *\n * @description\n * Determines whether two decoded values are equivalent.\n *\n * @param {*} a A value to compare against.\n * @param {*} b A value to compare against.\n * @returns {Boolean} Returns `true` if the values are equivalent/equal, otherwise `false`.\n */\nType.prototype.equals = function(a, b) {\n return a == b;\n};\n\nType.prototype.$subPattern = function() {\n var sub = this.pattern.toString();\n return sub.substr(1, sub.length - 2);\n};\n\nType.prototype.pattern = /.*/;\n\nType.prototype.toString = function() { return \"{Type:\" + this.name + \"}\"; };\n\n/** Given an encoded string, or a decoded object, returns a decoded object */\nType.prototype.$normalize = function(val) {\n return this.is(val) ? val : this.decode(val);\n};\n\n/*\n * Wraps an existing custom Type as an array of Type, depending on 'mode'.\n * e.g.:\n * - urlmatcher pattern \"/path?{queryParam[]:int}\"\n * - url: \"/path?queryParam=1&queryParam=2\n * - $stateParams.queryParam will be [1, 2]\n * if `mode` is \"auto\", then\n * - url: \"/path?queryParam=1 will create $stateParams.queryParam: 1\n * - url: \"/path?queryParam=1&queryParam=2 will create $stateParams.queryParam: [1, 2]\n */\nType.prototype.$asArray = function(mode, isSearch) {\n if (!mode) return this;\n if (mode === \"auto\" && !isSearch) throw new Error(\"'auto' array mode is for query parameters only\");\n\n function ArrayType(type, mode) {\n function bindTo(type, callbackName) {\n return function() {\n return type[callbackName].apply(type, arguments);\n };\n }\n\n // Wrap non-array value as array\n function arrayWrap(val) { return isArray(val) ? val : (isDefined(val) ? [ val ] : []); }\n // Unwrap array value for \"auto\" mode. Return undefined for empty array.\n function arrayUnwrap(val) {\n switch(val.length) {\n case 0: return undefined;\n case 1: return mode === \"auto\" ? val[0] : val;\n default: return val;\n }\n }\n function falsey(val) { return !val; }\n\n // Wraps type (.is/.encode/.decode) functions to operate on each value of an array\n function arrayHandler(callback, allTruthyMode) {\n return function handleArray(val) {\n val = arrayWrap(val);\n var result = map(val, callback);\n if (allTruthyMode === true)\n return filter(result, falsey).length === 0;\n return arrayUnwrap(result);\n };\n }\n\n // Wraps type (.equals) functions to operate on each value of an array\n function arrayEqualsHandler(callback) {\n return function handleArray(val1, val2) {\n var left = arrayWrap(val1), right = arrayWrap(val2);\n if (left.length !== right.length) return false;\n for (var i = 0; i < left.length; i++) {\n if (!callback(left[i], right[i])) return false;\n }\n return true;\n };\n }\n\n this.encode = arrayHandler(bindTo(type, 'encode'));\n this.decode = arrayHandler(bindTo(type, 'decode'));\n this.is = arrayHandler(bindTo(type, 'is'), true);\n this.equals = arrayEqualsHandler(bindTo(type, 'equals'));\n this.pattern = type.pattern;\n this.$normalize = arrayHandler(bindTo(type, '$normalize'));\n this.name = type.name;\n this.$arrayMode = mode;\n }\n\n return new ArrayType(this, mode);\n};\n\n\n\n/**\n * @ngdoc object\n * @name ui.router.util.$urlMatcherFactory\n *\n * @description\n * Factory for {@link ui.router.util.type:UrlMatcher `UrlMatcher`} instances. The factory\n * is also available to providers under the name `$urlMatcherFactoryProvider`.\n */\nfunction $UrlMatcherFactory() {\n $$UMFP = this;\n\n var isCaseInsensitive = false, isStrictMode = true, defaultSquashPolicy = false;\n\n function valToString(val) { return val != null ? val.toString().replace(/\\//g, \"%2F\") : val; }\n function valFromString(val) { return val != null ? val.toString().replace(/%2F/g, \"/\") : val; }\n\n var $types = {}, enqueue = true, typeQueue = [], injector, defaultTypes = {\n string: {\n encode: valToString,\n decode: valFromString,\n // TODO: in 1.0, make string .is() return false if value is undefined/null by default.\n // In 0.2.x, string params are optional by default for backwards compat\n is: function(val) { return val == null || !isDefined(val) || typeof val === \"string\"; },\n pattern: /[^/]*/\n },\n int: {\n encode: valToString,\n decode: function(val) { return parseInt(val, 10); },\n is: function(val) { return isDefined(val) && this.decode(val.toString()) === val; },\n pattern: /\\d+/\n },\n bool: {\n encode: function(val) { return val ? 1 : 0; },\n decode: function(val) { return parseInt(val, 10) !== 0; },\n is: function(val) { return val === true || val === false; },\n pattern: /0|1/\n },\n date: {\n encode: function (val) {\n if (!this.is(val))\n return undefined;\n return [ val.getFullYear(),\n ('0' + (val.getMonth() + 1)).slice(-2),\n ('0' + val.getDate()).slice(-2)\n ].join(\"-\");\n },\n decode: function (val) {\n if (this.is(val)) return val;\n var match = this.capture.exec(val);\n return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;\n },\n is: function(val) { return val instanceof Date && !isNaN(val.valueOf()); },\n equals: function (a, b) { return this.is(a) && this.is(b) && a.toISOString() === b.toISOString(); },\n pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,\n capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/\n },\n json: {\n encode: angular.toJson,\n decode: angular.fromJson,\n is: angular.isObject,\n equals: angular.equals,\n pattern: /[^/]*/\n },\n any: { // does not encode/decode\n encode: angular.identity,\n decode: angular.identity,\n equals: angular.equals,\n pattern: /.*/\n }\n };\n\n function getDefaultConfig() {\n return {\n strict: isStrictMode,\n caseInsensitive: isCaseInsensitive\n };\n }\n\n function isInjectable(value) {\n return (isFunction(value) || (isArray(value) && isFunction(value[value.length - 1])));\n }\n\n /**\n * [Internal] Get the default value of a parameter, which may be an injectable function.\n */\n $UrlMatcherFactory.$$getDefaultValue = function(config) {\n if (!isInjectable(config.value)) return config.value;\n if (!injector) throw new Error(\"Injectable functions cannot be called at configuration time\");\n return injector.invoke(config.value);\n };\n\n /**\n * @ngdoc function\n * @name ui.router.util.$urlMatcherFactory#caseInsensitive\n * @methodOf ui.router.util.$urlMatcherFactory\n *\n * @description\n * Defines whether URL matching should be case sensitive (the default behavior), or not.\n *\n * @param {boolean} value `false` to match URL in a case sensitive manner; otherwise `true`;\n * @returns {boolean} the current value of caseInsensitive\n */\n this.caseInsensitive = function(value) {\n if (isDefined(value))\n isCaseInsensitive = value;\n return isCaseInsensitive;\n };\n\n /**\n * @ngdoc function\n * @name ui.router.util.$urlMatcherFactory#strictMode\n * @methodOf ui.router.util.$urlMatcherFactory\n *\n * @description\n * Defines whether URLs should match trailing slashes, or not (the default behavior).\n *\n * @param {boolean=} value `false` to match trailing slashes in URLs, otherwise `true`.\n * @returns {boolean} the current value of strictMode\n */\n this.strictMode = function(value) {\n if (isDefined(value))\n isStrictMode = value;\n return isStrictMode;\n };\n\n /**\n * @ngdoc function\n * @name ui.router.util.$urlMatcherFactory#defaultSquashPolicy\n * @methodOf ui.router.util.$urlMatcherFactory\n *\n * @description\n * Sets the default behavior when generating or matching URLs with default parameter values.\n *\n * @param {string} value A string that defines the default parameter URL squashing behavior.\n * `nosquash`: When generating an href with a default parameter value, do not squash the parameter value from the URL\n * `slash`: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the\n * parameter is surrounded by slashes, squash (remove) one slash from the URL\n * any other string, e.g. \"~\": When generating an href with a default parameter value, squash (remove)\n * the parameter value from the URL and replace it with this string.\n */\n this.defaultSquashPolicy = function(value) {\n if (!isDefined(value)) return defaultSquashPolicy;\n if (value !== true && value !== false && !isString(value))\n throw new Error(\"Invalid squash policy: \" + value + \". Valid policies: false, true, arbitrary-string\");\n defaultSquashPolicy = value;\n return value;\n };\n\n /**\n * @ngdoc function\n * @name ui.router.util.$urlMatcherFactory#compile\n * @methodOf ui.router.util.$urlMatcherFactory\n *\n * @description\n * Creates a {@link ui.router.util.type:UrlMatcher `UrlMatcher`} for the specified pattern.\n *\n * @param {string} pattern The URL pattern.\n * @param {Object} config The config object hash.\n * @returns {UrlMatcher} The UrlMatcher.\n */\n this.compile = function (pattern, config) {\n return new UrlMatcher(pattern, extend(getDefaultConfig(), config));\n };\n\n /**\n * @ngdoc function\n * @name ui.router.util.$urlMatcherFactory#isMatcher\n * @methodOf ui.router.util.$urlMatcherFactory\n *\n * @description\n * Returns true if the specified object is a `UrlMatcher`, or false otherwise.\n *\n * @param {Object} object The object to perform the type check against.\n * @returns {Boolean} Returns `true` if the object matches the `UrlMatcher` interface, by\n * implementing all the same methods.\n */\n this.isMatcher = function (o) {\n if (!isObject(o)) return false;\n var result = true;\n\n forEach(UrlMatcher.prototype, function(val, name) {\n if (isFunction(val)) {\n result = result && (isDefined(o[name]) && isFunction(o[name]));\n }\n });\n return result;\n };\n\n /**\n * @ngdoc function\n * @name ui.router.util.$urlMatcherFactory#type\n * @methodOf ui.router.util.$urlMatcherFactory\n *\n * @description\n * Registers a custom {@link ui.router.util.type:Type `Type`} object that can be used to\n * generate URLs with typed parameters.\n *\n * @param {string} name The type name.\n * @param {Object|Function} definition The type definition. See\n * {@link ui.router.util.type:Type `Type`} for information on the values accepted.\n * @param {Object|Function} definitionFn (optional) A function that is injected before the app\n * runtime starts. The result of this function is merged into the existing `definition`.\n * See {@link ui.router.util.type:Type `Type`} for information on the values accepted.\n *\n * @returns {Object} Returns `$urlMatcherFactoryProvider`.\n *\n * @example\n * This is a simple example of a custom type that encodes and decodes items from an\n * array, using the array index as the URL-encoded value:\n *\n * \n * var list = ['John', 'Paul', 'George', 'Ringo'];\n *\n * $urlMatcherFactoryProvider.type('listItem', {\n * encode: function(item) {\n * // Represent the list item in the URL using its corresponding index\n * return list.indexOf(item);\n * },\n * decode: function(item) {\n * // Look up the list item by index\n * return list[parseInt(item, 10)];\n * },\n * is: function(item) {\n * // Ensure the item is valid by checking to see that it appears\n * // in the list\n * return list.indexOf(item) > -1;\n * }\n * });\n *\n * $stateProvider.state('list', {\n * url: \"/list/{item:listItem}\",\n * controller: function($scope, $stateParams) {\n * console.log($stateParams.item);\n * }\n * });\n *\n * // ...\n *\n * // Changes URL to '/list/3', logs \"Ringo\" to the console\n * $state.go('list', { item: \"Ringo\" });\n *
\n *\n * This is a more complex example of a type that relies on dependency injection to\n * interact with services, and uses the parameter name from the URL to infer how to\n * handle encoding and decoding parameter values:\n *\n * \n * // Defines a custom type that gets a value from a service,\n * // where each service gets different types of values from\n * // a backend API:\n * $urlMatcherFactoryProvider.type('dbObject', {}, function(Users, Posts) {\n *\n * // Matches up services to URL parameter names\n * var services = {\n * user: Users,\n * post: Posts\n * };\n *\n * return {\n * encode: function(object) {\n * // Represent the object in the URL using its unique ID\n * return object.id;\n * },\n * decode: function(value, key) {\n * // Look up the object by ID, using the parameter\n * // name (key) to call the correct service\n * return services[key].findById(value);\n * },\n * is: function(object, key) {\n * // Check that object is a valid dbObject\n * return angular.isObject(object) && object.id && services[key];\n * }\n * equals: function(a, b) {\n * // Check the equality of decoded objects by comparing\n * // their unique IDs\n * return a.id === b.id;\n * }\n * };\n * });\n *\n * // In a config() block, you can then attach URLs with\n * // type-annotated parameters:\n * $stateProvider.state('users', {\n * url: \"/users\",\n * // ...\n * }).state('users.item', {\n * url: \"/{user:dbObject}\",\n * controller: function($scope, $stateParams) {\n * // $stateParams.user will now be an object returned from\n * // the Users service\n * },\n * // ...\n * });\n *
\n */\n this.type = function (name, definition, definitionFn) {\n if (!isDefined(definition)) return $types[name];\n if ($types.hasOwnProperty(name)) throw new Error(\"A type named '\" + name + \"' has already been defined.\");\n\n $types[name] = new Type(extend({ name: name }, definition));\n if (definitionFn) {\n typeQueue.push({ name: name, def: definitionFn });\n if (!enqueue) flushTypeQueue();\n }\n return this;\n };\n\n // `flushTypeQueue()` waits until `$urlMatcherFactory` is injected before invoking the queued `definitionFn`s\n function flushTypeQueue() {\n while(typeQueue.length) {\n var type = typeQueue.shift();\n if (type.pattern) throw new Error(\"You cannot override a type's .pattern at runtime.\");\n angular.extend($types[type.name], injector.invoke(type.def));\n }\n }\n\n // Register default types. Store them in the prototype of $types.\n forEach(defaultTypes, function(type, name) { $types[name] = new Type(extend({name: name}, type)); });\n $types = inherit($types, {});\n\n /* No need to document $get, since it returns this */\n this.$get = ['$injector', function ($injector) {\n injector = $injector;\n enqueue = false;\n flushTypeQueue();\n\n forEach(defaultTypes, function(type, name) {\n if (!$types[name]) $types[name] = new Type(type);\n });\n return this;\n }];\n\n this.Param = function Param(id, type, config, location) {\n var self = this;\n config = unwrapShorthand(config);\n type = getType(config, type, location);\n var arrayMode = getArrayMode();\n type = arrayMode ? type.$asArray(arrayMode, location === \"search\") : type;\n if (type.name === \"string\" && !arrayMode && location === \"path\" && config.value === undefined)\n config.value = \"\"; // for 0.2.x; in 0.3.0+ do not automatically default to \"\"\n var isOptional = config.value !== undefined;\n var squash = getSquashPolicy(config, isOptional);\n var replace = getReplace(config, arrayMode, isOptional, squash);\n\n function unwrapShorthand(config) {\n var keys = isObject(config) ? objectKeys(config) : [];\n var isShorthand = indexOf(keys, \"value\") === -1 && indexOf(keys, \"type\") === -1 &&\n indexOf(keys, \"squash\") === -1 && indexOf(keys, \"array\") === -1;\n if (isShorthand) config = { value: config };\n config.$$fn = isInjectable(config.value) ? config.value : function () { return config.value; };\n return config;\n }\n\n function getType(config, urlType, location) {\n if (config.type && urlType) throw new Error(\"Param '\"+id+\"' has two type configurations.\");\n if (urlType) return urlType;\n if (!config.type) return (location === \"config\" ? $types.any : $types.string);\n return config.type instanceof Type ? config.type : new Type(config.type);\n }\n\n // array config: param name (param[]) overrides default settings. explicit config overrides param name.\n function getArrayMode() {\n var arrayDefaults = { array: (location === \"search\" ? \"auto\" : false) };\n var arrayParamNomenclature = id.match(/\\[\\]$/) ? { array: true } : {};\n return extend(arrayDefaults, arrayParamNomenclature, config).array;\n }\n\n /**\n * returns false, true, or the squash value to indicate the \"default parameter url squash policy\".\n */\n function getSquashPolicy(config, isOptional) {\n var squash = config.squash;\n if (!isOptional || squash === false) return false;\n if (!isDefined(squash) || squash == null) return defaultSquashPolicy;\n if (squash === true || isString(squash)) return squash;\n throw new Error(\"Invalid squash policy: '\" + squash + \"'. Valid policies: false, true, or arbitrary string\");\n }\n\n function getReplace(config, arrayMode, isOptional, squash) {\n var replace, configuredKeys, defaultPolicy = [\n { from: \"\", to: (isOptional || arrayMode ? undefined : \"\") },\n { from: null, to: (isOptional || arrayMode ? undefined : \"\") }\n ];\n replace = isArray(config.replace) ? config.replace : [];\n if (isString(squash))\n replace.push({ from: squash, to: undefined });\n configuredKeys = map(replace, function(item) { return item.from; } );\n return filter(defaultPolicy, function(item) { return indexOf(configuredKeys, item.from) === -1; }).concat(replace);\n }\n\n /**\n * [Internal] Get the default value of a parameter, which may be an injectable function.\n */\n function $$getDefaultValue() {\n if (!injector) throw new Error(\"Injectable functions cannot be called at configuration time\");\n var defaultValue = injector.invoke(config.$$fn);\n if (defaultValue !== null && defaultValue !== undefined && !self.type.is(defaultValue))\n throw new Error(\"Default value (\" + defaultValue + \") for parameter '\" + self.id + \"' is not an instance of Type (\" + self.type.name + \")\");\n return defaultValue;\n }\n\n /**\n * [Internal] Gets the decoded representation of a value if the value is defined, otherwise, returns the\n * default value, which may be the result of an injectable function.\n */\n function $value(value) {\n function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }\n function $replace(value) {\n var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });\n return replacement.length ? replacement[0] : value;\n }\n value = $replace(value);\n return !isDefined(value) ? $$getDefaultValue() : self.type.$normalize(value);\n }\n\n function toString() { return \"{Param:\" + id + \" \" + type + \" squash: '\" + squash + \"' optional: \" + isOptional + \"}\"; }\n\n extend(this, {\n id: id,\n type: type,\n location: location,\n array: arrayMode,\n squash: squash,\n replace: replace,\n isOptional: isOptional,\n value: $value,\n dynamic: undefined,\n config: config,\n toString: toString\n });\n };\n\n function ParamSet(params) {\n extend(this, params || {});\n }\n\n ParamSet.prototype = {\n $$new: function() {\n return inherit(this, extend(new ParamSet(), { $$parent: this}));\n },\n $$keys: function () {\n var keys = [], chain = [], parent = this,\n ignore = objectKeys(ParamSet.prototype);\n while (parent) { chain.push(parent); parent = parent.$$parent; }\n chain.reverse();\n forEach(chain, function(paramset) {\n forEach(objectKeys(paramset), function(key) {\n if (indexOf(keys, key) === -1 && indexOf(ignore, key) === -1) keys.push(key);\n });\n });\n return keys;\n },\n $$values: function(paramValues) {\n var values = {}, self = this;\n forEach(self.$$keys(), function(key) {\n values[key] = self[key].value(paramValues && paramValues[key]);\n });\n return values;\n },\n $$equals: function(paramValues1, paramValues2) {\n var equal = true, self = this;\n forEach(self.$$keys(), function(key) {\n var left = paramValues1 && paramValues1[key], right = paramValues2 && paramValues2[key];\n if (!self[key].type.equals(left, right)) equal = false;\n });\n return equal;\n },\n $$validates: function $$validate(paramValues) {\n var keys = this.$$keys(), i, param, rawVal, normalized, encoded;\n for (i = 0; i < keys.length; i++) {\n param = this[keys[i]];\n rawVal = paramValues[keys[i]];\n if ((rawVal === undefined || rawVal === null) && param.isOptional)\n break; // There was no parameter value, but the param is optional\n normalized = param.type.$normalize(rawVal);\n if (!param.type.is(normalized))\n return false; // The value was not of the correct Type, and could not be decoded to the correct Type\n encoded = param.type.encode(normalized);\n if (angular.isString(encoded) && !param.type.pattern.exec(encoded))\n return false; // The value was of the correct type, but when encoded, did not match the Type's regexp\n }\n return true;\n },\n $$parent: undefined\n };\n\n this.ParamSet = ParamSet;\n}\n\n// Register as a provider so it's available to other providers\nangular.module('ui.router.util').provider('$urlMatcherFactory', $UrlMatcherFactory);\nangular.module('ui.router.util').run(['$urlMatcherFactory', function($urlMatcherFactory) { }]);\n\n/**\n * @ngdoc object\n * @name ui.router.router.$urlRouterProvider\n *\n * @requires ui.router.util.$urlMatcherFactoryProvider\n * @requires $locationProvider\n *\n * @description\n * `$urlRouterProvider` has the responsibility of watching `$location`. \n * When `$location` changes it runs through a list of rules one by one until a \n * match is found. `$urlRouterProvider` is used behind the scenes anytime you specify \n * a url in a state configuration. All urls are compiled into a UrlMatcher object.\n *\n * There are several methods on `$urlRouterProvider` that make it useful to use directly\n * in your module config.\n */\n$UrlRouterProvider.$inject = ['$locationProvider', '$urlMatcherFactoryProvider'];\nfunction $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {\n var rules = [], otherwise = null, interceptDeferred = false, listener;\n\n // Returns a string that is a prefix of all strings matching the RegExp\n function regExpPrefix(re) {\n var prefix = /^\\^((?:\\\\[^a-zA-Z0-9]|[^\\\\\\[\\]\\^$*+?.()|{}]+)*)/.exec(re.source);\n return (prefix != null) ? prefix[1].replace(/\\\\(.)/g, \"$1\") : '';\n }\n\n // Interpolates matched values into a String.replace()-style pattern\n function interpolate(pattern, match) {\n return pattern.replace(/\\$(\\$|\\d{1,2})/, function (m, what) {\n return match[what === '$' ? 0 : Number(what)];\n });\n }\n\n /**\n * @ngdoc function\n * @name ui.router.router.$urlRouterProvider#rule\n * @methodOf ui.router.router.$urlRouterProvider\n *\n * @description\n * Defines rules that are used by `$urlRouterProvider` to find matches for\n * specific URLs.\n *\n * @example\n * \n * var app = angular.module('app', ['ui.router.router']);\n *\n * app.config(function ($urlRouterProvider) {\n * // Here's an example of how you might allow case insensitive urls\n * $urlRouterProvider.rule(function ($injector, $location) {\n * var path = $location.path(),\n * normalized = path.toLowerCase();\n *\n * if (path !== normalized) {\n * return normalized;\n * }\n * });\n * });\n *
\n *\n * @param {object} rule Handler function that takes `$injector` and `$location`\n * services as arguments. You can use them to return a valid path as a string.\n *\n * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance\n */\n this.rule = function (rule) {\n if (!isFunction(rule)) throw new Error(\"'rule' must be a function\");\n rules.push(rule);\n return this;\n };\n\n /**\n * @ngdoc object\n * @name ui.router.router.$urlRouterProvider#otherwise\n * @methodOf ui.router.router.$urlRouterProvider\n *\n * @description\n * Defines a path that is used when an invalid route is requested.\n *\n * @example\n * \n * var app = angular.module('app', ['ui.router.router']);\n *\n * app.config(function ($urlRouterProvider) {\n * // if the path doesn't match any of the urls you configured\n * // otherwise will take care of routing the user to the\n * // specified url\n * $urlRouterProvider.otherwise('/index');\n *\n * // Example of using function rule as param\n * $urlRouterProvider.otherwise(function ($injector, $location) {\n * return '/a/valid/url';\n * });\n * });\n *
\n *\n * @param {string|object} rule The url path you want to redirect to or a function \n * rule that returns the url path. The function version is passed two params: \n * `$injector` and `$location` services, and must return a url string.\n *\n * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance\n */\n this.otherwise = function (rule) {\n if (isString(rule)) {\n var redirect = rule;\n rule = function () { return redirect; };\n }\n else if (!isFunction(rule)) throw new Error(\"'rule' must be a function\");\n otherwise = rule;\n return this;\n };\n\n\n function handleIfMatch($injector, handler, match) {\n if (!match) return false;\n var result = $injector.invoke(handler, handler, { $match: match });\n return isDefined(result) ? result : true;\n }\n\n /**\n * @ngdoc function\n * @name ui.router.router.$urlRouterProvider#when\n * @methodOf ui.router.router.$urlRouterProvider\n *\n * @description\n * Registers a handler for a given url matching. if handle is a string, it is\n * treated as a redirect, and is interpolated according to the syntax of match\n * (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise).\n *\n * If the handler is a function, it is injectable. It gets invoked if `$location`\n * matches. You have the option of inject the match object as `$match`.\n *\n * The handler can return\n *\n * - **falsy** to indicate that the rule didn't match after all, then `$urlRouter`\n * will continue trying to find another one that matches.\n * - **string** which is treated as a redirect and passed to `$location.url()`\n * - **void** or any **truthy** value tells `$urlRouter` that the url was handled.\n *\n * @example\n * \n * var app = angular.module('app', ['ui.router.router']);\n *\n * app.config(function ($urlRouterProvider) {\n * $urlRouterProvider.when($state.url, function ($match, $stateParams) {\n * if ($state.$current.navigable !== state ||\n * !equalForKeys($match, $stateParams) {\n * $state.transitionTo(state, $match, false);\n * }\n * });\n * });\n *
\n *\n * @param {string|object} what The incoming path that you want to redirect.\n * @param {string|object} handler The path you want to redirect your user to.\n */\n this.when = function (what, handler) {\n var redirect, handlerIsString = isString(handler);\n if (isString(what)) what = $urlMatcherFactory.compile(what);\n\n if (!handlerIsString && !isFunction(handler) && !isArray(handler))\n throw new Error(\"invalid 'handler' in when()\");\n\n var strategies = {\n matcher: function (what, handler) {\n if (handlerIsString) {\n redirect = $urlMatcherFactory.compile(handler);\n handler = ['$match', function ($match) { return redirect.format($match); }];\n }\n return extend(function ($injector, $location) {\n return handleIfMatch($injector, handler, what.exec($location.path(), $location.search()));\n }, {\n prefix: isString(what.prefix) ? what.prefix : ''\n });\n },\n regex: function (what, handler) {\n if (what.global || what.sticky) throw new Error(\"when() RegExp must not be global or sticky\");\n\n if (handlerIsString) {\n redirect = handler;\n handler = ['$match', function ($match) { return interpolate(redirect, $match); }];\n }\n return extend(function ($injector, $location) {\n return handleIfMatch($injector, handler, what.exec($location.path()));\n }, {\n prefix: regExpPrefix(what)\n });\n }\n };\n\n var check = { matcher: $urlMatcherFactory.isMatcher(what), regex: what instanceof RegExp };\n\n for (var n in check) {\n if (check[n]) return this.rule(strategies[n](what, handler));\n }\n\n throw new Error(\"invalid 'what' in when()\");\n };\n\n /**\n * @ngdoc function\n * @name ui.router.router.$urlRouterProvider#deferIntercept\n * @methodOf ui.router.router.$urlRouterProvider\n *\n * @description\n * Disables (or enables) deferring location change interception.\n *\n * If you wish to customize the behavior of syncing the URL (for example, if you wish to\n * defer a transition but maintain the current URL), call this method at configuration time.\n * Then, at run time, call `$urlRouter.listen()` after you have configured your own\n * `$locationChangeSuccess` event handler.\n *\n * @example\n * \n * var app = angular.module('app', ['ui.router.router']);\n *\n * app.config(function ($urlRouterProvider) {\n *\n * // Prevent $urlRouter from automatically intercepting URL changes;\n * // this allows you to configure custom behavior in between\n * // location changes and route synchronization:\n * $urlRouterProvider.deferIntercept();\n *\n * }).run(function ($rootScope, $urlRouter, UserService) {\n *\n * $rootScope.$on('$locationChangeSuccess', function(e) {\n * // UserService is an example service for managing user state\n * if (UserService.isLoggedIn()) return;\n *\n * // Prevent $urlRouter's default handler from firing\n * e.preventDefault();\n *\n * UserService.handleLogin().then(function() {\n * // Once the user has logged in, sync the current URL\n * // to the router:\n * $urlRouter.sync();\n * });\n * });\n *\n * // Configures $urlRouter's listener *after* your custom listener\n * $urlRouter.listen();\n * });\n *
\n *\n * @param {boolean} defer Indicates whether to defer location change interception. Passing\n no parameter is equivalent to `true`.\n */\n this.deferIntercept = function (defer) {\n if (defer === undefined) defer = true;\n interceptDeferred = defer;\n };\n\n /**\n * @ngdoc object\n * @name ui.router.router.$urlRouter\n *\n * @requires $location\n * @requires $rootScope\n * @requires $injector\n * @requires $browser\n *\n * @description\n *\n */\n this.$get = $get;\n $get.$inject = ['$location', '$rootScope', '$injector', '$browser'];\n function $get( $location, $rootScope, $injector, $browser) {\n\n var baseHref = $browser.baseHref(), location = $location.url(), lastPushedUrl;\n\n function appendBasePath(url, isHtml5, absolute) {\n if (baseHref === '/') return url;\n if (isHtml5) return baseHref.slice(0, -1) + url;\n if (absolute) return baseHref.slice(1) + url;\n return url;\n }\n\n // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree\n function update(evt) {\n if (evt && evt.defaultPrevented) return;\n var ignoreUpdate = lastPushedUrl && $location.url() === lastPushedUrl;\n lastPushedUrl = undefined;\n // TODO: Re-implement this in 1.0 for https://github.com/angular-ui/ui-router/issues/1573\n //if (ignoreUpdate) return true;\n\n function check(rule) {\n var handled = rule($injector, $location);\n\n if (!handled) return false;\n if (isString(handled)) $location.replace().url(handled);\n return true;\n }\n var n = rules.length, i;\n\n for (i = 0; i < n; i++) {\n if (check(rules[i])) return;\n }\n // always check otherwise last to allow dynamic updates to the set of rules\n if (otherwise) check(otherwise);\n }\n\n function listen() {\n listener = listener || $rootScope.$on('$locationChangeSuccess', update);\n return listener;\n }\n\n if (!interceptDeferred) listen();\n\n return {\n /**\n * @ngdoc function\n * @name ui.router.router.$urlRouter#sync\n * @methodOf ui.router.router.$urlRouter\n *\n * @description\n * Triggers an update; the same update that happens when the address bar url changes, aka `$locationChangeSuccess`.\n * This method is useful when you need to use `preventDefault()` on the `$locationChangeSuccess` event,\n * perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed\n * with the transition by calling `$urlRouter.sync()`.\n *\n * @example\n * \n * angular.module('app', ['ui.router'])\n * .run(function($rootScope, $urlRouter) {\n * $rootScope.$on('$locationChangeSuccess', function(evt) {\n * // Halt state change from even starting\n * evt.preventDefault();\n * // Perform custom logic\n * var meetsRequirement = ...\n * // Continue with the update and state transition if logic allows\n * if (meetsRequirement) $urlRouter.sync();\n * });\n * });\n *
\n */\n sync: function() {\n update();\n },\n\n listen: function() {\n return listen();\n },\n\n update: function(read) {\n if (read) {\n location = $location.url();\n return;\n }\n if ($location.url() === location) return;\n\n $location.url(location);\n $location.replace();\n },\n\n push: function(urlMatcher, params, options) {\n var url = urlMatcher.format(params || {});\n\n // Handle the special hash param, if needed\n if (url !== null && params && params['#']) {\n url += '#' + params['#'];\n }\n\n $location.url(url);\n lastPushedUrl = options && options.$$avoidResync ? $location.url() : undefined;\n if (options && options.replace) $location.replace();\n },\n\n /**\n * @ngdoc function\n * @name ui.router.router.$urlRouter#href\n * @methodOf ui.router.router.$urlRouter\n *\n * @description\n * A URL generation method that returns the compiled URL for a given\n * {@link ui.router.util.type:UrlMatcher `UrlMatcher`}, populated with the provided parameters.\n *\n * @example\n * \n * $bob = $urlRouter.href(new UrlMatcher(\"/about/:person\"), {\n * person: \"bob\"\n * });\n * // $bob == \"/about/bob\";\n *
\n *\n * @param {UrlMatcher} urlMatcher The `UrlMatcher` object which is used as the template of the URL to generate.\n * @param {object=} params An object of parameter values to fill the matcher's required parameters.\n * @param {object=} options Options object. The options are:\n *\n * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. \"http://www.example.com/fullurl\".\n *\n * @returns {string} Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`\n */\n href: function(urlMatcher, params, options) {\n if (!urlMatcher.validates(params)) return null;\n\n var isHtml5 = $locationProvider.html5Mode();\n if (angular.isObject(isHtml5)) {\n isHtml5 = isHtml5.enabled;\n }\n \n var url = urlMatcher.format(params);\n options = options || {};\n\n if (!isHtml5 && url !== null) {\n url = \"#\" + $locationProvider.hashPrefix() + url;\n }\n\n // Handle special hash param, if needed\n if (url !== null && params && params['#']) {\n url += '#' + params['#'];\n }\n\n url = appendBasePath(url, isHtml5, options.absolute);\n\n if (!options.absolute || !url) {\n return url;\n }\n\n var slash = (!isHtml5 && url ? '/' : ''), port = $location.port();\n port = (port === 80 || port === 443 ? '' : ':' + port);\n\n return [$location.protocol(), '://', $location.host(), port, slash, url].join('');\n }\n };\n }\n}\n\nangular.module('ui.router.router').provider('$urlRouter', $UrlRouterProvider);\n\n/**\n * @ngdoc object\n * @name ui.router.state.$stateProvider\n *\n * @requires ui.router.router.$urlRouterProvider\n * @requires ui.router.util.$urlMatcherFactoryProvider\n *\n * @description\n * The new `$stateProvider` works similar to Angular's v1 router, but it focuses purely\n * on state.\n *\n * A state corresponds to a \"place\" in the application in terms of the overall UI and\n * navigation. A state describes (via the controller / template / view properties) what\n * the UI looks like and does at that place.\n *\n * States often have things in common, and the primary way of factoring out these\n * commonalities in this model is via the state hierarchy, i.e. parent/child states aka\n * nested states.\n *\n * The `$stateProvider` provides interfaces to declare these states for your app.\n */\n$StateProvider.$inject = ['$urlRouterProvider', '$urlMatcherFactoryProvider'];\nfunction $StateProvider( $urlRouterProvider, $urlMatcherFactory) {\n\n var root, states = {}, $state, queue = {}, abstractKey = 'abstract';\n\n // Builds state properties from definition passed to registerState()\n var stateBuilder = {\n\n // Derive parent state from a hierarchical name only if 'parent' is not explicitly defined.\n // state.children = [];\n // if (parent) parent.children.push(state);\n parent: function(state) {\n if (isDefined(state.parent) && state.parent) return findState(state.parent);\n // regex matches any valid composite state name\n // would match \"contact.list\" but not \"contacts\"\n var compositeName = /^(.+)\\.[^.]+$/.exec(state.name);\n return compositeName ? findState(compositeName[1]) : root;\n },\n\n // inherit 'data' from parent and override by own values (if any)\n data: function(state) {\n if (state.parent && state.parent.data) {\n state.data = state.self.data = extend({}, state.parent.data, state.data);\n }\n return state.data;\n },\n\n // Build a URLMatcher if necessary, either via a relative or absolute URL\n url: function(state) {\n var url = state.url, config = { params: state.params || {} };\n\n if (isString(url)) {\n if (url.charAt(0) == '^') return $urlMatcherFactory.compile(url.substring(1), config);\n return (state.parent.navigable || root).url.concat(url, config);\n }\n\n if (!url || $urlMatcherFactory.isMatcher(url)) return url;\n throw new Error(\"Invalid url '\" + url + \"' in state '\" + state + \"'\");\n },\n\n // Keep track of the closest ancestor state that has a URL (i.e. is navigable)\n navigable: function(state) {\n return state.url ? state : (state.parent ? state.parent.navigable : null);\n },\n\n // Own parameters for this state. state.url.params is already built at this point. Create and add non-url params\n ownParams: function(state) {\n var params = state.url && state.url.params || new $$UMFP.ParamSet();\n forEach(state.params || {}, function(config, id) {\n if (!params[id]) params[id] = new $$UMFP.Param(id, null, config, \"config\");\n });\n return params;\n },\n\n // Derive parameters for this state and ensure they're a super-set of parent's parameters\n params: function(state) {\n return state.parent && state.parent.params ? extend(state.parent.params.$$new(), state.ownParams) : new $$UMFP.ParamSet();\n },\n\n // If there is no explicit multi-view configuration, make one up so we don't have\n // to handle both cases in the view directive later. Note that having an explicit\n // 'views' property will mean the default unnamed view properties are ignored. This\n // is also a good time to resolve view names to absolute names, so everything is a\n // straight lookup at link time.\n views: function(state) {\n var views = {};\n\n forEach(isDefined(state.views) ? state.views : { '': state }, function (view, name) {\n if (name.indexOf('@') < 0) name += '@' + state.parent.name;\n views[name] = view;\n });\n return views;\n },\n\n // Keep a full path from the root down to this state as this is needed for state activation.\n path: function(state) {\n return state.parent ? state.parent.path.concat(state) : []; // exclude root from path\n },\n\n // Speed up $state.contains() as it's used a lot\n includes: function(state) {\n var includes = state.parent ? extend({}, state.parent.includes) : {};\n includes[state.name] = true;\n return includes;\n },\n\n $delegates: {}\n };\n\n function isRelative(stateName) {\n return stateName.indexOf(\".\") === 0 || stateName.indexOf(\"^\") === 0;\n }\n\n function findState(stateOrName, base) {\n if (!stateOrName) return undefined;\n\n var isStr = isString(stateOrName),\n name = isStr ? stateOrName : stateOrName.name,\n path = isRelative(name);\n\n if (path) {\n if (!base) throw new Error(\"No reference point given for path '\" + name + \"'\");\n base = findState(base);\n \n var rel = name.split(\".\"), i = 0, pathLength = rel.length, current = base;\n\n for (; i < pathLength; i++) {\n if (rel[i] === \"\" && i === 0) {\n current = base;\n continue;\n }\n if (rel[i] === \"^\") {\n if (!current.parent) throw new Error(\"Path '\" + name + \"' not valid for state '\" + base.name + \"'\");\n current = current.parent;\n continue;\n }\n break;\n }\n rel = rel.slice(i).join(\".\");\n name = current.name + (current.name && rel ? \".\" : \"\") + rel;\n }\n var state = states[name];\n\n if (state && (isStr || (!isStr && (state === stateOrName || state.self === stateOrName)))) {\n return state;\n }\n return undefined;\n }\n\n function queueState(parentName, state) {\n if (!queue[parentName]) {\n queue[parentName] = [];\n }\n queue[parentName].push(state);\n }\n\n function flushQueuedChildren(parentName) {\n var queued = queue[parentName] || [];\n while(queued.length) {\n registerState(queued.shift());\n }\n }\n\n function registerState(state) {\n // Wrap a new object around the state so we can store our private details easily.\n state = inherit(state, {\n self: state,\n resolve: state.resolve || {},\n toString: function() { return this.name; }\n });\n\n var name = state.name;\n if (!isString(name) || name.indexOf('@') >= 0) throw new Error(\"State must have a valid name\");\n if (states.hasOwnProperty(name)) throw new Error(\"State '\" + name + \"'' is already defined\");\n\n // Get parent name\n var parentName = (name.indexOf('.') !== -1) ? name.substring(0, name.lastIndexOf('.'))\n : (isString(state.parent)) ? state.parent\n : (isObject(state.parent) && isString(state.parent.name)) ? state.parent.name\n : '';\n\n // If parent is not registered yet, add state to queue and register later\n if (parentName && !states[parentName]) {\n return queueState(parentName, state.self);\n }\n\n for (var key in stateBuilder) {\n if (isFunction(stateBuilder[key])) state[key] = stateBuilder[key](state, stateBuilder.$delegates[key]);\n }\n states[name] = state;\n\n // Register the state in the global state list and with $urlRouter if necessary.\n if (!state[abstractKey] && state.url) {\n $urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) {\n if ($state.$current.navigable != state || !equalForKeys($match, $stateParams)) {\n $state.transitionTo(state, $match, { inherit: true, location: false });\n }\n }]);\n }\n\n // Register any queued children\n flushQueuedChildren(name);\n\n return state;\n }\n\n // Checks text to see if it looks like a glob.\n function isGlob (text) {\n return text.indexOf('*') > -1;\n }\n\n // Returns true if glob matches current $state name.\n function doesStateMatchGlob (glob) {\n var globSegments = glob.split('.'),\n segments = $state.$current.name.split('.');\n\n //match single stars\n for (var i = 0, l = globSegments.length; i < l; i++) {\n if (globSegments[i] === '*') {\n segments[i] = '*';\n }\n }\n\n //match greedy starts\n if (globSegments[0] === '**') {\n segments = segments.slice(indexOf(segments, globSegments[1]));\n segments.unshift('**');\n }\n //match greedy ends\n if (globSegments[globSegments.length - 1] === '**') {\n segments.splice(indexOf(segments, globSegments[globSegments.length - 2]) + 1, Number.MAX_VALUE);\n segments.push('**');\n }\n\n if (globSegments.length != segments.length) {\n return false;\n }\n\n return segments.join('') === globSegments.join('');\n }\n\n\n // Implicit root state that is always active\n root = registerState({\n name: '',\n url: '^',\n views: null,\n 'abstract': true\n });\n root.navigable = null;\n\n\n /**\n * @ngdoc function\n * @name ui.router.state.$stateProvider#decorator\n * @methodOf ui.router.state.$stateProvider\n *\n * @description\n * Allows you to extend (carefully) or override (at your own peril) the \n * `stateBuilder` object used internally by `$stateProvider`. This can be used \n * to add custom functionality to ui-router, for example inferring templateUrl \n * based on the state name.\n *\n * When passing only a name, it returns the current (original or decorated) builder\n * function that matches `name`.\n *\n * The builder functions that can be decorated are listed below. Though not all\n * necessarily have a good use case for decoration, that is up to you to decide.\n *\n * In addition, users can attach custom decorators, which will generate new \n * properties within the state's internal definition. There is currently no clear \n * use-case for this beyond accessing internal states (i.e. $state.$current), \n * however, expect this to become increasingly relevant as we introduce additional \n * meta-programming features.\n *\n * **Warning**: Decorators should not be interdependent because the order of \n * execution of the builder functions in non-deterministic. Builder functions \n * should only be dependent on the state definition object and super function.\n *\n *\n * Existing builder functions and current return values:\n *\n * - **parent** `{object}` - returns the parent state object.\n * - **data** `{object}` - returns state data, including any inherited data that is not\n * overridden by own values (if any).\n * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher}\n * or `null`.\n * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is \n * navigable).\n * - **params** `{object}` - returns an array of state params that are ensured to \n * be a super-set of parent's params.\n * - **views** `{object}` - returns a views object where each key is an absolute view \n * name (i.e. \"viewName@stateName\") and each value is the config object \n * (template, controller) for the view. Even when you don't use the views object \n * explicitly on a state config, one is still created for you internally.\n * So by decorating this builder function you have access to decorating template \n * and controller properties.\n * - **ownParams** `{object}` - returns an array of params that belong to the state, \n * not including any params defined by ancestor states.\n * - **path** `{string}` - returns the full path from the root down to this state. \n * Needed for state activation.\n * - **includes** `{object}` - returns an object that includes every state that \n * would pass a `$state.includes()` test.\n *\n * @example\n * \n * // Override the internal 'views' builder with a function that takes the state\n * // definition, and a reference to the internal function being overridden:\n * $stateProvider.decorator('views', function (state, parent) {\n * var result = {},\n * views = parent(state);\n *\n * angular.forEach(views, function (config, name) {\n * var autoName = (state.name + '.' + name).replace('.', '/');\n * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';\n * result[name] = config;\n * });\n * return result;\n * });\n *\n * $stateProvider.state('home', {\n * views: {\n * 'contact.list': { controller: 'ListController' },\n * 'contact.item': { controller: 'ItemController' }\n * }\n * });\n *\n * // ...\n *\n * $state.go('home');\n * // Auto-populates list and item views with /partials/home/contact/list.html,\n * // and /partials/home/contact/item.html, respectively.\n *
\n *\n * @param {string} name The name of the builder function to decorate. \n * @param {object} func A function that is responsible for decorating the original \n * builder function. The function receives two parameters:\n *\n * - `{object}` - state - The state config object.\n * - `{object}` - super - The original builder function.\n *\n * @return {object} $stateProvider - $stateProvider instance\n */\n this.decorator = decorator;\n function decorator(name, func) {\n /*jshint validthis: true */\n if (isString(name) && !isDefined(func)) {\n return stateBuilder[name];\n }\n if (!isFunction(func) || !isString(name)) {\n return this;\n }\n if (stateBuilder[name] && !stateBuilder.$delegates[name]) {\n stateBuilder.$delegates[name] = stateBuilder[name];\n }\n stateBuilder[name] = func;\n return this;\n }\n\n /**\n * @ngdoc function\n * @name ui.router.state.$stateProvider#state\n * @methodOf ui.router.state.$stateProvider\n *\n * @description\n * Registers a state configuration under a given state name. The stateConfig object\n * has the following acceptable properties.\n *\n * @param {string} name A unique state name, e.g. \"home\", \"about\", \"contacts\".\n * To create a parent/child state use a dot, e.g. \"about.sales\", \"home.newest\".\n * @param {object} stateConfig State configuration object.\n * @param {string|function=} stateConfig.template\n * \n * html template as a string or a function that returns\n * an html template as a string which should be used by the uiView directives. This property \n * takes precedence over templateUrl.\n * \n * If `template` is a function, it will be called with the following parameters:\n *\n * - {array.<object>} - state parameters extracted from the current $location.path() by\n * applying the current state\n *\n * template:\n * \"inline template definition
\" +\n * \"\"
\n * template: function(params) {\n * return \"generated template
\"; }
\n * \n *\n * @param {string|function=} stateConfig.templateUrl\n *