/*! * Angular Material Design * https://github.com/angular/material * @license MIT * v1.1.0-master-2b98560 */ function MdAutocompleteCtrl(e,t,n,o,i,l,r,a,c,u,m){function s(){n.initOptionalProperties(e,c,{searchText:"",selectedItem:null}),i(t),f(),n.nextTick(function(){x(),h(),e.autofocus&&t.on("focus",g)})}function d(){e.requireMatch&&Ie&&Ie.$setValidity("md-require-match",!!e.selectedItem)}function p(){function o(){var e=0,n=t.find("md-input-container");if(n.length){var o=n.find("input");e=n.prop("offsetHeight"),e-=o.prop("offsetTop"),e-=o.prop("offsetHeight"),e+=n.prop("offsetTop")}return e}function i(){var e=$e.scrollContainer.getBoundingClientRect(),t={};e.right>u.right-MENU_PADDING&&(t.left=r.right-e.width+"px"),$e.$.scrollContainer.css(t)}if(!$e)return n.nextTick(p,!1,e);var l,r=$e.wrap.getBoundingClientRect(),a=$e.snap.getBoundingClientRect(),u=$e.root.getBoundingClientRect(),m=a.bottom-u.top,s=u.bottom-a.top,d=r.left-u.left,h=r.width,g=o();c.mdFloatingLabel&&(d+=INPUT_PADDING,h-=2*INPUT_PADDING),l={left:d+"px",minWidth:h+"px",maxWidth:Math.max(r.right-u.left,u.right-r.left)-MENU_PADDING+"px"},m>s&&u.height-r.bottom-MENU_PADDING=S()}function Q(e,t,n){Object.defineProperty(he,e,{get:function(){return n},set:function(e){var o=n;n=e,t(e,o)}})}function Z(t){n.nextTick(function(){_(he.matches[t]).then(function(e){var t=$e.$.input.controller("ngModel");t.$setViewValue(e),t.$render()})["finally"](function(){e.selectedItem=he.matches[t],G(!1)})},!1)}function ee(){te(),ne()}function te(){he.index=0,he.matches=[]}function ne(){G(!0),e.searchText="";var t=document.createEvent("CustomEvent");t.initCustomEvent("change",!0,!0,{value:""}),$e.input.dispatchEvent(t),$e.input.blur(),e.searchText="",$e.input.focus()}function oe(t){function o(t){t&&(t=u.when(t),Me++,G(!0),n.nextTick(function(){t.then(i)["finally"](function(){0===--Me&&G(!1)})},!0,e))}function i(n){xe[r]=n,(t||"")===(e.searchText||"")&&se(n)}var l=e.$parent.$eval(fe),r=t.toLowerCase(),a=angular.isArray(l),c=!!l.then;a?i(l):c&&o(l)}function ie(){X().then(function(e){he.messages=[le(),e]})}function le(){if(Ae===he.matches.length)return"";switch(Ae=he.matches.length,he.matches.length){case 0:return"There are no matches available.";case 1:return"There is 1 match available.";default:return"There are "+he.matches.length+" matches available."}}function re(){if($e.li[0]){var e=$e.li[0].offsetHeight,t=e*he.index,n=t+e,o=$e.scroller.clientHeight,i=$e.scroller.scrollTop;ti+o&&ce(n-o)}}function ae(){return 0!==Me}function ce(e){$e.$.scrollContainer.controller("mdVirtualRepeatContainer").scrollTo(e)}function ue(){var e=(he.scope.searchText||"").length;return he.hasNotFound&&!z()&&(!he.loading||ae())&&e>=S()&&(be||Ce)&&!K()}function me(){var t=e.searchText||"",n=t.toLowerCase();!e.noCache&&xe[n]?se(xe[n]):oe(t),he.hidden=U()}function se(t){he.matches=t,he.hidden=U(),he.loading&&G(!1),e.selectOnMatch&&de(),ie(),p()}function de(){var t=e.searchText,n=he.matches,o=n[0];1===n.length&&_(o).then(function(n){var o=t==n;e.matchInsensitive&&!o&&(o=t.toLowerCase()==n.toLowerCase()),o&&Z(0)})}function pe(t,n){c[t]&&e.$parent.$eval(c[t],n||{})}var he=this,ge=e.itemsExpr.split(/ in /i),fe=ge[1],$e=null,xe={},Ce=!1,ve=[],be=!1,Ae=0,Me=0,Te=null,Ie=null;return Q("hidden",b,!0),he.scope=e,he.parent=e.$parent,he.itemName=ge[0],he.matches=[],he.loading=!1,he.hidden=!0,he.index=null,he.messages=[],he.id=n.nextUid(),he.isDisabled=null,he.isRequired=null,he.isReadonly=null,he.hasNotFound=!1,he.keydown=P,he.blur=k,he.focus=L,he.clear=ee,he.select=Z,he.listEnter=M,he.listLeave=T,he.mouseUp=I,he.getCurrentDisplayValue=X,he.registerSelectedItemWatcher=N,he.unregisterSelectedItemWatcher=H,he.notFoundVisible=ue,he.loadingIsVisible=Y,he.positionDropdown=p,s()}function MdAutocomplete(e){return{controller:"MdAutocompleteCtrl",controllerAs:"$mdAutocompleteCtrl",scope:{inputName:"@mdInputName",inputMinlength:"@mdInputMinlength",inputMaxlength:"@mdInputMaxlength",searchText:"=?mdSearchText",selectedItem:"=?mdSelectedItem",itemsExpr:"@mdItems",itemText:"&mdItemText",placeholder:"@placeholder",noCache:"=?mdNoCache",requireMatch:"=?mdRequireMatch",selectOnMatch:"=?mdSelectOnMatch",matchInsensitive:"=?mdMatchCaseInsensitive",itemChange:"&?mdSelectedItemChange",textChange:"&?mdSearchTextChange",minLength:"=?mdMinLength",delay:"=?mdDelay",autofocus:"=?mdAutofocus",floatingLabel:"@?mdFloatingLabel",autoselect:"=?mdAutoselect",menuClass:"@?mdMenuClass",inputId:"@?mdInputId",escapeOptions:"@?mdEscapeOptions"},link:function(e,t,n,o){o.hasNotFound=!!t.attr("md-has-not-found")},template:function(t,n){function o(){var e=t.find("md-item-template").detach(),n=e.length?e.html():t.html();return e.length||t.empty(),""+n+""}function i(){var e=t.find("md-not-found").detach(),n=e.length?e.html():"";return n?'
  • '+n+"
  • ":""}function l(){return n.mdFloatingLabel?'
    '+c+"
    ":' '}var r=i(),a=o(),c=t.html(),u=n.tabindex;return r&&t.attr("md-has-not-found",!0),t.attr("tabindex","-1")," "+l()+'
    • '+a+"
    • "+r+'

    {{message}}

    '}}}function MdAutocompleteItemScopeDirective(e,t){function n(e,n,o){return function(e,n,i){function l(n,o){c[o]=e[n],e.$watch(n,function(e){t.nextTick(function(){c[o]=e})})}function r(){var t=!1,n=!1;e.$watch(function(){n||t||(t=!0,e.$$postDigest(function(){n||c.$digest(),t=n=!1}))}),c.$watch(function(){n=!0})}var a=e.$mdAutocompleteCtrl,c=a.parent.$new(),u=a.itemName;l("$index","$index"),l("item",u),r(),o(c,function(e){n.after(e)})}}return{restrict:"AE",compile:n,terminal:!0,transclude:"element"}}function MdHighlightCtrl(e,t,n){this.$scope=e,this.$element=t,this.$attrs=n,this.regex=null}function MdHighlight(e,t){return{terminal:!0,controller:"MdHighlightCtrl",compile:function(n,o){var i=t(o.mdHighlightText),l=e(n.html());return function(e,t,n,o){o.init(i,l)}}}}goog.provide("ngmaterial.components.autocomplete"),goog.require("ngmaterial.components.icon"),goog.require("ngmaterial.components.virtualRepeat"),goog.require("ngmaterial.core"),angular.module("material.components.autocomplete",["material.core","material.components.icon","material.components.virtualRepeat"]),MdAutocompleteCtrl.$inject=["$scope","$element","$mdUtil","$mdConstant","$mdTheming","$window","$animate","$rootElement","$attrs","$q","$log"],angular.module("material.components.autocomplete").controller("MdAutocompleteCtrl",MdAutocompleteCtrl);var ITEM_HEIGHT=41,MAX_HEIGHT=5.5*ITEM_HEIGHT,MENU_PADDING=8,INPUT_PADDING=2;MdAutocomplete.$inject=["$$mdSvgRegistry"],angular.module("material.components.autocomplete").directive("mdAutocomplete",MdAutocomplete),MdAutocompleteItemScopeDirective.$inject=["$compile","$mdUtil"],angular.module("material.components.autocomplete").directive("mdAutocompleteParentScope",MdAutocompleteItemScopeDirective),MdHighlightCtrl.$inject=["$scope","$element","$attrs"],angular.module("material.components.autocomplete").controller("MdHighlightCtrl",MdHighlightCtrl),MdHighlightCtrl.prototype.init=function(e,t){this.flags=this.$attrs.mdHighlightFlags||"",this.unregisterFn=this.$scope.$watch(function(n){return{term:e(n),contentText:t(n)}}.bind(this),this.onRender.bind(this),!0),this.$element.on("$destroy",this.unregisterFn)},MdHighlightCtrl.prototype.onRender=function(e,t){var n=e.contentText;null!==this.regex&&e.term===t.term||(this.regex=this.createRegex(e.term,this.flags)),e.term?this.applyRegex(n):this.$element.text(n)},MdHighlightCtrl.prototype.applyRegex=function(e){var t=this.resolveTokens(e);this.$element.empty(),t.forEach(function(e){if(e.isMatch){var t=angular.element('').text(e.text);this.$element.append(t)}else this.$element.append(document.createTextNode(e))}.bind(this))},MdHighlightCtrl.prototype.resolveTokens=function(e){function t(t,o){var i=e.slice(t,o);i&&n.push(i)}var n=[],o=0;return e.replace(this.regex,function(e,i){t(o,i),n.push({text:e,isMatch:!0}),o=i+e.length}),t(o),n},MdHighlightCtrl.prototype.createRegex=function(e,t){var n="",o="",i=this.sanitizeRegex(e);return t.indexOf("^")>=0&&(n="^"),t.indexOf("$")>=0&&(o="$"),new RegExp(n+i+o,t.replace(/[$\^]/g,""))},MdHighlightCtrl.prototype.sanitizeRegex=function(e){return e&&e.toString().replace(/[\\\^\$\*\+\?\.\(\)\|\{}\[\]]/g,"\\$&")},MdHighlight.$inject=["$interpolate","$parse"],angular.module("material.components.autocomplete").directive("mdHighlightText",MdHighlight),ngmaterial.components.autocomplete=angular.module("material.components.autocomplete");