%PDF- %PDF-
Direktori : /var/www/cwg/wp-content/plugins/wp-grid-builder/frontend/assets/js/vendors/ |
Current File : //var/www/cwg/wp-content/plugins/wp-grid-builder/frontend/assets/js/vendors/autocomplete.js |
/*! * WP Grid Builder Plugin * * @package WP Grid Builder * @author Loïc Blascos * @link https://www.wpgridbuilder.com * @copyright 2019-2021 Loïc Blascos * */ !function(){var e={612:function(){[Element.prototype,CharacterData.prototype,DocumentType.prototype].forEach((function(e){e.hasOwnProperty("after")||Object.defineProperty(e,"after",{configurable:!0,enumerable:!0,writable:!0,value:function(){var e=Array.prototype.slice.call(arguments),t=document.createDocumentFragment();e.forEach((function(e){var n=e instanceof Node;t.appendChild(n?e:document.createTextNode(String(e)))})),this.parentNode.insertBefore(t,this.nextSibling)}})}))},443:function(){[Element.prototype,Document.prototype,DocumentFragment.prototype].forEach((function(e){e.hasOwnProperty("append")||Object.defineProperty(e,"append",{configurable:!0,enumerable:!0,writable:!0,value:function(){var e=Array.prototype.slice.call(arguments),t=document.createDocumentFragment();e.forEach((function(e){var n=e instanceof Node;t.appendChild(n?e:document.createTextNode(String(e)))})),this.appendChild(t)}})}))},70:function(){[Element.prototype,CharacterData.prototype,DocumentType.prototype].forEach((function(e){e.hasOwnProperty("before")||Object.defineProperty(e,"before",{configurable:!0,enumerable:!0,writable:!0,value:function(){var e=Array.prototype.slice.call(arguments),t=document.createDocumentFragment();e.forEach((function(e){var n=e instanceof Node;t.appendChild(n?e:document.createTextNode(String(e)))})),this.parentNode.insertBefore(t,this)}})}))},500:function(){Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;if(!document.documentElement.contains(t))return null;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null})},529:function(){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector)},744:function(){window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=function(e,t){t=t||window;for(var n=0;n<this.length;n++)e.call(t,this[n],n,this)})},897:function(){[Element.prototype,CharacterData.prototype,DocumentType.prototype].forEach((function(e){e.hasOwnProperty("remove")||Object.defineProperty(e,"remove",{configurable:!0,enumerable:!0,writable:!0,value:function(){null!==this.parentNode&&this.parentNode.removeChild(this)}})}))}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}n.d=function(e,t){for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){"use strict";var e={};n.r(e),n.d(e,{Clear:function(){return k},Input:function(){return y},List:function(){return g},Loader:function(){return w},Menu:function(){return b},Message:function(){return E}});n(612),n(70),n(443),n(897),n(529),n(500),n(744);function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function o(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?i(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):i(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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)}}function a(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return!t||"object"!==l(t)&&"function"!=typeof t?u(e):t}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,i=m(e);if(t){var o=m(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return c(this,n)}}var d=new(function(){function e(){s(this,e),t(this,"count",0),t(this,"instances","undefined"!=typeof Map&&new Map)}return a(e,[{key:"add",value:function(e,t){!this.has(e)&&this.instances.set(e,{id:++this.count,instance:t})}},{key:"get",value:function(e){return this.has(e)&&this.instances.get(e).instance}},{key:"id",value:function(e){return this.has(e)&&this.instances.get(e).id}},{key:"has",value:function(e){return this.instances.has(e)}},{key:"remove",value:function(e){this.instances.delete(e)}}]),e}()),v=function(){function e(n){var i=n.element;s(this,e),t(this,"prefix","_acplt"),this.input=i,this.suffix=d.id(i)}return a(e,[{key:"instance",get:function(){return d.get(this.input)}},{key:"components",get:function(){return this.instance.components}},{key:"options",get:function(){return this.instance.options}},{key:"classes",get:function(){return this.options.classes}},{key:"id",get:function(){return this.prefix+this.suffix}},{key:"items",get:function(){return this.instance.items||[]}},{key:"item",get:function(){return this.items[this.index]||{}}},{key:"index",get:function(){return this.instance.index}}]),e}(),y=function(e){p(n,e);var t=f(n);function n(){return s(this,n),t.apply(this,arguments)}return a(n,[{key:"init",value:function(){this.attributes(),this.wrapper(),this.label(),this.wrap()}},{key:"destroy",value:function(){this.collapse(),this.attributes("remove"),this.element.before(this.input),this.element.remove(),this.label.id==="".concat(this.id,"l")&&this.label.removeAttribute("id")}},{key:"attributes",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"set";e="".concat(e,"Attribute"),this.input[e]("autocomplete","off"),this.input[e]("aria-autocomplete",this.options.autoComplete?"both":"list")}},{key:"wrapper",value:function(){this.element=document.createElement("div"),this.element.className=this.classes.wrapper,this.element.setAttribute("aria-owns",this.id),this.element.setAttribute("aria-haspopup","listbox"),this.element.setAttribute("aria-expanded",!1)}},{key:"label",value:function(){this.label=document.querySelector('label[for="'.concat(this.input.id,'"]')),this.label||(this.label=this.input.closest("label")||{}),this.label.id||(this.label.id="".concat(this.id,"l"))}},{key:"wrap",value:function(){this.input.before(this.element),this.element.append(this.input)}},{key:"expand",value:function(){this.element.setAttribute("aria-expanded",!0),this.input.setAttribute("aria-controls",this.id),this.setDescendant()}},{key:"collapse",value:function(){this.element.setAttribute("aria-expanded",!1),this.input.removeAttribute("aria-activedescendant"),this.input.removeAttribute("aria-controls",this.id)}},{key:"setDescendant",value:function(){var e=this.index,t=0===e||e>0?"".concat(this.id,"-").concat(e):"",n=""!==t?"set":"remove";this.input["".concat(n,"Attribute")]("aria-activedescendant",t)}}]),n}(v),g=function(e){p(n,e);var t=f(n);function n(){return s(this,n),t.apply(this,arguments)}return a(n,[{key:"init",value:function(){this.element=document.createElement("ul"),this.element.id=this.id,this.element.className=this.classes.list,this.element.setAttribute("aria-labelledby",this.components.Input.label.id),this.element.setAttribute("role","listbox")}},{key:"destroy",value:function(){this.depopulate(),this.element.remove()}},{key:"populate",value:function(){this.list=document.createDocumentFragment(),this.depopulate(),this.createItem(),this.items.forEach(this.addItem,this),this.element.append(this.list)}},{key:"depopulate",value:function(){for(;this.element.firstChild;)this.element.firstChild.remove()}}]),n}(function(e){p(n,e);var t=f(n);function n(){return s(this,n),t.apply(this,arguments)}return a(n,[{key:"createItem",value:function(){this.node=document.createElement("li"),this.node.id="".concat(this.id,"-"),this.node.className=this.classes.item,this.node.setAttribute("role","option"),this.node.setAttribute("aria-selected",!1)}},{key:"cloneItem",value:function(e){var t=this.node.cloneNode(!1);return t.id+=e,t._index=e,t}},{key:"addItem",value:function(e,t){var n=this.cloneItem(t);null!==(e=this.options.renderItem(e,n,t))&&("string"==typeof e?n.textContent=e:n.append(e),this.list.append(n))}},{key:"getItem",value:function(){return this.element.children[this.index]}},{key:"focusItem",value:function(){this.setSelected(!0)}},{key:"blurItem",value:function(){this.setSelected(!1)}},{key:"setSelected",value:function(e){var t=this.getItem();t&&t.setAttribute("aria-selected",e)}}]),n}(v)),b=function(e){p(i,e);var n=f(i);function i(){var e;s(this,i);for(var o=arguments.length,r=new Array(o),a=0;a<o;a++)r[a]=arguments[a];return t(u(e=n.call.apply(n,[this].concat(r))),"resize",(function(){return requestAnimationFrame((function(){var t=e.input.getBoundingClientRect(),n=e.target(),i=e.element.style;i.top="".concat(t.bottom-n.top+(n.top?0:window.pageYOffset),"px"),i.left="".concat(t.left-n.left,"px"),i.width="".concat(t.width,"px"),e.instance.emitEvent("onResize",e.element)}))})),e}return a(i,[{key:"init",value:function(){this.element=document.createElement("div"),this.element.className=this.classes.menu,this.element.append(this.components.List.element),this.options.menuTarget instanceof HTMLElement||(this.options.menuTarget=document.body)}},{key:"destroy",value:function(){this.remove()}},{key:"append",value:function(){this.options.menuTarget.append(this.element),this.resize()}},{key:"remove",value:function(){this.element.remove(),this.element.removeAttribute("style")}},{key:"scroll",value:function(){var e=this.components.List.getItem();if(e){var t=e.getBoundingClientRect(),n=this.element.getBoundingClientRect(),i=t.top-n.top+t.height;i>n.height?this.element.scrollTop+=i-n.height:i<t.height&&(this.element.scrollTop+=i-t.height)}}},{key:"target",value:function(){var e=this.options.menuTarget;return e===document.body?{top:0,bottom:0,left:0}:e.getBoundingClientRect()}}]),i}(v),k=function(e){p(n,e);var t=f(n);function n(){return s(this,n),t.apply(this,arguments)}return a(n,[{key:"init",value:function(){this.button(),this.label(),this.icon()}},{key:"destroy",value:function(){this.remove()}},{key:"button",value:function(){this.element=document.createElement("button"),this.element.className=this.classes.clear,this.element.type="button"}},{key:"label",value:function(){var e=document.createElement("span");e.textContent=this.options.clearLabel,this.element.append(e)}},{key:"icon",value:function(){var e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg"),n=document.createElementNS(e,"path");n.setAttribute("d",this.options.clearShape),t.setAttribute("viewBox","0 0 20 20"),t.setAttribute("aria-hidden",!0),t.setAttribute("focusable",!1),t.appendChild(n),this.element.append(t)}},{key:"append",value:function(){!this.element.parentNode&&this.input.after(this.element)}},{key:"remove",value:function(){this.element.remove()}}]),n}(v),w=function(e){p(n,e);var t=f(n);function n(){return s(this,n),t.apply(this,arguments)}return a(n,[{key:"init",value:function(){var e=this;this.element=document.createElement("div"),this.element.className=this.classes.loader,[1,2,3].forEach((function(){return e.element.appendChild(document.createElement("span"))}))}},{key:"destroy",value:function(){this.remove()}},{key:"append",value:function(){!this.element.parentNode&&this.input.after(this.element)}},{key:"remove",value:function(){this.element.remove()}}]),n}(v),E=function(e){p(n,e);var t=f(n);function n(){return s(this,n),t.apply(this,arguments)}return a(n,[{key:"init",value:function(){this.element=document.createElement("span"),this.element.className=this.classes.message,this.element.setAttribute("role","status"),this.element.setAttribute("aria-atomic",!0),this.element.setAttribute("aria-live","polite"),this.input.before(this.element)}},{key:"destroy",value:function(){this.remove()}},{key:"remove",value:function(){this.element.remove()}},{key:"set",value:function(e){this.element.textContent=this.options.messages[e].replace("%s",this.item.label)}}]),n}(v);function x(e,t){return(t+e%t)%t}var A="acplt",O={source:[],minLength:1,maxResults:-1,regExp:"($1)",filterResults:function(e){return e},sortResults:function(e,t){return e.index-t.index||e.label.localeCompare(t.label)||e.label.length-t.label.length},highlighter:document.createElement("mark"),renderItem:function(e){return e.content},menuTarget:!1,smartAccent:!1,matchAll:!1,autoFocus:!0,autoSearch:!1,autoComplete:!1,loader:!1,clearable:!0,clearLabel:"Clear field",clearShape:"M12.549 14.737l-2.572-2.958-2.57 2.958a1.2 1.2 0 01-1.812-1.574L8.387 9.95 5.594 6.737a1.2 1.2 0 01.119-1.693 1.2 1.2 0 011.693.119l2.571 2.958 2.571-2.958a1.2 1.2 0 011.693-.119 1.2 1.2 0 01.119 1.693L11.567 9.95l2.793 3.213a1.2 1.2 0 11-1.811 1.574z",classes:{wrapper:A,menu:"".concat(A,"-menu"),list:"".concat(A,"-list"),item:"".concat(A,"-item"),clear:"".concat(A,"-clear"),loader:"".concat(A,"-loader"),message:"".concat(A,"-message")},messages:{open:"Use Up and Down to choose suggestions and press Enter to select suggestion.",input:"Type to search or press Escape to clear the input.",clear:"Field cleared.",select:"%s suggestion was selected.",noResults:"No suggestions found.",loading:"Loading suggestions..."}};function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function C(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var j=function(){function e(){s(this,e)}return a(e,[{key:"emitEvent",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];this.options[e]&&this.options[e].apply(this,n)}},{key:"addEvents",value:function(){this.handleEvents("add")}},{key:"removeEvents",value:function(){this.handleEvents("remove")}},{key:"handleEvent",value:function(e){this["on".concat(e.type)](e)}},{key:"handleEvents",value:function(e){e+="EventListener",this.components.Clear.element[e]("click",this),this.components.List.element[e]("click",this),this.components.List.element[e]("mouseenter",this,!0),this.element[e]("keydown",this),this.element[e]("keyup",this),this.element[e]("input",this),this.element[e]("focus",this),this.element[e]("blur",this),window[e]("mousedown",this),window[e]("resize",this)}},{key:"onclick",value:function(e){var t=e.target;if(t===this.components.Clear.element)return this.clear(),void this.element.focus();var n=t.closest("li"),i=n&&n._index;(0===i||i>0)&&this.select(i)}},{key:"onkeydown",value:function(e){var t=this.options.autoComplete;switch(e.key){case"Enter":this.select(this.index);break;case"Esc":case"Escape":this.clear();break;case"Down":case"ArrowDown":this.highlight(null===this.index?0:this.index+1),t&&this.replace();break;case"Up":case"ArrowUp":this.highlight(null===this.index?-1:this.index-1),t&&this.replace();break;default:return}e.preventDefault()}},{key:"onkeyup",value:function(e){var t=e.key;this.options.autoComplete&&1===C(t).length&&this.complete()}},{key:"onmousedown",value:function(e){var t=this.components,n=t.List,i=t.Clear,o=e.target.closest("ul")===n.element,s=e.target===i.element;(o||s)&&e.preventDefault()}},{key:"onmouseenter",value:function(e){var t=e.target._index;t>=0&&this.index!==t&&this.highlight(t,!1)}},{key:"onresize",value:function(){this.opened&&this.components.Menu.resize()}},{key:"oninput",value:function(){this.search(this.element.value)}},{key:"onfocus",value:function(){this.components.Message.set("input"),this.options.autoSearch&&this.oninput()}},{key:"onblur",value:function(){this.abort(),this.close(),this.update()}}]),e}(),D=function(){function e(t){s(this,e),this.options=t}return a(e,[{key:"parse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.string=e.trim(),this.accent=this.hasAccent(),this.regExp=this.getRegEx(this.string,this.options.regExp),this.filter(t),this.sort(),this.slice(),this.highlight(),this.data}},{key:"hasAccent",value:function(){return this.accent=!1,this.options.smartAccent&&this.normalize(this.string)!==this.string.toLowerCase()}},{key:"filter",value:function(e){var t=this;this.data=e.reduce((function(e,n){return n=t.toObject(n),t.exists(n)&&e.push(n),e}),[])}},{key:"toObject",value:function(e){return"object"===l(e)?o({},e):{value:e,label:e}}},{key:"exists",value:function(e){var t=!this.string||this.normalize(e.label).match(this.regExp),n=this.options.filterResults.apply(this,[!!t,e,this.string]);return n&&(e.index=t?t.index:null,e.content=e.label),n}},{key:"sort",value:function(){var e=this.options.sortResults;this.string&&"function"==typeof e&&this.data.sort(e)}},{key:"slice",value:function(){var e=this.options.maxResults;e>0&&(this.data=this.data.slice(0,e))}},{key:"highlight",value:function(){var e=this,t=this.options,n=t.highlighter,i=t.matchAll,o=this.string.length;if(n&&o){var s=i&&this.getRegEx(this.string,"($1)","gi");this.data.forEach((function(t){if(null!==t.index){var n=s?e.matchAll(t.label,s):[t.index],i=document.createDocumentFragment();t.content=e.wrapAll(t.label,n,o,i)}}))}}},{key:"matchAll",value:function(e,t){var n,i=[];for(e=this.normalize(e);null!==(n=t.exec(e));)i.push(n.index);return i}},{key:"wrapAll",value:function(e,t,n,i){var o=t.shift(),s=e.slice(0,o),r=e.slice(o+n),a=e.slice(o,o+n);return s&&i.append(document.createTextNode(s)),a&&i.append(this.wrapMatch(a)),t.length?this.wrapAll(r,t.map((function(e){return e-(o+n)})),n,i):i.append(document.createTextNode(r)),i}},{key:"wrapMatch",value:function(e){var t=this.options.highlighter.cloneNode(!1);return t.textContent=e,t}},{key:"getRegEx",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"i";return e=(e=this.normalize(e)).replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&"),new RegExp(t.replace("$1",e),n)}},{key:"normalize",value:function(e){return!this.accent&&String.prototype.normalize&&(e=(e=e.normalize("NFD")).replace(/[\u0300-\u036f]/g,"")),e.trim().toLowerCase()}}]),e}(),N=function(n){p(r,n);var i=f(r);function r(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,r),t(u(n=i.call(this)),"components",{}),n.element=e,n.options=o(o({},O),a),d.has(e)?c(n,d.get(e)):(d.add(e,u(n)),n.create(),n)}return a(r,[{key:"create",value:function(){for(var t in this.Data=new D(this.options),this.items=[],this.index=null,this.opened=!1,this.loading=!1,e)this.components[t]=new e[t](this),this.components[t].init();this.update(),this.addEvents()}},{key:"destroy",value:function(){var e=this.element,t=this.components,n=document.activeElement===e;d.has(e)&&(this.removeEvents(),Object.keys(t).filter((function(e){return t[e].destroy()})),d.remove(e),n&&e.focus())}},{key:"enable",value:function(){this.element.disabled=!1,this.update()}},{key:"disable",value:function(){this.element.disabled=!0,this.abort(),this.close(),this.update()}},{key:"update",value:function(){var e=this.element,t=e.disabled,n=e.value,i=this.options,o=i.clearable,s=i.loader&&!t&&!0===this.loading,r=o&&!s&&!t&&n.length>0;this.components.Clear[r?"append":"remove"](),this.components.Loader[s?"append":"remove"]()}},{key:"open",value:function(){!this.opened&&this.items.length&&(this.components.Message.set("open"),this.components.Input.expand(),this.components.Menu.append(),this.opened=!0,this.emitEvent("onOpen"))}},{key:"close",value:function(){this.opened&&(this.components.Input.collapse(),this.components.Menu.remove(),this.opened=!1,this.emitEvent("onClose"))}},{key:"clear",value:function(){var e=this.options,t=e.autoSearch,n=e.minLength,i=document.activeElement===this.element;""!==this.element.value&&(this.element.value="",this.components.Message.set("clear"),this.emitEvent("onClear"),this.abort(),i&&t&&n<1?this.search():this.depopulate())}},{key:"select",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.items[e];t&&this.opened&&(this.element.value=t.value,this.highlight(e,!1),this.emitEvent("onSelect",t),this.components.Message.set("select")),this.close(),this.update()}},{key:"search",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this.options,n=t.source,i=t.minLength,o="function"==typeof n?"load":"response";this.abort(),e.replace(/^\s+/,"").length<i?this.depopulate():(this.loading=!0,this.emitEvent("onSearch",e),this[o](e,n))}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.depopulate(),this.components.Message.set("loading"),this.emitEvent("source",e,this.response.bind(this,e))}},{key:"abort",value:function(){this.loading&&(this.loading=!1,this.emitEvent("onAbort"))}},{key:"response",value:function(e,t){!1!==this.loading&&(this.loading=!1,this.populate(e,t),this.items.length?this.open():(this.components.Message.set("noResults"),this.close()),this.update())}},{key:"populate",value:function(e,t){this.index=this.options.autoFocus?0:null,this.items=this.Data.parse(e,t),this.components.List.populate(),this.components.List.focusItem()}},{key:"depopulate",value:function(){this.close(),this.update(),this.populate()}},{key:"highlight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.opened&&e!==this.index&&(this.components.List.blurItem(),this.index=x(e,this.items.length),this.components.List.focusItem(),this.components.Input.setDescendant(),t&&this.components.Menu.scroll(),this.emitEvent("onHighlight",this.items[this.index]))}},{key:"complete",value:function(){if(this.items.length){var e=this.element.value,t=this.items[0].label,n=e+t.substring(e.length-e.search(/\S/)),i=this.Data.normalize(t);this.Data.normalize(e)!==i&&this.Data.normalize(n)===i&&(this.element.value=n,this.element.setSelectionRange(e.length,n.length))}}},{key:"replace",value:function(){this.items.length&&(this.element.value=this.items[this.index].label,this.update())}}]),r}(j);WP_Grid_Builder.vendors.autocomplete=function(e,t){return new N(e,t)}}()}();