text: !function(s){"function"==typeof define&&define.amd?define(["jquery"],s):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),s(t),t}:s(jQuery)}(function(p){"use strict";function s(e,t){var s=this;s.element=e,s.$element=p(e),s.state={multiple:!!s.$element.attr("multiple"),enabled:!1,opened:!1,currValue:-1,selectedIdx:-1,highlightedIdx:-1},s.eventTriggers={open:s.open,close:s.close,destroy:s.destroy,refresh:s.refresh,init:s.init},s.init(t)}var t=p(document),r=p(window),u="selectric",l=".sl",i=["a","e","i","o","u","n","c","y"],n=[/[\xE0-\xE5]/g,/[\xE8-\xEB]/g,/[\xEC-\xEF]/g,/[\xF2-\xF6]/g,/[\xF9-\xFC]/g,/[\xF1]/g,/[\xE7]/g,/[\xFD-\xFF]/g];s.prototype={utils:{isMobile:function(){return/android|ip(hone|od|ad)/i.test(navigator.userAgent)},escapeRegExp:function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},replaceDiacritics:function(e){for(var t=n.length;t--;)e=e.toLowerCase().replace(n[t],i[t]);return e},format:function(e){var l=arguments;return(""+e).replace(/\{(?:(\d+)|(\w+))\}/g,function(e,t,s){return s&&l[1]?l[1][s]:l[t]})},nextEnabledItem:function(e,t){for(;e[t=(t+1)%e.length].disabled;);return t},previousEnabledItem:function(e,t){for(;e[t=(0<t?t:e.length)-1].disabled;);return t},toDash:function(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()},triggerCallback:function(e,t){var s=t.element,l=t.options["on"+e],i=[s].concat([].slice.call(arguments).slice(1));p.isFunction(l)&&l.apply(s,i),p(s).trigger(u+"-"+this.toDash(e),i)},arrayToClassname:function(e){var t=p.grep(e,function(e){return!!e});return p.trim(t.join(" "))}},init:function(e){var t,s,l,i,n,o,a,r=this;r.options=p.extend(!0,{},p.fn[u].defaults,r.options,e),r.utils.triggerCallback("BeforeInit",r),r.destroy(!0),r.options.disableOnMobile&&r.utils.isMobile()?r.disableOnMobile=!0:(r.classes=r.getClassNames(),t=p("<input/>",{class:r.classes.input,readonly:r.utils.isMobile()}),s=p("<div/>",{class:r.classes.items,tabindex:-1}),l=p("<div/>",{class:r.classes.scroll}),i=p("<div/>",{class:r.classes.prefix,html:r.options.arrowButtonMarkup}),n=p("<span/>",{class:"label"}),o=r.$element.wrap("<div/>").parent().append(i.prepend(n),s,t),a=p("<div/>",{class:r.classes.hideselect}),r.elements={input:t,items:s,itemsScroll:l,wrapper:i,label:n,outerWrapper:o},r.options.nativeOnMobile&&r.utils.isMobile()&&(r.elements.input=void 0,a.addClass(r.classes.prefix+"-is-native"),r.$element.on("change",function(){r.refresh()})),r.$element.on(r.eventTriggers).wrap(a),r.originalTabindex=r.$element.prop("tabindex"),r.$element.prop("tabindex",-1),r.populate(),r.activate(),r.utils.triggerCallback("Init",r))},activate:function(){var e=this,t=e.elements.items.closest(":visible").children(":hidden").addClass(e.classes.tempshow),s=e.$element.width();t.removeClass(e.classes.tempshow),e.utils.triggerCallback("BeforeActivate",e),e.elements.outerWrapper.prop("class",e.utils.arrayToClassname([e.classes.wrapper,e.$element.prop("class").replace(/\S+/g,e.classes.prefix+"-$&"),e.options.responsive?e.classes.responsive:""])),e.options.inheritOriginalWidth&&0<s&&e.elements.outerWrapper.width(s),e.unbindEvents(),e.$element.prop("disabled")?(e.elements.outerWrapper.addClass(e.classes.disabled),e.elements.input&&e.elements.input.prop("disabled",!0)):(e.state.enabled=!0,e.elements.outerWrapper.removeClass(e.classes.disabled),e.$li=e.elements.items.removeAttr("style").find("li"),e.bindEvents()),e.utils.triggerCallback("Activate",e)},getClassNames:function(){var l=this,i=l.options.customClass,n={};return p.each("Input Items Open Disabled TempShow HideSelect Wrapper Focus Hover Responsive Above Below Scroll Group GroupLabel".split(" "),function(e,t){var s=i.prefix+t;n[t.toLowerCase()]=i.camelCase?s:l.utils.toDash(s)}),n.prefix=i.prefix,n},setLabel:function(){var e,t,s,l=this,i=l.options.labelBuilder;l.state.multiple?(e=0===(e=p.isArray(l.state.currValue)?l.state.currValue:[l.state.currValue]).length?[0]:e,t=p.map(e,function(t){return p.grep(l.lookupItems,function(e){return e.index===t})[0]}),t=p.grep(t,function(e){return 1<t.length||0===t.length?""!==p.trim(e.value):e}),t=p.map(t,function(e){return p.isFunction(i)?i(e):l.utils.format(i,e)}),l.options.multiple.maxLabelEntries&&(t.length>=l.options.multiple.maxLabelEntries+1?(t=t.slice(0,l.options.multiple.maxLabelEntries)).push(p.isFunction(i)?i({text:"..."}):l.utils.format(i,{text:"..."})):t.slice(t.length-1)),l.elements.label.html(t.join(l.options.multiple.separator))):(s=l.lookupItems[l.state.currValue],l.elements.label.html(p.isFunction(i)?i(s):l.utils.format(i,s)))},populate:function(){var l=this,e=l.$element.children(),t=l.$element.find("option"),s=t.filter(":selected"),i=t.index(s),n=0,o=l.state.multiple?[]:0;1<s.length&&l.state.multiple&&(i=[],s.each(function(){i.push(p(this).index())})),l.state.currValue=~i?i:o,l.state.selectedIdx=l.state.currValue,l.state.highlightedIdx=l.state.currValue,l.items=[],l.lookupItems=[],e.length&&(e.each(function(e){var s,t=p(this);t.is("optgroup")?(s={element:t,label:t.prop("label"),groupDisabled:t.prop("disabled"),items:[]},t.children().each(function(e){var t=p(this);s.items[e]=l.getItemData(n,t,s.groupDisabled||t.prop("disabled")),l.lookupItems[n]=s.items[e],n++}),l.items[e]=s):(l.items[e]=l.getItemData(n,t,t.prop("disabled")),l.lookupItems[n]=l.items[e],n++)}),l.setLabel(),l.elements.items.append(l.elements.itemsScroll.html(l.getItemsMarkup(l.items))))},getItemData:function(e,t,s){return{index:e,element:t,value:t.val(),className:t.prop("class"),text:t.html(),slug:p.trim(this.utils.replaceDiacritics(t.html())),alt:t.attr("data-alt"),selected:t.prop("selected"),disabled:s}},getItemsMarkup:function(e){var s=this,l="<ul>";return p.isFunction(s.options.listBuilder)&&s.options.listBuilder&&(e=s.options.listBuilder(e)),p.each(e,function(e,t){void 0!==t.label?(l+=s.utils.format('<ul class="{1}"><li class="{2}">{3}</li>',s.utils.arrayToClassname([s.classes.group,t.groupDisabled?"disabled":"",t.element.prop("class")]),s.classes.grouplabel,t.element.prop("label")),p.each(t.items,function(e,t){l+=s.getItemMarkup(t.index,t)}),l+="</ul>"):l+=s.getItemMarkup(t.index,t)}),l+"</ul>"},getItemMarkup:function(e,t){var s=this,l=s.options.optionsItemBuilder,i={value:t.value,text:t.text,slug:t.slug,index:t.index};return s.utils.format('<li data-index="{1}" class="{2}">{3}</li>',e,s.utils.arrayToClassname([t.className,e===s.items.length-1?"last":"",t.disabled?"disabled":"",t.selected?"selected":""]),p.isFunction(l)?s.utils.format(l(t,this.$element,e),t):s.utils.format(l,i))},unbindEvents:function(){this.elements.wrapper.add(this.$element).add(this.elements.outerWrapper).add(this.elements.input).off(l)},bindEvents:function(){var n=this;n.elements.outerWrapper.on("mouseenter.sl mouseleave"+l,function(e){p(this).toggleClass(n.classes.hover,"mouseenter"===e.type),n.options.openOnHover&&(clearTimeout(n.closeTimer),"mouseleave"===e.type?n.closeTimer=setTimeout(p.proxy(n.close,n),n.options.hoverIntentTimeout):n.open())}),n.elements.wrapper.on("click"+l,function(e){n.state.opened?n.close():n.open(e)}),n.options.nativeOnMobile&&n.utils.isMobile()||(n.$element.on("focus"+l,function(){n.elements.input.focus()}),n.elements.input.prop({tabindex:n.originalTabindex,disabled:!1}).on("keydown"+l,p.proxy(n.handleKeys,n)).on("focusin"+l,function(e){n.elements.outerWrapper.addClass(n.classes.focus),n.elements.input.one("blur",function(){n.elements.input.blur()}),n.options.openOnFocus&&!n.state.opened&&n.open(e)}).on("focusout"+l,function(){n.elements.outerWrapper.removeClass(n.classes.focus)}).on("input propertychange",function(){var e=n.elements.input.val(),i=new RegExp("^"+n.utils.escapeRegExp(e),"i");clearTimeout(n.resetStr),n.resetStr=setTimeout(function(){n.elements.input.val("")},n.options.keySearchTimeout),e.length&&p.each(n.items,function(e,t){if(!t.disabled){if(i.test(t.text)||i.test(t.slug))return n.highlight(e),!1;if(t.alt)for(var s=t.alt.split("|"),l=0;l<s.length&&s[l];l++)if(i.test(s[l].trim()))return n.highlight(e),!1}})})),n.$li.on({mousedown:function(e){e.preventDefault(),e.stopPropagation()},click:function(){return n.select(p(this).data("index")),!1}})},handleKeys:function(e){var t=this,s=e.which,l=t.options.keys,i=-1<p.inArray(s,l.previous),n=-1<p.inArray(s,l.next),o=-1<p.inArray(s,l.select),a=-1<p.inArray(s,l.open),r=t.state.highlightedIdx,u=i&&0===r||n&&r+1===t.items.length,c=0;if(13!==s&&32!==s||e.preventDefault(),i||n){if(!t.options.allowWrap&&u)return;i&&(c=t.utils.previousEnabledItem(t.lookupItems,r)),n&&(c=t.utils.nextEnabledItem(t.lookupItems,r)),t.highlight(c)}if(o&&t.state.opened)return t.select(r),void(t.state.multiple&&t.options.multiple.keepMenuOpen||t.close());a&&!t.state.opened&&t.open()},refresh:function(){this.populate(),this.activate(),this.utils.triggerCallback("Refresh",this)},setOptionsDimensions:function(){var e=this,t=e.elements.items.closest(":visible").children(":hidden").addClass(e.classes.tempshow),s=e.options.maxHeight,l=e.elements.items.outerWidth(),i=e.elements.wrapper.outerWidth()-(l-e.elements.items.width());!e.options.expandToItemText||l<i?e.finalWidth=i:(e.elements.items.css("overflow","scroll"),e.elements.outerWrapper.width(9e4),e.finalWidth=e.elements.items.width(),e.elements.items.css("overflow",""),e.elements.outerWrapper.width("")),e.elements.items.width(e.finalWidth).height()>s&&e.elements.items.height(s),t.removeClass(e.classes.tempshow)},isInViewport:function(){var e,t,s,l,i,n,o,a=this;!0===a.options.forceRenderAbove?a.elements.outerWrapper.addClass(a.classes.above):!0===a.options.forceRenderBelow?a.elements.outerWrapper.addClass(a.classes.below):(e=r.scrollTop(),t=r.height(),l=(s=a.elements.outerWrapper.offset().top)+a.elements.outerWrapper.outerHeight()+a.itemsHeight<=e+t,i=s-a.itemsHeight>e,o=!(n=!l&&i),a.elements.outerWrapper.toggleClass(a.classes.above,n),a.elements.outerWrapper.toggleClass(a.classes.below,o))},detectItemVisibility:function(e){var t=this,s=t.$li.filter("[data-index]");t.state.multiple&&(e=p.isArray(e)&&0===e.length?0:e,e=p.isArray(e)?Math.min.apply(Math,e):e);var l=s.eq(e).outerHeight(),i=s[e].offsetTop,n=t.elements.itemsScroll.scrollTop(),o=i+2*l;t.elements.itemsScroll.scrollTop(o>n+t.itemsHeight?o-t.itemsHeight:i-l<n?i-l:n)},open:function(e){var i=this;if(i.options.nativeOnMobile&&i.utils.isMobile())return!1;i.utils.triggerCallback("BeforeOpen",i),e&&(e.preventDefault(),i.options.stopPropagation&&e.stopPropagation()),i.state.enabled&&(i.setOptionsDimensions(),p("."+i.classes.hideselect,"."+i.classes.open).children()[u]("close"),i.state.opened=!0,i.itemsHeight=i.elements.items.outerHeight(),i.itemsInnerHeight=i.elements.items.height(),i.elements.outerWrapper.addClass(i.classes.open),i.elements.input.val(""),e&&"focusin"!==e.type&&i.elements.input.focus(),setTimeout(function(){t.on("click"+l,p.proxy(i.close,i)).on("scroll"+l,p.proxy(i.isInViewport,i))},1),i.isInViewport(),i.options.preventWindowScroll&&t.on("mousewheel.sl DOMMouseScroll"+l,"."+i.classes.scroll,function(e){var t=e.originalEvent,s=p(this).scrollTop(),l=0;"detail"in t&&(l=-1*t.detail),"wheelDelta"in t&&(l=t.wheelDelta),"wheelDeltaY"in t&&(l=t.wheelDeltaY),"deltaY"in t&&(l=-1*t.deltaY),(s===this.scrollHeight-i.itemsInnerHeight&&l<0||0===s&&0<l)&&e.preventDefault()}),i.detectItemVisibility(i.state.selectedIdx),i.highlight(i.state.multiple?-1:i.state.selectedIdx),i.utils.triggerCallback("Open",i))},close:function(){var e=this;e.utils.triggerCallback("BeforeClose",e),t.off(l),e.elements.outerWrapper.removeClass(e.classes.open),e.state.opened=!1,e.utils.triggerCallback("Close",e)},change:function(){var s=this;s.utils.triggerCallback("BeforeChange",s),s.state.multiple?(p.each(s.lookupItems,function(e){s.lookupItems[e].selected=!1,s.$element.find("option").prop("selected",!1)}),p.each(s.state.selectedIdx,function(e,t){s.lookupItems[t].selected=!0,s.$element.find("option").eq(t).prop("selected",!0)}),s.state.currValue=s.state.selectedIdx,s.setLabel(),s.utils.triggerCallback("Change",s)):s.state.currValue!==s.state.selectedIdx&&(s.$element.prop("selectedIndex",s.state.currValue=s.state.selectedIdx).data("value",s.lookupItems[s.state.selectedIdx].text),s.setLabel(),s.utils.triggerCallback("Change",s))},highlight:function(e){var t=this,s=t.$li.filter("[data-index]").removeClass("highlighted");t.utils.triggerCallback("BeforeHighlight",t),void 0===e||-1===e||t.lookupItems[e].disabled||(s.eq(t.state.highlightedIdx=e).addClass("highlighted"),t.detectItemVisibility(e),t.utils.triggerCallback("Highlight",t))},select:function(e){var t,s=this,l=s.$li.filter("[data-index]");s.utils.triggerCallback("BeforeSelect",s,e),void 0===e||-1===e||s.lookupItems[e].disabled||(s.state.multiple?(s.state.selectedIdx=p.isArray(s.state.selectedIdx)?s.state.selectedIdx:[s.state.selectedIdx],-1!==(t=p.inArray(e,s.state.selectedIdx))?s.state.selectedIdx.splice(t,1):s.state.selectedIdx.push(e),l.removeClass("selected").filter(function(e){return-1!==p.inArray(e,s.state.selectedIdx)}).addClass("selected")):l.removeClass("selected").eq(s.state.selectedIdx=e).addClass("selected"),s.state.multiple&&s.options.multiple.keepMenuOpen||s.close(),s.change(),s.utils.triggerCallback("Select",s,e))},destroy:function(e){var t=this;t.state&&t.state.enabled&&(t.elements.items.add(t.elements.wrapper).add(t.elements.input).remove(),e||t.$element.removeData(u).removeData("value"),t.$element.prop("tabindex",t.originalTabindex).off(l).off(t.eventTriggers).unwrap().unwrap(),t.state.enabled=!1)}},p.fn[u]=function(t){return this.each(function(){var e=p.data(this,u);e&&!e.disableOnMobile?"string"==typeof t&&e[t]?e[t]():e.init(t):p.data(this,u,new s(this,t))})},p.fn[u].defaults={onChange:function(e){p(e).change()},maxHeight:300,keySearchTimeout:500,arrowButtonMarkup:'<b class="button">&#x25be;</b>',disableOnMobile:!1,nativeOnMobile:!0,openOnFocus:!0,openOnHover:!1,hoverIntentTimeout:500,expandToItemText:!1,responsive:!1,preventWindowScroll:!0,inheritOriginalWidth:!1,allowWrap:!0,forceRenderAbove:!1,forceRenderBelow:!1,stopPropagation:!0,optionsItemBuilder:"{text}",labelBuilder:"{text}",listBuilder:!1,keys:{previous:[37,38],next:[39,40],select:[9,13,27],open:[13,32,37,38,39,40],close:[9,27]},customClass:{prefix:u,camelCase:!1},multiple:{separator:", ",keepMenuOpen:!0,maxLabelEntries:!1}}}),function(s){"function"==typeof define&&define.amd?define(["jquery"],s):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),s(t),t}:s(jQuery)}(function(i){"use strict";i.fn.selectric||i.error("Selectric not initialized"),i.fn.selectricPlaceholder=function(s){return this.each(function(){var e=i(this),t=e.data("selectric"),l=i.extend({placeholderOnOpen:!0},s);t.elements.label.html(t.$element.attr("placeholder")),e.on("selectric-before-open",function(e,t,s){l.placeholderOnOpen&&s.elements.label.data("value",s.elements.label.html()).html(s.$element.attr("placeholder"))}),e.on("selectric-before-close",function(e,t,s){l.placeholderOnOpen&&s.elements.label.html(s.elements.label.data("value"))})})}}),function(s){"function"==typeof define&&define.amd?define(["jquery"],s):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),s(t),t}:s(jQuery)}(function(r){"use strict";r.fn.selectric||r.error("Selectric not initialized"),r.fn.selectricAddNew=function(a){return this.each(function(){var t,s,l=r(this).data("selectric"),i=r.extend({createNewAutoSelect:!0,createNewMarkup:'<input type="text" /><button>Create</button>',allowCreateNew:!0,createNewCallback:r.noop,createNewError:function(){r.error("Title required.")}},a),n=l.$element,e=l.elements.itemsScroll,o=r("<div/>",{class:"create-new",html:i.createNewMarkup});i.allowCreateNew&&(e.prepend(o),t=o.find("input[type=text]"),s=o.find("button"),t.add(s).on("click",function(e){e.preventDefault(),e.stopPropagation()}),s.on("click",function(){var e;t.val()?(e=t.val(),n.append(r("<option>",{value:e,text:e})),i.createNewAutoSelect&&n.prop("selectedIndex",n.children().length-1),l.refresh(),l.open(),i.createNewCallback.call(l.element,e),t.add(s).off("click")):i.createNewError.call(l.element)}))})}});