!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(n){var e=function(){if(n&&n.fn&&n.fn.select2pocztapolska&&n.fn.select2pocztapolska.amd)var e=n.fn.select2pocztapolska.amd;var t,s,c;return e&&e.requirejs||(e?s=e:e={},function(d){function h(e,t){return n.call(e,t)}function r(e,t){var n,o,s,i,r,a,l,c,p,u,d,h=t&&t.split("/"),f=$.map,g=f&&f["*"]||{};if(e&&"."===e.charAt(0))if(t){for(r=(e=e.split("/")).length-1,$.nodeIdCompat&&b.test(e[r])&&(e[r]=e[r].replace(b,"")),e=h.slice(0,h.length-1).concat(e),p=0;p":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},e.appendMany=function(e,t){if("1.7"===i.fn.jquery.substr(0,3)){var n=i();i.map(t,function(e){n=n.add(e)}),t=n}e.append(t)},e}),e.define("select2pocztapolska/results",["jquery","./utils"],function(d,e){function o(e,t,n){this.$element=e,this.data=n,this.options=t,o.__super__.constructor.call(this)}return e.Extend(o,e.Observable),o.prototype.render=function(){var e=d('');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},o.prototype.clear=function(){this.$results.empty()},o.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=d('
  • '),o=this.options.get("translations").get(e.message);n.append(t(o(e.args))),n[0].className+=" select2pocztapolska-results__message",this.$results.append(n)},o.prototype.hideMessages=function(){this.$results.find(".select2pocztapolska-results__message").remove()},o.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n",{class:"select2pocztapolska-results__options select2pocztapolska-results__options--nested"});u.append(a),i.append(r),i.append(u)}else this.template(e,t);return d.data(t,"data",e),t},o.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=e.data("data");"true"==e.attr("aria-selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e);if(0!==n){var o=n-1;0===e.length&&(o=0);var s=t.eq(o);s.trigger("mouseenter");var i=l.$results.offset().top,r=s.offset().top,a=l.$results.scrollTop()+(r-i);0===o?l.$results.scrollTop(0):r-i<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var o=t.eq(n);o.trigger("mouseenter");var s=l.$results.offset().top+l.$results.outerHeight(!1),i=o.offset().top+o.outerHeight(!1),r=l.$results.scrollTop()+i-s;0===n?l.$results.scrollTop(0):sthis.$results.outerHeight()||i<0)&&this.$results.scrollTop(s)}},o.prototype.template=function(e,t){var n=this.options.get("templateResult"),o=this.options.get("escapeMarkup"),s=n(e,t);null==s?t.style.display="none":"string"==typeof s?t.innerHTML=o(s):d(t).append(s)},o}),e.define("select2pocztapolska/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("select2pocztapolska/selection/base",["jquery","../utils","../keys"],function(n,e,s){function o(e,t){this.$element=e,this.options=t,o.__super__.constructor.call(this)}return e.Extend(o,e.Observable),o.prototype.render=function(){var e=n('');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),this.$selection=e},o.prototype.bind=function(e,t){var n=this,o=(e.id,e.id+"-results");this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===s.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",o),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),n.$selection.focus(),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex)}),e.on("disable",function(){n.$selection.attr("tabindex","-1")})},o.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||n.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},o.prototype._attachCloseHandler=function(e){n(document.body).on("mousedown.select2pocztapolska."+e.id,function(e){var t=n(e.target).closest(".select2pocztapolska");n(".select2pocztapolska.select2pocztapolska-container--open").each(function(){var e=n(this);this!=t[0]&&e.data("element").select2pocztapolska("close")})})},o.prototype._detachCloseHandler=function(e){n(document.body).off("mousedown.select2pocztapolska."+e.id)},o.prototype.position=function(e,t){t.find(".selection").append(e)},o.prototype.destroy=function(){this._detachCloseHandler(this.container)},o.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},o}),e.define("select2pocztapolska/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,o){function s(){s.__super__.constructor.apply(this,arguments)}return n.Extend(s,t),s.prototype.render=function(){var e=s.__super__.render.call(this);return e.addClass("select2pocztapolska-selection--single"),e.html(''),e},s.prototype.bind=function(t,e){var n=this;s.__super__.bind.apply(this,arguments);var o=t.id+"-container";this.$selection.find(".select2pocztapolska-selection__rendered").attr("id",o),this.$selection.attr("aria-labelledby",o),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.focus()}),t.on("selection:update",function(e){n.update(e.data)})},s.prototype.clear=function(){this.$selection.find(".select2pocztapolska-selection__rendered").empty()},s.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},s.prototype.selectionContainer=function(){return e("")},s.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".select2pocztapolska-selection__rendered"),o=this.display(t,n);n.empty().append(o),n.prop("title",t.title||t.text)}else this.clear()},s}),e.define("select2pocztapolska/selection/multiple",["jquery","./base","../utils"],function(o,e,a){function s(e,t){s.__super__.constructor.apply(this,arguments)}return a.Extend(s,e),s.prototype.render=function(){var e=s.__super__.render.call(this);return e.addClass("select2pocztapolska-selection--multiple"),e.html('
      '),e},s.prototype.bind=function(e,t){var n=this;s.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){n.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2pocztapolska-selection__choice__remove",function(e){if(!n.options.get("disabled")){var t=o(this).parent().data("data");n.trigger("unselect",{originalEvent:e,data:t})}})},s.prototype.clear=function(){this.$selection.find(".select2pocztapolska-selection__rendered").empty()},s.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},s.prototype.selectionContainer=function(){return o('
    • ×
    • ')},s.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n×');n.data("data",t),this.$selection.find(".select2pocztapolska-selection__rendered").prepend(n)}},e}),e.define("select2pocztapolska/selection/search",["jquery","../utils","../keys"],function(o,e,r){function t(e,t,n){e.call(this,t,n)}return t.prototype.render=function(e){var t=o('');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,t,n){var o=this;e.call(this,t,n),t.on("open",function(){o.$search.trigger("focus")}),t.on("close",function(){o.$search.val(""),o.$search.removeAttr("aria-activedescendant"),o.$search.trigger("focus")}),t.on("enable",function(){o.$search.prop("disabled",!1),o._transferTabIndex()}),t.on("disable",function(){o.$search.prop("disabled",!0)}),t.on("focus",function(e){o.$search.trigger("focus")}),t.on("results:focus",function(e){o.$search.attr("aria-activedescendant",e.id)}),this.$selection.on("focusin",".select2pocztapolska-search--inline",function(e){o.trigger("focus",e)}),this.$selection.on("focusout",".select2pocztapolska-search--inline",function(e){o._handleBlur(e)}),this.$selection.on("keydown",".select2pocztapolska-search--inline",function(e){if(e.stopPropagation(),o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented(),e.which===r.BACKSPACE&&""===o.$search.val()){var t=o.$searchContainer.prev(".select2pocztapolska-selection__choice");if(0this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):void e.call(this,t,n)},e}),e.define("select2pocztapolska/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,o,s){var i=this;this.current(function(e){var t=null!=e?e.length:0;return 0=i.maximumSelectionLength?void i.trigger("results:message",{message:"maximumSelected",args:{maximum:i.maximumSelectionLength}}):void n.call(i,o,s)})},e}),e.define("select2pocztapolska/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2pocztapolska/dropdown/search",["jquery","../utils"],function(s,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=s('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var o=this;e.call(this,t,n),this.$search.on("keydown",function(e){o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){s(this).off("keyup")}),this.$search.on("keyup input",function(e){o.handleSearch(e)}),t.on("open",function(){o.$search.attr("tabindex",0),o.$search.focus(),window.setTimeout(function(){o.$search.focus()},0)}),t.on("close",function(){o.$search.attr("tabindex",-1),o.$search.val("")}),t.on("focus",function(){t.isOpen()&&o.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(o.showSearch(e)?o.$searchContainer.removeClass("select2pocztapolska-search--hide"):o.$searchContainer.addClass("select2pocztapolska-search--hide"))})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2pocztapolska/dropdown/hidePlaceholder",[],function(){function e(e,t,n,o){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,o)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),o=t.length-1;0<=o;o--){var s=t[o];this.placeholder.id===s.id&&n.splice(o,1)}return n},e}),e.define("select2pocztapolska/dropdown/infiniteScroll",["jquery"],function(s){function e(e,t,n,o){this.lastParams={},e.call(this,t,n,o),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var o=this;e.call(this,t,n),t.on("query",function(e){o.lastParams=e,o.loading=!0}),t.on("query:append",function(e){o.lastParams=e,o.loading=!0}),this.$results.on("scroll",function(){var e=s.contains(document.documentElement,o.$loadingMore[0]);!o.loading&&e&&o.$results.offset().top+o.$results.outerHeight(!1)+50>=o.$loadingMore.offset().top+o.$loadingMore.outerHeight(!1)&&o.loadMore()})},e.prototype.loadMore=function(){this.loading=!0;var e=s.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=s('
    • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2pocztapolska/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var o=this,s=!1;e.call(this,t,n),t.on("open",function(){o._showDropdown(),o._attachPositioningHandler(t),s||(s=!0,t.on("results:all",function(){o._positionDropdown(),o._resizeDropdown()}),t.on("results:append",function(){o._positionDropdown(),o._resizeDropdown()}))}),t.on("close",function(){o._hideDropdown(),o._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2pocztapolska"),t.addClass("select2pocztapolska-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,o="scroll.select2pocztapolska."+t.id,s="resize.select2pocztapolska."+t.id,i="orientationchange.select2pocztapolska."+t.id,r=this.$container.parents().filter(a.hasScroll);r.each(function(){f(this).data("select2pocztapolska-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),r.on(o,function(e){var t=f(this).data("select2pocztapolska-scroll-position");f(this).scrollTop(t.y)}),f(window).on(o+" "+s+" "+i,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2pocztapolska."+t.id,o="resize.select2pocztapolska."+t.id,s="orientationchange.select2pocztapolska."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+o+" "+s)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2pocztapolska-dropdown--above"),n=this.$dropdown.hasClass("select2pocztapolska-dropdown--below"),o=null,s=this.$container.offset();s.bottom=s.top+this.$container.outerHeight(!1);var i={height:this.$container.outerHeight(!1)};i.top=s.top,i.bottom=s.top+i.height;var r=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=as.bottom+r,u={left:s.left,top:i.bottom},d=this.$dropdownParent;"static"===d.css("position")&&(d=d.offsetParent());var h=d.offset();u.top-=h.top,u.left-=h.left,t||n||(o="below"),p||!c||t?!c&&p&&t&&(o="below"):o="above",("above"==o||t&&"below"!==o)&&(u.top=i.top-h.top-r),null!=o&&(this.$dropdown.removeClass("select2pocztapolska-dropdown--below select2pocztapolska-dropdown--above").addClass("select2pocztapolska-dropdown--"+o),this.$container.removeClass("select2pocztapolska-container--below select2pocztapolska-container--above").addClass("select2pocztapolska-container--"+o)),this.$dropdownContainer.css(u)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2pocztapolska/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,o){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,o)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,o=0;o');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2pocztapolska-container--"+this.options.get("theme")),e.data("element",this.$element),e},p}),e.define("jquery-mousewheel",["jquery"],function(e){return e}),e.define("jquery.select2pocztapolska",["jquery","jquery-mousewheel","./select2pocztapolska/core","./select2pocztapolska/defaults"],function(s,e,i,t){if(null==s.fn.select2pocztapolska){var r=["open","close","destroy"];s.fn.select2pocztapolska=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=s.extend(!0,{},t);new i(s(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,o=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=s(this).data("select2pocztapolska");null==e&&window.console&&console.error&&console.error("The select2pocztapolska('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,o)}),-1