text: !function(){"use strict";function e(e){e.put("selectbox.html",'<div   tabindex="{{ vm.instance }}"   class="sb-container"   id="{{ vm.formatInstance(vm.instance) }}">  <a href=""      class="sb-toggle"      ng-click="vm.toggle()"      ng-class="{\'sb-toggle-active\': vm.active}">    {{ vm.selected[vm.labelKey] || vm.value || \'Select\' }}  </a>  <ul class="sb-dropdown" ng-show="vm.active">    <li       class="sb-item"       ng-repeat="option in vm.options track by $index"       ng-class="{\'sb-item-active\': option === vm.selected,\'sb-item-focus\': $index === vm.focus}">        <a href=""            class="sb-item-handle"            ng-click="vm.change(option)"            title="{{ option[vm.labelKey] || option }}">          {{ option[vm.labelKey] || option }}        </a>    </li>    <li class="sb-item sb-empty" ng-if="vm.options.length === 0">the list is empty</li>  </ul></div>'),e.put("selectbox-multi.html",'<div   tabindex="{{ vm.instance }}"   class="sb-container sb-container-multi"   id="{{ vm.formatInstance(vm.instance) }}">  <a href=""      class="sb-toggle"      ng-click="vm.toggle()"      ng-class="{\'sb-toggle-active\': vm.active}">    {{ vm.title }}{{ vm.values.length ? (\': \' + vm.values.length) : \'\' }}  </a>  <ul class="sb-dropdown" ng-show="vm.active">    <li       class="sb-item"       ng-repeat="option in vm.options track by $index"       ng-class="{\'sb-item-active\': vm.contains(vm.values, option[vm.idKey]),\'sb-item-focus\': $index === vm.focus}">        <a href=""            class="sb-item-handle"            ng-click="vm.change(option)"            title="{{ option[vm.labelKey] || option }}">          {{ option[vm.labelKey] || option }}        </a>    </li>    <li class="sb-item sb-empty" ng-if="vm.options.length === 0">the list is empty</li>  </ul></div>')}function t(){function e(e,t,n,o,i){function c(){if(d.options.length)if(d.options[0][d.idKey]){for(var e=0;e<d.options.length;e+=1)if(d.options[e][d.idKey]===d.value){d.selected=d.options[e];break}}else d.selected=d.value}function l(){return i.formatInstance(d.instance)}function s(){d.active=!d.active,o(function(){d.active?v():f()})}function a(e){d.value=e[d.idKey]||e,c(),angular.isDefined(d.onChange)&&d.onChange({value:d.value})}function u(e){var t=i.getId(e.target.parentNode);l()!==t&&s()}function r(e){var t=0,n=d.options.length-1;return 13===e.keyCode?void o(function(){d.change(d.options[d.focus])}):void((40===e.keyCode||38===e.keyCode)&&o(function(){d.focus=i.getFocus(d.focus,t,n,e.keyCode),i.updateScrollPosition(d.focus,m)}))}function v(){n.bind("click",u),t.on("keydown",r)}function f(){d.focus=0,n.unbind("click",u),t.off("keydown",r)}var d=this,m=t[0].querySelector(".sb-dropdown"),g=i.getDefaults();d.instance=i.getInstance(),d.active=g.active,d.focus=g.focus,d.idKey=d.idKey||g.idKey,d.labelKey=d.labelKey||g.labelKey,c(),d.formatInstance=l,d.toggle=s,d.change=a,e.$on("$destroy",f)}return e.$inject=["$scope","$element","$document","$timeout","Selectbox"],{restrict:"E",templateUrl:"selectbox.html",scope:{},controller:e,controllerAs:"vm",bindToController:{options:"=",value:"=",idKey:"@",labelKey:"@",onChange:"&"}}}function n(){function e(e,t,n,o,i){function c(){return i.formatInstance(d.instance)}function l(){d.active=!d.active,o(function(){d.active?v():f()})}function s(e){var t=e[d.idKey],n=d.values.indexOf(t);-1===n?d.values.push(t):d.values.splice(n,1),angular.isDefined(d.onChange)&&d.onChange({values:d.values})}function a(e,t){return-1!==e.indexOf(t)}function u(e){var t=i.getId(e.target.parentNode),n=!t&&e.target.classList.contains("sb-item-handle");c()===t||n||l()}function r(e){var t=0,n=d.options.length-1;return-1!==[32,13].indexOf(e.keyCode)?void o(function(){13===e.keyCode&&f(),32===e.keyCode&&d.change(d.options[d.focus])}):void((40===e.keyCode||38===e.keyCode)&&o(function(){d.focus=i.getFocus(d.focus,t,n,e.keyCode),i.updateScrollPosition(d.focus,m)}))}function v(){n.bind("click",u),t.on("keydown",r)}function f(){d.focus=g.focus,d.active=g.active,n.unbind("click",u),t.off("keydown",r)}var d=this,m=t[0].querySelector(".sb-dropdown"),g=i.getDefaults();d.instance=i.getInstance(),d.title=d.title||"Select",d.active=g.active,d.focus=g.focus,d.idKey=d.idKey||g.idKey,d.labelKey=d.labelKey||g.labelKey,d.formatInstance=c,d.toggle=l,d.change=s,d.contains=a,e.$on("$destroy",f)}return e.$inject=["$scope","$element","$document","$timeout","Selectbox"],{restrict:"E",templateUrl:"selectbox-multi.html",scope:{},controller:e,controllerAs:"vm",bindToController:{title:"@",options:"=",values:"=",idKey:"@",labelKey:"@",onChange:"&"}}}function o(){function e(){return l+=1}function t(){return angular.copy(s)}function n(e){return"sb-"+e}function o(e,t,n,o){return 40===o&&(e=e>=n?t:e+1),38===o&&(e=t>=e?n:e-1),e}function i(e,t){var n=t.querySelector(".sb-item-focus"),o=n.offsetHeight*e;o>=t.offsetHeight?t.scrollTop=o:o<=t.scrollTop&&(t.scrollTop=0)}function c(e){return"function"!=typeof e.getAttribute?null:e.getAttribute("id")}var l=0,s={active:!1,focus:0,idKey:"id",labelKey:"label"};return{getInstance:e,getDefaults:t,formatInstance:n,getFocus:o,updateScrollPosition:i,getId:c}}angular.module("angularSelectbox",[]).run(e).directive("selectbox",t).directive("selectboxMulti",n).factory("Selectbox",o),e.$inject=["$templateCache"]}();