!function(){function t(t){var e=t.getBoundingClientRect();return{width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left,x:e.left,y:e.top}}function e(t){if("[object Window]"!==t.toString()){var e=t.ownerDocument;return e?e.defaultView:window}return t}function n(t){var n=e(t);return{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function r(t){return t instanceof e(t).Element||t instanceof Element}function o(t){return t instanceof e(t).HTMLElement||t instanceof HTMLElement}function i(t){return t?(t.nodeName||"").toLowerCase():null}function a(t){return(r(t)?t.ownerDocument:t.document).documentElement}function s(e){return t(a(e)).left+n(e).scrollLeft}function c(t){return e(t).getComputedStyle(t)}function l(t){var e=c(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function u(r,c,u){void 0===u&&(u=!1);var f,p,d=a(c),h=t(r),m=o(c),v={scrollLeft:0,scrollTop:0},g={x:0,y:0};return(m||!m&&!u)&&(("body"!==i(c)||l(d))&&(v=(f=c)!==e(f)&&o(f)?{scrollLeft:(p=f).scrollLeft,scrollTop:p.scrollTop}:n(f)),o(c)?((g=t(c)).x+=c.clientLeft,g.y+=c.clientTop):d&&(g.x=s(d))),{x:h.left+v.scrollLeft-g.x,y:h.top+v.scrollTop-g.y,width:h.width,height:h.height}}function f(t){return{x:t.offsetLeft,y:t.offsetTop,width:t.offsetWidth,height:t.offsetHeight}}function p(t){return"html"===i(t)?t:t.assignedSlot||t.parentNode||t.host||a(t)}function d(t,n){void 0===n&&(n=[]);var r=function t(e){return["html","body","#document"].indexOf(i(e))>=0?e.ownerDocument.body:o(e)&&l(e)?e:t(p(e))}(t),a="body"===i(r),s=e(r),c=a?[s].concat(s.visualViewport||[],l(r)?r:[]):r,u=n.concat(c);return a?u:u.concat(d(p(c)))}function h(t){return["table","td","th"].indexOf(i(t))>=0}function m(t){if(!o(t)||"fixed"===c(t).position)return null;var e=t.offsetParent;if(e){var n=a(e);if("body"===i(e)&&"static"===c(e).position&&"static"!==c(n).position)return n}return e}function v(t){for(var n=e(t),r=m(t);r&&h(r)&&"static"===c(r).position;)r=m(r);return r&&"body"===i(r)&&"static"===c(r).position?n:r||function(t){for(var e=p(t);o(e)&&["html","body"].indexOf(i(e))<0;){var n=c(e);if("none"!==n.transform||"none"!==n.perspective||n.willChange&&"auto"!==n.willChange)return e;e=e.parentNode}return null}(t)||n}var g="top",b="bottom",y="right",w=[g,b,y,"left"],x=w.reduce((function(t,e){return t.concat([e+"-start",e+"-end"])}),[]),O=[].concat(w,["auto"]).reduce((function(t,e){return t.concat([e,e+"-start",e+"-end"])}),[]),j=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function E(t){var e=new Map,n=new Set,r=[];return t.forEach((function(t){e.set(t.name,t)})),t.forEach((function(t){n.has(t.name)||function t(o){n.add(o.name),[].concat(o.requires||[],o.requiresIfExists||[]).forEach((function(r){if(!n.has(r)){var o=e.get(r);o&&t(o)}})),r.push(o)}(t)})),r}function k(t){return t.split("-")[0]}function A(t){return Object.assign(Object.assign({},t),{},{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function L(r,i){return"viewport"===i?A(function(t){var n=e(t),r=a(t),o=n.visualViewport,i=r.clientWidth,c=r.clientHeight,l=0,u=0;return o&&(i=o.width,c=o.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(l=o.offsetLeft,u=o.offsetTop)),{width:i,height:c,x:l+s(t),y:u}}(r)):o(i)?function(e){var n=t(e);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(i):A(function(t){var e=a(t),r=n(t),o=t.ownerDocument.body,i=Math.max(e.scrollWidth,e.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),l=Math.max(e.scrollHeight,e.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),u=-r.scrollLeft+s(t),f=-r.scrollTop;return"rtl"===c(o||e).direction&&(u+=Math.max(e.clientWidth,o?o.clientWidth:0)-i),{width:i,height:l,x:u,y:f}}(a(r)))}function M(t){var e=d(p(t)),n=["absolute","fixed"].indexOf(c(t).position)>=0&&o(t)?v(t):t;return r(n)?e.filter((function(t){return r(t)&&function(t,e){var n=Boolean(e.getRootNode&&e.getRootNode().host);if(t.contains(e))return!0;if(n){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}(t,n)&&"body"!==i(t)})):[]}function S(t){return t.split("-")[1]}function T(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function D(t){var e,n=t.reference,r=t.element,o=t.placement,i=o?k(o):null,a=o?S(o):null,s=n.x+n.width/2-r.width/2,c=n.y+n.height/2-r.height/2;switch(i){case g:e={x:s,y:n.y-r.height};break;case b:e={x:s,y:n.y+n.height};break;case y:e={x:n.x+n.width,y:c};break;case"left":e={x:n.x-r.width,y:c};break;default:e={x:n.x,y:n.y}}var l=i?T(i):null;if(null!=l){var u="y"===l?"height":"width";switch(a){case"start":e[l]=Math.floor(e[l])-Math.floor(n[u]/2-r[u]/2);break;case"end":e[l]=Math.floor(e[l])+Math.ceil(n[u]/2-r[u]/2)}}return e}function P(e,n){void 0===n&&(n={});var o,i=n,s=i.placement,c=void 0===s?e.placement:s,l=i.boundary,u=void 0===l?"clippingParents":l,f=i.rootBoundary,p=void 0===f?"viewport":f,d=i.elementContext,h=void 0===d?"popper":d,m=i.altBoundary,v=void 0!==m&&m,x=i.padding,O=void 0===x?0:x,j=function(t){return Object.assign(Object.assign({},{top:0,right:0,bottom:0,left:0}),t)}("number"!=typeof O?O:(o=O,w.reduce((function(t,e){return t[e]=o,t}),{}))),E="popper"===h?"reference":"popper",k=e.elements.reference,S=e.rects.popper,T=e.elements[v?E:h],P=function(t,e,n){var r="clippingParents"===e?M(t):[].concat(e),o=[].concat(r,[n]),i=o[0],a=o.reduce((function(e,n){var r=L(t,n);return e.top=Math.max(r.top,e.top),e.right=Math.min(r.right,e.right),e.bottom=Math.min(r.bottom,e.bottom),e.left=Math.max(r.left,e.left),e}),L(t,i));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}(r(T)?T:T.contextElement||a(e.elements.popper),u,p),R=t(k),B=D({reference:R,element:S,strategy:"absolute",placement:c}),C=A(Object.assign(Object.assign({},S),B)),H="popper"===h?C:R,W={top:P.top-H.top+j.top,bottom:H.bottom-P.bottom+j.bottom,left:P.left-H.left+j.left,right:H.right-P.right+j.right},I=e.modifiersData.offset;if("popper"===h&&I){var N=I[c];Object.keys(W).forEach((function(t){var e=[y,b].indexOf(t)>=0?1:-1,n=[g,b].indexOf(t)>=0?"y":"x";W[t]+=N[n]*e}))}return W}var R={placement:"bottom",modifiers:[],strategy:"absolute"};function B(){for(var t=arguments.length,e=new Array(t),n=0;n=0}));0===p.length&&(p=f);var d=p.reduce((function(e,n){return e[n]=P(t,{placement:n,boundary:o,rootBoundary:i,padding:a})[k(n)],e}),{});return Object.keys(d).sort((function(t,e){return d[t]-d[e]}))}(e,{placement:n,boundary:u,rootBoundary:f,padding:l,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),L=e.rects.reference,M=e.rects.popper,T=new Map,D=!0,R=A[0],B=0;B=0,N=I?"width":"height",U=P(e,{placement:C,boundary:u,rootBoundary:f,altBoundary:p,padding:l}),V=I?W?y:"left":W?b:g;L[N]>M[N]&&(V=q(V));var _=q(V),z=[];if(i&&z.push(U[H]<=0),s&&z.push(U[V]<=0,U[_]<=0),z.every((function(t){return t}))){R=C,D=!1;break}T.set(C,z)}if(D)for(var F=function(t){var e=A.find((function(e){var n=T.get(e);if(n)return n.slice(0,t).every((function(t){return t}))}));if(e)return R=e,"break"},X=h?3:1;X>0;X--){if("break"===F(X))break}e.placement!==R&&(e.modifiersData[r]._skip=!0,e.placement=R,e.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function z(t,e,n){return Math.max(t,Math.min(e,n))}var F={name:"preventOverflow",enabled:!0,phase:"main",fn:function(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,i=void 0===o||o,a=n.altAxis,s=void 0!==a&&a,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,p=n.padding,d=n.tether,h=void 0===d||d,m=n.tetherOffset,w=void 0===m?0:m,x=P(e,{boundary:c,rootBoundary:l,padding:p,altBoundary:u}),O=k(e.placement),j=S(e.placement),E=!j,A=T(O),L="x"===A?"y":"x",M=e.modifiersData.popperOffsets,D=e.rects.reference,R=e.rects.popper,B="function"==typeof w?w(Object.assign(Object.assign({},e.rects),{},{placement:e.placement})):w,C={x:0,y:0};if(M){if(i){var H="y"===A?g:"left",W="y"===A?b:y,I="y"===A?"height":"width",N=M[A],U=M[A]+x[H],q=M[A]-x[W],V=h?-R[I]/2:0,$="start"===j?D[I]:R[I],_="start"===j?-R[I]:-D[I],F=e.elements.arrow,X=h&&F?f(F):{width:0,height:0},Y=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},K=Y[H],G=Y[W],J=z(0,D[I],X[I]),Q=E?D[I]/2-V-J-K-B:$-J-K-B,Z=E?-D[I]/2+V+J+G+B:_+J+G+B,tt=e.elements.arrow&&v(e.elements.arrow),et=tt?"y"===A?tt.clientTop||0:tt.clientLeft||0:0,nt=e.modifiersData.offset?e.modifiersData.offset[e.placement][A]:0,rt=M[A]+Q-nt-et,ot=M[A]+Z-nt,it=z(h?Math.min(U,rt):U,N,h?Math.max(q,ot):q);M[A]=it,C[A]=it-N}if(s){var at="x"===A?g:"left",st="x"===A?b:y,ct=M[L],lt=z(ct+x[at],ct,ct-x[st]);M[L]=lt,C[L]=lt-ct}e.modifiersData[r]=C}},requiresIfExists:["offset"]};function X(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}return n}(t,e)||K(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n":">",'"':""","'":"'"};function tt(t){return t.replace(/[&<>"']/g,(function(t){return Z[t]}))}function et(t,e){if(!e)return tt(t);var n="("+function(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}(e)+")";return tt(t.replace(new RegExp(n,"gi"),"$1")).replace(/<(\/?mark)>/g,"<$1>")}var nt=function(){function t(e){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.input=e.input,this.lookup=e.lookup,this.onSelect=e.onSelect,this.silent=!0===e.silent,this.highlight=!0===e.highlight,this.cache=!0===e.cache,this.noResultsMessage=e.noResultsMessage||"-- no corresponding results --",this.cachedResults=[],this.emptyResults=[],this.popper=null,this.selected=null,this.showing=!1;var r,o,i="id_".concat(this.input.id);this.template=(r='
    '),(o=document.createElement("template")).innerHTML=r.trim(),o.content.firstChild),this.input.parentNode.append(this.template),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("role","combobox"),this.input.setAttribute("aria-owns",i),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-expanded","false"),this.input.addEventListener("input",(function(){var t=n.input.value.trim();n.selected=null,t?n.suggest(t):n.showing&&n.destroy()})),this.input.addEventListener("focusout",(function(){setTimeout((function(){n.destroy()}),200)})),this.input.addEventListener("keydown",(function(t){if(["ArrowUp","ArrowDown","Escape","Enter","Tab"].includes(t.key)){var e=["ArrowUp","ArrowDown"].includes(t.key);switch(e&&n.selected&&n.selected.classList.remove("selected","mouseover"),t.key){case"ArrowUp":var r=n.template.lastChild;n.selected=n.selected&&n.selected.previousElementSibling||r,n.selected.classList.contains("no-results")||t.preventDefault();break;case"ArrowDown":var o=n.template.firstChild;n.selected=n.selected&&n.selected.nextElementSibling||o;break;case"Escape":n.destroy();break;case"Enter":n.selected&&!n.selected.classList.contains("mouseover")&&(t.preventDefault(),n.triggerOnSelect(n.selected));break;case"Tab":n.selected&&!t.shiftKey&&(n.input.value=n.selected.textContent)}e&&n.selected&&!n.selected.classList.contains("no-results")&&(n.selected.classList.add("selected"),n.input.value=n.selected.textContent,n.input.setAttribute("aria-activedescendant",n.selected.id))}})),this.template.addEventListener("click",(function(t){t.stopPropagation(),n.triggerOnSelect(t.target.closest("li"))})),this.template.addEventListener("mouseover",(function(t){"LI"!==t.target.tagName||t.target.classList.contains("no-results")||(Array.from(n.template.childNodes).forEach((function(e){return e!==t.target&&e.classList.remove("selected","mouseover")})),n.selected=t.target,n.selected.classList.add("selected","mouseover"))}))}var e,n,r;return e=t,(n=[{key:"suggest",value:function(t){var e=this;if(this.cache){if(this.emptyResults.filter((function(e){return t.startsWith(Object.keys(e)[0])})).length)return void this.render([]);var n=X(this.cachedResults.filter((function(e){return e[t]})),1)[0];if(n)return void this.render(n[t])}this.lookup(t).then((function(n){var r,o,i,a=n.map((function(n){return{name:e.highlight?et(n.name,t):tt(n.name),value:tt(n.value)}}));e.cache&&(a.length?e.cachedResults:e.emptyResults).push((i=a,(o=t)in(r={})?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i,r)),e.render(a)}))}},{key:"render",value:function(t){if(this.popper||(this.popper=this.create()),t.length){this.template.innerHTML="";var e,n=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=K(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}(t.entries());try{for(n.s();!(e=n.n()).done;){var r=X(e.value,2),o=r[0],i=r[1];this.template.innerHTML+='
  • ').concat(i.name,"
  • ")}}catch(t){n.e(t)}finally{n.f()}}else{if(this.silent)return void this.destroy();this.template.querySelector(".no-results")||(this.template.innerHTML='"))}this.showing=!0,this.template.style.display="block",this.input.setAttribute("aria-expanded","true")}},{key:"destroy",value:function(){this.popper&&(this.input.setAttribute("aria-expanded","false"),this.template.style.display="none",this.template.innerHTML="",this.selected=null,this.showing=!1,this.popper.destroy(),this.popper=null)}},{key:"create",value:function(){return Q(this.input,this.template,{placement:"bottom-start"})}},{key:"triggerOnSelect",value:function(t){if(!t.classList.contains("no-results")){this.destroy(),this.input.value=t.textContent;var e=t.getAttribute("data-value");e&&this.onSelect&&this.onSelect(e)}}}])&&Y(e.prototype,n),r&&Y(e,r),t}();globalThis.AutoComplete=nt}(); //# sourceMappingURL=autocomplete.js.map