import{__spreadArray}from"tslib";import{i as isNil}from"./index-zWZxKBfo.js";function getValues(r){if(Array.isArray(r)){return r.filter((function(r){return!isNil(r)}))}return[]}function length(r){return getValues(r).length}function removeValue(r,e){return getValues(r).filter((function(r){return r!==e}))}function addValue(r,e,t){var n=getValues(r);if(t){if(n.includes(e)){return removeValue(r,e)}return __spreadArray(__spreadArray([],n,true),[e],false)}return[e]}function validateAfterBlur(r,e,t){var n=getValues(r);if(n.length>0){var a=e.get(n[0]);if(isNil(a)||t!==a.label){return[]}}else{var i=findOptionByLabel(e,t);if(!isNil(i)){return addValue(r,i.value,false)}}return n}function findOptionByLabelIterator(r,e){var t=r.next(),n=t.value,a=t.done;if(!isNil(n)&&n.label===e){return n}if(a){return undefined}return findOptionByLabelIterator(r,e)}function findOptionByLabel(r,e){return findOptionByLabelIterator(r.values(),e)}function findLabelByValue(r,e){var t=r.get(e);if(!isNil(t)){return t.label}return""}function startsWith(r,e){var t=r.trim().toLowerCase();var n=e.trim().toLowerCase();return t.startsWith(n)}function includes(r,e){var t=r.trim().toLowerCase();var n=e.trim().toLowerCase();return t.includes(n)}function preventDefault(r){r.preventDefault();r.stopPropagation()}export{addValue as a,findOptionByLabel as b,findLabelByValue as f,getValues as g,includes as i,length as l,preventDefault as p,removeValue as r,startsWith as s,validateAfterBlur as v};