/*! * Angular Material Design * https://github.com/angular/material * @license MIT * v1.1.2-master-a9ba340 */ !function(e,t,n){"use strict";function o(e,o,i,r,l,a,s,p,h,f,g,$){function x(){i.initOptionalProperties(e,h,{searchText:"",selectedItem:null,clearButton:!1}),l(o),A(),i.nextTick(function(){I(),b(),e.autofocus&&o.on("focus",w)})}function C(){e.requireMatch&&De&&De.$setValidity("md-require-match",!!e.selectedItem||!e.searchText)}function v(){function t(){var e=0,t=o.find("md-input-container");if(t.length){var n=t.find("input");e=t.prop("offsetHeight"),e-=n.prop("offsetTop"),e-=n.prop("offsetHeight"),e+=t.prop("offsetTop")}return e}function n(){var e=ye.scrollContainer.getBoundingClientRect(),t={};e.right>p.right-d&&(t.left=a.right-e.width+"px"),ye.$.scrollContainer.css(t)}if(!ye)return i.nextTick(v,!1,e);var r,l=(e.dropdownItems||u)*c,a=ye.wrap.getBoundingClientRect(),s=ye.snap.getBoundingClientRect(),p=ye.root.getBoundingClientRect(),f=s.bottom-p.top,g=p.bottom-s.top,$=a.left-p.left,x=a.width,C=t(),b=e.dropdownPosition;if(b||(b=f>g&&p.height-a.bottom-d=_()}function le(e,t,n){Object.defineProperty(we,e,{get:function(){return n},set:function(e){var o=n;n=e,t(e,o)}})}function ae(t){i.nextTick(function(){U(we.matches[t]).then(function(e){var t=ye.$.input.controller("ngModel");t.$setViewValue(e),t.$render()})["finally"](function(){e.selectedItem=we.matches[t],G(!1)})},!1)}function ce(){ue(),de()}function ue(){we.index=0,we.matches=[]}function de(){G(!0),e.searchText="";var t=document.createEvent("CustomEvent");t.initCustomEvent("change",!0,!0,{value:""}),ye.input.dispatchEvent(t),ye.input.blur(),e.searchText="",ye.input.focus()}function me(n){function o(t){t&&(t=f.when(t),Le++,G(!0),i.nextTick(function(){t.then(r)["finally"](function(){0===--Le&&G(!1)})},!0,e))}function r(t){Ie[a]=t,(n||"")===(e.searchText||"")&&Ce(t)}var l=e.$parent.$eval(Te),a=n.toLowerCase(),c=t.isArray(l),u=!!l.then;c?r(l):u&&o(l)}function se(e,t){var n=e?"polite":"assertive",o=[];t&Oe.Selected&&we.index!==-1&&o.push(ie()),t&Oe.Count&&o.push(f.resolve(pe())),f.all(o).then(function(e){$.announce(e.join(" "),n)})}function pe(){switch(we.matches.length){case 0:return"There are no matches available.";case 1:return"There is 1 match available.";default:return"There are "+we.matches.length+" matches available."}}function he(){if(ye.li[0]){var e=ye.li[0].offsetHeight,t=e*we.index,n=t+e,o=ye.scroller.clientHeight,i=ye.scroller.scrollTop;ti+o&&ge(n-o)}}function fe(){return 0!==Le}function ge(e){ye.$.scrollContainer.controller("mdVirtualRepeatContainer").scrollTo(e)}function $e(){var e=(we.scope.searchText||"").length;return we.hasNotFound&&!te()&&(!we.loading||fe())&&e>=_()&&(Re||Ee)&&!ne()}function xe(){var t=e.searchText||"",n=t.toLowerCase();!e.noCache&&Ie[n]?Ce(Ie[n]):me(t),we.hidden=J()}function Ce(t){we.matches=t,we.hidden=J(),we.loading&&G(!1),e.selectOnMatch&&ve(),v(),se(!0,Oe.Count)}function ve(){var t=e.searchText,n=we.matches,o=n[0];1===n.length&&U(o).then(function(n){var o=t==n;e.matchInsensitive&&!o&&(o=t.toLowerCase()==n.toLowerCase()),o&&ae(0)})}function be(t,n){h[t]&&e.$parent.$eval(h[t],n||{})}var we=this,Ae=e.itemsExpr.split(/ in /i),Te=Ae[1],ye=null,Ie={},Ee=!1,Me=[],Re=!1,Le=0,ke=null,De=null,Se=i.debounce(y);le("hidden",R,!0),we.scope=e,we.parent=e.$parent,we.itemName=Ae[0],we.matches=[],we.loading=!1,we.hidden=!0,we.index=null,we.id=i.nextUid(),we.isDisabled=null,we.isRequired=null,we.isReadonly=null,we.hasNotFound=!1,we.keydown=W,we.blur=V,we.focus=z,we.clear=ce,we.select=ae,we.listEnter=k,we.listLeave=D,we.mouseUp=S,we.getCurrentDisplayValue=ie,we.registerSelectedItemWatcher=q,we.unregisterSelectedItemWatcher=P,we.notFoundVisible=$e,we.loadingIsVisible=oe,we.positionDropdown=v;var Oe={Count:1,Selected:2};return x()}function i(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,n){var o=["md-select-on-focus","md-no-asterisk","ng-trim","ng-pattern"],i=e.find("input");return o.forEach(function(e){var t=n[n.$normalize(e)];null!==t&&i.attr(e,t)}),function(e,n,o,i){i.hasNotFound=!!n.attr("md-has-not-found"),t.isDefined(o.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 r(){return n.mdFloatingLabel?'
    '+u+"
    ":' '}function l(){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")," "+r()+" "+l()+'
    • '+c+"
    • "+a+"
    "}}}function r(e,t){function n(e,n,o){return function(e,n,i){function r(n,o){c[o]=e[n],e.$watch(n,function(e){t.nextTick(function(){c[o]=e})})}function l(){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;r("$index","$index"),r("item",u),l(),o(c,function(e){n.after(e)})}}return{restrict:"AE",compile:n,terminal:!0,transclude:"element"}}function l(e,t,n){this.$scope=e,this.$element=t,this.$attrs=n,this.regex=null}function a(e,t){return{terminal:!0,controller:"MdHighlightCtrl",compile:function(n,o){var i=t(o.mdHighlightText),r=e(n.html());return function(e,t,n,o){o.init(i,r)}}}}t.module("material.components.autocomplete",["material.core","material.components.icon","material.components.virtualRepeat"]),o.$inject=["$scope","$element","$mdUtil","$mdConstant","$mdTheming","$window","$animate","$rootElement","$attrs","$q","$log","$mdLiveAnnouncer"],t.module("material.components.autocomplete").controller("MdAutocompleteCtrl",o);var c=48,u=5,d=8,m=2;i.$inject=["$$mdSvgRegistry"],t.module("material.components.autocomplete").directive("mdAutocomplete",i),r.$inject=["$compile","$mdUtil"],t.module("material.components.autocomplete").directive("mdAutocompleteParentScope",r),l.$inject=["$scope","$element","$attrs"],t.module("material.components.autocomplete").controller("MdHighlightCtrl",l),l.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)},l.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)},l.prototype.applyRegex=function(e){var n=this.resolveTokens(e);this.$element.empty(),n.forEach(function(e){if(e.isMatch){var n=t.element('').text(e.text);this.$element.append(n)}else this.$element.append(document.createTextNode(e))}.bind(this))},l.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},l.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,""))},l.prototype.sanitizeRegex=function(e){return e&&e.toString().replace(/[\\\^\$\*\+\?\.\(\)\|\{}\[\]]/g,"\\$&")},a.$inject=["$interpolate","$parse"],t.module("material.components.autocomplete").directive("mdHighlightText",a)}(window,window.angular);