1var a, b; 2a = this, b = function () { 3 "use strict"; 4 5 function i(e, t) { 6 for (var n = 0; n < t.length; n++) { 7 var i = t[n]; 8 i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, i.key, i) 9 } 10 } 11 12 function s(e) { 13 return e.innerHTML = "" 14 } 15 16 function d(t, e, n, i, o, r) { 17 i({ 18 event: t, 19 query: e instanceof HTMLInputElement ? e.value : e.innerHTML, 20 matches: o.matches, 21 results: o.list.map(function (e) { 22 return e.value 23 }), 24 selection: o.list.find(function (e) { 25 return t.keyCode === f ? e.index === Number(r.getAttribute(a)) : "mousedown" === t.type ? e.index === Number(t.currentTarget.getAttribute(a)) : void 0 26 }) 27 }), s(n); 28 console.log("selected!"); 29 } 30 31 function e(e, t) { 32 t = t || { 33 bubbles: !1, 34 cancelable: !1, 35 detail: void 0 36 }; 37 var n = document.createEvent("CustomEvent"); 38 return n.initCustomEvent(e, t.bubbles, t.cancelable, t.detail), n 39 } 40 var a = "data-id", 41 n = "autoComplete_list", 42 l = "autoComplete_result", 43 t = "autoComplete_highlighted", 44 h = "autoComplete_selected", 45 f = 13, 46 v = 38, 47 m = 40, 48 Q = function (e) { 49 return "string" == typeof e ? document.querySelector(e) : e() 50 }, 51 U = function (e) { 52 var t = document.createElement(e.element); 53 return t.setAttribute("id", n), e.container && e.container(t), e.destination.insertAdjacentElement(e.position, t), t 54 }, 55 u = function (e) { 56 return "<span class=".concat(t, ">").concat(e, "</span>") 57 }, 58 c = function (e, o, r) { 59 var s = document.createDocumentFragment(); 60 o.forEach(function (e, t) { 61 var n = document.createElement(r.element), 62 i = o[t].index; 63 n.setAttribute(a, i), n.setAttribute("class", l), r.content ? r.content(e, n) : n.innerHTML = e.match || e, s.appendChild(n) 64 }), e.appendChild(s) 65 }, 66 p = function (t, n, i, o) { 67 function r(e) { 68 c.classList.remove(h), a = 1 === e ? c.nextSibling : c.previousSibling 69 } 70 71 function s(e) { 72 (c = e).classList.add(h) 73 } 74 var a, l = n.childNodes, 75 u = l.length - 1, 76 c = void 0; 77 t.onkeydown = function (e) { 78 if (0 < l.length) switch (e.keyCode) { 79 case v: 80 c ? (r(0), s(a || l[u])) : s(l[u]); 81 break; 82 case m: 83 c ? (r(1), s(a || l[0])) : s(l[0]); 84 break; 85 case f: 86 c && d(e, t, n, i, o, c) 87 } 88 }, l.forEach(function (e) { 89 e.onmousedown = function (e) { 90 return d(e, t, n, i, o) 91 } 92 }) 93 }, 94 g = s; 95 e.prototype = window.Event.prototype; 96 var y = { 97 CustomEventWrapper: "function" == typeof window.CustomEvent && window.CustomEvent || e, 98 initElementClosestPolyfill: function () { 99 Element.prototype.matches || (Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector), Element.prototype.closest || (Element.prototype.closest = function (e) { 100 var t = this; 101 do { 102 if (t.matches(e)) return t; 103 t = t.parentElement || t.parentNode 104 } while (null !== t && 1 === t.nodeType); 105 return null 106 }) 107 } 108 }; 109 return function () { 110 function K(e) { 111 ! function (e, t) { 112 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function") 113 }(this, K); 114 var t = e.selector, 115 n = void 0 === t ? "#autoComplete" : t, 116 i = e.data, 117 o = i.key, 118 r = i.src, 119 s = i.cache, 120 a = void 0 === s || s, 121 l = e.query, 122 u = e.trigger, 123 c = (u = void 0 === u ? {} : u).event, 124 d = void 0 === c ? ["input"] : c, 125 h = u.condition, 126 f = void 0 !== h && h, 127 v = e.searchEngine, 128 m = void 0 === v ? "strict" : v, 129 p = e.threshold, 130 g = void 0 === p ? 0 : p, 131 y = e.debounce, 132 b = void 0 === y ? 0 : y, 133 E = e.resultsList, 134 w = (E = void 0 === E ? {} : E).render, 135 C = void 0 !== w && w, 136 L = E.container, 137 k = void 0 !== L && L, 138 x = E.destination, 139 S = E.position, 140 T = void 0 === S ? "afterend" : S, 141 M = E.element, 142 R = void 0 === M ? "ul" : M, 143 q = E.navigation, 144 H = void 0 !== q && q, 145 A = e.sort, 146 P = void 0 !== A && A, 147 I = e.placeHolder, 148 j = e.maxResults, 149 N = void 0 === j ? 5 : j, 150 _ = e.resultItem, 151 V = (_ = void 0 === _ ? {} : _).content, 152 W = void 0 !== V && V, 153 D = _.element, 154 F = void 0 === D ? "li" : D, 155 O = e.noResults, 156 z = e.highlight, 157 B = void 0 !== z && z, 158 G = e.onSelection, 159 J = C ? U({ 160 container: k, 161 destination: x || Q(n), 162 position: T, 163 element: R 164 }) : null; 165 this.selector = n, this.data = { 166 src: function () { 167 return "function" == typeof r ? r() : r 168 }, 169 key: o, 170 cache: a 171 }, this.query = l, this.trigger = { 172 event: d, 173 condition: f 174 }, this.searchEngine = "loose" === m ? "loose" : "function" == typeof m ? m : "strict", this.threshold = g, this.debounce = b, this.resultsList = { 175 //}, this.searchEngine = "loose" === m ? "loose" : "function" == typeof m ? m : "strict", this.threshold = 1, this.debounce = b, this.resultsList = { 176 render: C, 177 view: J, 178 navigation: H 179 }, this.sort = P, this.placeHolder = I, this.maxResults = N, this.resultItem = { 180 content: W, 181 element: F 182 }, this.noResults = O, this.highlight = B, this.onSelection = G, this.init() 183 } 184 return function (e, t, n) { 185 t && i(e.prototype, t), n && i(e, n) 186 }(K, [{ 187 key: "search", 188 value: function (e, t) { 189 var n = t.toLowerCase(); 190 if ("loose" === this.searchEngine) { 191 e = e.replace(/ /g, ""); 192 for (var i = [], o = 0, r = 0; r < n.length; r++) { 193 var s = t[r]; 194 o < e.length && n[r] === e[o] && (s = this.highlight ? u(s) : s, o++), i.push(s) 195 } 196 return o === e.length && i.join("") 197 } 198 if (n.search("\\b"+e) != -1) return e = new RegExp("\\b".concat(e), "i").exec(t), this.highlight ? t.replace(e, u(e)) : t 199 //if (n.includes(e)) return e = new RegExp("\\b".concat(e), "i").exec(t), this.highlight ? t.replace(e, u(e)) : t 200 //if (n.includes(e)) return e = new RegExp("".concat(e), "i").exec(t), this.highlight ? t.replace(e, u(e)) : t 201 } 202 }, {
203 key: "listMatchedResults", 204 value: function (n) { 205 var u = this; 206 return new Promise(function (e) { 207 var l = []; 208 n.filter(function (i, o) { 209 function e(e) { 210 var t = e ? i[e] : i; 211 if (t) { 212 var n = "function" == typeof u.searchEngine ? u.searchEngine(u.queryValue, t) : u.search(u.queryValue, t); 213 n && e ? l.push({ 214 key: e, 215 index: o, 216 match: n, 217 value: i 218 }) : n && !e && l.push({ 219 index: o, 220 match: n, 221 value: i 222 }) 223 } 224 } 225 if (u.data.key) { 226 var t = !0, 227 n = !1, 228 r = void 0; 229 try { 230 for (var s, a = u.data.key[Symbol.iterator](); !(t = (s = a.next()).done); t = !0) { 231 e(s.value) 232 } 233 } catch (e) { 234 n = !0, r = e 235 } finally { 236 try { 237 t || null == a.return || a.return() 238 } finally { 239 if (n) throw r 240 } 241 } 242 } else e() 243 }); 244 var t = u.sort ? l.sort(u.sort).slice(0, u.maxResults) : l.slice(0, u.maxResults); 245 return e({ 246 matches: l.length, 247 list: t 248 }) 249 }) 250 } 251 }, { 252 key: "ignite", 253 value: function () { 254 var a = this, 255 l = Q(this.selector); 256 this.placeHolder && l.setAttribute("placeholder", this.placeHolder); 257 258 function t(t) { 259 Promise.resolve(a.data.cache ? a.dataStream : a.data.src()).then(function (e) { 260 a.dataStream = e, 261 function (t) { 262 function n(e, t) { 263 l.dispatchEvent(new y.CustomEventWrapper("autoComplete", { 264 bubbles: !0, 265 detail: { 266 event: e, 267 input: i, 268 query: o, 269 matches: t ? t.matches : null, 270 results: t ? t.list : null 271 }, 272 cancelable: !0 273 })) 274 } 275 var i = l instanceof HTMLInputElement || l instanceof HTMLTextAreaElement ? l.value.toLowerCase() : l.innerHTML.toLowerCase(), 276 o = a.queryValue = a.query && a.query.manipulate ? a.query.manipulate(i) : i, 277 e = a.resultsList.render, 278 r = a.trigger.condition ? a.trigger.condition(o) : o.length > a.threshold && o.replace(/ /g, "").length; 279 if (e) { 280 var s = a.resultsList.view; 281 g(s); 282 r ? a.listMatchedResults(a.dataStream, t).then(function (e) { 283 n(t, e), a.resultsList.render && (0 === e.list.length && a.noResults ? a.noResults() : (c(s, e.list, a.resultItem), a.onSelection && (a.resultsList.navigation ? a.resultsList.navigation(t, l, s, a.onSelection, e) : p(l, s, a.onSelection, e)))) 284 }) : n(t) 285 } else !e && r && a.listMatchedResults(a.dataStream, t).then(function (e) { 286 n(t, e) 287 }) 288 }(t) 289 }) 290 } 291 this.trigger.event.forEach(function (e) { 292 l.addEventListener(e, function (n, i) { 293 var o; 294 return function () { 295 var e = this, 296 t = arguments; 297 clearTimeout(o), o = setTimeout(function () { 298 return n.apply(e, t) 299 }, i) 300 } 301 }(function (e) { 302 return t(e) 303 }, a.debounce)) 304 }) 305 } 306 }, { 307 key: "init", 308 value: function () { 309 var t = this; 310 this.data.cache ? Promise.resolve(this.data.src()).then(function (e) { 311 t.dataStream = e, t.ignite() 312 }) : this.ignite(), y.initElementClosestPolyfill() 313 } 314 }]), K 315 }() 316}, "object" == typeof exports && "undefined" != typeof module ? module.exports = b() : "function" == typeof define && define.amd ? define(b) : a.autoComplete = b(); 317 318 319 320
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.