PageSourceSearch

https://chronodiali.ma/js/selectize.js

js chronodiali.ma collected 2026-10-07 01:23:05 UTC 68,938 bytes, 1,246 lines download raw bytes

1/*! selectize.js - v0.12.6 | https://github.com/selectize/selectize.js | Apache License (v2) */ ! function (t, e) {
2    "function" == typeof define && define.amd ? define("sifter", e) : "object" == typeof exports ? module.exports = e() : t.Sifter = e()
3}(this, function () {
4    var t = function (t, e) {
5        this.items = t, this.settings = e || {
6            diacritics: !0
7        }
8    };
9    t.prototype.tokenize = function (t) {
10        if (!(t = s(String(t || "").toLowerCase())) || !t.length) return [];
11        var e, i, n, r, l = [],
12            p = t.split(/ +/);
13        for (e = 0, i = p.length; e < i; e++) {
14            if (n = o(p[e]), this.settings.diacritics)
15                for (r in a) a.hasOwnProperty(r) && (n = n.replace(RegExp(r, "g"), a[r]));
16            l.push({
17                string: p[e],
18                regex: RegExp(n, "i")
19            })
20        }
21        return l
22    }, t.prototype.iterator = function (t, e) {
23        var i;
24        (i = r(t) ? Array.prototype.forEach || function (t) {
25            for (var e = 0, i = this.length; e < i; e++) t(this[e], e, this)
26        } : function (t) {
27            for (var e in this) this.hasOwnProperty(e) && t(this[e], e, this)
28        }).apply(t, [e])
29    }, t.prototype.getScoreFunction = function (t, e) {
30        s = this, r = (t = s.prepareSearch(t, e)).tokens, o = t.options.fields, a = r.length, l = t.options.nesting;
31        var i, s, o, r, a, l, p = function (t, e) {
32                var i, n;
33                return t ? -1 === (n = (t = String(t || "")).search(e.regex)) ? 0 : (i = e.string.length / t.length, 0 === n && (i += .5), i) : 0
34            },
35            u = (i = o.length) ? 1 === i ? function (t, e) {
36                return p(n(e, o[0], l), t)
37            } : function (t, e) {
38                for (var s = 0, r = 0; s < i; s++) r += p(n(e, o[s], l), t);
39                return r / i
40            } : function () {
41                return 0
42            };
43        return a ? 1 === a ? function (t) {
44            return u(r[0], t)
45        } : "and" === t.options.conjunction ? function (t) {
46            for (var e, i = 0, n = 0; i < a; i++) {
47                if ((e = u(r[i], t)) <= 0) return 0;
48                n += e
49            }
50            return n / a
51        } : function (t) {
52            for (var e = 0, i = 0; e < a; e++) i += u(r[e], t);
53            return i / a
54        } : function () {
55            return 0
56        }
57    }, t.prototype.getSortFunction = function (t, i) {
58        var s, o, r, a, l, p, u, c, d, h, f;
59        if (r = this, f = !(t = r.prepareSearch(t, i)).query && i.sort_empty || i.sort, d = function (t, e) {
60                return "$score" === t ? e.score : n(r.items[e.id], t, i.nesting)
61            }, l = [], f)
62            for (s = 0, o = f.length; s < o; s++)(t.query || "$score" !== f[s].field) && l.push(f[s]);
63        if (t.query) {
64            for (h = !0, s = 0, o = l.length; s < o; s++)
65                if ("$score" === l[s].field) {
66                    h = !1;
67                    break
68                } h && l.unshift({
69                field: "$score",
70                direction: "desc"
71            })
72        } else
73            for (s = 0, o = l.length; s < o; s++)
74                if ("$score" === l[s].field) {
75                    l.splice(s, 1);
76                    break
77                } for (c = [], s = 0, o = l.length; s < o; s++) c.push("desc" === l[s].direction ? -1 : 1);
78        return (p = l.length) ? 1 === p ? (a = l[0].field, u = c[0], function (t, i) {
79            return u * e(d(a, t), d(a, i))
80        }) : function (t, i) {
81            var n, s, o;
82            for (n = 0; n < p; n++)
83                if (o = l[n].field, s = c[n] * e(d(o, t), d(o, i))) return s;
84            return 0
85        } : null
86    }, t.prototype.prepareSearch = function (t, e) {
87        if ("object" == typeof t) return t;
88        var n = (e = i({}, e)).fields,
89            s = e.sort,
90            o = e.sort_empty;
91        return n && !r(n) && (e.fields = [n]), s && !r(s) && (e.sort = [s]), o && !r(o) && (e.sort_empty = [o]), {
92            options: e,
93            query: String(t || "").toLowerCase(),
94            tokens: this.tokenize(t),
95            total: 0,
96            items: []
97        }
98    }, t.prototype.search = function (t, e) {
99        var i, n, s, o;
100        return e = (n = this.prepareSearch(t, e)).options, t = n.query, o = e.score || this.get
vendor: 12,077 bytes, lines 100-354
100ScoreFunction(n), t.length ? this.iterator(this.items, function (t, s) {
101            i = o(t), (!1 === e.filter || i > 0) && n.items.push({
102                score: i,
103                id: s
104            })
105        }) : this.iterator(this.items, function (t, e) {
106            n.items.push({
107                score: 1,
108                id: e
109            })
110        }), (s = this.getSortFunction(n, e)) && n.items.sort(s), n.total = n.items.length, "number" == typeof e.limit && (n.items = n.items.slice(0, e.limit)), n
111    };
112    var e = function (t, e) {
113            return "number" == typeof t && "number" == typeof e ? t > e ? 1 : t < e ? -1 : 0 : (t = l(String(t || ""))) > (e = l(String(e || ""))) ? 1 : e > t ? -1 : 0
114        },
115        i = function (t, e) {
116            var i, n, s, o;
117            for (i = 1, n = arguments.length; i < n; i++)
118                if (o = arguments[i])
119                    for (s in o) o.hasOwnProperty(s) && (t[s] = o[s]);
120            return t
121        },
122        n = function (t, e, i) {
123            if (t && e) {
124                if (!i) return t[e];
125                for (var n = e.split("."); n.length && (t = t[n.shift()]););
126                return t
127            }
128        },
129        s = function (t) {
130            return (t + "").replace(/^\s+|\s+$|/g, "")
131        },
132        o = function (t) {
133            return (t + "").replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1")
134        },
135        r = Array.isArray || "undefined" != typeof $ && $.isArray || function (t) {
136            return "[object Array]" === Object.prototype.toString.call(t)
137        },
138        a = {
139            a: "[aḀḁĂă\xc2\xe2ǍǎȺⱥȦȧẠạ\xc4\xe4\xc0\xe0\xc1\xe1Āā\xc3\xe3\xc5\xe5ąĄ\xc3ąĄ]",
140            b: "[b␢βΒB฿\uD800\uDF01ᛒ]",
141            c: "[cĆćĈĉČčĊċC̄c̄\xc7\xe7ḈḉȻȼƇƈɕᴄCc]",
142            d: "[dĎďḊḋḐḑḌḍḒḓḎḏĐđD̦d̦ƉɖƊɗƋƌᵭᶁᶑȡᴅDd\xf0]",
143            e: "[e\xc9\xe9\xc8\xe8\xca\xeaḘḙĚěĔĕẼẽḚḛẺẻĖė\xcb\xebĒēȨȩĘęᶒɆɇȄȅẾếỀềỄễỂểḜḝḖḗḔḕȆȇẸẹỆệⱸᴇEeɘǝƏƐε]",
144            f: "[fƑƒḞḟ]",
145            g: "[gɢ₲ǤǥĜĝĞğĢģƓɠĠġ]",
146            h: "[hĤĥĦħḨḩẖẖḤḥḢḣɦʰǶƕ]",
147            i: "[i\xcd\xed\xcc\xecĬĭ\xce\xeeǏǐ\xcf\xefḮḯĨĩĮįĪīỈỉȈȉȊȋỊịḬḭƗɨɨ̆ᵻᶖİiIıɪIi]",
148            j: "[jȷĴĵɈɉʝɟʲ]",
149            k: "[kƘƙꝀꝁḰḱǨǩḲḳḴḵκϰ₭]",
150            l: "[lŁłĽľĻļĹĺḶḷḸḹḼḽḺḻĿŀȽƚⱠⱡⱢɫɬᶅɭȴʟLl]",
151            n: "[nŃńǸǹŇň\xd1\xf1ṄṅŅņṆṇṊṋṈṉN̈n̈ƝɲȠƞᵰᶇɳȵɴNnŊŋ]",
152            o: "[o\xd8\xf8\xd6\xf6\xd3\xf3\xd2\xf2\xd4\xf4ǑǒŐőŎŏȮȯỌọƟɵƠơỎỏŌō\xd5\xf5ǪǫȌȍՕօ]",
153            p: "[pṔṕṖṗⱣᵽƤƥᵱ]",
154            q: "[qꝖꝗʠɊɋꝘꝙq̃]",
155            r: "[rŔŕɌɍŘřŖŗṘṙȐȑȒȓṚṛⱤɽ]",
156            s: "[sŚśṠṡṢṣꞨꞩŜŝŠšŞşȘșS̈s̈]",
157            t: "[tŤťṪṫŢţṬṭƮʈȚțṰṱṮṯƬƭ]",
158            u: "[uŬŭɄʉỤụ\xdc\xfc\xda\xfa\xd9\xf9\xdb\xfbǓǔŰűŬŭƯưỦủŪūŨũŲųȔȕ∪]",
159            v: "[vṼṽṾṿƲʋꝞꝟⱱʋ]",
160            w: "[wẂẃẀẁŴŵẄẅẆẇẈẉ]",
161            x: "[xẌẍẊẋχ]",
162            y: "[y\xdd\xfdỲỳŶŷŸ\xffỸỹẎẏỴỵɎɏƳƴ]",
163            z: "[zŹźẐẑŽžŻżẒẓẔẕƵƶ]"
164        },
165        l = function () {
166            var t, e, i, n, s = "",
167                o = {};
168            for (i in a)
169                if (a.hasOwnProperty(i))
170                    for (s += n = a[i].substring(2, a[i].length - 1), t = 0, e = n.length; t < e; t++) o[n.charAt(t)] = i;
171            var r = RegExp("[" + s + "]", "g");
172            return function (t) {
173                return t.replace(r, function (t) {
174                    return o[t]
175                }).toLowerCase()
176            }
177        }();
178    return t
179}),
180function (t, e) {
181    "function" == typeof define && define.amd ? define("microplugin", e) : "object" == typeof exports ? module.exports = e() : t.MicroPlugin = e()
182}(this, function () {
183    var t = {};
184    t.mixin = function (t) {
185        t.plugins = {}, t.prototype.initializePlugins = function (t) {
186            var i, n, s, o = this,
187                r = [];
188            if (o.plugins = {
189                    names: [],
190                    settings: {},
191                    requested: {},
192                    loaded: {}
193                }, e.isArray(t))
194                for (i = 0, n = t.length; i < n; i++) "string" == typeof t[i] ? r.push(t[i]) : (o.plugins.settings[t[i].name] = t[i].options, r.push(t[i].name));
195            else if (t)
196                for (s in t) t.hasOwnProperty(s) && (o.plugins.settings[s] = t[s], r.push(s));
197            for (; r.length;) o.require(r.shift())
198        }, t.prototype.loadPlugin = function (e) {
199            var i = this.plugins,
200                n = t.plugins[e];
201            if (!t.plugins.hasOwnProperty(e)) throw Error('Unable to find "' + e + '" plugin');
202            i.requested[e] = !0, i.loaded[e] = n.fn.apply(this, [this.plugins.settings[e] || {}]), i.names.push(e)
203        }, t.prototype.require = function (t) {
204            var e = this.plugins;
205            if (!this.plugins.loaded.hasOwnProperty(t)) {
206                if (e.requested[t]) throw Error('Plugin has circular dependency ("' + t + '")');
207                this.loadPlugin(t)
208            }
209            return e.loaded[t]
210        }, t.define = function (e, i) {
211            t.plugins[e] = {
212                name: e,
213                fn: i
214            }
215        }
216    };
217    var e = {
218        isArray: Array.isArray || function (t) {
219            return "[object Array]" === Object.prototype.toString.call(t)
220        }
221    };
222    return t
223}),
224function (t, e) {
225    "function" == typeof define && define.amd ? define("selectize", ["jquery", "sifter", "microplugin"], e) : "object" == typeof exports ? module.exports = e(require("jquery"), require("sifter"), require("microplugin")) : t.Selectize = e(t.jQuery, t.Sifter, t.MicroPlugin)
226}(this, function (t, e, i) {
227    "use strict";
228    var n = function (t, e) {
229        if ("string" != typeof e || e.length) {
230            var i = "string" == typeof e ? RegExp(e, "i") : e,
231                n = function (t) {
232                    var e = 0;
233                    if (3 === t.nodeType) {
234                        var s = t.data.search(i);
235                        if (s >= 0 && t.data.length > 0) {
236                            var o = t.data.match(i),
237                                r = document.createElement("span");
238                            r.className = "highlight";
239                            var a = t.splitText(s),
240                                l = (a.splitText(o[0].length), a.cloneNode(!0));
241                            r.appendChild(l), a.parentNode.replaceChild(r, a), e = 1
242                        }
243                    } else if (1 === t.nodeType && t.childNodes && !/(script|style)/i.test(t.tagName) && ("highlight" !== t.className || "SPAN" !== t.tagName))
244                        for (var p = 0; p < t.childNodes.length; ++p) p += n(t.childNodes[p]);
245                    return e
246                };
247            return t.each(function () {
248                n(this)
249            })
250        }
251    };
252    t.fn.removeHighlight = function () {
253        return this.find("span.highlight").each(function () {
254            this.parentNode.firstChild.nodeName;
255            var t = this.parentNode;
256            t.replaceChild(this.firstChild, this), t.normalize()
257        }).end()
258    };
259    var s = function () {};
260    s.prototype = {
261        on: function (t, e) {
262            this._events = this._events || {}, this._events[t] = this._events[t] || [], this._events[t].push(e)
263        },
264        off: function (t, e) {
265            var i = arguments.length;
266            return 0 === i ? delete this._events : 1 === i ? delete this._events[t] : (this._events = this._events || {}, void(t in this._events != !1 && this._events[t].splice(this._events[t].indexOf(e), 1)))
267        },
268        trigger: function (t) {
269            if (this._events = this._events || {}, t in this._events != !1)
270                for (var e = 0; e < this._events[t].length; e++) this._events[t][e].apply(this, Array.prototype.slice.call(arguments, 1))
271        }
272    }, s.mixin = function (t) {
273        for (var e = ["on", "off", "trigger"], i = 0; i < e.length; i++) t.prototype[e[i]] = s.prototype[e[i]]
274    };
275    var o = /Mac/.test(navigator.userAgent),
276        r = o ? 91 : 17,
277        a = o ? 18 : 17,
278        l = !/android/i.test(window.navigator.userAgent) && !!document.createElement("input").validity,
279        p = function (t) {
280            return void 0 !== t
281        },
282        u = function (t) {
283            return null == t ? null : "boolean" == typeof t ? t ? "1" : "0" : t + ""
284        },
285        c = function (t) {
286            return (t + "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;")
287        },
288        d = {};
289    d.before = function (t, e, i) {
290        var n = t[e];
291        t[e] = function () {
292            return i.apply(t, arguments), n.apply(t, arguments)
293        }
294    }, d.after = function (t, e, i) {
295        var n = t[e];
296        t[e] = function () {
297            var e = n.apply(t, arguments);
298            return i.apply(t, arguments), e
299        }
300    };
301    var h, f = function (t) {
302            var e = !1;
303            return function () {
304                e || (e = !0, t.apply(this, arguments))
305            }
306        },
307        g = function (t, e) {
308            var i;
309            return function () {
310                var n = this,
311                    s = arguments;
312                window.clearTimeout(i), i = window.setTimeout(function () {
313                    t.apply(n, s)
314                }, e)
315            }
316        },
317        v = function (t, e, i) {
318            var n, s = t.trigger,
319                o = {};
320            for (n in t.trigger = function () {
321                    var i = arguments[0];
322                    if (-1 === e.indexOf(i)) return s.apply(t, arguments);
323                    o[i] = arguments
324                }, i.apply(t, []), t.trigger = s, o) o.hasOwnProperty(n) && s.apply(t, o[n])
325        },
326        m = function (t, e, i, n) {
327            t.on(e, i, function (e) {
328                for (var i = e.target; i && i.parentNode !== t[0];) i = i.parentNode;
329                return e.currentTarget = i, n.apply(this, [e])
330            })
331        },
332        y = function (t) {
333            var e = {};
334            if ("selectionStart" in t) e.start = t.selectionStart, e.length = t.selectionEnd - e.start;
335            else if (document.selection) {
336                t.focus();
337                var i = document.selection.createRange(),
338                    n = document.selection.createRange().text.length;
339                i.moveStart("character", -t.value.length), e.start = i.text.length - n, e.length = n
340            }
341            return e
342        },
343        O = function (t, e, i) {
344            var n, s, o = {};
345            if (i)
346                for (n = 0, s = i.length; n < s; n++) o[i[n]] = t.css(i[n]);
347            else o = t.css();
348            e.css(o)
349        },
350        C = function (e) {
351            var i = null,
352                n = function (n, s) {
353                    var o, r, a, l, p, u, c, d, h, f;
354                    n = n || window.event || {}, s = s || {}, n.metaKey || n.altKey || (s.force || !1 !== e.data("grow")) && (o = e.val(), n.type && "keydown" === n.type.toLowerCase() && (a = (r = n.keyCode) >= 48 && r <= 57 || r >= 65 && r <= 90 || r >= 96 && r <= 111 || r >= 186 && r <= 222 || 32 === r, 46 === r || 8 === r ? (d = y(e[0])).length ? o = o.substring(0, d.start) + o.substring(d.start + d.length) : 8 === r && d.start ? o = o.substring(0, d.start - 1) + o.substring(d.start + 1) : 46 === r && void 0 !== d.start && (o = o.substring(0, d.start) + o.substring(d.start + 1)) : a && (u = n.shift
vendor: 27,448 bytes, lines 354-817
354Key, c = String.fromCharCode(n.keyCode), o += c = u ? c.toUpperCase() : c.toLowerCase())), l = e.attr("placeholder"), !o && l && (o = l), (p = (h = o, f = e, (h ? (b.$testInput || (b.$testInput = t("<span>").css({
355                        position: "absolute",
356                        top: -99999,
357                        left: -99999,
358                        width: "auto",
359                        padding: 0,
360                        whiteSpace: "pre"
361                    }).appendTo("body")), b.$testInput.text(h), O(f, b.$testInput, ["letterSpacing", "fontSize", "fontFamily", "fontWeight", "textTransform"]), b.$testInput.width()) : 0) + 4)) !== i && (i = p, e.width(p), e.triggerHandler("resize")))
362                };
363            e.on("keydown keyup update blur", n), n()
364        },
365        w = function (t) {
366            var e = document.createElement("div");
367            return e.appendChild(t.cloneNode(!0)), e.innerHTML
368        },
369        b = function (i, n) {
370            var s, o, r, a, l = this;
371            (a = i[0]).selectize = l;
372            var p = window.getComputedStyle && window.getComputedStyle(a, null);
373            if (r = (r = p ? p.getPropertyValue("direction") : a.currentStyle && a.currentStyle.direction) || i.parents("[dir]:first").attr("dir") || "", t.extend(l, {
374                    order: 0,
375                    settings: n,
376                    $input: i,
377                    tabIndex: i.attr("tabindex") || "",
378                    tagType: "select" === a.tagName.toLowerCase() ? 1 : 2,
379                    rtl: /rtl/i.test(r),
380                    eventNS: ".selectize" + ++b.count,
381                    highlightedValue: null,
382                    isBlurring: !1,
383                    isOpen: !1,
384                    isDisabled: !1,
385                    isRequired: i.is("[required]"),
386                    isInvalid: !1,
387                    isLocked: !1,
388                    isFocused: !1,
389                    isInputHidden: !1,
390                    isSetup: !1,
391                    isShiftDown: !1,
392                    isCmdDown: !1,
393                    isCtrlDown: !1,
394                    ignoreFocus: !1,
395                    ignoreBlur: !1,
396                    ignoreHover: !1,
397                    hasOptions: !1,
398                    currentResults: null,
399                    lastValue: "",
400                    caretPos: 0,
401                    loading: 0,
402                    loadedSearches: {},
403                    $activeOption: null,
404                    $activeItems: [],
405                    optgroups: {},
406                    options: {},
407                    userOptions: {},
408                    items: [],
409                    renderCache: {},
410                    onSearchChange: null === n.loadThrottle ? l.onSearchChange : g(l.onSearchChange, n.loadThrottle)
411                }), l.sifter = new e(this.options, {
412                    diacritics: n.diacritics
413                }), l.settings.options) {
414                for (s = 0, o = l.settings.options.length; s < o; s++) l.registerOption(l.settings.options[s]);
415                delete l.settings.options
416            }
417            if (l.settings.optgroups) {
418                for (s = 0, o = l.settings.optgroups.length; s < o; s++) l.registerOptionGroup(l.settings.optgroups[s]);
419                delete l.settings.optgroups
420            }
421            l.settings.mode = l.settings.mode || (1 === l.settings.maxItems ? "single" : "multi"), "boolean" != typeof l.settings.hideSelected && (l.settings.hideSelected = "multi" === l.settings.mode), l.initializePlugins(l.settings.plugins), l.setupCallbacks(), l.setupTemplates(), l.setup()
422        };
423    return s.mixin(b), void 0 !== i ? i.mixin(b) : (h = {
424        explanation: 'Make sure you either: (1) are using the "standalone" version of Selectize, or (2) require MicroPlugin before you load Selectize.'
425    }, console.error("Selectize: Dependency MicroPlugin is missing"), h.explanation && (console.group && console.group(), console.error(h.explanation), console.group && console.groupEnd())), t.extend(b.prototype, {
426        setup: function () {
427            var e, i, n, s, p, u, c, d, h, f, g = this,
428                v = g.settings,
429                y = g.eventNS,
430                O = t(window),
431                w = t(document),
432                b = g.$input;
433            if (c = g.settings.mode, d = b.attr("class") || "", e = t("<div>").addClass(v.wrapperClass).addClass(d).addClass(c), i = t("<div>").addClass(v.inputClass).addClass("items").appendTo(e), n = t('<input type="text" autocomplete="off">').appendTo(i).attr("tabindex", b.is(":disabled") ? "-1" : g.tabIndex), u = t(v.dropdownParent || e), s = t("<div>").addClass(v.dropdownClass).addClass(c).hide().appendTo(u), p = t("<div>").addClass(v.dropdownContentClass).appendTo(s), (f = b.attr("id")) && (n.attr("id", f + "-selectized"), t("label[for='" + f + "']").attr("for", f + "-selectized")), g.settings.copyClassesToDropdown && s.addClass(d), e.css({
434                    width: b[0].style.width
435                }), g.plugins.names.length && (h = "plugin-" + g.plugins.names.join(" plugin-"), e.addClass(h), s.addClass(h)), (null === v.maxItems || v.maxItems > 1) && 1 === g.tagType && b.attr("multiple", "multiple"), g.settings.placeholder && n.attr("placeholder", v.placeholder), !g.settings.splitOn && g.settings.delimiter) {
436                var _ = g.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
437                g.settings.splitOn = RegExp("\\s*" + _ + "+\\s*")
438            }
439            b.attr("autocorrect") && n.attr("autocorrect", b.attr("autocorrect")), b.attr("autocapitalize") && n.attr("autocapitalize", b.attr("autocapitalize")), n[0].type = b[0].type, g.$wrapper = e, g.$control = i, g.$control_input = n, g.$dropdown = s, g.$dropdown_content = p, s.on("mouseenter mousedown click", "[data-disabled]>[data-selectable]", function (t) {
440                t.stopImmediatePropagation()
441            }), s.on("mouseenter", "[data-selectable]", function () {
442                return g.onOptionHover.apply(g, arguments)
443            }), s.on("mousedown click", "[data-selectable]", function () {
444                return g.onOptionSelect.apply(g, arguments)
445            }), m(i, "mousedown", "*:not(input)", function () {
446                return g.onItemSelect.apply(g, arguments)
447            }), C(n), i.on({
448                mousedown: function () {
449                    return g.onMouseDown.apply(g, arguments)
450                },
451                click: function () {
452                    return g.onClick.apply(g, arguments)
453                }
454            }), n.on({
455                mousedown: function (t) {
456                    t.stopPropagation()
457                },
458                keydown: function () {
459                    return g.onKeyDown.apply(g, arguments)
460                },
461                keyup: function () {
462                    return g.onKeyUp.apply(g, arguments)
463                },
464                keypress: function () {
465                    return g.onKeyPress.apply(g, arguments)
466                },
467                resize: function () {
468                    g.positionDropdown.apply(g, [])
469                },
470                blur: function () {
471                    return g.onBlur.apply(g, arguments)
472                },
473                focus: function () {
474                    return g.ignoreBlur = !1, g.onFocus.apply(g, arguments)
475                },
476                paste: function () {
477                    return g.onPaste.apply(g, arguments)
478                }
479            }), w.on("keydown" + y, function (t) {
480                g.isCmdDown = t[o ? "metaKey" : "ctrlKey"], g.isCtrlDown = t[o ? "altKey" : "ctrlKey"], g.isShiftDown = t.shiftKey
481            }), w.on("keyup" + y, function (t) {
482                t.keyCode === a && (g.isCtrlDown = !1), 16 === t.keyCode && (g.isShiftDown = !1), t.keyCode === r && (g.isCmdDown = !1)
483            }), w.on("mousedown" + y, function (t) {
484                if (g.isFocused) {
485                    if (t.target === g.$dropdown[0] || t.target.parentNode === g.$dropdown[0]) return !1;
486                    g.$control.has(t.target).length || t.target === g.$control[0] || g.blur(t.target)
487                }
488            }), O.on(["scroll" + y, "resize" + y].join(" "), function () {
489                g.isOpen && g.positionDropdown.apply(g, arguments)
490            }), O.on("mousemove" + y, function () {
491                g.ignoreHover = !1
492            }), this.revertSettings = {
493                $children: b.children().detach(),
494                tabindex: b.attr("tabindex")
495            }, b.attr("tabindex", -1).hide().after(g.$wrapper), t.isArray(v.items) && (g.setValue(v.items), delete v.items), l && b.on("invalid" + y, function (t) {
496                t.preventDefault(), g.isInvalid = !0, g.refreshState()
497            }), g.updateOriginalInput(), g.refreshItems(), g.refreshState(), g.updatePlaceholder(), g.isSetup = !0, b.is(":disabled") && g.disable(), g.on("change", this.onChange), b.data("selectize", g), b.addClass("selectized"), g.trigger("initialize"), !0 === v.preload && g.onSearchChange("")
498        },
499        setupTemplates: function () {
500            var e = this,
501                i = e.settings.labelField,
502                n = e.settings.optgroupLabelField;
503            e.settings.render = t.extend({}, {
504                optgroup: function (t) {
505                    return '<div class="optgroup">' + t.html + "</div>"
506                },
507                optgroup_header: function (t, e) {
508                    return '<div class="optgroup-header">' + e(t[n]) + "</div>"
509                },
510                option: function (t, e) {
511                    return '<div class="option">' + e(t[i]) + "</div>"
512                },
513                item: function (t, e) {
514                    return '<div class="item">' + e(t[i]) + "</div>"
515                },
516                option_create: function (t, e) {
517                    return '<div class="create">Add <strong>' + e(t.input) + "</strong>&hellip;</div>"
518                }
519            }, e.settings.render)
520        },
521        setupCallbacks: function () {
522            var t, e, i = {
523                initialize: "onInitialize",
524                change: "onChange",
525                item_add: "onItemAdd",
526                item_remove: "onItemRemove",
527                clear: "onClear",
528                option_add: "onOptionAdd",
529                option_remove: "onOptionRemove",
530                option_clear: "onOptionClear",
531                optgroup_add: "onOptionGroupAdd",
532                optgroup_remove: "onOptionGroupRemove",
533                optgroup_clear: "onOptionGroupClear",
534                dropdown_open: "onDropdownOpen",
535                dropdown_close: "onDropdownClose",
536                type: "onType",
537                load: "onLoad",
538                focus: "onFocus",
539                blur: "onBlur"
540            };
541            for (t in i) i.hasOwnProperty(t) && (e = this.settings[i[t]]) && this.on(t, e)
542        },
543        onClick: function (t) {
544            this.isFocused && this.isOpen || (this.focus(), t.preventDefault())
545        },
546        onMouseDown: function (e) {
547            var i = this,
548                n = e.isDefaultPrevented();
549            if (t(e.target), i.isFocused) {
550                if (e.target !== i.$control_input[0]) return "single" === i.settings.mode ? i.isOpen ? i.close() : i.open() : n || i.setActiveItem(null), !1
551            } else n || window.setTimeout(function () {
552                i.focus()
553            }, 0)
554        },
555        onChange: function () {
556            this.$input.trigger("change")
557        },
558        onPaste: function (e) {
559            var i = this;
560            if (i.isFull() || i.isInputHidden || i.isLocked) return void e.preventDefault();
561            i.settings.splitOn && setTimeout(function () {
562                var e = i.$control_input.val();
563                if (e.match(i.settings.splitOn))
564                    for (var n = t.trim(e).split(i.settings.splitOn), s = 0, o = n.length; s < o; s++) i.createItem(n[s])
565            }, 0)
566        },
567        onKeyPress: function (t) {
568            if (this.isLocked) return t && t.preventDefault();
569            var e = String.fromCharCode(t.keyCode || t.which);
570            return this.settings.create && "multi" === this.settings.mode && e === this.settings.delimiter ? (this.createItem(), t.preventDefault(), !1) : void 0
571        },
572        onKeyDown: function (t) {
573            var e = (t.target, this.$control_input[0], this);
574            if (e.isLocked) return void(9 !== t.keyCode && t.preventDefault());
575            switch (t.keyCode) {
576                case 65:
577                    if (e.isCmdDown) return void e.selectAll();
578                    break;
579                case 27:
580                    return void(e.isOpen && (t.preventDefault(), t.stopPropagation(), e.close()));
581                case 78:
582                    if (!t.ctrlKey || t.altKey) break;
583                case 40:
584                    if (!e.isOpen && e.hasOptions) e.open();
585                    else if (e.$activeOption) {
586                        e.ignoreHover = !0;
587                        var i = e.getAdjacentOption(e.$activeOption, 1);
588                        i.length && e.setActiveOption(i, !0, !0)
589                    }
590                    return void t.preventDefault();
591                case 80:
592                    if (!t.ctrlKey || t.altKey) break;
593                case 38:
594                    if (e.$activeOption) {
595                        e.ignoreHover = !0;
596                        var n = e.getAdjacentOption(e.$activeOption, -1);
597                        n.length && e.setActiveOption(n, !0, !0)
598                    }
599                    return void t.preventDefault();
600                case 13:
601                    return void(e.isOpen && e.$activeOption && (e.onOptionSelect({
602                        currentTarget: e.$activeOption
603                    }), t.preventDefault()));
604                case 37:
605                    return void e.advanceSelection(-1, t);
606                case 39:
607                    return void e.advanceSelection(1, t);
608                case 9:
609                    return e.settings.selectOnTab && e.isOpen && e.$activeOption && (e.onOptionSelect({
610                        currentTarget: e.$activeOption
611                    }), e.isFull() || t.preventDefault()), void(e.settings.create && e.createItem() && t.preventDefault());
612                case 8:
613                case 46:
614                    return void e.deleteSelection(t)
615            }
616            return !e.isFull() && !e.isInputHidden || (o ? t.metaKey : t.ctrlKey) ? void 0 : void t.preventDefault()
617        },
618        onKeyUp: function (t) {
619            var e = this;
620            if (e.isLocked) return t && t.preventDefault();
621            var i = e.$control_input.val() || "";
622            e.lastValue !== i && (e.lastValue = i, e.onSearchChange(i), e.refreshOptions(), e.trigger("type", i))
623        },
624        onSearchChange: function (t) {
625            var e = this,
626                i = e.settings.load;
627            i && (e.loadedSearches.hasOwnProperty(t) || (e.loadedSearches[t] = !0, e.load(function (n) {
628                i.apply(e, [t, n])
629            })))
630        },
631        onFocus: function (t) {
632            var e = this,
633                i = e.isFocused;
634            if (e.isDisabled) return e.blur(), t && t.preventDefault(), !1;
635            e.ignoreFocus || (e.isFocused = !0, "focus" === e.settings.preload && e.onSearchChange(""), i || e.trigger("focus"), e.$activeItems.length || (e.showInput(), e.setActiveItem(null), e.refreshOptions(!!e.settings.openOnFocus)), e.refreshState())
636        },
637        onBlur: function (t, e) {
638            var i = this;
639            if (i.isFocused && (i.isFocused = !1, !i.ignoreFocus)) {
640                if (!i.ignoreBlur && document.activeElement === i.$dropdown_content[0]) return i.ignoreBlur = !0, void i.onFocus(t);
641                var n = function () {
642                    i.close(), i.setTextboxValue(""), i.setActiveItem(null), i.setActiveOption(null), i.setCaret(i.items.length), i.refreshState(), e && e.focus && e.focus(), i.isBlurring = !1, i.ignoreFocus = !1, i.trigger("blur")
643                };
644                i.isBlurring = !0, i.ignoreFocus = !0, i.settings.create && i.settings.createOnBlur ? i.createItem(null, !1, n) : n()
645            }
646        },
647        onOptionHover: function (t) {
648            this.ignoreHover || this.setActiveOption(t.currentTarget, !1)
649        },
650        onOptionSelect: function (e) {
651            var i, n, s = this;
652            e.preventDefault && (e.preventDefault(), e.stopPropagation()), (n = t(e.currentTarget)).hasClass("create") ? s.createItem(null, function () {
653                s.settings.closeAfterSelect && s.close()
654            }) : void 0 !== (i = n.attr("data-value")) && (s.lastQuery = null, s.setTextboxValue(""), s.addItem(i), s.settings.closeAfterSelect ? s.close() : !s.settings.hideSelected && e.type && /mouse/.test(e.type) && s.setActiveOption(s.getOption(i)))
655        },
656        onItemSelect: function (t) {
657            this.isLocked || "multi" === this.settings.mode && (t.preventDefault(), this.setActiveItem(t.currentTarget, t))
658        },
659        load: function (t) {
660            var e = this,
661                i = e.$wrapper.addClass(e.settings.loadingClass);
662            e.loading++, t.apply(e, [function (t) {
663                e.loading = Math.max(e.loading - 1, 0), t && t.length && (e.addOption(t), e.refreshOptions(e.isFocused && !e.isInputHidden)), e.loading || i.removeClass(e.settings.loadingClass), e.trigger("load", t)
664            }])
665        },
666        setTextboxValue: function (t) {
667            var e = this.$control_input;
668            e.val() !== t && (e.val(t).triggerHandler("update"), this.lastValue = t)
669        },
670        getValue: function () {
671            return 1 === this.tagType && this.$input.attr("multiple") ? this.items : this.items.join(this.settings.delimiter)
672        },
673        setValue: function (t, e) {
674            v(this, e ? [] : ["change"], function () {
675                this.clear(e), this.addItems(t, e)
676            })
677        },
678        setActiveItem: function (e, i) {
679            var n, s, o, r, a, l, p, u, c = this;
680            if ("single" !== c.settings.mode) {
681                if (!(e = t(e)).length) return t(c.$activeItems).removeClass("active"), c.$activeItems = [], void(c.isFocused && c.showInput());
682                if ("mousedown" === (n = i && i.type.toLowerCase()) && c.isShiftDown && c.$activeItems.length) {
683                    for (u = c.$control.children(".active:last"), (r = Array.prototype.indexOf.apply(c.$control[0].childNodes, [u[0]])) > (a = Array.prototype.indexOf.apply(c.$control[0].childNodes, [e[0]])) && (p = r, r = a, a = p), s = r; s <= a; s++) l = c.$control[0].childNodes[s], -1 === c.$activeItems.indexOf(l) && (t(l).addClass("active"), c.$activeItems.push(l));
684                    i.preventDefault()
685                } else "mousedown" === n && c.isCtrlDown || "keydown" === n && this.isShiftDown ? e.hasClass("active") ? (o = c.$activeItems.indexOf(e[0]), c.$activeItems.splice(o, 1), e.removeClass("active")) : c.$activeItems.push(e.addClass("active")[0]) : (t(c.$activeItems).removeClass("active"), c.$activeItems = [e.addClass("active")[0]]);
686                c.hideInput(), this.isFocused || c.focus()
687            }
688        },
689        setActiveOption: function (e, i, n) {
690            var s, o, r, a, l, u = this;
691            u.$activeOption && u.$activeOption.removeClass("active"), u.$activeOption = null, (e = t(e)).length && (u.$activeOption = e.addClass("active"), !i && p(i) || (s = u.$dropdown_content.height(), o = u.$activeOption.outerHeight(!0), i = u.$dropdown_content.scrollTop() || 0, a = r = u.$activeOption.offset().top - u.$dropdown_content.offset().top + i, l = r - s + o, r + o > s + i ? u.$dropdown_content.stop().animate({
692                scrollTop: l
693            }, n ? u.settings.scrollDuration : 0) : r < i && u.$dropdown_content.stop().animate({
694                scrollTop: a
695            }, n ? u.settings.scrollDuration : 0)))
696        },
697        selectAll: function () {
698            var t = this;
699            "single" !== t.settings.mode && (t.$activeItems = Array.prototype.slice.apply(t.$control.children(":not(input)").addClass("active")), t.$activeItems.length && (t.hideInput(), t.close()), t.focus())
700        },
701        hideInput: function () {
702            var t = this;
703            t.setTextboxValue(""), t.$control_input.css({
704                opacity: 0,
705                position: "absolute",
706                left: t.rtl ? 1e4 : -1e4
707            }), t.isInputHidden = !0
708        },
709        showInput: function () {
710            this.$control_input.css({
711                opacity: 1,
712                position: "relative",
713                left: 0
714            }), this.isInputHidden = !1
715        },
716        focus: function () {
717            var t = this;
718            t.isDisabled || (t.ignoreFocus = !0, t.$control_input[0].focus(), window.setTimeout(function () {
719                t.ignoreFocus = !1, t.onFocus()
720            }, 0))
721        },
722        blur: function (t) {
723            this.$control_input[0].blur(), this.onBlur(null, t)
724        },
725        getScoreFunction: function (t) {
726            return this.sifter.getScoreFunction(t, this.getSearchOptions())
727        },
728        getSearchOptions: function () {
729            var t = this.settings,
730                e = t.sortField;
731            return "string" == typeof e && (e = [{
732                field: e
733            }]), {
734                fields: t.searchField,
735                conjunction: t.searchConjunction,
736                sort: e,
737                nesting: t.nesting
738            }
739        },
740        search: function (e) {
741            var i, n, s, o = this,
742                r = o.settings,
743                a = this.getSearchOptions();
744            if (r.score && "function" != typeof (s = o.settings.score.apply(this, [e]))) throw Error('Selectize "score" setting must be a function that returns a function');
745            if (e !== o.lastQuery ? (o.lastQuery = e, n = o.sifter.search(e, t.extend(a, {
746                    score: s
747                })), o.currentResults = n) : n = t.extend(!0, {}, o.currentResults), r.hideSelected)
748                for (i = n.items.length - 1; i >= 0; i--) - 1 !== o.items.indexOf(u(n.items[i].id)) && n.items.splice(i, 1);
749            return n
750        },
751        refreshOptions: function (e) {
752            void 0 === e && (e = !0);
753            var i, s, o, r, a, l, p, c, d, h, f, g, v, m, y, O, C = this,
754                b = t.trim(C.$control_input.val()),
755                _ = C.search(b),
756                x = C.$dropdown_content,
757                I = C.$activeOption && u(C.$activeOption.attr("data-value"));
758            for (r = _.items.length, "number" == typeof C.settings.maxOptions && (r = Math.min(r, C.settings.maxOptions)), a = {}, l = [], i = 0; i < r; i++)
759                for (p = C.options[_.items[i].id], c = C.render("option", p), d = p[C.settings.optgroupField] || "", h = t.isArray(d) ? d : [d], s = 0, o = h && h.length; s < o; s++) d = h[s], C.optgroups.hasOwnProperty(d) || (d = ""), a.hasOwnProperty(d) || (a[d] = document.createDocumentFragment(), l.push(d)), a[d].appendChild(c);
760            for (this.settings.lockOptgroupOrder && l.sort(function (t, e) {
761                    return (C.optgroups[t].$order || 0) - (C.optgroups[e].$order || 0)
762                }), f = document.createDocumentFragment(), i = 0, r = l.length; i < r; i++) d = l[i], C.optgroups.hasOwnProperty(d) && a[d].childNodes.length ? ((g = document.createDocumentFragment()).appendChild(C.render("optgroup_header", C.optgroups[d])), g.appendChild(a[d]), f.appendChild(C.render("optgroup", t.extend({}, C.optgroups[d], {
763                html: w(g),
764                dom: g
765            })))) : f.appendChild(a[d]);
766            if (x.html(f), C.settings.highlight && (x.removeHighlight(), _.query.length && _.tokens.length))
767                for (i = 0, r = _.tokens.length; i < r; i++) n(x, _.tokens[i].regex);
768            if (!C.settings.hideSelected)
769                for (i = 0, r = C.items.length; i < r; i++) C.getOption(C.items[i]).addClass("selected");
770            (v = C.canCreate(b)) && (x.prepend(C.render("option_create", {
771                input: b
772            })), O = t(x[0].childNodes[0])), C.hasOptions = _.items.length > 0 || v, C.hasOptions ? (_.items.length > 0 ? ((y = I && C.getOption(I)) && y.length ? m = y : "single" === C.settings.mode && C.items.length && (m = C.getOption(C.items[0])), m && m.length || (m = O && !C.settings.addPrecedence ? C.getAdjacentOption(O, 1) : x.find("[data-selectable]:first"))) : m = O, C.setActiveOption(m), e && !C.isOpen && C.open()) : (C.setActiveOption(null), e && C.isOpen && C.close())
773        },
774        addOption: function (e) {
775            var i, n, s, o = this;
776            if (t.isArray(e))
777                for (i = 0, n = e.length; i < n; i++) o.addOption(e[i]);
778            else(s = o.registerOption(e)) && (o.userOptions[s] = !0, o.lastQuery = null, o.trigger("option_add", s, e))
779        },
780        registerOption: function (t) {
781            var e = u(t[this.settings.valueField]);
782            return null != e && !this.options.hasOwnProperty(e) && (t.$order = t.$order || ++this.order, this.options[e] = t, e)
783        },
784        registerOptionGroup: function (t) {
785            var e = u(t[this.settings.optgroupValueField]);
786            return !!e && (t.$order = t.$order || ++this.order, this.optgroups[e] = t, e)
787        },
788        addOptionGroup: function (t, e) {
789            e[this.settings.optgroupValueField] = t, (t = this.registerOptionGroup(e)) && this.trigger("optgroup_add", t, e)
790        },
791        removeOptionGroup: function (t) {
792            this.optgroups.hasOwnProperty(t) && (delete this.optgroups[t], this.renderCache = {}, this.trigger("optgroup_remove", t))
793        },
794        clearOptionGroups: function () {
795            this.optgroups = {}, this.renderCache = {}, this.trigger("optgroup_clear")
796        },
797        updateOption: function (e, i) {
798            var n, s, o, r, a, l, p, c = this;
799            if (e = u(e), o = u(i[c.settings.valueField]), null !== e && c.options.hasOwnProperty(e)) {
800                if ("string" != typeof o) throw Error("Value must be set in option data");
801                p = c.options[e].$order, o !== e && (delete c.options[e], -1 !== (r = c.items.indexOf(e)) && c.items.splice(r, 1, o)), i.$order = i.$order || p, c.options[o] = i, a = c.renderCache.item, l = c.renderCache.option, a && (delete a[e], delete a[o]), l && (delete l[e], delete l[o]), -1 !== c.items.indexOf(o) && (n = c.getItem(e), s = t(c.render("item", i)), n.hasClass("active") && s.addClass("active"), n.replaceWith(s)), c.lastQuery = null, c.isOpen && c.refreshOptions(!1)
802            }
803        },
804        removeOption: function (t, e) {
805            var i = this;
806            t = u(t);
807            var n = i.renderCache.item,
808                s = i.renderCache.option;
809            n && delete n[t], s && delete s[t], delete i.userOptions[t], delete i.options[t], i.lastQuery = null, i.trigger("option_remove", t), i.removeItem(t, e)
810        },
811        clearOptions: function () {
812            var e = this;
813            e.loadedSearches = {}, e.userOptions = {}, e.renderCache = {};
814            var i = e.options;
815            t.each(e.options, function (t, n) {
816                -1 == e.items.indexOf(t) && delete i[t]
817            }
817), e.options = e.sifter.items = i, e.lastQuery = null, e.trigger("option_clear")
818        },
819        getOption: function (t) {
820            return this.getElementWithValue(t, this.$dropdown_content.find("[data-selectable]"))
821        },
822        getAdjacentOption: function (e, i) {
823            var n = this.$dropdown.find("[data-selectable]"),
824                s = n.index(e) + i;
825            return s >= 0 && s < n.length ? n.eq(s) : t()
826        },
827        getElementWithValue: function (e, i) {
828            if (void 0 !== (e = u(e)) && null !== e) {
829                for (var n = 0, s = i.length; n < s; n++)
830                    if (i[n].getAttribute("data-value") === e) return t(i[n])
831            }
832            return t()
833        },
834        getItem: function (t) {
835            return this.getElementWithValue(t, this.$control.children())
836        },
837        addItems: function (e, i) {
838            this.buffer = document.createDocumentFragment();
839            for (var n = this.$control[0].childNodes, s = 0; s < n.length; s++) this.buffer.appendChild(n[s]);
840            for (var o = t.isArray(e) ? e : [e], s = 0, r = o.length; s < r; s++) this.isPending = s < r - 1, this.addItem(o[s], i);
841            var a = this.$control[0];
842            a.insertBefore(this.buffer, a.firstChild), this.buffer = null
843        },
844        addItem: function (e, i) {
845            v(this, i ? [] : ["change"], function () {
846                var n, s, o, r, a, l = this.settings.mode;
847                if (e = u(e), -1 !== this.items.indexOf(e)) return void("single" === l && this.close());
848                this.options.hasOwnProperty(e) && ("single" === l && this.clear(i), "multi" === l && this.isFull() || (n = t(this.render("item", this.options[e])), a = this.isFull(), this.items.splice(this.caretPos, 0, e), this.insertAtCaret(n), (!this.isPending || !a && this.isFull()) && this.refreshState(), this.isSetup && (o = this.$dropdown_content.find("[data-selectable]"), this.isPending || (s = this.getOption(e), r = this.getAdjacentOption(s, 1).attr("data-value"), this.refreshOptions(this.isFocused && "single" !== l), r && this.setActiveOption(this.getOption(r))), !o.length || this.isFull() ? this.close() : this.isPending || this.positionDropdown(), this.updatePlaceholder(), this.trigger("item_add", e, n), this.isPending || this.updateOriginalInput({
849                    silent: i
850                }))))
851            })
852        },
853        removeItem: function (e, i) {
854            var n, s, o, r = this;
855            e = u((n = e instanceof t ? e : r.getItem(e)).attr("data-value")), -1 !== (s = r.items.indexOf(e)) && (n.remove(), n.hasClass("active") && (o = r.$activeItems.indexOf(n[0]), r.$activeItems.splice(o, 1)), r.items.splice(s, 1), r.lastQuery = null, !r.settings.persist && r.userOptions.hasOwnProperty(e) && r.removeOption(e, i), s < r.caretPos && r.setCaret(r.caretPos - 1), r.refreshState(), r.updatePlaceholder(), r.updateOriginalInput({
856                silent: i
857            }), r.positionDropdown(), r.trigger("item_remove", e, n))
858        },
859        createItem: function (e, i) {
860            var n = this,
861                s = n.caretPos;
862            e = e || t.trim(n.$control_input.val() || "");
863            var o = arguments[arguments.length - 1];
864            if ("function" != typeof o && (o = function () {}), "boolean" != typeof i && (i = !0), !n.canCreate(e)) return o(), !1;
865            n.lock();
866            var r = "function" == typeof n.settings.create ? this.settings.create : function (t) {
867                    var e = {};
868                    return e[n.settings.labelField] = t, e[n.settings.valueField] = t, e
869                },
870                a = f(function (t) {
871                    if (n.unlock(), !t || "object" != typeof t) return o();
872                    var e = u(t[n.settings.valueField]);
873                    if ("string" != typeof e) return o();
874                    n.setTextboxValue(""), n.addOption(t), n.setCaret(s), n.addItem(e), n.refreshOptions(i && "single" !== n.settings.mode), o(t)
875                }),
876                l = r.apply(this, [e, a]);
877            return void 0 !== l && a(l), !0
878        },
879        refreshItems: function () {
880            this.lastQuery = null, this.isSetup && this.addItem(this.items), this.refreshState(), this.updateOriginalInput()
881        },
882        refreshState: function () {
883            this.refreshValidityState(), this.refreshClasses()
884        },
885        refreshValidityState: function () {
886            if (!this.isRequired) return !1;
887            var t = !this.items.length;
888            this.isInvalid = t, this.$control_input.prop("required", t), this.$input.prop("required", !t)
889        },
890        refreshClasses: function () {
891            var e = this.isFull(),
892                i = this.isLocked;
893            this.$wrapper.toggleClass("rtl", this.rtl), this.$control.toggleClass("focus", this.isFocused).toggleClass("disabled", this.isDisabled).toggleClass("required", this.isRequired).toggleClass("invalid", this.isInvalid).toggleClass("locked", i).toggleClass("full", e).toggleClass("not-full", !e).toggleClass("input-active", this.isFocused && !this.isInputHidden).toggleClass("dropdown-active", this.isOpen).toggleClass("has-options", !t.isEmptyObject(this.options)).toggleClass("has-items", this.items.length > 0), this.$control_input.data("grow", !e && !i)
894        },
895        isFull: function () {
896            return null !== this.settings.maxItems && this.items.length >= this.settings.maxItems
897        },
898        updateOriginalInput: function (t) {
899            var e, i, n, s;
900            if (t = t || {}, 1 === this.tagType) {
901                for (n = [], e = 0, i = this.items.length; e < i; e++) s = this.options[this.items[e]][this.settings.labelField] || "", n.push('<option value="' + c(this.items[e]) + '" selected="selected">' + c(s) + "</option>");
902                n.length || this.$input.attr("multiple") || n.push('<option value="" selected="selected"></option>'), this.$input.html(n.join(""))
903            } else this.$input.val(this.getValue()), this.$input.attr("value", this.$input.val());
904            this.isSetup && (t.silent || this.trigger("change", this.$input.val()))
905        },
906        updatePlaceholder: function () {
907            if (this.settings.placeholder) {
908                var t = this.$control_input;
909                this.items.length ? t.removeAttr("placeholder") : t.attr("placeholder", this.settings.placeholder), t.triggerHandler("update", {
910                    force: !0
911                })
912            }
913        },
914        open: function () {
915            var t = this;
916            t.isLocked || t.isOpen || "multi" === t.settings.mode && t.isFull() || (t.focus(), t.isOpen = !0, t.refreshState(), t.$dropdown.css({
917                visibility: "hidden",
918                display: "block"
919            }), t.positionDropdown(), t.$dropdown.css({
920                visibility: "visible"
921            }), t.trigger("dropdown_open", t.$dropdown))
922        },
923        close: function () {
924            var t = this,
925                e = t.isOpen;
926            "single" === t.settings.mode && t.items.length && (t.hideInput(), t.isBlurring || t.$control_input.blur()), t.isOpen = !1, t.$dropdown.hide(), t.setActiveOption(null), t.refreshState(), e && t.trigger("dropdown_close", t.$dropdown)
927        },
928        positionDropdown: function () {
929            var t = this.$control,
930                e = "body" === this.settings.dropdownParent ? t.offset() : t.position();
931            e.top += t.outerHeight(!0), this.$dropdown.css({
932                width: t[0].getBoundingClientRect().width,
933                top: e.top,
934                left: e.left
935            })
936        },
937        clear: function (t) {
938            var e = this;
939            e.items.length && (e.$control.children(":not(input)").remove(), e.items = [], e.lastQuery = null, e.setCaret(0), e.setActiveItem(null), e.updatePlaceholder(), e.updateOriginalInput({
940                silent: t
941            }), e.refreshState(), e.showInput(), e.trigger("clear"))
942        },
943        insertAtCaret: function (t) {
944            var e = Math.min(this.caretPos, this.items.length),
945                i = t[0],
946                n = this.buffer || this.$control[0];
947            0 === e ? n.insertBefore(i, n.firstChild) : n.insertBefore(i, n.childNodes[e]), this.setCaret(e + 1)
948        },
949        deleteSelection: function (e) {
950            var i, n, s, o, r, a, l, p, u;
951            if (s = e && 8 === e.keyCode ? -1 : 1, o = y(this.$control_input[0]), this.$activeOption && !this.settings.hideSelected && (l = this.getAdjacentOption(this.$activeOption, -1).attr("data-value")), r = [], this.$activeItems.length) {
952                for (u = this.$control.children(".active:" + (s > 0 ? "last" : "first")), a = this.$control.children(":not(input)").index(u), s > 0 && a++, i = 0, n = this.$activeItems.length; i < n;
952 i++) r.push(t(this.$activeItems[i]).attr("data-value"));
953                e && (e.preventDefault(), e.stopPropagation())
954            } else(this.isFocused || "single" === this.settings.mode) && this.items.length && (s < 0 && 0 === o.start && 0 === o.length ? r.push(this.items[this.caretPos - 1]) : s > 0 && o.start === this.$control_input.val().length && r.push(this.items[this.caretPos]));
955            if (!r.length || "function" == typeof this.settings.onDelete && !1 === this.settings.onDelete.apply(this, [r])) return !1;
956            for (void 0 !== a && this.setCaret(a); r.length;) this.removeItem(r.pop());
957            return this.showInput(), this.positionDropdown(), this.refreshOptions(!0), l && (p = this.getOption(l)).length && this.setActiveOption(p), !0
958        },
959        advanceSelection: function (t, e) {
960            var i, n, s, o, r;
961            0 !== t && (this.rtl && (t *= -1), i = t > 0 ? "last" : "first", n = y(this.$control_input[0]), this.isFocused && !this.isInputHidden ? (o = this.$control_input.val().length, (t < 0 ? 0 !== n.start || 0 !== n.length : n.start !== o) || o || this.advanceCaret(t, e)) : (r = this.$control.children(".active:" + i)).length && (s = this.$control.children(":not(input)").index(r), this.setActiveItem(null), this.setCaret(t > 0 ? s + 1 : s)))
962        },
963        advanceCaret: function (t, e) {
964            var i, n;
965            0 !== t && (i = t > 0 ? "next" : "prev", this.isShiftDown ? (n = this.$control_input[i]()).length && (this.hideInput(), this.setActiveItem(n), e && e.preventDefault()) : this.setCaret(this.caretPos + t))
966        },
967        setCaret: function (e) {
968            var i, n, s, o, r = this;
969            if (e = "single" === r.settings.mode ? r.items.length : Math.max(0, Math.min(r.items.length, e)), !r.isPending)
970                for (s = r.$control.children(":not(input)"), i = 0, n = s.length; i < n; i++) o = t(s[i]).detach(), i < e ? r.$control_input.before(o) : r.$control.append(o);
971            r.caretPos = e
972        },
973        lock: function () {
974            this.close(), this.isLocked = !0, this.refreshState()
975        },
976        unlock: function () {
977            this.isLocked = !1, this.refreshState()
978        },
979        disable: function () {
980            var t = this;
981            t.$input.prop("disabled", !0), t.$control_input.prop("disabled", !0).prop("tabindex", -1), t.isDisabled = !0, t.lock()
982        },
983        enable: function () {
984            var t = this;
985            t.$input.prop("disabled", !1), t.$control_input.prop("disabled", !1).prop("tabindex", t.tabIndex), t.isDisabled = !1, t.unlock()
986        },
987        destroy: function () {
988            var e = this.eventNS,
989                i = this.revertSettings;
990            this.trigger("destroy"), this.off(), this.$wrapper.remove(), this.$dropdown.remove(), this.$input.html("").append(i.$children).removeAttr("tabindex").removeClass("selectized").attr({
991                tabindex: i.tabindex
992            }).show(), this.$control_input.removeData("grow"), this.$input.removeData("selectize"), 0 == --b.count && b.$testInput && (b.$testInput.remove(), b.$testInput = void 0), t(window).off(e), t(document).off(e), t(document.body).off(e), delete this.$input[0].selectize
993        },
994        render: function (e, i) {
995            var n, s, o = "",
996                r = !1,
997                a = this;
998            return "option" !== e && "item" !== e || (r = !!(n = u(i[a.settings.valueField]))), r && (p(a.renderCache[e]) || (a.renderCache[e] = {}), a.renderCache[e].hasOwnProperty(n)) ? a.renderCache[e][n] : (o = t(a.settings.render[e].apply(this, [i, c])), "option" === e || "option_create" === e ? i[a.settings.disabledField] || o.attr("data-selectable", "") : "optgroup" === e && (s = i[a.settings.optgroupValueField] || "", o.attr("data-group", s), i[a.settings.disabledField] && o.attr("data-disabled", "")), "option" !== e && "item" !== e || o.attr("data-value", n || ""), r && (a.renderCache[e][n] = o[0]), o[0])
999        },
1000        clearCache: function (t) {
1001            var e = this;
1002            void 0 === t ? e.renderCache = {} : delete e.renderCache[t]
1003        },
1004        canCreate: function (t) {
1005            if (!this.settings.create) return !1;
1006            var e = this.settings.createFilter;
1007            return t.length && ("function" != typeof e || e.apply(this, [t])) && ("string" != typeof e || RegExp(e).test(t)) && (!(e instanceof RegExp) || e.test(t))
1008        }
1009    }), b.count = 0, b.defaults = {
1010        options: [],
1011        optgroups: [],
1012        plugins: [],
1013        delimiter: ",",
1014        splitOn: null,
1015        persist: !0,
1016        diacritics: !0,
1017        create: !1,
1018        createOnBlur: !1,
1019        createFilter: null,
1020        highlight: !0,
1021        openOnFocus: !0,
1022        maxOptions: 1e3,
1023        maxItems: null,
1024        hideSelected: null,
1025        addPrecedence: !1,
1026        selectOnTab: !1,
1027        preload: !1,
1028        allowEmptyOption: !1,
1029        closeAfterSelect: !1,
1030        scrollDuration: 60,
1031        loadThrottle: 300,
1032        loadingClass: "loading",
1033        dataAttr: "data-data",
1034        optgroupField: "optgroup",
1035        valueField: "value",
1036        labelField: "text",
1037        disabledField: "disabled",
1038        optgroupLabelField: "label",
1039        optgroupValueField: "value",
1040        lockOptgroupOrder: !1,
1041        sortField: "$order",
1042        searchField: ["text"],
1043        searchConjunction: "and",
1044        mode: null,
1045        wrapperClass: "selectize-control",
1046        inputClass: "selectize-input",
1047        dropdownClass: "selectize-dropdown",
1048        dropdownContentClass: "selectize-dropdown-content",
1049        dropdownParent: null,
1050        copyClassesToDropdown: !0,
1051        render: {}
1052    }, t.fn.selectize = function (e) {
1053        var i = t.fn.selectize.defaults,
1054            n = t.extend({}, i, e),
1055            s = n.dataAttr,
1056            o = n.labelField,
1057            r = n.valueField,
1058            a = n.disabledField,
1059            l = n.optgroupField,
1060            p = n.optgroupLabelField,
1061            c = n.optgroupValueField,
1062            d = function (e, i) {
1063                var a, l, p, u, c = e.attr(s);
1064                if (c)
1065                    for (i.options = JSON.parse(c), a = 0, l = i.options.length; a < l; a++) i.items.push(i.options[a][r]);
1066                else {
1067                    var d = t.trim(e.val() || "");
1068                    if (!n.allowEmptyOption && !d.length) return;
1069                    for (p = d.split(n.delimiter), a = 0, l = p.length; a < l; a++)(u = {})[o] = p[a], u[r] = p[a], i.options.push(u);
1070                    i.items = p
1071                }
1072            },
1073            h = function (e, i) {
1074                var d, h, f, g, v = i.options,
1075                    m = {},
1076                    y = function (t) {
1077                        var e = s && t.attr(s);
1078                        return "string" == typeof e && e.length ? JSON.parse(e) : null
1079                    },
1080                    O = function (e, s) {
1081                        e = t(e);
1082                        var p = u(e.val());
1083                        if (p || n.allowEmptyOption) {
1084                            if (m.hasOwnProperty(p)) {
1085                                if (s) {
1086                                    var c = m[p][l];
1087                                    c ? t.isArray(c) ? c.push(s) : m[p][l] = [c, s] : m[p][l] = s
1088                                }
1089                            } else {
1090                                var d = y(e) || {};
1091                                d[o] = d[o] || e.text(), d[r] = d[r] || p, d[a] = d[a] || e.prop("disabled"), d[l] = d[l] || s, m[p] = d, v.push(d), e.is(":selected") && i.items.push(p)
1092                            }
1093                        }
1094                    };
1095                for (i.maxItems = e.attr("multiple") ? null : 1, g = e.children(), d = 0, h = g.length; d < h; d++) "optgroup" === (f = g[d].tagName.toLowerCase()) ? function (e) {
1096                    var n, s, o, r, l;
1097                    for ((o = (e = t(e)).attr("label")) && ((r = y(e) || {})[p] = o, r[c] = o, r[a] = e.prop("disabled"), i.optgroups.push(r)), l = t("option", e), n = 0, s = l.length; n < s; n++) O(l[n], o)
1098                }(g[d]) : "option" === f && O(g[d])
1099            };
1100        return this.each(function () {
1101            if (!this.selectize) {
1102                var s = t(this),
1103                    o = this.tagName.toLowerCase(),
1104                    r = s.attr("placeholder") || s.attr("data-placeholder");
1105                r || n.allowEmptyOption || (r = s.children('option[value=""]').text());
1106                var a = {
1107                    placeholder: r,
1108                    options: [],
1109                    optgroups: [],
1110                    items: []
1111                };
1112                "select" === o ? h(s, a) : d(s, a), new b(s, t.extend(!0, {}, i, a, e))
1113            }
1114        })
1115    }, t.fn.selectize.defaults = b.defaults, t.fn.selectize.support = {
1116        validity: l
1117    }, b.define("drag_drop", function (e) {
1118        if (!t.fn.sortable) throw Error('The "drag_drop" plugin requires jQuery UI "sortable".');
1119        if ("multi" === this.settings.mode) {
1120            var i, n, s, o = this;
1121            o.lock = (i = o.lock, function () {
1122                var t = o.$control.data("sortable");
1123                return t && t.disable(), i.apply(o, arguments)
1124            }), o.unlock = (n = o.unlock, function () {
1125                var t = o.$control.data("sortable");
1126                return t && t.enable(), n.apply(o, arguments)
1127            }), o.setup = (s = o.setup, function () {
1128                s.apply(this, arguments);
1129                var e = o.$control.sortable({
1130                    items: "[data-value]",
1131                    forcePlaceholderSize: !0,
1132                    disabled: o.isLocked,
1133                    start: function (t, i) {
1134                        i.placeholder.css("width", i.helper.css("width")), e.css({
1135                            overflow: "visible"
1136                        })
1137                    },
1138                    stop: function () {
1139                        e.css({
1140                            overflow: "hidden"
1141                        });
1142                        var i = o.$activeItems ? o.$activeItems.slice() : null,
1143                            n = [];
1144                        e.children("[data-value]").each(function () {
1145                            n.push(t(this).attr("data-value"))
1146                        }), o.setValue(n), o.setActiveItem(i)
1147                    }
1148                })
1149            })
1150        }
1151    }), b.define("dropdown_header", function (e) {
1152        var i, n = this;
1153        e = t.extend({
1154            title: "Untitled",
1155            headerClass: "selectize-dropdown-header",
1156            titleRowClass: "selectize-dropdown-header-title",
1157            labelClass: "selectize-dropdown-header-label",
1158            closeClass: "selectize-dropdown-header-close",
1159            html: function (t) {
1160                return '<div class="' + t.headerClass + '"><div class="' + t.titleRowClass + '"><span class="' + t.labelClass + '">' + t.title + '</span><a href="javascript:void(0)" class="' + t.closeClass + '">&times;</a></div></div>'
1161            }
1162        }, e), n.setup = (i = n.setup, function () {
1163            i.apply(n, arguments), n.$dropdown_header = t(e.html(e)), n.$dropdown.prepend(n.$dropdown_header)
1164        })
1165    }), b.define("optgroup_columns", function (e) {
1166        var i, n = this;
1167        e = t.extend({
1168            equalizeWidth: !0,
1169            equalizeHeight: !0
1170        }, e), this.getAdjacentOption = function (e, i) {
1171            var n = e.closest("[data-group]").find("[data-selectable]"),
1172                s = n.index(e) + i;
1173            return s >= 0 && s < n.length ? n.eq(s) : t()
1174        }, this.onKeyDown = (i = n.onKeyDown, function (t) {
1175            var e, s, o, r;
1176            return this.isOpen && (37 === t.keyCode || 39 === t.keyCode) ? (n.ignoreHover = !0, e = (r = this.$activeOption.closest("[data-group]")).find("[data-selectable]").index(this.$activeOption), void((s = (o = (r = 37 === t.keyCode ? r.prev("[data-group]") : r.next("[data-group]")).find("[data-selectable]")).eq(Math.min(o.length - 1, e))).length && this.setActiveOption(s))) : i.apply(this, arguments)
1177        });
1178        var s = function () {
1179                var t, e = s.width,
1180                    i = document;
1181                return void 0 === e && ((t = i.createElement("div")).innerHTML = '<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>', t = t.firstChild, i.body.appendChild(t), e = s.width = t.offsetWidth - t.clientWidth, i.body.removeChild(t)), e
1182            },
1183            o = function () {
1184                var i, o, r, a, l, p, u;
1185                if ((o = (u = t("[data-group]", n.$dropdown_content)).length) && n.$dropdown_content.width()) {
1186                    if (e.equalizeHeight) {
1187                        for (r = 0, i = 0; i < o; i++) r = Math.max(r, u.eq(i).height());
1188                        u.css({
1189                            height: r
1190                        })
1191                    }
1192                    e.equalizeWidth && (a = Math.round((p = n.$dropdown_content.innerWidth() - s()) / o), u.css({
1193                        width: a
1194                    }), o > 1 && (l = p - a * (o - 1), u.eq(o - 1).css({
1195                        width: l
1196                    })))
1197                }
1198            };
1199        (e.equalizeHeight || e.equalizeWidth) && (d.after(this, "positionDropdown", o), d.after(this, "refreshOptions", o))
1200    }), b.define("remove_button", function (e) {
1201        var i, n, s, o, r, a, l, p, u, d, h;
1202        if (e = t.extend({
1203                label: "&times;",
1204                title: "Remove",
1205                className: "remove",
1206                append: !0
1207            }, e), "single" === this.settings.mode) return void(i = this, (n = e).className = "remove-single", s = i, o = '<a href="javascript:void(0)" class="' + n.className + '" tabindex="-1" title="' + c(n.title) + '">' + n.label + "</a>", void(i.setup = (r = s.setup, function () {
1208            if (n.append) {
1209                var e = t(s.$input.context).attr("id"),
1210                    a = (t("#" + e), s.settings.render.item);
1211                s.settings.render.item = function (e) {
1212                    var n, s;
1213                    return n = a.apply(i, arguments), s = o, t("<span>").append(n).append(s)
1214                }
1215            }
1216            r.apply(i, arguments), i.$control.on("click", "." + n.className, function (t) {
1217                t.preventDefault(), s.isLocked || s.clear()
1218            })
1219        })));
1220        a = this, l = e, p = a, u = '<a href="javascript:void(0)" class="' + l.className + '" tabindex="-1" title="' + c(l.title) + '">' + l.label + "</a>", d = function (t, e) {
1221            var i = t.search(/(<\/[^>]+>\s*)$/);
1222            return t.substring(0, i) + e + t.substring(i)
1223        }, a.setup = (h = p.setup, function () {
1224            if (l.append) {
1225                var e = p.settings.render.item;
1226                p.settings.render.item = function (t) {
1227                    return d(e.apply(a, arguments), u)
1228                }
1229            }
1230            h.apply(a, arguments), a.$control.on("click", "." + l.className, function (e) {
1231                if (e.preventDefault(), !p.isLocked) {
1232                    var i = t(e.currentTarget).parent();
1233                    p.setActiveItem(i), p.deleteSelection() && p.setCaret(p.items.length)
1234                }
1235            })
1236        })
1237    }), b.define("restore_on_backspace", function (t) {
1238        var e;
1239        t.text = t.text || function (t) {
1240            return t[this.settings.labelField]
1241        }, this.onKeyDown = (e = this.onKeyDown, function (i) {
1242            var n, s;
1243            return 8 === i.keyCode && "" === this.$control_input.val() && !this.$activeItems.length && (n = this.caretPos - 1) >= 0 && n < this.items.length ? (s = this.options[this.items[n]], this.deleteSelection(i) && (this.setTextboxValue(t.text.apply(this, [s])), this.refreshOptions(!0)), void i.preventDefault()) : e.apply(this, arguments)
1244        })
1245    }), b
1246});

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.