Choices/assets/scripts/dist/bundle.js
2016-04-17 11:23:38 +01:00

1 line
28 KiB
JavaScript

!function(e){function t(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return e[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var n={};return t.m=e,t.c=n,t.p="/assets/scripts/dist/",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.Choices=void 0;var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=n(2),a=n(13),l=i(a),c=n(17),u=n(18),d=t.Choices=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?"[data-choice]":arguments[0],n=arguments[1];s(this,e);var i=document.createElement("fakeel"),o=n||{};if((0,u.isType)("String",t)){var a=document.querySelectorAll(t);if(a.length>1)for(var c=1;c<a.length;c++){var d=a[c];new e(d,n)}}var h={items:[],addItems:!0,removeItems:!0,editItems:!1,maxItems:!1,delimiter:",",allowDuplicates:!0,allowPaste:!0,regexFilter:!1,debug:!1,placeholder:!0,placeholderValue:"",prependValue:!1,appendValue:!1,selectAll:!0,classNames:{containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--items",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemOption:"choices__item--option",group:"choices__group",groupHeading:"choices__heading",activeState:"is-active",disabledState:"is-disabled",hiddenState:"is-hidden",selectedState:"is-selected"},callbackOnInit:function(){},callbackOnRender:function(){},callbackOnRemoveItem:function(){},callbackOnAddItem:function(){}};this.initialised=!1,this.options=(0,u.extend)(h,o||{}),this.store=(0,r.createStore)(l.default),this.supports="querySelector"in document&&"addEventListener"in document&&"classList"in i,this.passedElement=(0,u.isType)("String",t)?document.querySelector(t):t,this.presetItems=[],this.options.items.length?this.presetItems=this.options.items:""!==this.passedElement.value&&(this.presetItems=this.passedElement.value.split(this.options.delimiter)),this.init=this.init.bind(this),this.render=this.render.bind(this),this.destroy=this.destroy.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onClick=this.onClick.bind(this),this.onPaste=this.onPaste.bind(this),this.init()}return o(e,[{key:"isDisabled",value:function(){return!!this.input.disabled}},{key:"isEmpty",value:function(){return 0===this.store.getState().items.length}},{key:"hasSelectedItems",value:function(){var e=this.getItems();return e.some(function(e){return e.selected===!0})}},{key:"handleSelectAll",value:function(){this.options.removeItems&&!this.input.value&&this.options.selectAll&&this.input===document.activeElement&&this.selectAll(this.list.children)}},{key:"handleEnter",value:function(e,t){var n=!0;if(this.options.addItems?this.options.maxItems&&this.options.maxItems<=this.list.children.length?n=!1:this.options.allowDuplicates===!1&&this.passedElement.value&&(n=!e.some(function(e){return e.value===t})):n=!1,n&&"text"===this.passedElement.type){var i=!0;this.options.regexFilter&&(i=this.regexFilter(t)),i&&(this.addItem(t),this.clearInput(this.passedElement))}}},{key:"handleBackspaceKey",value:function(e){if(this.options.removeItems&&e){var t=e[e.length-1],n=e.some(function(e){return e.selected===!0});this.options.editItems&&!n?(this.input.value=t.value,this.removeItem(t)):this.removeAllSelectedItems()}}},{key:"handleClick",value:function(e,t){var n=this;this.options.removeItems&&t&&!function(){var i=t.getAttribute("data-choice-id");e.forEach(function(e){e.id!==parseInt(i)||e.selected?n.deselectItem(e):n.selectItem(e)})}()}},{key:"onKeyDown",value:function(e){var t=this.getItemsFilteredByActive(),n=this.input===document.activeElement,i=(this.getItems(),e.ctrlKey||e.metaKey),s=8,o=13,r=65;if(e.target===this.input&&(i&&e.keyCode===r&&this.list&&this.list.children&&this.handleSelectAll(),e.keyCode===o&&e.target.value)){var a=this.input.value;this.handleEnter(t,a)}n&&(e.keyCode!==s||e.target.value||(this.handleBackspaceKey(t),e.preventDefault()))}},{key:"onClick",value:function(e){var t=this;if(this.dropdown&&this.toggleDropdown(),this.containerOuter.contains(e.target))if(this.input!==document.activeElement&&this.input.focus(),e.target.hasAttribute("data-choice-item")){var n=this.getItemsFilteredByActive(),i=e.target;this.handleClick(n,i)}else e.target.hasAttribute("data-choice-selectable")&&!function(){var n=t.getOptions(),i=e.target.getAttribute("data-choice-id"),s=n.find(function(e){return e.id===parseInt(i)});s.selected||(t.selectOption(i,!0),t.addItem(s.value,s.label,s.id))}();else this.hasSelectedItems()&&this.deselectAll(),this.dropdown&&this.dropdown.classList.contains(this.options.classNames.activeState)&&this.toggleDropdown()}},{key:"onPaste",value:function(e){this.options.allowPaste||e.preventDefault()}},{key:"clearInput",value:function(){this.input.value&&(this.input.value="")}},{key:"regexFilter",value:function(e){var t=new RegExp(this.options.regexFilter,"i"),n=t.test(e);return n}},{key:"getItemById",value:function(e){if(!e||!(0,u.isType)("Number",e))return void console.error("getItemById: An id was not given or was not a number");var t=this.getItems(),n=t.find(function(t){return t.id===parseInt(e)}),i=this.list.querySelector("[data-choice-id='"+n.id+"']");return i}},{key:"selectItem",value:function(e){if(e){var t=e.id;this.store.dispatch((0,c.selectItem)(t,!0))}}},{key:"deselectItem",value:function(e){if(e){var t=e.id;this.store.dispatch((0,c.selectItem)(t,!1))}}},{key:"selectAll",value:function(){var e=this,t=this.getItems();t.forEach(function(t){e.selectItem(t)})}},{key:"deselectAll",value:function(){var e=this,t=this.getItems();t.forEach(function(t){e.deselectItem(t)})}},{key:"selectOption",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];e&&this.store.dispatch((0,c.selectOption)(e,t))}},{key:"addItem",value:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?-1:arguments[2],i=arguments.length<=3||void 0===arguments[3]?this.options.callbackOnAddItem:arguments[3];this.options.debug&&console.debug("Add item");var s=e.trim(),o=t||s;this.options.prependValue&&(s=this.options.prependValue+s.toString()),this.options.appendValue&&(s+=this.options.appendValue.toString());var r=this.store.getState().items.length+1;this.dropdown&&this.dropdown.classList.contains("is-active")&&this.toggleDropdown(),i&&((0,u.isType)("Function",i)?i(r,e):console.error("callbackOnAddItem: Callback is not a function")),this.store.dispatch((0,c.addItem)(s,o,r,n))}},{key:"removeItem",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?this.options.callbackOnRemoveItem:arguments[1];if(!e)return void console.error("removeItem: No item or value was passed to be removed");var n=e.id,i=e.value,s=e.optionId;t&&((0,u.isType)("Function",t)?t(i):console.error("callbackOnRemoveItem: Callback is not a function")),this.store.dispatch((0,c.removeItem)(n,s))}},{key:"removeAllItems",value:function(){var e=this,t=this.getItems();t.forEach(function(t){t.active&&e.removeItem(t)})}},{key:"removeAllSelectedItems",value:function(){var e=this,t=this.getItems();t.forEach(function(t){t.selected&&t.active&&e.removeItem(t)})}},{key:"toggleDropdown",value:function(){if(!this.dropdown)return void console.error("No dropdown set");var e=this.dropdown.classList.contains("is-active");this.dropdown.classList[e?"remove":"add"]("is-active")}},{key:"addOption",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?-1:arguments[1],n=this.store.getState(),i=n.options.length+1,s=e.value,o=e.innerHTML,r=e.selected;this.store.dispatch((0,c.addOption)(s,o,i,t)),r&&(this.selectOption(i),this.addItem(s,o,i))}},{key:"addGroup",value:function(e,t){this.store.dispatch((0,c.addGroup)(e,t))}},{key:"getItems",value:function(){var e=this.store.getState();return e.items}},{key:"getItemsFilteredByActive",value:function(){var e=this.getItems(),t=e.filter(function(e){return e.active===!0},[]);return t}},{key:"getItemsReducedToValues",value:function(){var e=this.getItems(),t=e.reduce(function(e,t){return e.push(t.value),e},[]);return t}},{key:"getOptions",value:function(){var e=this.store.getState();return e.options}},{key:"getGroups",value:function(){var e=this.store.getState();return e.groups}},{key:"generateTextInput",value:function(){var e=this,t=(0,u.strToEl)('<div class="'+this.options.classNames.containerOuter+'"></div>'),n=(0,u.strToEl)('<div class="'+this.options.classNames.containerInner+'"></div>');this.passedElement.classList.add(this.options.classNames.input,this.options.classNames.hiddenState),this.passedElement.tabIndex="-1",this.passedElement.setAttribute("style","display:none;"),this.passedElement.setAttribute("aria-hidden","true"),(0,u.wrap)(this.passedElement,n),(0,u.wrap)(n,t);var i=(0,u.strToEl)('<ul class="'+this.options.classNames.list+" "+this.options.classNames.listItems+'"></ul>'),s=(0,u.strToEl)('<input type="text" class="'+this.options.classNames.input+" "+this.options.classNames.inputCloned+'">');if(this.options.placeholder){var o=this.options.placeholderValue||this.passedElement.placeholder;o&&(s.placeholder=o,s.style.width=(0,u.getWidthOfInput)(s))}this.options.addItems||(s.disabled=!0,t.classList.add(this.options.classNames.disabledState)),t.appendChild(n),n.appendChild(i),n.appendChild(s),this.containerOuter=t,this.containerInner=n,this.input=s,this.list=i,this.presetItems.forEach(function(t){e.addItem(t)}),this.store.subscribe(this.render),this.render(),this.addEventListeners()}},{key:"generateMultipleSelectInput",value:function(){var e=this,t=(0,u.strToEl)('<div class="'+this.options.classNames.containerOuter+'"></div>'),n=(0,u.strToEl)('<div class="'+this.options.classNames.containerInner+'"></div>');this.passedElement.classList.add(this.options.classNames.input,this.options.classNames.hiddenState),this.passedElement.tabIndex="-1",this.passedElement.setAttribute("style","display:none;"),this.passedElement.setAttribute("aria-hidden","true"),(0,u.wrap)(this.passedElement,n),(0,u.wrap)(n,t);var i=(0,u.strToEl)('<ul class="'+this.options.classNames.list+" "+this.options.classNames.listItems+'"></ul>'),s=(0,u.strToEl)('<input type="text" class="'+this.options.classNames.input+" "+this.options.classNames.inputCloned+'">'),o=(0,u.strToEl)('<div class="'+this.options.classNames.list+" "+this.options.classNames.listDropdown+'"></div>');this.options.placeholder&&this.options.placeholderValue&&(s.placeholder=this.options.placeholderValue,s.style.width=(0,u.getWidthOfInput)(s)),this.options.addItems||(s.disabled=!0),t.appendChild(n),t.appendChild(o),n.appendChild(i),n.appendChild(s),this.containerOuter=t,this.containerInner=n,this.input=s,this.list=i,this.dropdown=o;var r=Array.from(this.passedElement.getElementsByTagName("OPTGROUP"));if(r.length)r.forEach(function(t,n){var i=Array.from(t.getElementsByTagName("OPTION")),s=n;e.addGroup(t.label,s),i.forEach(function(t){e.addOption(t,s)})});else{var a=Array.from(this.passedElement.options);a.forEach(function(t){e.addOption(t)})}this.store.subscribe(this.render),this.render(),this.addEventListeners()}},{key:"addEventListeners",value:function(){document.addEventListener("keydown",this.onKeyDown),document.addEventListener("click",this.onClick),document.addEventListener("paste",this.onPaste)}},{key:"removeEventListeners",value:function(){document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("click",this.onClick),document.removeEventListener("paste",this.onPaste)}},{key:"observeStore",value:function(e,t,n){function i(){var i=t(e.getState());i!==s&&(s=i,n(s))}var s=void 0,o=e.subscribe(i);return i(),o}},{key:"render",value:function(){var e=this,t=arguments.length<=0||void 0===arguments[0]?this.options.callbackOnRender:arguments[0],n=this.options.classNames,i=this.getItems(),s=this.getOptions(),o=this.getGroups();this.dropdown&&!function(){e.dropdown.innerHTML="";var t=document.createDocumentFragment();if(o.length)o.forEach(function(e){var i=(0,u.strToEl)('\n <div class="'+n.group+" "+(e.disabled?n.itemDisabled:"")+'" data-choice-value="'+e.value+'" data-choice-group-id="'+e.id+'">\n <div class="'+n.groupHeading+'">'+e.value+"</div>\n </div>\n "),o=s.filter(function(t){return t.groupId===e.id});if(o)o.forEach(function(e){var t=(0,u.strToEl)('\n <div class="'+n.item+" "+n.itemOption+" "+(e.selected?n.selectedState+" "+n.itemDisabled:n.itemSelectable)+'" data-choice-selectable data-choice-id="'+e.id+'" data-choice-value="'+e.value+'">\n '+e.label+"\n </div>\n ");i.appendChild(t)});else{var r=(0,u.strToEl)('<div class="'+n.item+'">No options to select</div>');i.appendChild(r)}t.appendChild(i)});else if(s)s.forEach(function(e){var i=(0,u.strToEl)('\n <div class="'+n.item+" "+n.itemOption+" "+(e.selected?n.selectedState+" "+n.itemDisabled:n.itemSelectable)+'" data-choice-selectable data-choice-id="'+e.id+'" data-choice-value="'+e.value+'">\n '+e.label+"\n </div>\n ");t.appendChild(i)});else{var i=(0,u.strToEl)('<div class="'+n.item+'">No options to select</div>');t.appendChild(i)}e.dropdown.appendChild(t)}();var r=this.getItemsReducedToValues();this.passedElement.value=r.join(this.options.delimiter),this.list.innerHTML="";var a=document.createDocumentFragment();i.forEach(function(t){if(t.active){var i=(0,u.strToEl)('\n <li class="'+n.item+" "+(e.options.removeItems?n.itemSelectable:"")+" "+(t.selected?n.selectedState:"")+'" data-choice-item data-choice-id="'+t.id+'" data-choice-selected="'+t.selected+'">\n '+t.label+"\n </li>\n ");a.appendChild(i)}}),this.list.appendChild(a),t&&((0,u.isType)("Function",t)?t(i,s,o):console.error("callbackOnRender: Callback is not a function"))}},{key:"renderInput",value:function(e){switch(this.options.debug&&console.debug("Render"),e.type){case"text":this.generateTextInput();break;case"select-one":break;case"select-multiple":this.generateMultipleSelectInput();break;default:this.generateMultipleSelectInput()}}},{key:"init",value:function(){var e=arguments.length<=0||void 0===arguments[0]?this.options.callbackOnInit:arguments[0];this.supports||console.error("init: Your browser doesn'nt support shit"),this.initialised=!0,this.renderInput(this.passedElement),e&&((0,u.isType)("Function",e)?e():console.error("callbackOnInit: Callback is not a function"))}},{key:"destroy",value:function(){this.options=null,this.passedElement=null,this.initialised=null}}]),e}();document.addEventListener("DOMContentLoaded",function(){var e=document.getElementById("choices-1"),t=(new d(e,{delimiter:" ",editItems:!0,maxItems:5}),new d("#choices-2",{allowPaste:!1,allowDuplicates:!1,editItems:!0}),new d("#choices-3",{allowDuplicates:!1,editItems:!0,regexFilter:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/}),new d("#choices-4",{addItems:!1,removeItems:!1}),new d("#choices-5",{prependValue:"item-",appendValue:"-"+Date.now()}));t.removeAllItems();new d("#choices-6",{items:["josh@joshuajohnson.co.uk","joe@bloggs.co.uk"]}),new d("#choices-7",{}),new d("[data-choice]",{placeholderValue:"This is a placeholder set in the config"})})},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0,t.compose=t.applyMiddleware=t.bindActionCreators=t.combineReducers=t.createStore=void 0;var s=n(3),o=i(s),r=n(8),a=i(r),l=n(10),c=i(l),u=n(11),d=i(u),h=n(12),p=i(h),f=n(9);i(f);t.createStore=o.default,t.combineReducers=a.default,t.bindActionCreators=c.default,t.applyMiddleware=d.default,t.compose=p.default},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function s(e,t,n){function i(){f===p&&(f=p.slice())}function o(){return h}function l(e){if("function"!=typeof e)throw new Error("Expected listener to be a function.");var t=!0;return i(),f.push(e),function(){if(t){t=!1,i();var n=f.indexOf(e);f.splice(n,1)}}}function c(e){if(!(0,r.default)(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if("undefined"==typeof e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(v)throw new Error("Reducers may not dispatch actions.");try{v=!0,h=d(h,e)}finally{v=!1}for(var t=p=f,n=0;n<t.length;n++)t[n]();return e}function u(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");d=e,c({type:a.INIT})}if("function"==typeof t&&"undefined"==typeof n&&(n=t,t=void 0),"undefined"!=typeof n){if("function"!=typeof n)throw new Error("Expected the enhancer to be a function.");return n(s)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var d=e,h=t,p=[],f=p,v=!1;return c({type:a.INIT}),{dispatch:c,subscribe:l,getState:o,replaceReducer:u}}t.__esModule=!0,t.ActionTypes=void 0,t.default=s;var o=n(4),r=i(o),a=t.ActionTypes={INIT:"@@redux/INIT"}},function(e,t,n){function i(e){if(!r(e)||h.call(e)!=a||o(e))return!1;var t=s(e);if(null===t)return!0;var n=u.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&c.call(n)==d}var s=n(5),o=n(6),r=n(7),a="[object Object]",l=Object.prototype,c=Function.prototype.toString,u=l.hasOwnProperty,d=c.call(Object),h=l.toString;e.exports=i},function(e,t){function n(e){return i(Object(e))}var i=Object.getPrototypeOf;e.exports=n},function(e,t){function n(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(n){}return t}e.exports=n},function(e,t){function n(e){return!!e&&"object"==typeof e}e.exports=n},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function s(e,t){var n=t&&t.type,i=n&&'"'+n.toString()+'"'||"an action";return'Reducer "'+e+'" returned undefined handling '+i+". To ignore an action, you must explicitly return the previous state."}function o(e){Object.keys(e).forEach(function(t){var n=e[t],i=n(void 0,{type:a.ActionTypes.INIT});if("undefined"==typeof i)throw new Error('Reducer "'+t+'" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.');var s="@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".");if("undefined"==typeof n(void 0,{type:s}))throw new Error('Reducer "'+t+'" returned undefined when probed with a random type. '+("Don't try to handle "+a.ActionTypes.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined.")})}function r(e){for(var t=Object.keys(e),n={},i=0;i<t.length;i++){var r=t[i];"function"==typeof e[r]&&(n[r]=e[r])}var a,l=Object.keys(n);try{o(n)}catch(c){a=c}return function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=arguments[1];if(a)throw a;for(var i=!1,o={},r=0;r<l.length;r++){var c=l[r],u=n[c],d=e[c],h=u(d,t);if("undefined"==typeof h){var p=s(c,t);throw new Error(p)}o[c]=h,i=i||h!==d}return i?o:e}}t.__esModule=!0,t.default=r;var a=n(3),l=n(4),c=(i(l),n(9));i(c)},function(e,t){"use strict";function n(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(t){}}t.__esModule=!0,t.default=n},function(e,t){"use strict";function n(e,t){return function(){return t(e.apply(void 0,arguments))}}function i(e,t){if("function"==typeof e)return n(e,t);if("object"!=typeof e||null===e)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var i=Object.keys(e),s={},o=0;o<i.length;o++){var r=i[o],a=e[r];"function"==typeof a&&(s[r]=n(a,t))}return s}t.__esModule=!0,t.default=i},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function s(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return function(e){return function(n,i,s){var r=e(n,i,s),l=r.dispatch,c=[],u={getState:r.getState,dispatch:function(e){return l(e)}};return c=t.map(function(e){return e(u)}),l=a.default.apply(void 0,c)(r.dispatch),o({},r,{dispatch:l})}}}var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e};t.__esModule=!0,t.default=s;var r=n(12),a=i(r)},function(e,t){"use strict";function n(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return function(){if(0===t.length)return arguments.length<=0?void 0:arguments[0];var e=t[t.length-1],n=t.slice(0,-1);return n.reduceRight(function(e,t){return t(e)},e.apply(void 0,arguments))}}t.__esModule=!0,t.default=n},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var s=n(2),o=n(14),r=i(o),a=n(15),l=i(a),c=n(16),u=i(c),d=(0,s.combineReducers)({items:r.default,groups:l.default,options:u.default});t.default=d},function(e,t){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=arguments[1];switch(t.type){case"ADD_ITEM":var i=[].concat(n(e),[{id:t.id,optionId:t.optionId,value:t.value,label:t.label,active:!0,selected:!1}]);return i.map(function(e){return e.selected&&(e.selected=!1),e});case"REMOVE_ITEM":return e.map(function(e){return e.id===t.id&&(e.active=!1),e});case"SELECT_ITEM":return e.map(function(e){return e.id===t.id&&(e.selected=t.selected),e});default:return e}};t.default=i},function(e,t){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=arguments[1];switch(t.type){case"ADD_GROUP":return[].concat(n(e),[{id:parseInt(t.id),value:t.value,disabled:!1}]);default:return e}};t.default=i},function(e,t){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){var e=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],t=arguments[1];switch(t.type){case"ADD_OPTION":return[].concat(n(e),[{id:parseInt(t.id),groupId:t.groupId,value:t.value,label:t.label,disabled:!1,selected:!1}]);case"SELECT_OPTION":return e.map(function(e){return e.id===parseInt(t.id)&&(e.selected=t.selected),e});case"REMOVE_ITEM":return t.optionId>-1?e.map(function(e){return e.id===parseInt(t.optionId)&&(e.selected=t.selected),e}):e;default:return e}};t.default=i},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.addItem=function(e,t,n,i){return{type:"ADD_ITEM",value:e,label:t,id:parseInt(n),optionId:parseInt(i)}},t.removeItem=function(e,t){return{type:"REMOVE_ITEM",id:parseInt(e),optionId:parseInt(t)}},t.selectItem=function(e,t){return{type:"SELECT_ITEM",id:parseInt(e),selected:t}},t.addOption=function(e,t,n,i){return{type:"ADD_OPTION",value:e,label:t,id:parseInt(n),groupId:parseInt(i)}},t.selectOption=function(e,t){return{type:"SELECT_OPTION",id:parseInt(e),selected:t}},t.addGroup=function(e,t){return{type:"ADD_GROUP",value:e,id:parseInt(t)}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=(t.hasClass=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},t.capitalise=function(e){return e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})},t.isType=function(e,t){var n=Object.prototype.toString.call(t).slice(8,-1);return void 0!==t&&null!==t&&n===e}),i=(t.extend=function o(){for(var e={},t=!1,i=arguments.length,s=function(i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t&&n("Object",i[s])?e[s]=o(!0,e[s],i[s]):e[s]=i[s])},r=0;i>r;r++){var a=arguments[r];n("Object",a)?s(a):console.error("Custom options must be an object")}return e},t.whichTransitionEvent=function(){var e,t=document.createElement("fakeelement"),n={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in n)if(void 0!==t.style[e])return n[e]},t.whichAnimationEvent=function(){var e,t=document.createElement("fakeelement"),n={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(e in n)if(void 0!==t.style[e])return n[e]}),s=(t.getParentsUntil=function(e,t,n){for(var i=[];e&&e!==document;e=e.parentNode){if(t){var s=t.charAt(0);if("."===s&&e.classList.contains(t.substr(1)))break;if("#"===s&&e.id===t.substr(1))break;if("["===s&&e.hasAttribute(t.substr(1,t.length-1)))break;if(e.tagName.toLowerCase()===t)break}if(n){var o=n.charAt(0);"."===o&&e.classList.contains(n.substr(1))&&i.push(e),"#"===o&&e.id===n.substr(1)&&i.push(e),"["===o&&e.hasAttribute(n.substr(1,n.length-1))&&i.push(e),e.tagName.toLowerCase()===n&&i.push(e)}else i.push(e)}return 0===i.length?null:i},t.wrap=function(e,t){return t=t||document.createElement("div"),e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t),t.appendChild(e)},t.getSiblings=function(e){for(var t=[],n=e.parentNode.firstChild;n;n=n.nextSibling)1===n.nodeType&&n!==e&&t.push(n);return t},t.findAncestor=function(e,t){for(;(e=e.parentElement)&&!e.classList.contains(t););return e},t.debounce=function(e,t,n){var i;return function(){var s=this,o=arguments,r=function(){i=null,n||e.apply(s,o)},a=n&&!i;clearTimeout(i),i=setTimeout(r,t),a&&e.apply(s,o)}},t.getElemDistance=function(e){var t=0;if(e.offsetParent)do t+=e.offsetTop,e=e.offsetParent;while(e);return t>=0?t:0},t.getElementOffset=function(e,t){var n=t;return n>1&&(n=1),n>0&&(n=0),Math.max(e.offsetHeight*n)},t.getScrollPosition=function(e){return"bottom"===e?Math.max((window.scrollY||window.pageYOffset)+(window.innerHeight||document.documentElement.clientHeight)):window.scrollY||window.pageYOffset},t.isInView=function(e,t,n){return this.getScrollPosition(t)>this.getElemDistance(e)+this.getElementOffset(e,n)},t.stripHTML=function(e){var t=document.createElement("DIV");return t.innerHTML=e,t.textContent||t.innerText||""},t.addAnimation=function(e,t){var n=i(),s=function o(){e.classList.remove(t),e.removeEventListener(n,o,!1)};e.classList.add(t),e.addEventListener(n,s,!1)},t.getRandomNumber=function(e,t){return Math.floor(Math.random()*(t-e)+e)},t.strToEl=function(){var e=document.createElement("div");return function(t){var n;for(e.innerHTML=t,n=e.children[0];e.firstChild;)e.removeChild(e.firstChild);return n}}());t.getWidthOfInput=function(e){var t=arguments.length<=1||void 0===arguments[1]?20:arguments[1],n=e.value||e.placeholder,i=e.offsetWidth;if(n){var o=s('<span class="offscreen">'+n+"</span>");o.style.position="absolute",o.style.top="-9999px",o.style.left="-9999px",o.style.padding="0",o.style.width="auto",document.body.appendChild(o),o.offsetWidth>t&&o.offsetWidth!=e.offsetWidth&&(i=o.offsetWidth+t),document.body.removeChild(o)}return i+"px"}}]);