/*! * Angular Material Design * https://github.com/angular/material * @license MIT * v1.1.2-master-a9ba340 */ function MdAutocompleteCtrl(e,t,n,o,i,l,r,a,c,u,d,m){function s(){n.initOptionalProperties(e,c,{searchText:"",selectedItem:null,clearButton:!1}),i(t),$(),n.nextTick(function(){v(),g(),e.autofocus&&t.on("focus",f)})}function p(){e.requireMatch&&Ie&&Ie.$setValidity("md-require-match",!!e.selectedItem||!e.searchText)}function h(){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=Ce.scrollContainer.getBoundingClientRect(),t={};e.right>d.right-MENU_PADDING&&(t.left=a.right-e.width+"px"),Ce.$.scrollContainer.css(t)}if(!Ce)return n.nextTick(h,!1,e);var l,r=(e.dropdownItems||MAX_ITEMS)*ITEM_HEIGHT,a=Ce.wrap.getBoundingClientRect(),u=Ce.snap.getBoundingClientRect(),d=Ce.root.getBoundingClientRect(),m=u.bottom-d.top,s=d.bottom-u.top,p=a.left-d.left,g=a.width,f=o(),$=e.dropdownPosition;if($||($=m>s&&d.height-a.bottom-MENU_PADDING=q()}function ee(e,t,n){Object.defineProperty(fe,e,{get:function(){return n},set:function(e){var o=n;n=e,t(e,o)}})}function te(t){n.nextTick(function(){B(fe.matches[t]).then(function(e){var t=Ce.$.input.controller("ngModel");t.$setViewValue(e),t.$render()})["finally"](function(){e.selectedItem=fe.matches[t],G(!1)})},!1)}function ne(){oe(),ie()}function oe(){fe.index=0,fe.matches=[]}function ie(){G(!0),e.searchText="";var t=document.createEvent("CustomEvent");t.initCustomEvent("change",!0,!0,{value:""}),Ce.input.dispatchEvent(t),Ce.input.blur(),e.searchText="",Ce.input.focus()}function le(t){function o(t){t&&(t=u.when(t),Te++,G(!0),n.nextTick(function(){t.then(i)["finally"](function(){0===--Te&&G(!1)})},!0,e))}function i(n){ve[r]=n,(t||"")===(e.searchText||"")&&pe(n)}var l=e.$parent.$eval(xe),r=t.toLowerCase(),a=angular.isArray(l),c=!!l.then;a?i(l):c&&o(l)}function re(e,t){var n=e?"polite":"assertive",o=[];t&ye.Selected&&fe.index!==-1&&o.push(Q()),t&ye.Count&&o.push(u.resolve(ae())),u.all(o).then(function(e){m.announce(e.join(" "),n)})}function ae(){switch(fe.matches.length){case 0:return"There are no matches available.";case 1:return"There is 1 match available.";default:return"There are "+fe.matches.length+" matches available."}}function ce(){if(Ce.li[0]){var e=Ce.li[0].offsetHeight,t=e*fe.index,n=t+e,o=Ce.scroller.clientHeight,i=Ce.scroller.scrollTop;ti+o&&de(n-o)}}function ue(){return 0!==Te}function de(e){Ce.$.scrollContainer.controller("mdVirtualRepeatContainer").scrollTo(e)}function me(){var e=(fe.scope.searchText||"").length;return fe.hasNotFound&&!Y()&&(!fe.loading||ue())&&e>=q()&&(Me||be)&&!X()}function se(){var t=e.searchText||"",n=t.toLowerCase();!e.noCache&&ve[n]?pe(ve[n]):le(t),fe.hidden=V()}function pe(t){fe.matches=t,fe.hidden=V(),fe.loading&&G(!1),e.selectOnMatch&&he(),h(),re(!0,ye.Count)}function he(){var t=e.searchText,n=fe.matches,o=n[0];1===n.length&&B(o).then(function(n){var o=t==n;e.matchInsensitive&&!o&&(o=t.toLowerCase()==n.toLowerCase()),o&&te(0)})}function ge(t,n){c[t]&&e.$parent.$eval(c[t],n||{})}var fe=this,$e=e.itemsExpr.split(/ in /i),xe=$e[1],Ce=null,ve={},be=!1,Ae=[],Me=!1,Te=0,we=null,Ie=null,De=n.debounce(C);ee("hidden",M,!0),fe.scope=e,fe.parent=e.$parent,fe.itemName=$e[0],fe.matches=[],fe.loading=!1,fe.hidden=!0,fe.index=null,fe.id=n.nextUid(),fe.isDisabled=null,fe.isRequired=null,fe.isReadonly=null,fe.hasNotFound=!1,fe.keydown=_,fe.blur=P,fe.focus=O,fe.clear=ne,fe.select=te,fe.listEnter=w,fe.listLeave=I,fe.mouseUp=D,fe.getCurrentDisplayValue=Q,fe.registerSelectedItemWatcher=S,fe.unregisterSelectedItemWatcher=H,fe.notFoundVisible=me,fe.loadingIsVisible=J,fe.positionDropdown=h;var ye={Count:1,Selected:2};return 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",dropdownItems:"=?mdDropdownItems",dropdownPosition:"@?mdDropdownPosition",clearButton:"=?mdClearButton"},compile:function(e,t){var n=["md-select-on-focus","md-no-asterisk","ng-trim","ng-pattern"],o=e.find("input");return n.forEach(function(e){var n=t[t.$normalize(e)];null!==n&&o.attr(e,n)}),function(e,t,n,o){o.hasNotFound=!!t.attr("md-has-not-found"),angular.isDefined(n.mdClearButton)||e.floatingLabel||(e.clearButton=!0)}},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?'
    '+u+"
    ":' '}function r(){return''}var a=i(),c=o(),u=t.html(),d=n.tabindex;return a&&t.attr("md-has-not-found",!0),t.attr("tabindex","-1")," "+l()+" "+r()+'
    • '+c+"
    • "+a+"
    "}}}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","$mdLiveAnnouncer"],angular.module("material.components.autocomplete").controller("MdAutocompleteCtrl",MdAutocompleteCtrl);var ITEM_HEIGHT=48,MAX_ITEMS=5,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");