-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdadata.min.js
More file actions
1 lines (1 loc) · 37.5 KB
/
dadata.min.js
File metadata and controls
1 lines (1 loc) · 37.5 KB
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.suggestions=e():t.suggestions=e()}(self,(function(){return(()=>{"use strict";var t={843:(t,e,n)=>{n.d(e,{Z:()=>i});var o=n(645),r=n.n(o)()((function(t){return t[1]}));r.push([t.id,".suggestions-98d9c187::-ms-clear{display:none}",""]),r.locals={input:"suggestions-98d9c187"};const i=r},46:(t,e,n)=>{n.d(e,{Z:()=>i});var o=n(645),r=n.n(o)()((function(t){return t[1]}));r.push([t.id,".suggestions-09bab179{box-sizing:border-box;background-color:#fff;border:1px solid #999;cursor:default;position:absolute;z-index:9999;-webkit-text-size-adjust:100%}.suggestions-09bab179.suggestions-0bca60d1{border-style:none;left:0 !important;width:100% !important}.suggestions-09bab179 strong{font-weight:normal;color:#39f}.suggestions-3d96efb7{padding:4px;font-size:85%;color:#777;line-height:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.suggestions-dc6c4f0c{position:absolute;top:0;right:0;padding:4px;display:block;text-align:center;filter:grayscale(100%)}.suggestions-dc6c4f0c:hover{filter:none}.suggestions-dc6c4f0c>svg{height:20px}.suggestions-0bca60d1 .suggestions-dc6c4f0c{position:static;display:block;text-align:center}.suggestions-a231b9a0{list-style:none;padding:0;margin:0}.suggestions-e2acca19{padding:4px;overflow:hidden;cursor:pointer;background-color:#fff;transition:.3s ease-out}.suggestions-e2acca19:hover{background-color:#f7f7f7}.suggestions-e2acca19.suggestions-ff2d929f,.suggestions-e2acca19.suggestions-ff2d929f:hover{background:#f0f0f0}.suggestions-0bca60d1 .suggestions-e2acca19{border-bottom:1px solid #ddd}",""]),r.locals={popover:"suggestions-09bab179",isMobile:"suggestions-0bca60d1",hint:"suggestions-3d96efb7",promo:"suggestions-dc6c4f0c",list:"suggestions-a231b9a0",item:"suggestions-e2acca19",isHighlighted:"suggestions-ff2d929f"};const i=r},645:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=t(e);return e[2]?"@media ".concat(e[2]," {").concat(n,"}"):n})).join("")},e.i=function(t,n,o){"string"==typeof t&&(t=[[null,t,""]]);var r={};if(o)for(var i=0;i<this.length;i++){var s=this[i][0];null!=s&&(r[s]=!0)}for(var u=0;u<t.length;u++){var a=[].concat(t[u]);o&&r[a[0]]||(n&&(a[2]?a[2]="".concat(n," and ").concat(a[2]):a[2]=n),e.push(a))}},e}},379:(t,e,n)=>{var o,r=function(){var t={};return function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}t[e]=n}return t[e]}}(),i=[];function s(t){for(var e=-1,n=0;n<i.length;n++)if(i[n].identifier===t){e=n;break}return e}function u(t,e){for(var n={},o=[],r=0;r<t.length;r++){var u=t[r],a=e.base?u[0]+e.base:u[0],l=n[a]||0,c="".concat(a," ").concat(l);n[a]=l+1;var p=s(c),h={css:u[1],media:u[2],sourceMap:u[3]};-1!==p?(i[p].references++,i[p].updater(h)):i.push({identifier:c,updater:d(h,e),references:1}),o.push(c)}return o}function a(t){var e=document.createElement("style"),o=t.attributes||{};if(void 0===o.nonce){var i=n.nc;i&&(o.nonce=i)}if(Object.keys(o).forEach((function(t){e.setAttribute(t,o[t])})),"function"==typeof t.insert)t.insert(e);else{var s=r(t.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(e)}return e}var l,c=(l=[],function(t,e){return l[t]=e,l.filter(Boolean).join("\n")});function p(t,e,n,o){var r=n?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):o.css;if(t.styleSheet)t.styleSheet.cssText=c(e,r);else{var i=document.createTextNode(r),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(i,s[e]):t.appendChild(i)}}function h(t,e,n){var o=n.css,r=n.media,i=n.sourceMap;if(r?t.setAttribute("media",r):t.removeAttribute("media"),i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleSheet)t.styleSheet.cssText=o;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(o))}}var f=null,g=0;function d(t,e){var n,o,r;if(e.singleton){var i=g++;n=f||(f=a(e)),o=p.bind(null,n,i,!1),r=p.bind(null,n,i,!0)}else n=a(e),o=h.bind(null,n,e),r=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(n)};return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else r()}}t.exports=function(t,e){(e=e||{}).singleton||"boolean"==typeof e.singleton||(e.singleton=(void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o));var n=u(t=t||[],e);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var o=0;o<n.length;o++){var r=s(n[o]);i[r].references--}for(var a=u(t,e),l=0;l<n.length;l++){var c=s(n[l]);0===i[c].references&&(i[c].updater(),i.splice(c,1))}n=a}}}},362:(t,e,n)=>{n.r(e),n.d(e,{dispose:()=>St,execMethod:()=>bt,init:()=>mt});var o=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var o=Array(t),r=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,u=i.length;s<u;s++,r++)o[r]=i[s];return o};const r=function(){function t(){this.disposeHandlers=[]}return t.prototype.dispose=function(){this.disposeHandlers.reverse().forEach((function(t){return t()})),this.disposeHandlers.length=0},t.prototype.onDispose=function(t){this.disposeHandlers.push(t)},t.prototype.setDisposableTimeout=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=setTimeout.apply(void 0,o([t,e],n));return this.onDispose((function(){return clearTimeout(i)})),i},t.prototype.setDisposableInterval=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=setInterval.apply(void 0,o([t,e],n));return this.onDispose((function(){return clearInterval(i)})),i},t.prototype.addDisposableEventListener=function(t,e,n){t.addEventListener(e,n),this.onDispose((function(){return t.removeEventListener(e,n)}))},t}();var i=function(t){return"string"==typeof t},s={"&":/&/g,"<":/</g,">":/>/g,""":/"/g,"'":/'/g,"/":/\//g},u=function(t){return Object.keys(s).reduce((function(t,e){return t.replace(s[e],e)}),t)},a=function(t){return t.filter(i).reduce((function(t,e){return function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var o=Array(t),r=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,u=i.length;s<u;s++,r++)o[r]=i[s];return o}(t,e.split(/\s+/g))}),[])},l=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return a(e).forEach((function(e){return t.classList.add(e)}))},c=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return a(e).forEach((function(e){return t.classList.remove(e)}))},p=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a(t).map(u).join(" ")},h=n(379),f=n.n(h),g=n(843);f()(g.Z,{injectType:"singletonStyleTag",insert:"head",singleton:!0});const d=g.Z.locals||{};var v,y=function(t,e){var n,o,r=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];o=r,n&&clearTimeout(n),n=window.setTimeout((function(){n=null,t.apply(void 0,o)}),e)};return r.cancel=function(){n&&clearTimeout(n)},r},m=(v=function(t,e){return(v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}v(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),b=function(){return(b=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},S="suggestions-input-visible",O="suggestions-value-change",w={autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false"};const E=function(t){function e(e,n){var o=t.call(this)||this;return o.el=e,o.options=n,o.lastValue=o.el.value,o.suggestedValue=null,o.debouncedTriggerOnChange=y((function(){return o.el.dispatchEvent(new Event(O))}),o.options.deferRequestBy),o.setupElementClass(),o.setupAttributes(),o.attachEventHandlers(),o.observeVisibility(),o}return m(e,t),e.prototype.getValue=function(){return this.lastValue},e.prototype.setValue=function(t){this.lastValue=t,this.el.value=t},e.prototype.suggestValue=function(t){this.suggestedValue=t,null===t?this.el.value=this.lastValue:(this.lastValue=this.el.value,this.el.value=t)},e.prototype.setupElementClass=function(){var t,e=this,n=null===(t=this.options.classNames)||void 0===t?void 0:t.input;l(this.el,d.input,n),this.onDispose((function(){return c(e.el,d.input,n)}))},e.prototype.setupAttributes=function(){var t=this,e=Object.keys(w).reduce((function(e,n){var o;return b(b({},e),((o={})[n]=t.el.getAttribute(n),o))}),{});Object.entries(w).forEach((function(e){var n=e[0],o=e[1];return t.el.setAttribute(n,o)})),this.onDispose((function(){Object.entries(e).forEach((function(e){var n=e[0],o=e[1];null===o?t.el.removeAttribute(n):t.el.setAttribute(n,o)}))}))},e.prototype.observeVisibility=function(){var t=this,e=!1,n=function(){t.el.dispatchEvent(new Event(S)),e=!0};if("function"==typeof IntersectionObserver){var o=new IntersectionObserver((function(t){t.some((function(t){return t.intersectionRatio>0}))&&(n(),o.disconnect())}));o.observe(this.el),this.onDispose((function(){e||o.disconnect()}))}else{var r=null,i=function(){Boolean(t.el.offsetParent)&&(n(),r&&clearInterval(r))};i(),e||(r=window.setInterval(i,500),this.onDispose((function(){!e&&r&&clearInterval(r)})))}},e.prototype.checkIfValueChanged=function(){var t=this.el.value;i(this.suggestedValue)&&t===this.suggestedValue||t!==this.lastValue&&(this.lastValue=t,this.debouncedTriggerOnChange())},e.prototype.attachEventHandlers=function(){var t=this,e=y((function(){return t.checkIfValueChanged()}),0);this.addDisposableEventListener(this.el,"keyup",e),this.addDisposableEventListener(this.el,"cut",e),this.addDisposableEventListener(this.el,"paste",e),this.addDisposableEventListener(this.el,"input",e),this.addDisposableEventListener(this.el,"focus",(function(){t.checkIfValueChanged()}))},e}(r);var x=function(t){return function(t){return function(t){return"number"==typeof t}(t)&&isFinite(t)}(t)&&t>0},P="Suggestions is not initialized on ths element.",C="Suggestions has been disposed on ths element.",j="Aborted by the next request.",I=function(){return(I=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},T=function(){},_=function(){return(_=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};const N=function(){function t(t){this.options=t,this.correctCount=this.getCorrectCount(),this.typeUrl=this.options.type.toLowerCase()}return t.prototype.fetch=function(e,n){var o,r=this.options,i=r.noCache,s=r.partner,u=r.requestHeaders,a=r.requestTimeout,l=r.requestToken,c=r.requestUrl,p=r.serviceUrl;o=c||""+(void 0===p?"https://suggestions.dadata.ru/suggestions/api/4_1/rs":p).replace(/([^/])$/,"$1/")+e;var h=null==l?void 0:l.trim(),f=_(_({},u),{Accept:"application/json","X-Version":"20.11.2"});h&&(f.Authorization="Token "+h),s&&(f["X-Partner"]=s);var g=function(){return function(t,e){return void 0===e&&(e={}),new Promise((function(n,o){if("function"!=typeof XMLHttpRequest)throw new Error("XMLHttpRequest is not available.");var r=new XMLHttpRequest,i=e.method,s=e.headers,u=e.timeout,a=e.body;r.open(i||"GET",t),r.withCredentials=!1,s&&Object.keys(s).forEach((function(t){return r.setRequestHeader(t,s[t])})),"object"==typeof a&&(a=JSON.stringify(a),r.setRequestHeader("Content-type","application/json"));var l=x(u)?setTimeout((function(){return r.abort()}),u):null;r.onabort=function(){return o(new Error("Request exceeded timeout."))},r.onload=r.onerror=function(){var t;try{l&&clearTimeout(l);var e=r.responseText,i=r.status,s=r.statusText;(!i||i>=400)&&o(new Error(s));var u=r.getAllResponseHeaders().split(/[\r\n]+/).filter(Boolean).reduce((function(t,e){var n,o=e.split(": "),r=o[0],i=o.slice(1);return I(I({},t),((n={})[r.toLowerCase()]=i.join(": "),n))}),{});n({status:i,statusText:s,headers:u,body:(null===(t=u["content-type"])||void 0===t?void 0:t.match(/\bapplication\/json\b/i))?JSON.parse(e):e})}catch(t){o(t)}},r.send(null==a?"":String(a))}))}(o,_(_({},n),{headers:_(_({},f),null==n?void 0:n.headers),timeout:a}))};if(i)return g();var d=JSON.stringify([o,n]),v=t.pendingQueries[d];if(v)return v;var y=g();return t.pendingQueries[d]=y,y.finally((function(){delete t.pendingQueries[d]})).catch(T),y},t.prototype.status=function(){return this.fetch("status/"+this.typeUrl).then((function(t){var e=t.body,n=t.headers;if(!e.search)throw new Error("Suggestions Service Unavailable.");var o=n["x-plan"];return o&&(e.plan=o),e}))},t.prototype.fetchSuggestions=function(t,e,n){var o,r=this.options,i=r.language,s=r.requestParamName,u=r.requestParams;return this.fetch(t+"/"+this.typeUrl,{method:"POST",body:_(_(_({},u),(o={},o[s]=e,o.count=this.correctCount,o.language=i,o)),n)}).then((function(t){return t.body.suggestions}))},t.prototype.getCorrectCount=function(){var t=this.options.count;return x(t)?t:void 0},t.pendingQueries={},t.resetPendingQueries=function(){t.pendingQueries={}},t}();var L=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),D=function(){return(D=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};const k=function(t){function e(e,n,o){var r=t.call(this)||this;return r.el=e,r.ImplementationClass=n,r.options=o,r.api=new N(r.options),r.input=new E(r.el,r.options),r.execCalls=[],r.onDispose((function(){return r.input.dispose()})),r.waitForInputIsVisible(),r}return L(e,t),e.prototype.invokeImplementationMethod=function(t){for(var e=this,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return new Promise((function(o,r){var i;e.implementation?o((i=e.implementation)[t].apply(i,n)):(e.execCalls.push([t,n,o,r]),e.onDispose((function(){r(new Error(C))})))}))},e.prototype.waitForInputIsVisible=function(){var t=this,e=function(){t.fetchStatus().then((function(e){t.implementation=t.initImplementation(e)}),T)};this.el.addEventListener(S,e),this.onDispose((function(){return t.el.removeEventListener(S,e)}))},e.prototype.fetchStatus=function(){var t=this,n=this.options,o=n.noCache,r=n.type,i=n.onSearchError,s=e.statusByType[r];if(s&&!o)return Promise.resolve(s);var u=this.api.status();return u.then((function(t){e.statusByType[r]=t}),(function(e){return null==i?void 0:i(e,null,t.el)})),u},e.prototype.initImplementation=function(t){var e=new this.ImplementationClass(this.el,D(D({},this.options),{helperElements:Array.prototype.slice.call(this.options.helperElements||[]),api:this.api,input:this.input,plan:t.plan}));return this.onDispose((function(){return e.dispose()})),this.execCalls.forEach((function(t){var n=t[0],o=t[1],r=t[2],i=t[3];try{r(e[n].apply(e,o))}catch(t){i(t)}})),e},e.statusByType={},e.clearStatusCache=function(){e.statusByType={}},e}(r);var A={autoHighlightFirst:!1,count:5,deferRequestBy:100,enrichmentEnabled:!1,hint:"Выберите вариант или продолжите ввод",language:"ru",minLength:1,mobileMaxWidth:600,noCache:!1,noSuggestionsHint:"Неизвестное значение",preventBadQueries:!1,requestParamName:"query",requestTimeout:3e3,scrollOnFocus:!1,serviceUrl:"https://suggestions.dadata.ru/suggestions/api/4_1/rs",triggerSelectOnBlur:!0,triggerSelectOnEnter:!0,triggerSelectOnSpace:!1},H={formatSelected:null,isQueryRequestable:null,isSuggestionDataComplete:null,onInvalidateSelection:null,onSearchComplete:null,onSearchError:null,onSearchStart:null,onSelect:null,onSelectNothing:null,renderSuggestion:null},M=function(){return(M=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},V=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var o=Array(t),r=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,u=i.length;s<u;s++,r++)o[r]=i[s];return o},q=new(WeakMap||Map),B=function(t){var e;null===(e=q.get(t))||void 0===e||e.dispose(),q.delete(t)},R=function(t,e){for(var n,o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var i=q.get(t);return i?(n=i).invokeImplementationMethod.apply(n,V([e],o)):Promise.reject(new Error(P))},Z=n(46);f()(Z.Z,{injectType:"singletonStyleTag",insert:"head",singleton:!0});const Q=Z.Z.locals||{};var F=function(t,e){var n=document.createElement(t);return e&&Object.assign(n,e),n},z=function(t,e){var n,o=null,r=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];if(!n)return n=window.setTimeout((function(){n=null,o&&t.apply(void 0,o),o=null}),e),t.apply(void 0,r);o=r};return r.cancel=function(){n&&clearTimeout(n)},r},G=function(t,e){return x(e)&&t.innerWidth<=e},U=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();const $=function(t){function e(e,n){var o=t.call(this)||this;return o.target=e,o.onShouldAlign=n,o.observeParentsScroll(),o.observeDomChanges(),o.addDisposableEventListener(window,"resize",o.onShouldAlign),o.addDisposableEventListener(document,"transitionend",o.onShouldAlign),o}return U(e,t),e.prototype.observeParentsScroll=function(){for(var t=this,e=[],n=this.target.parentElement;n;)e.push(n),n=n.parentElement;e.forEach((function(e){return t.addDisposableEventListener(e,"scroll",t.onShouldAlign)}))},e.prototype.observeDomChanges=function(){if("function"==typeof MutationObserver){var t=new MutationObserver(this.onShouldAlign);t.observe(document.body,{subtree:!0,attributes:!0,childList:!0}),this.onDispose((function(){return t.disconnect()}))}else this.setDisposableInterval(this.onShouldAlign,1e3)},e}(r);var W=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();const J=function(t){function e(e,n){var o,r=t.call(this)||this;return r.target=e,r.options=n,r.container=this.target.parentNode,r.el=F("div",{className:p(Q.popover,null===(o=r.options.classNames)||void 0===o?void 0:o.popover)}),r.items=r.createItems(r.options.items),r.alignThrottleTimeout=50,r.mount(),r.align(),r.initPositionObserver(),r.render(),r.listenToMousedown(),r.observeViewportSize(),r}return W(e,t),e.prototype.setItems=function(t){this.items=this.createItems(t),this.render()},e.prototype.highlightItem=function(t){this.items.forEach((function(e,n){n===t?l(e,Q.isHighlighted):c(e,Q.isHighlighted)}))},e.prototype.mount=function(){var t=this;this.target.parentNode.insertBefore(this.el,this.target.nextSibling),this.onDispose((function(){return t.container.removeChild(t.el)}))},e.prototype.align=function(){var t=this.target.getBoundingClientRect(),e=this.el.style;e.width=t.width+"px"},e.prototype.initPositionObserver=function(){var t=this,e=new $(this.target,z((function(){return t.align()}),this.alignThrottleTimeout));this.onDispose((function(){return e.dispose()}))},e.prototype.render=function(){var t=this.options,e=t.classNames,n=t.hint,o=t.noSuggestionsHint,r=t.showPromo,i=this.items,s=document.createDocumentFragment(),u=i.length?n:o;if(u){var a=F("div",{className:p(Q.hint,null==e?void 0:e.hint),textContent:u});s.appendChild(a)}var l=F("ul",{className:p(Q.list,null==e?void 0:e.list)});l.append.apply(l,i),s.appendChild(l),r&&s.appendChild(F("a",{className:Q.promo,target:"_blank",tabIndex:-1,href:"https://dadata.ru/suggestions/?utm_source=dadata&utm_medium=module&utm_campaign=suggestions-jquery",innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 167.55 38.92">\n <defs>\n <style>.cls-1{fill:#cdcccc;}.cls-2{fill:#ef4741;}.cls-3{fill:#fff;}</style>\n </defs>\n\x3c!-- <title>dadata-logo</title>--\x3e\n <path class="cls-1"\n d="M192.61,153.07H196v-3.15h-3.39Zm9.55-14.46v-2.45h-3v16.91h3.14V142.2a4.39,4.39,0,0,1,4.23-3.7h1.75v-2.69h-1.54C203.75,135.81,202.35,137.76,202.16,138.61Zm20.2-2.45v11.3a5,5,0,0,1-4.65,3.66,7.19,7.19,0,0,1-2-.23,2,2,0,0,1-1.12-.6,2.38,2.38,0,0,1-.44-.86,4.38,4.38,0,0,1-.1-1V136.16h-3.14v12.4a4.83,4.83,0,0,0,1.26,3.65q1.26,1.21,4.61,1.21c3.38,0,4.62-.91,5.56-2.34v2h3.14V136.16Z"\n transform="translate(-57.96 -122.27)"/>\n <rect class="cls-2" width="131.91" height="38.92" rx="3" ry="3"/>\n <path class="cls-3"\n d="M119.34,130.39h-9.18v22.68h10.23c3.84,0,10.18-.35,10.18-6.88v-8.91C130.56,130.74,123.18,130.39,119.34,130.39Zm5.77,15.2c0,3.27-2.38,3.6-5.09,3.6h-4.41V134.27H119c2.71,0,6.14.33,6.14,3.6Zm-48-15.2H68v22.68H78.18c3.84,0,10.18-.35,10.18-6.88v-8.91C88.36,130.74,81,130.39,77.14,130.39Zm5.77,15.2c0,3.27-2.38,3.6-5.09,3.6H73.41V134.27h3.36c2.71,0,6.14.33,6.14,3.6Zm74-14.32h-5.1V148a6.28,6.28,0,0,0,.4,2.36,4,4,0,0,0,1,1.54,4.56,4.56,0,0,0,1.57.88,8.16,8.16,0,0,0,1.85.42q.89.08,2.08.09a24.23,24.23,0,0,0,2.83-.17v-2.87h-1.82a3.08,3.08,0,0,1-2.31-.61,3.79,3.79,0,0,1-.52-2.36V139h4.65v-3.14h-4.65Zm21,5.68q-1.82-1.14-6.5-1.13h-5.92v.25l.73,2.9h5.19a5,5,0,0,1,2.5.5,2.37,2.37,0,0,1,.72,2v1.15H168.9q-3,0-4.12,1.17T163.62,148c0,2.21.37,3.14,1.12,3.84s2.2,1.22,4.48,1.22h7.06c1.76,0,3.45-.83,3.45-2.82v-8.81Q179.73,138.08,177.91,136.94Zm-3.29,13.3h-3.35a4.27,4.27,0,0,1-2.22-.35q-.44-.35-.44-2t.42-2.06a3.55,3.55,0,0,1,2.1-.38h3.49Zm-27.5-13.3q-1.82-1.14-6.5-1.13h-5.92v.25l.73,2.9h5.19a5,5,0,0,1,2.5.5,2.38,2.38,0,0,1,.72,2v1.15h-5.73q-3,0-4.12,1.17T132.84,148c0,2.21.37,3.14,1.12,3.84s2.2,1.22,4.48,1.22h7.06c1.77,0,3.45-.83,3.45-2.82v-8.81Q148.94,138.08,147.13,136.94Zm-3.28,13.3h-3.35a4.27,4.27,0,0,1-2.22-.35q-.44-.35-.44-2t.42-2.06a3.55,3.55,0,0,1,2.1-.38h3.49Zm-38.92-13.3q-1.82-1.14-6.5-1.13H92.5v.25l.73,2.9h5.19a5,5,0,0,1,2.5.5,2.38,2.38,0,0,1,.72,2v1.15H95.91q-3,0-4.12,1.17T90.63,148c0,2.21.37,3.14,1.12,3.84s2.2,1.22,4.48,1.22h7.06c1.77,0,3.45-.83,3.45-2.82v-8.81Q106.74,138.08,104.92,136.94Zm-3.28,13.3H98.29a4.27,4.27,0,0,1-2.22-.35q-.44-.35-.44-2t.42-2.06a3.55,3.55,0,0,1,2.1-.38h3.49Z"\n transform="translate(-57.96 -122.27)"/>\n</svg>\n'})),this.el.innerHTML="",this.el.appendChild(s)},e.prototype.createItems=function(t){var e=this.options,n=e.classNames,o=e.onItemClick,r=t.map((function(t){return F("li",{className:p(Q.item,null==n?void 0:n.item),innerHTML:t})}));return r.forEach((function(t,e){return t.addEventListener("click",(function(){return o(e)}))})),r},e.prototype.listenToMousedown=function(){this.addDisposableEventListener(this.el,"mousedown",this.options.onMousedown)},e.prototype.observeViewportSize=function(){var t=this,e=this.options.mobileMaxWidth;if(x(e)){var n=!1,o=z((function(){var o=G(window,e);o!==n&&(o?l(t.el,Q.isMobile):c(t.el,Q.isMobile),n=o)}),this.alignThrottleTimeout);o(),this.addDisposableEventListener(window,"resize",o)}},e}(r);var X=function(){return(X=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},Y=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var o=Array(t),r=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,u=i.length;s<u;s++,r++)o[r]=i[s];return o},K="\\s\"'~\\*\\.,:\\|\\[\\]\\(\\)\\{\\}<>№",tt=new RegExp("["+K+"]+","g"),et=new RegExp("[\\-\\+\\\\\\?!@#$%^&]+","g"),nt=new RegExp("([^"+K+"]*)(["+K+"]*)","g"),ot=function(t){return t.toLowerCase().replace(/[ёЁ]/g,"е")},rt=function(t){return t.map((function(t){var e=u(t.text);return e&&t.matched?"<strong>"+e+"</strong>":e})).join("")},it=function(t,e,n,o){var r=t.reduce((function(t,e){if(e.token&&!e.matched&&(!(null==o?void 0:o.includes(e.token))||(d=e.text)!==d.toLowerCase())){var r=n.find((function(t){return t.test(e.token)}));if(r){var i=r.exec(e.token),s=i[1],u=i[2],a=i[3],l=i[4],c=i[5],p=(null==s?void 0:s.length)||0,h=l.length,f=c.length,g=[];return p&&(u&&g.push({text:e.text.substr(0,u.length),token:u,matched:!1}),g.push({text:a,token:"",matched:!1})),g.push({text:e.text.substr(p,h),token:e.token.substr(p,h),matched:!0}),f&&g.push({text:e.text.substr(p+h),token:e.token.substr(p+h),matched:!1}),Y(t,g)}}var d;return Y(t,[e])}),[]),i=r.filter((function(t){return t.matched})).length;return i===e?r:it(r,i,n,o)},st=function(t,e){if(typeof t!=typeof e)return!1;switch(typeof t){case"object":if(null===t&&null===e)return!0;if(null===t||null===e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!st(t[n],e[n]))return!1;return!0}return Object.keys(t).every((function(n){return st(t[n],e[n])}));case"number":if(isNaN(t))return isNaN(e);break;case"symbol":return t.toString()===e.toString()}return t===e},ut=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),at=function(){return(at=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};const lt=function(t){function e(e,n){var o=t.call(this)||this;return o.el=e,o.options=n,o.fetchSuggestionApiMethod="findById",o.currentSuggestion=null,o}return ut(e,t),e.prototype.fixData=function(){var t=this,e=this.options.input,n=e.getValue().trim();return new Promise((function(o,r){t.onDispose((function(){return r(new Error(C))})),Promise.resolve(t.isQueryRequestable(n)?t.fetchSuggestion(n).then((function(t){return e.setValue(t?t.value:""),t})):null).then((function(e){t.setCurrentSuggestion(e),o(e)})).catch(r)}))},e.prototype.isQueryRequestable=function(t){var e=this.options,n=e.isQueryRequestable,o=e.minLength;return n?n(t):!x(o)||t.length>=o},e.prototype.setCurrentSuggestion=function(t){var e=this.options,n=e.input,o=e.onInvalidateSelection,r=e.onSelect,i=e.onSelectNothing;t?st(t,this.currentSuggestion)||null==r||r(t,!0,this.el):this.currentSuggestion?null==o||o(this.currentSuggestion,this.el):null==i||i(n.getValue(),this.el),this.currentSuggestion=t},e.prototype.getCurrentSuggestion=function(){return this.currentSuggestion},e.prototype.fetchSuggestion=function(t,e){return this.options.api.fetchSuggestions(this.fetchSuggestionApiMethod,t,at(at({},e),{count:1})).then((function(t){return t[0]||null}))},e.prototype.triggeringSearchCallbacks=function(t){var e=this,n=this.options,o=n.onSearchError,r=n.onSearchStart,s=n.onSearchComplete;return function(n,u){var a=null==r?void 0:r(n,e.el),l=i(a)?a:n,c=t.call(e,l,u);return c.then((function(t){null==s||s(t instanceof Array?t:t?[t]:[],l,e.el)}),(function(t){t.message!==j&&(null==o||o(t,l,e.el))})),c}},e}(r);var ct=function(t,e){void 0===e&&(e=function(){return new Error});var n=null,o=null;return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return n&&st(n.args,r)?n.promise:(o&&o(),(n={args:r,promise:new Promise((function(i,s){o=function(){return s(e.apply(void 0,r))},t.apply(void 0,r).finally((function(){n=null,o=null})).then(i,s)}))}).promise)}},pt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}();const ht=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.fetchSuggestionsApiMethod="suggest",e.fetchSuggestionsCaches={},e.fetchSuggestionsFromApi=e.triggeringSearchCallbacks(ct((function(t,n){return e.options.api.fetchSuggestions(e.fetchSuggestionsApiMethod,t,n)}),(function(){return new Error(j)}))),e}return pt(e,t),e.prototype.fetchSuggestions=function(t,e){var n=this,o=this.options,r=o.preventBadQueries;if(o.noCache)return this.fetchSuggestionsFromApi(t,e);var i=JSON.stringify(e),s=this.fetchSuggestionsCaches[i];if(s){var u=s[t];if(u)return Promise.resolve(u);if(r&&Object.keys(s).some((function(e){return 0===t.indexOf(e)&&0===s[e].length})))return Promise.resolve([])}return this.fetchSuggestionsFromApi(t,e).then((function(e){return(s||(n.fetchSuggestionsCaches[i]={}))[t]=e,e}))},e}(lt);var ft,gt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),dt=function(){return(dt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};!function(t){t[t.CLOSED=0]="CLOSED",t[t.OPENING=1]="OPENING",t[t.OPEN=2]="OPEN",t[t.SELECTING=3]="SELECTING"}(ft||(ft={}));const vt=function(t){function e(e,n){var o=t.call(this,e,n)||this;return o.popoverState=ft.CLOSED,o.popover=null,o.suggestions=[],o.highlightIndex=-1,o.shouldIgnoreBlur=!1,o.fetchSuggestionApiMethod="suggest",o.listenToInput(),o.listenToHelpersElements(),o}return gt(e,t),e.prototype.highlightNext=function(){var t=this.suggestions.length;if(t){var e=this.highlightIndex;this.setHighlightIndex(e<t-1?e+1:0)}},e.prototype.highlightPrev=function(){var t=this.suggestions.length;if(t){var e=this.highlightIndex;this.setHighlightIndex(e>0?e-1:t-1)}},e.prototype.setHighlightIndex=function(t){var e,n=this.options.input;if(this.highlightIndex=t,t>=0){var o=this.suggestions[t];n.getValue().trim()!==o.value&&n.suggestValue(o.value),null===(e=this.popover)||void 0===e||e.highlightItem(t)}else n.suggestValue(null)},e.prototype.getMatchedHighlightIndex=function(){if(this.suggestions.length){var t=this.getCurrentSuggestion();if(t){var e=this.suggestions.find((function(e){return st(e,t)}));if(e)return this.suggestions.indexOf(e)}var n=this.options.input.getValue().trim(),o=this.suggestions.find((function(t){return t.value===n}));if(o)return this.suggestions.indexOf(o);if(this.options.autoHighlightFirst)return 0}return-1},e.prototype.listenToInput=function(){var t=this,e=this.options,n=e.input,o=e.helperElements,r=e.mobileMaxWidth,i=e.scrollOnFocus,s=e.triggerSelectOnBlur,u=e.triggerSelectOnEnter,a=e.triggerSelectOnSpace;this.addDisposableEventListener(this.el,O,(function(){t.getCurrentSuggestion()&&t.setCurrentSuggestion(null),t.updatePopover()})),this.addDisposableEventListener(this.el,"keydown",(function(e){switch(e.key){case"ArrowDown":switch(e.preventDefault(),t.popoverState){case ft.CLOSED:t.updatePopover();break;case ft.OPEN:t.highlightNext()}break;case"ArrowUp":e.preventDefault(),t.popoverState===ft.OPEN&&t.highlightPrev();break;case"Escape":t.popoverState===ft.OPEN&&t.disposePopover();break;case"Enter":u&&t.popoverState===ft.OPEN&&(e.preventDefault(),t.select(t.highlightIndex));break;case" ":a&&function(t,e){if(t!==document.activeElement)return!1;try{var n=t.selectionStart;if("number"==typeof n)return n===t.value.length}catch(t){}return!0}(t.el)&&t.popoverState===ft.OPEN&&(e.preventDefault(),t.select(t.highlightIndex,{continueSelecting:!0}))}})),this.addDisposableEventListener(this.el,"focus",(function(){t.popoverState===ft.CLOSED&&t.updatePopover(),G(window,r)&&(function(t){var e=t.value;try{t.selectionEnd=t.selectionStart=e.length,t.scrollLeft=t.scrollWidth}catch(n){t.value=e}}(t.el),i&&function(t){for(var e=t.getBoundingClientRect().top,n=t.parentElement;e&&n;){var o="BODY"===n.tagName||"HTML"===n.tagName?n.scrollHeight-n.clientHeight:"visible"!==getComputedStyle(n).overflowY?n.scrollHeight-n.offsetHeight:0;if(o){var r=Math.min(o,e);n.scrollTop+=r,e-=r}n=n.parentElement}}(t.el))})),this.addDisposableEventListener(this.el,"blur",(function(e){var r=e.relatedTarget;t.shouldIgnoreBlur||o&&r instanceof Element&&Array.from(o).some((function(t){return t===r||t.contains(r)}))||(s&&t.popoverState!==ft.OPENING&&t.popoverState!==ft.SELECTING&&t.isQueryRequestable(n.getValue().trim())&&t.select(t.highlightIndex),t.disposePopover()),t.shouldIgnoreBlur=!1}))},e.prototype.listenToHelpersElements=function(){var t=this,e=this.options.helperElements;e&&this.addDisposableEventListener(document,"mousedown",(function(n){var o=n.target;o instanceof Element&&Array.from(e).some((function(t){return t===o||t.contains(o)}))&&t.ignoreNextBlur()}))},e.prototype.setPopoverState=function(t){this.popoverState=t},e.prototype.updatePopover=function(){var t=this.options.input.getValue().trim();this.isQueryRequestable(t)?this.updateSuggestions(t):this.disposePopover()},e.prototype.initPopover=function(t){var e=this;this.popover=new J(this.el,dt(dt({},this.options),{showPromo:"FREE"===this.options.plan,items:t,onMousedown:function(){return e.ignoreNextBlur()},onItemClick:function(t){e.el.focus(),e.popoverState===ft.OPEN&&e.select(t)}})),this.setPopoverState(ft.OPEN),this.setHighlightIndex(this.getMatchedHighlightIndex()),this.onDispose((function(){return e.disposePopover()}))},e.prototype.disposePopover=function(){this.popover&&(this.popover.dispose(),this.popover=null,this.setPopoverState(ft.CLOSED),this.setHighlightIndex(-1))},e.prototype.ignoreNextBlur=function(){this.shouldIgnoreBlur=!0},e.prototype.updateSuggestions=function(t){var e=this,n=this.options,o=n.renderSuggestion,r=n.unformattableTokens;this.popoverState===ft.CLOSED&&this.setPopoverState(ft.OPENING),this.fetchSuggestions(t).then((function(n){if(e.suggestions=n,e.popoverState===ft.OPEN&&1===n.length&&st(n[0],e.getCurrentSuggestion()))e.disposePopover();else{var i=n.map((function(e){var i=e.value;return(null==o?void 0:o(e,t,{suggestions:n,unformattableTokens:r}))||function(t,e,n){var o,r,i,s=(o=e,r=null==n?void 0:n.unformattableTokens,i=o.split(tt).filter(Boolean).map(ot).reduce((function(t,e){var n=e.split(et);return Y(t,[e],n.length>1?n:[])}),[]),r&&i.sort((function(t,e){var n=r.includes(t);return n===r.includes(e)?0:n?1:-1})),i).map((function(t){return new RegExp("^((.*)([\\-\\+\\\\\\?!@#$%^&]+))?("+t.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")+")([^\\-\\+\\\\\\?!@#$%^&]*[\\-\\+\\\\\\?!@#$%^&]*)","i")})),u=it(function(t){var e,n=[];for(nt.lastIndex=0;(e=nt.exec(t))&&e[0];){var o=e[1],r=e[2];o&&n.push({text:o,token:ot(o),matched:!1}),r&&n.push({text:r,token:"",matched:!1})}return n}(t),0,s,null==n?void 0:n.unformattableTokens);if(n&&x(n.maxLength)){var a=n.maxLength;return rt(u.reduce((function(t,e){if(a<=0)return t;var n=e.text.length;if(n<=a)return a-=n,Y(t,[e]);var o=Y(t,[X(X({},e),{text:e.text.substr(0,a)+"..."})]);return a=0,o}),[]))}return rt(u)}(i,t,{unformattableTokens:r})}));e.popover?(e.popover.setItems(i),e.setHighlightIndex(e.getMatchedHighlightIndex())):e.initPopover(i)}})).catch(T)},e.prototype.select=function(t,e){var n=this,o=this.options,r=o.input,i=o.formatSelected,s=o.isSuggestionDataComplete,u=o.enrichmentEnabled,a=this.suggestions[t]||null;if(a&&st(a,this.getCurrentSuggestion()))(null==e?void 0:e.continueSelecting)?r.setValue(r.getValue()+" "):this.popoverState===ft.OPEN&&this.disposePopover();else{this.popoverState===ft.OPEN&&this.setPopoverState(ft.SELECTING);var l=a&&((null==i?void 0:i(a))||a.value);a&&r.setValue(l),new Promise((function(t,o){var r;a&&(!function(t){return Boolean(t&&"object"==typeof t&&"qc"in t)}(r=a.data)||null==r.qc)&&u&&!(null==e?void 0:e.continueSelecting)?t(n.fetchSuggestion(a.unrestricted_value)):o()})).catch((function(){return a})).then((function(t){return t||a})).then((function(o){n.setCurrentSuggestion(o),o&&(n.suggestions[t]=o);var u=Boolean(null==e?void 0:e.continueSelecting)&&!(o&&(null==s?void 0:s(o))),a=r.getValue().trim();if(null===l||a===l){var c=o?(null==i?void 0:i(o))||o.value:a;r.setValue(c+(u?" ":""))}u?(n.popoverState===ft.SELECTING&&n.setPopoverState(ft.OPEN),n.updatePopover()):n.popoverState===ft.SELECTING&&n.disposePopover()}))}},e}(ht);var yt=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var o=Array(t),r=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,u=i.length;s<u;s++,r++)o[r]=i[s];return o},mt=function(t,e){return function(t,e,n){var o;if(!(null==e?void 0:e.type))throw new Error('Option "type" is required.');null===(o=q.get(t))||void 0===o||o.dispose();var r=new k(t,n,M(M({},A),function(t){return Object.keys(H).reduce((function(t,e){var n;return"function"==typeof t[e]?t:M(M({},t),((n={})[e]=H[e],n))}),t)}(e)));return q.set(t,r),function(){return B(t)}}(t,e,vt)},bt=function(t,e){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return R.apply(void 0,yt([t,e],n))},St=B}},e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={id:o,exports:{}};return t[o](r,r.exports,n),r.exports}return n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(362)})()}));